From: Bruno Randolf <br1@einfach.org>
To: linville@tuxdriver.com
Cc: ath5k-devel@lists.ath5k.org, linux-wireless@vger.kernel.org
Subject: [PATCH v2 10/20] ath5k: add sysfs files for ANI parameters
Date: Wed, 19 May 2010 10:31:32 +0900 [thread overview]
Message-ID: <20100519013132.22206.87611.stgit@tt-desk> (raw)
In-Reply-To: <20100519012528.22206.77550.stgit@tt-desk>
/sys/class/ieee80211/phy0/device/ani/ani_mode
/sys/class/ieee80211/phy0/device/ani/noise_immunity_level
/sys/class/ieee80211/phy0/device/ani/spur_level
/sys/class/ieee80211/phy0/device/ani/firstep_level
/sys/class/ieee80211/phy0/device/ani/ofdm_weak_signal_detection
/sys/class/ieee80211/phy0/device/ani/cck_weak_signal_detection
/sys/class/ieee80211/phy0/device/ani/noise_immunity_level_max
/sys/class/ieee80211/phy0/device/ani/spur_level_max
/sys/class/ieee80211/phy0/device/ani/firstep_level_max
sysfs has a lot of symlinks, so you can find the files also in other locations,
like (by PCI ID) /sys/devices/pci0000:00/0000:00:11.0/ani and others.
Signed-off-by: Bruno Randolf <br1@einfach.org>
---
drivers/net/wireless/ath/ath5k/Makefile | 1
drivers/net/wireless/ath/ath5k/ath5k.h | 3 +
drivers/net/wireless/ath/ath5k/base.c | 3 +
drivers/net/wireless/ath/ath5k/reset.c | 1
drivers/net/wireless/ath/ath5k/sysfs.c | 116 +++++++++++++++++++++++++++++++
5 files changed, 123 insertions(+), 1 deletions(-)
create mode 100644 drivers/net/wireless/ath/ath5k/sysfs.c
diff --git a/drivers/net/wireless/ath/ath5k/Makefile b/drivers/net/wireless/ath/ath5k/Makefile
index cc09595..2242a14 100644
--- a/drivers/net/wireless/ath/ath5k/Makefile
+++ b/drivers/net/wireless/ath/ath5k/Makefile
@@ -13,5 +13,6 @@ ath5k-y += base.o
ath5k-y += led.o
ath5k-y += rfkill.o
ath5k-y += ani.o
+ath5k-y += sysfs.o
ath5k-$(CONFIG_ATH5K_DEBUG) += debug.o
obj-$(CONFIG_ATH5K) += ath5k.o
diff --git a/drivers/net/wireless/ath/ath5k/ath5k.h b/drivers/net/wireless/ath/ath5k/ath5k.h
index d6f9afe..eace74d 100644
--- a/drivers/net/wireless/ath/ath5k/ath5k.h
+++ b/drivers/net/wireless/ath/ath5k/ath5k.h
@@ -1150,6 +1150,9 @@ struct ath5k_hw {
int ath5k_hw_attach(struct ath5k_softc *sc);
void ath5k_hw_detach(struct ath5k_hw *ah);
+int ath5k_sysfs_register(struct ath5k_softc *sc);
+void ath5k_sysfs_unregister(struct ath5k_softc *sc);
+
/* LED functions */
int ath5k_init_leds(struct ath5k_softc *sc);
void ath5k_led_enable(struct ath5k_softc *sc);
diff --git a/drivers/net/wireless/ath/ath5k/base.c b/drivers/net/wireless/ath/ath5k/base.c
index 3b43b76..d5d514f 100644
--- a/drivers/net/wireless/ath/ath5k/base.c
+++ b/drivers/net/wireless/ath/ath5k/base.c
@@ -861,6 +861,8 @@ ath5k_attach(struct pci_dev *pdev, struct ieee80211_hw *hw)
ath5k_init_leds(sc);
+ ath5k_sysfs_register(sc);
+
return 0;
err_queues:
ath5k_txq_release(sc);
@@ -896,6 +898,7 @@ ath5k_detach(struct pci_dev *pdev, struct ieee80211_hw *hw)
ath5k_hw_release_tx_queue(sc->ah, sc->bhalq);
ath5k_unregister_leds(sc);
+ ath5k_sysfs_unregister(sc);
/*
* NB: can't reclaim these until after ieee80211_ifdetach
* returns because we'll get called back to reclaim node
diff --git a/drivers/net/wireless/ath/ath5k/reset.c b/drivers/net/wireless/ath/ath5k/reset.c
index 2890a7f..b1d3239 100644
--- a/drivers/net/wireless/ath/ath5k/reset.c
+++ b/drivers/net/wireless/ath/ath5k/reset.c
@@ -851,7 +851,6 @@ static void ath5k_hw_commit_eeprom_settings(struct ath5k_hw *ah,
AR5K_PHY_NF_THRESH62,
ee->ee_thr_62[ee_mode]);
-
/* False detect backoff for channels
* that have spur noise. Write the new
* cyclic power RSSI threshold. */
diff --git a/drivers/net/wireless/ath/ath5k/sysfs.c b/drivers/net/wireless/ath/ath5k/sysfs.c
new file mode 100644
index 0000000..90757de
--- /dev/null
+++ b/drivers/net/wireless/ath/ath5k/sysfs.c
@@ -0,0 +1,116 @@
+#include <linux/device.h>
+#include <linux/pci.h>
+
+#include "base.h"
+#include "ath5k.h"
+#include "reg.h"
+
+#define SIMPLE_SHOW_STORE(name, get, set) \
+static ssize_t ath5k_attr_show_##name(struct device *dev, \
+ struct device_attribute *attr, \
+ char *buf) \
+{ \
+ struct ath5k_softc *sc = dev_get_drvdata(dev); \
+ return snprintf(buf, PAGE_SIZE, "%d\n", get); \
+} \
+ \
+static ssize_t ath5k_attr_store_##name(struct device *dev, \
+ struct device_attribute *attr, \
+ const char *buf, size_t count) \
+{ \
+ struct ath5k_softc *sc = dev_get_drvdata(dev); \
+ int val; \
+ \
+ val = (int)simple_strtoul(buf, NULL, 10); \
+ set(sc->ah, val); \
+ return count; \
+} \
+static DEVICE_ATTR(name, S_IRUGO | S_IWUSR, \
+ ath5k_attr_show_##name, ath5k_attr_store_##name)
+
+#define SIMPLE_SHOW(name, get) \
+static ssize_t ath5k_attr_show_##name(struct device *dev, \
+ struct device_attribute *attr, \
+ char *buf) \
+{ \
+ struct ath5k_softc *sc = dev_get_drvdata(dev); \
+ return snprintf(buf, PAGE_SIZE, "%d\n", get); \
+} \
+static DEVICE_ATTR(name, S_IRUGO, ath5k_attr_show_##name, NULL)
+
+/*** ANI ***/
+
+SIMPLE_SHOW_STORE(ani_mode, sc->ani_state.ani_mode, ath5k_ani_init);
+SIMPLE_SHOW_STORE(noise_immunity_level, sc->ani_state.noise_imm_level,
+ ath5k_ani_set_noise_immunity_level);
+SIMPLE_SHOW_STORE(spur_level, sc->ani_state.spur_level,
+ ath5k_ani_set_spur_immunity_level);
+SIMPLE_SHOW_STORE(firstep_level, sc->ani_state.firstep_level,
+ ath5k_ani_set_firstep_level);
+SIMPLE_SHOW_STORE(ofdm_weak_signal_detection, sc->ani_state.ofdm_weak_sig,
+ ath5k_ani_set_ofdm_weak_signal_detection);
+SIMPLE_SHOW_STORE(cck_weak_signal_detection, sc->ani_state.cck_weak_sig,
+ ath5k_ani_set_cck_weak_signal_detection);
+SIMPLE_SHOW(spur_level_max, sc->ani_state.max_spur_level);
+
+static ssize_t ath5k_attr_show_noise_immunity_level_max(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+ return snprintf(buf, PAGE_SIZE, "%d\n", ATH5K_ANI_MAX_NOISE_IMM_LVL);
+}
+static DEVICE_ATTR(noise_immunity_level_max, S_IRUGO,
+ ath5k_attr_show_noise_immunity_level_max, NULL);
+
+static ssize_t ath5k_attr_show_firstep_level_max(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+ return snprintf(buf, PAGE_SIZE, "%d\n", ATH5K_ANI_MAX_FIRSTEP_LVL);
+}
+static DEVICE_ATTR(firstep_level_max, S_IRUGO,
+ ath5k_attr_show_firstep_level_max, NULL);
+
+static struct attribute *ath5k_sysfs_entries_ani[] = {
+ &dev_attr_ani_mode.attr,
+ &dev_attr_noise_immunity_level.attr,
+ &dev_attr_spur_level.attr,
+ &dev_attr_firstep_level.attr,
+ &dev_attr_ofdm_weak_signal_detection.attr,
+ &dev_attr_cck_weak_signal_detection.attr,
+ &dev_attr_noise_immunity_level_max.attr,
+ &dev_attr_spur_level_max.attr,
+ &dev_attr_firstep_level_max.attr,
+ NULL
+};
+
+static struct attribute_group ath5k_attribute_group_ani = {
+ .name = "ani",
+ .attrs = ath5k_sysfs_entries_ani,
+};
+
+
+/*** register / unregister ***/
+
+int
+ath5k_sysfs_register(struct ath5k_softc *sc)
+{
+ struct device *dev = &sc->pdev->dev;
+ int err;
+
+ err = sysfs_create_group(&dev->kobj, &ath5k_attribute_group_ani);
+ if (err) {
+ ATH5K_ERR(sc, "failed to create sysfs group\n");
+ return err;
+ }
+
+ return 0;
+}
+
+void
+ath5k_sysfs_unregister(struct ath5k_softc *sc)
+{
+ struct device *dev = &sc->pdev->dev;
+
+ sysfs_remove_group(&dev->kobj, &ath5k_attribute_group_ani);
+}
next prev parent reply other threads:[~2010-05-19 1:32 UTC|newest]
Thread overview: 54+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-19 1:30 [PATCH v2 00/20] pending ath5k + antenna patches Bruno Randolf
2010-05-19 1:30 ` [PATCH v2 01/20] ath5k: add debugfs file for queue debugging Bruno Randolf
2010-05-19 1:30 ` [PATCH v2 02/20] ath5k: wake queues on reset Bruno Randolf
2010-05-20 12:51 ` [ath5k-devel] " Nick Kossifidis
2010-05-19 1:30 ` [PATCH v2 03/20] ath5k: initialize calibration timers Bruno Randolf
2010-05-20 12:48 ` Nick Kossifidis
2010-05-19 1:31 ` [PATCH v2 04/20] ath5k: move noise floor calibration into tasklet Bruno Randolf
2010-05-20 12:50 ` Nick Kossifidis
2010-05-19 1:31 ` [PATCH v2 05/20] ath5k: Stop queues only for NF calibration Bruno Randolf
2010-05-20 12:52 ` Nick Kossifidis
2010-05-19 1:31 ` [PATCH v2 06/20] ath5k: run NF calibration only every 60 seconds Bruno Randolf
2010-05-19 1:31 ` [PATCH v2 07/20] ath5k: remove ATH_TRACE macro Bruno Randolf
2010-05-20 12:56 ` Nick Kossifidis
2010-05-19 1:31 ` [PATCH v2 08/20] ath5k: clarify logic when to enable spur mitigation filter Bruno Randolf
2010-05-19 1:31 ` [PATCH v2 09/20] ath5k: use ath5k_softc as driver data Bruno Randolf
2010-05-19 1:31 ` Bruno Randolf [this message]
2010-05-20 12:58 ` [PATCH v2 10/20] ath5k: add sysfs files for ANI parameters Nick Kossifidis
2010-05-19 1:31 ` [PATCH v2 11/20] ath5k: always calculate ANI listen time Bruno Randolf
2010-05-20 12:59 ` Nick Kossifidis
2010-05-19 1:31 ` [PATCH v2 12/20] ath5k: print error message if ANI levels are out of range Bruno Randolf
2010-05-19 1:31 ` [PATCH v2 13/20] cfg80211: Add nl80211 antenna configuration Bruno Randolf
2010-05-19 17:07 ` Luis R. Rodriguez
2010-05-20 0:35 ` Bruno Randolf
2010-05-20 0:51 ` [ath5k-devel] " Luis R. Rodriguez
2010-05-20 1:12 ` Bruno Randolf
2010-05-20 1:26 ` Luis R. Rodriguez
2010-05-20 2:21 ` Bruno Randolf
2010-05-20 5:17 ` Luis R. Rodriguez
2010-05-20 5:36 ` Bruno Randolf
2010-05-20 6:43 ` Luis R. Rodriguez
2010-05-20 22:02 ` David Quan
2010-05-20 22:05 ` Luis R. Rodriguez
2010-05-20 22:14 ` Sam Ng
2010-05-20 22:24 ` Luis R. Rodriguez
2010-05-21 1:59 ` Bruno Randolf
2010-05-21 17:11 ` Luis R. Rodriguez
2010-05-21 19:10 ` Felix Fietkau
2010-05-21 20:28 ` Luis R. Rodriguez
2010-05-24 0:45 ` Bruno Randolf
2010-05-24 9:15 ` RHS Linux User
2010-06-04 19:30 ` John W. Linville
2010-06-04 21:21 ` [ath5k-devel] " Luis R. Rodriguez
2010-06-04 21:53 ` Luis R. Rodriguez
2010-06-07 3:45 ` Bruno Randolf
2010-05-19 1:31 ` [PATCH v2 14/20] mac80211: Add " Bruno Randolf
2010-05-19 1:31 ` [PATCH v2 15/20] ath5k: Add support for " Bruno Randolf
2010-05-19 1:32 ` [PATCH v2 16/20] ath5k: remove setting ANI and antenna thru debugfs files Bruno Randolf
2010-05-19 1:32 ` [PATCH v2 17/20] ath5k: fix NULL pointer in antenna configuration Bruno Randolf
2010-05-19 1:32 ` [PATCH v2 18/20] ath5k: update AR5K_PHY_RESTART_DIV_GC values to match masks Bruno Randolf
2010-05-20 12:54 ` Nick Kossifidis
2010-05-19 1:32 ` [PATCH v2 19/20] ath5k: new function for setting the antenna switch table Bruno Randolf
2010-05-19 1:32 ` [PATCH v2 20/20] ath5k: no need to save/restore the default antenna Bruno Randolf
2010-05-19 1:41 ` [PATCH v2 00/20] pending ath5k + antenna patches Luis R. Rodriguez
2010-05-19 12:59 ` John W. Linville
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=20100519013132.22206.87611.stgit@tt-desk \
--to=br1@einfach.org \
--cc=ath5k-devel@lists.ath5k.org \
--cc=linux-wireless@vger.kernel.org \
--cc=linville@tuxdriver.com \
/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).