diff options
author | Russell King <rmk@dyn-67.arm.linux.org.uk> | 2007-02-12 05:28:24 -0500 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2007-02-12 05:28:24 -0500 |
commit | ab2c21529df6ee0f06787773882a1abc6bc2d665 (patch) | |
tree | 9ad875a78ea5122a8b0388dd8fe1d3e2c9e6d948 /arch/arm/common | |
parent | 44b18693904e65d840ae999ac8aa717551cf509f (diff) |
[ARM] Add a reference from struct device to the dma bounce info
dmabounce keeps a per-device structure, and finds the correct
structure by walking a list. Since architectures can now add
fields to struct device, we can attach this structure direct to
the struct device, thereby eliminating the code to search the
list.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/common')
-rw-r--r-- | arch/arm/common/dmabounce.c | 31 |
1 files changed, 7 insertions, 24 deletions
diff --git a/arch/arm/common/dmabounce.c b/arch/arm/common/dmabounce.c index 2e635b814c14..490e1fe286d5 100644 --- a/arch/arm/common/dmabounce.c +++ b/arch/arm/common/dmabounce.c | |||
@@ -66,8 +66,6 @@ struct dmabounce_pool { | |||
66 | }; | 66 | }; |
67 | 67 | ||
68 | struct dmabounce_device_info { | 68 | struct dmabounce_device_info { |
69 | struct list_head node; | ||
70 | |||
71 | struct device *dev; | 69 | struct device *dev; |
72 | struct list_head safe_buffers; | 70 | struct list_head safe_buffers; |
73 | #ifdef STATS | 71 | #ifdef STATS |
@@ -81,8 +79,6 @@ struct dmabounce_device_info { | |||
81 | rwlock_t lock; | 79 | rwlock_t lock; |
82 | }; | 80 | }; |
83 | 81 | ||
84 | static LIST_HEAD(dmabounce_devs); | ||
85 | |||
86 | #ifdef STATS | 82 | #ifdef STATS |
87 | static void print_alloc_stats(struct dmabounce_device_info *device_info) | 83 | static void print_alloc_stats(struct dmabounce_device_info *device_info) |
88 | { | 84 | { |
@@ -96,19 +92,6 @@ static void print_alloc_stats(struct dmabounce_device_info *device_info) | |||
96 | } | 92 | } |
97 | #endif | 93 | #endif |
98 | 94 | ||
99 | /* find the given device in the dmabounce device list */ | ||
100 | static inline struct dmabounce_device_info * | ||
101 | find_dmabounce_dev(struct device *dev) | ||
102 | { | ||
103 | struct dmabounce_device_info *d; | ||
104 | |||
105 | list_for_each_entry(d, &dmabounce_devs, node) | ||
106 | if (d->dev == dev) | ||
107 | return d; | ||
108 | |||
109 | return NULL; | ||
110 | } | ||
111 | |||
112 | 95 | ||
113 | /* allocate a 'safe' buffer and keep track of it */ | 96 | /* allocate a 'safe' buffer and keep track of it */ |
114 | static inline struct safe_buffer * | 97 | static inline struct safe_buffer * |
@@ -231,7 +214,7 @@ static inline dma_addr_t | |||
231 | map_single(struct device *dev, void *ptr, size_t size, | 214 | map_single(struct device *dev, void *ptr, size_t size, |
232 | enum dma_data_direction dir) | 215 | enum dma_data_direction dir) |
233 | { | 216 | { |
234 | struct dmabounce_device_info *device_info = find_dmabounce_dev(dev); | 217 | struct dmabounce_device_info *device_info = dev->archdata.dmabounce; |
235 | dma_addr_t dma_addr; | 218 | dma_addr_t dma_addr; |
236 | int needs_bounce = 0; | 219 | int needs_bounce = 0; |
237 | 220 | ||
@@ -292,7 +275,7 @@ static inline void | |||
292 | unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size, | 275 | unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size, |
293 | enum dma_data_direction dir) | 276 | enum dma_data_direction dir) |
294 | { | 277 | { |
295 | struct dmabounce_device_info *device_info = find_dmabounce_dev(dev); | 278 | struct dmabounce_device_info *device_info = dev->archdata.dmabounce; |
296 | struct safe_buffer *buf = NULL; | 279 | struct safe_buffer *buf = NULL; |
297 | 280 | ||
298 | /* | 281 | /* |
@@ -343,7 +326,7 @@ static inline void | |||
343 | sync_single(struct device *dev, dma_addr_t dma_addr, size_t size, | 326 | sync_single(struct device *dev, dma_addr_t dma_addr, size_t size, |
344 | enum dma_data_direction dir) | 327 | enum dma_data_direction dir) |
345 | { | 328 | { |
346 | struct dmabounce_device_info *device_info = find_dmabounce_dev(dev); | 329 | struct dmabounce_device_info *device_info = dev->archdata.dmabounce; |
347 | struct safe_buffer *buf = NULL; | 330 | struct safe_buffer *buf = NULL; |
348 | 331 | ||
349 | if (device_info) | 332 | if (device_info) |
@@ -606,7 +589,7 @@ dmabounce_register_dev(struct device *dev, unsigned long small_buffer_size, | |||
606 | device_info->bounce_count = 0; | 589 | device_info->bounce_count = 0; |
607 | #endif | 590 | #endif |
608 | 591 | ||
609 | list_add(&device_info->node, &dmabounce_devs); | 592 | dev->archdata.dmabounce = device_info; |
610 | 593 | ||
611 | printk(KERN_INFO "dmabounce: registered device %s on %s bus\n", | 594 | printk(KERN_INFO "dmabounce: registered device %s on %s bus\n", |
612 | dev->bus_id, dev->bus->name); | 595 | dev->bus_id, dev->bus->name); |
@@ -623,7 +606,9 @@ dmabounce_register_dev(struct device *dev, unsigned long small_buffer_size, | |||
623 | void | 606 | void |
624 | dmabounce_unregister_dev(struct device *dev) | 607 | dmabounce_unregister_dev(struct device *dev) |
625 | { | 608 | { |
626 | struct dmabounce_device_info *device_info = find_dmabounce_dev(dev); | 609 | struct dmabounce_device_info *device_info = dev->archdata.dmabounce; |
610 | |||
611 | dev->archdata.dmabounce = NULL; | ||
627 | 612 | ||
628 | if (!device_info) { | 613 | if (!device_info) { |
629 | printk(KERN_WARNING | 614 | printk(KERN_WARNING |
@@ -649,8 +634,6 @@ dmabounce_unregister_dev(struct device *dev) | |||
649 | print_map_stats(device_info); | 634 | print_map_stats(device_info); |
650 | #endif | 635 | #endif |
651 | 636 | ||
652 | list_del(&device_info->node); | ||
653 | |||
654 | kfree(device_info); | 637 | kfree(device_info); |
655 | 638 | ||
656 | printk(KERN_INFO "dmabounce: device %s on %s bus unregistered\n", | 639 | printk(KERN_INFO "dmabounce: device %s on %s bus unregistered\n", |