diff options
author | Andy Walls <awalls@md.metrocast.net> | 2011-01-27 00:10:42 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2011-03-22 18:23:54 -0400 |
commit | 915e54733de4a36742ab78b4768750ce72662f85 (patch) | |
tree | e7531da1ff91d843577a6ac5fc7b021234885166 /drivers | |
parent | 9a55a2b37eb7e4941ef55aadb858b615d229afee (diff) |
[media] lirc_zilog: Don't acquire the rx->buf_lock in the poll() function
There is no need to take the rx->buf_lock in the the poll() function
as all the underling calls made on objects in the rx->buf lirc_buffer object
are protected by spinlocks.
Corrected a bad error return value in poll(): return POLLERR instead
of -ENODEV.
Added some comments to poll() for when, in the future, I forget what
poll() and poll_wait() are supposed to do.
[Jarod: minor debug spew fix]
Signed-off-by: Andy Walls <awalls@md.metrocast.net>
Signed-off-by: Jarod Wilson <jarod@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/staging/lirc/lirc_zilog.c | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/drivers/staging/lirc/lirc_zilog.c b/drivers/staging/lirc/lirc_zilog.c index 720ef6739d0e..695c3df93ca8 100644 --- a/drivers/staging/lirc/lirc_zilog.c +++ b/drivers/staging/lirc/lirc_zilog.c | |||
@@ -985,19 +985,26 @@ static unsigned int poll(struct file *filep, poll_table *wait) | |||
985 | unsigned int ret; | 985 | unsigned int ret; |
986 | 986 | ||
987 | dprintk("poll called\n"); | 987 | dprintk("poll called\n"); |
988 | if (rx == NULL) | ||
989 | return -ENODEV; | ||
990 | 988 | ||
991 | mutex_lock(&rx->buf_lock); | 989 | if (rx == NULL) { |
990 | /* | ||
991 | * Revisit this, if our poll function ever reports writeable | ||
992 | * status for Tx | ||
993 | */ | ||
994 | dprintk("poll result = POLLERR\n"); | ||
995 | return POLLERR; | ||
996 | } | ||
992 | 997 | ||
998 | /* | ||
999 | * Add our lirc_buffer's wait_queue to the poll_table. A wake up on | ||
1000 | * that buffer's wait queue indicates we may have a new poll status. | ||
1001 | */ | ||
993 | poll_wait(filep, &rx->buf.wait_poll, wait); | 1002 | poll_wait(filep, &rx->buf.wait_poll, wait); |
994 | 1003 | ||
995 | dprintk("poll result = %s\n", | 1004 | /* Indicate what ops could happen immediately without blocking */ |
996 | lirc_buffer_empty(&rx->buf) ? "0" : "POLLIN|POLLRDNORM"); | ||
997 | |||
998 | ret = lirc_buffer_empty(&rx->buf) ? 0 : (POLLIN|POLLRDNORM); | 1005 | ret = lirc_buffer_empty(&rx->buf) ? 0 : (POLLIN|POLLRDNORM); |
999 | 1006 | ||
1000 | mutex_unlock(&rx->buf_lock); | 1007 | dprintk("poll result = %s\n", ret ? "POLLIN|POLLRDNORM" : "none"); |
1001 | return ret; | 1008 | return ret; |
1002 | } | 1009 | } |
1003 | 1010 | ||