Commit 21795094 authored by Ivo van Doorn's avatar Ivo van Doorn Committed by John W. Linville

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: default avatarIvo van Doorn <IvDoorn@gmail.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent f590f48e
...@@ -707,11 +707,13 @@ struct rt2x00_dev { ...@@ -707,11 +707,13 @@ struct rt2x00_dev {
/* /*
* Register pointers * Register pointers
* csr_addr: Base register address. (PCI) * csr.base: CSR base register address. (PCI)
* csr_cache: CSR cache for usb_control_msg. (USB) * csr.cache: CSR cache for usb_control_msg. (USB)
*/ */
void __iomem *csr_addr; union csr {
void *csr_cache; void __iomem *base;
void *cache;
} csr;
/* /*
* Mutex to protect register accesses on USB devices. * Mutex to protect register accesses on USB devices.
......
...@@ -350,9 +350,9 @@ static void rt2x00pci_free_reg(struct rt2x00_dev *rt2x00dev) ...@@ -350,9 +350,9 @@ static void rt2x00pci_free_reg(struct rt2x00_dev *rt2x00dev)
kfree(rt2x00dev->eeprom); kfree(rt2x00dev->eeprom);
rt2x00dev->eeprom = NULL; rt2x00dev->eeprom = NULL;
if (rt2x00dev->csr_addr) { if (rt2x00dev->csr.base) {
iounmap(rt2x00dev->csr_addr); iounmap(rt2x00dev->csr.base);
rt2x00dev->csr_addr = NULL; rt2x00dev->csr.base = NULL;
} }
} }
...@@ -360,9 +360,9 @@ static int rt2x00pci_alloc_reg(struct rt2x00_dev *rt2x00dev) ...@@ -360,9 +360,9 @@ static int rt2x00pci_alloc_reg(struct rt2x00_dev *rt2x00dev)
{ {
struct pci_dev *pci_dev = rt2x00dev_pci(rt2x00dev); struct pci_dev *pci_dev = rt2x00dev_pci(rt2x00dev);
rt2x00dev->csr_addr = ioremap(pci_resource_start(pci_dev, 0), rt2x00dev->csr.base = ioremap(pci_resource_start(pci_dev, 0),
pci_resource_len(pci_dev, 0)); pci_resource_len(pci_dev, 0));
if (!rt2x00dev->csr_addr) if (!rt2x00dev->csr.base)
goto exit; goto exit;
rt2x00dev->eeprom = kzalloc(rt2x00dev->ops->eeprom_size, GFP_KERNEL); rt2x00dev->eeprom = kzalloc(rt2x00dev->ops->eeprom_size, GFP_KERNEL);
......
...@@ -61,7 +61,7 @@ static inline void rt2x00pci_register_read(struct rt2x00_dev *rt2x00dev, ...@@ -61,7 +61,7 @@ static inline void rt2x00pci_register_read(struct rt2x00_dev *rt2x00dev,
const unsigned long offset, const unsigned long offset,
u32 *value) u32 *value)
{ {
*value = readl(rt2x00dev->csr_addr + offset); *value = readl(rt2x00dev->csr.base + offset);
} }
static inline void static inline void
...@@ -69,14 +69,14 @@ rt2x00pci_register_multiread(struct rt2x00_dev *rt2x00dev, ...@@ -69,14 +69,14 @@ rt2x00pci_register_multiread(struct rt2x00_dev *rt2x00dev,
const unsigned long offset, const unsigned long offset,
void *value, const u16 length) void *value, const u16 length)
{ {
memcpy_fromio(value, rt2x00dev->csr_addr + offset, length); memcpy_fromio(value, rt2x00dev->csr.base + offset, length);
} }
static inline void rt2x00pci_register_write(struct rt2x00_dev *rt2x00dev, static inline void rt2x00pci_register_write(struct rt2x00_dev *rt2x00dev,
const unsigned long offset, const unsigned long offset,
u32 value) u32 value)
{ {
writel(value, rt2x00dev->csr_addr + offset); writel(value, rt2x00dev->csr.base + offset);
} }
static inline void static inline void
...@@ -84,7 +84,7 @@ rt2x00pci_register_multiwrite(struct rt2x00_dev *rt2x00dev, ...@@ -84,7 +84,7 @@ rt2x00pci_register_multiwrite(struct rt2x00_dev *rt2x00dev,
const unsigned long offset, const unsigned long offset,
void *value, const u16 length) void *value, const u16 length)
{ {
memcpy_toio(rt2x00dev->csr_addr + offset, value, length); memcpy_toio(rt2x00dev->csr.base + offset, value, length);
} }
/* /*
......
...@@ -84,20 +84,20 @@ int rt2x00usb_vendor_req_buff_lock(struct rt2x00_dev *rt2x00dev, ...@@ -84,20 +84,20 @@ int rt2x00usb_vendor_req_buff_lock(struct rt2x00_dev *rt2x00dev,
/* /*
* Check for Cache availability. * Check for Cache availability.
*/ */
if (unlikely(!rt2x00dev->csr_cache || buffer_length > CSR_CACHE_SIZE)) { if (unlikely(!rt2x00dev->csr.cache || buffer_length > CSR_CACHE_SIZE)) {
ERROR(rt2x00dev, "CSR cache not available.\n"); ERROR(rt2x00dev, "CSR cache not available.\n");
return -ENOMEM; return -ENOMEM;
} }
if (requesttype == USB_VENDOR_REQUEST_OUT) if (requesttype == USB_VENDOR_REQUEST_OUT)
memcpy(rt2x00dev->csr_cache, buffer, buffer_length); memcpy(rt2x00dev->csr.cache, buffer, buffer_length);
status = rt2x00usb_vendor_request(rt2x00dev, request, requesttype, status = rt2x00usb_vendor_request(rt2x00dev, request, requesttype,
offset, 0, rt2x00dev->csr_cache, offset, 0, rt2x00dev->csr.cache,
buffer_length, timeout); buffer_length, timeout);
if (!status && requesttype == USB_VENDOR_REQUEST_IN) if (!status && requesttype == USB_VENDOR_REQUEST_IN)
memcpy(buffer, rt2x00dev->csr_cache, buffer_length); memcpy(buffer, rt2x00dev->csr.cache, buffer_length);
return status; return status;
} }
...@@ -562,14 +562,14 @@ static void rt2x00usb_free_reg(struct rt2x00_dev *rt2x00dev) ...@@ -562,14 +562,14 @@ static void rt2x00usb_free_reg(struct rt2x00_dev *rt2x00dev)
kfree(rt2x00dev->eeprom); kfree(rt2x00dev->eeprom);
rt2x00dev->eeprom = NULL; rt2x00dev->eeprom = NULL;
kfree(rt2x00dev->csr_cache); kfree(rt2x00dev->csr.cache);
rt2x00dev->csr_cache = NULL; rt2x00dev->csr.cache = NULL;
} }
static int rt2x00usb_alloc_reg(struct rt2x00_dev *rt2x00dev) static int rt2x00usb_alloc_reg(struct rt2x00_dev *rt2x00dev)
{ {
rt2x00dev->csr_cache = kzalloc(CSR_CACHE_SIZE, GFP_KERNEL); rt2x00dev->csr.cache = kzalloc(CSR_CACHE_SIZE, GFP_KERNEL);
if (!rt2x00dev->csr_cache) if (!rt2x00dev->csr.cache)
goto exit; goto exit;
rt2x00dev->eeprom = kzalloc(rt2x00dev->ops->eeprom_size, GFP_KERNEL); rt2x00dev->eeprom = kzalloc(rt2x00dev->ops->eeprom_size, GFP_KERNEL);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment