Hello community,

here is the log from the commit of package usb_modeswitch for openSUSE:Factory 
checked in at 2017-02-14 00:35:51
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/usb_modeswitch (Old)
 and      /work/SRC/openSUSE:Factory/.usb_modeswitch.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "usb_modeswitch"

Changes:
--------
--- /work/SRC/openSUSE:Factory/usb_modeswitch/usb_modeswitch.changes    
2016-09-17 14:38:07.000000000 +0200
+++ /work/SRC/openSUSE:Factory/.usb_modeswitch.new/usb_modeswitch.changes       
2017-02-14 00:35:53.572189468 +0100
@@ -1,0 +2,28 @@
+Sat Jan 28 22:39:32 UTC 2017 - joerg.loren...@ki.tng.de
+
+- Update to version 2.5.0
+  * ATTENTION: Parameter transmitted from udev now reduced to %k
+    (kernel name), however, rules file parameters can be '%b/%k' or
+    '%k' - this fixes issues with parameter handling by the systemd
+    unit file.
+  * Remove endpoint reset ahead of bulk message transmission, only
+    reset if endpoints are actually stalled, helping with quirky
+    device behaviour (see www.draisberghof.de/usb_modeswitch/bb/
+    viewtopic.php?f=2&t=2582 ).
+  * Stability fix by making a buffer in the config parser static,
+    preventing problems seen in Fedora (thanks to Lubomir Rintel
+    for patches and hints regarding the three previous issues).
+  * Removed premature driver unbinding in wrapper which could
+    disrupt certain devices already in target mode (reported by
+    Aleksander Morgado).
+  * Improved check for determining install mode (essential with
+    generic config files present, e.g. 12d1:#linux).
+- Update usb-modeswitch-data package to version 20170120.
+
+-------------------------------------------------------------------
+Fri Oct 28 14:33:42 UTC 2016 - joerg.loren...@ki.tng.de
+
+- Update usb-modeswitch-data package to version 20160803.
+- Added systemd as BuildRequires and fixed install of service file.
+
+-------------------------------------------------------------------

Old:
----
  usb-modeswitch-2.4.0.tar.bz2
  usb-modeswitch-data-20160612.tar.bz2

New:
----
  usb-modeswitch-2.5.0.tar.bz2
  usb-modeswitch-data-20170120.tar.bz2

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ usb_modeswitch.spec ++++++
--- /var/tmp/diff_new_pack.6cAkSm/_old  2017-02-14 00:35:54.572048304 +0100
+++ /var/tmp/diff_new_pack.6cAkSm/_new  2017-02-14 00:35:54.576047739 +0100
@@ -1,7 +1,7 @@
 #
 # spec file for package usb_modeswitch
 #
-# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -17,10 +17,10 @@
 
 
 %define source_name    usb-modeswitch
-%define date           20160612
+%define date           20170120
 %define _udevdir %(pkg-config --variable=udevdir udev)
 Name:           usb_modeswitch
-Version:        2.4.0
+Version:        2.5.0
 Release:        0
 Summary:        A mode switching tool for controlling multiple-device USB gear
 License:        GPL-2.0+
@@ -35,6 +35,8 @@
 BuildRequires:  tcl
 BuildRequires:  pkgconfig(libusb-1.0)
 BuildRequires:  pkgconfig(udev)
+BuildRequires:  systemd
+%{?systemd_requires}
 Requires:       tcl >= 8.4
 Requires:       usb_modeswitch-data = %{version}
 BuildRoot:      %{_tmppath}/%{name}-%{version}-build
@@ -68,7 +70,7 @@
 # The install target recreates usb_modeswitch_dispatcher, which is racy in 
respect to its
 # installation. install-common just uses the file from the build phase. 
boo#998641
 make DESTDIR=%{buildroot} install-common %{?_smp_mflags} 
UDEVDIR=%{buildroot}%{_udevdir}
-install --mode=444 -D -t %{buildroot}%{_unitdir} usb_modeswitch@.service
+install -Dm 444 usb_modeswitch@.service 
%{buildroot}%{_unitdir}/usb_modeswitch@.service
 
 cd %{source_name}-data-%{date}
 make DESTDIR=%{buildroot} install %{?_smp_mflags} 
RULESDIR=%{buildroot}%{_udevdir}/rules.d

++++++ usb-modeswitch-2.4.0.tar.bz2 -> usb-modeswitch-2.5.0.tar.bz2 ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/usb-modeswitch-2.4.0/ChangeLog 
new/usb-modeswitch-2.5.0/ChangeLog
--- old/usb-modeswitch-2.4.0/ChangeLog  2016-06-12 14:08:36.000000000 +0200
+++ new/usb-modeswitch-2.5.0/ChangeLog  2017-01-17 19:22:01.000000000 +0100
@@ -2,6 +2,19 @@
 History of USB_ModeSwitch
 =========================
 
+Version 2.5.0, 2017/01/17
+    ATTENTION: Parameter transmitted from udev now reduced to %k (kernel
+    name), however, rules file parameters can be '%b/%k' or '%k' - this
+    fixes issues with parameter handling by the systemd unit file;
+    remove endpoint reset ahead of bulk message transmission, only reset
+    if endpoints are actually stalled, helping with quirky device behaviour
+    (see www.draisberghof.de/usb_modeswitch/bb/viewtopic.php?f=2&t=2582 );
+    stability fix by making a buffer in the config parser static, preventing
+    problems seen in Fedora (thanks to Lubomir Rintel for patches and hints
+    regarding the three previous issues); removed premature driver unbinding
+    in wrapper which could disrupt certain devices already in target mode
+    (reported by Aleksander Morgado); improved check for determining install
+    mode (essential with generic config files present, e.g. 12d1:#linux)
 Version 2.4.0, 2016/06/12
     ATTENTION: All ad-hoc driver binding code (using new_id driver attribute)
     removed - was a potential source of side effects and should now be
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/usb-modeswitch-2.4.0/Makefile 
new/usb-modeswitch-2.5.0/Makefile
--- old/usb-modeswitch-2.4.0/Makefile   2016-06-12 10:13:53.000000000 +0200
+++ new/usb-modeswitch-2.5.0/Makefile   2017-01-16 22:15:46.000000000 +0100
@@ -1,5 +1,5 @@
 PROG        = usb_modeswitch
-VERS        = 2.4.0
+VERS        = 2.5.0
 CC          ?= gcc
 CFLAGS      += -Wall
 LIBS        = `pkg-config --libs --cflags libusb-1.0`
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/usb-modeswitch-2.4.0/README 
new/usb-modeswitch-2.5.0/README
--- old/usb-modeswitch-2.4.0/README     2016-06-12 22:33:35.000000000 +0200
+++ new/usb-modeswitch-2.5.0/README     2017-01-17 20:39:16.000000000 +0100
@@ -50,8 +50,8 @@
 and rules - and doing the mode switch without any user interaction.
 However, the core C program should be as portable als libusb itself; it does 
not
 rely on specific Linux features.
-It can also be run as an interactive command line tool, particularly useful 
when
-trying to tinker with hitherto unknown devices.
+It can also be run as an interactive command line tool, which can be useful
+when trying to tinker with hitherto unknown devices.
 
 We have already collected a wide range of information on how to mode-switch all
 sorts of devices. If you run into a new one that is unknown yet, don't despair:
@@ -110,8 +110,8 @@
 
 Install the data package as well and you are set.
 
-NOTE: installing over (possibly outdated) Linux distribution packages of this
-program and the data collection should not be a problem.
+NOTE: installing over (possibly outdated) distribution packages of this
+program and the data collection should generally not be a problem.
 
 
 How to use
@@ -123,18 +123,21 @@
 For manual use just run "usb_modeswitch" (as root). Work with the command
 line interface or with a setup file. You can use any file and give its path
 with the "-c" parameter.
+
 The file named "device_reference.txt" that you can find on the home site of
 this package is a device and configuration reference containing most known
 devices; you can use it as a "database" to create your own configuration file.
 It's heavily commented and should tell you what to do. It also contains a
 thorough explanation of all the parameters.
+However, the device list in that reference file is no longer maintained.
+See the data package for the USB IDs of devices known to usb_modeswitch.
 
 Run "usb_modeswitch -h" to list the command line parameters.
 See also the provided man page.
 
 Important note: Manual use is mainly intended for testing and analyzing!!
 The program puts no limits on what you can send to your USB device, so I
-assume it is possible to screw it up profoundly.
+assume it is possible to screw it up profoundly. You have been warned.
 
 Once your new device is switching fine you can add it to the data files to
 make the process automatic.
@@ -167,6 +170,8 @@
 Please go to the homepage (see link at the top). Read carefully.
 For support questions use ONLY public posts in the forum.
 
+Again - to see the USB IDs of known devices, see the data package.
+
 
 
 Contribute
@@ -177,9 +182,8 @@
 
 Note the device's vendor and product ID from /proc/bus/usb/devices (or from the
 output of lsusb); the assigned driver is usually "usb-storage". Then try spying
-on the USB communication to the device with the same ID inside MS Windoze. I
-recommend this tool:
-"SniffUSB" (http://benoit.papillault.free.fr/usbsnoop/index.php.en).
+on the USB communication to the device with the same ID inside MS Windoze.
+Nowadays the standard tool for this is Wireshark/USBPcap.
 
 PLEASE post any improvements, new device information and/or bug reports to the
 forum (see above) or send it to the author (see below)!
@@ -188,7 +192,7 @@
 Whodunit
 ========
 
-Copyright 2007 - 2015 Josua Dietze (for non-support notifications write a 
personal
+Copyright 2007 - 2017 Josua Dietze (for non-support notifications write a 
personal
 message through the forum to "Josh"; everything else only in a forum thread)
 
  !!! NO SUPPORT QUESTIONS VIA E-MAIL, use the forum !!!
@@ -239,7 +243,7 @@
  Adam Goode
  Leonid Lisovskiy
  Vladislav Grishenko
- Daniel Drake
+ Lubomir Rintel
 
 Device information contributors are named in the "device_reference.txt" file.
 
@@ -268,4 +272,4 @@
 
 
 
-Last revised: 2016-06-12, Josua Dietze
+Last revised: 2017-01-16, Josua Dietze
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/usb-modeswitch-2.4.0/dispatcher.c 
new/usb-modeswitch-2.5.0/dispatcher.c
--- old/usb-modeswitch-2.4.0/dispatcher.c       2016-03-05 11:08:29.000000000 
+0100
+++ new/usb-modeswitch-2.5.0/dispatcher.c       2017-01-17 20:39:49.000000000 
+0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2016 Josua Dietze, usb_modeswitch version 2.3.0
+ * Copyright (c) 2011-2017 Josua Dietze, usb_modeswitch version 2.5.0
  * Contains code under
  * Copyright (c) 2010 Wojciech A. Koszek <wkos...@freebsd.org>
  * All rights reserved.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/usb-modeswitch-2.4.0/usb-modeswitch-upstart.conf 
new/usb-modeswitch-2.5.0/usb-modeswitch-upstart.conf
--- old/usb-modeswitch-2.4.0/usb-modeswitch-upstart.conf        2016-03-05 
11:08:29.000000000 +0100
+++ new/usb-modeswitch-2.5.0/usb-modeswitch-upstart.conf        2017-01-11 
20:45:03.000000000 +0100
@@ -1,5 +1,5 @@
 start on usb-modeswitch-upstart
 task
 script
-       exec /usr/sbin/usb_modeswitch_dispatcher --switch-upstart $UMS_PARAM
+       exec /usr/sbin/usb_modeswitch_dispatcher --switch-mode $UMS_PARAM
 end script
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/usb-modeswitch-2.4.0/usb_modeswitch.c 
new/usb-modeswitch-2.5.0/usb_modeswitch.c
--- old/usb-modeswitch-2.4.0/usb_modeswitch.c   2016-06-12 19:48:35.000000000 
+0200
+++ new/usb-modeswitch-2.5.0/usb_modeswitch.c   2017-01-17 08:33:45.000000000 
+0100
@@ -1,8 +1,8 @@
 /*
   Mode switching tool for controlling mode of 'multi-state' USB devices
-  Version 2.4.0, 2016/06/12
+  Version 2.5.0, 2017/01/17
 
-  Copyright (C) 2007 - 2016 Josua Dietze (mail to "usb_admin" at the domain
+  Copyright (C) 2007 - 2017 Josua Dietze (mail to "usb_admin" at the domain
   of the home page; or write a personal message through the forum to "Josh".
   NO SUPPORT VIA E-MAIL - please use the forum for that)
 
@@ -45,7 +45,7 @@
 
 /* Recommended tab size: 4 */
 
-#define VERSION "2.4.0"
+#define VERSION "2.5.0"
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -473,11 +473,11 @@
 
        if (strlen(MessageContent)) {
                if (strlen(MessageContent) % 2 != 0) {
-                       fprintf(stderr, "Error: MessageContent hex string has 
uneven length. Abort\n\n");
+                       fprintf(stderr, "MessageContent hex string has uneven 
length. Abort\n\n");
                        exit(1);
                }
                if ( hexstr2bin(MessageContent, ByteString, 
strlen(MessageContent)/2) == -1) {
-                       fprintf(stderr, "Error: MessageContent %s\n is not a 
hex string. Abort\n\n",
+                       fprintf(stderr, "MessageContent %s\n is not a hex 
string. Abort\n\n",
                                        MessageContent);
 
                        exit(1);
@@ -579,6 +579,33 @@
        /* Get class of default device/interface */
        interfaceClass = get_interface_class();
 
+       if (interfaceClass == -1) {
+               fprintf(stderr, "Error: Could not get class of interface %d. 
Does it exist? Abort\n\n",Interface);
+               abortExit();
+       } else {
+               SHOW_PROGRESS(output," with class %d\n", interfaceClass);
+       }
+
+       if (defaultClass == 0 || defaultClass == 0xef)
+               defaultClass = interfaceClass;
+       else
+               if (interfaceClass == LIBUSB_CLASS_MASS_STORAGE && defaultClass 
!= LIBUSB_CLASS_MASS_STORAGE
+                               && defaultClass != LIBUSB_CLASS_VENDOR_SPEC) {
+
+                       /* Unexpected default class combined with differing 
interface class */
+                       SHOW_PROGRESS(output,"Bogus Class/InterfaceClass: 
0x%02x/0x08\n", defaultClass);
+                       defaultClass = 8;
+               }
+
+       if ((strlen(MessageContent) && strncmp("55534243",MessageContent,8) == 
0)
+                       || StandardEject || ModeMap & HUAWEINEW_MODE || ModeMap 
& CISCO_MODE
+                       || ModeMap & OPTION_MODE)
+               if (defaultClass != 8) {
+                       fprintf(stderr, "Error: can't use storage command in 
MessageContent with interface %d; "
+                               "interface class is %d, expected 8. Abort\n\n", 
Interface, defaultClass);
+                       abortExit();
+               }
+
        /* Check or get endpoints and alloc message list if needed*/
        if (strlen(MessageContent) || StandardEject || ModeMap & CISCO_MODE
                                || ModeMap & HUAWEINEW_MODE || ModeMap & 
OPTION_MODE) {
@@ -606,29 +633,6 @@
 
        }
 
-       if (interfaceClass == -1) {
-               fprintf(stderr, "Error: Could not get class of interface %d. 
Does it exist? Abort\n\n",Interface);
-               abortExit();
-       }
-
-       if (defaultClass == 0 || defaultClass == 0xef)
-               defaultClass = interfaceClass;
-       else
-               if (interfaceClass == LIBUSB_CLASS_MASS_STORAGE && defaultClass 
!= LIBUSB_CLASS_MASS_STORAGE
-                               && defaultClass != LIBUSB_CLASS_VENDOR_SPEC) {
-
-                       /* Unexpected default class combined with differing 
interface class */
-                       SHOW_PROGRESS(output,"Bogus Class/InterfaceClass: 
0x%02x/0x08\n", defaultClass);
-                       defaultClass = 8;
-               }
-
-       if (strlen(MessageContent) && strncmp("55534243",MessageContent,8) == 0)
-               if (defaultClass != 8) {
-                       fprintf(stderr, "Error: can't use storage command in 
MessageContent with interface %d;\n"
-                               "       interface class is %d, expected 8. 
Abort\n\n", Interface, defaultClass);
-                       abortExit();
-               }
-
        if (show_progress) {
                fprintf(output,"\nUSB description data (for identification)\n");
                deviceDescription();
@@ -973,6 +977,7 @@
 {
        const char* cmdHead = "55534243";
        int ret, i;
+       int retries = 1;
 /*     char* msg[3];
        msg[0] = MessageContent;
        msg[1] = MessageContent2;
@@ -984,11 +989,12 @@
                SHOW_PROGRESS(output," Could not claim interface (error %d). 
Skip message sending\n", ret);
                return 0;
        }
-       libusb_clear_halt(devh, MessageEndpoint);
+
        SHOW_PROGRESS(output,"Use endpoint 0x%02x for message sending ...\n", 
MessageEndpoint);
        if (show_progress)
                fflush(stdout);
 
+retry:
        for (i=0; i<MSG_DIM; i++) {
                if ( strlen(Messages[i]) == 0)
                        break;
@@ -1008,6 +1014,11 @@
                        ret = read_bulk(ResponseEndpoint, ByteString, 
strlen(Messages[i])/2 );
                }
                SHOW_PROGRESS(output,"\n");
+               if (ret == LIBUSB_TRANSFER_STALL && retries--) {
+                       SHOW_PROGRESS(output,"Endpoint stalled. Resetting 
...\n");
+                       libusb_clear_halt(devh, MessageEndpoint);
+                       goto retry;
+               }
                if (ret < 0)
                        goto skip;
        }
@@ -1855,7 +1866,8 @@
        char *FirstQuote, *LastQuote, *P1, *P2;
        int Line=0;
        unsigned Len=0, Pos=0;
-       char Str[LINE_DIM], *token, *configPos;
+       static char Str[LINE_DIM];
+       char *token, *configPos;
        FILE *file = NULL;
 
        // Reading and storing input during the first call
@@ -2030,6 +2042,8 @@
 
 void abortExit()
 {
+       fflush(output);
+       fflush(stderr);
        close_all();
        exit(1);
 }
@@ -2039,7 +2053,7 @@
 {
        char* version = VERSION;
        fprintf(output,"\n * usb_modeswitch: handle USB devices with multiple 
modes\n"
-               " * Version %s (C) Josua Dietze 2016\n"
+               " * Version %s (C) Josua Dietze 2017\n"
                " * Based on libusb1/libusbx\n\n"
                " ! PLEASE REPORT NEW CONFIGURATIONS !\n\n", version);
 }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/usb-modeswitch-2.4.0/usb_modeswitch.h 
new/usb-modeswitch-2.5.0/usb_modeswitch.h
--- old/usb-modeswitch-2.4.0/usb_modeswitch.h   2016-06-12 21:48:26.000000000 
+0200
+++ new/usb-modeswitch-2.5.0/usb_modeswitch.h   2016-03-05 11:08:29.000000000 
+0100
@@ -2,7 +2,7 @@
   This file is part of usb_modeswitch, a mode switching tool for controlling
   the mode of 'multi-state' USB devices
 
-  Version 2.4.0, 2016/06/12
+  Version 2.3.0, 2016/01/12
   Copyright (C) 2007 - 2016  Josua Dietze
 
   Config file parsing stuff borrowed from Guillaume Dargaud
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/usb-modeswitch-2.4.0/usb_modeswitch.sh 
new/usb-modeswitch-2.5.0/usb_modeswitch.sh
--- old/usb-modeswitch-2.4.0/usb_modeswitch.sh  2016-06-12 14:12:27.000000000 
+0200
+++ new/usb-modeswitch-2.5.0/usb_modeswitch.sh  2017-01-17 20:57:50.000000000 
+0100
@@ -1,5 +1,5 @@
 #!/bin/sh
-# part of usb_modeswitch 2.4.0
+# part of usb_modeswitch 2.5.0
 device_in()
 {
        if [ ! -e /var/lib/usb_modeswitch/$1 ]; then
@@ -57,16 +57,19 @@
 IFS='/' read -r p1 p2 <<EOF
 $1
 EOF
+if [ "$p2" = "" -a "$p1" != "" ]; then
+       p2=$p1
+fi
 
 PATH=/bin:/sbin:/usr/bin:/usr/sbin
 init_path=`readlink /sbin/init`
 if [ `basename $init_path` = "systemd" ]; then
-       systemctl --no-block start usb_modeswitch@$p1'_'$p2.service
+       systemctl --no-block start usb_modeswitch@$p2.service
 elif [ -e "/etc/init/usb-modeswitch-upstart.conf" ]; then
-       initctl emit --no-wait usb-modeswitch-upstart UMS_PARAM=$1
+       initctl emit --no-wait usb-modeswitch-upstart UMS_PARAM=$p2
 else
        # only old distros, new udev will kill all subprocesses
        exec 1<&- 2<&- 5<&- 7<&-
-       exec usb_modeswitch_dispatcher --switch-mode $1 &
+       exec usb_modeswitch_dispatcher --switch-mode $p2 &
 fi
 exit 0
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/usb-modeswitch-2.4.0/usb_modeswitch.tcl 
new/usb-modeswitch-2.5.0/usb_modeswitch.tcl
--- old/usb-modeswitch-2.4.0/usb_modeswitch.tcl 2016-06-12 11:33:56.000000000 
+0200
+++ new/usb-modeswitch-2.5.0/usb_modeswitch.tcl 2017-01-17 20:41:33.000000000 
+0100
@@ -9,8 +9,8 @@
 # the mode switching program with the matching parameter
 # file from /usr/share/usb_modeswitch
 #
-# Part of usb-modeswitch-2.4.0 package
-# (C) Josua Dietze 2009-2016
+# Part of usb-modeswitch-2.5.0 package
+# (C) Josua Dietze 2009-2017
 
 set arg0 [lindex $argv 0]
 if [regexp {\.tcl$} $arg0] {
@@ -40,6 +40,11 @@
 set flags(config) ""
 Log "[ParseGlobalConfig]"
 
+if {$flags(stordelay) > 0} {
+       SetStorageDelay $flags(stordelay)
+}
+
+
 # The facility to add a symbolic link pointing to the
 # ttyUSB port which provides interrupt transfer, i.e.
 # the port to connect through.
@@ -55,74 +60,47 @@
        SafeExit
 }
 
-if {[lindex $argv 0] == "--switch-systemd"} {
-       set argList [split [lindex $argv 1] _]
-       Log "\nStarted via systemd"
-} else {
-       if {[lindex $argv 0] == "--switch-upstart"} {
-               Log "\nStarted via upstart"
+# arg0: the bus id for the device (udev: %b), now deprecated
+# arg1: the "kernel name" for the device (udev: %k)
+#
+# From version 2.5.0 upward %b is removed by udev sh script
+# which can handle old and new udev params ('%b/%k' and '%k')
+
+Log "Raw parameters: $argv"
+set device "noname"
+if {[lindex $argv 0] == "--switch-mode"} {
+       if [string length [lindex $argv 1]] {
+               set arg1 [lindex $argv 1]
+       } else {
+               Log "\nNo data from udev. Exit"
+               SafeExit
        }
-       set argList [split [lindex $argv 1] /]
-}
-if [string length [lindex $argList 1]] {
-       set device [lindex $argList 1]
 } else {
-       set device "noname"
-}
-if {$flags(stordelay) > 0} {
-       SetStorageDelay $flags(stordelay)
-}
-
-Log "Raw args from udev: [lindex $argv 1]\n"
-
-if {$device == "noname"} {
-       Log "\nNo data from udev. Exit"
+       Log "\nNo command given. Exit"
        SafeExit
 }
 
-if {![regexp -- {--switch-} [lindex $argv 0]]} {
-       Log "\nNo command given. Exit"
-       SafeExit
+if {![regexp {(.*?):.*$} $arg1 d device]} {
+       if {![regexp {([0-9]+-[0-9]+\.?[0-9]*.*)} $arg1 d device]} {
+               Log "Could not determine device dir from udev values! Exit"
+               SafeExit
+       }
 }
+set flags(logwrite) 1
 
 set setup(dbdir) /usr/share/usb_modeswitch
 set setup(dbdir_etc) /etc/usb_modeswitch.d
-
-
 if {![file exists $setup(dbdir)] && ![file exists $setup(dbdir_etc)]} {
        Log "\nError: no config database found in /usr/share or /etc. Exit"
        SafeExit
 }
-set bindir /usr/sbin
 
+set bindir /usr/sbin
 set devList1 {}
 set devList2 {}
-
-
-# arg 0: the bus id for the device (udev: %b), often ommitted
-# arg 1: the "kernel name" for the device (udev: %k)
-#
-# Used to determine the top directory for the device in sysfs
-
 set ifChk 0
-if {[string length [lindex $argList 0]] == 0} {
-       if {[string length [lindex $argList 1]] == 0} {
-               Log "No device number values given from udev! Exit"
-               SafeExit
-       } else {
-               if {![regexp {(.*?):} [lindex $argList 1] d dev_top]} {
-                       if {![regexp {([0-9]+-[0-9]+\.?[0-9]*.*)} [lindex 
$argList 1] d dev_top]} {
-                               Log "Could not determine device dir from udev 
values! Exit"
-                               SafeExit
-                       }
-               }
-       }
-} else {
-       set dev_top [lindex $argList 0]
-       regexp {(.*?):} $dev_top d dev_top
-}
 
-set devdir /sys/bus/usb/devices/$dev_top
+set devdir /sys/bus/usb/devices/$device
 if {![file isdirectory $devdir]} {
        Log "Top device directory not found ($devdir)! Exit"
        SafeExit
@@ -141,8 +119,6 @@
 set ifdir [file tail [IfDir $iface $devdir]]
 regexp {:([0-9]+\.[0-9]+)$} $ifdir d iface
 
-set flags(logwrite) 1
-
 # Mapping of the short string identifiers (in the config
 # file names) to the long name used here
 #
@@ -228,13 +204,10 @@
        Log "SCSI attributes not needed, move on"
 }
 
-# General wait - some devices need this
-after 500
-
 # Now check for a matching config file. Matching is done
 # by MatchDevice
 
-set report {}
+set report ""
 foreach mconfig $configList {
 
        # skipping installer leftovers like "*.rpmnew"
@@ -243,74 +216,89 @@
        Log "Check config: $mconfig"
        if [MatchDevice $mconfig] {
                Log "! matched. Read config data"
-#              set flags(config) $mconfig
-               if [string length $usb(busnum)] {
-                       set busParam "-b [string trimleft $usb(busnum) 0]"
-                       set devParam "-g [string trimleft $usb(devnum) 0]"
-               } else {
-                       set busParam ""
-                       set devParam ""
-               }
                set flags(config) [ConfigGet conffile $mconfig]
-               ParseDeviceConfig $flags(config)
-               if [regexp -nocase {/[0-9a-f]+:#} $flags(config)] {
-                       Log "Note: Using generic manufacturer configuration for 
\"$flags(os)\""
-               }
-               if $flags(nombim) {
-                       set config(NoMBIMCheck) 1
-               }
-               if {$config(WaitBefore) != ""} {
-                       Log "Delay time of $config(WaitBefore) seconds"
-                       append config(WaitBefore) "000"
-                       after $config(WaitBefore)
-                       Log " wait is over, start mode switch"
-               }
-               if {$config(NoMBIMCheck)==0 && $usb(bNumConfigurations) > 1} {
-                       Log "Device may have an MBIM configuration, check 
driver ..."
-                       if [CheckMBIM] {
-                               Log " driver for MBIM devices is available"
-                               Log "Find MBIM configuration number ..."
-                               if [catch {set cfgno [exec 
/usr/sbin/usb_modeswitch -j -Q $busParam $devParam -v $usb(idVendor) -p 
$usb(idProduct)]} err] {
-                                       Log "Error when trying to find MBIM 
configuration, switch to legacy modem mode"
-                               } else {
-                                       set cfgno [string trim $cfgno]
-                                       if {$cfgno > 0} {
-                                               set config(Configuration) $cfgno
-                                               set flags(config) 
"Configuration=$cfgno"
-                                       } else {
-                                               Log " No MBIM configuration 
found, switch to legacy modem mode"
-                                       }
-                               }
+               break
+       } else {
+               Log "* no match, don't use this config"
+       }
+}
+if {$flags(config) == ""} {
+       Log "No matching config file found. Exit"
+       SafeExit
+}
+
+ParseDeviceConfig $flags(config)
+
+if [regexp -nocase {0x([0-9a-f]+)} $config(TargetClass) d tc] {
+       if {$tc == $config(class)} {
+               Log "Class of interface 0 matches target. Do nothing"
+               set report "ok:busdev"
+       }
+}
+
+if [string length $usb(busnum)] {
+       set busParam "-b [string trimleft $usb(busnum) 0]"
+       set devParam "-g [string trimleft $usb(devnum) 0]"
+} else {
+       set busParam ""
+       set devParam ""
+}
+if [regexp -nocase $flags(os) $flags(config)] {
+       Log "Note: Using generic manufacturer configuration for \"$flags(os)\""
+}
+if $flags(nombim) {
+       set config(NoMBIMCheck) 1
+}
+if {$config(NoMBIMCheck)==0 && $usb(bNumConfigurations) > 1} {
+       Log "Device may have an MBIM configuration, check driver ..."
+       if [CheckMBIM] {
+               Log " driver for MBIM devices is available"
+               Log "Find MBIM configuration number ..."
+               if [catch {set cfgno [exec /usr/sbin/usb_modeswitch -j -Q 
$busParam $devParam -v $usb(idVendor) -p $usb(idProduct)]} err] {
+                       Log "Error when trying to find MBIM configuration, 
switch to legacy modem mode"
+               } else {
+                       set cfgno [string trim $cfgno]
+                       if {$cfgno > 0} {
+                               set config(Configuration) $cfgno
+                               set flags(config) "Configuration=$cfgno"
                        } else {
-                               Log " no MBIM driver found, switch to legacy 
modem mode"
+                               Log " No MBIM configuration found, switch to 
legacy modem mode"
                        }
                }
-               if [PantechAutoSwitch] {
-                       Log "Waiting for Pantech auto-modeswitch"
-                       set report "ok:busdev"
-                       break
-               }
-               if {$config(Configuration) == 0} {
-                       Log "Config file contains dummy method, do nothing. 
Exit"
-                       SafeExit
-               }
-               UnbindDriver $devdir $ifdir
-               # Now we are actually switching
-               if $flags(logging) {
-                       Log "Command to be run:\nusb_modeswitch -W -D 
$configParam $busParam $devParam -v $usb(idVendor) -p $usb(idProduct) -f 
\$flags(config)"
-                       set report [exec /usr/sbin/usb_modeswitch -W -D 
$configParam $busParam $devParam -v $usb(idVendor) -p $usb(idProduct) -f 
"$flags(config)" 2>@1]
-                       Log "\nVerbose debug output of usb_modeswitch and 
libusb follows"
-                       Log "(Note that some USB errors are to be expected in 
the process)"
-                       Log "--------------------------------"
-                       Log $report
-                       Log "--------------------------------"
-                       Log "(end of usb_modeswitch output)\n"
-               } else {
-                       set report [exec /usr/sbin/usb_modeswitch -Q -D 
$configParam $busParam $devParam -v $usb(idVendor) -p $usb(idProduct) -f 
"$flags(config)" 2>@1]
-               }
-               break
        } else {
-               Log "* no match, don't use this config"
+               Log " no MBIM driver found, switch to legacy modem mode"
+       }
+}
+if [PantechAutoSwitch] {
+       Log "Waiting for Pantech auto-modeswitch"
+       set report "ok:busdev"
+}
+if {$config(Configuration) == 0} {
+       Log "Config file contains dummy method, do nothing. Exit"
+       SafeExit
+}
+# General wait - some devices need this
+after 500
+
+if {$config(WaitBefore) != ""} {
+       Log "Delay time of $config(WaitBefore) seconds"
+       append config(WaitBefore) "000"
+       after $config(WaitBefore)
+}
+
+if {$report == ""} {
+       # Now we are actually switching
+       if $flags(logging) {
+               Log "Command line:\nusb_modeswitch -W -D $configParam $busParam 
$devParam -v $usb(idVendor) -p $usb(idProduct) -f \$flags(config)"
+               catch {set report [exec /usr/sbin/usb_modeswitch -W -D 
$configParam $busParam $devParam -v $usb(idVendor) -p $usb(idProduct) -f 
"$flags(config)" 2>@1]} report
+               Log "\nVerbose debug output of usb_modeswitch and libusb 
follows"
+               Log "(Note that some USB errors are to be expected in the 
process)"
+               Log "--------------------------------"
+               Log $report
+               Log "--------------------------------"
+               Log "(end of usb_modeswitch output)\n"
+       } else {
+               catch {set report [exec /usr/sbin/usb_modeswitch -Q -D 
$configParam $busParam $devParam -v $usb(idVendor) -p $usb(idProduct) -f 
"$flags(config)" 2>@1]} report
        }
 }
 
@@ -976,16 +964,6 @@
 
 }
 
-proc UnbindDriver {devdir ifdir} {
-
-set att $devdir/$ifdir/driver/unbind
-if [file exists $att] {
-       Log "Unbinding driver"
-       exec echo -n "$ifdir" > $att
-}
-
-}
-
 proc {LogAttributes} {} {
 
 global flags usb
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/usb-modeswitch-2.4.0/usb_modeswitch@.service 
new/usb-modeswitch-2.5.0/usb_modeswitch@.service
--- old/usb-modeswitch-2.4.0/usb_modeswitch@.service    2016-03-05 
11:08:29.000000000 +0100
+++ new/usb-modeswitch-2.5.0/usb_modeswitch@.service    2017-01-11 
20:45:03.000000000 +0100
@@ -3,6 +3,6 @@
 
 [Service]
 Type=oneshot
-ExecStart=/usr/sbin/usb_modeswitch_dispatcher --switch-systemd %i
+ExecStart=/usr/sbin/usb_modeswitch_dispatcher --switch-mode %i
 #ExecStart=/bin/echo %i
 

++++++ usb-modeswitch-data-20160612.tar.bz2 -> 
usb-modeswitch-data-20170120.tar.bz2 ++++++
++++ 3430 lines of diff (skipped)


Reply via email to