300-rt2x00-Move-Move-pci_dev-specific-access-to-rt2x00p.patch 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. From 313314263fda19db8eed94a7d7259b595634212e Mon Sep 17 00:00:00 2001
  2. From: Ivo van Doorn <[email protected]>
  3. Date: Sat, 14 Mar 2009 20:02:51 +0100
  4. Subject: [PATCH] rt2x00: Move Move pci_dev specific access to rt2x00pci
  5. pci_dev->irq and pci_name(pci_dev) access should be limited
  6. to rt2x00pci only. This is more generic and allows a rt2x00 pci
  7. driver to be controlled as PCI device but also as platform driver
  8. (needed for rt2800pci SoC support).
  9. Signed-off-by: Felix Fietkau <[email protected]>
  10. Signed-off-by: Ivo van Doorn <[email protected]>
  11. ---
  12. drivers/net/wireless/rt2x00/rt2400pci.c | 2 +-
  13. drivers/net/wireless/rt2x00/rt2500pci.c | 2 +-
  14. drivers/net/wireless/rt2x00/rt2x00.h | 18 ++++++++++++++++++
  15. drivers/net/wireless/rt2x00/rt2x00pci.c | 16 ++++++++++++----
  16. drivers/net/wireless/rt2x00/rt61pci.c | 7 +------
  17. 5 files changed, 33 insertions(+), 12 deletions(-)
  18. --- a/drivers/net/wireless/rt2x00/rt2400pci.c
  19. +++ b/drivers/net/wireless/rt2x00/rt2400pci.c
  20. @@ -1361,7 +1361,7 @@ static int rt2400pci_init_eeprom(struct
  21. */
  22. value = rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RF_TYPE);
  23. rt2x00pci_register_read(rt2x00dev, CSR0, &reg);
  24. - rt2x00_set_chip(rt2x00dev, RT2460, value, reg);
  25. + rt2x00_set_chip_rf(rt2x00dev, value, reg);
  26. if (!rt2x00_rf(&rt2x00dev->chip, RF2420) &&
  27. !rt2x00_rf(&rt2x00dev->chip, RF2421)) {
  28. --- a/drivers/net/wireless/rt2x00/rt2500pci.c
  29. +++ b/drivers/net/wireless/rt2x00/rt2500pci.c
  30. @@ -1525,7 +1525,7 @@ static int rt2500pci_init_eeprom(struct
  31. */
  32. value = rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RF_TYPE);
  33. rt2x00pci_register_read(rt2x00dev, CSR0, &reg);
  34. - rt2x00_set_chip(rt2x00dev, RT2560, value, reg);
  35. + rt2x00_set_chip_rf(rt2x00dev, value, reg);
  36. if (!rt2x00_rf(&rt2x00dev->chip, RF2522) &&
  37. !rt2x00_rf(&rt2x00dev->chip, RF2523) &&
  38. --- a/drivers/net/wireless/rt2x00/rt2x00.h
  39. +++ b/drivers/net/wireless/rt2x00/rt2x00.h
  40. @@ -672,6 +672,12 @@ struct rt2x00_dev {
  41. unsigned long flags;
  42. /*
  43. + * Device information, Bus IRQ and name (PCI, SoC)
  44. + */
  45. + int irq;
  46. + const char *name;
  47. +
  48. + /*
  49. * Chipset identification.
  50. */
  51. struct rt2x00_chip chip;
  52. @@ -860,6 +866,18 @@ static inline void rt2x00_set_chip(struc
  53. rt2x00dev->chip.rev = rev;
  54. }
  55. +static inline void rt2x00_set_chip_rt(struct rt2x00_dev *rt2x00dev,
  56. + const u16 rt)
  57. +{
  58. + rt2x00dev->chip.rt = rt;
  59. +}
  60. +
  61. +static inline void rt2x00_set_chip_rf(struct rt2x00_dev *rt2x00dev,
  62. + const u16 rf, const u32 rev)
  63. +{
  64. + rt2x00_set_chip(rt2x00dev, rt2x00dev->chip.rt, rf, rev);
  65. +}
  66. +
  67. static inline char rt2x00_rt(const struct rt2x00_chip *chipset, const u16 chip)
  68. {
  69. return (chipset->rt == chip);
  70. --- a/drivers/net/wireless/rt2x00/rt2x00pci.c
  71. +++ b/drivers/net/wireless/rt2x00/rt2x00pci.c
  72. @@ -170,7 +170,6 @@ static void rt2x00pci_free_queue_dma(str
  73. int rt2x00pci_initialize(struct rt2x00_dev *rt2x00dev)
  74. {
  75. - struct pci_dev *pci_dev = to_pci_dev(rt2x00dev->dev);
  76. struct data_queue *queue;
  77. int status;
  78. @@ -186,11 +185,11 @@ int rt2x00pci_initialize(struct rt2x00_d
  79. /*
  80. * Register interrupt handler.
  81. */
  82. - status = request_irq(pci_dev->irq, rt2x00dev->ops->lib->irq_handler,
  83. - IRQF_SHARED, pci_name(pci_dev), rt2x00dev);
  84. + status = request_irq(rt2x00dev->irq, rt2x00dev->ops->lib->irq_handler,
  85. + IRQF_SHARED, rt2x00dev->name, rt2x00dev);
  86. if (status) {
  87. ERROR(rt2x00dev, "IRQ %d allocation failed (error %d).\n",
  88. - pci_dev->irq, status);
  89. + rt2x00dev->irq, status);
  90. goto exit;
  91. }
  92. @@ -270,6 +269,7 @@ int rt2x00pci_probe(struct pci_dev *pci_
  93. struct ieee80211_hw *hw;
  94. struct rt2x00_dev *rt2x00dev;
  95. int retval;
  96. + u16 chip;
  97. retval = pci_request_regions(pci_dev, pci_name(pci_dev));
  98. if (retval) {
  99. @@ -307,6 +307,14 @@ int rt2x00pci_probe(struct pci_dev *pci_
  100. rt2x00dev->dev = &pci_dev->dev;
  101. rt2x00dev->ops = ops;
  102. rt2x00dev->hw = hw;
  103. + rt2x00dev->irq = pci_dev->irq;
  104. + rt2x00dev->name = pci_name(pci_dev);
  105. +
  106. + /*
  107. + * Determine RT chipset by reading PCI header.
  108. + */
  109. + pci_read_config_word(pci_dev, PCI_DEVICE_ID, &chip);
  110. + rt2x00_set_chip_rt(rt2x00dev, chip);
  111. retval = rt2x00pci_alloc_reg(rt2x00dev);
  112. if (retval)
  113. --- a/drivers/net/wireless/rt2x00/rt61pci.c
  114. +++ b/drivers/net/wireless/rt2x00/rt61pci.c
  115. @@ -2308,7 +2308,6 @@ static int rt61pci_init_eeprom(struct rt
  116. u32 reg;
  117. u16 value;
  118. u16 eeprom;
  119. - u16 device;
  120. /*
  121. * Read EEPROM word for configuration.
  122. @@ -2317,14 +2316,10 @@ static int rt61pci_init_eeprom(struct rt
  123. /*
  124. * Identify RF chipset.
  125. - * To determine the RT chip we have to read the
  126. - * PCI header of the device.
  127. */
  128. - pci_read_config_word(to_pci_dev(rt2x00dev->dev),
  129. - PCI_CONFIG_HEADER_DEVICE, &device);
  130. value = rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RF_TYPE);
  131. rt2x00pci_register_read(rt2x00dev, MAC_CSR0, &reg);
  132. - rt2x00_set_chip(rt2x00dev, device, value, reg);
  133. + rt2x00_set_chip_rf(rt2x00dev, value, reg);
  134. if (!rt2x00_rf(&rt2x00dev->chip, RF5225) &&
  135. !rt2x00_rf(&rt2x00dev->chip, RF5325) &&