Thanks Bob. I'll make this patch as soon as I have time. -- dave --
Bob Copeland wrote: > Add two new debugfs files, led_pin and led_polarity, to make it easier > for users to find the right numbers for their system. > > Signed-off-by: Bob Copeland <m...@bobcopeland.com> > --- > > Dave, > > Please apply this, then try echoing values 0-5 into > /debug/ath5k/phy0/led_pin, and the values 0 or 1 into led_polarity. > Then we can add the correct values to the device table. > > drivers/net/wireless/ath5k/ath5k.h | 3 + > drivers/net/wireless/ath5k/base.c | 7 +-- > drivers/net/wireless/ath5k/debug.c | 89 > ++++++++++++++++++++++++++++++++++++ > drivers/net/wireless/ath5k/debug.h | 2 + > 4 files changed, 95 insertions(+), 6 deletions(-) > > diff --git a/drivers/net/wireless/ath5k/ath5k.h > b/drivers/net/wireless/ath5k/ath5k.h > index b9af2b8..e91211a 100644 > --- a/drivers/net/wireless/ath5k/ath5k.h > +++ b/drivers/net/wireless/ath5k/ath5k.h > @@ -1129,6 +1129,9 @@ struct ath5k_hw { > extern struct ath5k_hw *ath5k_hw_attach(struct ath5k_softc *sc, u8 > mac_version); > extern void ath5k_hw_detach(struct ath5k_hw *ah); > > +/* LED functions */ > +void ath5k_led_enable(struct ath5k_softc *sc); > + > /* Reset Functions */ > extern int ath5k_hw_nic_wakeup(struct ath5k_hw *ah, int flags, bool initial); > extern int ath5k_hw_reset(struct ath5k_hw *ah, enum nl80211_iftype op_mode, > struct ieee80211_channel *channel, bool change_channel); > diff --git a/drivers/net/wireless/ath5k/base.c > b/drivers/net/wireless/ath5k/base.c > index bce825b..f0281aa 100644 > --- a/drivers/net/wireless/ath5k/base.c > +++ b/drivers/net/wireless/ath5k/base.c > @@ -372,7 +372,6 @@ static void ath5k_tasklet_reset(unsigned long data); > static void ath5k_calibrate(unsigned long data); > /* LED functions */ > static int ath5k_init_leds(struct ath5k_softc *sc); > -static void ath5k_led_enable(struct ath5k_softc *sc); > static void ath5k_led_off(struct ath5k_softc *sc); > static void ath5k_unregister_leds(struct ath5k_softc *sc); > > @@ -2534,8 +2533,7 @@ ath5k_calibrate(unsigned long data) > * LED functions * > \***************/ > > -static void > -ath5k_led_enable(struct ath5k_softc *sc) > +void ath5k_led_enable(struct ath5k_softc *sc) > { > if (test_bit(ATH_STAT_LEDSOFT, sc->status)) { > ath5k_hw_set_gpio_output(sc->ah, sc->led_pin); > @@ -2645,9 +2643,6 @@ ath5k_init_leds(struct ath5k_softc *sc) > sc->led_on = 0; /* active low */ > } > > - if (!test_bit(ATH_STAT_LEDSOFT, sc->status)) > - goto out; > - > ath5k_led_enable(sc); > > snprintf(name, sizeof(name), "ath5k-%s::rx", wiphy_name(hw->wiphy)); > diff --git a/drivers/net/wireless/ath5k/debug.c > b/drivers/net/wireless/ath5k/debug.c > index 6c750ec..0b10a87 100644 > --- a/drivers/net/wireless/ath5k/debug.c > +++ b/drivers/net/wireless/ath5k/debug.c > @@ -288,6 +288,86 @@ static const struct file_operations fops_reset = { > }; > > > +/* debugfs: leds */ > +static int led_pin_read(struct file *file, char __user *user_buf, > + size_t count, loff_t *ppos) > +{ > + struct ath5k_softc *sc = file->private_data; > + char buf[20]; > + int len; > + > + len = snprintf(buf, sizeof(buf), "%d\n", sc->led_pin); > + > + return simple_read_from_buffer(user_buf, count, ppos, buf, len); > +} > + > +static ssize_t led_pin_write(struct file *file, > + const char __user *userbuf, > + size_t count, loff_t *ppos) > +{ > + struct ath5k_softc *sc = file->private_data; > + char buf[20]; > + char *p = buf; > + int val; > + > + if (copy_from_user(buf, userbuf, min(count, sizeof(buf)))) > + return -EFAULT; > + > + val = simple_strtoul(p, &p, 10); > + if (p != buf) { > + __set_bit(ATH_STAT_LEDSOFT, sc->status); > + sc->led_pin = val; > + ath5k_led_enable(sc); > + } > + return count; > +} > + > +static int led_polarity_read(struct file *file, char __user *user_buf, > + size_t count, loff_t *ppos) > +{ > + struct ath5k_softc *sc = file->private_data; > + char buf[20]; > + int len; > + > + len = snprintf(buf, sizeof(buf), "%d\n", sc->led_on); > + > + return simple_read_from_buffer(user_buf, count, ppos, buf, len); > +} > + > +static ssize_t led_polarity_write(struct file *file, > + const char __user *userbuf, > + size_t count, loff_t *ppos) > +{ > + struct ath5k_softc *sc = file->private_data; > + char buf[20]; > + char *p = buf; > + int val; > + > + if (copy_from_user(buf, userbuf, min(count, sizeof(buf)))) > + return -EFAULT; > + > + val = simple_strtoul(p, &p, 10); > + if (p != buf) > + sc->led_on = val; > + > + return count; > +} > + > +static const struct file_operations fops_led_pin = { > + .open = ath5k_debugfs_open, > + .read = led_pin_read, > + .write = led_pin_write, > + .owner = THIS_MODULE, > +}; > + > +static const struct file_operations fops_led_polarity = { > + .open = ath5k_debugfs_open, > + .read = led_polarity_read, > + .write = led_polarity_write, > + .owner = THIS_MODULE, > +}; > + > + > /* debugfs: debug level */ > > static struct { > @@ -391,6 +471,13 @@ ath5k_debug_init_device(struct ath5k_softc *sc) > > sc->debug.debugfs_reset = debugfs_create_file("reset", S_IWUSR, > sc->debug.debugfs_phydir, sc, &fops_reset); > + > + sc->debug.debugfs_led_pin = debugfs_create_file("led_pin", > + S_IWUSR | S_IRUGO, sc->debug.debugfs_phydir, sc, &fops_led_pin); > + > + sc->debug.debugfs_led_polarity = debugfs_create_file("led_polarity", > + S_IWUSR | S_IRUGO, sc->debug.debugfs_phydir, sc, > + &fops_led_polarity); > } > > void > @@ -406,6 +493,8 @@ ath5k_debug_finish_device(struct ath5k_softc *sc) > debugfs_remove(sc->debug.debugfs_registers); > debugfs_remove(sc->debug.debugfs_beacon); > debugfs_remove(sc->debug.debugfs_reset); > + debugfs_remove(sc->debug.debugfs_led_pin); > + debugfs_remove(sc->debug.debugfs_led_polarity); > debugfs_remove(sc->debug.debugfs_phydir); > } > > diff --git a/drivers/net/wireless/ath5k/debug.h > b/drivers/net/wireless/ath5k/debug.h > index 66f69f0..67cbbf4 100644 > --- a/drivers/net/wireless/ath5k/debug.h > +++ b/drivers/net/wireless/ath5k/debug.h > @@ -74,6 +74,8 @@ struct ath5k_dbg_info { > struct dentry *debugfs_registers; > struct dentry *debugfs_beacon; > struct dentry *debugfs_reset; > + struct dentry *debugfs_led_pin; > + struct dentry *debugfs_led_polarity; > }; > > /** _______________________________________________ ath5k-devel mailing list ath5k-devel@lists.ath5k.org https://lists.ath5k.org/mailman/listinfo/ath5k-devel