From e1dc7bee745f74b42685b4b0b0a24895966e545e Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Mon, 2 Jul 2012 14:52:56 +0200 Subject: iio: iio_buffer_register: Use correct channel when calculating masklength The channel set assigned to the iio device is not necessarily the same has the channel set passed to iio_buffer_register. So to avoid possible complications always work with the channel set pass to iio_buffer_register and ignore the channel set assigned to the iio device. Signed-off-by: Lars-Peter Clausen Signed-off-by: Jonathan Cameron --- drivers/iio/industrialio-buffer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/iio') diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c index 3d8d187eef2a..096a6bfe0cdf 100644 --- a/drivers/iio/industrialio-buffer.c +++ b/drivers/iio/industrialio-buffer.c @@ -292,7 +292,7 @@ int iio_buffer_register(struct iio_dev *indio_dev, if (channels[i].scan_index > (int)indio_dev->masklength - 1) indio_dev->masklength - = indio_dev->channels[i].scan_index + 1; + = channels[i].scan_index + 1; ret = iio_buffer_add_channel_sysfs(indio_dev, &channels[i]); -- cgit v1.2.3 From 46b24311ccc8b37da9e6e006c6158229a5354268 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Tue, 3 Jul 2012 10:55:40 +0200 Subject: iio: Fix unitialized use of list The dev_attr list is initialized in __iio_add_event_config_attrs which is called only when indio_dev->channels is true. Nevertheless the list is used unconditionally later in iio_device_register_eventset which results in a NULL pointer exception. To fix this unconditionally initialize the list in iio_device_register_eventset. Signed-off-by: Sascha Hauer Signed-off-by: Jonathan Cameron --- drivers/iio/industrialio-event.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'drivers/iio') diff --git a/drivers/iio/industrialio-event.c b/drivers/iio/industrialio-event.c index b49059de5d02..fa6543bf6731 100644 --- a/drivers/iio/industrialio-event.c +++ b/drivers/iio/industrialio-event.c @@ -345,7 +345,6 @@ static inline int __iio_add_event_config_attrs(struct iio_dev *indio_dev) { int j, ret, attrcount = 0; - INIT_LIST_HEAD(&indio_dev->event_interface->dev_attr_list); /* Dynically created from the channels array */ for (j = 0; j < indio_dev->num_channels; j++) { ret = iio_device_add_event_sysfs(indio_dev, @@ -396,6 +395,8 @@ int iio_device_register_eventset(struct iio_dev *indio_dev) goto error_ret; } + INIT_LIST_HEAD(&indio_dev->event_interface->dev_attr_list); + iio_setup_ev_int(indio_dev->event_interface); if (indio_dev->info->event_attrs != NULL) { attr = indio_dev->info->event_attrs->attrs; -- cgit v1.2.3 From 7b7627410e2c211f24787f61e6419e16d259aa13 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 30 Jun 2012 13:55:23 +0100 Subject: iio: Fix inkern remove incorrect put of device The device_get is after this point so on error we should not be removing it. Signed-off-by: Jonathan Cameron --- drivers/iio/inkern.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers/iio') diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c index 9a46ca61ef02..e2aded04996b 100644 --- a/drivers/iio/inkern.c +++ b/drivers/iio/inkern.c @@ -193,7 +193,6 @@ struct iio_channel *iio_channel_get_all(const char *name) c->map->adc_channel_label); if (chans[mapind].channel == NULL) { ret = -EINVAL; - iio_device_put(chans[mapind].indio_dev); goto error_free_chans; } iio_device_get(chans[mapind].indio_dev); -- cgit v1.2.3