diff options
author | Luiz Fernando N. Capitulino <lcapitulino@mandriva.com.br> | 2006-10-30 12:53:03 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2006-12-01 17:23:29 -0500 |
commit | 0c1ac4f25f894f9df0ffe9b912c165fb6a185a3c (patch) | |
tree | 07242b094efb9c306d7b825f70d9c1660ab95241 /include/linux/usb.h | |
parent | 6f7cd44162ca1bffd54f4090e67b9810bacb5d25 (diff) |
USB: makes usb_endpoint_* functions inline.
We have no benefits of having the usb_endpoint_* functions as functions,
but making them inline saves text and data segment sizes:
text data bss dec hex filename
14893634 3108770 1108840 19111244 1239d4c vmlinux.func
14893185 3108566 1108840 19110591 1239abf vmlinux.inline
This is the result of a 2.6.19-rc3 kernel compiled with GCC 4.1.1 without
CONFIG_MODULES, CONFIG_CC_OPTIMIZE_FOR_SIZE, CONFIG_REGPARM options set.
USB support is fully enabled (while most of the other drivers are not),
and that kernel has most of the USB code ported to use the endpoint
functions.
That happens because a call to those functions are expensive (in terms
of bytes), while the function's size is smaller or have the same 'size' of
the call.
Signed-off-by: Luiz Fernando N. Capitulino <lcapitulino@mandriva.com.br>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'include/linux/usb.h')
-rw-r--r-- | include/linux/usb.h | 142 |
1 files changed, 131 insertions, 11 deletions
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 | ||