Skip to contentSkip to conversation

iio: Fix build error in industrialio-core.c

PATCH In review Sasha Levin 4 participants 7 messages Nov 23, 2011 – Nov 24, 2011

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iio: Fix build error in industrialio-core.c

The error was introduced in commit b4641336 ("iio: fix a leak due to improper use of anon_inode_getfd()").

Looks like the code wasn't even compile tested. Instead of just fixing the error I changed the function a bit to make it nicer.

---
 drivers/staging/iio/industrialio-core.c |   21 ++++++++++-----------
 1 files changed, 10 insertions(+), 11 deletions(-)
drivers/staging/iio/industrialio-core.c +10 -11
index 2656409..5367914 100644
@@ -242,25 +242,24 @@ static const struct file_operations iio_event_chrdev_fileops = {
 
 static int iio_event_getfd(struct iio_dev *indio_dev)
 {
+	struct iio_event_interface *ev_int = indio_dev->event_interface;
 	int fd;
 
-	if (indio_dev->event_interface == NULL)
+	if (ev_int == NULL)
 		return -ENODEV;
 
-	mutex_lock(&indio_dev->event_interface->event_list_lock);
-	if (test_and_set_bit(IIO_BUSY_BIT_POS,
-			     &indio_dev->event_interface->flags)) {
-		mutex_unlock(&indio_dev->event_interface->event_list_lock);
+	mutex_lock(&ev_int->event_list_lock);
+	if (test_and_set_bit(IIO_BUSY_BIT_POS, &ev_int->flags)) {
+		mutex_unlock(&ev_int->event_list_lock);
 		return -EBUSY;
 	}
-	mutex_unlock(&indio_dev->event_interface->event_list_lock);
-	fd = anon_inode_getfd("iio:event",
-				&iio_event_chrdev_fileops,
-				indio_dev->event_interface, O_RDONLY);
+	mutex_unlock(&ev_int->event_list_lock);
+	fd = anon_inode_getfd("iio:event", &iio_event_chrdev_fileops,
+				ev_int, O_RDONLY);
 	if (fd < 0) {
-		mutex_lock(&indio_dev->event_interface->event_list_lock);
+		mutex_lock(&ev_int->event_list_lock);
 		clear_bit(IIO_BUSY_BIT_POS, &ev_int->flags);
-		mutex_unlock(&indio_dev->event_interface->event_list_lock);
+		mutex_unlock(&ev_int->event_list_lock);
 	}
 	return fd;
 }
Signature · 1 line
1.7.8.rc3
#1 lore raw
Quoted 3 lines · Sasha Levin

The error was introduced in commit b4641336 ("iio: fix a leak due to improper use of anon_inode_getfd()").

Which tree is that patch from? It's not in linux-next.

regards,
dan carpenter

Acked-by on v1 1/1
#3 lore raw
In reply to Sasha Levin
Quoted 6 lines · Sasha Levin

The error was introduced in commit b4641336 ("iio: fix a leak due to improper use of anon_inode_getfd()").

Looks like the code wasn't even compile tested. Instead of just fixing the
error I changed the function a bit to make it nicer.

Minimal change would have been slightly nicer but clean up is obvious so fine. Thanks for doing this. Andrew m has a dirty build fix in NM but he will drop that when this hits.

Quoted 5 lines
Quoted 48 lines

---
drivers/staging/iio/industrialio-core.c | 21 ++++++++++-----------

1 files changed, 10 insertions(+), 11 deletions(-)
drivers/staging/iio/industrialio-core.c +10 -11
index 2656409..5367914 100644
@@ -242,25 +242,24 @@ static const struct file_operations
 iio_event_chrdev_fileops = {
 
 static int iio_event_getfd(struct iio_dev *indio_dev)
 {
+	struct iio_event_interface *ev_int = indio_dev->event_interface;
 	int fd;
 
-	if (indio_dev->event_interface == NULL)
+	if (ev_int == NULL)
 		return -ENODEV;
 
-	mutex_lock(&indio_dev->event_interface->event_list_lock);
-	if (test_and_set_bit(IIO_BUSY_BIT_POS,
-			     &indio_dev->event_interface->flags)) {
-		mutex_unlock(&indio_dev->event_interface->event_list_lock);
+	mutex_lock(&ev_int->event_list_lock);
+	if (test_and_set_bit(IIO_BUSY_BIT_POS, &ev_int->flags)) {
+		mutex_unlock(&ev_int->event_list_lock);
 		return -EBUSY;
 	}
-	mutex_unlock(&indio_dev->event_interface->event_list_lock);
-	fd = anon_inode_getfd("iio:event",
-				&iio_event_chrdev_fileops,
-				indio_dev->event_interface, O_RDONLY);
+	mutex_unlock(&ev_int->event_list_lock);
+	fd = anon_inode_getfd("iio:event", &iio_event_chrdev_fileops,
+				ev_int, O_RDONLY);
 	if (fd < 0) {
-		mutex_lock(&indio_dev->event_interface->event_list_lock);
+		mutex_lock(&ev_int->event_list_lock);
 		clear_bit(IIO_BUSY_BIT_POS, &ev_int->flags);
-		mutex_unlock(&indio_dev->event_interface->event_list_lock);
+		mutex_unlock(&ev_int->event_list_lock);
 	}
 	return fd;

}

Signature · 1 line
1.7.8.rc3
Signature · 2 lines
Sent from my Android phone 
with K-9 Mail. Please excuse my brevity.
#4 lore raw
Quoted 10 lines · Jonathan Cameron
Quoted 6 lines · Sasha Levin

The error was introduced in commit b4641336 ("iio: fix a leak due to improper use of anon_inode_getfd()").

Looks like the code wasn't even compile tested. Instead of just fixing the
error I changed the function a bit to make it nicer.

Minimal change would have been slightly nicer but clean up is obvious so fine. Thanks for doing this. Andrew m has a dirty build fix in NM but he will drop that when this hits.

If you'd like I can split it into two patches, the fix and the cleanup.

Signature · 1 line
Sasha.
#5 lore raw
Quoted 8 lines · Sasha Levin
Quoted 7 lines · Jonathan Cameron
Quoted 4 lines · Sasha Levin

The error was introduced in commit b4641336 ("iio: fix a leak due to improper use of anon_inode_getfd()").

Looks like the code wasn't even compile tested. Instead of just

Quoted 8 lines

fixing

Quoted 3 lines
Quoted 2 lines

the
error I changed the function a bit to make it nicer.

Minimal change would have been slightly nicer but clean up is obvious

so fine. Thanks for doing this. Andrew m has a dirty build fix in NM but he will drop that when this hits.

If you'd like I can split it into two patches, the fix and the cleanup.

Unless Greg wants that don't bother. I just want the fix in place!

Quoted 3 lines
Signature · 1 line
Sasha.
Signature · 2 lines
Sent from my Android phone 
with K-9 Mail. Please excuse my brevity.
#6 lore raw
In reply to Sasha Levin
Quoted 4 lines · On Wed, 23 Nov 2011 12:13:59 +0200 Sasha Levin <[email protected]> wrote:

The error was introduced in commit b4641336 ("iio: fix a leak due to improper use of anon_inode_getfd()").

Quoted 8 lines

Looks like the code wasn't even compile tested. Instead of just fixing the error I changed the function a bit to make it nicer.

I will add this to my fixes tree today (so linux-next will build).

Signature · 3 lines
Cheers,
Stephen Rothwell                    [email protected]
http://www.canb.auug.org.au/~sfr/