rt2x00: Move Move pci_dev specific access to rt2x00pci
PATCH 1/4 rt2x00: Move Move pci_dev specific access to rt2x00pci
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).
--- drivers/net/wireless/rt2x00/rt2400pci.c | 2 +- drivers/net/wireless/rt2x00/rt2500pci.c | 2 +- drivers/net/wireless/rt2x00/rt2x00.h | 18 ++++++++++++++++++ drivers/net/wireless/rt2x00/rt2x00pci.c | 16 ++++++++++++---- drivers/net/wireless/rt2x00/rt61pci.c | 7 +------ drivers/net/wireless/rt2x00/rt61pci.h | 6 ------ 6 files changed, 33 insertions(+), 18 deletions(-)
drivers/net/wireless/rt2x00/rt2400pci.c +1 -1
@@ -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 , ®); -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 )) {
drivers/net/wireless/rt2x00/rt2500pci.c +1 -1
@@ -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 , ®); -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) &&
drivers/net/wireless/rt2x00/rt2x00.h +18 -0
@@ -672,6 +672,12 @@ struct rt2x00_dev {unsigned long flags;/* +* Device information, Bus IRQ and name (PCI, SoC) +*/ +int irq; +const char *name; + +/* * Chipset identification. */ struct rt2x00_chip chip;
@@ -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);
drivers/net/wireless/rt2x00/rt2x00pci.c +12 -4
@@ -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)
drivers/net/wireless/rt2x00/rt61pci.c +1 -6
@@ -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 , ®); -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) &&
drivers/net/wireless/rt2x00/rt61pci.h +0 -6
@@ -63,12 +63,6 @@*/ /* -* PCI Configuration Header -*/ -#define PCI_CONFIG_HEADER_VENDOR 0x0000 -#define PCI_CONFIG_HEADER_DEVICE 0x0002 - -/* * HOST_CMD_CSR: For HOST to interrupt embedded processor */ #define HOST_CMD_CSR 0x0008
Signature · 1 line
1.5.6.1
PATCH 2/4 rt2x00: Fix Sparse warning
rt2x00link_reset_qual() is not declared in a header, and is only internally used within rt2x00link.c. It should be declared as static.
--- drivers/net/wireless/rt2x00/rt2x00link.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/net/wireless/rt2x00/rt2x00link.c +1 -1
@@ -387,7 +387,7 @@ void rt2x00link_reset_tuner(struct rt2x00_dev *rt2x00dev, bool antenna)rt2x00link_antenna_reset (rt2x00dev); } -void rt2x00link_reset_qual (struct rt2x00_dev *rt2x00dev) +static void rt2x00link_reset_qual (struct rt2x00_dev *rt2x00dev) {struct link_qual *qual = &rt2x00dev->link.qual;
Signature · 1 line
1.5.6.1
PATCH 3/4 rt2x00: Don't free register information on suspend
After suspend & resume the rt2x00 devices won't wakeup anymore due to a broken register information setup. The most important problem is the release of the EEPROM buffer which is completely cleared and never read again after the suspend.
--- drivers/net/wireless/rt2x00/rt2x00pci.c | 18 +----------------- drivers/net/wireless/rt2x00/rt2x00usb.c | 18 +----------------- 2 files changed, 2 insertions(+), 34 deletions(-)
drivers/net/wireless/rt2x00/rt2x00pci.c +1 -17
@@ -377,8 +377,6 @@ int rt2x00pci_suspend(struct pci_dev *pci_dev, pm_message_t state)if (retval)return retval; -rt2x00pci_free_reg (rt2x00dev); -pci_save_state (pci_dev);pci_disable_device (pci_dev);return pci_set_power_state (pci_dev,pci_choose_state (pci_dev, state));
@@ -389,7 +387,6 @@ int rt2x00pci_resume(struct pci_dev *pci_dev) {struct ieee80211_hw *hw =pci_get_drvdata (pci_dev);struct rt2x00_dev *rt2x00dev = hw->priv; -int retval; if (pci_set_power_state(pci_dev, PCI_D0) || pci_enable_device(pci_dev) ||
@@ -398,20 +395,7 @@ int rt2x00pci_resume(struct pci_dev *pci_dev) return -EIO; } - retval =rt2x00pci_alloc_reg (rt2x00dev); -if (retval) -return retval; - - retval =rt2x00lib_resume (rt2x00dev); -if (retval) - goto exit_free_reg; - -return 0 ; - -exit_free_reg: -rt2x00pci_free_reg (rt2x00dev); - -return retval; +return rt2x00lib_resume (rt2x00dev); }EXPORT_SYMBOL_GPL (rt2x00pci_resume);#endif /* CONFIG_PM */
drivers/net/wireless/rt2x00/rt2x00usb.c +1 -17
@@ -702,8 +702,6 @@ int rt2x00usb_suspend(struct usb_interface *usb_intf, pm_message_t state)if (retval)return retval; -rt2x00usb_free_reg (rt2x00dev); -/* * Decrease usbdev refcount. */
@@ -717,24 +715,10 @@ int rt2x00usb_resume(struct usb_interface *usb_intf) {struct ieee80211_hw *hw =usb_get_intfdata (usb_intf);struct rt2x00_dev *rt2x00dev = hw->priv; -int retval;usb_get_dev (interface_to_usbdev (usb_intf)); - retval =rt2x00usb_alloc_reg (rt2x00dev); -if (retval) -return retval; - - retval =rt2x00lib_resume (rt2x00dev); -if (retval) - goto exit_free_reg; - -return 0 ; - -exit_free_reg: -rt2x00usb_free_reg (rt2x00dev); - -return retval; +return rt2x00lib_resume (rt2x00dev); }EXPORT_SYMBOL_GPL (rt2x00usb_resume);#endif /* CONFIG_PM */
Signature · 1 line
1.5.6.1
PATCH 4/4 rt2x00: Add rt73usb USB IDs
--- drivers/net/wireless/rt2x00/rt73usb.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
drivers/net/wireless/rt2x00/rt73usb.c +2 -0
@@ -2369,6 +2369,8 @@ static struct usb_device_id rt73usb_device_table[] = {/* Buffalo */ { USB_DEVICE(0x0411, 0x00d8), USB_DEVICE_DATA(&rt73usb_ops) }, { USB_DEVICE(0x0411, 0x00f4), USB_DEVICE_DATA(&rt73usb_ops) }, + { USB_DEVICE(0x0411, 0x0116), USB_DEVICE_DATA(&rt73usb_ops) }, + { USB_DEVICE(0x0411, 0x0119), USB_DEVICE_DATA(&rt73usb_ops) },/* CNet */ { USB_DEVICE(0x1371, 0x9022), USB_DEVICE_DATA(&rt73usb_ops) }, { USB_DEVICE(0x1371, 0x9032), USB_DEVICE_DATA(&rt73usb_ops) },
Signature · 1 line
1.5.6.1
Re: [PATCH 3/4] rt2x00: Don't free register information on suspend
In reply to Ivo van DoornHi John,
Quoted 5 lines · Ivo van Doorn
After suspend & resume the rt2x00 devices won't wakeup anymore due to a broken register information setup. The most important problem is the release of the EEPROM buffer which is completely cleared and never read again after the suspend.
Since this fixes suspend & resume for rt2x00 (this was a regression from 2.6.27 or 2.6.28, the code was actually broken in 2.6.29 as well), could this perhaps be added to the queue for 2.6.30 as well?
Thanks,
Ivo
Quoted 88 lines
Signed-off-by Ivo van Doorn <[email protected]>--- drivers/net/wireless/rt2x00/rt2x00pci.c | 18 +----------------- drivers/net/wireless/rt2x00/rt2x00usb.c | 18 +----------------- 2 files changed, 2 insertions(+), 34 deletions(-)drivers/net/wireless/rt2x00/rt2x00pci.c +1
-17@@ -377,8 +377,6 @@ int rt2x00pci_suspend(struct pci_dev *pci_dev, pm_message_t state)if (retval)return retval; -rt2x00pci_free_reg (rt2x00dev); -pci_save_state (pci_dev);pci_disable_device (pci_dev);return pci_set_power_state (pci_dev,pci_choose_state (pci_dev, state));@@ -389,7 +387,6 @@ int rt2x00pci_resume(struct pci_dev *pci_dev) {struct ieee80211_hw *hw =pci_get_drvdata (pci_dev);struct rt2x00_dev *rt2x00dev = hw->priv; -int retval; if (pci_set_power_state(pci_dev, PCI_D0) || pci_enable_device(pci_dev) ||@@ -398,20 +395,7 @@ int rt2x00pci_resume(struct pci_dev *pci_dev) return -EIO; } - retval =rt2x00pci_alloc_reg (rt2x00dev); -if (retval) -return retval; - - retval =rt2x00lib_resume (rt2x00dev); -if (retval) - goto exit_free_reg; - -return 0 ; - -exit_free_reg: -rt2x00pci_free_reg (rt2x00dev); - -return retval; +return rt2x00lib_resume (rt2x00dev); }EXPORT_SYMBOL_GPL (rt2x00pci_resume);#endif /* CONFIG_PM */ drivers/net/wireless/rt2x00/rt2x00usb.c +1
-17@@ -702,8 +702,6 @@ int rt2x00usb_suspend(struct usb_interface *usb_intf, pm_message_t state)if (retval)return retval; -rt2x00usb_free_reg (rt2x00dev); -/* * Decrease usbdev refcount. */ @@ -717,24 +715,10 @@ int rt2x00usb_resume(struct usb_interface *usb_intf) {struct ieee80211_hw *hw =usb_get_intfdata (usb_intf);struct rt2x00_dev *rt2x00dev = hw->priv; -int retval;usb_get_dev (interface_to_usbdev (usb_intf)); - retval =rt2x00usb_alloc_reg (rt2x00dev); -if (retval) -return retval; - - retval =rt2x00lib_resume (rt2x00dev); -if (retval) - goto exit_free_reg; - -return 0 ; - -exit_free_reg: -rt2x00usb_free_reg (rt2x00dev); - -return retval; +return rt2x00lib_resume (rt2x00dev); }EXPORT_SYMBOL_GPL (rt2x00usb_resume);#endif /* CONFIG_PM */