diff options
Diffstat (limited to 'drivers/usb/class/usblp.c')
-rw-r--r-- | drivers/usb/class/usblp.c | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/drivers/usb/class/usblp.c b/drivers/usb/class/usblp.c index 6377db1b446d..63e50a1f1396 100644 --- a/drivers/usb/class/usblp.c +++ b/drivers/usb/class/usblp.c | |||
@@ -398,6 +398,9 @@ static int usblp_open(struct inode *inode, struct file *file) | |||
398 | retval = 0; | 398 | retval = 0; |
399 | #endif | 399 | #endif |
400 | 400 | ||
401 | retval = usb_autopm_get_interface(intf); | ||
402 | if (retval < 0) | ||
403 | goto out; | ||
401 | usblp->used = 1; | 404 | usblp->used = 1; |
402 | file->private_data = usblp; | 405 | file->private_data = usblp; |
403 | 406 | ||
@@ -442,6 +445,7 @@ static int usblp_release(struct inode *inode, struct file *file) | |||
442 | usblp->used = 0; | 445 | usblp->used = 0; |
443 | if (usblp->present) { | 446 | if (usblp->present) { |
444 | usblp_unlink_urbs(usblp); | 447 | usblp_unlink_urbs(usblp); |
448 | usb_autopm_put_interface(usblp->intf); | ||
445 | } else /* finish cleanup from disconnect */ | 449 | } else /* finish cleanup from disconnect */ |
446 | usblp_cleanup (usblp); | 450 | usblp_cleanup (usblp); |
447 | mutex_unlock (&usblp_mutex); | 451 | mutex_unlock (&usblp_mutex); |
@@ -1203,14 +1207,9 @@ static int usblp_suspend (struct usb_interface *intf, pm_message_t message) | |||
1203 | { | 1207 | { |
1204 | struct usblp *usblp = usb_get_intfdata (intf); | 1208 | struct usblp *usblp = usb_get_intfdata (intf); |
1205 | 1209 | ||
1206 | /* this races against normal access and open */ | ||
1207 | mutex_lock (&usblp_mutex); | ||
1208 | mutex_lock (&usblp->mut); | ||
1209 | /* we take no more IO */ | 1210 | /* we take no more IO */ |
1210 | usblp->sleeping = 1; | 1211 | usblp->sleeping = 1; |
1211 | usblp_unlink_urbs(usblp); | 1212 | usblp_unlink_urbs(usblp); |
1212 | mutex_unlock (&usblp->mut); | ||
1213 | mutex_unlock (&usblp_mutex); | ||
1214 | 1213 | ||
1215 | return 0; | 1214 | return 0; |
1216 | } | 1215 | } |
@@ -1220,15 +1219,9 @@ static int usblp_resume (struct usb_interface *intf) | |||
1220 | struct usblp *usblp = usb_get_intfdata (intf); | 1219 | struct usblp *usblp = usb_get_intfdata (intf); |
1221 | int r; | 1220 | int r; |
1222 | 1221 | ||
1223 | mutex_lock (&usblp_mutex); | ||
1224 | mutex_lock (&usblp->mut); | ||
1225 | |||
1226 | usblp->sleeping = 0; | 1222 | usblp->sleeping = 0; |
1227 | r = handle_bidir (usblp); | 1223 | r = handle_bidir (usblp); |
1228 | 1224 | ||
1229 | mutex_unlock (&usblp->mut); | ||
1230 | mutex_unlock (&usblp_mutex); | ||
1231 | |||
1232 | return r; | 1225 | return r; |
1233 | } | 1226 | } |
1234 | 1227 | ||
@@ -1251,6 +1244,7 @@ static struct usb_driver usblp_driver = { | |||
1251 | .suspend = usblp_suspend, | 1244 | .suspend = usblp_suspend, |
1252 | .resume = usblp_resume, | 1245 | .resume = usblp_resume, |
1253 | .id_table = usblp_ids, | 1246 | .id_table = usblp_ids, |
1247 | .supports_autosuspend = 1, | ||
1254 | }; | 1248 | }; |
1255 | 1249 | ||
1256 | static int __init usblp_init(void) | 1250 | static int __init usblp_init(void) |