mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-11-22 14:49:24 +01:00
rfkill: Fix wiphy ID lookup
map_wiphy made the assumption that phy names follow the "phyN" pattern but phys created or renamed by the "iw" command can have arbitrary names. It seems that /sys/class/rfkill/rfkill%u/name is not updated on a phy rename, so we can't use it to subsequently read /sys/class/ieee80211/<name>/index but both /sys/class/rfkill/rfkill%u/../index and /sys/class/rfkill/rfkill%u/device/index point to that file.
This commit is contained in:
parent
fba5ada1a1
commit
f316614f59
@ -87,7 +87,7 @@ static struct rfkill_map_entry *map_wiphy(unsigned int rfkill_id)
|
||||
unsigned int wiphy_id;
|
||||
struct rfkill_map_entry *entry;
|
||||
|
||||
path = l_strdup_printf("/sys/class/rfkill/rfkill%u/name", rfkill_id);
|
||||
path = l_strdup_printf("/sys/class/rfkill/rfkill%u/device/index", rfkill_id);
|
||||
|
||||
fd = TFR(open(path, O_RDONLY));
|
||||
|
||||
@ -104,7 +104,7 @@ static struct rfkill_map_entry *map_wiphy(unsigned int rfkill_id)
|
||||
return NULL;
|
||||
|
||||
buf[bytes] = '\0';
|
||||
if (sscanf(buf, "phy%u %n", &wiphy_id, &consumed) != 1 ||
|
||||
if (sscanf(buf, "%u %n", &wiphy_id, &consumed) != 1 ||
|
||||
consumed != bytes)
|
||||
return NULL;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user