Search Linux Wireless

Re: [PATCH 1/1] ath5k: add debugfs entries for registers, tsf, beacon

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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, &register_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@xxxxxxxxx)
Faculty of Informatics, Masaryk University
-
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]
  Powered by Linux