Commit 891f78ea authored by Tony Jones's avatar Tony Jones Committed by Greg Kroah-Hartman

DMA: Convert from class_device to device for DMA engine

Signed-off-by: default avatarTony Jones <tonyj@suse.de>
Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
Cc: Shannon Nelson <shannon.nelson@intel.com>
Cc: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 62ca8792
...@@ -41,12 +41,12 @@ ...@@ -41,12 +41,12 @@
* the definition of dma_event_callback in dmaengine.h. * the definition of dma_event_callback in dmaengine.h.
* *
* Each device has a kref, which is initialized to 1 when the device is * Each device has a kref, which is initialized to 1 when the device is
* registered. A kref_get is done for each class_device registered. When the * registered. A kref_get is done for each device registered. When the
* class_device is released, the coresponding kref_put is done in the release * device is released, the coresponding kref_put is done in the release
* method. Every time one of the device's channels is allocated to a client, * method. Every time one of the device's channels is allocated to a client,
* a kref_get occurs. When the channel is freed, the coresponding kref_put * a kref_get occurs. When the channel is freed, the coresponding kref_put
* happens. The device's release function does a completion, so * happens. The device's release function does a completion, so
* unregister_device does a remove event, class_device_unregister, a kref_put * unregister_device does a remove event, device_unregister, a kref_put
* for the first reference, then waits on the completion for all other * for the first reference, then waits on the completion for all other
* references to finish. * references to finish.
* *
...@@ -77,9 +77,9 @@ static LIST_HEAD(dma_client_list); ...@@ -77,9 +77,9 @@ static LIST_HEAD(dma_client_list);
/* --- sysfs implementation --- */ /* --- sysfs implementation --- */
static ssize_t show_memcpy_count(struct class_device *cd, char *buf) static ssize_t show_memcpy_count(struct device *dev, struct device_attribute *attr, char *buf)
{ {
struct dma_chan *chan = container_of(cd, struct dma_chan, class_dev); struct dma_chan *chan = to_dma_chan(dev);
unsigned long count = 0; unsigned long count = 0;
int i; int i;
...@@ -89,9 +89,10 @@ static ssize_t show_memcpy_count(struct class_device *cd, char *buf) ...@@ -89,9 +89,10 @@ static ssize_t show_memcpy_count(struct class_device *cd, char *buf)
return sprintf(buf, "%lu\n", count); return sprintf(buf, "%lu\n", count);
} }
static ssize_t show_bytes_transferred(struct class_device *cd, char *buf) static ssize_t show_bytes_transferred(struct device *dev, struct device_attribute *attr,
char *buf)
{ {
struct dma_chan *chan = container_of(cd, struct dma_chan, class_dev); struct dma_chan *chan = to_dma_chan(dev);
unsigned long count = 0; unsigned long count = 0;
int i; int i;
...@@ -101,9 +102,9 @@ static ssize_t show_bytes_transferred(struct class_device *cd, char *buf) ...@@ -101,9 +102,9 @@ static ssize_t show_bytes_transferred(struct class_device *cd, char *buf)
return sprintf(buf, "%lu\n", count); return sprintf(buf, "%lu\n", count);
} }
static ssize_t show_in_use(struct class_device *cd, char *buf) static ssize_t show_in_use(struct device *dev, struct device_attribute *attr, char *buf)
{ {
struct dma_chan *chan = container_of(cd, struct dma_chan, class_dev); struct dma_chan *chan = to_dma_chan(dev);
int in_use = 0; int in_use = 0;
if (unlikely(chan->slow_ref) && if (unlikely(chan->slow_ref) &&
...@@ -119,7 +120,7 @@ static ssize_t show_in_use(struct class_device *cd, char *buf) ...@@ -119,7 +120,7 @@ static ssize_t show_in_use(struct class_device *cd, char *buf)
return sprintf(buf, "%d\n", in_use); return sprintf(buf, "%d\n", in_use);
} }
static struct class_device_attribute dma_class_attrs[] = { static struct device_attribute dma_attrs[] = {
__ATTR(memcpy_count, S_IRUGO, show_memcpy_count, NULL), __ATTR(memcpy_count, S_IRUGO, show_memcpy_count, NULL),
__ATTR(bytes_transferred, S_IRUGO, show_bytes_transferred, NULL), __ATTR(bytes_transferred, S_IRUGO, show_bytes_transferred, NULL),
__ATTR(in_use, S_IRUGO, show_in_use, NULL), __ATTR(in_use, S_IRUGO, show_in_use, NULL),
...@@ -128,16 +129,16 @@ static struct class_device_attribute dma_class_attrs[] = { ...@@ -128,16 +129,16 @@ static struct class_device_attribute dma_class_attrs[] = {
static void dma_async_device_cleanup(struct kref *kref); static void dma_async_device_cleanup(struct kref *kref);
static void dma_class_dev_release(struct class_device *cd) static void dma_dev_release(struct device *dev)
{ {
struct dma_chan *chan = container_of(cd, struct dma_chan, class_dev); struct dma_chan *chan = to_dma_chan(dev);
kref_put(&chan->device->refcount, dma_async_device_cleanup); kref_put(&chan->device->refcount, dma_async_device_cleanup);
} }
static struct class dma_devclass = { static struct class dma_devclass = {
.name = "dma", .name = "dma",
.class_dev_attrs = dma_class_attrs, .dev_attrs = dma_attrs,
.release = dma_class_dev_release, .dev_release = dma_dev_release,
}; };
/* --- client and device registration --- */ /* --- client and device registration --- */
...@@ -377,12 +378,12 @@ int dma_async_device_register(struct dma_device *device) ...@@ -377,12 +378,12 @@ int dma_async_device_register(struct dma_device *device)
continue; continue;
chan->chan_id = chancnt++; chan->chan_id = chancnt++;
chan->class_dev.class = &dma_devclass; chan->dev.class = &dma_devclass;
chan->class_dev.dev = NULL; chan->dev.parent = NULL;
snprintf(chan->class_dev.class_id, BUS_ID_SIZE, "dma%dchan%d", snprintf(chan->dev.bus_id, BUS_ID_SIZE, "dma%dchan%d",
device->dev_id, chan->chan_id); device->dev_id, chan->chan_id);
rc = class_device_register(&chan->class_dev); rc = device_register(&chan->dev);
if (rc) { if (rc) {
chancnt--; chancnt--;
free_percpu(chan->local); free_percpu(chan->local);
...@@ -411,7 +412,7 @@ err_out: ...@@ -411,7 +412,7 @@ err_out:
if (chan->local == NULL) if (chan->local == NULL)
continue; continue;
kref_put(&device->refcount, dma_async_device_cleanup); kref_put(&device->refcount, dma_async_device_cleanup);
class_device_unregister(&chan->class_dev); device_unregister(&chan->dev);
chancnt--; chancnt--;
free_percpu(chan->local); free_percpu(chan->local);
} }
...@@ -445,7 +446,7 @@ void dma_async_device_unregister(struct dma_device *device) ...@@ -445,7 +446,7 @@ void dma_async_device_unregister(struct dma_device *device)
list_for_each_entry(chan, &device->channels, device_node) { list_for_each_entry(chan, &device->channels, device_node) {
dma_clients_notify_removed(chan); dma_clients_notify_removed(chan);
class_device_unregister(&chan->class_dev); device_unregister(&chan->dev);
dma_chan_release(chan); dma_chan_release(chan);
} }
......
...@@ -132,7 +132,7 @@ struct dma_chan { ...@@ -132,7 +132,7 @@ struct dma_chan {
/* sysfs */ /* sysfs */
int chan_id; int chan_id;
struct class_device class_dev; struct device dev;
struct kref refcount; struct kref refcount;
int slow_ref; int slow_ref;
...@@ -142,6 +142,7 @@ struct dma_chan { ...@@ -142,6 +142,7 @@ struct dma_chan {
struct dma_chan_percpu *local; struct dma_chan_percpu *local;
}; };
#define to_dma_chan(p) container_of(p, struct dma_chan, dev)
void dma_chan_cleanup(struct kref *kref); void dma_chan_cleanup(struct kref *kref);
......
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