rt2x00: Move Move pci_dev specific access to rt2x00pci
authorIvo van Doorn <ivdoorn@gmail.com>
Sat, 28 Mar 2009 19:51:24 +0000 (20:51 +0100)
committerJohn W. Linville <linville@tuxdriver.com>
Wed, 22 Apr 2009 20:54:29 +0000 (16:54 -0400)
pci_dev->irq and pci_name(pci_dev) access should be limited
to rt2x00pci only. This is more generic and allows a rt2x00 pci
driver to be controlled as PCI device but also as platform driver
(needed for rt2800pci SoC support).

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/rt2x00/rt2400pci.c
drivers/net/wireless/rt2x00/rt2500pci.c
drivers/net/wireless/rt2x00/rt2x00.h
drivers/net/wireless/rt2x00/rt2x00pci.c
drivers/net/wireless/rt2x00/rt61pci.c
drivers/net/wireless/rt2x00/rt61pci.h

index 0f08773328c6b8f182936fbb9dc2e95f58401226..411eb9cbb4e57d6cdbb5d4a6d6b92a07048af635 100644 (file)
@@ -1361,7 +1361,7 @@ static int rt2400pci_init_eeprom(struct rt2x00_dev *rt2x00dev)
         */
        value = rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RF_TYPE);
        rt2x00pci_register_read(rt2x00dev, CSR0, &reg);
-       rt2x00_set_chip(rt2x00dev, RT2460, value, reg);
+       rt2x00_set_chip_rf(rt2x00dev, value, reg);
 
        if (!rt2x00_rf(&rt2x00dev->chip, RF2420) &&
            !rt2x00_rf(&rt2x00dev->chip, RF2421)) {
index 276a8232aaa084583a5b4b97897c4a8207b25f7b..e1be67ca23d824c3ffb58d0de1373eb982aa2113 100644 (file)
@@ -1525,7 +1525,7 @@ static int rt2500pci_init_eeprom(struct rt2x00_dev *rt2x00dev)
         */
        value = rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RF_TYPE);
        rt2x00pci_register_read(rt2x00dev, CSR0, &reg);
-       rt2x00_set_chip(rt2x00dev, RT2560, value, reg);
+       rt2x00_set_chip_rf(rt2x00dev, value, reg);
 
        if (!rt2x00_rf(&rt2x00dev->chip, RF2522) &&
            !rt2x00_rf(&rt2x00dev->chip, RF2523) &&
index 84bd6f19acb0749be1dd6200a99fbe595ca8da49..e03d69975ea4f0d264fa3ee86a24695a611233f5 100644 (file)
@@ -671,6 +671,12 @@ struct rt2x00_dev {
         */
        unsigned long flags;
 
+       /*
+        * Device information, Bus IRQ and name (PCI, SoC)
+        */
+       int irq;
+       const char *name;
+
        /*
         * Chipset identification.
         */
@@ -860,6 +866,18 @@ static inline void rt2x00_set_chip(struct rt2x00_dev *rt2x00dev,
        rt2x00dev->chip.rev = rev;
 }
 
+static inline void rt2x00_set_chip_rt(struct rt2x00_dev *rt2x00dev,
+                                     const u16 rt)
+{
+       rt2x00dev->chip.rt = rt;
+}
+
+static inline void rt2x00_set_chip_rf(struct rt2x00_dev *rt2x00dev,
+                                     const u16 rf, const u32 rev)
+{
+       rt2x00_set_chip(rt2x00dev, rt2x00dev->chip.rt, rf, rev);
+}
+
 static inline char rt2x00_rt(const struct rt2x00_chip *chipset, const u16 chip)
 {
        return (chipset->rt == chip);
index 9730b4f8fd268d029756a56de15774e224102fc9..cdd5154bd4c05faa5065d3ff286ad6cfa93bd642 100644 (file)
@@ -170,7 +170,6 @@ static void rt2x00pci_free_queue_dma(struct rt2x00_dev *rt2x00dev,
 
 int rt2x00pci_initialize(struct rt2x00_dev *rt2x00dev)
 {
-       struct pci_dev *pci_dev = to_pci_dev(rt2x00dev->dev);
        struct data_queue *queue;
        int status;
 
@@ -186,11 +185,11 @@ int rt2x00pci_initialize(struct rt2x00_dev *rt2x00dev)
        /*
         * Register interrupt handler.
         */
-       status = request_irq(pci_dev->irq, rt2x00dev->ops->lib->irq_handler,
-                            IRQF_SHARED, pci_name(pci_dev), rt2x00dev);
+       status = request_irq(rt2x00dev->irq, rt2x00dev->ops->lib->irq_handler,
+                            IRQF_SHARED, rt2x00dev->name, rt2x00dev);
        if (status) {
                ERROR(rt2x00dev, "IRQ %d allocation failed (error %d).\n",
-                     pci_dev->irq, status);
+                     rt2x00dev->irq, status);
                goto exit;
        }
 
@@ -270,6 +269,7 @@ int rt2x00pci_probe(struct pci_dev *pci_dev, const struct pci_device_id *id)
        struct ieee80211_hw *hw;
        struct rt2x00_dev *rt2x00dev;
        int retval;
+       u16 chip;
 
        retval = pci_request_regions(pci_dev, pci_name(pci_dev));
        if (retval) {
@@ -307,6 +307,14 @@ int rt2x00pci_probe(struct pci_dev *pci_dev, const struct pci_device_id *id)
        rt2x00dev->dev = &pci_dev->dev;
        rt2x00dev->ops = ops;
        rt2x00dev->hw = hw;
+       rt2x00dev->irq = pci_dev->irq;
+       rt2x00dev->name = pci_name(pci_dev);
+
+       /*
+        * Determine RT chipset by reading PCI header.
+        */
+       pci_read_config_word(pci_dev, PCI_DEVICE_ID, &chip);
+       rt2x00_set_chip_rt(rt2x00dev, chip);
 
        retval = rt2x00pci_alloc_reg(rt2x00dev);
        if (retval)
index 2ca8b7a9722c96f8dfd6b7ad0689d1738d143145..4346cd1494bc701803e0988a98bdb8ddc3c4e38b 100644 (file)
@@ -2308,7 +2308,6 @@ static int rt61pci_init_eeprom(struct rt2x00_dev *rt2x00dev)
        u32 reg;
        u16 value;
        u16 eeprom;
-       u16 device;
 
        /*
         * Read EEPROM word for configuration.
@@ -2317,14 +2316,10 @@ static int rt61pci_init_eeprom(struct rt2x00_dev *rt2x00dev)
 
        /*
         * Identify RF chipset.
-        * To determine the RT chip we have to read the
-        * PCI header of the device.
         */
-       pci_read_config_word(to_pci_dev(rt2x00dev->dev),
-                            PCI_CONFIG_HEADER_DEVICE, &device);
        value = rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RF_TYPE);
        rt2x00pci_register_read(rt2x00dev, MAC_CSR0, &reg);
-       rt2x00_set_chip(rt2x00dev, device, value, reg);
+       rt2x00_set_chip_rf(rt2x00dev, value, reg);
 
        if (!rt2x00_rf(&rt2x00dev->chip, RF5225) &&
            !rt2x00_rf(&rt2x00dev->chip, RF5325) &&
index 41e8959919f6dd897dc49133ab51027e9f0192f6..6c71f77c8165803b90033e77addde041367c9fee 100644 (file)
  * PCI registers.
  */
 
-/*
- * PCI Configuration Header
- */
-#define PCI_CONFIG_HEADER_VENDOR       0x0000
-#define PCI_CONFIG_HEADER_DEVICE       0x0002
-
 /*
  * HOST_CMD_CSR: For HOST to interrupt embedded processor
  */