-#define RT2X00DEBUGFS_OPS_READ(__name) \
- static ssize_t rt2x00debug_read_##__name(struct file *file, \
- char __user *buf, size_t length, loff_t *offset) \
- { \
- struct rt2x00debug_intf *intf = file->private_data; \
- const struct rt2x00debug *debug = intf->debug; \
- const struct rt2x00debug_reg *reg = &debug->reg_##__name;\
- \
- if (intf->offset_##__name > reg->word_count) \
- return -EINVAL; \
- \
- return rt2x00debug_file_read(intf->rt2x00dev, buf, \
- offset, intf->offset_##__name, reg); \
- }
-
-RT2X00DEBUGFS_OPS_READ(csr);
-RT2X00DEBUGFS_OPS_READ(eeprom);
-RT2X00DEBUGFS_OPS_READ(bbp);
-
-#define RT2X00DEBUGFS_OPS_WRITE(__name) \
- static ssize_t rt2x00debug_write_##__name(struct file *file, \
- const char __user *buf, size_t length, loff_t *offset) \
- { \
- struct rt2x00debug_intf *intf = file->private_data; \
- const struct rt2x00debug *debug = intf->debug; \
- const struct rt2x00debug_reg *reg = &debug->reg_##__name;\
- \
- if (intf->offset_##__name > reg->word_count) \
- return -EINVAL; \
- \
- return rt2x00debug_file_write(intf->rt2x00dev, buf, \
- offset, intf->offset_##__name, length, reg); \
- }
-
-RT2X00DEBUGFS_OPS_WRITE(csr);
-RT2X00DEBUGFS_OPS_WRITE(eeprom);
-RT2X00DEBUGFS_OPS_WRITE(bbp);
-
-#define RT2X00DEBUGFS_OPS(__name) \
- static const struct file_operations rt2x00debug_fop_##__name = {\
- .owner = THIS_MODULE, \
- .read = rt2x00debug_read_##__name, \
- .write = rt2x00debug_write_##__name, \
- .open = rt2x00debug_file_open, \
- .release = rt2x00debug_file_release, \
- };
-
-RT2X00DEBUGFS_OPS(csr);
-RT2X00DEBUGFS_OPS(eeprom);
-RT2X00DEBUGFS_OPS(bbp);