From 9f9e9c3ff112d6ba5b1723a8ae1f67450d7091b1 Mon Sep 17 00:00:00 2001 From: Dmitry Tarnyagin Date: Tue, 4 Oct 2011 18:11:41 +0200 Subject: cw1200: New debugfs entry for 11n support New R/W entry /sys/kernel/debug/ieee80211/phy0/cw1200/11n allows to disable and reenable 11n support in run-time. Disable 11n: echo 0 > /sys/kernel/debug/ieee80211/phy0/cw1200/11n Enable 11n: echo 1 > /sys/kernel/debug/ieee80211/phy0/cw1200/11n ST-Ericsson ID: 365735 Change-Id: Ie7b667308aa276e4ac0f4f365f86b2b103a21f7e Signed-off-by: Dmitry Tarnyagin Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/33005 Reviewed-by: QATEST Reviewed-by: Bartosz MARKOWSKI Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/33538 Reviewed-by: Philippe LANGLAIS --- drivers/staging/cw1200/debug.c | 53 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/drivers/staging/cw1200/debug.c b/drivers/staging/cw1200/debug.c index 3715678d522..6ec0d086d8b 100644 --- a/drivers/staging/cw1200/debug.c +++ b/drivers/staging/cw1200/debug.c @@ -367,6 +367,55 @@ static const struct file_operations fops_counters = { .owner = THIS_MODULE, }; +static int cw1200_generic_open(struct inode *inode, struct file *file) +{ + file->private_data = inode->i_private; + return 0; +} + +static ssize_t cw1200_11n_read(struct file *file, + char __user *user_buf, size_t count, loff_t *ppos) +{ + struct cw1200_common *priv = file->private_data; + struct ieee80211_supported_band *band = + priv->hw->wiphy->bands[IEEE80211_BAND_2GHZ]; + return simple_read_from_buffer(user_buf, count, ppos, + band->ht_cap.ht_supported ? "1\n" : "0\n", 2); +} + +static ssize_t cw1200_11n_write(struct file *file, + char __user *user_buf, size_t count, loff_t *ppos) +{ + struct cw1200_common *priv = file->private_data; + struct ieee80211_supported_band *band[2] = { + priv->hw->wiphy->bands[IEEE80211_BAND_2GHZ], + priv->hw->wiphy->bands[IEEE80211_BAND_5GHZ], + }; + char buf[1]; + int ena = 0; + + if (!count) + return -EINVAL; + if (copy_from_user(buf, user_buf, 1)) + return -EFAULT; + if (buf[0] == 1) + ena = 1; + + band[0]->ht_cap.ht_supported = ena; +#ifdef CONFIG_CW1200_5GHZ_SUPPORT + band[1]->ht_cap.ht_supported = ena; +#endif /* CONFIG_CW1200_5GHZ_SUPPORT */ + + return count; +} + +static const struct file_operations fops_11n = { + .open = cw1200_generic_open, + .read = cw1200_11n_read, + .write = cw1200_11n_write, + .llseek = default_llseek, +}; + int cw1200_debug_init(struct cw1200_common *priv) { struct cw1200_debug_priv *d = kzalloc(sizeof(struct cw1200_debug_priv), @@ -388,6 +437,10 @@ int cw1200_debug_init(struct cw1200_common *priv) priv, &fops_counters)) goto err; + if (!debugfs_create_file("11n", S_IRUSR | S_IWUSR, + d->debugfs_phy, priv, &fops_11n)) + goto err; + return 0; err: -- cgit v1.2.3