wwan: fix init
This commit is contained in:
parent
90ada66343
commit
a8b3e73b81
@ -32,55 +32,31 @@ 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 bus
|
||||
local driver usb devicename desc
|
||||
|
||||
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"
|
||||
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
|
||||
|
||||
[ -n "$usb" ] && {
|
||||
local old_cb control data
|
||||
|
||||
json_set_namespace wwan old_cb
|
||||
json_init
|
||||
json_load "$(cat "$usb")"
|
||||
json_load "$(cat $usb)"
|
||||
json_select
|
||||
json_get_vars desc control data
|
||||
json_set_namespace "$old_cb"
|
||||
json_set_namespace $old_cb
|
||||
|
||||
[ -n "$control" -a -n "$data" ] && {
|
||||
ttys=$(ls -d /sys/bus/usb/devices/$devicename/${devicename}*/tty?* /sys/bus/usb/devices/$devicename/${devicename}*/tty/tty?* | sed "s/.*\///g" | tr "\n" " ")
|
||||
@ -92,9 +68,6 @@ 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)
|
||||
@ -115,9 +88,9 @@ proto_wwan_setup() {
|
||||
return 1
|
||||
}
|
||||
|
||||
uci_set_state network "$interface" driver "$driver"
|
||||
uci_set_state network "$interface" ctl_device "$ctl_device"
|
||||
uci_set_state network "$interface" dat_device "$dat_device"
|
||||
uci_set_state network $interface driver "$driver"
|
||||
uci_set_state network $interface ctl_device "$ctl_device"
|
||||
uci_set_state network $interface dat_device "$dat_device"
|
||||
|
||||
case $driver in
|
||||
qmi_wwan) proto_qmi_setup $@ ;;
|
||||
@ -130,9 +103,9 @@ proto_wwan_setup() {
|
||||
|
||||
proto_wwan_teardown() {
|
||||
local interface=$1
|
||||
local driver=$(uci_get_state network "$interface" driver)
|
||||
ctl_device=$(uci_get_state network "$interface" ctl_device)
|
||||
dat_device=$(uci_get_state network "$interface" dat_device)
|
||||
local driver=$(uci_get_state network $interface driver)
|
||||
ctl_device=$(uci_get_state network $interface ctl_device)
|
||||
dat_device=$(uci_get_state network $interface dat_device)
|
||||
|
||||
case $driver in
|
||||
qmi_wwan) proto_qmi_teardown $@ ;;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user