Commit a18c715e authored by Rafał Miłecki's avatar Rafał Miłecki Committed by John W. Linville

b43: bus: abstract device structs and irq

Signed-off-by: default avatarRafał Miłecki <zajec5@gmail.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 0581483a
...@@ -70,6 +70,10 @@ struct b43_bus_dev *b43_bus_dev_ssb_init(struct ssb_device *sdev) ...@@ -70,6 +70,10 @@ struct b43_bus_dev *b43_bus_dev_ssb_init(struct ssb_device *sdev)
dev->block_read = b43_bus_ssb_block_read; dev->block_read = b43_bus_ssb_block_read;
dev->block_write = b43_bus_ssb_block_write; dev->block_write = b43_bus_ssb_block_write;
dev->dev = sdev->dev;
dev->dma_dev = sdev->dma_dev;
dev->irq = sdev->irq;
dev->bus_sprom = &sdev->bus->sprom; dev->bus_sprom = &sdev->bus->sprom;
dev->core_id = sdev->id.coreid; dev->core_id = sdev->id.coreid;
......
...@@ -20,6 +20,10 @@ struct b43_bus_dev { ...@@ -20,6 +20,10 @@ struct b43_bus_dev {
void (*block_write)(struct b43_bus_dev *dev, const void *buffer, void (*block_write)(struct b43_bus_dev *dev, const void *buffer,
size_t count, u16 offset, u8 reg_width); size_t count, u16 offset, u8 reg_width);
struct device *dev;
struct device *dma_dev;
unsigned int irq;
struct ssb_sprom *bus_sprom; struct ssb_sprom *bus_sprom;
u16 core_id; u16 core_id;
......
...@@ -333,10 +333,10 @@ static inline ...@@ -333,10 +333,10 @@ static inline
dma_addr_t dmaaddr; dma_addr_t dmaaddr;
if (tx) { if (tx) {
dmaaddr = dma_map_single(ring->dev->sdev->dma_dev, dmaaddr = dma_map_single(ring->dev->dev->dma_dev,
buf, len, DMA_TO_DEVICE); buf, len, DMA_TO_DEVICE);
} else { } else {
dmaaddr = dma_map_single(ring->dev->sdev->dma_dev, dmaaddr = dma_map_single(ring->dev->dev->dma_dev,
buf, len, DMA_FROM_DEVICE); buf, len, DMA_FROM_DEVICE);
} }
...@@ -348,10 +348,10 @@ static inline ...@@ -348,10 +348,10 @@ static inline
dma_addr_t addr, size_t len, int tx) dma_addr_t addr, size_t len, int tx)
{ {
if (tx) { if (tx) {
dma_unmap_single(ring->dev->sdev->dma_dev, dma_unmap_single(ring->dev->dev->dma_dev,
addr, len, DMA_TO_DEVICE); addr, len, DMA_TO_DEVICE);
} else { } else {
dma_unmap_single(ring->dev->sdev->dma_dev, dma_unmap_single(ring->dev->dev->dma_dev,
addr, len, DMA_FROM_DEVICE); addr, len, DMA_FROM_DEVICE);
} }
} }
...@@ -361,7 +361,7 @@ static inline ...@@ -361,7 +361,7 @@ static inline
dma_addr_t addr, size_t len) dma_addr_t addr, size_t len)
{ {
B43_WARN_ON(ring->tx); B43_WARN_ON(ring->tx);
dma_sync_single_for_cpu(ring->dev->sdev->dma_dev, dma_sync_single_for_cpu(ring->dev->dev->dma_dev,
addr, len, DMA_FROM_DEVICE); addr, len, DMA_FROM_DEVICE);
} }
...@@ -370,7 +370,7 @@ static inline ...@@ -370,7 +370,7 @@ static inline
dma_addr_t addr, size_t len) dma_addr_t addr, size_t len)
{ {
B43_WARN_ON(ring->tx); B43_WARN_ON(ring->tx);
dma_sync_single_for_device(ring->dev->sdev->dma_dev, dma_sync_single_for_device(ring->dev->dev->dma_dev,
addr, len, DMA_FROM_DEVICE); addr, len, DMA_FROM_DEVICE);
} }
...@@ -401,7 +401,7 @@ static int alloc_ringmemory(struct b43_dmaring *ring) ...@@ -401,7 +401,7 @@ static int alloc_ringmemory(struct b43_dmaring *ring)
*/ */
if (ring->type == B43_DMA_64BIT) if (ring->type == B43_DMA_64BIT)
flags |= GFP_DMA; flags |= GFP_DMA;
ring->descbase = dma_alloc_coherent(ring->dev->sdev->dma_dev, ring->descbase = dma_alloc_coherent(ring->dev->dev->dma_dev,
B43_DMA_RINGMEMSIZE, B43_DMA_RINGMEMSIZE,
&(ring->dmabase), flags); &(ring->dmabase), flags);
if (!ring->descbase) { if (!ring->descbase) {
...@@ -415,7 +415,7 @@ static int alloc_ringmemory(struct b43_dmaring *ring) ...@@ -415,7 +415,7 @@ static int alloc_ringmemory(struct b43_dmaring *ring)
static void free_ringmemory(struct b43_dmaring *ring) static void free_ringmemory(struct b43_dmaring *ring)
{ {
dma_free_coherent(ring->dev->sdev->dma_dev, B43_DMA_RINGMEMSIZE, dma_free_coherent(ring->dev->dev->dma_dev, B43_DMA_RINGMEMSIZE,
ring->descbase, ring->dmabase); ring->descbase, ring->dmabase);
} }
...@@ -523,7 +523,7 @@ static bool b43_dma_mapping_error(struct b43_dmaring *ring, ...@@ -523,7 +523,7 @@ static bool b43_dma_mapping_error(struct b43_dmaring *ring,
dma_addr_t addr, dma_addr_t addr,
size_t buffersize, bool dma_to_device) size_t buffersize, bool dma_to_device)
{ {
if (unlikely(dma_mapping_error(ring->dev->sdev->dma_dev, addr))) if (unlikely(dma_mapping_error(ring->dev->dev->dma_dev, addr)))
return 1; return 1;
switch (ring->type) { switch (ring->type) {
...@@ -869,7 +869,7 @@ struct b43_dmaring *b43_setup_dmaring(struct b43_wldev *dev, ...@@ -869,7 +869,7 @@ struct b43_dmaring *b43_setup_dmaring(struct b43_wldev *dev,
goto err_kfree_meta; goto err_kfree_meta;
/* test for ability to dma to txhdr_cache */ /* test for ability to dma to txhdr_cache */
dma_test = dma_map_single(dev->sdev->dma_dev, dma_test = dma_map_single(dev->dev->dma_dev,
ring->txhdr_cache, ring->txhdr_cache,
b43_txhdr_size(dev), b43_txhdr_size(dev),
DMA_TO_DEVICE); DMA_TO_DEVICE);
...@@ -884,7 +884,7 @@ struct b43_dmaring *b43_setup_dmaring(struct b43_wldev *dev, ...@@ -884,7 +884,7 @@ struct b43_dmaring *b43_setup_dmaring(struct b43_wldev *dev,
if (!ring->txhdr_cache) if (!ring->txhdr_cache)
goto err_kfree_meta; goto err_kfree_meta;
dma_test = dma_map_single(dev->sdev->dma_dev, dma_test = dma_map_single(dev->dev->dma_dev,
ring->txhdr_cache, ring->txhdr_cache,
b43_txhdr_size(dev), b43_txhdr_size(dev),
DMA_TO_DEVICE); DMA_TO_DEVICE);
...@@ -898,7 +898,7 @@ struct b43_dmaring *b43_setup_dmaring(struct b43_wldev *dev, ...@@ -898,7 +898,7 @@ struct b43_dmaring *b43_setup_dmaring(struct b43_wldev *dev,
} }
} }
dma_unmap_single(dev->sdev->dma_dev, dma_unmap_single(dev->dev->dma_dev,
dma_test, b43_txhdr_size(dev), dma_test, b43_txhdr_size(dev),
DMA_TO_DEVICE); DMA_TO_DEVICE);
} }
...@@ -1013,9 +1013,9 @@ static int b43_dma_set_mask(struct b43_wldev *dev, u64 mask) ...@@ -1013,9 +1013,9 @@ static int b43_dma_set_mask(struct b43_wldev *dev, u64 mask)
/* Try to set the DMA mask. If it fails, try falling back to a /* Try to set the DMA mask. If it fails, try falling back to a
* lower mask, as we can always also support a lower one. */ * lower mask, as we can always also support a lower one. */
while (1) { while (1) {
err = dma_set_mask(dev->sdev->dma_dev, mask); err = dma_set_mask(dev->dev->dma_dev, mask);
if (!err) { if (!err) {
err = dma_set_coherent_mask(dev->sdev->dma_dev, mask); err = dma_set_coherent_mask(dev->dev->dma_dev, mask);
if (!err) if (!err)
break; break;
} }
......
...@@ -138,7 +138,7 @@ static int b43_register_led(struct b43_wldev *dev, struct b43_led *led, ...@@ -138,7 +138,7 @@ static int b43_register_led(struct b43_wldev *dev, struct b43_led *led,
led->led_dev.default_trigger = default_trigger; led->led_dev.default_trigger = default_trigger;
led->led_dev.brightness_set = b43_led_brightness_set; led->led_dev.brightness_set = b43_led_brightness_set;
err = led_classdev_register(dev->sdev->dev, &led->led_dev); err = led_classdev_register(dev->dev->dev, &led->led_dev);
if (err) { if (err) {
b43warn(dev->wl, "LEDs: Failed to register %s\n", name); b43warn(dev->wl, "LEDs: Failed to register %s\n", name);
led->wl = NULL; led->wl = NULL;
......
...@@ -2063,7 +2063,7 @@ int b43_do_request_fw(struct b43_request_fw_context *ctx, ...@@ -2063,7 +2063,7 @@ int b43_do_request_fw(struct b43_request_fw_context *ctx,
B43_WARN_ON(1); B43_WARN_ON(1);
return -ENOSYS; return -ENOSYS;
} }
err = request_firmware(&blob, ctx->fwname, ctx->dev->sdev->dev); err = request_firmware(&blob, ctx->fwname, ctx->dev->dev->dev);
if (err == -ENOENT) { if (err == -ENOENT) {
snprintf(ctx->errors[ctx->req_type], snprintf(ctx->errors[ctx->req_type],
sizeof(ctx->errors[ctx->req_type]), sizeof(ctx->errors[ctx->req_type]),
...@@ -3970,8 +3970,8 @@ static struct b43_wldev * b43_wireless_core_stop(struct b43_wldev *dev) ...@@ -3970,8 +3970,8 @@ static struct b43_wldev * b43_wireless_core_stop(struct b43_wldev *dev)
if (dev->sdev->bus->bustype == SSB_BUSTYPE_SDIO) { if (dev->sdev->bus->bustype == SSB_BUSTYPE_SDIO) {
b43_sdio_free_irq(dev); b43_sdio_free_irq(dev);
} else { } else {
synchronize_irq(dev->sdev->irq); synchronize_irq(dev->dev->irq);
free_irq(dev->sdev->irq, dev); free_irq(dev->dev->irq, dev);
} }
mutex_lock(&wl->mutex); mutex_lock(&wl->mutex);
dev = wl->current_dev; dev = wl->current_dev;
...@@ -4011,12 +4011,12 @@ static int b43_wireless_core_start(struct b43_wldev *dev) ...@@ -4011,12 +4011,12 @@ static int b43_wireless_core_start(struct b43_wldev *dev)
goto out; goto out;
} }
} else { } else {
err = request_threaded_irq(dev->sdev->irq, b43_interrupt_handler, err = request_threaded_irq(dev->dev->irq, b43_interrupt_handler,
b43_interrupt_thread_handler, b43_interrupt_thread_handler,
IRQF_SHARED, KBUILD_MODNAME, dev); IRQF_SHARED, KBUILD_MODNAME, dev);
if (err) { if (err) {
b43err(dev->wl, "Cannot request IRQ-%d\n", b43err(dev->wl, "Cannot request IRQ-%d\n",
dev->sdev->irq); dev->dev->irq);
goto out; goto out;
} }
} }
......
...@@ -140,7 +140,7 @@ static DEVICE_ATTR(interference, 0644, ...@@ -140,7 +140,7 @@ static DEVICE_ATTR(interference, 0644,
int b43_sysfs_register(struct b43_wldev *wldev) int b43_sysfs_register(struct b43_wldev *wldev)
{ {
struct device *dev = wldev->sdev->dev; struct device *dev = wldev->dev->dev;
B43_WARN_ON(b43_status(wldev) != B43_STAT_INITIALIZED); B43_WARN_ON(b43_status(wldev) != B43_STAT_INITIALIZED);
...@@ -149,7 +149,7 @@ int b43_sysfs_register(struct b43_wldev *wldev) ...@@ -149,7 +149,7 @@ int b43_sysfs_register(struct b43_wldev *wldev)
void b43_sysfs_unregister(struct b43_wldev *wldev) void b43_sysfs_unregister(struct b43_wldev *wldev)
{ {
struct device *dev = wldev->sdev->dev; struct device *dev = wldev->dev->dev;
device_remove_file(dev, &dev_attr_interference); device_remove_file(dev, &dev_attr_interference);
} }
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