diff options
author | Tony Jones <tonyj@suse.de> | 2007-09-24 20:03:03 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2008-01-24 23:40:05 -0500 |
commit | 891f78ea833edd4a1e524e15bfe297a7a84d81a0 (patch) | |
tree | 533f12df743c4adc6d2b40d048ffb7d16c93e591 | |
parent | 62ca8792560e5bd7dc09f54ed3523a7864f416c7 (diff) |
DMA: Convert from class_device to device for DMA engine
Signed-off-by: Tony Jones <tonyj@suse.de>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Cc: Shannon Nelson <shannon.nelson@intel.com>
Cc: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r-- | drivers/dma/dmaengine.c | 43 | ||||
-rw-r--r-- | include/linux/dmaengine.h | 3 |
2 files changed, 24 insertions, 22 deletions
diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c index d59b2f417306..bcf52df30339 100644 --- a/drivers/dma/dmaengine.c +++ b/drivers/dma/dmaengine.c | |||
@@ -41,12 +41,12 @@ | |||
41 | * the definition of dma_event_callback in dmaengine.h. | 41 | * the definition of dma_event_callback in dmaengine.h. |
42 | * | 42 | * |
43 | * Each device has a kref, which is initialized to 1 when the device is | 43 | * Each device has a kref, which is initialized to 1 when the device is |
44 | * registered. A kref_get is done for each class_device registered. When the | 44 | * registered. A kref_get is done for each device registered. When the |
45 | * class_device is released, the coresponding kref_put is done in the release | 45 | * device is released, the coresponding kref_put is done in the release |
46 | * method. Every time one of the device's channels is allocated to a client, | 46 | * method. Every time one of the device's channels is allocated to a client, |
47 | * a kref_get occurs. When the channel is freed, the coresponding kref_put | 47 | * a kref_get occurs. When the channel is freed, the coresponding kref_put |
48 | * happens. The device's release function does a completion, so | 48 | * happens. The device's release function does a completion, so |
49 | * unregister_device does a remove event, class_device_unregister, a kref_put | 49 | * unregister_device does a remove event, device_unregister, a kref_put |
50 | * for the first reference, then waits on the completion for all other | 50 | * for the first reference, then waits on the completion for all other |
51 | * references to finish. | 51 | * references to finish. |
52 | * | 52 | * |
@@ -77,9 +77,9 @@ static LIST_HEAD(dma_client_list); | |||
77 | 77 | ||
78 | /* --- sysfs implementation --- */ | 78 | /* --- sysfs implementation --- */ |
79 | 79 | ||
80 | static ssize_t show_memcpy_count(struct class_device *cd, char *buf) | 80 | static ssize_t show_memcpy_count(struct device *dev, struct device_attribute *attr, char *buf) |
81 | { | 81 | { |
82 | struct dma_chan *chan = container_of(cd, struct dma_chan, class_dev); | 82 | struct dma_chan *chan = to_dma_chan(dev); |
83 | unsigned long count = 0; | 83 | unsigned long count = 0; |
84 | int i; | 84 | int i; |
85 | 85 | ||
@@ -89,9 +89,10 @@ static ssize_t show_memcpy_count(struct class_device *cd, char *buf) | |||
89 | return sprintf(buf, "%lu\n", count); | 89 | return sprintf(buf, "%lu\n", count); |
90 | } | 90 | } |
91 | 91 | ||
92 | static ssize_t show_bytes_transferred(struct class_device *cd, char *buf) | 92 | static ssize_t show_bytes_transferred(struct device *dev, struct device_attribute *attr, |
93 | char *buf) | ||
93 | { | 94 | { |
94 | struct dma_chan *chan = container_of(cd, struct dma_chan, class_dev); | 95 | struct dma_chan *chan = to_dma_chan(dev); |
95 | unsigned long count = 0; | 96 | unsigned long count = 0; |
96 | int i; | 97 | int i; |
97 | 98 | ||
@@ -101,9 +102,9 @@ static ssize_t show_bytes_transferred(struct class_device *cd, char *buf) | |||
101 | return sprintf(buf, "%lu\n", count); | 102 | return sprintf(buf, "%lu\n", count); |
102 | } | 103 | } |
103 | 104 | ||
104 | static ssize_t show_in_use(struct class_device *cd, char *buf) | 105 | static ssize_t show_in_use(struct device *dev, struct device_attribute *attr, char *buf) |
105 | { | 106 | { |
106 | struct dma_chan *chan = container_of(cd, struct dma_chan, class_dev); | 107 | struct dma_chan *chan = to_dma_chan(dev); |
107 | int in_use = 0; | 108 | int in_use = 0; |
108 | 109 | ||
109 | if (unlikely(chan->slow_ref) && | 110 | if (unlikely(chan->slow_ref) && |
@@ -119,7 +120,7 @@ static ssize_t show_in_use(struct class_device *cd, char *buf) | |||
119 | return sprintf(buf, "%d\n", in_use); | 120 | return sprintf(buf, "%d\n", in_use); |
120 | } | 121 | } |
121 | 122 | ||
122 | static struct class_device_attribute dma_class_attrs[] = { | 123 | static struct device_attribute dma_attrs[] = { |
123 | __ATTR(memcpy_count, S_IRUGO, show_memcpy_count, NULL), | 124 | __ATTR(memcpy_count, S_IRUGO, show_memcpy_count, NULL), |
124 | __ATTR(bytes_transferred, S_IRUGO, show_bytes_transferred, NULL), | 125 | __ATTR(bytes_transferred, S_IRUGO, show_bytes_transferred, NULL), |
125 | __ATTR(in_use, S_IRUGO, show_in_use, NULL), | 126 | __ATTR(in_use, S_IRUGO, show_in_use, NULL), |
@@ -128,16 +129,16 @@ static struct class_device_attribute dma_class_attrs[] = { | |||
128 | 129 | ||
129 | static void dma_async_device_cleanup(struct kref *kref); | 130 | static void dma_async_device_cleanup(struct kref *kref); |
130 | 131 | ||
131 | static void dma_class_dev_release(struct class_device *cd) | 132 | static void dma_dev_release(struct device *dev) |
132 | { | 133 | { |
133 | struct dma_chan *chan = container_of(cd, struct dma_chan, class_dev); | 134 | struct dma_chan *chan = to_dma_chan(dev); |
134 | kref_put(&chan->device->refcount, dma_async_device_cleanup); | 135 | kref_put(&chan->device->refcount, dma_async_device_cleanup); |
135 | } | 136 | } |
136 | 137 | ||
137 | static struct class dma_devclass = { | 138 | static struct class dma_devclass = { |
138 | .name = "dma", | 139 | .name = "dma", |
139 | .class_dev_attrs = dma_class_attrs, | 140 | .dev_attrs = dma_attrs, |
140 | .release = dma_class_dev_release, | 141 | .dev_release = dma_dev_release, |
141 | }; | 142 | }; |
142 | 143 | ||
143 | /* --- client and device registration --- */ | 144 | /* --- client and device registration --- */ |
@@ -377,12 +378,12 @@ int dma_async_device_register(struct dma_device *device) | |||
377 | continue; | 378 | continue; |
378 | 379 | ||
379 | chan->chan_id = chancnt++; | 380 | chan->chan_id = chancnt++; |
380 | chan->class_dev.class = &dma_devclass; | 381 | chan->dev.class = &dma_devclass; |
381 | chan->class_dev.dev = NULL; | 382 | chan->dev.parent = NULL; |
382 | snprintf(chan->class_dev.class_id, BUS_ID_SIZE, "dma%dchan%d", | 383 | snprintf(chan->dev.bus_id, BUS_ID_SIZE, "dma%dchan%d", |
383 | device->dev_id, chan->chan_id); | 384 | device->dev_id, chan->chan_id); |
384 | 385 | ||
385 | rc = class_device_register(&chan->class_dev); | 386 | rc = device_register(&chan->dev); |
386 | if (rc) { | 387 | if (rc) { |
387 | chancnt--; | 388 | chancnt--; |
388 | free_percpu(chan->local); | 389 | free_percpu(chan->local); |
@@ -411,7 +412,7 @@ err_out: | |||
411 | if (chan->local == NULL) | 412 | if (chan->local == NULL) |
412 | continue; | 413 | continue; |
413 | kref_put(&device->refcount, dma_async_device_cleanup); | 414 | kref_put(&device->refcount, dma_async_device_cleanup); |
414 | class_device_unregister(&chan->class_dev); | 415 | device_unregister(&chan->dev); |
415 | chancnt--; | 416 | chancnt--; |
416 | free_percpu(chan->local); | 417 | free_percpu(chan->local); |
417 | } | 418 | } |
@@ -445,7 +446,7 @@ void dma_async_device_unregister(struct dma_device *device) | |||
445 | 446 | ||
446 | list_for_each_entry(chan, &device->channels, device_node) { | 447 | list_for_each_entry(chan, &device->channels, device_node) { |
447 | dma_clients_notify_removed(chan); | 448 | dma_clients_notify_removed(chan); |
448 | class_device_unregister(&chan->class_dev); | 449 | device_unregister(&chan->dev); |
449 | dma_chan_release(chan); | 450 | dma_chan_release(chan); |
450 | } | 451 | } |
451 | 452 | ||
diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h index a3b6035b6c86..55c9a6952f44 100644 --- a/include/linux/dmaengine.h +++ b/include/linux/dmaengine.h | |||
@@ -132,7 +132,7 @@ struct dma_chan { | |||
132 | 132 | ||
133 | /* sysfs */ | 133 | /* sysfs */ |
134 | int chan_id; | 134 | int chan_id; |
135 | struct class_device class_dev; | 135 | struct device dev; |
136 | 136 | ||
137 | struct kref refcount; | 137 | struct kref refcount; |
138 | int slow_ref; | 138 | int slow_ref; |
@@ -142,6 +142,7 @@ struct dma_chan { | |||
142 | struct dma_chan_percpu *local; | 142 | struct dma_chan_percpu *local; |
143 | }; | 143 | }; |
144 | 144 | ||
145 | #define to_dma_chan(p) container_of(p, struct dma_chan, dev) | ||
145 | 146 | ||
146 | void dma_chan_cleanup(struct kref *kref); | 147 | void dma_chan_cleanup(struct kref *kref); |
147 | 148 | ||