Comment 4 for bug 1544612

Revision history for this message
Dirk F (fieldhouse) wrote :

Actually, this is more tricky than I thought. The validity of the bug 1299975 patch depends on which wireless driver is in use, apparently reflecting some crufty aspects of sysfs and its driver implementations.

In bug 1299975, on rereading, the reporter (savage) says that with an Intel wireless device the virtual file presented in /sys/class/net/$device/device was named "enabled" whereas the script /usr/lib/pm-utils/power.d/wireless referenced "enable".

Whereas I observe that, if present, the virtual file presented in /sys/class/net/$device/device is named "enable", just as in the directory listing in comment #3.

In a Toshiba Tecra 8200 with wlan1 identified as Qualcomm Atheros ARS212/5213/2414 (driver "ath5k"), it's present as "enable".

In a Dell Inspiron 1721 with wlan0 identified as Broadcom Corporation BCM4321 (driver "b43-pci-bridge"), it's not present at all in /sys/class/net/$device/device, but there is a corresponding /sys/bus/pci/drivers/b43-pci-bridge/0000:0b:00.0/enable (and writing 0 to this file disables the driver). However the test in the wireless script assumes that the device is disabled if the /sys/class/net/$device/device/enable* file doesn't exist, so the script fails in this case.

Presumably

a) the presence of the /sys/class/net/$device/device/enable* file depends on whether the ability to disable the device via /sys/class/net/$device/device is supported by the device+driver combination,

b) if the file is present its exact name depends on some details of the driver's sysfs interface and installation procedure, but it is either "enable" or "enabled" (and both are never present together), and

c) if the file is not present the wireless script should assume the device is enabled.

If these assumptions are valid, the following might be a better bet for lines 22-23 of /usr/lib/pm-utils/power.d/wireless:

    # Assume device is disabled if enable or enabled file exists containing 0; then skip
    [ -f /sys/class/net/$1/device/enable* ] && [ "$(cat /sys/class/net/$1/device/enable*)" = "0" ] && return 1

Obviously there are multiline options that could be more precise.