[ARM] Add a reference from struct device to the dma bounce info
authorRussell King <rmk@dyn-67.arm.linux.org.uk>
Mon, 12 Feb 2007 10:28:24 +0000 (10:28 +0000)
committerRussell King <rmk+kernel@arm.linux.org.uk>
Mon, 12 Feb 2007 10:28:24 +0000 (10:28 +0000)
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>
arch/arm/common/dmabounce.c
include/asm-arm/device.h

index 2e635b814c14b06dd7cf84cbba4ccc2afd72cf58..490e1fe286d5ce164b991125fa0af3454fe3c28c 100644 (file)
@@ -66,8 +66,6 @@ struct dmabounce_pool {
 };
 
 struct dmabounce_device_info {
-       struct list_head node;
-
        struct device *dev;
        struct list_head safe_buffers;
 #ifdef STATS
@@ -81,8 +79,6 @@ struct dmabounce_device_info {
        rwlock_t lock;
 };
 
-static LIST_HEAD(dmabounce_devs);
-
 #ifdef STATS
 static void print_alloc_stats(struct dmabounce_device_info *device_info)
 {
@@ -96,19 +92,6 @@ static void print_alloc_stats(struct dmabounce_device_info *device_info)
 }
 #endif
 
-/* find the given device in the dmabounce device list */
-static inline struct dmabounce_device_info *
-find_dmabounce_dev(struct device *dev)
-{
-       struct dmabounce_device_info *d;
-
-       list_for_each_entry(d, &dmabounce_devs, node)
-               if (d->dev == dev)
-                       return d;
-
-       return NULL;
-}
-
 
 /* allocate a 'safe' buffer and keep track of it */
 static inline struct safe_buffer *
@@ -231,7 +214,7 @@ static inline dma_addr_t
 map_single(struct device *dev, void *ptr, size_t size,
                enum dma_data_direction dir)
 {
-       struct dmabounce_device_info *device_info = find_dmabounce_dev(dev);
+       struct dmabounce_device_info *device_info = dev->archdata.dmabounce;
        dma_addr_t dma_addr;
        int needs_bounce = 0;
 
@@ -292,7 +275,7 @@ static inline void
 unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size,
                enum dma_data_direction dir)
 {
-       struct dmabounce_device_info *device_info = find_dmabounce_dev(dev);
+       struct dmabounce_device_info *device_info = dev->archdata.dmabounce;
        struct safe_buffer *buf = NULL;
 
        /*
@@ -343,7 +326,7 @@ static inline void
 sync_single(struct device *dev, dma_addr_t dma_addr, size_t size,
                enum dma_data_direction dir)
 {
-       struct dmabounce_device_info *device_info = find_dmabounce_dev(dev);
+       struct dmabounce_device_info *device_info = dev->archdata.dmabounce;
        struct safe_buffer *buf = NULL;
 
        if (device_info)
@@ -606,7 +589,7 @@ dmabounce_register_dev(struct device *dev, unsigned long small_buffer_size,
        device_info->bounce_count = 0;
 #endif
 
-       list_add(&device_info->node, &dmabounce_devs);
+       dev->archdata.dmabounce = device_info;
 
        printk(KERN_INFO "dmabounce: registered device %s on %s bus\n",
                dev->bus_id, dev->bus->name);
@@ -623,7 +606,9 @@ dmabounce_register_dev(struct device *dev, unsigned long small_buffer_size,
 void
 dmabounce_unregister_dev(struct device *dev)
 {
-       struct dmabounce_device_info *device_info = find_dmabounce_dev(dev);
+       struct dmabounce_device_info *device_info = dev->archdata.dmabounce;
+
+       dev->archdata.dmabounce = NULL;
 
        if (!device_info) {
                printk(KERN_WARNING
@@ -649,8 +634,6 @@ dmabounce_unregister_dev(struct device *dev)
        print_map_stats(device_info);
 #endif
 
-       list_del(&device_info->node);
-
        kfree(device_info);
 
        printk(KERN_INFO "dmabounce: device %s on %s bus unregistered\n",
index d8f9872b0e2dc3587a9e658adc957f093b7906fb..c61642b406033659db06494a75fcb4c8d8914477 100644 (file)
@@ -3,5 +3,13 @@
  *
  * This file is released under the GPLv2
  */
-#include <asm-generic/device.h>
+#ifndef ASMARM_DEVICE_H
+#define ASMARM_DEVICE_H
 
+struct dev_archdata {
+#ifdef CONFIG_DMABOUNCE
+       struct dmabounce_device_info *dmabounce;
+#endif
+};
+
+#endif