libertas: convert sleepparams from wlanconfig to debugfs
Marcelo Tosatti
mtosatti at redhat.unroutablecom
Tue Nov 28 02:56:39 EST 2006
Commit: 2d0553c736901f154f25ff01b3567995fd980893
Parent: 5933cb03edfdfdb503afdab8ccef09ce6efc255a
commit 2d0553c736901f154f25ff01b3567995fd980893
Author: Marcelo Tosatti <mtosatti at redhat.com>
AuthorDate: Thu Nov 16 13:13:20 2006 -0200
Commit: Marcelo Tosatti <mtosatti at redhat.com>
CommitDate: Thu Nov 16 13:13:20 2006 -0200
libertas: convert sleepparams from wlanconfig to debugfs
Subject says it all.
Signed-off-by: Marcelo Tosatti <mtosatti at redhat.com>
---
drivers/net/wireless/libertas/wlan_debugfs.c | 92 ++++++++++++++++++++++++++
drivers/net/wireless/libertas/wlan_dev.h | 1
drivers/net/wireless/libertas/wlan_ioctl.c | 45 -------------
drivers/net/wireless/libertas/wlan_wext.c | 1
drivers/net/wireless/libertas/wlan_wext.h | 12 ---
5 files changed, 94 insertions(+), 57 deletions(-)
diff --git a/drivers/net/wireless/libertas/wlan_debugfs.c b/drivers/net/wireless/libertas/wlan_debugfs.c
index b16df4b..c2ec0cd 100644
--- a/drivers/net/wireless/libertas/wlan_debugfs.c
+++ b/drivers/net/wireless/libertas/wlan_debugfs.c
@@ -4,6 +4,7 @@ #include <linux/dcache.h>
#include <linux/debugfs.h>
#include "wlan_dev.h"
#include "wlan_decl.h"
+#include "host.h"
static struct dentry *libertas_dir = NULL;
static const int big_buffer_len = 4096;
@@ -104,6 +105,85 @@ static ssize_t libertas_getscantable(str
return res;
}
+static ssize_t libertas_sleepparams_write(struct file *file,
+ const char __user *user_buf, size_t count,
+ loff_t *ppos)
+{
+ wlan_private *priv = file->private_data;
+ char *buf = big_buffer;
+ ssize_t buf_size, res;
+ int p1, p2, p3, p4, p5, p6;
+ struct sleep_params sp;
+
+ down(&big_buffer_sem);
+ buf_size = min(count, sizeof(big_buffer) - 1);
+ if (copy_from_user(buf, user_buf, buf_size)) {
+ res = -EFAULT;
+ goto out_unlock;
+ }
+ res = sscanf(buf, "%d %d %d %d %d %d", &p1, &p2, &p3, &p4, &p5, &p6);
+ printk(KERN_ERR "res=%d\n", res);
+ if (res != 6) {
+ res = -EFAULT;
+ goto out_unlock;
+ }
+ sp.sp_error = p1;
+ sp.sp_offset = p2;
+ sp.sp_stabletime = p3;
+ sp.sp_calcontrol = p4;
+ sp.sp_extsleepclk = p5;
+ sp.sp_reserved = p6;
+
+ memcpy(&priv->adapter->sp, &sp, sizeof(struct sleep_params));
+
+ res = libertas_prepare_and_send_command(priv,
+ HostCmd_CMD_802_11_SLEEP_PARAMS,
+ HostCmd_ACT_GEN_SET,
+ HostCmd_OPTION_WAITFORRSP, 0, NULL);
+
+ if (!res)
+ res = count;
+ else
+ res = -EINVAL;
+
+out_unlock:
+ up(&big_buffer_sem);
+ return res;
+}
+
+static ssize_t libertas_sleepparams_read(struct file *file, char __user *userbuf,
+ size_t count, loff_t *ppos)
+{
+ wlan_private *priv = file->private_data;
+ wlan_adapter *adapter = priv->adapter;
+ char *buf = big_buffer;
+ ssize_t res;
+ size_t pos = 0;
+ ssize_t len = big_buffer_len;
+
+ down(&big_buffer_sem);
+
+ res = libertas_prepare_and_send_command(priv,
+ HostCmd_CMD_802_11_SLEEP_PARAMS,
+ HostCmd_ACT_GEN_GET,
+ HostCmd_OPTION_WAITFORRSP, 0, NULL);
+ if (res) {
+ res = -EFAULT;
+ goto out_unlock;
+ }
+
+ pos += snprintf(buf, len, "%d %d %d %d %d %d\n", adapter->sp.sp_error,
+ adapter->sp.sp_offset, adapter->sp.sp_stabletime,
+ adapter->sp.sp_calcontrol, adapter->sp.sp_extsleepclk,
+ adapter->sp.sp_reserved);
+
+ res = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
+
+out_unlock:
+ up(&big_buffer_sem);
+ return res;
+}
+
static struct file_operations libertas_devinfo_fops = {
.owner = THIS_MODULE,
@@ -119,6 +199,13 @@ static struct file_operations libertas_g
.read = libertas_getscantable,
};
+static struct file_operations libertas_sleepparams_fops = {
+ .owner = THIS_MODULE,
+ .open = open_file_generic,
+ .write = libertas_sleepparams_write,
+ .read = libertas_sleepparams_read,
+};
+
void libertas_debugfs_init(void)
{
if (!libertas_dir)
@@ -156,6 +243,11 @@ void libertas_debugfs_init_one(wlan_priv
priv,
&libertas_getscantable_fops);
+ priv->debugfs_sleepparams = debugfs_create_file("sleepparams", 0644,
+ priv->debugfs_dir,
+ priv,
+ &libertas_sleepparams_fops);
+
#ifdef PROC_DEBUG
libertas_debug_init(priv, dev);
#endif
diff --git a/drivers/net/wireless/libertas/wlan_dev.h b/drivers/net/wireless/libertas/wlan_dev.h
index d7f3920..8a33b61 100644
--- a/drivers/net/wireless/libertas/wlan_dev.h
+++ b/drivers/net/wireless/libertas/wlan_dev.h
@@ -173,6 +173,7 @@ struct _wlan_private {
struct dentry *debugfs_devinfo;
struct dentry *debugfs_debug;
struct dentry *debugfs_getscantable;
+ struct dentry *debugfs_sleepparams;
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 4e79171..ffb6ad1 100644
--- a/drivers/net/wireless/libertas/wlan_ioctl.c
+++ b/drivers/net/wireless/libertas/wlan_ioctl.c
@@ -1416,47 +1416,6 @@ static int wlan_do_getlog_ioctl(wlan_pri
}
/**
- * @brief config sleep parameters
- * @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_sleep_params_ioctl(wlan_private * priv, struct iwreq *wrq)
-{
- int ret;
- wlan_adapter *Adapter = priv->adapter;
- wlan_ioctl_sleep_params_config sp;
-
- ENTER();
-
- memset(&sp, 0, sizeof(sp));
-
- if (copy_from_user(&sp, wrq->u.data.pointer,
- min_t(size_t, sizeof(sp), wrq->u.data.length))) {
- dprintk(1, "Copy from user failed\n");
- return -EFAULT;
- }
-
- memcpy(&Adapter->sp, &sp.Error, sizeof(struct sleep_params));
-
- ret = libertas_prepare_and_send_command(priv, HostCmd_CMD_802_11_SLEEP_PARAMS,
- sp.Action, HostCmd_OPTION_WAITFORRSP,
- 0, NULL);
-
- if (!ret && !sp.Action && wrq->u.data.pointer) {
- memcpy(&sp.Error, &Adapter->sp, sizeof(struct sleep_params));
- if (copy_to_user(wrq->u.data.pointer, &sp, sizeof(sp))) {
- dprintk(1, "Copy to user failed\n");
- return -EFAULT;
- }
- wrq->u.data.length = sizeof(sp);
- }
-
- LEAVE();
- return ret;
-}
-
-/**
* @brief Read the CIS Table
* @param priv A pointer to wlan_private structure
* @param req A pointer to ifreq structure
@@ -2343,10 +2302,6 @@ #define MAX_U16_VAL 65535
case WLAN_SET64CHAR_GET64CHAR:
switch ((int)wrq->u.data.flags) {
- case WLANSLEEPPARAMS:
- ret = wlan_sleep_params_ioctl(priv, wrq);
- break;
-
case WLANSCAN_MODE:
dprintk(1, "Scan Mode Ioctl\n");
ret = wlan_scan_mode_ioctl(priv, wrq);
diff --git a/drivers/net/wireless/libertas/wlan_wext.c b/drivers/net/wireless/libertas/wlan_wext.c
index 227f8fa..c45eaec 100644
--- a/drivers/net/wireless/libertas/wlan_wext.c
+++ b/drivers/net/wireless/libertas/wlan_wext.c
@@ -1530,6 +1530,7 @@ #endif /* REASSOCIATION */
IW_PRIV_TYPE_CHAR | 64,
IW_PRIV_TYPE_CHAR | 64,
""},
+ /* XXX: converted to debugfs, remove */
{
WLANSLEEPPARAMS,
IW_PRIV_TYPE_CHAR | 64,
diff --git a/drivers/net/wireless/libertas/wlan_wext.h b/drivers/net/wireless/libertas/wlan_wext.h
index f991dc8..355a67d 100644
--- a/drivers/net/wireless/libertas/wlan_wext.h
+++ b/drivers/net/wireless/libertas/wlan_wext.h
@@ -235,18 +235,6 @@ int wlan_set_encode(struct net_device *d
struct iw_point *dwrq, char *extra);
#endif
-/** sleep_params */
-typedef struct _wlan_ioctl_sleep_params_config {
- u16 Action;
- u16 Error;
- u16 Offset;
- u16 StableTime;
- u8 CalControl;
- u8 ExtSleepClk;
- u16 Reserved;
-} __attribute__ ((packed)) wlan_ioctl_sleep_params_config,
- *pwlan_ioctl_sleep_params_config;
-
/** BCA TIME SHARE */
typedef struct _wlan_ioctl_bca_timeshare_config {
/** ACT_GET/ACT_SET */
More information about the Commits-kernel
mailing list