aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/usb/core/devio.c13
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
93static inline int connected (struct usb_device *dev) 93static 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
98static loff_t usbdev_lseek(struct file *file, loff_t offset, int orig) 99static 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}