rt2x00: Reduce requirement for debugfs wrapper functions
PATCH 6/11 rt2x00: Reduce requirement for debugfs wrapper functions
Quoted 1 line
From
6a6a1092f310fcea951cac0072287073b1fd4e93Mon Sep 17 00:00:00 2001
From: Ivo van Doorn <[email protected]>
Date: Tue, 24 Jul 2007 17:31:09 +0200
Subject: [PATCH 06/11] rt2x00: Reduce requirement for debugfs wrapper functions
Because the callback functions for each register for very generic, individual drivers needed to add wrapper functions to translate passed values to the correct type.
We should make rt2x00debug more aware of the different types, and make both the rt2x00debug code less complex by adding some better helper macros. And help the driver part by removing the requirement of wrapper functions for BBP and EEPROM. CSR wrapping remains requirement due to the word->offset translation.
--- drivers/net/wireless/mac80211/rt2x00/rt2400pci.c | 56 ++---- drivers/net/wireless/mac80211/rt2x00/rt2500pci.c | 56 ++---- drivers/net/wireless/mac80211/rt2x00/rt2500usb.c | 66 ++---- drivers/net/wireless/mac80211/rt2x00/rt2x00.h | 4 +- drivers/net/wireless/mac80211/rt2x00/rt2x00debug.c | 240 +++++++------------- drivers/net/wireless/mac80211/rt2x00/rt2x00debug.h | 27 +-- drivers/net/wireless/mac80211/rt2x00/rt61pci.c | 56 ++---- drivers/net/wireless/mac80211/rt2x00/rt73usb.c | 64 ++---- 8 files changed, 192 insertions(+), 377 deletions(-)
drivers/net/wireless/mac80211/rt2x00/rt2400pci.c +16 -40
@@ -74,7 +74,7 @@ static u32 rt2400pci_bbp_check(const struct rt2x00_dev *rt2x00dev) }static void rt2400pci_bbp_write (const struct rt2x00_dev *rt2x00dev, -const u8 reg_id,const u8 value) +const unsigned int word,const u8 value) {u32 reg;
@@ -92,7 +92,7 @@ static void rt2400pci_bbp_write(const struct rt2x00_dev *rt2x00dev,*/ reg =0 ;rt2x00_set_field32 (®,BBPCSR_VALUE , value); -rt2x00_set_field32 (®,BBPCSR_REGNUM , reg_id); +rt2x00_set_field32 (®,BBPCSR_REGNUM , word);rt2x00_set_field32 (®,BBPCSR_BUSY ,1 );rt2x00_set_field32 (®,BBPCSR_WRITE_CONTROL ,1 );
@@ -100,7 +100,7 @@ static void rt2400pci_bbp_write(const struct rt2x00_dev *rt2x00dev, }static void rt2400pci_bbp_read (const struct rt2x00_dev *rt2x00dev, -const u8 reg_id,u8 *value) +const unsigned int word,u8 *value) {u32 reg;
@@ -117,7 +117,7 @@ static void rt2400pci_bbp_read(const struct rt2x00_dev *rt2x00dev,* Write the request into the BBP. */ reg =0 ; -rt2x00_set_field32 (®,BBPCSR_REGNUM , reg_id); +rt2x00_set_field32 (®,BBPCSR_REGNUM , word);rt2x00_set_field32 (®,BBPCSR_BUSY ,1 );rt2x00_set_field32 (®,BBPCSR_WRITE_CONTROL ,0 );
@@ -199,59 +199,35 @@ static void rt2400pci_eepromregister_write(struct eeprom_93cx6 *eeprom)#ifdef CONFIG_RT2X00_LIB_DEBUGFS #define CSR_OFFSET (__word) ( CSR_REG_BASE + ((__word) * sizeof(u32)) ) -static void rt2400pci_read_csr (struct rt2x00_dev *rt2x00dev, -const unsigned int word,void *data) +static void rt2400pci_read_csr (const struct rt2x00_dev *rt2x00dev, +const unsigned int word,u32 *data) {rt2x00pci_register_read (rt2x00dev,CSR_OFFSET (word), data); } -static void rt2400pci_write_csr (struct rt2x00_dev *rt2x00dev, -const unsigned int word,void *data) +static void rt2400pci_write_csr (const struct rt2x00_dev *rt2x00dev, +const unsigned int word,u32 data) { -rt2x00pci_register_write (rt2x00dev,CSR_OFFSET (word), *((u32 *)data)); -} - -static void rt2400pci_read_eeprom (struct rt2x00_dev *rt2x00dev, -const unsigned int word,void *data) -{ -rt2x00_eeprom_read (rt2x00dev, word, data); -} - -static void rt2400pci_write_eeprom (struct rt2x00_dev *rt2x00dev, -const unsigned int word,void *data) -{ -rt2x00_eeprom_write (rt2x00dev, word, *((u16 *)data)); -} - -static void rt2400pci_read_bbp (struct rt2x00_dev *rt2x00dev, -const unsigned int word,void *data) -{ -rt2400pci_bbp_read (rt2x00dev, word, data); -} - -static void rt2400pci_write_bbp (struct rt2x00_dev *rt2x00dev, -const unsigned int word,void *data) -{ -rt2400pci_bbp_write (rt2x00dev, word, *((u8 *)data)); +rt2x00pci_register_write (rt2x00dev,CSR_OFFSET (word), data); }static const struct rt2x00debug rt2400pci_rt2x00debug = { .owner =THIS_MODULE , - .reg_csr = { + .csr = { .read = rt2400pci_read_csr, .write = rt2400pci_write_csr, .word_size =sizeof (u32), .word_count =CSR_REG_SIZE /sizeof (u32), }, - .reg_eeprom = { - .read = rt2400pci_read_eeprom, - .write = rt2400pci_write_eeprom, + .eeprom = { + .read = rt2x00_eeprom_read, + .write = rt2x00_eeprom_write, .word_size =sizeof (u16), .word_count =EEPROM_SIZE /sizeof (u16), }, - .reg_bbp = { - .read = rt2400pci_read_bbp, - .write = rt2400pci_write_bbp, + .bbp = { + .read = rt2400pci_bbp_read, + .write = rt2400pci_bbp_write, .word_size =sizeof (u8), .word_count =BBP_SIZE /sizeof (u8), },
drivers/net/wireless/mac80211/rt2x00/rt2500pci.c +16 -40
103 lines not on this page · raw message
drivers/net/wireless/mac80211/rt2x00/rt2500usb.c +21 -45
136 lines not on this page · raw message
drivers/net/wireless/mac80211/rt2x00/rt2x00.h +2 -2
@@ -951,13 +951,13 @@ static inline void* rt2x00_eeprom_addr(const struct rt2x00_dev *rt2x00dev, }static inline void rt2x00_eeprom_read (const struct rt2x00_dev *rt2x00dev, -const u8 word,u16 *data) +const unsigned int word,u16 *data) { *data =le16_to_cpu (rt2x00dev->eeprom[word]); }static inline void rt2x00_eeprom_write (const struct rt2x00_dev *rt2x00dev, -const u8 word,u16 data) +const unsigned int word,u16 data) { rt2x00dev->eeprom[word] =cpu_to_le16 (data); }
drivers/net/wireless/mac80211/rt2x00/rt2x00debug.c +88 -152
263 lines not on this page · raw message
drivers/net/wireless/mac80211/rt2x00/rt2x00debug.h +13 -14
@@ -30,16 +30,15 @@#include <net/wireless.h> -typedef void (debug_access_t )(struct rt2x00_dev *rt2x00dev, -const unsigned int word,void *data); - -struct rt2x00debug_reg { -debug_access_t *read; -debug_access_t *write; - -unsigned int word_size; -unsigned int word_count; -}; +#define RT2X00DEBUGFS_REGISTER_ENTRY (__name, __type) \ +struct reg##__name { \ + void (*read)(const struct rt2x00_dev *rt2x00dev,\ + const unsigned int word, __type *data); \ + void (*write)(const struct rt2x00_dev *rt2x00dev,\ + const unsigned int word, __type data); \ + unsigned int word_size; \ + unsigned int word_count; \ +} __namestruct rt2x00debug {/*
@@ -48,11 +47,11 @@ struct rt2x00debug {struct module *owner;/* -* Register access information. +* Register access entries. */ -struct rt2x00debug_reg reg_csr; -struct rt2x00debug_reg reg_eeprom; -struct rt2x00debug_reg reg_bbp; +RT2X00DEBUGFS_REGISTER_ENTRY (csr, u32); +RT2X00DEBUGFS_REGISTER_ENTRY (eeprom, u16); +RT2X00DEBUGFS_REGISTER_ENTRY (bbp, u8); };#ifdef CONFIG_RT2X00_LIB_DEBUGFS
drivers/net/wireless/mac80211/rt2x00/rt61pci.c +16 -40
103 lines not on this page · raw message
drivers/net/wireless/mac80211/rt2x00/rt73usb.c +20 -44
135 lines not on this page · raw message
Signature · 1 line
1.5.2.2