Hello community,

here is the log from the commit of package usb_modeswitch for openSUSE:Factory 
checked in at 2012-12-14 11:21:37
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/usb_modeswitch (Old)
 and      /work/SRC/openSUSE:Factory/.usb_modeswitch.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "usb_modeswitch", Maintainer is "se...@novell.com"

Changes:
--------
--- /work/SRC/openSUSE:Factory/usb_modeswitch/usb_modeswitch.changes    
2012-10-25 12:12:05.000000000 +0200
+++ /work/SRC/openSUSE:Factory/.usb_modeswitch.new/usb_modeswitch.changes       
2012-12-14 11:21:40.000000000 +0100
@@ -1,0 +2,15 @@
+Mon Dec  3 12:34:50 UTC 2012 - p.drou...@gmail.com
+
+- Update to 1.2.5:
+  * Initial support for MBIM devices, use with data package >= 20121109;
+    checking for these is the automatic default, new parameter NoMBIMCheck
+    prevents the check per device in case of problems; new global option
+    to set "delay_use" of usb-storage (as low values may prevent
+    mode-switching);
+  * fix for handling multi-configuration devices (thanks
+    to Bjørn Mork for advice)
+- Removed files:
+  * add_alcatel_ot_x220d.patch: supported on upstream release
+  * 1bbb:f017: supported on upstream release
+- Adapt huawei-timing.patch for 1.2.5
+-------------------------------------------------------------------

Old:
----
  1bbb:f017
  add_alcatel_ot_x220d.patch
  usb-modeswitch-1.2.3.tar.bz2
  usb-modeswitch-data-20120531.tar.bz2

New:
----
  usb-modeswitch-1.2.5.tar.bz2
  usb-modeswitch-data-20121109.tar.bz2

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

Other differences:
------------------
++++++ usb_modeswitch.spec ++++++
--- /var/tmp/diff_new_pack.I8dBeL/_old  2012-12-14 11:21:43.000000000 +0100
+++ /var/tmp/diff_new_pack.I8dBeL/_new  2012-12-14 11:21:43.000000000 +0100
@@ -23,19 +23,17 @@
 %endif
 
 Name:           usb_modeswitch
-Version:        1.2.3
+Version:        1.2.5
 Release:        0
 Summary:        A mode switching tool for controlling multiple-device USB gear
 License:        GPL-2.0+
 Group:          Hardware/Mobile
 Url:            http://www.draisberghof.de/usb_modeswitch
 %define source_name    usb-modeswitch
-%define date           20120531
+%define date           20121109
 Source0:        
http://www.draisberghof.de/usb_modeswitch/%{source_name}-%{version}.tar.bz2
 Source1:        %{source_name}-data-%{date}.tar.bz2
 Source2:        %{name}-data.rpmlintrc
-Source3:        1bbb:f017
-Patch0:         add_alcatel_ot_x220d.patch
 Patch1:         huawei-timing.patch
 BuildRoot:      %{_tmppath}/%{name}-%{version}-build
 BuildRequires:  fdupes
@@ -69,7 +67,6 @@
 
 %prep
 %setup -q -a1 -n %{source_name}-%{version}
-%patch0
 %patch1 -p1 -d %{source_name}-data-%{date}
 
 %build
@@ -78,7 +75,6 @@
 %install
 %makeinstall UDEVDIR=$RPM_BUILD_ROOT%{_udevdir}
 cd %{source_name}-data-%{date}
-cp %{SOURCE3} .
 %makeinstall RULESDIR=$RPM_BUILD_ROOT%{_udevdir}/rules.d
 %fdupes -s $RPM_BUILD_ROOT
 

++++++ huawei-timing.patch ++++++
--- /var/tmp/diff_new_pack.I8dBeL/_old  2012-12-14 11:21:43.000000000 +0100
+++ /var/tmp/diff_new_pack.I8dBeL/_new  2012-12-14 11:21:43.000000000 +0100
@@ -1,19 +1,19 @@
 diff -u -r usb-modeswitch-data-20120531.org/40-usb_modeswitch.rules 
usb-modeswitch-data-20120531/40-usb_modeswitch.rules
---- usb-modeswitch-data-20120531.org/40-usb_modeswitch.rules   2012-09-28 
14:15:48.751958694 +0200
-+++ usb-modeswitch-data-20120531/40-usb_modeswitch.rules       2012-09-28 
14:16:49.063343878 +0200
-@@ -443,6 +443,9 @@
+--- usb-modeswitch-data-20121109.org/40-usb_modeswitch.rules   2012-12-03 
14:15:48.751958694 +0200
++++ usb-modeswitch-data2-0121109/40-usb_modeswitch.rules       2012-12-03 
14:16:49.063343878 +0200
+@@ -474,6 +474,9 @@
  # Huawei E173s
- ATTRS{idVendor}=="12d1", ATTRS{idProduct}=="1c0b", RUN+="usb_modeswitch 
'%b/%k'"
+ ATTR{idVendor}=="12d1", ATTR{idProduct}=="1c0b", RUN+="usb_modeswitch '%b/%k'"
  
 +# Huawei E173s
 +ATTRS{idVendor}=="12d1", ATTRS{idProduct}=="1c00", RUN+="usb_modeswitch -w 
3000 '%b/%k'"
 +
  # Huawei E173 (Moviestar)
- ATTRS{idVendor}=="12d1", ATTRS{idProduct}=="1c24", RUN+="usb_modeswitch 
'%b/%k'"
+ ATTR{idVendor}=="12d1", ATTR{idProduct}=="1c24", RUN+="usb_modeswitch '%b/%k'"
  
 diff -u -r usb-modeswitch-data-20120531.org/usb_modeswitch.d/12d1:1c0b 
usb-modeswitch-data-20120531/usb_modeswitch.d/12d1:1c0b
---- usb-modeswitch-data-20120531.org/usb_modeswitch.d/12d1:1c0b        
2012-09-28 14:15:48.754958714 +0200
-+++ usb-modeswitch-data-20120531/usb_modeswitch.d/12d1:1c0b    2012-09-28 
14:17:35.495640324 +0200
+--- usb-modeswitch-data-20121109.org/usb_modeswitch.d/12d1:1c0b        
2012-12-03 14:15:48.754958714 +0200
++++ usb-modeswitch-data-20121109/usb_modeswitch.d/12d1:1c0b    2012-12-03 
14:17:35.495640324 +0200
 @@ -5,3 +5,4 @@
  
  
MessageContent="55534243123456780000000000000011062000000100000000000000000000"

++++++ usb-modeswitch-1.2.3.tar.bz2 -> usb-modeswitch-1.2.5.tar.bz2 ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/usb-modeswitch-1.2.3/ChangeLog 
new/usb-modeswitch-1.2.5/ChangeLog
--- old/usb-modeswitch-1.2.3/ChangeLog  2012-01-28 18:01:31.000000000 +0100
+++ new/usb-modeswitch-1.2.5/ChangeLog  2012-11-09 23:46:31.000000000 +0100
@@ -2,6 +2,18 @@
 History of USB_ModeSwitch
 =========================
 
+Version 1.2.5, 2012/11/09
+    Initial support for MBIM devices, use with data package >= 20121109;
+    checking for these is the automatic default, new parameter NoMBIMCheck
+    prevents the check per device in case of problems; new global option
+    to set "delay_use" of usb-storage (as low values may prevent
+    mode-switching); fix for handling multi-configuration devices (thanks
+    to Bjørn Mork for advice)
+Version 1.2.4, 2012/08/12
+    Additional interface checks to prevent sending UFI commands to non-
+    storage interfaces (prompted by more ambiguous device IDs popping up);
+    change in SierraMode for handling newer devices which caused an error
+    abort before; Makefile fix for parallelized make runs
 Version 1.2.3, 2012/01/28
     Fixed two bugs both causing the embedded-jimsh install variant of the
     dispatcher crash (the "pure-script" install variant was NOT affected);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/usb-modeswitch-1.2.3/Makefile 
new/usb-modeswitch-1.2.5/Makefile
--- old/usb-modeswitch-1.2.3/Makefile   2012-01-27 20:09:00.000000000 +0100
+++ new/usb-modeswitch-1.2.5/Makefile   2012-09-07 21:54:31.000000000 +0200
@@ -1,5 +1,5 @@
 PROG        = usb_modeswitch
-VERS        = 1.2.3
+VERS        = 1.2.5
 CC          = gcc
 CFLAGS      += -Wall
 LIBS        = -l usb
@@ -20,7 +20,7 @@
 
 static: $(PROG) dispatcher-static
 
-$(PROG): $(OBJS)
+$(PROG): $(OBJS) usb_modeswitch.h
        $(CC) -o $(PROG) $(OBJS) $(CFLAGS) $(LIBS) $(LDFLAGS)
 
 dispatcher-static: dispatcher.c usb_modeswitch.tcl
@@ -45,7 +45,7 @@
        $(RM) usb_modeswitch.string
        cd jim && $(MAKE) distclean
 
-install-common:
+install-common: all
        install -D -s --mode=755 usb_modeswitch $(SBINDIR)/usb_modeswitch
        install -D --mode=755 usb_modeswitch.sh $(UDEVDIR)/usb_modeswitch
        install -D --mode=644 usb_modeswitch.conf $(ETCDIR)/usb_modeswitch.conf
@@ -64,14 +64,13 @@
        sed 's_!/usr/bin/tclsh_!'"$$SHELL"'_' <usb_modeswitch.tcl 
>usb_modeswitch_dispatcher
        install -D --mode=755 usb_modeswitch_dispatcher 
$(SBINDIR)/usb_modeswitch_dispatcher
 
-install-binary:
-       install -D -s --mode=755 usb_modeswitch_dispatcher 
$(SBINDIR)/usb_modeswitch_dispatcher
-
-install: all install-common install-script
+install: install-common install-script
 
-install-shared: shared install-common install-binary
+install-shared: dispatcher-dynamic install-common
+       install -D -s --mode=755 usb_modeswitch_dispatcher 
$(SBINDIR)/usb_modeswitch_dispatcher
 
-install-static: static install-common install-binary
+install-static: dispatcher-static install-common
+       install -D -s --mode=755 usb_modeswitch_dispatcher 
$(SBINDIR)/usb_modeswitch_dispatcher
 
 uninstall:
        $(RM) $(SBINDIR)/usb_modeswitch
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/usb-modeswitch-1.2.3/README 
new/usb-modeswitch-1.2.5/README
--- old/usb-modeswitch-1.2.3/README     2011-12-27 00:19:02.000000000 +0100
+++ new/usb-modeswitch-1.2.5/README     2012-11-08 22:55:25.000000000 +0100
@@ -20,7 +20,7 @@
 (TM)" since it eliminates the need for shipping a separate driver carrier.
 
 In the beginning, nothing of this was documented in any form and there was
-hardly any Linux support available.
+hardly any Linux/Unix support available.
 On the good side, most of the known devices are working out of the box in all
 modes with the available Linux modules like "usb-storage" or serial USB 
drivers.
 That leaves only the problem of the mode-switching from storage to whatever
@@ -29,14 +29,15 @@
 Fortunately there are things like human intelligence, USB sniffing programs and
 "libusb". It is possible to eavesdrop the communication of the MS Windows
 driver, to isolate the command or action that does the switching, and to replay
-the same sequence in Linux.
+the same sequence in the Unix system.
 
 USB_ModeSwitch makes this process easy to handle by taking the relevant para-
 meters from a configuration file and doing all the initialization and communi-
 cation stuff, with heavy help from "libusb".
-It is mainly used automatically - via udev events and rules - to do the switch
-without any user interaction. But it can also be run as a command line tool,
-usually when trying to make unknown devices work.
+In Linux it is intended to be used automatically - via udev events and rules -
+and doing the mode switch without any user interaction, but it can also be run
+as a command line tool, usually when trying to make hitherto unknown devices
+work on Unix systems.
 
 We have already collected a wide range of information on how to switch all
 sorts of devices. If you run into a new one that is unknown yet, don't despair:
@@ -79,12 +80,17 @@
 
    # make install-static
 
-These commands will install a small posix shell script, the dispatcher
-(wrapper) as script or as binary, a global config file, the core program and
-a man page.
+Note that the "static"/"shared" targets are NOT referring to the usb_modeswitch
+program, only to the dispatcher!
+Any one of these commands will install a small posix shell script, the
+dispatcher (wrapper) as script or as binary, a global config file, the core
+program and a man page.
 
 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.
+
 
 How to use
 ==========
@@ -157,10 +163,11 @@
 Whodunit
 ========
 
-Copyright 2007, 2008, 2009, 2010, 2011 Josua Dietze (mail to "usb_admin"
+Copyright 2007, 2008, 2009, 2010, 2011, 2012 Josua Dietze (mail to "usb_admin"
  at the domain "draisberghof.de" or write a personal message through the forum
  to "Josh")
- NO SUPPORT QUESTIONS VIA E-MAIL, use the forum!
+
+ !!! NO SUPPORT QUESTIONS VIA E-MAIL, use the forum !!!
 
 Major contributions:
 
@@ -227,4 +234,4 @@
 
 
 
-Last revised: 2011-12-26, Josua Dietze
+Last revised: 2012-11-09, Josua Dietze
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/usb-modeswitch-1.2.3/dispatcher.c 
new/usb-modeswitch-1.2.5/dispatcher.c
--- old/usb-modeswitch-1.2.3/dispatcher.c       2012-01-27 18:16:18.000000000 
+0100
+++ new/usb-modeswitch-1.2.5/dispatcher.c       2012-11-08 23:36:29.000000000 
+0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2012 Josua Dietze, usb_modeswitch version 1.2.3
+ * Copyright (c) 2011-2012 Josua Dietze, usb_modeswitch version 1.2.5
  * 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-1.2.3/usb_modeswitch.c 
new/usb-modeswitch-1.2.5/usb_modeswitch.c
--- old/usb-modeswitch-1.2.3/usb_modeswitch.c   2012-01-28 17:58:39.000000000 
+0100
+++ new/usb-modeswitch-1.2.5/usb_modeswitch.c   2012-11-08 23:36:43.000000000 
+0100
@@ -1,6 +1,6 @@
 /*
   Mode switching tool for controlling flip flop (multiple device) USB gear
-  Version 1.2.3, 2012/01/28
+  Version 1.2.5, 2012/11/09
 
   Copyright (C) 2007 - 2012 Josua Dietze (mail to "usb_admin" at the domain
   of the home page; or write a personal message through the forum to "Josh".
@@ -45,7 +45,7 @@
 
 /* Recommended tab size: 4 */
 
-#define VERSION "1.2.3"
+#define VERSION "1.2.5"
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -85,7 +85,7 @@
 char DetachStorageOnly=0, HuaweiMode=0, SierraMode=0, SonyMode=0, GCTMode=0, 
KobilMode=0;
 char SequansMode=0, MobileActionMode=0, CiscoMode=0, QisdaMode=0;
 char verbose=0, show_progress=1, ResetUSB=0, CheckSuccess=0, config_read=0;
-char NeedResponse=0, NoDriverLoading=0, InquireDevice=1, sysmode=0;
+char NeedResponse=0, NoDriverLoading=0, InquireDevice=1, sysmode=0, mbim=0;
 
 char imanufact[DESCR_MAX], iproduct[DESCR_MAX], iserial[DESCR_MAX];
 
@@ -137,6 +137,7 @@
        {"sysmode",                             no_argument, 0, 'D'},
        {"no-inquire",                  no_argument, 0, 'I'},
        {"stdinput",                    no_argument, 0, 't'},
+       {"find-mbim",                   no_argument, 0, 'j'},
        {"long-config",                 required_argument, 0, 'f'},
        {"check-success",               required_argument, 0, 's'},
        {"interface",                   required_argument, 0, 'i'},
@@ -271,7 +272,7 @@
 
        while (1)
        {
-               c = getopt_long (argc, argv, 
"heWQDndHSOBGTNALRItv:p:V:P:C:m:M:2:3:w:r:c:i:u:a:s:f:b:g:",
+               c = getopt_long (argc, argv, 
"hejWQDndHSOBGTNALRItv:p:V:P:C:m:M:2:3:w:r:c:i:u:a:s:f:b:g:",
                                                long_options, &option_index);
 
                /* Detect the end of the options. */
@@ -307,7 +308,7 @@
                        case 't': readConfigFile("stdin"); break;
                        case 'W': verbose = 1; show_progress = 1; count--; 
break;
                        case 'Q': show_progress = 0; verbose = 0; count--; 
break;
-                       case 'D': sysmode = 1; count--; break;
+                       case 'D': sysmode = 1; InquireDevice = 0; count--; 
break;
                        case 's': CheckSuccess = strtol(optarg, NULL, 10); 
count--; break;
                        case 'I': InquireDevice = 0; break;
                        case 'b': busnum = strtol(optarg, NULL, 10); break;
@@ -316,6 +317,7 @@
                        case 'i': Interface = strtol(optarg, NULL, 16); break;
                        case 'u': Configuration = strtol(optarg, NULL, 16); 
break;
                        case 'a': AltSetting = strtol(optarg, NULL, 16); break;
+                       case 'j': mbim = 1; break;
 
                        case 'f':
                                longConfig = malloc(strlen(optarg)+5);
@@ -378,13 +380,13 @@
                                if (verbose) fprintf(output,"Taking all 
parameters from the command line\n\n");
        }
 
-       if (verbose)
+       if (verbose) {
                printVersion();
-
-       if (verbose)
                printConfig();
+               SHOW_PROGRESS(output,"\n");
+       }
 
-       /* Plausibility checks. The default IDs are mandatory */
+       /* Some sanity checks. The default IDs are mandatory */
        if (!(DefaultVendor && DefaultProduct)) {
                SHOW_PROGRESS(output,"No default vendor/product ID given. 
Aborting.\n\n");
                exit(1);
@@ -399,7 +401,6 @@
                        exit(1);
                }
        }
-       SHOW_PROGRESS(output,"\n");
 
        if (devnum == -1) {
                searchMode = SEARCH_DEFAULT;
@@ -420,6 +421,11 @@
 
        usb_find_busses();
        usb_find_devices();
+       
+       if (mbim) {
+               printf("%d\n", findMBIMConfig(DefaultVendor, DefaultProduct, 
searchMode) );
+               exit(0);
+       }
 
        /* Count existing target devices, remember for success check */
        if ((TargetVendor || TargetClass) && searchMode != SEARCH_BUSDEV) {
@@ -457,9 +463,12 @@
        }
 
        /* Get current configuration of default device
-        * A configuration value of -1 denotes a quirky device which has
-        * trouble determining the current configuration. Just use the first
-        * branch (which may be incorrect)
+        * A configuration value of -1 helps with quirky devices which have
+        * trouble determining the current configuration. We are just using the
+        * current config branch then.
+        * This affects only single-configuration devices so it's no problem.
+        * The dispatcher is using this always if no change of configuration
+        * is required for switching
         */
        if (Configuration > -1)
                currentConfig = get_current_configuration(devh);
@@ -468,11 +477,15 @@
                currentConfig = 0;
        }
 
+       if (Interface == -1)
+               Interface = 
dev->config[0].interface[0].altsetting[0].bInterfaceNumber;
+       SHOW_PROGRESS(output,"Using interface number %d\n", Interface);
+
        /* Get class of default device/interface */
        defaultClass = dev->descriptor.bDeviceClass;
-       interfaceClass = get_interface0_class(dev, currentConfig);
+       interfaceClass = get_interface_class(dev, currentConfig, Interface);
        if (interfaceClass == -1) {
-               fprintf(stderr, "Error: getting the interface class failed. 
Aborting.\n\n");
+               fprintf(stderr, "Error: getting the class of interface %d 
failed. Does it exist? Aborting.\n\n",Interface);
                exit(1);
        }
 
@@ -485,9 +498,12 @@
                        defaultClass = 8;
                }
 
-       if (Interface == -1)
-               Interface = 
dev->config[0].interface[0].altsetting[0].bInterfaceNumber;
-       SHOW_PROGRESS(output,"Using first interface: 0x%02x\n", Interface);
+       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, should be 8. 
Aborting.\n\n", Interface, defaultClass);
+                       exit(1);
+               }
 
        /* Check or get endpoints */
        if (strlen(MessageContent) || InquireDevice || CiscoMode) {
@@ -789,6 +805,55 @@
 }
 
 
+int findMBIMConfig(vendor, product, mode)
+{
+       struct usb_bus *bus;
+       int resultConfig=0;
+       int i, j;
+
+       SHOW_PROGRESS(output,"Search USB devices...\n");
+       for (bus = usb_get_busses(); bus; bus = bus->next) {
+               if (mode == SEARCH_BUSDEV)
+                       if (busnum != (int)strtol(bus->dirname,NULL,10))
+                               continue;
+               struct usb_device *dev;
+               for (dev = bus->devices; dev; dev = dev->next) {
+                       if (mode == SEARCH_BUSDEV) {
+                               if (dev->devnum != devnum)
+                                       continue;
+                       } else {
+//                             if (verbose)
+//                                     fprintf (output,"  searching devices, 
found USB ID %04x:%04x\n", dev->descriptor.idVendor, dev->descriptor.idProduct);
+                               if (dev->descriptor.idVendor != vendor)
+                                       continue;
+                               if (product != dev->descriptor.idProduct)
+                                       continue;
+                       }
+                       SHOW_PROGRESS(output,"Found device, searching for MBIM 
configuration...\n");
+
+                       // No check if there is only one configuration
+                       if (dev->descriptor.bNumConfigurations < 2)
+                               return -1;
+
+                       // Checking all interfaces of all configurations
+                       for (j=0; j<dev->descriptor.bNumConfigurations; j++) {
+                               resultConfig = 
dev->config[j].bConfigurationValue;
+                               for (i=0; i<dev->config[j].bNumInterfaces; i++) 
{
+//                                     SHOW_PROGRESS(output,"MBIM Check: 
looking at ifc %d, class is %d, subclass is %d\n",
+//                                             
i,dev->config[j].interface[i].altsetting[0].bInterfaceClass,dev->config[j].interface[i].altsetting[0].bInterfaceSubClass);
+
+                                       if ( 
dev->config[j].interface[i].altsetting[0].bInterfaceClass == 2 )
+                                               if ( 
dev->config[j].interface[i].altsetting[0].bInterfaceSubClass == 0x0e )
+                                                       // found MBIM interface 
in this configuration
+                                                       return resultConfig;
+                               }
+                       }
+                       return -1;
+               }
+       }
+       return 0;
+}
+
 void resetUSB ()
 {
        int success;
@@ -948,6 +1013,10 @@
 
        SHOW_PROGRESS(output,"Trying to send Sierra control message\n");
        ret = usb_control_msg(devh, 0x40, 0x0b, 00000001, 0, buffer, 0, 1000);
+       if (ret == -32) {
+               SHOW_PROGRESS(output," communication with device stopped. May 
have switched, continue ...\n");
+           return;
+       }
        if (ret != 0) {
                fprintf(stderr, "Error: sending Sierra control message failed 
(error %d). Aborting.\n\n", ret);
            exit(1);
@@ -1644,6 +1713,27 @@
        return -1;
 }
 
+int get_interface_class(struct usb_device *dev, int cfgNumber, int ifcNumber)
+{
+       int i;
+       int j;
+       // some single-configuration devices balk on iteration, treat them 
separately
+       if (cfgNumber == 0)
+               for (i=0; i<dev->config[0].bNumInterfaces; i++) {
+//                     SHOW_PROGRESS(output,"Test: looking at ifc %d, class is 
%d\n",i,dev->config[0].interface[i].altsetting[0].bInterfaceClass);
+                       if 
(dev->config[0].interface[i].altsetting[0].bInterfaceNumber == ifcNumber)
+                               return 
dev->config[0].interface[i].altsetting[0].bInterfaceClass;
+               }
+       else
+               for (j=0; j<dev->descriptor.bNumConfigurations; j++)
+                       if (dev->config[j].bConfigurationValue == cfgNumber)
+                               for (i=0; i<dev->config[j].bNumInterfaces; i++) 
{
+//                                     SHOW_PROGRESS(output,"Test: looking at 
ifc %d, class is 
%d\n",i,dev->config[j].interface[i].altsetting[0].bInterfaceClass);
+                                       if 
(dev->config[j].interface[i].altsetting[0].bInterfaceNumber == ifcNumber)
+                                               return 
dev->config[j].interface[i].altsetting[0].bInterfaceClass;
+                               }
+       return -1;
+}
 
 /* Parameter parsing */
 
@@ -1812,6 +1902,7 @@
        fprintf (output,"\nUsage: usb_modeswitch [<params>] [-c filename]\n\n"
        " -h, --help                    this help\n"
        " -e, --version                 print version information and exit\n"
+       " -j, --find-mbim               return config no. with MBIM interface, 
exit\n"
        " -v, --default-vendor NUM      vendor ID of original mode 
(mandatory)\n"
        " -p, --default-product NUM     product ID of original mode 
(mandatory)\n"
        " -V, --target-vendor NUM       target mode vendor ID (optional)\n"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/usb-modeswitch-1.2.3/usb_modeswitch.conf 
new/usb-modeswitch-1.2.5/usb_modeswitch.conf
--- old/usb-modeswitch-1.2.3/usb_modeswitch.conf        2012-01-30 
23:52:14.000000000 +0100
+++ new/usb-modeswitch-1.2.5/usb_modeswitch.conf        2012-11-10 
00:38:47.000000000 +0100
@@ -17,3 +17,11 @@
 # "usb_modeswitch_<interface-name>" and probably others
 
 EnableLogging=0
+
+
+# Optional increase of "delay_use" for the usb-storage driver; there are hints
+# that a recent kernel default change to 1 sec. may lead to problems, particu-
+# larly with USB 3.0 ports. Set this to at least 3 (seconds) in that case.
+# Does nothing if the current system value is same or higher
+
+# SetStorageDelay=3
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/usb-modeswitch-1.2.3/usb_modeswitch.h 
new/usb-modeswitch-1.2.5/usb_modeswitch.h
--- old/usb-modeswitch-1.2.3/usb_modeswitch.h   2012-01-28 17:59:03.000000000 
+0100
+++ new/usb-modeswitch-1.2.5/usb_modeswitch.h   2012-11-08 23:36:57.000000000 
+0100
@@ -2,7 +2,7 @@
   This file is part of usb_modeswitch, a mode switching tool for controlling
   flip flop (multiple device) USB gear
 
-  Version 1.2.3, 2012/01/28
+  Version 1.2.5, 2012/11/09
   Copyright (C) 2007 - 2012  Josua Dietze
 
   Config file parsing stuff borrowed from Guillaume Dargaud
@@ -52,6 +52,7 @@
 int find_first_bulk_input_endpoint(struct usb_device *dev);
 int get_current_configuration(struct usb_dev_handle* devh);
 int get_interface0_class(struct usb_device *dev, int devconfig);
+int get_interface_class(struct usb_device *dev, int cfgNumber, int ifcNumber);
 char* ReadParseParam(const char* FileName, char *VariableName);
 int hex2num(char c);
 int hex2byte(const char *hex);
@@ -63,6 +64,8 @@
 int deviceInquire();
 void resetUSB();
 void release_usb_device(int dummy);
+int findMBIMConfig(int vendor, int product, int mode);
+
 
 // Boolean
 #define  and     &&
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/usb-modeswitch-1.2.3/usb_modeswitch.sh 
new/usb-modeswitch-1.2.5/usb_modeswitch.sh
--- old/usb-modeswitch-1.2.3/usb_modeswitch.sh  2012-01-28 10:30:04.000000000 
+0100
+++ new/usb-modeswitch-1.2.5/usb_modeswitch.sh  2012-11-08 23:37:07.000000000 
+0100
@@ -1,5 +1,5 @@
 #!/bin/sh
-# part of usb_modeswitch 1.2.3
+# part of usb_modeswitch 1.2.5
 device_in()
 {
        if [ ! -e /var/lib/usb_modeswitch/$1 ]; then
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/usb-modeswitch-1.2.3/usb_modeswitch.tcl 
new/usb-modeswitch-1.2.5/usb_modeswitch.tcl
--- old/usb-modeswitch-1.2.3/usb_modeswitch.tcl 2012-01-28 21:46:09.000000000 
+0100
+++ new/usb-modeswitch-1.2.5/usb_modeswitch.tcl 2012-11-10 00:35:18.000000000 
+0100
@@ -9,7 +9,7 @@
 # the mode switching program with the matching parameter
 # file from /usr/share/usb_modeswitch
 #
-# Part of usb-modeswitch-1.2.3 package
+# Part of usb-modeswitch-1.2.5 package
 # (C) Josua Dietze 2009-2012
 
 set arg0 [lindex $argv 0]
@@ -26,14 +26,13 @@
 
 set flags(logging) 0
 set flags(noswitching) 0
-
-#set env(PATH) "/bin:/sbin:/usr/bin:/usr/sbin"
+set flags(stordelay) 0
 
 # Execution starts at file bottom
 
 proc {Main} {argv argc} {
 
-global scsi usb config match device flags settings
+global scsi usb config match device flags setup devdir
 
 set loginit [ParseGlobalConfig]
 
@@ -53,15 +52,17 @@
 }
 
 set argList [split [lindex $argv 1] /]
-
 if [string length [lindex $argList 1]] {
        set device [lindex $argList 1]
 } else {
        set device "noname"
 }
 
-Log "Raw args from udev: [lindex $argv 1]\n\n$loginit"
+if {$flags(stordelay) > 0} {
+       SetStorageDelay $flags(stordelay)
+}
 
+Log "Raw args from udev: [lindex $argv 1]\n\n$loginit"
 if {$device == "noname"} {
        Log "No data from udev. Exiting"
        SafeExit
@@ -72,16 +73,11 @@
        SafeExit
 }
 
-if {![regexp /lib/udev/usb_modeswitch [lindex $argv 2]]} {
-       Log "Dispatcher was not run from call script. Exiting"
-       SafeExit
-}
+set setup(dbdir) /usr/share/usb_modeswitch
+set setup(dbdir_etc) /etc/usb_modeswitch.d
 
-set settings(dbdir)    /usr/share/usb_modeswitch
-set settings(dbdir_etc)        /etc/usb_modeswitch.d
 
-
-if {![file exists $settings(dbdir)] && ![file exists $settings(dbdir_etc)]} {
+if {![file exists $setup(dbdir)] && ![file exists $setup(dbdir_etc)]} {
        Log "Error: no config database found in /usr/share or /etc. Exiting"
        SafeExit
 }
@@ -94,20 +90,23 @@
 # arg 0: the bus id for the device (udev: %b)
 # arg 1: the "kernel name" for the device (udev: %k)
 #
-# Both together give the top directory where the path
-# to the SCSI attributes can be determined (further down)
-# Addendum: older kernel/udev version seem to differ in
-# providing these attributes - or not. So more probing
-# is needed
+# 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! Exiting"
                SafeExit
        } else {
                if {![regexp {(.*?):} [lindex $argList 1] d dev_top]} {
-                       Log "Could not determine top device dir from udev 
values! Exiting"
-                       SafeExit
+                       if [regexp {([0-9]+-[0-9]+\.?[0-9]*)} [lindex $argList 
1] d dev_top] {
+                               # new udev rules file, got to check class of 
first interface
+                               Log "Called by new rules file - remember to 
check class of first interface ..."
+                               set ifChk 1
+                       } else {
+                               Log "Could not determine device dir from udev 
values! Exiting"
+                               SafeExit
+                       }
                }
        }
 } else {
@@ -121,7 +120,6 @@
        SafeExit
 }
 Log "Using top device dir $devdir"
-set ifdir "[file tail $devdir]:1.0"
 
 
 # Mapping of the short string identifiers (in the config
@@ -143,6 +141,35 @@
        SafeExit
 }
 
+set iface 0
+if $ifChk {
+       Log "Check class of first interface ..."
+       set iface [ChkIface 0]
+       if {$iface < 0} {
+               set iface [ChkIface 9]
+       }
+       if {$iface < 0} {
+               if {$usb(idVendor)=="19d2" && $usb(idProduct)=="2000"} {
+                       set iface [ChkIface 3]
+               }
+# Corrected, was wrongly reported
+#              if {$usb(idVendor)=="16d8" && $usb(idProduct)=="6803"} {
+#                      set iface [ChkIface 3]
+#              }
+       }
+       if {$iface < 0} {
+               Log " Device is not in install mode. Exiting"
+               SafeExit
+       } else {
+               Log " Device is in install mode."
+       }
+}
+set ifdir [file tail [IfDir $iface]]
+regexp {:([0-9]+\.[0-9]+)$} $ifdir d iface
+
+Log "Using interface $iface"
+
+
 if $flags(logging) {
        Log "----------------\nUSB values from sysfs:"
        foreach attr {manufacturer product serial} {
@@ -182,7 +209,7 @@
        }
 }
 if $scsiNeeded {
-       if [ReadSCSIAttrs $devdir:1.0] {
+       if [ReadSCSIAttrs $devdir:$iface] {
                Log "----------------\nSCSI values from sysfs:"
                foreach attr {vendor model rev} {
                        Log " $attr\t$scsi($attr)"
@@ -226,11 +253,32 @@
                        after $config(waitBefore)
                        Log " waiting is over, switching starts now"
                }
+               if {$config(noMBIMCheck)==0 && $usb(bNumConfigurations) > 1} {
+                       Log "Device may have an MBIM configuration, checking 
driver ..."
+                       if [CheckMBIM] {
+                               Log " driver for MBIM devices is available"
+                               Log "Finding 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 config(driverModule) ""
+                                               set configBuffer 
"Configuration=$cfgno"
+                                       } else {
+                                               Log " No MBIM configuration 
found, switch to legacy modem mode"
+                                       }
+                               }
+                       } else {
+                               Log " no MBIM driver found, switch to legacy 
modem mode"
+                       }
+               }
 
                # Now we are actually switching
                if $flags(logging) {
-                       Log "Command to be run:\nusb_modeswitch -I -W -D -s 20 
$configParam $busParam $devParam -v $usb(idVendor) -p $usb(idProduct) -f 
\$configBuffer"
-                       set report [exec /usr/sbin/usb_modeswitch -I -W -D -s 
20 $configParam $busParam $devParam -v $usb(idVendor) -p $usb(idProduct) -f 
"$configBuffer" 2>@ stdout]
+                       Log "Command to be run:\nusb_modeswitch -W -D -s 20 
$configParam $busParam $devParam -v $usb(idVendor) -p $usb(idProduct) -f 
\$configBuffer"
+                       set report [exec /usr/sbin/usb_modeswitch -W -D -s 20 
$configParam $busParam $devParam -v $usb(idVendor) -p $usb(idProduct) -f 
"$configBuffer" 2>@ stdout]
                        Log "\nVerbose debug output of usb_modeswitch and 
libusb follows"
                        Log "(Note that some USB errors are to be expected in 
the process)"
                        Log "--------------------------------"
@@ -238,7 +286,7 @@
                        Log "--------------------------------"
                        Log "(end of usb_modeswitch output)\n"
                } else {
-                       set report [exec /usr/sbin/usb_modeswitch -I -Q -D -s 
20 $configParam $busParam $devParam -v $usb(idVendor) -p $usb(idProduct) -f 
"$configBuffer" 2>@ stdout]
+                       set report [exec /usr/sbin/usb_modeswitch -Q -D -s 20 
$configParam $busParam $devParam -v $usb(idVendor) -p $usb(idProduct) -f 
"$configBuffer" 2>@ stdout]
                }
                break
        } else {
@@ -281,7 +329,7 @@
 
 # Now checking for bound drivers (only for class 0xff)
 
-if {$usb($ifdir/bInterfaceClass) != "" && [regexp {ok:} $report]} {
+if {$config(driverModule) != "" && $usb($ifdir/bInterfaceClass) != "" && 
[regexp {ok:} $report]} {
        if {$usb($ifdir/bInterfaceClass) != "ff"} {
                set config(driverModule) ""
                Log " No vendor-specific class found, skip driver checking"
@@ -496,6 +544,7 @@
 set rc [open $configFile r]
 while {![eof $rc]} {
        gets $rc line
+       if [regexp {^#} [string trim $line]] {continue}
        if [regexp {DisableSwitching\s*=\s*([^\s]+)} $line d val] {
                if [regexp -nocase {1|yes|true} $val] {
                        set flags(noswitching) 1
@@ -506,6 +555,11 @@
                        set flags(logging) 1
                }
        }
+       if [regexp {SetStorageDelay\s*=\s*([^\s]+)} $line d val] {
+               if [regexp {\d+} $val] {
+                       set flags(stordelay) $val
+               }
+       }
 
 }
 return "Using global config file: $configFile"
@@ -524,6 +578,7 @@
 set config(targetProduct) ""
 set config(targetClass) ""
 set config(Configuration) ""
+set config(noMBIMCheck) 0
 set config(checkSuccess) 20
 set loadDriver 1
 
@@ -554,6 +609,9 @@
 if [regexp -line {^[^#]*?WaitBefore.*?=.*?([0-9]+).*?$} $configContent d 
config(waitBefore)] {
        Log "config: WaitBefore set to $config(waitBefore)"
 }
+if [regexp -line {^[^#]*?NoMBIMCheck.*?=.*?([0-9]+).*?$} $configContent d 
config(noMBIMCheck)] {
+       Log "config: noMBIMCheck set to $config(noMBIMCheck)"
+}
 if [regexp -line {^[^#]*?NoDriverLoading.*?=.*?(1|yes|true).*?$} 
$configContent] {
        set loadDriver 0
        Log "config: NoDriverLoading is set to active"
@@ -582,17 +640,17 @@
 
 proc ConfigGet {command config} {
 
-global settings
+global setup
 
 switch $command {
 
        conflist {
                # Unpackaged configs first; sorting is essential for priority
-               set configList [lsort -decreasing [glob -nocomplain 
$settings(dbdir_etc)/$config*]]
-               set configList [concat $configList [lsort -decreasing [glob 
-nocomplain $settings(dbdir)/$config*]]]
-               if [file exists $settings(dbdir)/configPack.tar.gz] {
-                       Log "Found packed config collection 
$settings(dbdir)/configPack.tar.gz"
-                       if [catch {set packedList [exec tar -tzf 
$settings(dbdir)/configPack.tar.gz 2>/dev/null]} err] {
+               set configList [lsort -decreasing [glob -nocomplain 
$setup(dbdir_etc)/$config*]]
+               set configList [concat $configList [lsort -decreasing [glob 
-nocomplain $setup(dbdir)/$config*]]]
+               if [file exists $setup(dbdir)/configPack.tar.gz] {
+                       Log "Found packed config collection 
$setup(dbdir)/configPack.tar.gz"
+                       if [catch {set packedList [exec tar -tzf 
$setup(dbdir)/configPack.tar.gz 2>/dev/null]} err] {
                                Log "Error: problem opening config package; tar 
returned\n $err"
                                return {}
                        }
@@ -609,11 +667,11 @@
        conffile {
                if [regexp {^pack/} $config] {
                        set config [regsub {pack/} $config {}]
-                       Log "Extracting config $config from collection 
$settings(dbdir)/configPack.tar.gz"
-                       set configContent [exec tar -xzOf 
$settings(dbdir)/configPack.tar.gz $config 2>/dev/null]
+                       Log "Extracting config $config from collection 
$setup(dbdir)/configPack.tar.gz"
+                       set configContent [exec tar -xzOf 
$setup(dbdir)/configPack.tar.gz $config 2>/dev/null]
                } else {
-                       if [regexp [list $settings(dbdir_etc)] $config] {
-                               Log "Using config file from override folder 
$settings(dbdir_etc)"
+                       if [regexp [list $setup(dbdir_etc)] $config] {
+                               Log "Using config file from override folder 
$setup(dbdir_etc)"
                                SysLog "usb_modeswitch: using overriding config 
file $config; make sure this is intended"
                                SysLog "usb_modeswitch: please report any new 
or corrected settings; otherwise, check for outdated files"
                        }
@@ -631,8 +689,8 @@
 proc {Log} {msg} {
 
 global flags device
-if {$flags(logging) == 0} {return}
 
+if {$flags(logging) == 0} {return}
 if {![info exists flags(wc)]} {
        if [catch {set flags(wc) [open /var/log/usb_modeswitch_$device w]} err] 
{
                if [catch {set flags(wc) [open /dev/console w]} err] {
@@ -923,10 +981,11 @@
 }
 # end of proc {RemoveFromBindList}
 
+
 proc {CheckSuccess} {devdir} {
 
 global config usb
-set ifdir "[file tail $devdir]:1.0"
+set ifdir [file tail [IfDir 0]]
 
 if {[string length $config(targetClass)] || [string length 
$config(Configuration)]} {
        set config(targetVendor) $usb(idVendor)
@@ -942,6 +1001,9 @@
        } else {
                Log " Reading attributes ..."
        }
+       set ifdir [IfDir 0]
+       if {$ifdir == ""} {continue}
+       set ifdir [file tail $ifdir]
        if {![ReadUSBAttrs $devdir $ifdir]} {
                Log " Essential attributes are missing, continue wait ..."
                continue
@@ -950,7 +1012,7 @@
                if {![regexp $usb($ifdir/bInterfaceClass) 
$config(targetClass)]} {continue}
        }
        if [string length $config(Configuration)] {
-               if {$usb(bConfigurationValue) != $config(Configuration} 
{continue}
+               if {$usb(bConfigurationValue) != $config(Configuration)} 
{continue}
        }
        if {![regexp $usb(idVendor) $config(targetVendor)]} {continue}
        if {![regexp $usb(idProduct) $config(targetProduct)]} {continue}
@@ -965,6 +1027,51 @@
 }
 # end of proc {CheckSuccess}
 
+
+proc {ChkIface} {iface} {
+
+if {[IfClass $iface] == 8} {
+       return $iface
+} else {
+       return -1
+}
+
+}
+# end of proc {ChkIface}
+
+proc {IfDir} {iface} {
+
+global devdir
+set allfiles [glob -nocomplain $devdir/*]
+set files [glob -nocomplain $devdir/*.$iface]
+if {[llength $files] == 0} {
+       return ""
+}
+set ifdir [lindex $files 0]
+if {![file isdirectory $ifdir]} {
+       return ""
+}
+return $ifdir
+
+}
+# end of proc {IfDir}
+
+proc {IfClass} {iface} {
+
+set ifdir [IfDir $iface]
+
+if {![file exists $ifdir/bInterfaceClass]} {
+       return -1
+}
+set rc [open $ifdir/bInterfaceClass r]
+set c [read $rc]
+close $rc
+return [string trimleft [string trim $c] 0]
+
+}
+# end of proc {IfClass}
+
+
 proc {SysLog} {msg} {
 
 global flags
@@ -986,6 +1093,38 @@
 }
 # end of proc {SysLog}
 
+proc {SetStorageDelay} {secs} {
+
+Log "Adjusting delay for USB storage devices ..."
+set attrib /sys/module/usb_storage/parameters/delay_use
+if {![file exists $attrib]} {
+       Log "Error: could not find delay_use attribute"
+       return
+}
+if [catch {set ch [open $attrib r+]} err] {
+       Log "Error: could not access delay_use attribute: $err"
+       return
+}
+if {[read $ch] < $secs} {
+       seek $ch 0 start
+       puts -nonewline $ch $secs
+       Log " Delay set to $secs seconds\n"
+} else {
+       Log " Current value is higher than $secs. Leave it alone\n"
+}
+close $ch
+
+}
+# end of proc {SetStorageDelay}
+
+proc {CheckMBIM} {} {
+
+set kversion [exec uname -r]
+if [file exists /lib/modules/$kversion/kernel/drivers/net/usb/cdc_mbim.ko] 
{return 1}
+if [file exists /sys/bus/usb/drivers/cdc_mbim] {return 1}
+return 0
+
+}
 
 
 # The actual entry point

++++++ usb-modeswitch-data-20120531.tar.bz2 -> 
usb-modeswitch-data-20121109.tar.bz2 ++++++
++++ 1781 lines of diff (skipped)

-- 
To unsubscribe, e-mail: opensuse-commit+unsubscr...@opensuse.org
For additional commands, e-mail: opensuse-commit+h...@opensuse.org

Reply via email to