Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[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>

authored by

Russell King and committed by
Russell King
ab2c2152 44b18693

+16 -25
+7 -24
arch/arm/common/dmabounce.c
··· 66 66 }; 67 67 68 68 struct dmabounce_device_info { 69 - struct list_head node; 70 - 71 69 struct device *dev; 72 70 struct list_head safe_buffers; 73 71 #ifdef STATS ··· 79 81 rwlock_t lock; 80 82 }; 81 83 82 - static LIST_HEAD(dmabounce_devs); 83 - 84 84 #ifdef STATS 85 85 static void print_alloc_stats(struct dmabounce_device_info *device_info) 86 86 { ··· 91 95 device_info->total_allocs); 92 96 } 93 97 #endif 94 - 95 - /* find the given device in the dmabounce device list */ 96 - static inline struct dmabounce_device_info * 97 - find_dmabounce_dev(struct device *dev) 98 - { 99 - struct dmabounce_device_info *d; 100 - 101 - list_for_each_entry(d, &dmabounce_devs, node) 102 - if (d->dev == dev) 103 - return d; 104 - 105 - return NULL; 106 - } 107 98 108 99 109 100 /* allocate a 'safe' buffer and keep track of it */ ··· 214 231 map_single(struct device *dev, void *ptr, size_t size, 215 232 enum dma_data_direction dir) 216 233 { 217 - struct dmabounce_device_info *device_info = find_dmabounce_dev(dev); 234 + struct dmabounce_device_info *device_info = dev->archdata.dmabounce; 218 235 dma_addr_t dma_addr; 219 236 int needs_bounce = 0; 220 237 ··· 275 292 unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size, 276 293 enum dma_data_direction dir) 277 294 { 278 - struct dmabounce_device_info *device_info = find_dmabounce_dev(dev); 295 + struct dmabounce_device_info *device_info = dev->archdata.dmabounce; 279 296 struct safe_buffer *buf = NULL; 280 297 281 298 /* ··· 326 343 sync_single(struct device *dev, dma_addr_t dma_addr, size_t size, 327 344 enum dma_data_direction dir) 328 345 { 329 - struct dmabounce_device_info *device_info = find_dmabounce_dev(dev); 346 + struct dmabounce_device_info *device_info = dev->archdata.dmabounce; 330 347 struct safe_buffer *buf = NULL; 331 348 332 349 if (device_info) ··· 589 606 device_info->bounce_count = 0; 590 607 #endif 591 608 592 - list_add(&device_info->node, &dmabounce_devs); 609 + dev->archdata.dmabounce = device_info; 593 610 594 611 printk(KERN_INFO "dmabounce: registered device %s on %s bus\n", 595 612 dev->bus_id, dev->bus->name); ··· 606 623 void 607 624 dmabounce_unregister_dev(struct device *dev) 608 625 { 609 - struct dmabounce_device_info *device_info = find_dmabounce_dev(dev); 626 + struct dmabounce_device_info *device_info = dev->archdata.dmabounce; 627 + 628 + dev->archdata.dmabounce = NULL; 610 629 611 630 if (!device_info) { 612 631 printk(KERN_WARNING ··· 633 648 print_alloc_stats(device_info); 634 649 print_map_stats(device_info); 635 650 #endif 636 - 637 - list_del(&device_info->node); 638 651 639 652 kfree(device_info); 640 653
+9 -1
include/asm-arm/device.h
··· 3 3 * 4 4 * This file is released under the GPLv2 5 5 */ 6 - #include <asm-generic/device.h> 6 + #ifndef ASMARM_DEVICE_H 7 + #define ASMARM_DEVICE_H 7 8 9 + struct dev_archdata { 10 + #ifdef CONFIG_DMABOUNCE 11 + struct dmabounce_device_info *dmabounce; 12 + #endif 13 + }; 14 + 15 + #endif