From: Jiri Slaby <jirislaby@gmail.com>
To: bruno randolf <bruno@thinktube.com>
Cc: ath5k-devel@lists.ath5k.org, linux-wireless@vger.kernel.org,
linville@tuxdriver.com, mcgrof@gmail.com, mickflemm@gmail.com
Subject: Re: [PATCH 1/1] ath5k: add debugfs entries for registers, tsf, beacon
Date: Sat, 08 Dec 2007 09:42:33 +0100 [thread overview]
Message-ID: <475A58F9.2080009@gmail.com> (raw)
In-Reply-To: <200712051950.08672.bruno@thinktube.com>
On 12/05/2007 11:50 AM, bruno randolf wrote:
[...]
> +static int open_file_registers(struct inode *inode, struct file *file)
> +{
> + struct seq_file *s;
> + int res;
> + res = seq_open(file, ®ister_seq_ops);
> + s = (struct seq_file *)file->private_data;
you don't need to cast here (from void *).
> + s->private = inode->i_private;
> + return res;
> +}
> +
> +static const struct file_operations fops_registers = {
BTW. to prevent removing the module while having opened this debug stuff, you
should add:
.owner = THIS_MODULE,
> + .open = open_file_registers,
> + .read = seq_read,
> + .llseek = seq_lseek,
> + .release = seq_release
> +};
> +
> +
> +/* debugfs: TSF */
> +
> +static ssize_t read_file_tsf(struct file *file, char __user *user_buf,
> + size_t count, loff_t *ppos)
> +{
> + struct ath5k_softc *sc = file->private_data;
> + char buf[100];
> + snprintf(buf, 100, "0x%016llx\n", ath5k_hw_get_tsf64(sc->ah));
> + return simple_read_from_buffer(user_buf, count, ppos, buf, 19);
> +}
> +
> +static ssize_t write_file_tsf(struct file *file,
> + const char __user *userbuf,
> + size_t count, loff_t *ppos)
> +{
> + struct ath5k_softc *sc = file->private_data;
> + if (strncmp(userbuf, "reset", 5) == 0) {
> + ath5k_hw_reset_tsf(sc->ah);
> + printk(KERN_INFO "debugfs reset TSF\n");
> + }
> + return count;
> +}
> +
> +static const struct file_operations fops_tsf = {
and here
> + .read = read_file_tsf,
> + .write = write_file_tsf,
> + .open = ath5k_debugfs_open,
> +};
> +
> +
> +/* debugfs: beacons */
> +
> +static ssize_t read_file_beacon(struct file *file, char __user *user_buf,
> + size_t count, loff_t *ppos)
> +{
> + struct ath5k_softc *sc = file->private_data;
> + struct ath5k_hw *ah = sc->ah;
> +
> + char buf[1000];
> + int len = 0;
> + REG_PRINT_APPEND(AR5K_BEACON);
> + len += snprintf(buf+len, 1000-len, "\tbeacon period:\t%d\n",
> + ath5k_hw_reg_read(ah, AR5K_BEACON) & AR5K_BEACON_PERIOD);
> + len += snprintf(buf+len, 1000-len, "\tbeacon tim:\t%x\n",
> + (ath5k_hw_reg_read(ah, AR5K_BEACON) & AR5K_BEACON_TIM)
> + >> AR5K_BEACON_TIM_S);
> + len += snprintf(buf+len, 1000-len, "\tbeacons enabled: %s\n",
> + ath5k_hw_reg_read(ah, AR5K_BEACON) & AR5K_BEACON_ENABLE ?
> + "YES" : "NO");
> + REG_PRINT_APPEND(AR5K_TIMER0);
> + REG_PRINT_APPEND(AR5K_TIMER1);
> + REG_PRINT_APPEND(AR5K_TIMER2);
> + REG_PRINT_APPEND(AR5K_TIMER3);
> + REG_PRINT_APPEND(AR5K_LAST_TSTP);
> + REG_PRINT_APPEND(AR5K_BEACON_CNT);
> +
> + return simple_read_from_buffer(user_buf, count, ppos, buf, len);
> +}
> +
> +static ssize_t write_file_beacon(struct file *file,
> + const char __user *userbuf,
> + size_t count, loff_t *ppos)
> +{
> + struct ath5k_softc *sc = file->private_data;
> + struct ath5k_hw *ah = sc->ah;
> +
> + if (strncmp(userbuf, "disable", 7) == 0) {
> + AR5K_REG_DISABLE_BITS(ah, AR5K_BEACON, AR5K_BEACON_ENABLE);
> + printk(KERN_INFO "debugfs disable beacons\n");
> + } else if (strncmp(userbuf, "enable", 6) == 0) {
> + AR5K_REG_ENABLE_BITS(ah, AR5K_BEACON, AR5K_BEACON_ENABLE);
> + printk(KERN_INFO "debugfs enable beacons\n");
> + }
> + return count;
> +}
> +
> +static const struct file_operations fops_beacon = {
and here.
> + .read = read_file_beacon,
> + .write = write_file_beacon,
> + .open = ath5k_debugfs_open,
> +};
> +
> +
> +/* debugfs: reset */
> +
> +static ssize_t write_file_reset(struct file *file,
> + const char __user *userbuf,
> + size_t count, loff_t *ppos)
> +{
> + struct ath5k_softc *sc = file->private_data;
> + tasklet_schedule(&sc->restq);
> + return count;
> +}
> +
> +static const struct file_operations fops_reset = {
and here :)
> + .write = write_file_reset,
> + .open = ath5k_debugfs_open,
> +};
thanks,
--
Jiri Slaby (jirislaby@gmail.com)
Faculty of Informatics, Masaryk University
prev parent reply other threads:[~2007-12-08 8:42 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-12-05 7:27 [PATCH 1/1] ath5k: add debugfs entries for registers, tsf, beacon Bruno Randolf
2007-12-05 9:12 ` Jiri Slaby
2007-12-05 10:50 ` bruno randolf
2007-12-07 22:35 ` Luis R. Rodriguez
2007-12-08 0:34 ` [ath5k-devel] " bruno randolf
2007-12-08 8:42 ` Jiri Slaby [this message]
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=475A58F9.2080009@gmail.com \
--to=jirislaby@gmail.com \
--cc=ath5k-devel@lists.ath5k.org \
--cc=bruno@thinktube.com \
--cc=linux-wireless@vger.kernel.org \
--cc=linville@tuxdriver.com \
--cc=mcgrof@gmail.com \
--cc=mickflemm@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.