diff options
author | Gertjan van Wingerde <gwingerde@kpnplanet.nl> | 2008-06-16 13:55:43 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2008-06-26 16:49:15 -0400 |
commit | 14a3bf89212b5c758bd39bb4afc972c4ba6d599f (patch) | |
tree | 8ea03c6d2c69a0875c69fd13b4ecd772456cf710 /drivers/net | |
parent | c95edf5432f097c926dd3f59239ecde80da3b214 (diff) |
rt2x00: Convert rt2x00 to use generic DMA-mapping API
At the same time clean up the device administration a bit, by storing a pointer
to struct device instead of a void pointer that is dependent on the type of
device. The normal PCI and USB subsystem provided macros can be used to convert
the device pointer to the right type.
This makes the rt2x00 driver a bit more type-safe.
Signed-off-by: Gertjan van Wingerde <gwingerde@kpnplanet.nl>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/wireless/rt2x00/rt2400pci.c | 2 | ||||
-rw-r--r-- | drivers/net/wireless/rt2x00/rt2500pci.c | 2 | ||||
-rw-r--r-- | drivers/net/wireless/rt2x00/rt2500usb.c | 5 | ||||
-rw-r--r-- | drivers/net/wireless/rt2x00/rt2x00.h | 6 | ||||
-rw-r--r-- | drivers/net/wireless/rt2x00/rt2x00pci.c | 19 | ||||
-rw-r--r-- | drivers/net/wireless/rt2x00/rt2x00usb.c | 11 | ||||
-rw-r--r-- | drivers/net/wireless/rt2x00/rt61pci.c | 4 | ||||
-rw-r--r-- | drivers/net/wireless/rt2x00/rt73usb.c | 2 |
8 files changed, 25 insertions, 26 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2400pci.c b/drivers/net/wireless/rt2x00/rt2400pci.c index bb3d83560d02..76ec1514fa44 100644 --- a/drivers/net/wireless/rt2x00/rt2400pci.c +++ b/drivers/net/wireless/rt2x00/rt2400pci.c | |||
@@ -1366,7 +1366,7 @@ static void rt2400pci_probe_hw_mode(struct rt2x00_dev *rt2x00dev) | |||
1366 | IEEE80211_HW_SIGNAL_DBM; | 1366 | IEEE80211_HW_SIGNAL_DBM; |
1367 | rt2x00dev->hw->extra_tx_headroom = 0; | 1367 | rt2x00dev->hw->extra_tx_headroom = 0; |
1368 | 1368 | ||
1369 | SET_IEEE80211_DEV(rt2x00dev->hw, &rt2x00dev_pci(rt2x00dev)->dev); | 1369 | SET_IEEE80211_DEV(rt2x00dev->hw, rt2x00dev->dev); |
1370 | SET_IEEE80211_PERM_ADDR(rt2x00dev->hw, | 1370 | SET_IEEE80211_PERM_ADDR(rt2x00dev->hw, |
1371 | rt2x00_eeprom_addr(rt2x00dev, | 1371 | rt2x00_eeprom_addr(rt2x00dev, |
1372 | EEPROM_MAC_ADDR_0)); | 1372 | EEPROM_MAC_ADDR_0)); |
diff --git a/drivers/net/wireless/rt2x00/rt2500pci.c b/drivers/net/wireless/rt2x00/rt2500pci.c index 3c956b91c4e3..5f0117f9a88b 100644 --- a/drivers/net/wireless/rt2x00/rt2500pci.c +++ b/drivers/net/wireless/rt2x00/rt2500pci.c | |||
@@ -1688,7 +1688,7 @@ static void rt2500pci_probe_hw_mode(struct rt2x00_dev *rt2x00dev) | |||
1688 | 1688 | ||
1689 | rt2x00dev->hw->extra_tx_headroom = 0; | 1689 | rt2x00dev->hw->extra_tx_headroom = 0; |
1690 | 1690 | ||
1691 | SET_IEEE80211_DEV(rt2x00dev->hw, &rt2x00dev_pci(rt2x00dev)->dev); | 1691 | SET_IEEE80211_DEV(rt2x00dev->hw, rt2x00dev->dev); |
1692 | SET_IEEE80211_PERM_ADDR(rt2x00dev->hw, | 1692 | SET_IEEE80211_PERM_ADDR(rt2x00dev->hw, |
1693 | rt2x00_eeprom_addr(rt2x00dev, | 1693 | rt2x00_eeprom_addr(rt2x00dev, |
1694 | EEPROM_MAC_ADDR_0)); | 1694 | EEPROM_MAC_ADDR_0)); |
diff --git a/drivers/net/wireless/rt2x00/rt2500usb.c b/drivers/net/wireless/rt2x00/rt2500usb.c index 9851cefaabf3..6b6e7b93d2ad 100644 --- a/drivers/net/wireless/rt2x00/rt2500usb.c +++ b/drivers/net/wireless/rt2x00/rt2500usb.c | |||
@@ -1588,7 +1588,7 @@ static void rt2500usb_probe_hw_mode(struct rt2x00_dev *rt2x00dev) | |||
1588 | 1588 | ||
1589 | rt2x00dev->hw->extra_tx_headroom = TXD_DESC_SIZE; | 1589 | rt2x00dev->hw->extra_tx_headroom = TXD_DESC_SIZE; |
1590 | 1590 | ||
1591 | SET_IEEE80211_DEV(rt2x00dev->hw, &rt2x00dev_usb(rt2x00dev)->dev); | 1591 | SET_IEEE80211_DEV(rt2x00dev->hw, rt2x00dev->dev); |
1592 | SET_IEEE80211_PERM_ADDR(rt2x00dev->hw, | 1592 | SET_IEEE80211_PERM_ADDR(rt2x00dev->hw, |
1593 | rt2x00_eeprom_addr(rt2x00dev, | 1593 | rt2x00_eeprom_addr(rt2x00dev, |
1594 | EEPROM_MAC_ADDR_0)); | 1594 | EEPROM_MAC_ADDR_0)); |
@@ -1672,7 +1672,8 @@ static int rt2500usb_probe_hw(struct rt2x00_dev *rt2x00dev) | |||
1672 | static int rt2500usb_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb) | 1672 | static int rt2500usb_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb) |
1673 | { | 1673 | { |
1674 | struct rt2x00_dev *rt2x00dev = hw->priv; | 1674 | struct rt2x00_dev *rt2x00dev = hw->priv; |
1675 | struct usb_device *usb_dev = rt2x00dev_usb_dev(rt2x00dev); | 1675 | struct usb_device *usb_dev = |
1676 | interface_to_usbdev(to_usb_interface(rt2x00dev->dev)); | ||
1676 | struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb); | 1677 | struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb); |
1677 | struct rt2x00_intf *intf = vif_to_intf(tx_info->control.vif); | 1678 | struct rt2x00_intf *intf = vif_to_intf(tx_info->control.vif); |
1678 | struct queue_entry_priv_usb_bcn *bcn_priv; | 1679 | struct queue_entry_priv_usb_bcn *bcn_priv; |
diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h index 21fd9b40be8f..8d45235ecc36 100644 --- a/drivers/net/wireless/rt2x00/rt2x00.h +++ b/drivers/net/wireless/rt2x00/rt2x00.h | |||
@@ -625,11 +625,7 @@ struct rt2x00_dev { | |||
625 | * When accessing this variable, the rt2x00dev_{pci,usb} | 625 | * When accessing this variable, the rt2x00dev_{pci,usb} |
626 | * macro's should be used for correct typecasting. | 626 | * macro's should be used for correct typecasting. |
627 | */ | 627 | */ |
628 | void *dev; | 628 | struct device *dev; |
629 | #define rt2x00dev_pci(__dev) ( (struct pci_dev *)(__dev)->dev ) | ||
630 | #define rt2x00dev_usb(__dev) ( (struct usb_interface *)(__dev)->dev ) | ||
631 | #define rt2x00dev_usb_dev(__dev)\ | ||
632 | ( (struct usb_device *)interface_to_usbdev(rt2x00dev_usb(__dev)) ) | ||
633 | 629 | ||
634 | /* | 630 | /* |
635 | * Callback functions. | 631 | * Callback functions. |
diff --git a/drivers/net/wireless/rt2x00/rt2x00pci.c b/drivers/net/wireless/rt2x00/rt2x00pci.c index 8d6ad18d3890..d6138389a5d0 100644 --- a/drivers/net/wireless/rt2x00/rt2x00pci.c +++ b/drivers/net/wireless/rt2x00/rt2x00pci.c | |||
@@ -194,7 +194,6 @@ EXPORT_SYMBOL_GPL(rt2x00pci_txdone); | |||
194 | static int rt2x00pci_alloc_queue_dma(struct rt2x00_dev *rt2x00dev, | 194 | static int rt2x00pci_alloc_queue_dma(struct rt2x00_dev *rt2x00dev, |
195 | struct data_queue *queue) | 195 | struct data_queue *queue) |
196 | { | 196 | { |
197 | struct pci_dev *pci_dev = rt2x00dev_pci(rt2x00dev); | ||
198 | struct queue_entry_priv_pci *entry_priv; | 197 | struct queue_entry_priv_pci *entry_priv; |
199 | void *addr; | 198 | void *addr; |
200 | dma_addr_t dma; | 199 | dma_addr_t dma; |
@@ -203,7 +202,8 @@ static int rt2x00pci_alloc_queue_dma(struct rt2x00_dev *rt2x00dev, | |||
203 | /* | 202 | /* |
204 | * Allocate DMA memory for descriptor and buffer. | 203 | * Allocate DMA memory for descriptor and buffer. |
205 | */ | 204 | */ |
206 | addr = pci_alloc_consistent(pci_dev, dma_size(queue), &dma); | 205 | addr = dma_alloc_coherent(rt2x00dev->dev, dma_size(queue), &dma, |
206 | GFP_KERNEL | GFP_DMA); | ||
207 | if (!addr) | 207 | if (!addr) |
208 | return -ENOMEM; | 208 | return -ENOMEM; |
209 | 209 | ||
@@ -226,19 +226,18 @@ static int rt2x00pci_alloc_queue_dma(struct rt2x00_dev *rt2x00dev, | |||
226 | static void rt2x00pci_free_queue_dma(struct rt2x00_dev *rt2x00dev, | 226 | static void rt2x00pci_free_queue_dma(struct rt2x00_dev *rt2x00dev, |
227 | struct data_queue *queue) | 227 | struct data_queue *queue) |
228 | { | 228 | { |
229 | struct pci_dev *pci_dev = rt2x00dev_pci(rt2x00dev); | ||
230 | struct queue_entry_priv_pci *entry_priv = | 229 | struct queue_entry_priv_pci *entry_priv = |
231 | queue->entries[0].priv_data; | 230 | queue->entries[0].priv_data; |
232 | 231 | ||
233 | if (entry_priv->data) | 232 | if (entry_priv->data) |
234 | pci_free_consistent(pci_dev, dma_size(queue), | 233 | dma_free_coherent(rt2x00dev->dev, dma_size(queue), |
235 | entry_priv->data, entry_priv->data_dma); | 234 | entry_priv->data, entry_priv->data_dma); |
236 | entry_priv->data = NULL; | 235 | entry_priv->data = NULL; |
237 | } | 236 | } |
238 | 237 | ||
239 | int rt2x00pci_initialize(struct rt2x00_dev *rt2x00dev) | 238 | int rt2x00pci_initialize(struct rt2x00_dev *rt2x00dev) |
240 | { | 239 | { |
241 | struct pci_dev *pci_dev = rt2x00dev_pci(rt2x00dev); | 240 | struct pci_dev *pci_dev = to_pci_dev(rt2x00dev->dev); |
242 | struct data_queue *queue; | 241 | struct data_queue *queue; |
243 | int status; | 242 | int status; |
244 | 243 | ||
@@ -279,7 +278,7 @@ void rt2x00pci_uninitialize(struct rt2x00_dev *rt2x00dev) | |||
279 | /* | 278 | /* |
280 | * Free irq line. | 279 | * Free irq line. |
281 | */ | 280 | */ |
282 | free_irq(rt2x00dev_pci(rt2x00dev)->irq, rt2x00dev); | 281 | free_irq(to_pci_dev(rt2x00dev->dev)->irq, rt2x00dev); |
283 | 282 | ||
284 | /* | 283 | /* |
285 | * Free DMA | 284 | * Free DMA |
@@ -308,7 +307,7 @@ static void rt2x00pci_free_reg(struct rt2x00_dev *rt2x00dev) | |||
308 | 307 | ||
309 | static int rt2x00pci_alloc_reg(struct rt2x00_dev *rt2x00dev) | 308 | static int rt2x00pci_alloc_reg(struct rt2x00_dev *rt2x00dev) |
310 | { | 309 | { |
311 | struct pci_dev *pci_dev = rt2x00dev_pci(rt2x00dev); | 310 | struct pci_dev *pci_dev = to_pci_dev(rt2x00dev->dev); |
312 | 311 | ||
313 | rt2x00dev->csr.base = ioremap(pci_resource_start(pci_dev, 0), | 312 | rt2x00dev->csr.base = ioremap(pci_resource_start(pci_dev, 0), |
314 | pci_resource_len(pci_dev, 0)); | 313 | pci_resource_len(pci_dev, 0)); |
@@ -357,7 +356,7 @@ int rt2x00pci_probe(struct pci_dev *pci_dev, const struct pci_device_id *id) | |||
357 | if (pci_set_mwi(pci_dev)) | 356 | if (pci_set_mwi(pci_dev)) |
358 | ERROR_PROBE("MWI not available.\n"); | 357 | ERROR_PROBE("MWI not available.\n"); |
359 | 358 | ||
360 | if (pci_set_dma_mask(pci_dev, DMA_32BIT_MASK)) { | 359 | if (dma_set_mask(&pci_dev->dev, DMA_32BIT_MASK)) { |
361 | ERROR_PROBE("PCI DMA not supported.\n"); | 360 | ERROR_PROBE("PCI DMA not supported.\n"); |
362 | retval = -EIO; | 361 | retval = -EIO; |
363 | goto exit_disable_device; | 362 | goto exit_disable_device; |
@@ -373,7 +372,7 @@ int rt2x00pci_probe(struct pci_dev *pci_dev, const struct pci_device_id *id) | |||
373 | pci_set_drvdata(pci_dev, hw); | 372 | pci_set_drvdata(pci_dev, hw); |
374 | 373 | ||
375 | rt2x00dev = hw->priv; | 374 | rt2x00dev = hw->priv; |
376 | rt2x00dev->dev = pci_dev; | 375 | rt2x00dev->dev = &pci_dev->dev; |
377 | rt2x00dev->ops = ops; | 376 | rt2x00dev->ops = ops; |
378 | rt2x00dev->hw = hw; | 377 | rt2x00dev->hw = hw; |
379 | 378 | ||
diff --git a/drivers/net/wireless/rt2x00/rt2x00usb.c b/drivers/net/wireless/rt2x00/rt2x00usb.c index 3080969ae5b3..f91901ffda5b 100644 --- a/drivers/net/wireless/rt2x00/rt2x00usb.c +++ b/drivers/net/wireless/rt2x00/rt2x00usb.c | |||
@@ -40,7 +40,8 @@ int rt2x00usb_vendor_request(struct rt2x00_dev *rt2x00dev, | |||
40 | void *buffer, const u16 buffer_length, | 40 | void *buffer, const u16 buffer_length, |
41 | const int timeout) | 41 | const int timeout) |
42 | { | 42 | { |
43 | struct usb_device *usb_dev = rt2x00dev_usb_dev(rt2x00dev); | 43 | struct usb_device *usb_dev = |
44 | interface_to_usbdev(to_usb_interface(rt2x00dev->dev)); | ||
44 | int status; | 45 | int status; |
45 | unsigned int i; | 46 | unsigned int i; |
46 | unsigned int pipe = | 47 | unsigned int pipe = |
@@ -176,7 +177,8 @@ static void rt2x00usb_interrupt_txdone(struct urb *urb) | |||
176 | int rt2x00usb_write_tx_data(struct queue_entry *entry) | 177 | int rt2x00usb_write_tx_data(struct queue_entry *entry) |
177 | { | 178 | { |
178 | struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev; | 179 | struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev; |
179 | struct usb_device *usb_dev = rt2x00dev_usb_dev(rt2x00dev); | 180 | struct usb_device *usb_dev = |
181 | interface_to_usbdev(to_usb_interface(rt2x00dev->dev)); | ||
180 | struct queue_entry_priv_usb *entry_priv = entry->priv_data; | 182 | struct queue_entry_priv_usb *entry_priv = entry->priv_data; |
181 | struct skb_frame_desc *skbdesc; | 183 | struct skb_frame_desc *skbdesc; |
182 | u32 length; | 184 | u32 length; |
@@ -364,7 +366,8 @@ EXPORT_SYMBOL_GPL(rt2x00usb_disable_radio); | |||
364 | void rt2x00usb_init_rxentry(struct rt2x00_dev *rt2x00dev, | 366 | void rt2x00usb_init_rxentry(struct rt2x00_dev *rt2x00dev, |
365 | struct queue_entry *entry) | 367 | struct queue_entry *entry) |
366 | { | 368 | { |
367 | struct usb_device *usb_dev = rt2x00dev_usb_dev(rt2x00dev); | 369 | struct usb_device *usb_dev = |
370 | interface_to_usbdev(to_usb_interface(rt2x00dev->dev)); | ||
368 | struct queue_entry_priv_usb *entry_priv = entry->priv_data; | 371 | struct queue_entry_priv_usb *entry_priv = entry->priv_data; |
369 | 372 | ||
370 | usb_fill_bulk_urb(entry_priv->urb, usb_dev, | 373 | usb_fill_bulk_urb(entry_priv->urb, usb_dev, |
@@ -558,7 +561,7 @@ int rt2x00usb_probe(struct usb_interface *usb_intf, | |||
558 | usb_set_intfdata(usb_intf, hw); | 561 | usb_set_intfdata(usb_intf, hw); |
559 | 562 | ||
560 | rt2x00dev = hw->priv; | 563 | rt2x00dev = hw->priv; |
561 | rt2x00dev->dev = usb_intf; | 564 | rt2x00dev->dev = &usb_intf->dev; |
562 | rt2x00dev->ops = ops; | 565 | rt2x00dev->ops = ops; |
563 | rt2x00dev->hw = hw; | 566 | rt2x00dev->hw = hw; |
564 | mutex_init(&rt2x00dev->usb_cache_mutex); | 567 | mutex_init(&rt2x00dev->usb_cache_mutex); |
diff --git a/drivers/net/wireless/rt2x00/rt61pci.c b/drivers/net/wireless/rt2x00/rt61pci.c index 27f30ae8f52b..2a7f30620356 100644 --- a/drivers/net/wireless/rt2x00/rt61pci.c +++ b/drivers/net/wireless/rt2x00/rt61pci.c | |||
@@ -1973,7 +1973,7 @@ static int rt61pci_init_eeprom(struct rt2x00_dev *rt2x00dev) | |||
1973 | * To determine the RT chip we have to read the | 1973 | * To determine the RT chip we have to read the |
1974 | * PCI header of the device. | 1974 | * PCI header of the device. |
1975 | */ | 1975 | */ |
1976 | pci_read_config_word(rt2x00dev_pci(rt2x00dev), | 1976 | pci_read_config_word(to_pci_dev(rt2x00dev->dev), |
1977 | PCI_CONFIG_HEADER_DEVICE, &device); | 1977 | PCI_CONFIG_HEADER_DEVICE, &device); |
1978 | value = rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RF_TYPE); | 1978 | value = rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RF_TYPE); |
1979 | rt2x00pci_register_read(rt2x00dev, MAC_CSR0, ®); | 1979 | rt2x00pci_register_read(rt2x00dev, MAC_CSR0, ®); |
@@ -2239,7 +2239,7 @@ static void rt61pci_probe_hw_mode(struct rt2x00_dev *rt2x00dev) | |||
2239 | IEEE80211_HW_SIGNAL_DBM; | 2239 | IEEE80211_HW_SIGNAL_DBM; |
2240 | rt2x00dev->hw->extra_tx_headroom = 0; | 2240 | rt2x00dev->hw->extra_tx_headroom = 0; |
2241 | 2241 | ||
2242 | SET_IEEE80211_DEV(rt2x00dev->hw, &rt2x00dev_pci(rt2x00dev)->dev); | 2242 | SET_IEEE80211_DEV(rt2x00dev->hw, rt2x00dev->dev); |
2243 | SET_IEEE80211_PERM_ADDR(rt2x00dev->hw, | 2243 | SET_IEEE80211_PERM_ADDR(rt2x00dev->hw, |
2244 | rt2x00_eeprom_addr(rt2x00dev, | 2244 | rt2x00_eeprom_addr(rt2x00dev, |
2245 | EEPROM_MAC_ADDR_0)); | 2245 | EEPROM_MAC_ADDR_0)); |
diff --git a/drivers/net/wireless/rt2x00/rt73usb.c b/drivers/net/wireless/rt2x00/rt73usb.c index 42b7e98b2d27..ead6db04d60a 100644 --- a/drivers/net/wireless/rt2x00/rt73usb.c +++ b/drivers/net/wireless/rt2x00/rt73usb.c | |||
@@ -1821,7 +1821,7 @@ static void rt73usb_probe_hw_mode(struct rt2x00_dev *rt2x00dev) | |||
1821 | IEEE80211_HW_SIGNAL_DBM; | 1821 | IEEE80211_HW_SIGNAL_DBM; |
1822 | rt2x00dev->hw->extra_tx_headroom = TXD_DESC_SIZE; | 1822 | rt2x00dev->hw->extra_tx_headroom = TXD_DESC_SIZE; |
1823 | 1823 | ||
1824 | SET_IEEE80211_DEV(rt2x00dev->hw, &rt2x00dev_usb(rt2x00dev)->dev); | 1824 | SET_IEEE80211_DEV(rt2x00dev->hw, rt2x00dev->dev); |
1825 | SET_IEEE80211_PERM_ADDR(rt2x00dev->hw, | 1825 | SET_IEEE80211_PERM_ADDR(rt2x00dev->hw, |
1826 | rt2x00_eeprom_addr(rt2x00dev, | 1826 | rt2x00_eeprom_addr(rt2x00dev, |
1827 | EEPROM_MAC_ADDR_0)); | 1827 | EEPROM_MAC_ADDR_0)); |