packages/utils/usb-modeswitch: use the hammer
authorJo-Philipp Wich <jow@openwrt.org>
Mon, 24 Oct 2011 17:52:58 +0000 (17:52 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Mon, 24 Oct 2011 17:52:58 +0000 (17:52 +0000)
Not particularly beautiful but doing the trick...

Signed-off-by: Daniel Golle <dgolle@allnet.de>
SVN-Revision: 28555

utils/usb-modeswitch/files/modeswitch.hotplug

index 1aecb1fb3150da9b28cbed8d3057b208a5836e50..7f9ce9411d1e45363aebb18b2d6e335d5927f22d 100644 (file)
@@ -120,7 +120,20 @@ if [ "$ACTION" = add ]; then
                # If a candidate is remaining, start usb-modeswitch
                [ -n "$configs" ] && {
                        log "$DEVICENAME: Selecting ${configs%% *} for mode switching"
-                       $modeswitch -c "${configs%% *}"
+                       # ugly workaround, but working for all hw we got for testing
+                       switching_done=0
+                       switching_tries=0
+                       local usb_dir="/sys/$DEVPATH"       
+                       [ -f "$usb_dir/idVendor" ] || usb_dir="${usb_dir%/*}"
+                       while [ $switching_done -lt 1 -a $switching_tries -le 6 ]; do
+                               $modeswitch -I -D -n -s 30 -c "${configs%% *}"
+                               if [ $(sanitize "$usb_dir/idProduct") -eq $uPid ]; then
+                                       log "switching seemingly failed"
+                               else
+                                       switching_done=1
+                               fi
+                               switching_tries=$(( $switching_tries + 1 ))
+                       done
                }
        }
 fi