Compare commits
2 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7a26f47661 | ||
|
|
7c2c5f8d87 |
3 changed files with 348 additions and 82 deletions
334
0001-Bring-back-the-module-binding.patch
Normal file
334
0001-Bring-back-the-module-binding.patch
Normal file
|
|
@ -0,0 +1,334 @@
|
|||
From cf2afa734597ef88b8f5871bf18cf849b105e51d Mon Sep 17 00:00:00 2001
|
||||
From: Lubomir Rintel <lkundrak@v3.sk>
|
||||
Date: Mon, 25 Jul 2016 12:03:22 +0200
|
||||
Subject: [PATCH] Bring back the module binding
|
||||
|
||||
We still need it for some devices.
|
||||
|
||||
http://www.draisberghof.de/usb_modeswitch/bb/viewtopic.php?f=2&t=2560
|
||||
---
|
||||
usb_modeswitch.sh | 23 +++++-
|
||||
usb_modeswitch.tcl | 214 +++++++++++++++++++++++++++++++++++++++++++++++++----
|
||||
2 files changed, 221 insertions(+), 16 deletions(-)
|
||||
|
||||
diff --git a/usb_modeswitch.sh b/usb_modeswitch.sh
|
||||
index b126ec3..f4b76dd 100755
|
||||
--- a/usb_modeswitch.sh
|
||||
+++ b/usb_modeswitch.sh
|
||||
@@ -40,7 +40,27 @@ fi
|
||||
PATH=/sbin:/usr/sbin:$PATH
|
||||
case "$1" in
|
||||
--driver-bind)
|
||||
- # driver binding code removed
|
||||
+ (
|
||||
+ dir=$(ls -d /sys$2/ttyUSB* 2>/dev/null)
|
||||
+ sleep 1
|
||||
+ if [ ! -z "$dir" ]; then
|
||||
+ exit 0
|
||||
+ fi
|
||||
+ set +e
|
||||
+ device_in "bind_list" $v_id $p_id
|
||||
+ if [ "$?" = "1" ]; then
|
||||
+ id_attr="/sys/bus/usb-serial/drivers/option1/new_id"
|
||||
+ if [ ! -e "$id_attr" ]; then
|
||||
+ modprobe option 2>/dev/null || true
|
||||
+ fi
|
||||
+ if [ -e "$id_attr" ]; then
|
||||
+ echo "$v_id $p_id ff" > $id_attr
|
||||
+ else
|
||||
+ modprobe -r usbserial 2>/dev/null
|
||||
+ modprobe usbserial "vendor=0x$v_id" "product=0x$p_id" 2>/dev/null
|
||||
+ fi
|
||||
+ fi
|
||||
+ ) &
|
||||
exit 0
|
||||
;;
|
||||
--symlink-name)
|
||||
@@ -53,7 +73,6 @@ case "$1" in
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
-
|
||||
IFS='/' read -r p1 p2 <<EOF
|
||||
$1
|
||||
EOF
|
||||
diff --git a/usb_modeswitch.tcl b/usb_modeswitch.tcl
|
||||
index 3e590fd..b74d46c 100755
|
||||
--- a/usb_modeswitch.tcl
|
||||
+++ b/usb_modeswitch.tcl
|
||||
@@ -276,6 +276,7 @@ foreach mconfig $configList {
|
||||
set cfgno [string trim $cfgno]
|
||||
if {$cfgno > 0} {
|
||||
set config(Configuration) $cfgno
|
||||
+ set config(DriverModule) ""
|
||||
set flags(config) "Configuration=$cfgno"
|
||||
} else {
|
||||
Log " No MBIM configuration found, switch to legacy modem mode"
|
||||
@@ -290,10 +291,6 @@ foreach mconfig $configList {
|
||||
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) {
|
||||
@@ -348,19 +345,68 @@ if [regexp {ok:busdev} $report] {
|
||||
ReadUSBAttrs $devdir $ifdir
|
||||
}
|
||||
|
||||
-# driver binding removed !!
|
||||
+# Checking for bound drivers if there is an interface with class 0xff
|
||||
|
||||
-if {[string length "$usb(idVendor)$usb(idProduct)"] < 8} {
|
||||
- if {![regexp {ok:(\w{4}):(\w{4})} $report d usb(idVendor) usb(idProduct)]} {
|
||||
- Log "No target vendor/product ID found or given, can't continue. Abort"
|
||||
- SafeExit
|
||||
+if {$config(DriverModule) != "" && [regexp {ok:} $report]} {
|
||||
+ if [HasFF $devdir] {
|
||||
+ AddToList link_list $usb(idVendor):$usb(idProduct)
|
||||
+ } else {
|
||||
+ set config(DriverModule) ""
|
||||
+ Log " No vendor-specific class found, skip driver check"
|
||||
}
|
||||
}
|
||||
-# wait for drivers to bind
|
||||
-after 500
|
||||
-if {[llength [glob -nocomplain $devdir/$ifdir/ttyUSB*]] > 0} {
|
||||
- Log "Serial USB driver bound to interface 0\n will try to guess and symlink modem port on next connect"
|
||||
- AddToList link_list $usb(idVendor):$usb(idProduct)
|
||||
+
|
||||
+# If module is set (it is by default), driver shall be loaded.
|
||||
+# If not, then NoDriverLoading is active
|
||||
+
|
||||
+if {$config(DriverModule) != ""} {
|
||||
+ if {[string length "$usb(idVendor)$usb(idProduct)"] < 8} {
|
||||
+ if {![regexp {ok:(\w{4}):(\w{4})} $report d usb(idVendor) usb(idProduct)]} {
|
||||
+ Log "No target vendor/product ID found or given, can't continue. Abort"
|
||||
+ SafeExit
|
||||
+ }
|
||||
+ }
|
||||
+ # wait for any drivers to bind automatically
|
||||
+ after 1500
|
||||
+ Log "Now check for bound driver ..."
|
||||
+ if {![file exists $devdir/$ifdir/driver]} {
|
||||
+ Log " no driver has bound to interface 0 yet"
|
||||
+
|
||||
+ # If device is known, the sh wrapper will take care, else:
|
||||
+ if {[InBindList $usb(idVendor):$usb(idProduct)] == 0} {
|
||||
+ Log "Device is not in \"bind_list\" yet, bind it now"
|
||||
+
|
||||
+ # Load driver
|
||||
+ CheckDriverBind $usb(idVendor) $usb(idProduct)
|
||||
+
|
||||
+ # Old/slow systems may take a while to create the devices
|
||||
+ set counter 0
|
||||
+ while {![file exists $devdir/$ifdir/driver]} {
|
||||
+ if {$counter == 14} {break}
|
||||
+ after 500
|
||||
+ incr counter
|
||||
+ }
|
||||
+ if {$counter == 14} {
|
||||
+ Log " driver binding failed"
|
||||
+ } else {
|
||||
+ Log " driver was bound to the device"
|
||||
+ AddToList bind_list $usb(idVendor):$usb(idProduct)
|
||||
+ }
|
||||
+ }
|
||||
+ } else {
|
||||
+ Log " driver has bound, device is known"
|
||||
+ if {[llength [glob -nocomplain $devdir/$ifdir/ttyUSB*]] > 0} {
|
||||
+ AddToList link_list $usb(idVendor):$usb(idProduct)
|
||||
+ }
|
||||
+ }
|
||||
+} else {
|
||||
+ # Just in case "NoDriverLoading" was added after the first bind
|
||||
+ RemoveFromBindList $usb(idVendor):$usb(idProduct)
|
||||
+}
|
||||
+
|
||||
+if [regexp {ok:$} $report] {
|
||||
+ # "NoDriverLoading" was set
|
||||
+ Log "No driver check or bind for this device"
|
||||
}
|
||||
|
||||
# In newer kernels there is a switch to avoid the use of a device
|
||||
@@ -553,6 +599,8 @@ return "Use global config file: $configFile"
|
||||
proc ParseDeviceConfig {cfg} {
|
||||
|
||||
global config
|
||||
+set config(DriverModule) ""
|
||||
+set config(DriverIDPath) ""
|
||||
set config(WaitBefore) ""
|
||||
set config(TargetVendor) ""
|
||||
set config(TargetProduct) ""
|
||||
@@ -561,6 +609,7 @@ set config(Configuration) ""
|
||||
set config(NoMBIMCheck) 0
|
||||
set config(PantechMode) 0
|
||||
set config(CheckSuccess) 20
|
||||
+set loadDriver 1
|
||||
|
||||
foreach pname [lsort [array names config]] {
|
||||
if [regexp -line "^\[^# \]*?$pname.*?= *(0x(\\w+)|\"(\[0-9a-fA-F,\]+)\"|(\[0-9\]+)) *\$" $cfg d config($pname)] {
|
||||
@@ -568,6 +617,26 @@ foreach pname [lsort [array names config]] {
|
||||
}
|
||||
}
|
||||
|
||||
+if [regexp -line {^[^#]*?NoDriverLoading.*?=.*?(1|yes|true).*?$} $cfg] {
|
||||
+ set loadDriver 0
|
||||
+ Log "config: NoDriverLoading is set to active"
|
||||
+}
|
||||
+
|
||||
+# For general driver loading; TODO: add respective device names.
|
||||
+# Presently only useful for HSO devices (which are recounted now)
|
||||
+if $loadDriver {
|
||||
+ if {$config(DriverModule) == ""} {
|
||||
+ set config(DriverModule) "option"
|
||||
+ set config(DriverIDPath) "/sys/bus/usb-serial/drivers/option1"
|
||||
+ } else {
|
||||
+ if {$config(DriverIDPath) == ""} {
|
||||
+ set config(DriverIDPath) "/sys/bus/usb/drivers/$config(DriverModule)"
|
||||
+ }
|
||||
+ }
|
||||
+ Log "Driver module is \"$config(DriverModule)\", ID path is $config(DriverIDPath)\n"
|
||||
+} else {
|
||||
+ Log "Driver will not be handled by usb_modeswitch"
|
||||
+}
|
||||
set config(WaitBefore) [string trimleft $config(WaitBefore) 0]
|
||||
|
||||
}
|
||||
@@ -768,6 +837,92 @@ return $symlinkName
|
||||
# end of proc {SymLinkName}
|
||||
|
||||
|
||||
+# Load and bind driver (default "option")
|
||||
+#
|
||||
+proc {CheckDriverBind} {vid pid} {
|
||||
+global config
|
||||
+
|
||||
+foreach fn {/sbin/modprobe /usr/sbin/modprobe} {
|
||||
+ if [file exists $fn] {
|
||||
+ set loader $fn
|
||||
+ }
|
||||
+}
|
||||
+Log "Module loader is $loader"
|
||||
+
|
||||
+set idfile $config(DriverIDPath)/new_id
|
||||
+if {![file exists $idfile]} {
|
||||
+ if {$loader == ""} {
|
||||
+ Log "Can't do anymore without module loader; get \"modtools\"!"
|
||||
+ return
|
||||
+ }
|
||||
+ Log "\nTry to load module \"$config(DriverModule)\""
|
||||
+ if [catch {set result [exec $loader -v $config(DriverModule)]} err] {
|
||||
+ Log " Running \"$loader $config(DriverModule)\" gave an error:\n $err"
|
||||
+ } else {
|
||||
+ Log " Module was loaded successfully:\n$result"
|
||||
+ }
|
||||
+} else {
|
||||
+ Log "Module is active already"
|
||||
+}
|
||||
+set i 0
|
||||
+while {$i < 50} {
|
||||
+ if [file exists $idfile] {
|
||||
+ break
|
||||
+ }
|
||||
+ after 20
|
||||
+ incr i
|
||||
+}
|
||||
+if {$i < 50} {
|
||||
+ Log "Try to add ID to driver \"$config(DriverModule)\""
|
||||
+ SysLog "usb_modeswitch: add device ID $vid:$pid to driver \"$config(DriverModule)\""
|
||||
+ SysLog "usb_modeswitch: please report the device ID to the Linux USB developers!"
|
||||
+ if [catch {exec echo "$vid $pid ff" >$idfile} err] {
|
||||
+ Log " Error adding ID to driver:\n $err"
|
||||
+ } else {
|
||||
+ Log " ID added to driver; check for new devices in /dev"
|
||||
+ }
|
||||
+} else {
|
||||
+ Log " \"$idfile\" not found, check if kernel version is at least 2.6.27"
|
||||
+ Log "Fall back to \"usbserial\""
|
||||
+ set config(DriverModule) usbserial
|
||||
+ Log "\nTry to unload driver \"usbserial\""
|
||||
+ if [catch {exec $loader -r usbserial} err] {
|
||||
+ Log " Running \"$loader -r usbserial\" gave an error:\n $err"
|
||||
+ Log "No more fallbacks"
|
||||
+ return
|
||||
+ }
|
||||
+ after 50
|
||||
+ Log "\nTry to load driver \"usbserial\" with device IDs"
|
||||
+ if [catch {set result [exec $loader -v usbserial vendor=0x$vid product=0x$pid]} err] {
|
||||
+ Log " Running \"$loader usbserial\" gave an error:\n $err"
|
||||
+ } else {
|
||||
+ Log " Driver was loaded successfully:\n$result"
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+}
|
||||
+# end of proc {CheckDriverBind}
|
||||
+
|
||||
+
|
||||
+# Check if USB ID is listed as needing driver binding
|
||||
+proc {InBindList} {id} {
|
||||
+
|
||||
+set listfile /var/lib/usb_modeswitch/bind_list
|
||||
+if {![file exists $listfile]} {return 0}
|
||||
+set rc [open $listfile r]
|
||||
+set buffer [read $rc]
|
||||
+close $rc
|
||||
+if [string match *$id* $buffer] {
|
||||
+Log "Found $id in bind_list"
|
||||
+ return 1
|
||||
+} else {
|
||||
+Log "No $id in bind_list"
|
||||
+ return 0
|
||||
+}
|
||||
+
|
||||
+}
|
||||
+# end of proc {InBindList}
|
||||
+
|
||||
# Add USB ID to list of devices needing later treatment
|
||||
proc {AddToList} {name id} {
|
||||
|
||||
@@ -791,6 +946,37 @@ close $lc
|
||||
# end of proc {AddToList}
|
||||
|
||||
|
||||
+# Remove USB ID from bind list (NoDriverLoading is set)
|
||||
+proc {RemoveFromBindList} {id} {
|
||||
+
|
||||
+set listfile /var/lib/usb_modeswitch/bind_list
|
||||
+if [file exists $listfile] {
|
||||
+ set rc [open $listfile r]
|
||||
+ set buffer [read $rc]
|
||||
+ close $rc
|
||||
+ set idList [split [string trim $buffer] \n]
|
||||
+} else {
|
||||
+ return
|
||||
+}
|
||||
+set idx [lsearch $idList $id]
|
||||
+if {$idx > -1} {
|
||||
+ set idList [lreplace $idList $idx $idx]
|
||||
+} else {
|
||||
+ return
|
||||
+}
|
||||
+if {[llength $idList] == 0} {
|
||||
+ file delete $listfile
|
||||
+ return
|
||||
+}
|
||||
+set buffer [join $idList "\n"]
|
||||
+if [catch {set lc [open $listfile w]}] {return}
|
||||
+puts $lc $buffer
|
||||
+close $lc
|
||||
+
|
||||
+}
|
||||
+# end of proc {RemoveFromBindList}
|
||||
+
|
||||
+
|
||||
proc {CheckSuccess} {devdir} {
|
||||
|
||||
global config usb flags
|
||||
--
|
||||
2.7.4
|
||||
|
||||
|
|
@ -1,74 +0,0 @@
|
|||
--- device_reference.txt 2014-05-29 22:18:46.000000000 +0200
|
||||
+++ device_reference_utf8.txt 2014-11-24 20:51:17.647221466 +0100
|
||||
@@ -60,7 +60,7 @@
|
||||
########################################################
|
||||
# Option GlobeTrotter GT MAX 3.6 (aka "T-Mobile Web'n'walk Card Compact II")
|
||||
#
|
||||
-# Contributor: Bernd Holzmüller
|
||||
+# Contributor: Bernd Holzmüller
|
||||
|
||||
DefaultVendor= 0x05c6
|
||||
DefaultProduct= 0x1000
|
||||
@@ -279,7 +279,7 @@
|
||||
#
|
||||
# Probably works with DetachStorageOnly too
|
||||
#
|
||||
-# Contributor: Flávio Moringa and others
|
||||
+# Contributor: Flávio Moringa and others
|
||||
|
||||
DefaultVendor= 0x19d2
|
||||
DefaultProduct= 0x2000
|
||||
@@ -777,7 +777,7 @@
|
||||
#
|
||||
# Recommended init command: ATE0V1&D2&C1S0=0
|
||||
#
|
||||
-# Contributor: Jérôme Oufella
|
||||
+# Contributor: Jérôme Oufella
|
||||
|
||||
DefaultVendor= 0x1004
|
||||
DefaultProduct= 0x1000
|
||||
@@ -1336,7 +1336,7 @@
|
||||
########################################################
|
||||
# LG HDM-2100 (EVDO Rev.A USB modem)
|
||||
#
|
||||
-# Contributor: Jérôme Oufella
|
||||
+# Contributor: Jérôme Oufella
|
||||
|
||||
DefaultVendor= 0x1004
|
||||
DefaultProduct=0x607f
|
||||
@@ -1641,7 +1641,7 @@
|
||||
########################################################
|
||||
# Huawei U8110 / U8300 / Joy, Vodafone 845 (Android smartphone)
|
||||
#
|
||||
-# Contributor: David Erosa GarcÃÂa
|
||||
+# Contributor: David Erosa García
|
||||
|
||||
DefaultVendor= 0x12d1
|
||||
DefaultProduct=0x1031
|
||||
@@ -1658,7 +1658,7 @@
|
||||
########################################################
|
||||
# Nokia CS-10
|
||||
#
|
||||
-# Contributor: Wacław Sierek
|
||||
+# Contributor: Wacław Sierek
|
||||
|
||||
DefaultVendor= 0x0421
|
||||
DefaultProduct=0x060c
|
||||
@@ -1700,7 +1700,7 @@
|
||||
#######################################################
|
||||
# Samsung GT-B3730
|
||||
#
|
||||
-# Contributor: Per Øyvind Karlsen
|
||||
+# Contributor: Per Øyvind Karlsen
|
||||
|
||||
DefaultVendor= 0x04e8
|
||||
DefaultProduct=0x689a
|
||||
@@ -1771,7 +1771,7 @@
|
||||
#######################################################
|
||||
# Huawei EC168C (from Zantel)
|
||||
#
|
||||
-# Contributor: Ã…smund Hjulstad
|
||||
+# Contributor: Åsmund Hjulstad
|
||||
|
||||
DefaultVendor= 0x12d1
|
||||
DefaultProduct=0x1446
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
Name: usb_modeswitch
|
||||
Version: 2.4.0
|
||||
Release: 3%{?dist}
|
||||
Release: 4%{?dist}
|
||||
Summary: USB Modeswitch gets mobile broadband cards in operational mode
|
||||
Summary(de): USB Modeswitch aktiviert UMTS-Karten
|
||||
Group: Applications/System
|
||||
|
|
@ -14,12 +14,15 @@ Source1: http://www.draisberghof.de/usb_modeswitch/device_reference.txt
|
|||
|
||||
# http://www.draisberghof.de/usb_modeswitch/bb/viewtopic.php?f=2&t=2546
|
||||
Patch0: rhbz948451-fix-manual-pages.patch
|
||||
# Submitted upstream (2014-11-24)
|
||||
Patch1: device_reference-utf8.patch
|
||||
|
||||
# http://www.draisberghof.de/usb_modeswitch/bb/viewtopic.php?f=2&t=2556
|
||||
Patch2: 0001-Fix-crash-on-early-fail.patch
|
||||
Patch1: 0001-Fix-crash-on-early-fail.patch
|
||||
|
||||
# http://www.draisberghof.de/usb_modeswitch/bb/viewtopic.php?f=2&t=2557
|
||||
Patch3: 0001-usb_modeswitch-don-t-return-a-value-from-stack.patch
|
||||
Patch2: 0001-usb_modeswitch-don-t-return-a-value-from-stack.patch
|
||||
|
||||
# http://www.draisberghof.de/usb_modeswitch/bb/viewtopic.php?f=2&t=2560
|
||||
Patch3: 0001-Bring-back-the-module-binding.patch
|
||||
|
||||
BuildRequires: libusbx-devel
|
||||
BuildRequires: jimtcl-devel
|
||||
|
|
@ -46,9 +49,9 @@ Vodafone, Option, ZTE und Novatell werden unterstützt.
|
|||
cp -f %{SOURCE1} device_reference.txt
|
||||
|
||||
%patch0 -p1 -b .manpage
|
||||
%patch1 -p0 -b .utf8
|
||||
%patch2 -p1 -b .libusb_exit
|
||||
%patch3 -p1 -b .stack
|
||||
%patch1 -p1 -b .libusb_exit
|
||||
%patch2 -p1 -b .stack
|
||||
%patch3 -p1 -b .binding
|
||||
|
||||
|
||||
%build
|
||||
|
|
@ -75,6 +78,9 @@ make install \
|
|||
|
||||
|
||||
%changelog
|
||||
* Tue Jul 26 2016 Lubomir Rintel <lkundrak@v3.sk> - 2.4.0-4
|
||||
- Bring back the module binding
|
||||
|
||||
* Thu Jul 21 2016 Lubomir Rintel <lkundrak@v3.sk> - 2.4.0-3
|
||||
- Fix undefined behavior in config parser (rh #1352055)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue