Skip to content

Commit

Permalink
Misc, phantom, fix poll
Browse files Browse the repository at this point in the history
Return ERR even if there are pending data, but hw is not running.  Do not
decrement count in poll, do it in ioctl, where data are actually read.

Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
jirislaby authored and torvalds committed Apr 29, 2008
1 parent 7e4e8e6 commit 7d4f9f0
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions drivers/misc/phantom.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ static long phantom_ioctl(struct file *file, unsigned int cmd,
for (i = 0; i < m; i++)
if (rs.mask & BIT(i))
rs.values[i] = ioread32(dev->iaddr + i);
atomic_set(&dev->counter, 0);
spin_unlock_irqrestore(&dev->regs_lock, flags);

if (copy_to_user(argp, &rs, sizeof(rs)))
Expand Down Expand Up @@ -254,11 +255,12 @@ static unsigned int phantom_poll(struct file *file, poll_table *wait)

pr_debug("phantom_poll: %d\n", atomic_read(&dev->counter));
poll_wait(file, &dev->wait, wait);
if (atomic_read(&dev->counter)) {

if (!(dev->status & PHB_RUNNING))
mask = POLLERR;
else if (atomic_read(&dev->counter))
mask = POLLIN | POLLRDNORM;
atomic_dec(&dev->counter);
} else if ((dev->status & PHB_RUNNING) == 0)
mask = POLLIN | POLLRDNORM | POLLERR;

pr_debug("phantom_poll end: %x/%d\n", mask, atomic_read(&dev->counter));

return mask;
Expand Down

0 comments on commit 7d4f9f0

Please sign in to comment.