1
0
Fork 0

brcmfmac: support read chipname via sysfs

It adds support of reading chipname via sysfs, so that user space can
distinguish WiFi module among AP5256, AP5256V and 1MW.

- AP5256
reMarkable: ~/ cat /sys/class/ieee80211/phy*/chipname
BCM4345/9

- AP5256V
reMarkable: ~/ cat /sys/class/ieee80211/phy*/chipname
BCM43012/2

- 1MW
reMarkable: ~/ cat /sys/class/ieee80211/phy*/chipname
BCM4345/6

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
zero-colors
Shawn Guo 2021-06-16 16:41:00 +08:00 committed by Lars Ivar Miljeteig
parent 4a4bfbce1e
commit dbd623fb1d
1 changed files with 20 additions and 0 deletions

View File

@ -1054,6 +1054,17 @@ static int brcmf_inet6addr_changed(struct notifier_block *nb,
}
#endif
static ssize_t chipname_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
struct brcmf_bus *bus_if = dev_get_drvdata(dev->parent);
struct brcmf_pub *drvr = bus_if->drvr;
struct brcmf_rev_info *ri = &drvr->revinfo;
return snprintf(buf, PAGE_SIZE, "%s\n", ri->chipname);
}
static DEVICE_ATTR_RO(chipname);
static int brcmf_revinfo_read(struct seq_file *s, void *data)
{
struct brcmf_bus *bus_if = dev_get_drvdata(s->private);
@ -1280,6 +1291,13 @@ int brcmf_attach(struct device *dev)
goto fail;
}
/* Create sysfs file to get chip name */
ret = device_create_file(&drvr->wiphy->dev, &dev_attr_chipname);
if (ret) {
brcmf_err("failed to create sysfs file chipname");
goto fail;
}
return 0;
fail:
@ -1341,6 +1359,8 @@ void brcmf_detach(struct device *dev)
if (drvr == NULL)
return;
device_remove_file(&drvr->wiphy->dev, &dev_attr_chipname);
#ifdef CONFIG_INET
unregister_inetaddr_notifier(&drvr->inetaddr_notifier);
#endif