diff options
-rw-r--r-- | drivers/usb/core/usb.c | 144 | ||||
-rw-r--r-- | include/linux/usb.h | 142 |
2 files changed, 131 insertions, 155 deletions
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c index 467cb02832f3..a83c2d5065c1 100644 --- a/drivers/usb/core/usb.c +++ b/drivers/usb/core/usb.c | |||
@@ -537,138 +537,6 @@ int usb_get_current_frame_number(struct usb_device *dev) | |||
537 | return usb_hcd_get_frame_number (dev); | 537 | return usb_hcd_get_frame_number (dev); |
538 | } | 538 | } |
539 | 539 | ||
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 | /*-------------------------------------------------------------------*/ | 540 | /*-------------------------------------------------------------------*/ |
673 | /* | 541 | /* |
674 | * __usb_get_extra_descriptor() finds a descriptor of specific type in the | 542 | * __usb_get_extra_descriptor() finds a descriptor of specific type in the |
@@ -1102,18 +970,6 @@ EXPORT_SYMBOL(__usb_get_extra_descriptor); | |||
1102 | EXPORT_SYMBOL(usb_find_device); | 970 | EXPORT_SYMBOL(usb_find_device); |
1103 | EXPORT_SYMBOL(usb_get_current_frame_number); | 971 | EXPORT_SYMBOL(usb_get_current_frame_number); |
1104 | 972 | ||
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); | 973 | EXPORT_SYMBOL (usb_buffer_alloc); |
1118 | EXPORT_SYMBOL (usb_buffer_free); | 974 | EXPORT_SYMBOL (usb_buffer_free); |
1119 | 975 | ||
diff --git a/include/linux/usb.h b/include/linux/usb.h index e5cb1690975a..e732e024a141 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h | |||
@@ -495,17 +495,137 @@ static inline int usb_make_path (struct usb_device *dev, char *buf, | |||
495 | 495 | ||
496 | /*-------------------------------------------------------------------------*/ | 496 | /*-------------------------------------------------------------------------*/ |
497 | 497 | ||
498 | extern int usb_endpoint_dir_in(const struct usb_endpoint_descriptor *epd); | 498 | /** |
499 | extern int usb_endpoint_dir_out(const struct usb_endpoint_descriptor *epd); | 499 | * usb_endpoint_dir_in - check if the endpoint has IN direction |
500 | extern int usb_endpoint_xfer_bulk(const struct usb_endpoint_descriptor *epd); | 500 | * @epd: endpoint to be checked |
501 | extern int usb_endpoint_xfer_int(const struct usb_endpoint_descriptor *epd); | 501 | * |
502 | extern int usb_endpoint_xfer_isoc(const struct usb_endpoint_descriptor *epd); | 502 | * Returns true if the endpoint is of type IN, otherwise it returns false. |
503 | extern int usb_endpoint_is_bulk_in(const struct usb_endpoint_descriptor *epd); | 503 | */ |
504 | extern int usb_endpoint_is_bulk_out(const struct usb_endpoint_descriptor *epd); | 504 | static inline int usb_endpoint_dir_in(const struct usb_endpoint_descriptor *epd) |
505 | extern int usb_endpoint_is_int_in(const struct usb_endpoint_descriptor *epd); | 505 | { |
506 | extern int usb_endpoint_is_int_out(const struct usb_endpoint_descriptor *epd); | 506 | return ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN); |
507 | extern int usb_endpoint_is_isoc_in(const struct usb_endpoint_descriptor *epd); | 507 | } |
508 | extern int usb_endpoint_is_isoc_out(const struct usb_endpoint_descriptor *epd); | 508 | |
509 | /** | ||
510 | * usb_endpoint_dir_out - check if the endpoint has OUT direction | ||
511 | * @epd: endpoint to be checked | ||
512 | * | ||
513 | * Returns true if the endpoint is of type OUT, otherwise it returns false. | ||
514 | */ | ||
515 | static inline int usb_endpoint_dir_out(const struct usb_endpoint_descriptor *epd) | ||
516 | { | ||
517 | return ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT); | ||
518 | } | ||
519 | |||
520 | /** | ||
521 | * usb_endpoint_xfer_bulk - check if the endpoint has bulk transfer type | ||
522 | * @epd: endpoint to be checked | ||
523 | * | ||
524 | * Returns true if the endpoint is of type bulk, otherwise it returns false. | ||
525 | */ | ||
526 | static inline int usb_endpoint_xfer_bulk(const struct usb_endpoint_descriptor *epd) | ||
527 | { | ||
528 | return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == | ||
529 | USB_ENDPOINT_XFER_BULK); | ||
530 | } | ||
531 | |||
532 | /** | ||
533 | * usb_endpoint_xfer_int - check if the endpoint has interrupt transfer type | ||
534 | * @epd: endpoint to be checked | ||
535 | * | ||
536 | * Returns true if the endpoint is of type interrupt, otherwise it returns | ||
537 | * false. | ||
538 | */ | ||
539 | static inline int usb_endpoint_xfer_int(const struct usb_endpoint_descriptor *epd) | ||
540 | { | ||
541 | return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == | ||
542 | USB_ENDPOINT_XFER_INT); | ||
543 | } | ||
544 | |||
545 | /** | ||
546 | * usb_endpoint_xfer_isoc - check if the endpoint has isochronous transfer type | ||
547 | * @epd: endpoint to be checked | ||
548 | * | ||
549 | * Returns true if the endpoint is of type isochronous, otherwise it returns | ||
550 | * false. | ||
551 | */ | ||
552 | static inline int usb_endpoint_xfer_isoc(const struct usb_endpoint_descriptor *epd) | ||
553 | { | ||
554 | return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == | ||
555 | USB_ENDPOINT_XFER_ISOC); | ||
556 | } | ||
557 | |||
558 | /** | ||
559 | * usb_endpoint_is_bulk_in - check if the endpoint is bulk IN | ||
560 | * @epd: endpoint to be checked | ||
561 | * | ||
562 | * Returns true if the endpoint has bulk transfer type and IN direction, | ||
563 | * otherwise it returns false. | ||
564 | */ | ||
565 | static inline int usb_endpoint_is_bulk_in(const struct usb_endpoint_descriptor *epd) | ||
566 | { | ||
567 | return (usb_endpoint_xfer_bulk(epd) && usb_endpoint_dir_in(epd)); | ||
568 | } | ||
569 | |||
570 | /** | ||
571 | * usb_endpoint_is_bulk_out - check if the endpoint is bulk OUT | ||
572 | * @epd: endpoint to be checked | ||
573 | * | ||
574 | * Returns true if the endpoint has bulk transfer type and OUT direction, | ||
575 | * otherwise it returns false. | ||
576 | */ | ||
577 | static inline int usb_endpoint_is_bulk_out(const struct usb_endpoint_descriptor *epd) | ||
578 | { | ||
579 | return (usb_endpoint_xfer_bulk(epd) && usb_endpoint_dir_out(epd)); | ||
580 | } | ||
581 | |||
582 | /** | ||
583 | * usb_endpoint_is_int_in - check if the endpoint is interrupt IN | ||
584 | * @epd: endpoint to be checked | ||
585 | * | ||
586 | * Returns true if the endpoint has interrupt transfer type and IN direction, | ||
587 | * otherwise it returns false. | ||
588 | */ | ||
589 | static inline int usb_endpoint_is_int_in(const struct usb_endpoint_descriptor *epd) | ||
590 | { | ||
591 | return (usb_endpoint_xfer_int(epd) && usb_endpoint_dir_in(epd)); | ||
592 | } | ||
593 | |||
594 | /** | ||
595 | * usb_endpoint_is_int_out - check if the endpoint is interrupt OUT | ||
596 | * @epd: endpoint to be checked | ||
597 | * | ||
598 | * Returns true if the endpoint has interrupt transfer type and OUT direction, | ||
599 | * otherwise it returns false. | ||
600 | */ | ||
601 | static inline int usb_endpoint_is_int_out(const struct usb_endpoint_descriptor *epd) | ||
602 | { | ||
603 | return (usb_endpoint_xfer_int(epd) && usb_endpoint_dir_out(epd)); | ||
604 | } | ||
605 | |||
606 | /** | ||
607 | * usb_endpoint_is_isoc_in - check if the endpoint is isochronous IN | ||
608 | * @epd: endpoint to be checked | ||
609 | * | ||
610 | * Returns true if the endpoint has isochronous transfer type and IN direction, | ||
611 | * otherwise it returns false. | ||
612 | */ | ||
613 | static inline int usb_endpoint_is_isoc_in(const struct usb_endpoint_descriptor *epd) | ||
614 | { | ||
615 | return (usb_endpoint_xfer_isoc(epd) && usb_endpoint_dir_in(epd)); | ||
616 | } | ||
617 | |||
618 | /** | ||
619 | * usb_endpoint_is_isoc_out - check if the endpoint is isochronous OUT | ||
620 | * @epd: endpoint to be checked | ||
621 | * | ||
622 | * Returns true if the endpoint has isochronous transfer type and OUT direction, | ||
623 | * otherwise it returns false. | ||
624 | */ | ||
625 | static inline int usb_endpoint_is_isoc_out(const struct usb_endpoint_descriptor *epd) | ||
626 | { | ||
627 | return (usb_endpoint_xfer_isoc(epd) && usb_endpoint_dir_out(epd)); | ||
628 | } | ||
509 | 629 | ||
510 | /*-------------------------------------------------------------------------*/ | 630 | /*-------------------------------------------------------------------------*/ |
511 | 631 | ||