aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/iio/industrialio-ring.c
diff options
context:
space:
mode:
authorJonathan Cameron <jic23@cam.ac.uk>2011-05-18 14:40:57 +0100
committerGreg Kroah-Hartman <gregkh@suse.de>2011-05-19 16:06:12 -0700
commit3feb07979c4d5b63d5e15ef01c97018a6d0db5b3 (patch)
tree3c4851b70649d964f155ea849ce2f5c102bc8b48 /drivers/staging/iio/industrialio-ring.c
parentb9d40a9d5583a530372b4e1888e4f643ed05aca6 (diff)
downloadkernel_samsung_smdk4412-3feb07979c4d5b63d5e15ef01c97018a6d0db5b3.zip
kernel_samsung_smdk4412-3feb07979c4d5b63d5e15ef01c97018a6d0db5b3.tar.gz
kernel_samsung_smdk4412-3feb07979c4d5b63d5e15ef01c97018a6d0db5b3.tar.bz2
staging:iio: Buffer device flattening.
Given we now only have one device we don't need the extra layer any more. Hence this patch removes it. Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging/iio/industrialio-ring.c')
-rw-r--r--drivers/staging/iio/industrialio-ring.c76
1 files changed, 25 insertions, 51 deletions
diff --git a/drivers/staging/iio/industrialio-ring.c b/drivers/staging/iio/industrialio-ring.c
index 559d613..625263e 100644
--- a/drivers/staging/iio/industrialio-ring.c
+++ b/drivers/staging/iio/industrialio-ring.c
@@ -106,72 +106,60 @@ static const struct file_operations iio_ring_fileops = {
.llseek = noop_llseek,
};
-static void iio_ring_access_release(struct device *dev)
+void iio_ring_access_release(struct device *dev)
{
struct iio_ring_buffer *buf
- = access_dev_to_iio_ring_buffer(dev);
+ = container_of(dev, struct iio_ring_buffer, dev);
cdev_del(&buf->access_handler.chrdev);
iio_device_free_chrdev_minor(MINOR(dev->devt));
}
-
-static struct device_type iio_ring_access_type = {
- .release = iio_ring_access_release,
-};
+EXPORT_SYMBOL(iio_ring_access_release);
static inline int
-__iio_request_ring_buffer_access_chrdev(struct iio_ring_buffer *buf,
- int id,
+__iio_request_ring_buffer_chrdev(struct iio_ring_buffer *buf,
struct module *owner)
{
int ret, minor;
buf->access_handler.flags = 0;
- buf->access_dev.parent = &buf->dev;
- buf->access_dev.bus = &iio_bus_type;
- buf->access_dev.type = &iio_ring_access_type;
- device_initialize(&buf->access_dev);
+ buf->dev.bus = &iio_bus_type;
+ device_initialize(&buf->dev);
minor = iio_device_get_chrdev_minor();
if (minor < 0) {
ret = minor;
goto error_device_put;
}
- buf->access_dev.devt = MKDEV(MAJOR(iio_devt), minor);
-
-
- buf->access_id = id;
-
- dev_set_name(&buf->access_dev, "%s:access%d",
- dev_name(&buf->dev),
- buf->access_id);
- ret = device_add(&buf->access_dev);
+ buf->dev.devt = MKDEV(MAJOR(iio_devt), minor);
+ dev_set_name(&buf->dev, "%s:buffer%d",
+ dev_name(buf->dev.parent),
+ buf->id);
+ ret = device_add(&buf->dev);
if (ret < 0) {
- printk(KERN_ERR "failed to add the ring access dev\n");
+ printk(KERN_ERR "failed to add the ring dev\n");
goto error_device_put;
}
-
cdev_init(&buf->access_handler.chrdev, &iio_ring_fileops);
buf->access_handler.chrdev.owner = owner;
-
- ret = cdev_add(&buf->access_handler.chrdev, buf->access_dev.devt, 1);
+ ret = cdev_add(&buf->access_handler.chrdev, buf->dev.devt, 1);
if (ret) {
- printk(KERN_ERR "failed to allocate ring access chrdev\n");
+ printk(KERN_ERR "failed to allocate ring chrdev\n");
goto error_device_unregister;
}
return 0;
error_device_unregister:
- device_unregister(&buf->access_dev);
+ device_unregister(&buf->dev);
error_device_put:
- put_device(&buf->access_dev);
+ put_device(&buf->dev);
return ret;
}
-static void __iio_free_ring_buffer_access_chrdev(struct iio_ring_buffer *buf)
+static void __iio_free_ring_buffer_chrdev(struct iio_ring_buffer *buf)
{
- device_unregister(&buf->access_dev);
+ device_unregister(&buf->dev);
}
void iio_ring_buffer_init(struct iio_ring_buffer *ring,
@@ -344,36 +332,25 @@ int iio_ring_buffer_register_ex(struct iio_ring_buffer *ring, int id,
ring->id = id;
- dev_set_name(&ring->dev, "%s:buffer%d",
- dev_name(ring->dev.parent),
- ring->id);
- ret = device_add(&ring->dev);
- if (ret)
- goto error_ret;
-
- ret = __iio_request_ring_buffer_access_chrdev(ring,
- 0,
- ring->owner);
+ ret = __iio_request_ring_buffer_chrdev(ring, ring->owner);
if (ret)
- goto error_remove_device;
-
+ goto error_ret;
if (ring->scan_el_attrs) {
ret = sysfs_create_group(&ring->dev.kobj,
ring->scan_el_attrs);
if (ret) {
dev_err(&ring->dev,
"Failed to add sysfs scan elements\n");
- goto error_free_ring_buffer_access_chrdev;
+ goto error_free_ring_buffer_chrdev;
}
} else if (channels) {
ret = sysfs_create_group(&ring->dev.kobj,
&iio_scan_el_dummy_group);
if (ret)
- goto error_free_ring_buffer_access_chrdev;
+ goto error_free_ring_buffer_chrdev;
}
-
INIT_LIST_HEAD(&ring->scan_el_dev_attr_list);
INIT_LIST_HEAD(&ring->scan_el_en_attr_list);
if (channels) {
@@ -388,10 +365,8 @@ int iio_ring_buffer_register_ex(struct iio_ring_buffer *ring, int id,
return 0;
error_cleanup_dynamic:
__iio_ring_attr_cleanup(ring);
-error_free_ring_buffer_access_chrdev:
- __iio_free_ring_buffer_access_chrdev(ring);
-error_remove_device:
- device_del(&ring->dev);
+error_free_ring_buffer_chrdev:
+ __iio_free_ring_buffer_chrdev(ring);
error_ret:
return ret;
}
@@ -406,8 +381,7 @@ EXPORT_SYMBOL(iio_ring_buffer_register);
void iio_ring_buffer_unregister(struct iio_ring_buffer *ring)
{
__iio_ring_attr_cleanup(ring);
- __iio_free_ring_buffer_access_chrdev(ring);
- device_del(&ring->dev);
+ __iio_free_ring_buffer_chrdev(ring);
}
EXPORT_SYMBOL(iio_ring_buffer_unregister);