In there are all the debug facilites I would have liked to have while I was
trying to understand why chipset revision RT5390R wasn't working (see:
http://article.gmane.org/gmane.linux.kernel.wireless.general/89561 ).
Changes since v4:
- re-add BBP size patch (first one) in the series
- add Ivo's Acked-bys
Changes since v3:
- Don't print a debug message when register type isn't registered
Changes since v2:
- split the second patch in two to incorporate changes suggested by Ivo
van Doorn (thanks for the review!) :
- first part (second patch) is now only a small rewrite of the code to
initialize only the supported register. Any unsupported register wouldn't
have its files created.
- second patch best viewed ignoring spaces ((git) diff -w)
- third patch is effectively adding RFCSR support.
- we allocate more data for sprintf since we add a new register.
Changes since v1:
- removed initialization in chipsets other than rt2800, we now rely on
default initialization.
- added comments to make this explicit
- fix rfcsr size (64)
- fix pre-review bug thanks to Ivo Van Doorn
Anisse Astier (3):
rt2800: debugfs register access: BBP is 256 bytes big
rt2x00: debugfs support - allow a register to be empty
rt2x00: Add debugfs access for rfcsr register
drivers/net/wireless/rt2x00/rt2800.h | 4 +-
drivers/net/wireless/rt2x00/rt2800lib.c | 7 +++
drivers/net/wireless/rt2x00/rt2x00debug.c | 82 ++++++++++++++++-------------
drivers/net/wireless/rt2x00/rt2x00debug.h | 1 +
4 files changed, 57 insertions(+), 37 deletions(-)
--
1.7.9.4
We're already using BBP for values > 128. Make that explicit and allow
debugfs access.
Signed-off-by: Anisse Astier <[email protected]>
Acked-by: Ivo van Doorn <[email protected]>
---
drivers/net/wireless/rt2x00/rt2800.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/wireless/rt2x00/rt2800.h b/drivers/net/wireless/rt2x00/rt2800.h
index 1ce2634..d91f4f6 100644
--- a/drivers/net/wireless/rt2x00/rt2800.h
+++ b/drivers/net/wireless/rt2x00/rt2800.h
@@ -99,7 +99,7 @@
#define EEPROM_BASE 0x0000
#define EEPROM_SIZE 0x0110
#define BBP_BASE 0x0000
-#define BBP_SIZE 0x0080
+#define BBP_SIZE 0x00ff
#define RF_BASE 0x0004
#define RF_SIZE 0x0010
--
1.7.9.4
RFCSR is only used in rt2800. For other chipsets, the debug struct
for rfcsr should be zeroed, which isn't be an issue, since the code
can now cope with that.
Signed-off-by: Anisse Astier <[email protected]>
Acked-by: Ivo van Doorn <[email protected]>
---
drivers/net/wireless/rt2x00/rt2800.h | 2 ++
drivers/net/wireless/rt2x00/rt2800lib.c | 7 +++++++
drivers/net/wireless/rt2x00/rt2x00debug.c | 11 ++++++++++-
drivers/net/wireless/rt2x00/rt2x00debug.h | 1 +
4 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/drivers/net/wireless/rt2x00/rt2800.h b/drivers/net/wireless/rt2x00/rt2800.h
index d91f4f6..9348521 100644
--- a/drivers/net/wireless/rt2x00/rt2800.h
+++ b/drivers/net/wireless/rt2x00/rt2800.h
@@ -102,6 +102,8 @@
#define BBP_SIZE 0x00ff
#define RF_BASE 0x0004
#define RF_SIZE 0x0010
+#define RFCSR_BASE 0x0000
+#define RFCSR_SIZE 0x0040
/*
* Number of TX queues.
diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c
index bcd6cd9..1305e4e 100644
--- a/drivers/net/wireless/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/rt2x00/rt2800lib.c
@@ -823,6 +823,13 @@ const struct rt2x00debug rt2800_rt2x00debug = {
.word_size = sizeof(u32),
.word_count = RF_SIZE / sizeof(u32),
},
+ .rfcsr = {
+ .read = rt2800_rfcsr_read,
+ .write = rt2800_rfcsr_write,
+ .word_base = RFCSR_BASE,
+ .word_size = sizeof(u8),
+ .word_count = RFCSR_SIZE / sizeof(u8),
+ },
};
EXPORT_SYMBOL_GPL(rt2800_rt2x00debug);
#endif /* CONFIG_RT2X00_LIB_DEBUGFS */
diff --git a/drivers/net/wireless/rt2x00/rt2x00debug.c b/drivers/net/wireless/rt2x00/rt2x00debug.c
index 5bb1221..3bb8caf 100644
--- a/drivers/net/wireless/rt2x00/rt2x00debug.c
+++ b/drivers/net/wireless/rt2x00/rt2x00debug.c
@@ -70,6 +70,7 @@ struct rt2x00debug_intf {
* - eeprom offset/value files
* - bbp offset/value files
* - rf offset/value files
+ * - rfcsr offset/value files
* - queue folder
* - frame dump file
* - queue stats file
@@ -89,6 +90,8 @@ struct rt2x00debug_intf {
struct dentry *bbp_val_entry;
struct dentry *rf_off_entry;
struct dentry *rf_val_entry;
+ struct dentry *rfcsr_off_entry;
+ struct dentry *rfcsr_val_entry;
struct dentry *queue_folder;
struct dentry *queue_frame_dump_entry;
struct dentry *queue_stats_entry;
@@ -131,6 +134,7 @@ struct rt2x00debug_intf {
unsigned int offset_eeprom;
unsigned int offset_bbp;
unsigned int offset_rf;
+ unsigned int offset_rfcsr;
};
void rt2x00debug_update_crypto(struct rt2x00_dev *rt2x00dev,
@@ -525,6 +529,7 @@ RT2X00DEBUGFS_OPS(csr, "0x%.8x\n", u32);
RT2X00DEBUGFS_OPS(eeprom, "0x%.4x\n", u16);
RT2X00DEBUGFS_OPS(bbp, "0x%.2x\n", u8);
RT2X00DEBUGFS_OPS(rf, "0x%.8x\n", u32);
+RT2X00DEBUGFS_OPS(rfcsr, "0x%.2x\n", u8);
static ssize_t rt2x00debug_read_dev_flags(struct file *file,
char __user *buf,
@@ -614,7 +619,7 @@ static struct dentry *rt2x00debug_create_file_chipset(const char *name,
const struct rt2x00debug *debug = intf->debug;
char *data;
- data = kzalloc(8 * MAX_LINE_LENGTH, GFP_KERNEL);
+ data = kzalloc(9 * MAX_LINE_LENGTH, GFP_KERNEL);
if (!data)
return NULL;
@@ -637,6 +642,7 @@ static struct dentry *rt2x00debug_create_file_chipset(const char *name,
RT2X00DEBUGFS_SPRINTF_REGISTER(eeprom);
RT2X00DEBUGFS_SPRINTF_REGISTER(bbp);
RT2X00DEBUGFS_SPRINTF_REGISTER(rf);
+ RT2X00DEBUGFS_SPRINTF_REGISTER(rfcsr);
#undef RT2X00DEBUGFS_SPRINTF_REGISTER
blob->size = strlen(blob->data);
@@ -720,6 +726,7 @@ void rt2x00debug_register(struct rt2x00_dev *rt2x00dev)
RT2X00DEBUGFS_CREATE_REGISTER_ENTRY(intf, eeprom);
RT2X00DEBUGFS_CREATE_REGISTER_ENTRY(intf, bbp);
RT2X00DEBUGFS_CREATE_REGISTER_ENTRY(intf, rf);
+ RT2X00DEBUGFS_CREATE_REGISTER_ENTRY(intf, rfcsr);
#undef RT2X00DEBUGFS_CREATE_REGISTER_ENTRY
@@ -771,6 +778,8 @@ void rt2x00debug_deregister(struct rt2x00_dev *rt2x00dev)
debugfs_remove(intf->queue_stats_entry);
debugfs_remove(intf->queue_frame_dump_entry);
debugfs_remove(intf->queue_folder);
+ debugfs_remove(intf->rfcsr_val_entry);
+ debugfs_remove(intf->rfcsr_off_entry);
debugfs_remove(intf->rf_val_entry);
debugfs_remove(intf->rf_off_entry);
debugfs_remove(intf->bbp_val_entry);
diff --git a/drivers/net/wireless/rt2x00/rt2x00debug.h b/drivers/net/wireless/rt2x00/rt2x00debug.h
index fa11409..e11d39b 100644
--- a/drivers/net/wireless/rt2x00/rt2x00debug.h
+++ b/drivers/net/wireless/rt2x00/rt2x00debug.h
@@ -65,6 +65,7 @@ struct rt2x00debug {
RT2X00DEBUGFS_REGISTER_ENTRY(eeprom, u16);
RT2X00DEBUGFS_REGISTER_ENTRY(bbp, u8);
RT2X00DEBUGFS_REGISTER_ENTRY(rf, u32);
+ RT2X00DEBUGFS_REGISTER_ENTRY(rfcsr, u8);
};
#endif /* RT2X00DEBUG_H */
--
1.7.9.4
Allow a register to be unspecified, therefore not creating its debugfs
file entry.
Signed-off-by: Anisse Astier <[email protected]>
Acked-by: Ivo van Doorn <[email protected]>
---
drivers/net/wireless/rt2x00/rt2x00debug.c | 71 +++++++++++++++--------------
1 file changed, 36 insertions(+), 35 deletions(-)
diff --git a/drivers/net/wireless/rt2x00/rt2x00debug.c b/drivers/net/wireless/rt2x00/rt2x00debug.c
index 78787fc..5bb1221 100644
--- a/drivers/net/wireless/rt2x00/rt2x00debug.c
+++ b/drivers/net/wireless/rt2x00/rt2x00debug.c
@@ -624,22 +624,21 @@ static struct dentry *rt2x00debug_create_file_chipset(const char *name,
data += sprintf(data, "revision:\t%04x\n", intf->rt2x00dev->chip.rev);
data += sprintf(data, "\n");
data += sprintf(data, "register\tbase\twords\twordsize\n");
- data += sprintf(data, "csr\t%d\t%d\t%d\n",
- debug->csr.word_base,
- debug->csr.word_count,
- debug->csr.word_size);
- data += sprintf(data, "eeprom\t%d\t%d\t%d\n",
- debug->eeprom.word_base,
- debug->eeprom.word_count,
- debug->eeprom.word_size);
- data += sprintf(data, "bbp\t%d\t%d\t%d\n",
- debug->bbp.word_base,
- debug->bbp.word_count,
- debug->bbp.word_size);
- data += sprintf(data, "rf\t%d\t%d\t%d\n",
- debug->rf.word_base,
- debug->rf.word_count,
- debug->rf.word_size);
+#define RT2X00DEBUGFS_SPRINTF_REGISTER(__name) \
+{ \
+ if(debug->__name.read) \
+ data += sprintf(data, __stringify(__name) \
+ "\t%d\t%d\t%d\n", \
+ debug->__name.word_base, \
+ debug->__name.word_count, \
+ debug->__name.word_size); \
+}
+ RT2X00DEBUGFS_SPRINTF_REGISTER(csr);
+ RT2X00DEBUGFS_SPRINTF_REGISTER(eeprom);
+ RT2X00DEBUGFS_SPRINTF_REGISTER(bbp);
+ RT2X00DEBUGFS_SPRINTF_REGISTER(rf);
+#undef RT2X00DEBUGFS_SPRINTF_REGISTER
+
blob->size = strlen(blob->data);
return debugfs_create_blob(name, S_IRUSR, intf->driver_folder, blob);
@@ -694,25 +693,27 @@ void rt2x00debug_register(struct rt2x00_dev *rt2x00dev)
if (IS_ERR(intf->register_folder) || !intf->register_folder)
goto exit;
-#define RT2X00DEBUGFS_CREATE_REGISTER_ENTRY(__intf, __name) \
-({ \
- (__intf)->__name##_off_entry = \
- debugfs_create_u32(__stringify(__name) "_offset", \
- S_IRUSR | S_IWUSR, \
- (__intf)->register_folder, \
- &(__intf)->offset_##__name); \
- if (IS_ERR((__intf)->__name##_off_entry) \
- || !(__intf)->__name##_off_entry) \
- goto exit; \
- \
- (__intf)->__name##_val_entry = \
- debugfs_create_file(__stringify(__name) "_value", \
- S_IRUSR | S_IWUSR, \
- (__intf)->register_folder, \
- (__intf), &rt2x00debug_fop_##__name);\
- if (IS_ERR((__intf)->__name##_val_entry) \
- || !(__intf)->__name##_val_entry) \
- goto exit; \
+#define RT2X00DEBUGFS_CREATE_REGISTER_ENTRY(__intf, __name) \
+({ \
+ if(debug->__name.read) { \
+ (__intf)->__name##_off_entry = \
+ debugfs_create_u32(__stringify(__name) "_offset", \
+ S_IRUSR | S_IWUSR, \
+ (__intf)->register_folder, \
+ &(__intf)->offset_##__name); \
+ if (IS_ERR((__intf)->__name##_off_entry) \
+ || !(__intf)->__name##_off_entry) \
+ goto exit; \
+ \
+ (__intf)->__name##_val_entry = \
+ debugfs_create_file(__stringify(__name) "_value", \
+ S_IRUSR | S_IWUSR, \
+ (__intf)->register_folder, \
+ (__intf), &rt2x00debug_fop_##__name); \
+ if (IS_ERR((__intf)->__name##_val_entry) \
+ || !(__intf)->__name##_val_entry) \
+ goto exit; \
+ } \
})
RT2X00DEBUGFS_CREATE_REGISTER_ENTRY(intf, csr);
--
1.7.9.4