rt2x00: Move driver callback functions into the ops structure
authorIvo van Doorn <ivdoorn@gmail.com>
Sun, 11 Jul 2010 10:31:23 +0000 (12:31 +0200)
committerJohn W. Linville <linville@tuxdriver.com>
Mon, 12 Jul 2010 20:05:37 +0000 (16:05 -0400)
All callback functions are gathered in rt2x00dev->ops except
for the callback functions which are used in rt2800lib to
acces rt2800pci/usb.

Move the priv pointer from rt2x00dev to rt2x00dev->ops and
rename it to drv to make it obvious that it is the driver callback
structure.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/rt2x00/rt2800lib.h
drivers/net/wireless/rt2x00/rt2800pci.c
drivers/net/wireless/rt2x00/rt2800usb.c
drivers/net/wireless/rt2x00/rt2x00.h

index cecbd3abc35bb30f5b1b0c842c7255d3656cb25b..091641e3c5e2ec95eb4d89449490f7b45c41d18d 100644 (file)
@@ -50,7 +50,7 @@ static inline void rt2800_register_read(struct rt2x00_dev *rt2x00dev,
                                        const unsigned int offset,
                                        u32 *value)
 {
-       const struct rt2800_ops *rt2800ops = rt2x00dev->priv;
+       const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
 
        rt2800ops->register_read(rt2x00dev, offset, value);
 }
@@ -59,7 +59,7 @@ static inline void rt2800_register_read_lock(struct rt2x00_dev *rt2x00dev,
                                             const unsigned int offset,
                                             u32 *value)
 {
-       const struct rt2800_ops *rt2800ops = rt2x00dev->priv;
+       const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
 
        rt2800ops->register_read_lock(rt2x00dev, offset, value);
 }
@@ -68,7 +68,7 @@ static inline void rt2800_register_write(struct rt2x00_dev *rt2x00dev,
                                         const unsigned int offset,
                                         u32 value)
 {
-       const struct rt2800_ops *rt2800ops = rt2x00dev->priv;
+       const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
 
        rt2800ops->register_write(rt2x00dev, offset, value);
 }
@@ -77,7 +77,7 @@ static inline void rt2800_register_write_lock(struct rt2x00_dev *rt2x00dev,
                                              const unsigned int offset,
                                              u32 value)
 {
-       const struct rt2800_ops *rt2800ops = rt2x00dev->priv;
+       const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
 
        rt2800ops->register_write_lock(rt2x00dev, offset, value);
 }
@@ -86,7 +86,7 @@ static inline void rt2800_register_multiread(struct rt2x00_dev *rt2x00dev,
                                             const unsigned int offset,
                                             void *value, const u32 length)
 {
-       const struct rt2800_ops *rt2800ops = rt2x00dev->priv;
+       const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
 
        rt2800ops->register_multiread(rt2x00dev, offset, value, length);
 }
@@ -96,7 +96,7 @@ static inline void rt2800_register_multiwrite(struct rt2x00_dev *rt2x00dev,
                                              const void *value,
                                              const u32 length)
 {
-       const struct rt2800_ops *rt2800ops = rt2x00dev->priv;
+       const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
 
        rt2800ops->register_multiwrite(rt2x00dev, offset, value, length);
 }
@@ -106,7 +106,7 @@ static inline int rt2800_regbusy_read(struct rt2x00_dev *rt2x00dev,
                                      const struct rt2x00_field32 field,
                                      u32 *reg)
 {
-       const struct rt2800_ops *rt2800ops = rt2x00dev->priv;
+       const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
 
        return rt2800ops->regbusy_read(rt2x00dev, offset, field, reg);
 }
@@ -114,14 +114,14 @@ static inline int rt2800_regbusy_read(struct rt2x00_dev *rt2x00dev,
 static inline int rt2800_drv_write_firmware(struct rt2x00_dev *rt2x00dev,
                                            const u8 *data, const size_t len)
 {
-       const struct rt2800_ops *rt2800ops = rt2x00dev->priv;
+       const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
 
        return rt2800ops->drv_write_firmware(rt2x00dev, data, len);
 }
 
 static inline int rt2800_drv_init_registers(struct rt2x00_dev *rt2x00dev)
 {
-       const struct rt2800_ops *rt2800ops = rt2x00dev->priv;
+       const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
 
        return rt2800ops->drv_init_registers(rt2x00dev);
 }
index 0fdd58b9dece6fce0a9da819401ef7167eaba2ba..39b3846fa340a83704a69d8a252bb7a6d6fa87b5 100644 (file)
@@ -926,27 +926,10 @@ static int rt2800pci_validate_eeprom(struct rt2x00_dev *rt2x00dev)
        return rt2800_validate_eeprom(rt2x00dev);
 }
 
-static const struct rt2800_ops rt2800pci_rt2800_ops = {
-       .register_read          = rt2x00pci_register_read,
-       .register_read_lock     = rt2x00pci_register_read, /* same for PCI */
-       .register_write         = rt2x00pci_register_write,
-       .register_write_lock    = rt2x00pci_register_write, /* same for PCI */
-
-       .register_multiread     = rt2x00pci_register_multiread,
-       .register_multiwrite    = rt2x00pci_register_multiwrite,
-
-       .regbusy_read           = rt2x00pci_regbusy_read,
-
-       .drv_write_firmware     = rt2800pci_write_firmware,
-       .drv_init_registers     = rt2800pci_init_registers,
-};
-
 static int rt2800pci_probe_hw(struct rt2x00_dev *rt2x00dev)
 {
        int retval;
 
-       rt2x00dev->priv = (void *)&rt2800pci_rt2800_ops;
-
        /*
         * Allocate eeprom data.
         */
@@ -1018,6 +1001,18 @@ static const struct ieee80211_ops rt2800pci_mac80211_ops = {
        .ampdu_action           = rt2800_ampdu_action,
 };
 
+static const struct rt2800_ops rt2800pci_rt2800_ops = {
+       .register_read          = rt2x00pci_register_read,
+       .register_read_lock     = rt2x00pci_register_read, /* same for PCI */
+       .register_write         = rt2x00pci_register_write,
+       .register_write_lock    = rt2x00pci_register_write, /* same for PCI */
+       .register_multiread     = rt2x00pci_register_multiread,
+       .register_multiwrite    = rt2x00pci_register_multiwrite,
+       .regbusy_read           = rt2x00pci_regbusy_read,
+       .drv_write_firmware     = rt2800pci_write_firmware,
+       .drv_init_registers     = rt2800pci_init_registers,
+};
+
 static const struct rt2x00lib_ops rt2800pci_rt2x00_ops = {
        .irq_handler            = rt2800pci_interrupt,
        .irq_handler_thread     = rt2800pci_interrupt_thread,
@@ -1082,6 +1077,7 @@ static const struct rt2x00_ops rt2800pci_ops = {
        .tx                     = &rt2800pci_queue_tx,
        .bcn                    = &rt2800pci_queue_bcn,
        .lib                    = &rt2800pci_rt2x00_ops,
+       .drv                    = &rt2800pci_rt2800_ops,
        .hw                     = &rt2800pci_mac80211_ops,
 #ifdef CONFIG_RT2X00_LIB_DEBUGFS
        .debugfs                = &rt2800_rt2x00debug,
index 7b8d51f580380e50bf72e0895abc34a39427391b..5a2dfe87c6b61b5f48ec9d55ad95fea5208ab4ca 100644 (file)
@@ -470,27 +470,10 @@ static int rt2800usb_validate_eeprom(struct rt2x00_dev *rt2x00dev)
        return rt2800_validate_eeprom(rt2x00dev);
 }
 
-static const struct rt2800_ops rt2800usb_rt2800_ops = {
-       .register_read          = rt2x00usb_register_read,
-       .register_read_lock     = rt2x00usb_register_read_lock,
-       .register_write         = rt2x00usb_register_write,
-       .register_write_lock    = rt2x00usb_register_write_lock,
-
-       .register_multiread     = rt2x00usb_register_multiread,
-       .register_multiwrite    = rt2x00usb_register_multiwrite,
-
-       .regbusy_read           = rt2x00usb_regbusy_read,
-
-       .drv_write_firmware     = rt2800usb_write_firmware,
-       .drv_init_registers     = rt2800usb_init_registers,
-};
-
 static int rt2800usb_probe_hw(struct rt2x00_dev *rt2x00dev)
 {
        int retval;
 
-       rt2x00dev->priv = (void *)&rt2800usb_rt2800_ops;
-
        /*
         * Allocate eeprom data.
         */
@@ -556,6 +539,18 @@ static const struct ieee80211_ops rt2800usb_mac80211_ops = {
        .ampdu_action           = rt2800_ampdu_action,
 };
 
+static const struct rt2800_ops rt2800usb_rt2800_ops = {
+       .register_read          = rt2x00usb_register_read,
+       .register_read_lock     = rt2x00usb_register_read_lock,
+       .register_write         = rt2x00usb_register_write,
+       .register_write_lock    = rt2x00usb_register_write_lock,
+       .register_multiread     = rt2x00usb_register_multiread,
+       .register_multiwrite    = rt2x00usb_register_multiwrite,
+       .regbusy_read           = rt2x00usb_regbusy_read,
+       .drv_write_firmware     = rt2800usb_write_firmware,
+       .drv_init_registers     = rt2800usb_init_registers,
+};
+
 static const struct rt2x00lib_ops rt2800usb_rt2x00_ops = {
        .probe_hw               = rt2800usb_probe_hw,
        .get_firmware_name      = rt2800usb_get_firmware_name,
@@ -619,6 +614,7 @@ static const struct rt2x00_ops rt2800usb_ops = {
        .tx                     = &rt2800usb_queue_tx,
        .bcn                    = &rt2800usb_queue_bcn,
        .lib                    = &rt2800usb_rt2x00_ops,
+       .drv                    = &rt2800usb_rt2800_ops,
        .hw                     = &rt2800usb_mac80211_ops,
 #ifdef CONFIG_RT2X00_LIB_DEBUGFS
        .debugfs                = &rt2800_rt2x00debug,
index 9dd0d171abf13d683279982ae1221816803a7332..c21af38cc5af57364694c8bc46e19867e2c8150d 100644 (file)
@@ -621,6 +621,7 @@ struct rt2x00_ops {
        const struct data_queue_desc *bcn;
        const struct data_queue_desc *atim;
        const struct rt2x00lib_ops *lib;
+       const void *drv;
        const struct ieee80211_ops *hw;
 #ifdef CONFIG_RT2X00_LIB_DEBUGFS
        const struct rt2x00debug *debugfs;
@@ -881,11 +882,6 @@ struct rt2x00_dev {
         * and interrupt thread routine.
         */
        u32 irqvalue[2];
-
-       /*
-        * Driver specific data.
-        */
-       void *priv;
 };
 
 /*