diff options
author | Alan Stern <stern@rowland.harvard.edu> | 2006-07-01 22:05:56 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2006-09-27 14:58:49 -0400 |
commit | 349710c3a79c0405911b8b604953f0c665e17756 (patch) | |
tree | 78cf600f2e2467161df0bf634601e2894f376da5 | |
parent | 4a2a8a2cce86b9d001378cc25acb5c61e6ca7d63 (diff) |
usbfs: detect device unregistration
This patch (as711b) is a revised version of an earlier submission. It
modifies the usbfs code to detect when a device has been unregistered from
usbfs, even if the device is still connected. Although this can't happen
now, it will be able to happen after the upcoming changes to usb_generic.
Nobody objected to this patch when it was submitted before, so it should
be okay to apply this version. The revision is merely to take into
account the changes introduced by as723, which touches the same driver.
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r-- | drivers/usb/core/devio.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c index d8b0476237f3..e84f19d4089c 100644 --- a/drivers/usb/core/devio.c +++ b/drivers/usb/core/devio.c | |||
@@ -90,9 +90,10 @@ MODULE_PARM_DESC (usbfs_snoop, "true to log all usbfs traffic"); | |||
90 | 90 | ||
91 | #define MAX_USBFS_BUFFER_SIZE 16384 | 91 | #define MAX_USBFS_BUFFER_SIZE 16384 |
92 | 92 | ||
93 | static inline int connected (struct usb_device *dev) | 93 | static inline int connected (struct dev_state *ps) |
94 | { | 94 | { |
95 | return dev->state != USB_STATE_NOTATTACHED; | 95 | return (!list_empty(&ps->list) && |
96 | ps->dev->state != USB_STATE_NOTATTACHED); | ||
96 | } | 97 | } |
97 | 98 | ||
98 | static loff_t usbdev_lseek(struct file *file, loff_t offset, int orig) | 99 | static loff_t usbdev_lseek(struct file *file, loff_t offset, int orig) |
@@ -130,7 +131,7 @@ static ssize_t usbdev_read(struct file *file, char __user *buf, size_t nbytes, l | |||
130 | 131 | ||
131 | pos = *ppos; | 132 | pos = *ppos; |
132 | usb_lock_device(dev); | 133 | usb_lock_device(dev); |
133 | if (!connected(dev)) { | 134 | if (!connected(ps)) { |
134 | ret = -ENODEV; | 135 | ret = -ENODEV; |
135 | goto err; | 136 | goto err; |
136 | } else if (pos < 0) { | 137 | } else if (pos < 0) { |
@@ -1326,7 +1327,7 @@ static int proc_ioctl(struct dev_state *ps, struct usbdevfs_ioctl *ctl) | |||
1326 | } | 1327 | } |
1327 | } | 1328 | } |
1328 | 1329 | ||
1329 | if (!connected(ps->dev)) { | 1330 | if (!connected(ps)) { |
1330 | kfree(buf); | 1331 | kfree(buf); |
1331 | return -ENODEV; | 1332 | return -ENODEV; |
1332 | } | 1333 | } |
@@ -1425,7 +1426,7 @@ static int usbdev_ioctl(struct inode *inode, struct file *file, unsigned int cmd | |||
1425 | if (!(file->f_mode & FMODE_WRITE)) | 1426 | if (!(file->f_mode & FMODE_WRITE)) |
1426 | return -EPERM; | 1427 | return -EPERM; |
1427 | usb_lock_device(dev); | 1428 | usb_lock_device(dev); |
1428 | if (!connected(dev)) { | 1429 | if (!connected(ps)) { |
1429 | usb_unlock_device(dev); | 1430 | usb_unlock_device(dev); |
1430 | return -ENODEV; | 1431 | return -ENODEV; |
1431 | } | 1432 | } |
@@ -1566,7 +1567,7 @@ static unsigned int usbdev_poll(struct file *file, struct poll_table_struct *wai | |||
1566 | poll_wait(file, &ps->wait, wait); | 1567 | poll_wait(file, &ps->wait, wait); |
1567 | if (file->f_mode & FMODE_WRITE && !list_empty(&ps->async_completed)) | 1568 | if (file->f_mode & FMODE_WRITE && !list_empty(&ps->async_completed)) |
1568 | mask |= POLLOUT | POLLWRNORM; | 1569 | mask |= POLLOUT | POLLWRNORM; |
1569 | if (!connected(ps->dev)) | 1570 | if (!connected(ps)) |
1570 | mask |= POLLERR | POLLHUP; | 1571 | mask |= POLLERR | POLLHUP; |
1571 | return mask; | 1572 | return mask; |
1572 | } | 1573 | } |