libertas: convert register access from wlanconfig to debugfs
Marcelo Tosatti
mtosatti at redhat.unroutablecom
Mon Dec 11 15:18:30 EST 2006
Commit: 99d1b96627509e9410e0af8239422ede70fbccd8
Parent: 7b2ffce4d5903a0ac63f3e526c40c3e24bf8f5aa
commit 99d1b96627509e9410e0af8239422ede70fbccd8
Author: Marcelo Tosatti <mtosatti at redhat.com>
AuthorDate: Wed Nov 29 05:20:48 2006 -0200
Commit: Marcelo Tosatti <mtosatti at redhat.com>
CommitDate: Wed Nov 29 05:20:48 2006 -0200
libertas: convert register access from wlanconfig to debugfs
Subject says it all.
Signed-off-by: Marcelo Tosatti <mtosatti at redhat.com>
---
drivers/net/wireless/libertas/wlan_debugfs.c | 333 ++++++++++++++++++++++++++
drivers/net/wireless/libertas/wlan_dev.h | 12 +
drivers/net/wireless/libertas/wlan_ioctl.c | 69 -----
drivers/net/wireless/libertas/wlan_wext.h | 1
4 files changed, 345 insertions(+), 70 deletions(-)
diff --git a/drivers/net/wireless/libertas/wlan_debugfs.c b/drivers/net/wireless/libertas/wlan_debugfs.c
index 14e1295..23f307d 100644
--- a/drivers/net/wireless/libertas/wlan_debugfs.c
+++ b/drivers/net/wireless/libertas/wlan_debugfs.c
@@ -2,6 +2,7 @@
#include <linux/module.h>
#include <linux/dcache.h>
#include <linux/debugfs.h>
+#include <linux/delay.h>
#include <net/iw_handler.h>
#include "wlan_dev.h"
#include "wlan_decl.h"
@@ -1372,6 +1373,261 @@ out_unlock:
return res;
}
+static ssize_t libertas_rdmac_read(struct file *file, char __user *userbuf,
+ size_t count, loff_t *ppos)
+{
+ wlan_private *priv = file->private_data;
+ wlan_adapter *adapter = priv->adapter;
+ struct wlan_offset_value offval;
+ char *buf = big_buffer;
+ ssize_t len = big_buffer_len;
+ ssize_t pos = 0;
+ int ret;
+
+ down(&big_buffer_sem);
+ offval.offset = priv->mac_offset;
+ offval.value = 0;
+
+ ret = libertas_prepare_and_send_command(priv,
+ HostCmd_CMD_MAC_REG_ACCESS, 0,
+ HostCmd_OPTION_WAITFORRSP, 0, &offval);
+ mdelay(10);
+ pos += snprintf(buf+pos, len-pos, "MAC[0x%x] = 0x%08x\n",
+ priv->mac_offset, adapter->OffsetValue.value);
+
+ ret = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
+ up(&big_buffer_sem);
+
+ return ret;
+}
+
+static ssize_t libertas_rdmac_write(struct file *file,
+ const char __user *userbuf,
+ size_t count, loff_t *ppos)
+{
+ wlan_private *priv = file->private_data;
+ char *buf = big_buffer;
+ ssize_t res, buf_size;
+
+ down(&big_buffer_sem);
+ buf_size = min(count, sizeof(big_buffer) - 1);
+ if (copy_from_user(buf, userbuf, buf_size)) {
+ res = -EFAULT;
+ goto out_unlock;
+ }
+ priv->mac_offset = simple_strtoul((char *)buf, NULL, 16);
+ res = count;
+out_unlock:
+ up(&big_buffer_sem);
+ return res;
+}
+
+static ssize_t libertas_wrmac_write(struct file *file,
+ const char __user *userbuf,
+ size_t count, loff_t *ppos)
+{
+
+ wlan_private *priv = file->private_data;
+ char *buf = big_buffer;
+ ssize_t res, buf_size;
+ u32 offset, value;
+ struct wlan_offset_value offval;
+
+ down(&big_buffer_sem);
+ buf_size = min(count, sizeof(big_buffer) - 1);
+ if (copy_from_user(buf, userbuf, buf_size)) {
+ res = -EFAULT;
+ goto out_unlock;
+ }
+ res = sscanf(buf, "%x %x", &offset, &value);
+ if (res != 2) {
+ res = -EFAULT;
+ goto out_unlock;
+ }
+
+ offval.offset = offset;
+ offval.value = value;
+ res = libertas_prepare_and_send_command(priv,
+ HostCmd_CMD_MAC_REG_ACCESS, 1,
+ HostCmd_OPTION_WAITFORRSP, 0, &offval);
+ mdelay(10);
+
+ res = count;
+out_unlock:
+ up(&big_buffer_sem);
+ return res;
+}
+
+static ssize_t libertas_rdbbp_read(struct file *file, char __user *userbuf,
+ size_t count, loff_t *ppos)
+{
+ wlan_private *priv = file->private_data;
+ wlan_adapter *adapter = priv->adapter;
+ struct wlan_offset_value offval;
+ char *buf = big_buffer;
+ ssize_t len = big_buffer_len;
+ ssize_t pos = 0;
+ int ret;
+
+ down(&big_buffer_sem);
+ offval.offset = priv->bbp_offset;
+ offval.value = 0;
+
+ ret = libertas_prepare_and_send_command(priv,
+ HostCmd_CMD_BBP_REG_ACCESS, 0,
+ HostCmd_OPTION_WAITFORRSP, 0, &offval);
+ mdelay(10);
+ pos += snprintf(buf+pos, len-pos, "BBP[0x%x] = 0x%08x\n",
+ priv->bbp_offset, adapter->OffsetValue.value);
+
+ ret = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
+ up(&big_buffer_sem);
+
+ return ret;
+}
+
+static ssize_t libertas_rdbbp_write(struct file *file,
+ const char __user *userbuf,
+ size_t count, loff_t *ppos)
+{
+ wlan_private *priv = file->private_data;
+ char *buf = big_buffer;
+ ssize_t res, buf_size;
+
+ down(&big_buffer_sem);
+ buf_size = min(count, sizeof(big_buffer) - 1);
+ if (copy_from_user(buf, userbuf, buf_size)) {
+ res = -EFAULT;
+ goto out_unlock;
+ }
+ priv->bbp_offset = simple_strtoul((char *)buf, NULL, 16);
+ res = count;
+out_unlock:
+ up(&big_buffer_sem);
+ return res;
+}
+
+static ssize_t libertas_wrbbp_write(struct file *file,
+ const char __user *userbuf,
+ size_t count, loff_t *ppos)
+{
+
+ wlan_private *priv = file->private_data;
+ char *buf = big_buffer;
+ ssize_t res, buf_size;
+ u32 offset, value;
+ struct wlan_offset_value offval;
+
+ down(&big_buffer_sem);
+ buf_size = min(count, sizeof(big_buffer) - 1);
+ if (copy_from_user(buf, userbuf, buf_size)) {
+ res = -EFAULT;
+ goto out_unlock;
+ }
+ res = sscanf(buf, "%x %x", &offset, &value);
+ if (res != 2) {
+ res = -EFAULT;
+ goto out_unlock;
+ }
+
+ offval.offset = offset;
+ offval.value = value;
+ res = libertas_prepare_and_send_command(priv,
+ HostCmd_CMD_BBP_REG_ACCESS, 1,
+ HostCmd_OPTION_WAITFORRSP, 0, &offval);
+ mdelay(10);
+
+ res = count;
+out_unlock:
+ up(&big_buffer_sem);
+ return res;
+}
+
+static ssize_t libertas_rdrf_read(struct file *file, char __user *userbuf,
+ size_t count, loff_t *ppos)
+{
+ wlan_private *priv = file->private_data;
+ wlan_adapter *adapter = priv->adapter;
+ struct wlan_offset_value offval;
+ char *buf = big_buffer;
+ ssize_t len = big_buffer_len;
+ ssize_t pos = 0;
+ int ret;
+
+ down(&big_buffer_sem);
+ offval.offset = priv->rf_offset;
+ offval.value = 0;
+
+ ret = libertas_prepare_and_send_command(priv,
+ HostCmd_CMD_RF_REG_ACCESS, 0,
+ HostCmd_OPTION_WAITFORRSP, 0, &offval);
+ mdelay(10);
+ pos += snprintf(buf+pos, len-pos, "RF[0x%x] = 0x%08x\n",
+ priv->rf_offset, adapter->OffsetValue.value);
+
+ ret = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
+ up(&big_buffer_sem);
+
+ return ret;
+}
+
+static ssize_t libertas_rdrf_write(struct file *file,
+ const char __user *userbuf,
+ size_t count, loff_t *ppos)
+{
+ wlan_private *priv = file->private_data;
+ char *buf = big_buffer;
+ ssize_t res, buf_size;
+
+ down(&big_buffer_sem);
+ buf_size = min(count, sizeof(big_buffer) - 1);
+ if (copy_from_user(buf, userbuf, buf_size)) {
+ res = -EFAULT;
+ goto out_unlock;
+ }
+ priv->rf_offset = simple_strtoul((char *)buf, NULL, 16);
+ res = count;
+out_unlock:
+ up(&big_buffer_sem);
+ return res;
+}
+
+static ssize_t libertas_wrrf_write(struct file *file,
+ const char __user *userbuf,
+ size_t count, loff_t *ppos)
+{
+
+ wlan_private *priv = file->private_data;
+ char *buf = big_buffer;
+ ssize_t res, buf_size;
+ u32 offset, value;
+ struct wlan_offset_value offval;
+
+ down(&big_buffer_sem);
+ buf_size = min(count, sizeof(big_buffer) - 1);
+ if (copy_from_user(buf, userbuf, buf_size)) {
+ res = -EFAULT;
+ goto out_unlock;
+ }
+ res = sscanf(buf, "%x %x", &offset, &value);
+ if (res != 2) {
+ res = -EFAULT;
+ goto out_unlock;
+ }
+
+ offval.offset = offset;
+ offval.value = value;
+ res = libertas_prepare_and_send_command(priv,
+ HostCmd_CMD_RF_REG_ACCESS, 1,
+ HostCmd_OPTION_WAITFORRSP, 0, &offval);
+ mdelay(10);
+
+ res = count;
+out_unlock:
+ up(&big_buffer_sem);
+ return res;
+}
+
static struct file_operations libertas_devinfo_fops = {
.owner = THIS_MODULE,
.open = open_file_generic,
@@ -1447,6 +1703,48 @@ static struct file_operations libertas_h
.write = libertas_highsnr_write,
};
+static struct file_operations libertas_rdmac_fops = {
+ .owner = THIS_MODULE,
+ .open = open_file_generic,
+ .read = libertas_rdmac_read,
+ .write = libertas_rdmac_write,
+};
+
+static struct file_operations libertas_wrmac_fops = {
+ .owner = THIS_MODULE,
+ .open = open_file_generic,
+ .write = libertas_wrmac_write,
+};
+
+static struct file_operations libertas_rdbbp_fops = {
+ .owner = THIS_MODULE,
+ .open = open_file_generic,
+ .read = libertas_rdbbp_read,
+ .write = libertas_rdbbp_write,
+};
+
+static struct file_operations libertas_wrbbp_fops = {
+ .owner = THIS_MODULE,
+ .open = open_file_generic,
+ .write = libertas_wrbbp_write,
+};
+
+static struct file_operations libertas_rdrf_fops = {
+ .owner = THIS_MODULE,
+ .open = open_file_generic,
+ .read = libertas_rdrf_read,
+ .write = libertas_rdrf_write,
+};
+
+static struct file_operations libertas_wrrf_fops = {
+ .owner = THIS_MODULE,
+ .open = open_file_generic,
+ .write = libertas_wrrf_write,
+};
+
+
+
+
void libertas_debugfs_init(void)
{
if (!libertas_dir)
@@ -1533,6 +1831,34 @@ void libertas_debugfs_init_one(wlan_priv
priv,
&libertas_highsnr_fops);
+ priv->regs_dir = debugfs_create_dir("registers", priv->debugfs_dir);
+ if (!priv->regs_dir)
+ goto exit;
+ priv->rdmac = debugfs_create_file("rdmac", 0644,
+ priv->regs_dir,
+ priv,
+ &libertas_rdmac_fops);
+ priv->wrmac = debugfs_create_file("wrmac", 0600,
+ priv->regs_dir,
+ priv,
+ &libertas_wrmac_fops);
+
+ priv->rdbbp = debugfs_create_file("rdbbp", 0644,
+ priv->regs_dir,
+ priv,
+ &libertas_rdbbp_fops);
+ priv->wrbbp = debugfs_create_file("wrbbp", 0600,
+ priv->regs_dir,
+ priv,
+ &libertas_wrbbp_fops);
+ priv->rdrf = debugfs_create_file("rdrf", 0644,
+ priv->regs_dir,
+ priv,
+ &libertas_rdrf_fops);
+ priv->wrrf = debugfs_create_file("wrrf", 0600,
+ priv->regs_dir,
+ priv,
+ &libertas_wrrf_fops);
#ifdef PROC_DEBUG
libertas_debug_init(priv, dev);
#endif
@@ -1542,6 +1868,13 @@ exit:
void libertas_debugfs_remove_one(wlan_private *priv)
{
+ debugfs_remove(priv->rdmac);
+ debugfs_remove(priv->wrmac);
+ debugfs_remove(priv->rdbbp);
+ debugfs_remove(priv->wrbbp);
+ debugfs_remove(priv->rdrf);
+ debugfs_remove(priv->wrrf);
+ debugfs_remove(priv->regs_dir);
debugfs_remove(priv->low_rssi);
debugfs_remove(priv->low_snr);
diff --git a/drivers/net/wireless/libertas/wlan_dev.h b/drivers/net/wireless/libertas/wlan_dev.h
index 84817cc..dfb9a58 100644
--- a/drivers/net/wireless/libertas/wlan_dev.h
+++ b/drivers/net/wireless/libertas/wlan_dev.h
@@ -185,6 +185,18 @@ struct _wlan_private {
struct dentry *high_rssi;
struct dentry *high_snr;
+ struct dentry *regs_dir;
+ struct dentry *rdmac;
+ struct dentry *wrmac;
+ struct dentry *rdbbp;
+ struct dentry *wrbbp;
+ struct dentry *rdrf;
+ struct dentry *wrrf;
+
+ u32 mac_offset;
+ u32 bbp_offset;
+ u32 rf_offset;
+
const struct firmware *firmware;
struct device *hotplug_device;
diff --git a/drivers/net/wireless/libertas/wlan_ioctl.c b/drivers/net/wireless/libertas/wlan_ioctl.c
index bf6ec4c..ccae193 100644
--- a/drivers/net/wireless/libertas/wlan_ioctl.c
+++ b/drivers/net/wireless/libertas/wlan_ioctl.c
@@ -628,71 +628,6 @@ static int wlan_get_adhoc_status_ioctl(w
}
/**
- * @brief Read/Write adapter registers
- *
- * @param priv A pointer to wlan_private structure
- * @param req A pointer to ifreq structure
- * @return WLAN_STATUS_SUCCESS --success, otherwise fail
- */
-static int wlan_regrdwr_ioctl(wlan_private * priv, struct ifreq *req)
-{
- wlan_ioctl_regrdwr regrdwr;
- struct wlan_offset_value offval;
- wlan_adapter *Adapter = priv->adapter;
- int ret = WLAN_STATUS_SUCCESS;
-
- ENTER();
-
- if (copy_from_user(®rdwr, req->ifr_data, sizeof(regrdwr))) {
- dprintk(1,
- "copy of regrdwr for wlan_regrdwr_ioctl from user failed \n");
- LEAVE();
- return -EFAULT;
- }
-
- offval.offset = regrdwr.Offset;
- offval.value = (regrdwr.Action) ? regrdwr.Value : 0x00;
-
- dprintk(1, "RegAccess: %02x Action:%d "
- "Offset: %04x Value: %04x\n",
- regrdwr.WhichReg, regrdwr.Action, offval.offset, offval.value);
-
- /*
- * regrdwr.WhichReg should contain the command that
- * corresponds to which register access is to be
- * performed HostCmd_CMD_MAC_REG_ACCESS 0x0019
- * HostCmd_CMD_BBP_REG_ACCESS 0x001a
- * HostCmd_CMD_RF_REG_ACCESS 0x001b
- */
- ret = libertas_prepare_and_send_command(priv, regrdwr.WhichReg,
- regrdwr.Action, HostCmd_OPTION_WAITFORRSP,
- 0, &offval);
-
- if (ret) {
- LEAVE();
- return ret;
- }
-
- mdelay(10);
-
- /*
- * Return the result back to the user
- */
- regrdwr.Value = Adapter->OffsetValue.value;
- if (regrdwr.Action == HostCmd_ACT_GEN_READ) {
- if (copy_to_user(req->ifr_data, ®rdwr, sizeof(regrdwr))) {
- dprintk(1,
- "copy of regrdwr for wlan_regrdwr_ioctl to user failed \n");
- LEAVE();
- return -EFAULT;
- }
- }
-
- LEAVE();
- return WLAN_STATUS_SUCCESS;
-}
-
-/**
* @brief Set/Get WPA IE
* @param priv A pointer to wlan_private structure
* @param req A pointer to ifreq structure
@@ -1957,10 +1892,6 @@ int libertas_do_ioctl(struct net_device
ret = wlan_scan_type_ioctl(priv, wrq);
break;
- case WLANREGRDWR: /* Register read write command */
- ret = wlan_regrdwr_ioctl(priv, req);
- break;
-
/* FIXME: this really should be handled by wireless extensions
already, so it can probably be dropped here. */
case SIOCSIWENCODE: /* set encoding token & mode for WPA */
diff --git a/drivers/net/wireless/libertas/wlan_wext.h b/drivers/net/wireless/libertas/wlan_wext.h
index 07b7a4f..071af50 100644
--- a/drivers/net/wireless/libertas/wlan_wext.h
+++ b/drivers/net/wireless/libertas/wlan_wext.h
@@ -38,7 +38,6 @@ #define WLANIOCTL SIOCIWFIRSTPRIV
#define WLANSETWPAIE (WLANIOCTL + 0)
#define WLANCISDUMP (WLANIOCTL + 1)
-#define WLANREGRDWR (WLANIOCTL + 3)
#define MAX_EEPROM_DATA 256
#define WLAN_SETINT_GETINT (WLANIOCTL + 7)
More information about the Commits-kernel
mailing list