From: Michael Buesch <mb@bu3sch.de>
To: bcm43xx-dev@lists.berlios.de
Cc: Larry Finger <Larry.Finger@lwfinger.net>, linux-wireless@vger.kernel.org
Subject: Re: [RFC V2] bcm43xx-mac80211: Add TX power set file to debugfs
Date: Mon, 6 Aug 2007 23:07:40 +0200 [thread overview]
Message-ID: <200708062307.40590.mb@bu3sch.de> (raw)
In-Reply-To: <46b78ac2.M4X/XQ9LXYHUe/aO%Larry.Finger@lwfinger.net>
On Monday 06 August 2007 22:55:30 Larry Finger wrote:
> For testing purposes, this patch adds a file named "power_level" to the
> debugfs for bcm43xx-mac80211. If this file is read, it returns the current
> setting for the "Desired power level". Writing a number between 5 and 18
> will set that value as the new value for the desired power setting.
>
> Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
> ---
>
> Michael,
>
> The error before is fixed in this version.
>
> Larry
>
> Index: wireless-dev/drivers/net/wireless/bcm43xx-mac80211/bcm43xx_debugfs.c
> ===================================================================
> --- wireless-dev.orig/drivers/net/wireless/bcm43xx-mac80211/bcm43xx_debugfs.c
> +++ wireless-dev/drivers/net/wireless/bcm43xx-mac80211/bcm43xx_debugfs.c
> @@ -151,6 +151,74 @@ out_unlock_bb:
> return res;
> }
>
> +static ssize_t power_read_file(struct file *file, char __user *userbuf,
> + size_t count, loff_t *ppos)
> +{
> + struct bcm43xx_wldev *dev = file->private_data;
> + const size_t len = ARRAY_SIZE(big_buffer);
> + char *buf = big_buffer;
> + size_t pos = 0;
> + ssize_t res;
> + unsigned long flags;
> +
> + mutex_lock(&big_buffer_mutex);
> + mutex_lock(&dev->wl->mutex);
> + spin_lock_irqsave(&dev->wl->irq_lock, flags);
> + if (bcm43xx_status(dev) < BCM43xx_STAT_STARTED) {
> + fappend("Board not initialized.\n");
> + goto out;
> + }
> + fappend("%d dBm\n",dev->phy.power_level);
> +
> +out:
> + spin_unlock_irqrestore(&dev->wl->irq_lock, flags);
> + mutex_unlock(&dev->wl->mutex);
> + res = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
> + mutex_unlock(&big_buffer_mutex);
> +
> + return res;
> +}
> +
> +static ssize_t power_write_file(struct file *file, const char __user *user_buf,
> + size_t count, loff_t *ppos)
> +{
> + struct bcm43xx_wldev *dev = file->private_data;
> + char *buf = big_buffer;
> + ssize_t buf_size;
> + ssize_t res;
> + unsigned long flags;
> + int power;
> +
> + mutex_lock(&big_buffer_mutex);
> + buf_size = min(count, ARRAY_SIZE(big_buffer) - 1);
> + if (copy_from_user(buf, user_buf, buf_size)) {
> + res = -EFAULT;
> + goto out_unlock_bb;
> + }
> + mutex_lock(&dev->wl->mutex);
> + spin_lock_irqsave(&dev->wl->irq_lock, flags);
> + if (bcm43xx_status(dev) < BCM43xx_STAT_STARTED) {
> + bcmerr(dev->wl, "debugfs: Board not initialized.\n");
> + res = -EFAULT;
> + goto out_unlock;
> + }
> + if ((sscanf(buf, "%d", &power) != 1) || (power > 18 || power < 5)) {
> + bcmerr(dev->wl, "debugfs: Invalid values for power level\n");
> + res = -EINVAL;
> + goto out_unlock;
> + }
> + dev->phy.power_level = power;
> + res = buf_size;
> +
> +out_unlock:
> + spin_unlock_irqrestore(&dev->wl->irq_lock, flags);
> + mutex_unlock(&dev->wl->mutex);
> +out_unlock_bb:
> + mutex_unlock(&big_buffer_mutex);
> +
> + return res;
> +}
> +
> static ssize_t txstat_read_file(struct file *file, char __user *userbuf,
> size_t count, loff_t *ppos)
> {
> @@ -405,6 +473,12 @@ static struct file_operations restart_fo
> .open = open_file_generic,
> };
>
> +static struct file_operations power_fops = {
> + .read = power_read_file,
> + .write = power_write_file,
> + .open = open_file_generic,
> +};
> +
>
> int bcm43xx_debug(struct bcm43xx_wldev *dev, enum bcm43xx_dyndbg feature)
> {
> @@ -495,6 +569,11 @@ void bcm43xx_debugfs_add_device(struct b
> if (IS_ERR(e->dentry_restart))
> e->dentry_restart = NULL;
>
> + e->dentry_power = debugfs_create_file("power_level", 0600, e->subdir,
> + dev, &power_fops);
> + if (IS_ERR(e->dentry_power))
> + e->dentry_power = NULL;
> +
> bcm43xx_add_dynamic_debug(dev);
> }
>
> @@ -512,6 +591,7 @@ void bcm43xx_debugfs_remove_device(struc
> debugfs_remove(e->dentry_txstat);
> debugfs_remove(e->dentry_restart);
> debugfs_remove(e->dentry_txpower_g);
> + debugfs_remove(e->dentry_power);
> debugfs_remove(e->subdir);
> kfree(e->txstatlog.log);
> kfree(e);
> Index: wireless-dev/drivers/net/wireless/bcm43xx-mac80211/bcm43xx_debugfs.h
> ===================================================================
> --- wireless-dev.orig/drivers/net/wireless/bcm43xx-mac80211/bcm43xx_debugfs.h
> +++ wireless-dev/drivers/net/wireless/bcm43xx-mac80211/bcm43xx_debugfs.h
> @@ -35,6 +35,7 @@ struct bcm43xx_dfsentry {
> struct dentry *dentry_txstat;
> struct dentry *dentry_txpower_g;
> struct dentry *dentry_restart;
> + struct dentry *dentry_power;
>
> struct bcm43xx_wldev *dev;
>
> Index: wireless-dev/drivers/net/wireless/bcm43xx-mac80211/bcm43xx_main.c
> ===================================================================
> --- wireless-dev.orig/drivers/net/wireless/bcm43xx-mac80211/bcm43xx_main.c
> +++ wireless-dev/drivers/net/wireless/bcm43xx-mac80211/bcm43xx_main.c
> @@ -2763,7 +2763,8 @@ static int bcm43xx_dev_config(struct iee
>
> /* Adjust the desired TX power level. */
> if (conf->power_level != 0) {
> - if (conf->power_level != phy->power_level) {
> + if (conf->power_level != phy->power_level &&
> + phy->power_level == 0) {
> phy->power_level = conf->power_level;
> bcm43xx_phy_xmitpower(dev);
> }
No, why do you poke with this at all.
This completely breaks power adjustment from mac80211.
Simply don't touch bcm43xx_dev_config :)
--
Greetings Michael.
next prev parent reply other threads:[~2007-08-06 21:08 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-08-06 20:55 [RFC V2] bcm43xx-mac80211: Add TX power set file to debugfs Larry Finger
2007-08-06 21:07 ` Michael Buesch [this message]
2007-08-06 21:26 ` Larry Finger
2007-08-06 21:35 ` Michael Buesch
2007-08-07 0:37 ` Tomas Winkler
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200708062307.40590.mb@bu3sch.de \
--to=mb@bu3sch.de \
--cc=Larry.Finger@lwfinger.net \
--cc=bcm43xx-dev@lists.berlios.de \
--cc=linux-wireless@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).