Search Linux Wireless

[PATCH 2/2] wl12xx Export chip id to sysfs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Export the chip id to userspace. This helps to change application behavior
according to architecture of the wl12xx chip.

Signed-off-by: Gery Kahn <geryk@xxxxxx>
---
 drivers/net/wireless/wl12xx/main.c |   30 ++++++++++++++++++++++++++++++
 1 files changed, 30 insertions(+), 0 deletions(-)

diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c
index d65fef6..13a6cfa 100644
--- a/drivers/net/wireless/wl12xx/main.c
+++ b/drivers/net/wireless/wl12xx/main.c
@@ -4437,6 +4437,25 @@ static ssize_t wl1271_sysfs_show_hw_pg_ver(struct device *dev,
 static DEVICE_ATTR(hw_pg_ver, S_IRUGO,
 		   wl1271_sysfs_show_hw_pg_ver, NULL);
 
+static ssize_t wl1271_sysfs_show_chip_id(struct device *dev,
+					 struct device_attribute *attr,
+					 char *buf)
+{
+	struct wl1271 *wl = dev_get_drvdata(dev);
+	ssize_t len;
+
+	len = PAGE_SIZE;
+
+	mutex_lock(&wl->mutex);
+	len = snprintf(buf, len, "0x%x\n", wl->chip.id);
+	mutex_unlock(&wl->mutex);
+
+	return len;
+}
+
+static DEVICE_ATTR(chip_id, S_IRUGO,
+		   wl1271_sysfs_show_chip_id, NULL);
+
 static ssize_t wl1271_sysfs_read_fwlog(struct file *filp, struct kobject *kobj,
 				       struct bin_attribute *bin_attr,
 				       char *buffer, loff_t pos, size_t count)
@@ -4803,8 +4822,17 @@ struct ieee80211_hw *wl1271_alloc_hw(void)
 		goto err_hw_pg_ver;
 	}
 
+	ret = device_create_file(&wl->plat_dev->dev, &dev_attr_chip_id);
+	if (ret < 0) {
+		wl1271_error("failed to create sysfs file chip_id");
+		goto err_fwlog_attr;
+	}
+
 	return hw;
 
+err_fwlog_attr:
+	device_remove_bin_file(&wl->plat_dev->dev, &fwlog_attr);
+
 err_hw_pg_ver:
 	device_remove_file(&wl->plat_dev->dev, &dev_attr_hw_pg_ver);
 
@@ -4849,6 +4877,8 @@ int wl1271_free_hw(struct wl1271 *wl)
 
 	device_remove_bin_file(&wl->plat_dev->dev, &fwlog_attr);
 
+	device_remove_file(&wl->plat_dev->dev, &dev_attr_chip_id);
+
 	device_remove_file(&wl->plat_dev->dev, &dev_attr_hw_pg_ver);
 
 	device_remove_file(&wl->plat_dev->dev, &dev_attr_bt_coex_state);
-- 
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]
  Powered by Linux