diff options
| -rw-r--r-- | drivers/usb/core/usb.c | 144 | ||||
| -rw-r--r-- | include/linux/usb.h | 14 |
2 files changed, 158 insertions, 0 deletions
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c index 9ebfc0fe819d..82837d45b484 100644 --- a/drivers/usb/core/usb.c +++ b/drivers/usb/core/usb.c | |||
| @@ -482,6 +482,138 @@ int usb_get_current_frame_number(struct usb_device *dev) | |||
| 482 | return dev->bus->op->get_frame_number (dev); | 482 | return dev->bus->op->get_frame_number (dev); |
| 483 | } | 483 | } |
| 484 | 484 | ||
| 485 | /** | ||
| 486 | * usb_endpoint_dir_in - check if the endpoint has IN direction | ||
| 487 | * @epd: endpoint to be checked | ||
| 488 | * | ||
| 489 | * Returns true if the endpoint is of type IN, otherwise it returns false. | ||
| 490 | */ | ||
| 491 | int usb_endpoint_dir_in(const struct usb_endpoint_descriptor *epd) | ||
| 492 | { | ||
| 493 | return ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN); | ||
| 494 | } | ||
| 495 | |||
| 496 | /** | ||
| 497 | * usb_endpoint_dir_out - check if the endpoint has OUT direction | ||
| 498 | * @epd: endpoint to be checked | ||
| 499 | * | ||
| 500 | * Returns true if the endpoint is of type OUT, otherwise it returns false. | ||
| 501 | */ | ||
| 502 | int usb_endpoint_dir_out(const struct usb_endpoint_descriptor *epd) | ||
| 503 | { | ||
| 504 | return ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT); | ||
| 505 | } | ||
| 506 | |||
| 507 | /** | ||
| 508 | * usb_endpoint_xfer_bulk - check if the endpoint has bulk transfer type | ||
| 509 | * @epd: endpoint to be checked | ||
| 510 | * | ||
| 511 | * Returns true if the endpoint is of type bulk, otherwise it returns false. | ||
| 512 | */ | ||
| 513 | int usb_endpoint_xfer_bulk(const struct usb_endpoint_descriptor *epd) | ||
| 514 | { | ||
| 515 | return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == | ||
| 516 | USB_ENDPOINT_XFER_BULK); | ||
| 517 | } | ||
| 518 | |||
| 519 | /** | ||
| 520 | * usb_endpoint_xfer_int - check if the endpoint has interrupt transfer type | ||
| 521 | * @epd: endpoint to be checked | ||
| 522 | * | ||
| 523 | * Returns true if the endpoint is of type interrupt, otherwise it returns | ||
| 524 | * false. | ||
| 525 | */ | ||
| 526 | int usb_endpoint_xfer_int(const struct usb_endpoint_descriptor *epd) | ||
| 527 | { | ||
| 528 | return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == | ||
| 529 | USB_ENDPOINT_XFER_INT); | ||
| 530 | } | ||
| 531 | |||
| 532 | /** | ||
| 533 | * usb_endpoint_xfer_isoc - check if the endpoint has isochronous transfer type | ||
| 534 | * @epd: endpoint to be checked | ||
| 535 | * | ||
| 536 | * Returns true if the endpoint is of type isochronous, otherwise it returns | ||
| 537 | * false. | ||
| 538 | */ | ||
| 539 | int usb_endpoint_xfer_isoc(const struct usb_endpoint_descriptor *epd) | ||
| 540 | { | ||
| 541 | return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == | ||
| 542 | USB_ENDPOINT_XFER_ISOC); | ||
| 543 | } | ||
| 544 | |||
| 545 | /** | ||
| 546 | * usb_endpoint_is_bulk_in - check if the endpoint is bulk IN | ||
| 547 | * @epd: endpoint to be checked | ||
| 548 | * | ||
| 549 | * Returns true if the endpoint has bulk transfer type and IN direction, | ||
| 550 | * otherwise it returns false. | ||
| 551 | */ | ||
| 552 | int usb_endpoint_is_bulk_in(const struct usb_endpoint_descriptor *epd) | ||
| 553 | { | ||
| 554 | return (usb_endpoint_xfer_bulk(epd) && usb_endpoint_dir_in(epd)); | ||
| 555 | } | ||
| 556 | |||
| 557 | /** | ||
| 558 | * usb_endpoint_is_bulk_out - check if the endpoint is bulk OUT | ||
| 559 | * @epd: endpoint to be checked | ||
| 560 | * | ||
| 561 | * Returns true if the endpoint has bulk transfer type and OUT direction, | ||
| 562 | * otherwise it returns false. | ||
| 563 | */ | ||
| 564 | int usb_endpoint_is_bulk_out(const struct usb_endpoint_descriptor *epd) | ||
| 565 | { | ||
| 566 | return (usb_endpoint_xfer_bulk(epd) && usb_endpoint_dir_out(epd)); | ||
| 567 | } | ||
| 568 | |||
| 569 | /** | ||
| 570 | * usb_endpoint_is_int_in - check if the endpoint is interrupt IN | ||
| 571 | * @epd: endpoint to be checked | ||
| 572 | * | ||
| 573 | * Returns true if the endpoint has interrupt transfer type and IN direction, | ||
| 574 | * otherwise it returns false. | ||
| 575 | */ | ||
| 576 | int usb_endpoint_is_int_in(const struct usb_endpoint_descriptor *epd) | ||
| 577 | { | ||
| 578 | return (usb_endpoint_xfer_int(epd) && usb_endpoint_dir_in(epd)); | ||
| 579 | } | ||
| 580 | |||
| 581 | /** | ||
| 582 | * usb_endpoint_is_int_out - check if the endpoint is interrupt OUT | ||
| 583 | * @epd: endpoint to be checked | ||
| 584 | * | ||
| 585 | * Returns true if the endpoint has interrupt transfer type and OUT direction, | ||
| 586 | * otherwise it returns false. | ||
| 587 | */ | ||
| 588 | int usb_endpoint_is_int_out(const struct usb_endpoint_descriptor *epd) | ||
| 589 | { | ||
| 590 | return (usb_endpoint_xfer_int(epd) && usb_endpoint_dir_out(epd)); | ||
| 591 | } | ||
| 592 | |||
| 593 | /** | ||
| 594 | * usb_endpoint_is_isoc_in - check if the endpoint is isochronous IN | ||
| 595 | * @epd: endpoint to be checked | ||
| 596 | * | ||
| 597 | * Returns true if the endpoint has isochronous transfer type and IN direction, | ||
| 598 | * otherwise it returns false. | ||
| 599 | */ | ||
| 600 | int usb_endpoint_is_isoc_in(const struct usb_endpoint_descriptor *epd) | ||
| 601 | { | ||
| 602 | return (usb_endpoint_xfer_isoc(epd) && usb_endpoint_dir_in(epd)); | ||
| 603 | } | ||
| 604 | |||
| 605 | /** | ||
| 606 | * usb_endpoint_is_isoc_out - check if the endpoint is isochronous OUT | ||
| 607 | * @epd: endpoint to be checked | ||
| 608 | * | ||
| 609 | * Returns true if the endpoint has isochronous transfer type and OUT direction, | ||
| 610 | * otherwise it returns false. | ||
| 611 | */ | ||
| 612 | int usb_endpoint_is_isoc_out(const struct usb_endpoint_descriptor *epd) | ||
| 613 | { | ||
| 614 | return (usb_endpoint_xfer_isoc(epd) && usb_endpoint_dir_out(epd)); | ||
| 615 | } | ||
| 616 | |||
| 485 | /*-------------------------------------------------------------------*/ | 617 | /*-------------------------------------------------------------------*/ |
| 486 | /* | 618 | /* |
| 487 | * __usb_get_extra_descriptor() finds a descriptor of specific type in the | 619 | * __usb_get_extra_descriptor() finds a descriptor of specific type in the |
| @@ -909,6 +1041,18 @@ EXPORT_SYMBOL(__usb_get_extra_descriptor); | |||
| 909 | EXPORT_SYMBOL(usb_find_device); | 1041 | EXPORT_SYMBOL(usb_find_device); |
| 910 | EXPORT_SYMBOL(usb_get_current_frame_number); | 1042 | EXPORT_SYMBOL(usb_get_current_frame_number); |
| 911 | 1043 | ||
| 1044 | EXPORT_SYMBOL_GPL(usb_endpoint_dir_in); | ||
| 1045 | EXPORT_SYMBOL_GPL(usb_endpoint_dir_out); | ||
| 1046 | EXPORT_SYMBOL_GPL(usb_endpoint_xfer_bulk); | ||
| 1047 | EXPORT_SYMBOL_GPL(usb_endpoint_xfer_int); | ||
| 1048 | EXPORT_SYMBOL_GPL(usb_endpoint_xfer_isoc); | ||
| 1049 | EXPORT_SYMBOL_GPL(usb_endpoint_is_bulk_in); | ||
| 1050 | EXPORT_SYMBOL_GPL(usb_endpoint_is_bulk_out); | ||
| 1051 | EXPORT_SYMBOL_GPL(usb_endpoint_is_int_in); | ||
| 1052 | EXPORT_SYMBOL_GPL(usb_endpoint_is_int_out); | ||
| 1053 | EXPORT_SYMBOL_GPL(usb_endpoint_is_isoc_in); | ||
| 1054 | EXPORT_SYMBOL_GPL(usb_endpoint_is_isoc_out); | ||
| 1055 | |||
| 912 | EXPORT_SYMBOL (usb_buffer_alloc); | 1056 | EXPORT_SYMBOL (usb_buffer_alloc); |
| 913 | EXPORT_SYMBOL (usb_buffer_free); | 1057 | EXPORT_SYMBOL (usb_buffer_free); |
| 914 | 1058 | ||
diff --git a/include/linux/usb.h b/include/linux/usb.h index 3d5cfa731680..f807479ef65b 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h | |||
| @@ -467,6 +467,20 @@ static inline int usb_make_path (struct usb_device *dev, char *buf, | |||
| 467 | 467 | ||
| 468 | /*-------------------------------------------------------------------------*/ | 468 | /*-------------------------------------------------------------------------*/ |
| 469 | 469 | ||
| 470 | extern int usb_endpoint_dir_in(const struct usb_endpoint_descriptor *epd); | ||
| 471 | extern int usb_endpoint_dir_out(const struct usb_endpoint_descriptor *epd); | ||
| 472 | extern int usb_endpoint_xfer_bulk(const struct usb_endpoint_descriptor *epd); | ||
| 473 | extern int usb_endpoint_xfer_int(const struct usb_endpoint_descriptor *epd); | ||
| 474 | extern int usb_endpoint_xfer_isoc(const struct usb_endpoint_descriptor *epd); | ||
| 475 | extern int usb_endpoint_is_bulk_in(const struct usb_endpoint_descriptor *epd); | ||
| 476 | extern int usb_endpoint_is_bulk_out(const struct usb_endpoint_descriptor *epd); | ||
| 477 | extern int usb_endpoint_is_int_in(const struct usb_endpoint_descriptor *epd); | ||
| 478 | extern int usb_endpoint_is_int_out(const struct usb_endpoint_descriptor *epd); | ||
| 479 | extern int usb_endpoint_is_isoc_in(const struct usb_endpoint_descriptor *epd); | ||
| 480 | extern int usb_endpoint_is_isoc_out(const struct usb_endpoint_descriptor *epd); | ||
| 481 | |||
| 482 | /*-------------------------------------------------------------------------*/ | ||
| 483 | |||
| 470 | #define USB_DEVICE_ID_MATCH_DEVICE \ | 484 | #define USB_DEVICE_ID_MATCH_DEVICE \ |
| 471 | (USB_DEVICE_ID_MATCH_VENDOR | USB_DEVICE_ID_MATCH_PRODUCT) | 485 | (USB_DEVICE_ID_MATCH_VENDOR | USB_DEVICE_ID_MATCH_PRODUCT) |
| 472 | #define USB_DEVICE_ID_MATCH_DEV_RANGE \ | 486 | #define USB_DEVICE_ID_MATCH_DEV_RANGE \ |
