linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/10] staging:iio:various fixes
@ 2011-10-26 16:27 Jonathan Cameron
  2011-10-26 16:27 ` [PATCH 01/10] staging:iio:light:tsl2563 both intensity channels have same chan_spec Jonathan Cameron
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: Jonathan Cameron @ 2011-10-26 16:27 UTC (permalink / raw)
  To: greg; +Cc: linux-iio, Jonathan Cameron

Hi Greg,

A mixed bag of fixes.  Nothing controversial and all have been on
the mailing list in various series.

[PATCH 0/6] staging:iio: misc fixes
Hi All,

I've just gathered up the fixes sitting in my various trees
ready to send on.  I have lost track of whether all of these
have previously been posted for review so this is to make
sure they all have.  They are all in the github master branch.

I'd like to push these out before the larger changes that
Lars-Peter and I made at the end of last week.

Thanks,

Jonathan

Jonathan Cameron (5):
  staging:iio:light:tsl2563 both intensity channels have same
    chan_spec.
  staging:iio:triggers Remove unecessary existence checks and return
    val
  staging:iio:industrialio-trigger.c Trivial code style brackets fix
  staging:iio:kfifo remove entirely pointless code.
  staging:iio: trigger fixes for repeat request of same trigger and
    allocation failure

Maxin B. John (1):
  staging:iio:light:tsl2563 missing setting of id in get id function.

[PATCH] staging:iio: one more fix

Drat, missed this one in the last set.

Anyhow, relatively trivial.


Lars-Peter's ones were bare patches as presented here.




Jonathan Cameron (7):
  staging:iio:light:tsl2563 both intensity channels have same
    chan_spec.
  staging:iio:triggers Remove unecessary existence checks and return
    val
  staging:iio:industrialio-trigger.c Trivial code style brackets fix
  staging:iio:kfifo remove entirely pointless code.
  staging:iio: trigger fixes for repeat request of same trigger and
    allocation failure
  staging:iio:core shared attrs do not work with modifier.
  staging:iio: core.  Allow for event chrdev obtaining ioctl if no
    buffer present.

Lars-Peter Clausen (2):
  staging:iio:events: Make sure userspace buffer is large enough
  staging:iio:iio_utils.h: Add missing include

Maxin B. John (1):
  staging:iio:light:tsl2563 missing setting of id in get id function.

 drivers/staging/iio/Documentation/iio_utils.h |    1 +
 drivers/staging/iio/iio_core.h                |    2 +-
 drivers/staging/iio/iio_core_trigger.h        |    3 +-
 drivers/staging/iio/industrialio-buffer.c     |    6 +++-
 drivers/staging/iio/industrialio-core.c       |    8 +++--
 drivers/staging/iio/industrialio-trigger.c    |   34 +++++++++++++-----------
 drivers/staging/iio/kfifo_buf.c               |    9 +------
 drivers/staging/iio/light/tsl2563.c           |    4 ++-
 8 files changed, 34 insertions(+), 33 deletions(-)

-- 
1.7.7


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 01/10] staging:iio:light:tsl2563 both intensity channels have same chan_spec.
  2011-10-26 16:27 [PATCH 00/10] staging:iio:various fixes Jonathan Cameron
@ 2011-10-26 16:27 ` Jonathan Cameron
  2011-10-26 16:27 ` [PATCH 02/10] staging:iio:light:tsl2563 missing setting of id in get id function Jonathan Cameron
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Jonathan Cameron @ 2011-10-26 16:27 UTC (permalink / raw)
  To: greg; +Cc: linux-iio, Jonathan Cameron

Bug has been fixed for some time in the outofstaging tree, but
didn't propogate back to here.

Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
---
 drivers/staging/iio/light/tsl2563.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/iio/light/tsl2563.c b/drivers/staging/iio/light/tsl2563.c
index 7e984bc..be99925 100644
--- a/drivers/staging/iio/light/tsl2563.c
+++ b/drivers/staging/iio/light/tsl2563.c
@@ -544,7 +544,7 @@ static const struct iio_chan_spec tsl2563_channels[] = {
 	}, {
 		.type = IIO_INTENSITY,
 		.modified = 1,
-		.channel2 = IIO_MOD_LIGHT_BOTH,
+		.channel2 = IIO_MOD_LIGHT_IR,
 		.info_mask = (1 << IIO_CHAN_INFO_CALIBSCALE_SEPARATE),
 	}
 };
-- 
1.7.7


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 02/10] staging:iio:light:tsl2563 missing setting of id in get id function.
  2011-10-26 16:27 [PATCH 00/10] staging:iio:various fixes Jonathan Cameron
  2011-10-26 16:27 ` [PATCH 01/10] staging:iio:light:tsl2563 both intensity channels have same chan_spec Jonathan Cameron
@ 2011-10-26 16:27 ` Jonathan Cameron
  2011-10-26 16:27 ` [PATCH 03/10] staging:iio:triggers Remove unecessary existence checks and return val Jonathan Cameron
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Jonathan Cameron @ 2011-10-26 16:27 UTC (permalink / raw)
  To: greg; +Cc: linux-iio, Maxin B. John, Jonathan Cameron

From: "Maxin B. John" <maxin.john@gmail.com>

Signed-off-by: Maxin B. John <maxin.john@gmail.com>
Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
---
 drivers/staging/iio/light/tsl2563.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/drivers/staging/iio/light/tsl2563.c b/drivers/staging/iio/light/tsl2563.c
index be99925..6a17945 100644
--- a/drivers/staging/iio/light/tsl2563.c
+++ b/drivers/staging/iio/light/tsl2563.c
@@ -226,6 +226,8 @@ static int tsl2563_read_id(struct tsl2563_chip *chip, u8 *id)
 	if (ret < 0)
 		return ret;
 
+	*id = ret;
+
 	return 0;
 }
 
-- 
1.7.7


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 03/10] staging:iio:triggers Remove unecessary existence checks and return val
  2011-10-26 16:27 [PATCH 00/10] staging:iio:various fixes Jonathan Cameron
  2011-10-26 16:27 ` [PATCH 01/10] staging:iio:light:tsl2563 both intensity channels have same chan_spec Jonathan Cameron
  2011-10-26 16:27 ` [PATCH 02/10] staging:iio:light:tsl2563 missing setting of id in get id function Jonathan Cameron
@ 2011-10-26 16:27 ` Jonathan Cameron
  2011-10-26 16:27 ` [PATCH 04/10] staging:iio:industrialio-trigger.c Trivial code style brackets fix Jonathan Cameron
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Jonathan Cameron @ 2011-10-26 16:27 UTC (permalink / raw)
  To: greg; +Cc: linux-iio, Jonathan Cameron

Postenable and predisable are called via buffer->ops so  don't
need to check if buffer exists.

The return value of iio_device_register_trigger_consumer is
always zero and it isn't checked anyway so get rid of it.

Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
---
 drivers/staging/iio/iio_core_trigger.h     |    3 +--
 drivers/staging/iio/industrialio-trigger.c |   16 +++++-----------
 2 files changed, 6 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/iio/iio_core_trigger.h b/drivers/staging/iio/iio_core_trigger.h
index 523c288..6f7c56f 100644
--- a/drivers/staging/iio/iio_core_trigger.h
+++ b/drivers/staging/iio/iio_core_trigger.h
@@ -13,8 +13,7 @@
  * iio_device_register_trigger_consumer() - set up an iio_dev to use triggers
  * @indio_dev: iio_dev associated with the device that will consume the trigger
  **/
-
-int iio_device_register_trigger_consumer(struct iio_dev *indio_dev);
+void iio_device_register_trigger_consumer(struct iio_dev *indio_dev);
 
 /**
  * iio_device_unregister_trigger_consumer() - reverse the registration process
diff --git a/drivers/staging/iio/industrialio-trigger.c b/drivers/staging/iio/industrialio-trigger.c
index 2c626e0..ca4124a 100644
--- a/drivers/staging/iio/industrialio-trigger.c
+++ b/drivers/staging/iio/industrialio-trigger.c
@@ -473,12 +473,10 @@ void iio_free_trigger(struct iio_trigger *trig)
 }
 EXPORT_SYMBOL(iio_free_trigger);
 
-int iio_device_register_trigger_consumer(struct iio_dev *indio_dev)
+void iio_device_register_trigger_consumer(struct iio_dev *indio_dev)
 {
 	indio_dev->groups[indio_dev->groupcounter++] =
 		&iio_trigger_consumer_attr_group;
-
-	return 0;
 }
 
 void iio_device_unregister_trigger_consumer(struct iio_dev *indio_dev)
@@ -490,18 +488,14 @@ void iio_device_unregister_trigger_consumer(struct iio_dev *indio_dev)
 
 int iio_triggered_buffer_postenable(struct iio_dev *indio_dev)
 {
-	return indio_dev->trig
-		? iio_trigger_attach_poll_func(indio_dev->trig,
-					       indio_dev->pollfunc)
-		: 0;
+	return iio_trigger_attach_poll_func(indio_dev->trig,
+					    indio_dev->pollfunc);
 }
 EXPORT_SYMBOL(iio_triggered_buffer_postenable);
 
 int iio_triggered_buffer_predisable(struct iio_dev *indio_dev)
 {
-	return indio_dev->trig
-		? iio_trigger_dettach_poll_func(indio_dev->trig,
-						indio_dev->pollfunc)
-		: 0;
+	return iio_trigger_dettach_poll_func(indio_dev->trig,
+					     indio_dev->pollfunc);
 }
 EXPORT_SYMBOL(iio_triggered_buffer_predisable);
-- 
1.7.7


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 04/10] staging:iio:industrialio-trigger.c Trivial code style brackets fix
  2011-10-26 16:27 [PATCH 00/10] staging:iio:various fixes Jonathan Cameron
                   ` (2 preceding siblings ...)
  2011-10-26 16:27 ` [PATCH 03/10] staging:iio:triggers Remove unecessary existence checks and return val Jonathan Cameron
@ 2011-10-26 16:27 ` Jonathan Cameron
  2011-10-26 16:27 ` [PATCH 05/10] staging:iio:kfifo remove entirely pointless code Jonathan Cameron
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Jonathan Cameron @ 2011-10-26 16:27 UTC (permalink / raw)
  To: greg; +Cc: linux-iio, Jonathan Cameron

Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
---
 drivers/staging/iio/industrialio-trigger.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/iio/industrialio-trigger.c b/drivers/staging/iio/industrialio-trigger.c
index ca4124a..9412013 100644
--- a/drivers/staging/iio/industrialio-trigger.c
+++ b/drivers/staging/iio/industrialio-trigger.c
@@ -159,13 +159,12 @@ EXPORT_SYMBOL(iio_trigger_generic_data_rdy_poll);
 void iio_trigger_poll_chained(struct iio_trigger *trig, s64 time)
 {
 	int i;
-	if (!trig->use_count) {
+	if (!trig->use_count)
 		for (i = 0; i < CONFIG_IIO_CONSUMERS_PER_TRIGGER; i++)
 			if (trig->subirqs[i].enabled) {
 				trig->use_count++;
 				handle_nested_irq(trig->subirq_base + i);
 			}
-	}
 }
 EXPORT_SYMBOL(iio_trigger_poll_chained);
 
@@ -173,10 +172,9 @@ void iio_trigger_notify_done(struct iio_trigger *trig)
 {
 	trig->use_count--;
 	if (trig->use_count == 0 && trig->ops && trig->ops->try_reenable)
-		if (trig->ops->try_reenable(trig)) {
+		if (trig->ops->try_reenable(trig))
 			/* Missed and interrupt so launch new poll now */
 			iio_trigger_poll(trig, 0);
-		}
 }
 EXPORT_SYMBOL(iio_trigger_notify_done);
 
-- 
1.7.7


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 05/10] staging:iio:kfifo remove entirely pointless code.
  2011-10-26 16:27 [PATCH 00/10] staging:iio:various fixes Jonathan Cameron
                   ` (3 preceding siblings ...)
  2011-10-26 16:27 ` [PATCH 04/10] staging:iio:industrialio-trigger.c Trivial code style brackets fix Jonathan Cameron
@ 2011-10-26 16:27 ` Jonathan Cameron
  2011-10-26 16:27 ` [PATCH 06/10] staging:iio: trigger fixes for repeat request of same trigger and allocation failure Jonathan Cameron
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Jonathan Cameron @ 2011-10-26 16:27 UTC (permalink / raw)
  To: greg; +Cc: linux-iio, Jonathan Cameron

I really don't want to think about how this bit got
in there.  It allocates some storage - copies something
into it then frees it without making use of it.
Oops.

Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
---
 drivers/staging/iio/kfifo_buf.c |    9 +--------
 1 files changed, 1 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/iio/kfifo_buf.c b/drivers/staging/iio/kfifo_buf.c
index e8c234b..fd98a0e 100644
--- a/drivers/staging/iio/kfifo_buf.c
+++ b/drivers/staging/iio/kfifo_buf.c
@@ -150,16 +150,9 @@ static int iio_store_to_kfifo(struct iio_buffer *r,
 {
 	int ret;
 	struct iio_kfifo *kf = iio_to_kfifo(r);
-	u8 *datal = kmalloc(r->bytes_per_datum, GFP_KERNEL);
-	memcpy(datal, data, r->bytes_per_datum - sizeof(timestamp));
-	memcpy(datal + r->bytes_per_datum - sizeof(timestamp),
-		&timestamp, sizeof(timestamp));
 	ret = kfifo_in(&kf->kf, data, r->bytes_per_datum);
-	if (ret != r->bytes_per_datum) {
-		kfree(datal);
+	if (ret != r->bytes_per_datum)
 		return -EBUSY;
-	}
-	kfree(datal);
 	return 0;
 }
 
-- 
1.7.7


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 06/10] staging:iio: trigger fixes for repeat request of same trigger and allocation failure
  2011-10-26 16:27 [PATCH 00/10] staging:iio:various fixes Jonathan Cameron
                   ` (4 preceding siblings ...)
  2011-10-26 16:27 ` [PATCH 05/10] staging:iio:kfifo remove entirely pointless code Jonathan Cameron
@ 2011-10-26 16:27 ` Jonathan Cameron
  2011-10-26 16:27 ` [PATCH 07/10] staging:iio:core shared attrs do not work with modifier Jonathan Cameron
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Jonathan Cameron @ 2011-10-26 16:27 UTC (permalink / raw)
  To: greg; +Cc: linux-iio, Jonathan Cameron

Both of these are decidedly silly bugs show up whilst testing
completely different code paths.

Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
---
 drivers/staging/iio/industrialio-trigger.c |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/iio/industrialio-trigger.c b/drivers/staging/iio/industrialio-trigger.c
index 9412013..20dc8e8 100644
--- a/drivers/staging/iio/industrialio-trigger.c
+++ b/drivers/staging/iio/industrialio-trigger.c
@@ -220,8 +220,16 @@ static int iio_trigger_attach_poll_func(struct iio_trigger *trig,
 	ret = request_threaded_irq(pf->irq, pf->h, pf->thread,
 				   pf->type, pf->name,
 				   pf);
-	if (trig->ops && trig->ops->set_trigger_state && notinuse)
+	if (ret < 0) {
+		module_put(pf->indio_dev->info->driver_module);
+		return ret;
+	}
+
+	if (trig->ops && trig->ops->set_trigger_state && notinuse) {
 		ret = trig->ops->set_trigger_state(trig, true);
+		if (ret < 0)
+			module_put(pf->indio_dev->info->driver_module);
+	}
 
 	return ret;
 }
@@ -334,6 +342,8 @@ static ssize_t iio_trigger_write_current(struct device *dev,
 	mutex_unlock(&indio_dev->mlock);
 
 	trig = iio_trigger_find_by_name(buf, len);
+	if (oldtrig == trig)
+		return len;
 
 	if (trig && indio_dev->info->validate_trigger) {
 		ret = indio_dev->info->validate_trigger(indio_dev, trig);
-- 
1.7.7

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 07/10] staging:iio:core shared attrs do not work with modifier.
  2011-10-26 16:27 [PATCH 00/10] staging:iio:various fixes Jonathan Cameron
                   ` (5 preceding siblings ...)
  2011-10-26 16:27 ` [PATCH 06/10] staging:iio: trigger fixes for repeat request of same trigger and allocation failure Jonathan Cameron
@ 2011-10-26 16:27 ` Jonathan Cameron
  2011-10-26 16:27 ` [PATCH 08/10] staging:iio:events: Make sure userspace buffer is large enough Jonathan Cameron
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Jonathan Cameron @ 2011-10-26 16:27 UTC (permalink / raw)
  To: greg; +Cc: linux-iio, Jonathan Cameron

The logic building the name had a small bug where
it did not verify if it was generic before applying the
modifier.

Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
---
 drivers/staging/iio/industrialio-core.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/iio/industrialio-core.c b/drivers/staging/iio/industrialio-core.c
index 326e967..555877d 100644
--- a/drivers/staging/iio/industrialio-core.c
+++ b/drivers/staging/iio/industrialio-core.c
@@ -408,7 +408,7 @@ int __iio_device_attr_init(struct device_attribute *dev_attr,
 	sysfs_attr_init(&dev_attr->attr);
 
 	/* Build up postfix of <extend_name>_<modifier>_postfix */
-	if (chan->modified) {
+	if (chan->modified && !generic) {
 		if (chan->extend_name)
 			full_postfix = kasprintf(GFP_KERNEL, "%s_%s_%s",
 						 iio_modifier_names[chan
-- 
1.7.7

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 08/10] staging:iio:events: Make sure userspace buffer is large enough
  2011-10-26 16:27 [PATCH 00/10] staging:iio:various fixes Jonathan Cameron
                   ` (6 preceding siblings ...)
  2011-10-26 16:27 ` [PATCH 07/10] staging:iio:core shared attrs do not work with modifier Jonathan Cameron
@ 2011-10-26 16:27 ` Jonathan Cameron
  2011-10-26 16:27 ` [PATCH 09/10] staging:iio:iio_utils.h: Add missing include Jonathan Cameron
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Jonathan Cameron @ 2011-10-26 16:27 UTC (permalink / raw)
  To: greg; +Cc: linux-iio, Lars-Peter Clausen, Jonathan Cameron

From: Lars-Peter Clausen <lars@metafoo.de>

Make sure that the userspace buffer is large enough to hold a iio_event_data
struct before writing to it.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
---
 drivers/staging/iio/industrialio-core.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/iio/industrialio-core.c b/drivers/staging/iio/industrialio-core.c
index 555877d..6379a08 100644
--- a/drivers/staging/iio/industrialio-core.c
+++ b/drivers/staging/iio/industrialio-core.c
@@ -169,8 +169,11 @@ static ssize_t iio_event_chrdev_read(struct file *filep,
 {
 	struct iio_event_interface *ev_int = filep->private_data;
 	struct iio_detected_event_list *el;
+	size_t len = sizeof(el->ev);
 	int ret;
-	size_t len;
+
+	if (count < len)
+		return -EINVAL;
 
 	mutex_lock(&ev_int->event_list_lock);
 	if (list_empty(&ev_int->det_events)) {
@@ -192,7 +195,6 @@ static ssize_t iio_event_chrdev_read(struct file *filep,
 	el = list_first_entry(&ev_int->det_events,
 			      struct iio_detected_event_list,
 			      list);
-	len = sizeof el->ev;
 	if (copy_to_user(buf, &(el->ev), len)) {
 		ret = -EFAULT;
 		goto error_mutex_unlock;
-- 
1.7.7

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 09/10] staging:iio:iio_utils.h: Add missing include
  2011-10-26 16:27 [PATCH 00/10] staging:iio:various fixes Jonathan Cameron
                   ` (7 preceding siblings ...)
  2011-10-26 16:27 ` [PATCH 08/10] staging:iio:events: Make sure userspace buffer is large enough Jonathan Cameron
@ 2011-10-26 16:27 ` Jonathan Cameron
  2011-10-26 16:27 ` [PATCH 10/10] staging:iio: core. Allow for event chrdev obtaining ioctl if no buffer present Jonathan Cameron
  2011-11-27  0:33 ` [PATCH 00/10] staging:iio:various fixes Greg KH
  10 siblings, 0 replies; 12+ messages in thread
From: Jonathan Cameron @ 2011-10-26 16:27 UTC (permalink / raw)
  To: greg; +Cc: linux-iio, Lars-Peter Clausen, Jonathan Cameron

From: Lars-Peter Clausen <lars@metafoo.de>

iio_utils.h uses opendir and friends which need dirent.h

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
---
 drivers/staging/iio/Documentation/iio_utils.h |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/staging/iio/Documentation/iio_utils.h b/drivers/staging/iio/Documentation/iio_utils.h
index 75938b2..dbbad8a 100644
--- a/drivers/staging/iio/Documentation/iio_utils.h
+++ b/drivers/staging/iio/Documentation/iio_utils.h
@@ -13,6 +13,7 @@
 #include <ctype.h>
 #include <stdio.h>
 #include <stdint.h>
+#include <dirent.h>
 
 #define IIO_MAX_NAME_LENGTH 30
 
-- 
1.7.7

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 10/10] staging:iio: core.  Allow for event chrdev obtaining ioctl if no buffer present.
  2011-10-26 16:27 [PATCH 00/10] staging:iio:various fixes Jonathan Cameron
                   ` (8 preceding siblings ...)
  2011-10-26 16:27 ` [PATCH 09/10] staging:iio:iio_utils.h: Add missing include Jonathan Cameron
@ 2011-10-26 16:27 ` Jonathan Cameron
  2011-11-27  0:33 ` [PATCH 00/10] staging:iio:various fixes Greg KH
  10 siblings, 0 replies; 12+ messages in thread
From: Jonathan Cameron @ 2011-10-26 16:27 UTC (permalink / raw)
  To: greg; +Cc: linux-iio, Jonathan Cameron

Logic bug meant the chrdev would fail to open if there was no buffer support
in a driver or in the core. This meant the ioctl to get the event chrdev
would fail and hence events were not available.

V2: change error to -EINVAL to mark as unsuitable for reading rather than
not there.  Both are true depending on how you look at it.

Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
---
 drivers/staging/iio/iio_core.h            |    2 +-
 drivers/staging/iio/industrialio-buffer.c |    6 ++++--
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/iio/iio_core.h b/drivers/staging/iio/iio_core.h
index 36159e0..ff27f13 100644
--- a/drivers/staging/iio/iio_core.h
+++ b/drivers/staging/iio/iio_core.h
@@ -49,7 +49,7 @@ ssize_t iio_buffer_read_first_n_outer(struct file *filp, char __user *buf,
 
 static inline int iio_chrdev_buffer_open(struct iio_dev *indio_dev)
 {
-	return -EINVAL;
+	return 0;
 }
 
 static inline void iio_chrdev_buffer_release(struct iio_dev *indio_dev)
diff --git a/drivers/staging/iio/industrialio-buffer.c b/drivers/staging/iio/industrialio-buffer.c
index 6dd5d7d..4e57243 100644
--- a/drivers/staging/iio/industrialio-buffer.c
+++ b/drivers/staging/iio/industrialio-buffer.c
@@ -42,7 +42,7 @@ ssize_t iio_buffer_read_first_n_outer(struct file *filp, char __user *buf,
 	struct iio_dev *indio_dev = filp->private_data;
 	struct iio_buffer *rb = indio_dev->buffer;
 
-	if (!rb->access->read_first_n)
+	if (!rb || !rb->access->read_first_n)
 		return -EINVAL;
 	return rb->access->read_first_n(rb, n, buf);
 }
@@ -67,7 +67,7 @@ int iio_chrdev_buffer_open(struct iio_dev *indio_dev)
 {
 	struct iio_buffer *rb = indio_dev->buffer;
 	if (!rb)
-		return -EINVAL;
+		return 0;
 	if (rb->access->mark_in_use)
 		rb->access->mark_in_use(rb);
 	return 0;
@@ -77,6 +77,8 @@ void iio_chrdev_buffer_release(struct iio_dev *indio_dev)
 {
 	struct iio_buffer *rb = indio_dev->buffer;
 
+	if (!rb)
+		return;
 	clear_bit(IIO_BUSY_BIT_POS, &rb->flags);
 	if (rb->access->unmark_in_use)
 		rb->access->unmark_in_use(rb);
-- 
1.7.7


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH 00/10] staging:iio:various fixes
  2011-10-26 16:27 [PATCH 00/10] staging:iio:various fixes Jonathan Cameron
                   ` (9 preceding siblings ...)
  2011-10-26 16:27 ` [PATCH 10/10] staging:iio: core. Allow for event chrdev obtaining ioctl if no buffer present Jonathan Cameron
@ 2011-11-27  0:33 ` Greg KH
  10 siblings, 0 replies; 12+ messages in thread
From: Greg KH @ 2011-11-27  0:33 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio

On Wed, Oct 26, 2011 at 05:27:35PM +0100, Jonathan Cameron wrote:
> Hi Greg,
> 
> A mixed bag of fixes.  Nothing controversial and all have been on
> the mailing list in various series.

All applied, thanks.

greg k-h

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2011-11-27  0:33 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-26 16:27 [PATCH 00/10] staging:iio:various fixes Jonathan Cameron
2011-10-26 16:27 ` [PATCH 01/10] staging:iio:light:tsl2563 both intensity channels have same chan_spec Jonathan Cameron
2011-10-26 16:27 ` [PATCH 02/10] staging:iio:light:tsl2563 missing setting of id in get id function Jonathan Cameron
2011-10-26 16:27 ` [PATCH 03/10] staging:iio:triggers Remove unecessary existence checks and return val Jonathan Cameron
2011-10-26 16:27 ` [PATCH 04/10] staging:iio:industrialio-trigger.c Trivial code style brackets fix Jonathan Cameron
2011-10-26 16:27 ` [PATCH 05/10] staging:iio:kfifo remove entirely pointless code Jonathan Cameron
2011-10-26 16:27 ` [PATCH 06/10] staging:iio: trigger fixes for repeat request of same trigger and allocation failure Jonathan Cameron
2011-10-26 16:27 ` [PATCH 07/10] staging:iio:core shared attrs do not work with modifier Jonathan Cameron
2011-10-26 16:27 ` [PATCH 08/10] staging:iio:events: Make sure userspace buffer is large enough Jonathan Cameron
2011-10-26 16:27 ` [PATCH 09/10] staging:iio:iio_utils.h: Add missing include Jonathan Cameron
2011-10-26 16:27 ` [PATCH 10/10] staging:iio: core. Allow for event chrdev obtaining ioctl if no buffer present Jonathan Cameron
2011-11-27  0:33 ` [PATCH 00/10] staging:iio:various fixes Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).