diff options
author | Florian Eckert <fe@dev.tdt.de> | 2017-08-23 07:23:52 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2019-10-18 19:46:21 +0200 |
commit | c45c7606cc8017995609033a7fee80fa01b45434 (patch) | |
tree | e9483a5ef2517babb68a96adbbda8bd0b2c45132 /package/network | |
parent | ddf6ec29b477f0cf7ce7839c8c9710fb4b969621 (diff) | |
download | upstream-c45c7606cc8017995609033a7fee80fa01b45434.tar.gz upstream-c45c7606cc8017995609033a7fee80fa01b45434.tar.bz2 upstream-c45c7606cc8017995609033a7fee80fa01b45434.zip |
wwan: check new uci bus option on proto setup event
If system has more then one and different wwan interface (modem). Then the
wwan protohandler will always take the modem which is discovered first.
The protohandler will always setup the same interface. To fix this add a
new usb "bus" option which is associated with wwan device and so will set
the specified interface up. With this change more then one interface
could be mananged by the wwan protohandler.
If the "bus" option is not set in the uci network config then the protohandler
behaves as before the change. The protohanldler will take the first
interface which he founds.
Signed-off-by: Florian Eckert <fe@dev.tdt.de>
Diffstat (limited to 'package/network')
-rw-r--r-- | package/network/utils/wwan/Makefile | 2 | ||||
-rwxr-xr-x | package/network/utils/wwan/files/wwan.sh | 51 |
2 files changed, 40 insertions, 13 deletions
diff --git a/package/network/utils/wwan/Makefile b/package/network/utils/wwan/Makefile index 8ce9fd224c..16291de0b1 100644 --- a/package/network/utils/wwan/Makefile +++ b/package/network/utils/wwan/Makefile @@ -1,7 +1,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=wwan -PKG_VERSION:=2014-07-17 +PKG_VERSION:=2019-04-29 PKG_RELEASE=1 PKG_LICENSE:=GPL-2.0 diff --git a/package/network/utils/wwan/files/wwan.sh b/package/network/utils/wwan/files/wwan.sh index 303fa9e99e..4843b1dd47 100755 --- a/package/network/utils/wwan/files/wwan.sh +++ b/package/network/utils/wwan/files/wwan.sh @@ -32,21 +32,45 @@ proto_wwan_init_config() { proto_config_add_string pincode proto_config_add_string delay proto_config_add_string modes + proto_config_add_string bus } proto_wwan_setup() { - local driver usb devicename desc - - for a in `ls /sys/bus/usb/devices`; do - local vendor product - [ -z "$usb" -a -f /sys/bus/usb/devices/$a/idVendor -a -f /sys/bus/usb/devices/$a/idProduct ] || continue - vendor=$(cat /sys/bus/usb/devices/$a/idVendor) - product=$(cat /sys/bus/usb/devices/$a/idProduct) - [ -f /lib/network/wwan/$vendor:$product ] && { - usb=/lib/network/wwan/$vendor:$product - devicename=$a - } - done + local driver usb devicename desc bus + + json_get_vars bus + + if [ -L "/sys/bus/usb/devices/${bus}" ]; then + if [ -f "/sys/bus/usb/devices/${bus}/idVendor" ] \ + && [ -f "/sys/bus/usb/devices/${bus}/idProduct" ]; then + local vendor product + vendor=$(cat /sys/bus/usb/devices/${bus}/idVendor) + product=$(cat /sys/bus/usb/devices/${bus}/idProduct) + [ -f /lib/network/wwan/$vendor:$product ] && { + usb=/lib/network/wwan/$vendor:$product + devicename=$bus + } + else + echo "wwan[$$]" "Specified usb bus ${bus} was not found" + proto_notify_error "$interface" NO_USB + proto_block_restart "$interface" + return 1 + fi + else + echo "wwan[$$]" "Searching for a valid wwan usb device..." + for a in `ls /sys/bus/usb/devices`; do + local vendor product + [ -z "$usb" -a -f /sys/bus/usb/devices/$a/idVendor -a -f /sys/bus/usb/devices/$a/idProduct ] || continue + vendor=$(cat /sys/bus/usb/devices/$a/idVendor) + product=$(cat /sys/bus/usb/devices/$a/idProduct) + [ -f /lib/network/wwan/$vendor:$product ] && { + usb=/lib/network/wwan/$vendor:$product + devicename=$a + } + done + fi + + echo "wwan[$$]" "Using wwan usb device on bus $devicename" [ -n "$usb" ] && { local old_cb control data @@ -68,6 +92,9 @@ proto_wwan_setup() { [ -z "$ctl_device" ] && for net in $(ls /sys/class/net/ | grep -e wwan -e usb); do [ -z "$ctl_device" ] || continue + [ -n "$bus" ] && { + [ $(readlink /sys/class/net/$net | grep $bus) ] || continue + } driver=$(grep DRIVER /sys/class/net/$net/device/uevent | cut -d= -f2) case "$driver" in qmi_wwan|cdc_mbim) |