diff options
author | Ivo van Doorn <ivdoorn@gmail.com> | 2008-02-10 16:49:13 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2008-02-29 15:37:19 -0500 |
commit | 21795094e2b71b4b11bfb468321046c1336cef69 (patch) | |
tree | de99ccc0f93ba165574db3b55fd9c0839dd65bed /drivers/net | |
parent | f590f48e87d1e61c03f01fa15be00e852c05426d (diff) |
rt2x00: make csr_cache and csr_addr an union
The csr_cache and csr_addr pointers are both the same size
and they are never used both by the same driver. This makes
them a nice candidate for an union.
We could merge into 1 pointer, but that would either upset sparse,
or require a lot of __force casts.
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/rt2x00.h | 10 | ||||
-rw-r--r-- | drivers/net/wireless/rt2x00/rt2x00pci.c | 10 | ||||
-rw-r--r-- | drivers/net/wireless/rt2x00/rt2x00pci.h | 8 | ||||
-rw-r--r-- | drivers/net/wireless/rt2x00/rt2x00usb.c | 16 |
4 files changed, 23 insertions, 21 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h index f6ec9fe23096..9098532e046a 100644 --- a/drivers/net/wireless/rt2x00/rt2x00.h +++ b/drivers/net/wireless/rt2x00/rt2x00.h | |||
@@ -707,11 +707,13 @@ struct rt2x00_dev { | |||
707 | 707 | ||
708 | /* | 708 | /* |
709 | * Register pointers | 709 | * Register pointers |
710 | * csr_addr: Base register address. (PCI) | 710 | * csr.base: CSR base register address. (PCI) |
711 | * csr_cache: CSR cache for usb_control_msg. (USB) | 711 | * csr.cache: CSR cache for usb_control_msg. (USB) |
712 | */ | 712 | */ |
713 | void __iomem *csr_addr; | 713 | union csr { |
714 | void *csr_cache; | 714 | void __iomem *base; |
715 | void *cache; | ||
716 | } csr; | ||
715 | 717 | ||
716 | /* | 718 | /* |
717 | * Mutex to protect register accesses on USB devices. | 719 | * Mutex to protect register accesses on USB devices. |
diff --git a/drivers/net/wireless/rt2x00/rt2x00pci.c b/drivers/net/wireless/rt2x00/rt2x00pci.c index 238f1c1e4ad0..b8c6a8c9d6d2 100644 --- a/drivers/net/wireless/rt2x00/rt2x00pci.c +++ b/drivers/net/wireless/rt2x00/rt2x00pci.c | |||
@@ -350,9 +350,9 @@ static void rt2x00pci_free_reg(struct rt2x00_dev *rt2x00dev) | |||
350 | kfree(rt2x00dev->eeprom); | 350 | kfree(rt2x00dev->eeprom); |
351 | rt2x00dev->eeprom = NULL; | 351 | rt2x00dev->eeprom = NULL; |
352 | 352 | ||
353 | if (rt2x00dev->csr_addr) { | 353 | if (rt2x00dev->csr.base) { |
354 | iounmap(rt2x00dev->csr_addr); | 354 | iounmap(rt2x00dev->csr.base); |
355 | rt2x00dev->csr_addr = NULL; | 355 | rt2x00dev->csr.base = NULL; |
356 | } | 356 | } |
357 | } | 357 | } |
358 | 358 | ||
@@ -360,9 +360,9 @@ static int rt2x00pci_alloc_reg(struct rt2x00_dev *rt2x00dev) | |||
360 | { | 360 | { |
361 | struct pci_dev *pci_dev = rt2x00dev_pci(rt2x00dev); | 361 | struct pci_dev *pci_dev = rt2x00dev_pci(rt2x00dev); |
362 | 362 | ||
363 | rt2x00dev->csr_addr = ioremap(pci_resource_start(pci_dev, 0), | 363 | rt2x00dev->csr.base = ioremap(pci_resource_start(pci_dev, 0), |
364 | pci_resource_len(pci_dev, 0)); | 364 | pci_resource_len(pci_dev, 0)); |
365 | if (!rt2x00dev->csr_addr) | 365 | if (!rt2x00dev->csr.base) |
366 | goto exit; | 366 | goto exit; |
367 | 367 | ||
368 | rt2x00dev->eeprom = kzalloc(rt2x00dev->ops->eeprom_size, GFP_KERNEL); | 368 | rt2x00dev->eeprom = kzalloc(rt2x00dev->ops->eeprom_size, GFP_KERNEL); |
diff --git a/drivers/net/wireless/rt2x00/rt2x00pci.h b/drivers/net/wireless/rt2x00/rt2x00pci.h index 71335e16b058..8932b31d2624 100644 --- a/drivers/net/wireless/rt2x00/rt2x00pci.h +++ b/drivers/net/wireless/rt2x00/rt2x00pci.h | |||
@@ -61,7 +61,7 @@ static inline void rt2x00pci_register_read(struct rt2x00_dev *rt2x00dev, | |||
61 | const unsigned long offset, | 61 | const unsigned long offset, |
62 | u32 *value) | 62 | u32 *value) |
63 | { | 63 | { |
64 | *value = readl(rt2x00dev->csr_addr + offset); | 64 | *value = readl(rt2x00dev->csr.base + offset); |
65 | } | 65 | } |
66 | 66 | ||
67 | static inline void | 67 | static inline void |
@@ -69,14 +69,14 @@ rt2x00pci_register_multiread(struct rt2x00_dev *rt2x00dev, | |||
69 | const unsigned long offset, | 69 | const unsigned long offset, |
70 | void *value, const u16 length) | 70 | void *value, const u16 length) |
71 | { | 71 | { |
72 | memcpy_fromio(value, rt2x00dev->csr_addr + offset, length); | 72 | memcpy_fromio(value, rt2x00dev->csr.base + offset, length); |
73 | } | 73 | } |
74 | 74 | ||
75 | static inline void rt2x00pci_register_write(struct rt2x00_dev *rt2x00dev, | 75 | static inline void rt2x00pci_register_write(struct rt2x00_dev *rt2x00dev, |
76 | const unsigned long offset, | 76 | const unsigned long offset, |
77 | u32 value) | 77 | u32 value) |
78 | { | 78 | { |
79 | writel(value, rt2x00dev->csr_addr + offset); | 79 | writel(value, rt2x00dev->csr.base + offset); |
80 | } | 80 | } |
81 | 81 | ||
82 | static inline void | 82 | static inline void |
@@ -84,7 +84,7 @@ rt2x00pci_register_multiwrite(struct rt2x00_dev *rt2x00dev, | |||
84 | const unsigned long offset, | 84 | const unsigned long offset, |
85 | void *value, const u16 length) | 85 | void *value, const u16 length) |
86 | { | 86 | { |
87 | memcpy_toio(rt2x00dev->csr_addr + offset, value, length); | 87 | memcpy_toio(rt2x00dev->csr.base + offset, value, length); |
88 | } | 88 | } |
89 | 89 | ||
90 | /* | 90 | /* |
diff --git a/drivers/net/wireless/rt2x00/rt2x00usb.c b/drivers/net/wireless/rt2x00/rt2x00usb.c index 44ab2167c6ee..4219057d85cb 100644 --- a/drivers/net/wireless/rt2x00/rt2x00usb.c +++ b/drivers/net/wireless/rt2x00/rt2x00usb.c | |||
@@ -84,20 +84,20 @@ int rt2x00usb_vendor_req_buff_lock(struct rt2x00_dev *rt2x00dev, | |||
84 | /* | 84 | /* |
85 | * Check for Cache availability. | 85 | * Check for Cache availability. |
86 | */ | 86 | */ |
87 | if (unlikely(!rt2x00dev->csr_cache || buffer_length > CSR_CACHE_SIZE)) { | 87 | if (unlikely(!rt2x00dev->csr.cache || buffer_length > CSR_CACHE_SIZE)) { |
88 | ERROR(rt2x00dev, "CSR cache not available.\n"); | 88 | ERROR(rt2x00dev, "CSR cache not available.\n"); |
89 | return -ENOMEM; | 89 | return -ENOMEM; |
90 | } | 90 | } |
91 | 91 | ||
92 | if (requesttype == USB_VENDOR_REQUEST_OUT) | 92 | if (requesttype == USB_VENDOR_REQUEST_OUT) |
93 | memcpy(rt2x00dev->csr_cache, buffer, buffer_length); | 93 | memcpy(rt2x00dev->csr.cache, buffer, buffer_length); |
94 | 94 | ||
95 | status = rt2x00usb_vendor_request(rt2x00dev, request, requesttype, | 95 | status = rt2x00usb_vendor_request(rt2x00dev, request, requesttype, |
96 | offset, 0, rt2x00dev->csr_cache, | 96 | offset, 0, rt2x00dev->csr.cache, |
97 | buffer_length, timeout); | 97 | buffer_length, timeout); |
98 | 98 | ||
99 | if (!status && requesttype == USB_VENDOR_REQUEST_IN) | 99 | if (!status && requesttype == USB_VENDOR_REQUEST_IN) |
100 | memcpy(buffer, rt2x00dev->csr_cache, buffer_length); | 100 | memcpy(buffer, rt2x00dev->csr.cache, buffer_length); |
101 | 101 | ||
102 | return status; | 102 | return status; |
103 | } | 103 | } |
@@ -562,14 +562,14 @@ static void rt2x00usb_free_reg(struct rt2x00_dev *rt2x00dev) | |||
562 | kfree(rt2x00dev->eeprom); | 562 | kfree(rt2x00dev->eeprom); |
563 | rt2x00dev->eeprom = NULL; | 563 | rt2x00dev->eeprom = NULL; |
564 | 564 | ||
565 | kfree(rt2x00dev->csr_cache); | 565 | kfree(rt2x00dev->csr.cache); |
566 | rt2x00dev->csr_cache = NULL; | 566 | rt2x00dev->csr.cache = NULL; |
567 | } | 567 | } |
568 | 568 | ||
569 | static int rt2x00usb_alloc_reg(struct rt2x00_dev *rt2x00dev) | 569 | static int rt2x00usb_alloc_reg(struct rt2x00_dev *rt2x00dev) |
570 | { | 570 | { |
571 | rt2x00dev->csr_cache = kzalloc(CSR_CACHE_SIZE, GFP_KERNEL); | 571 | rt2x00dev->csr.cache = kzalloc(CSR_CACHE_SIZE, GFP_KERNEL); |
572 | if (!rt2x00dev->csr_cache) | 572 | if (!rt2x00dev->csr.cache) |
573 | goto exit; | 573 | goto exit; |
574 | 574 | ||
575 | rt2x00dev->eeprom = kzalloc(rt2x00dev->ops->eeprom_size, GFP_KERNEL); | 575 | rt2x00dev->eeprom = kzalloc(rt2x00dev->ops->eeprom_size, GFP_KERNEL); |