diff options
author | David Brownell <david-b@pacbell.net> | 2007-08-02 02:58:22 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2007-10-12 17:55:03 -0400 |
commit | a4e3ef5597e26dad006544d38b9ab6ff42382b76 (patch) | |
tree | ea35833ffe27301bd058f64dda90d190decc0265 /include/linux/usb_gadget.h | |
parent | a1d534bb23e5c5c28fb6f6fb48588362df0907e8 (diff) |
USB: gadget: gadget_is_{dualspeed,otg} predicates and cleanup
This adds two small inlines to the gadget stack, which will
often evaluate to compile-time constants. That can help
shrink object code and remove #ifdeffery.
- gadget_is_dualspeed(), currently always a compile-time
constant (depending on which controller is selected).
- gadget_is_otg(), usually a compile time "false", but this
is a runtime test if the platform enables OTG (since it's
reasonable to populate boards with different USB sockets).
It also updates two peripheral controller drivers to use these:
- fsl_usb2_udc, mostly OTG-related bugfixes: non-OTG devices
must follow the rules about drawing VBUS power, and OTG ones
need to reject invalid SET_FEATURE requests.
- omap_udc, just scrubbing a bit of #ifdeffery.
And also gadgetfs, which lost some #ifdefs and moved to a more
standard handling of DEBUG and VERBOSE_DEBUG.
The main benefits come from patches which will follow.
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'include/linux/usb_gadget.h')
-rw-r--r-- | include/linux/usb_gadget.h | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/include/linux/usb_gadget.h b/include/linux/usb_gadget.h index ec9732e7fea2..5ea611e48ec1 100644 --- a/include/linux/usb_gadget.h +++ b/include/linux/usb_gadget.h | |||
@@ -480,6 +480,39 @@ static inline void *get_gadget_data (struct usb_gadget *gadget) | |||
480 | 480 | ||
481 | 481 | ||
482 | /** | 482 | /** |
483 | * gadget_is_dualspeed - return true iff the hardware handles high speed | ||
484 | * @gadget: controller that might support both high and full speeds | ||
485 | */ | ||
486 | static inline int gadget_is_dualspeed(struct usb_gadget *g) | ||
487 | { | ||
488 | #ifdef CONFIG_USB_GADGET_DUALSPEED | ||
489 | /* runtime test would check "g->is_dualspeed" ... that might be | ||
490 | * useful to work around hardware bugs, but is mostly pointless | ||
491 | */ | ||
492 | return 1; | ||
493 | #else | ||
494 | return 0; | ||
495 | #endif | ||
496 | } | ||
497 | |||
498 | /** | ||
499 | * gadget_is_otg - return true iff the hardware is OTG-ready | ||
500 | * @gadget: controller that might have a Mini-AB connector | ||
501 | * | ||
502 | * This is a runtime test, since kernels with a USB-OTG stack sometimes | ||
503 | * run on boards which only have a Mini-B (or Mini-A) connector. | ||
504 | */ | ||
505 | static inline int gadget_is_otg(struct usb_gadget *g) | ||
506 | { | ||
507 | #ifdef CONFIG_USB_OTG | ||
508 | return g->is_otg; | ||
509 | #else | ||
510 | return 0; | ||
511 | #endif | ||
512 | } | ||
513 | |||
514 | |||
515 | /** | ||
483 | * usb_gadget_frame_number - returns the current frame number | 516 | * usb_gadget_frame_number - returns the current frame number |
484 | * @gadget: controller that reports the frame number | 517 | * @gadget: controller that reports the frame number |
485 | * | 518 | * |