Hi,
poll system call has to return -1 on some error occurance on the device. In its 
normal working condition it returns the state of the device whether its readble 
or writable...
When the device is disconnected here again i am checking whether device is 
present or not..
 
    struct scanner_dev *dev;
    dev = (struct scanner_dev *)file->private_data;
    if(!dev) // or if(!dev->device_present)
        return -EBADF;

irrespective of what error value i return, poll at the application is returning 
1(that is, there is some activity on one file descriptor) After this, 
application is trying to read/ write on device which is gonna fail again. I 
tried returning POLLERR if device is not present but no effect...

I tried searching other standard USB driver , they do the same as i have done.. 
But not getting why poll is always returning positive number or timeout to 
application.

here is poll implementation...

static unsigned int scanner_poll (struct file *file, 
          struct poll_table_struct *wait)
{
 struct scanner_dev *dev;
 unsigned int mask = 0;

 dev = (struct scanner_dev *)file->private_data;

if(!dev->device_present)

    return -EBADF;


 if (NULL != wait)
  poll_wait (file, &dev->read_q, wait);
 // If data is present , say its readable(POLLIN)
 if (dev->read_data_present)
 {
#ifdef DEBUG
  printk ("Read data present \n");
#endif
  mask |= POLLIN | POLLRDNORM;
 }
 // Scanner device is always writtable (POLLOUT)
 mask |= POLLOUT | POLLWRNORM;
 return mask;
}

 

Thanks for ur inputs in advance
Savita

 


-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.
Get Certified Today * Register for a JBoss Training Course
Free Certification Exam for All Training Attendees Through End of 2005
Visit http://www.jboss.com/services/certification for more information
_______________________________________________
[email protected]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to