diff options
Diffstat (limited to 'drivers/usb/core/usb.c')
-rw-r--r-- | drivers/usb/core/usb.c | 169 |
1 files changed, 13 insertions, 156 deletions
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c index 467cb02832f3..02426d0b9a34 100644 --- a/drivers/usb/core/usb.c +++ b/drivers/usb/core/usb.c | |||
@@ -200,19 +200,13 @@ static void ksuspend_usb_cleanup(void) | |||
200 | destroy_workqueue(ksuspend_usb_wq); | 200 | destroy_workqueue(ksuspend_usb_wq); |
201 | } | 201 | } |
202 | 202 | ||
203 | #else | ||
204 | |||
205 | #define ksuspend_usb_init() 0 | ||
206 | #define ksuspend_usb_cleanup() do {} while (0) | ||
207 | |||
208 | #endif | ||
209 | |||
210 | #ifdef CONFIG_USB_SUSPEND | 203 | #ifdef CONFIG_USB_SUSPEND |
211 | 204 | ||
212 | /* usb_autosuspend_work - callback routine to autosuspend a USB device */ | 205 | /* usb_autosuspend_work - callback routine to autosuspend a USB device */ |
213 | static void usb_autosuspend_work(void *_udev) | 206 | static void usb_autosuspend_work(struct work_struct *work) |
214 | { | 207 | { |
215 | struct usb_device *udev = _udev; | 208 | struct usb_device *udev = |
209 | container_of(work, struct usb_device, autosuspend.work); | ||
216 | 210 | ||
217 | usb_pm_lock(udev); | 211 | usb_pm_lock(udev); |
218 | udev->auto_pm = 1; | 212 | udev->auto_pm = 1; |
@@ -222,10 +216,17 @@ static void usb_autosuspend_work(void *_udev) | |||
222 | 216 | ||
223 | #else | 217 | #else |
224 | 218 | ||
225 | static void usb_autosuspend_work(void *_udev) | 219 | static void usb_autosuspend_work(struct work_struct *work) |
226 | {} | 220 | {} |
227 | 221 | ||
228 | #endif | 222 | #endif /* CONFIG_USB_SUSPEND */ |
223 | |||
224 | #else | ||
225 | |||
226 | #define ksuspend_usb_init() 0 | ||
227 | #define ksuspend_usb_cleanup() do {} while (0) | ||
228 | |||
229 | #endif /* CONFIG_PM */ | ||
229 | 230 | ||
230 | /** | 231 | /** |
231 | * usb_alloc_dev - usb device constructor (usbcore-internal) | 232 | * usb_alloc_dev - usb device constructor (usbcore-internal) |
@@ -304,7 +305,7 @@ usb_alloc_dev(struct usb_device *parent, struct usb_bus *bus, unsigned port1) | |||
304 | 305 | ||
305 | #ifdef CONFIG_PM | 306 | #ifdef CONFIG_PM |
306 | mutex_init(&dev->pm_mutex); | 307 | mutex_init(&dev->pm_mutex); |
307 | INIT_WORK(&dev->autosuspend, usb_autosuspend_work, dev); | 308 | INIT_DELAYED_WORK(&dev->autosuspend, usb_autosuspend_work); |
308 | #endif | 309 | #endif |
309 | return dev; | 310 | return dev; |
310 | } | 311 | } |
@@ -537,138 +538,6 @@ int usb_get_current_frame_number(struct usb_device *dev) | |||
537 | return usb_hcd_get_frame_number (dev); | 538 | return usb_hcd_get_frame_number (dev); |
538 | } | 539 | } |
539 | 540 | ||
540 | /** | ||
541 | * usb_endpoint_dir_in - check if the endpoint has IN direction | ||
542 | * @epd: endpoint to be checked | ||
543 | * | ||
544 | * Returns true if the endpoint is of type IN, otherwise it returns false. | ||
545 | */ | ||
546 | int usb_endpoint_dir_in(const struct usb_endpoint_descriptor *epd) | ||
547 | { | ||
548 | return ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN); | ||
549 | } | ||
550 | |||
551 | /** | ||
552 | * usb_endpoint_dir_out - check if the endpoint has OUT direction | ||
553 | * @epd: endpoint to be checked | ||
554 | * | ||
555 | * Returns true if the endpoint is of type OUT, otherwise it returns false. | ||
556 | */ | ||
557 | int usb_endpoint_dir_out(const struct usb_endpoint_descriptor *epd) | ||
558 | { | ||
559 | return ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT); | ||
560 | } | ||
561 | |||
562 | /** | ||
563 | * usb_endpoint_xfer_bulk - check if the endpoint has bulk transfer type | ||
564 | * @epd: endpoint to be checked | ||
565 | * | ||
566 | * Returns true if the endpoint is of type bulk, otherwise it returns false. | ||
567 | */ | ||
568 | int usb_endpoint_xfer_bulk(const struct usb_endpoint_descriptor *epd) | ||
569 | { | ||
570 | return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == | ||
571 | USB_ENDPOINT_XFER_BULK); | ||
572 | } | ||
573 | |||
574 | /** | ||
575 | * usb_endpoint_xfer_int - check if the endpoint has interrupt transfer type | ||
576 | * @epd: endpoint to be checked | ||
577 | * | ||
578 | * Returns true if the endpoint is of type interrupt, otherwise it returns | ||
579 | * false. | ||
580 | */ | ||
581 | int usb_endpoint_xfer_int(const struct usb_endpoint_descriptor *epd) | ||
582 | { | ||
583 | return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == | ||
584 | USB_ENDPOINT_XFER_INT); | ||
585 | } | ||
586 | |||
587 | /** | ||
588 | * usb_endpoint_xfer_isoc - check if the endpoint has isochronous transfer type | ||
589 | * @epd: endpoint to be checked | ||
590 | * | ||
591 | * Returns true if the endpoint is of type isochronous, otherwise it returns | ||
592 | * false. | ||
593 | */ | ||
594 | int usb_endpoint_xfer_isoc(const struct usb_endpoint_descriptor *epd) | ||
595 | { | ||
596 | return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == | ||
597 | USB_ENDPOINT_XFER_ISOC); | ||
598 | } | ||
599 | |||
600 | /** | ||
601 | * usb_endpoint_is_bulk_in - check if the endpoint is bulk IN | ||
602 | * @epd: endpoint to be checked | ||
603 | * | ||
604 | * Returns true if the endpoint has bulk transfer type and IN direction, | ||
605 | * otherwise it returns false. | ||
606 | */ | ||
607 | int usb_endpoint_is_bulk_in(const struct usb_endpoint_descriptor *epd) | ||
608 | { | ||
609 | return (usb_endpoint_xfer_bulk(epd) && usb_endpoint_dir_in(epd)); | ||
610 | } | ||
611 | |||
612 | /** | ||
613 | * usb_endpoint_is_bulk_out - check if the endpoint is bulk OUT | ||
614 | * @epd: endpoint to be checked | ||
615 | * | ||
616 | * Returns true if the endpoint has bulk transfer type and OUT direction, | ||
617 | * otherwise it returns false. | ||
618 | */ | ||
619 | int usb_endpoint_is_bulk_out(const struct usb_endpoint_descriptor *epd) | ||
620 | { | ||
621 | return (usb_endpoint_xfer_bulk(epd) && usb_endpoint_dir_out(epd)); | ||
622 | } | ||
623 | |||
624 | /** | ||
625 | * usb_endpoint_is_int_in - check if the endpoint is interrupt IN | ||
626 | * @epd: endpoint to be checked | ||
627 | * | ||
628 | * Returns true if the endpoint has interrupt transfer type and IN direction, | ||
629 | * otherwise it returns false. | ||
630 | */ | ||
631 | int usb_endpoint_is_int_in(const struct usb_endpoint_descriptor *epd) | ||
632 | { | ||
633 | return (usb_endpoint_xfer_int(epd) && usb_endpoint_dir_in(epd)); | ||
634 | } | ||
635 | |||
636 | /** | ||
637 | * usb_endpoint_is_int_out - check if the endpoint is interrupt OUT | ||
638 | * @epd: endpoint to be checked | ||
639 | * | ||
640 | * Returns true if the endpoint has interrupt transfer type and OUT direction, | ||
641 | * otherwise it returns false. | ||
642 | */ | ||
643 | int usb_endpoint_is_int_out(const struct usb_endpoint_descriptor *epd) | ||
644 | { | ||
645 | return (usb_endpoint_xfer_int(epd) && usb_endpoint_dir_out(epd)); | ||
646 | } | ||
647 | |||
648 | /** | ||
649 | * usb_endpoint_is_isoc_in - check if the endpoint is isochronous IN | ||
650 | * @epd: endpoint to be checked | ||
651 | * | ||
652 | * Returns true if the endpoint has isochronous transfer type and IN direction, | ||
653 | * otherwise it returns false. | ||
654 | */ | ||
655 | int usb_endpoint_is_isoc_in(const struct usb_endpoint_descriptor *epd) | ||
656 | { | ||
657 | return (usb_endpoint_xfer_isoc(epd) && usb_endpoint_dir_in(epd)); | ||
658 | } | ||
659 | |||
660 | /** | ||
661 | * usb_endpoint_is_isoc_out - check if the endpoint is isochronous OUT | ||
662 | * @epd: endpoint to be checked | ||
663 | * | ||
664 | * Returns true if the endpoint has isochronous transfer type and OUT direction, | ||
665 | * otherwise it returns false. | ||
666 | */ | ||
667 | int usb_endpoint_is_isoc_out(const struct usb_endpoint_descriptor *epd) | ||
668 | { | ||
669 | return (usb_endpoint_xfer_isoc(epd) && usb_endpoint_dir_out(epd)); | ||
670 | } | ||
671 | |||
672 | /*-------------------------------------------------------------------*/ | 541 | /*-------------------------------------------------------------------*/ |
673 | /* | 542 | /* |
674 | * __usb_get_extra_descriptor() finds a descriptor of specific type in the | 543 | * __usb_get_extra_descriptor() finds a descriptor of specific type in the |
@@ -1102,18 +971,6 @@ EXPORT_SYMBOL(__usb_get_extra_descriptor); | |||
1102 | EXPORT_SYMBOL(usb_find_device); | 971 | EXPORT_SYMBOL(usb_find_device); |
1103 | EXPORT_SYMBOL(usb_get_current_frame_number); | 972 | EXPORT_SYMBOL(usb_get_current_frame_number); |
1104 | 973 | ||
1105 | EXPORT_SYMBOL_GPL(usb_endpoint_dir_in); | ||
1106 | EXPORT_SYMBOL_GPL(usb_endpoint_dir_out); | ||
1107 | EXPORT_SYMBOL_GPL(usb_endpoint_xfer_bulk); | ||
1108 | EXPORT_SYMBOL_GPL(usb_endpoint_xfer_int); | ||
1109 | EXPORT_SYMBOL_GPL(usb_endpoint_xfer_isoc); | ||
1110 | EXPORT_SYMBOL_GPL(usb_endpoint_is_bulk_in); | ||
1111 | EXPORT_SYMBOL_GPL(usb_endpoint_is_bulk_out); | ||
1112 | EXPORT_SYMBOL_GPL(usb_endpoint_is_int_in); | ||
1113 | EXPORT_SYMBOL_GPL(usb_endpoint_is_int_out); | ||
1114 | EXPORT_SYMBOL_GPL(usb_endpoint_is_isoc_in); | ||
1115 | EXPORT_SYMBOL_GPL(usb_endpoint_is_isoc_out); | ||
1116 | |||
1117 | EXPORT_SYMBOL (usb_buffer_alloc); | 974 | EXPORT_SYMBOL (usb_buffer_alloc); |
1118 | EXPORT_SYMBOL (usb_buffer_free); | 975 | EXPORT_SYMBOL (usb_buffer_free); |
1119 | 976 | ||