diff options
Diffstat (limited to 'include/linux/usb/ch9.h')
| -rw-r--r-- | include/linux/usb/ch9.h | 183 |
1 files changed, 181 insertions, 2 deletions
diff --git a/include/linux/usb/ch9.h b/include/linux/usb/ch9.h index 9b42baed390..b145119a90d 100644 --- a/include/linux/usb/ch9.h +++ b/include/linux/usb/ch9.h | |||
| @@ -102,7 +102,7 @@ | |||
| 102 | #define USB_REQ_LOOPBACK_DATA_READ 0x16 | 102 | #define USB_REQ_LOOPBACK_DATA_READ 0x16 |
| 103 | #define USB_REQ_SET_INTERFACE_DS 0x17 | 103 | #define USB_REQ_SET_INTERFACE_DS 0x17 |
| 104 | 104 | ||
| 105 | /* The Link Power Mangement (LPM) ECN defines USB_REQ_TEST_AND_SET command, | 105 | /* The Link Power Management (LPM) ECN defines USB_REQ_TEST_AND_SET command, |
| 106 | * used by hubs to put ports into a new L1 suspend state, except that it | 106 | * used by hubs to put ports into a new L1 suspend state, except that it |
| 107 | * forgot to define its number ... | 107 | * forgot to define its number ... |
| 108 | */ | 108 | */ |
| @@ -353,6 +353,185 @@ struct usb_endpoint_descriptor { | |||
| 353 | #define USB_ENDPOINT_XFER_INT 3 | 353 | #define USB_ENDPOINT_XFER_INT 3 |
| 354 | #define USB_ENDPOINT_MAX_ADJUSTABLE 0x80 | 354 | #define USB_ENDPOINT_MAX_ADJUSTABLE 0x80 |
| 355 | 355 | ||
| 356 | /*-------------------------------------------------------------------------*/ | ||
| 357 | |||
| 358 | /** | ||
| 359 | * usb_endpoint_num - get the endpoint's number | ||
| 360 | * @epd: endpoint to be checked | ||
| 361 | * | ||
| 362 | * Returns @epd's number: 0 to 15. | ||
| 363 | */ | ||
| 364 | static inline int usb_endpoint_num(const struct usb_endpoint_descriptor *epd) | ||
| 365 | { | ||
| 366 | return epd->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK; | ||
| 367 | } | ||
| 368 | |||
| 369 | /** | ||
| 370 | * usb_endpoint_type - get the endpoint's transfer type | ||
| 371 | * @epd: endpoint to be checked | ||
| 372 | * | ||
| 373 | * Returns one of USB_ENDPOINT_XFER_{CONTROL, ISOC, BULK, INT} according | ||
| 374 | * to @epd's transfer type. | ||
| 375 | */ | ||
| 376 | static inline int usb_endpoint_type(const struct usb_endpoint_descriptor *epd) | ||
| 377 | { | ||
| 378 | return epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK; | ||
| 379 | } | ||
| 380 | |||
| 381 | /** | ||
| 382 | * usb_endpoint_dir_in - check if the endpoint has IN direction | ||
| 383 | * @epd: endpoint to be checked | ||
| 384 | * | ||
| 385 | * Returns true if the endpoint is of type IN, otherwise it returns false. | ||
| 386 | */ | ||
| 387 | static inline int usb_endpoint_dir_in(const struct usb_endpoint_descriptor *epd) | ||
| 388 | { | ||
| 389 | return ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN); | ||
| 390 | } | ||
| 391 | |||
| 392 | /** | ||
| 393 | * usb_endpoint_dir_out - check if the endpoint has OUT direction | ||
| 394 | * @epd: endpoint to be checked | ||
| 395 | * | ||
| 396 | * Returns true if the endpoint is of type OUT, otherwise it returns false. | ||
| 397 | */ | ||
| 398 | static inline int usb_endpoint_dir_out( | ||
| 399 | const struct usb_endpoint_descriptor *epd) | ||
| 400 | { | ||
| 401 | return ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT); | ||
| 402 | } | ||
| 403 | |||
| 404 | /** | ||
| 405 | * usb_endpoint_xfer_bulk - check if the endpoint has bulk transfer type | ||
| 406 | * @epd: endpoint to be checked | ||
| 407 | * | ||
| 408 | * Returns true if the endpoint is of type bulk, otherwise it returns false. | ||
| 409 | */ | ||
| 410 | static inline int usb_endpoint_xfer_bulk( | ||
| 411 | const struct usb_endpoint_descriptor *epd) | ||
| 412 | { | ||
| 413 | return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == | ||
| 414 | USB_ENDPOINT_XFER_BULK); | ||
| 415 | } | ||
| 416 | |||
| 417 | /** | ||
| 418 | * usb_endpoint_xfer_control - check if the endpoint has control transfer type | ||
| 419 | * @epd: endpoint to be checked | ||
| 420 | * | ||
| 421 | * Returns true if the endpoint is of type control, otherwise it returns false. | ||
| 422 | */ | ||
| 423 | static inline int usb_endpoint_xfer_control( | ||
| 424 | const struct usb_endpoint_descriptor *epd) | ||
| 425 | { | ||
| 426 | return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == | ||
| 427 | USB_ENDPOINT_XFER_CONTROL); | ||
| 428 | } | ||
| 429 | |||
| 430 | /** | ||
| 431 | * usb_endpoint_xfer_int - check if the endpoint has interrupt transfer type | ||
| 432 | * @epd: endpoint to be checked | ||
| 433 | * | ||
| 434 | * Returns true if the endpoint is of type interrupt, otherwise it returns | ||
| 435 | * false. | ||
| 436 | */ | ||
| 437 | static inline int usb_endpoint_xfer_int( | ||
| 438 | const struct usb_endpoint_descriptor *epd) | ||
| 439 | { | ||
| 440 | return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == | ||
| 441 | USB_ENDPOINT_XFER_INT); | ||
| 442 | } | ||
| 443 | |||
| 444 | /** | ||
| 445 | * usb_endpoint_xfer_isoc - check if the endpoint has isochronous transfer type | ||
| 446 | * @epd: endpoint to be checked | ||
| 447 | * | ||
| 448 | * Returns true if the endpoint is of type isochronous, otherwise it returns | ||
| 449 | * false. | ||
| 450 | */ | ||
| 451 | static inline int usb_endpoint_xfer_isoc( | ||
| 452 | const struct usb_endpoint_descriptor *epd) | ||
| 453 | { | ||
| 454 | return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == | ||
| 455 | USB_ENDPOINT_XFER_ISOC); | ||
| 456 | } | ||
| 457 | |||
| 458 | /** | ||
| 459 | * usb_endpoint_is_bulk_in - check if the endpoint is bulk IN | ||
| 460 | * @epd: endpoint to be checked | ||
| 461 | * | ||
| 462 | * Returns true if the endpoint has bulk transfer type and IN direction, | ||
| 463 | * otherwise it returns false. | ||
| 464 | */ | ||
| 465 | static inline int usb_endpoint_is_bulk_in( | ||
| 466 | const struct usb_endpoint_descriptor *epd) | ||
| 467 | { | ||
| 468 | return (usb_endpoint_xfer_bulk(epd) && usb_endpoint_dir_in(epd)); | ||
| 469 | } | ||
| 470 | |||
| 471 | /** | ||
| 472 | * usb_endpoint_is_bulk_out - check if the endpoint is bulk OUT | ||
| 473 | * @epd: endpoint to be checked | ||
| 474 | * | ||
| 475 | * Returns true if the endpoint has bulk transfer type and OUT direction, | ||
| 476 | * otherwise it returns false. | ||
| 477 | */ | ||
| 478 | static inline int usb_endpoint_is_bulk_out( | ||
| 479 | const struct usb_endpoint_descriptor *epd) | ||
| 480 | { | ||
| 481 | return (usb_endpoint_xfer_bulk(epd) && usb_endpoint_dir_out(epd)); | ||
| 482 | } | ||
| 483 | |||
| 484 | /** | ||
| 485 | * usb_endpoint_is_int_in - check if the endpoint is interrupt IN | ||
| 486 | * @epd: endpoint to be checked | ||
| 487 | * | ||
| 488 | * Returns true if the endpoint has interrupt transfer type and IN direction, | ||
| 489 | * otherwise it returns false. | ||
| 490 | */ | ||
| 491 | static inline int usb_endpoint_is_int_in( | ||
| 492 | const struct usb_endpoint_descriptor *epd) | ||
| 493 | { | ||
| 494 | return (usb_endpoint_xfer_int(epd) && usb_endpoint_dir_in(epd)); | ||
| 495 | } | ||
| 496 | |||
| 497 | /** | ||
| 498 | * usb_endpoint_is_int_out - check if the endpoint is interrupt OUT | ||
| 499 | * @epd: endpoint to be checked | ||
| 500 | * | ||
| 501 | * Returns true if the endpoint has interrupt transfer type and OUT direction, | ||
| 502 | * otherwise it returns false. | ||
| 503 | */ | ||
| 504 | static inline int usb_endpoint_is_int_out( | ||
| 505 | const struct usb_endpoint_descriptor *epd) | ||
| 506 | { | ||
| 507 | return (usb_endpoint_xfer_int(epd) && usb_endpoint_dir_out(epd)); | ||
| 508 | } | ||
| 509 | |||
| 510 | /** | ||
| 511 | * usb_endpoint_is_isoc_in - check if the endpoint is isochronous IN | ||
| 512 | * @epd: endpoint to be checked | ||
| 513 | * | ||
| 514 | * Returns true if the endpoint has isochronous transfer type and IN direction, | ||
| 515 | * otherwise it returns false. | ||
| 516 | */ | ||
| 517 | static inline int usb_endpoint_is_isoc_in( | ||
| 518 | const struct usb_endpoint_descriptor *epd) | ||
| 519 | { | ||
| 520 | return (usb_endpoint_xfer_isoc(epd) && usb_endpoint_dir_in(epd)); | ||
| 521 | } | ||
| 522 | |||
| 523 | /** | ||
| 524 | * usb_endpoint_is_isoc_out - check if the endpoint is isochronous OUT | ||
| 525 | * @epd: endpoint to be checked | ||
| 526 | * | ||
| 527 | * Returns true if the endpoint has isochronous transfer type and OUT direction, | ||
| 528 | * otherwise it returns false. | ||
| 529 | */ | ||
| 530 | static inline int usb_endpoint_is_isoc_out( | ||
| 531 | const struct usb_endpoint_descriptor *epd) | ||
| 532 | { | ||
| 533 | return (usb_endpoint_xfer_isoc(epd) && usb_endpoint_dir_out(epd)); | ||
| 534 | } | ||
| 356 | 535 | ||
| 357 | /*-------------------------------------------------------------------------*/ | 536 | /*-------------------------------------------------------------------------*/ |
| 358 | 537 | ||
| @@ -584,8 +763,8 @@ enum usb_device_state { | |||
| 584 | /* chapter 9 and authentication (wireless) device states */ | 763 | /* chapter 9 and authentication (wireless) device states */ |
| 585 | USB_STATE_ATTACHED, | 764 | USB_STATE_ATTACHED, |
| 586 | USB_STATE_POWERED, /* wired */ | 765 | USB_STATE_POWERED, /* wired */ |
| 587 | USB_STATE_UNAUTHENTICATED, /* auth */ | ||
| 588 | USB_STATE_RECONNECTING, /* auth */ | 766 | USB_STATE_RECONNECTING, /* auth */ |
| 767 | USB_STATE_UNAUTHENTICATED, /* auth */ | ||
| 589 | USB_STATE_DEFAULT, /* limited function */ | 768 | USB_STATE_DEFAULT, /* limited function */ |
| 590 | USB_STATE_ADDRESS, | 769 | USB_STATE_ADDRESS, |
| 591 | USB_STATE_CONFIGURED, /* most functions */ | 770 | USB_STATE_CONFIGURED, /* most functions */ |
