diff options
author | Greg Kroah-Hartman <gregkh@suse.de> | 2010-10-28 09:44:56 -0700 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-10-28 09:44:56 -0700 |
commit | e4c5bf8e3dca827a1b3a6fac494eae8c74b7e1e7 (patch) | |
tree | ea51b391f7d74ca695dcb9f5e46eb02688a92ed9 /drivers/staging/iio/industrialio-ring.c | |
parent | 81280572ca6f54009edfa4deee563e8678784218 (diff) | |
parent | a4ac0d847af9dd34d5953a5e264400326144b6b2 (diff) |
Merge 'staging-next' to Linus's tree
This merges the staging-next tree to Linus's tree and resolves
some conflicts that were present due to changes in other trees that were
affected by files here.
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.c | 61 |
1 files changed, 37 insertions, 24 deletions
diff --git a/drivers/staging/iio/industrialio-ring.c b/drivers/staging/iio/industrialio-ring.c index 1c5f67253b82..9a98fcdbe109 100644 --- a/drivers/staging/iio/industrialio-ring.c +++ b/drivers/staging/iio/industrialio-ring.c @@ -15,10 +15,8 @@ */ #include <linux/kernel.h> #include <linux/device.h> -#include <linux/interrupt.h> #include <linux/fs.h> #include <linux/poll.h> -#include <linux/module.h> #include <linux/cdev.h> #include <linux/slab.h> @@ -53,7 +51,7 @@ int iio_push_or_escallate_ring_event(struct iio_ring_buffer *ring_buf, EXPORT_SYMBOL(iio_push_or_escallate_ring_event); /** - * iio_ring_open() chrdev file open for ring buffer access + * iio_ring_open() - chrdev file open for ring buffer access * * This function relies on all ring buffer implementations having an * iio_ring_buffer as their first element. @@ -72,7 +70,7 @@ static int iio_ring_open(struct inode *inode, struct file *filp) } /** - * iio_ring_release() -chrdev file close ring buffer access + * iio_ring_release() - chrdev file close ring buffer access * * This function relies on all ring buffer implementations having an * iio_ring_buffer as their first element. @@ -91,7 +89,7 @@ static int iio_ring_release(struct inode *inode, struct file *filp) } /** - * iio_ring_rip_outer() chrdev read for ring buffer access + * iio_ring_rip_outer() - chrdev read for ring buffer access * * This function relies on all ring buffer implementations having an * iio_ring _bufer as their first element. @@ -107,7 +105,7 @@ static ssize_t iio_ring_rip_outer(struct file *filp, char __user *buf, return -EINVAL; copied = rb->access.rip_lots(rb, count, &data, &dead_offset); - if (copied < 0) { + if (copied <= 0) { ret = copied; goto error_ret; } @@ -137,8 +135,9 @@ static const struct file_operations iio_ring_fileops = { }; /** - * __iio_request_ring_buffer_event_chrdev() allocate ring event chrdev + * __iio_request_ring_buffer_event_chrdev() - allocate ring event chrdev * @buf: ring buffer whose event chrdev we are allocating + * @id: id of this ring buffer (typically 0) * @owner: the module who owns the ring buffer (for ref counting) * @dev: device with which the chrdev is associated **/ @@ -280,6 +279,16 @@ int iio_ring_buffer_register(struct iio_ring_buffer *ring, int id) if (ret) goto error_free_ring_buffer_event_chrdev; + 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_event_chrdev; + } + } + return ret; error_free_ring_buffer_event_chrdev: __iio_free_ring_buffer_event_chrdev(ring); @@ -292,6 +301,10 @@ EXPORT_SYMBOL(iio_ring_buffer_register); void iio_ring_buffer_unregister(struct iio_ring_buffer *ring) { + if (ring->scan_el_attrs) + sysfs_remove_group(&ring->dev.kobj, + ring->scan_el_attrs); + __iio_free_ring_buffer_access_chrdev(ring); __iio_free_ring_buffer_event_chrdev(ring); device_del(&ring->dev); @@ -313,7 +326,7 @@ ssize_t iio_read_ring_length(struct device *dev, } EXPORT_SYMBOL(iio_read_ring_length); - ssize_t iio_write_ring_length(struct device *dev, +ssize_t iio_write_ring_length(struct device *dev, struct device_attribute *attr, const char *buf, size_t len) @@ -339,20 +352,20 @@ EXPORT_SYMBOL(iio_read_ring_length); } EXPORT_SYMBOL(iio_write_ring_length); -ssize_t iio_read_ring_bps(struct device *dev, +ssize_t iio_read_ring_bytes_per_datum(struct device *dev, struct device_attribute *attr, char *buf) { int len = 0; struct iio_ring_buffer *ring = dev_get_drvdata(dev); - if (ring->access.get_bpd) + if (ring->access.get_bytes_per_datum) len = sprintf(buf, "%d\n", - ring->access.get_bpd(ring)); + ring->access.get_bytes_per_datum(ring)); return len; } -EXPORT_SYMBOL(iio_read_ring_bps); +EXPORT_SYMBOL(iio_read_ring_bytes_per_datum); ssize_t iio_store_ring_enable(struct device *dev, struct device_attribute *attr, @@ -466,10 +479,10 @@ ssize_t iio_scan_el_show(struct device *dev, char *buf) { int ret; - struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct iio_ring_buffer *ring = dev_get_drvdata(dev); struct iio_scan_el *this_el = to_iio_scan_el(attr); - ret = iio_scan_mask_query(indio_dev, this_el->number); + ret = iio_scan_mask_query(ring, this_el->number); if (ret < 0) return ret; return sprintf(buf, "%d\n", ret); @@ -483,7 +496,8 @@ ssize_t iio_scan_el_store(struct device *dev, { int ret = 0; bool state; - struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct iio_ring_buffer *ring = dev_get_drvdata(dev); + struct iio_dev *indio_dev = ring->indio_dev; struct iio_scan_el *this_el = to_iio_scan_el(attr); state = !(buf[0] == '0'); @@ -492,19 +506,17 @@ ssize_t iio_scan_el_store(struct device *dev, ret = -EBUSY; goto error_ret; } - ret = iio_scan_mask_query(indio_dev, this_el->number); + ret = iio_scan_mask_query(ring, this_el->number); if (ret < 0) goto error_ret; if (!state && ret) { - ret = iio_scan_mask_clear(indio_dev, this_el->number); + ret = iio_scan_mask_clear(ring, this_el->number); if (ret) goto error_ret; - indio_dev->scan_count--; } else if (state && !ret) { - ret = iio_scan_mask_set(indio_dev, this_el->number); + ret = iio_scan_mask_set(ring, this_el->number); if (ret) goto error_ret; - indio_dev->scan_count++; } if (this_el->set_state) ret = this_el->set_state(this_el, indio_dev, state); @@ -520,8 +532,8 @@ ssize_t iio_scan_el_ts_show(struct device *dev, struct device_attribute *attr, char *buf) { - struct iio_dev *indio_dev = dev_get_drvdata(dev); - return sprintf(buf, "%d\n", indio_dev->scan_timestamp); + struct iio_ring_buffer *ring = dev_get_drvdata(dev); + return sprintf(buf, "%d\n", ring->scan_timestamp); } EXPORT_SYMBOL(iio_scan_el_ts_show); @@ -531,7 +543,8 @@ ssize_t iio_scan_el_ts_store(struct device *dev, size_t len) { int ret = 0; - struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct iio_ring_buffer *ring = dev_get_drvdata(dev); + struct iio_dev *indio_dev = ring->indio_dev; bool state; state = !(buf[0] == '0'); mutex_lock(&indio_dev->mlock); @@ -539,7 +552,7 @@ ssize_t iio_scan_el_ts_store(struct device *dev, ret = -EBUSY; goto error_ret; } - indio_dev->scan_timestamp = state; + ring->scan_timestamp = state; error_ret: mutex_unlock(&indio_dev->mlock); |