diff options
Diffstat (limited to 'include/linux/usb/gadget.h')
-rw-r--r-- | include/linux/usb/gadget.h | 123 |
1 files changed, 55 insertions, 68 deletions
diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h index c1527c2ef3cb..aa3047ff00d1 100644 --- a/include/linux/usb/gadget.h +++ b/include/linux/usb/gadget.h | |||
@@ -70,9 +70,10 @@ struct usb_ep; | |||
70 | * | 70 | * |
71 | * Bulk endpoints can use any size buffers, and can also be used for interrupt | 71 | * Bulk endpoints can use any size buffers, and can also be used for interrupt |
72 | * transfers. interrupt-only endpoints can be much less functional. | 72 | * transfers. interrupt-only endpoints can be much less functional. |
73 | * | ||
74 | * NOTE: this is analagous to 'struct urb' on the host side, except that | ||
75 | * it's thinner and promotes more pre-allocation. | ||
73 | */ | 76 | */ |
74 | // NOTE this is analagous to 'struct urb' on the host side, | ||
75 | // except that it's thinner and promotes more pre-allocation. | ||
76 | 77 | ||
77 | struct usb_request { | 78 | struct usb_request { |
78 | void *buf; | 79 | void *buf; |
@@ -168,10 +169,10 @@ struct usb_ep { | |||
168 | * | 169 | * |
169 | * returns zero, or a negative error code. | 170 | * returns zero, or a negative error code. |
170 | */ | 171 | */ |
171 | static inline int | 172 | static inline int usb_ep_enable(struct usb_ep *ep, |
172 | usb_ep_enable (struct usb_ep *ep, const struct usb_endpoint_descriptor *desc) | 173 | const struct usb_endpoint_descriptor *desc) |
173 | { | 174 | { |
174 | return ep->ops->enable (ep, desc); | 175 | return ep->ops->enable(ep, desc); |
175 | } | 176 | } |
176 | 177 | ||
177 | /** | 178 | /** |
@@ -186,10 +187,9 @@ usb_ep_enable (struct usb_ep *ep, const struct usb_endpoint_descriptor *desc) | |||
186 | * | 187 | * |
187 | * returns zero, or a negative error code. | 188 | * returns zero, or a negative error code. |
188 | */ | 189 | */ |
189 | static inline int | 190 | static inline int usb_ep_disable(struct usb_ep *ep) |
190 | usb_ep_disable (struct usb_ep *ep) | ||
191 | { | 191 | { |
192 | return ep->ops->disable (ep); | 192 | return ep->ops->disable(ep); |
193 | } | 193 | } |
194 | 194 | ||
195 | /** | 195 | /** |
@@ -206,10 +206,10 @@ usb_ep_disable (struct usb_ep *ep) | |||
206 | * | 206 | * |
207 | * Returns the request, or null if one could not be allocated. | 207 | * Returns the request, or null if one could not be allocated. |
208 | */ | 208 | */ |
209 | static inline struct usb_request * | 209 | static inline struct usb_request *usb_ep_alloc_request(struct usb_ep *ep, |
210 | usb_ep_alloc_request (struct usb_ep *ep, gfp_t gfp_flags) | 210 | gfp_t gfp_flags) |
211 | { | 211 | { |
212 | return ep->ops->alloc_request (ep, gfp_flags); | 212 | return ep->ops->alloc_request(ep, gfp_flags); |
213 | } | 213 | } |
214 | 214 | ||
215 | /** | 215 | /** |
@@ -221,10 +221,10 @@ usb_ep_alloc_request (struct usb_ep *ep, gfp_t gfp_flags) | |||
221 | * Caller guarantees the request is not queued, and that it will | 221 | * Caller guarantees the request is not queued, and that it will |
222 | * no longer be requeued (or otherwise used). | 222 | * no longer be requeued (or otherwise used). |
223 | */ | 223 | */ |
224 | static inline void | 224 | static inline void usb_ep_free_request(struct usb_ep *ep, |
225 | usb_ep_free_request (struct usb_ep *ep, struct usb_request *req) | 225 | struct usb_request *req) |
226 | { | 226 | { |
227 | ep->ops->free_request (ep, req); | 227 | ep->ops->free_request(ep, req); |
228 | } | 228 | } |
229 | 229 | ||
230 | /** | 230 | /** |
@@ -281,10 +281,10 @@ usb_ep_free_request (struct usb_ep *ep, struct usb_request *req) | |||
281 | * report errors; errors will also be | 281 | * report errors; errors will also be |
282 | * reported when the usb peripheral is disconnected. | 282 | * reported when the usb peripheral is disconnected. |
283 | */ | 283 | */ |
284 | static inline int | 284 | static inline int usb_ep_queue(struct usb_ep *ep, |
285 | usb_ep_queue (struct usb_ep *ep, struct usb_request *req, gfp_t gfp_flags) | 285 | struct usb_request *req, gfp_t gfp_flags) |
286 | { | 286 | { |
287 | return ep->ops->queue (ep, req, gfp_flags); | 287 | return ep->ops->queue(ep, req, gfp_flags); |
288 | } | 288 | } |
289 | 289 | ||
290 | /** | 290 | /** |
@@ -301,9 +301,9 @@ usb_ep_queue (struct usb_ep *ep, struct usb_request *req, gfp_t gfp_flags) | |||
301 | * restrictions prevent drivers from supporting configuration changes, | 301 | * restrictions prevent drivers from supporting configuration changes, |
302 | * even to configuration zero (a "chapter 9" requirement). | 302 | * even to configuration zero (a "chapter 9" requirement). |
303 | */ | 303 | */ |
304 | static inline int usb_ep_dequeue (struct usb_ep *ep, struct usb_request *req) | 304 | static inline int usb_ep_dequeue(struct usb_ep *ep, struct usb_request *req) |
305 | { | 305 | { |
306 | return ep->ops->dequeue (ep, req); | 306 | return ep->ops->dequeue(ep, req); |
307 | } | 307 | } |
308 | 308 | ||
309 | /** | 309 | /** |
@@ -327,10 +327,9 @@ static inline int usb_ep_dequeue (struct usb_ep *ep, struct usb_request *req) | |||
327 | * transfer requests are still queued, or if the controller hardware | 327 | * transfer requests are still queued, or if the controller hardware |
328 | * (usually a FIFO) still holds bytes that the host hasn't collected. | 328 | * (usually a FIFO) still holds bytes that the host hasn't collected. |
329 | */ | 329 | */ |
330 | static inline int | 330 | static inline int usb_ep_set_halt(struct usb_ep *ep) |
331 | usb_ep_set_halt (struct usb_ep *ep) | ||
332 | { | 331 | { |
333 | return ep->ops->set_halt (ep, 1); | 332 | return ep->ops->set_halt(ep, 1); |
334 | } | 333 | } |
335 | 334 | ||
336 | /** | 335 | /** |
@@ -346,10 +345,9 @@ usb_ep_set_halt (struct usb_ep *ep) | |||
346 | * Note that some hardware can't support this request (like pxa2xx_udc), | 345 | * Note that some hardware can't support this request (like pxa2xx_udc), |
347 | * and accordingly can't correctly implement interface altsettings. | 346 | * and accordingly can't correctly implement interface altsettings. |
348 | */ | 347 | */ |
349 | static inline int | 348 | static inline int usb_ep_clear_halt(struct usb_ep *ep) |
350 | usb_ep_clear_halt (struct usb_ep *ep) | ||
351 | { | 349 | { |
352 | return ep->ops->set_halt (ep, 0); | 350 | return ep->ops->set_halt(ep, 0); |
353 | } | 351 | } |
354 | 352 | ||
355 | /** | 353 | /** |
@@ -367,11 +365,10 @@ usb_ep_clear_halt (struct usb_ep *ep) | |||
367 | * errno if the endpoint doesn't use a FIFO or doesn't support such | 365 | * errno if the endpoint doesn't use a FIFO or doesn't support such |
368 | * precise handling. | 366 | * precise handling. |
369 | */ | 367 | */ |
370 | static inline int | 368 | static inline int usb_ep_fifo_status(struct usb_ep *ep) |
371 | usb_ep_fifo_status (struct usb_ep *ep) | ||
372 | { | 369 | { |
373 | if (ep->ops->fifo_status) | 370 | if (ep->ops->fifo_status) |
374 | return ep->ops->fifo_status (ep); | 371 | return ep->ops->fifo_status(ep); |
375 | else | 372 | else |
376 | return -EOPNOTSUPP; | 373 | return -EOPNOTSUPP; |
377 | } | 374 | } |
@@ -385,11 +382,10 @@ usb_ep_fifo_status (struct usb_ep *ep) | |||
385 | * must never be used except when endpoint is not being used for any | 382 | * must never be used except when endpoint is not being used for any |
386 | * protocol translation. | 383 | * protocol translation. |
387 | */ | 384 | */ |
388 | static inline void | 385 | static inline void usb_ep_fifo_flush(struct usb_ep *ep) |
389 | usb_ep_fifo_flush (struct usb_ep *ep) | ||
390 | { | 386 | { |
391 | if (ep->ops->fifo_flush) | 387 | if (ep->ops->fifo_flush) |
392 | ep->ops->fifo_flush (ep); | 388 | ep->ops->fifo_flush(ep); |
393 | } | 389 | } |
394 | 390 | ||
395 | 391 | ||
@@ -469,10 +465,10 @@ struct usb_gadget { | |||
469 | struct device dev; | 465 | struct device dev; |
470 | }; | 466 | }; |
471 | 467 | ||
472 | static inline void set_gadget_data (struct usb_gadget *gadget, void *data) | 468 | static inline void set_gadget_data(struct usb_gadget *gadget, void *data) |
473 | { dev_set_drvdata (&gadget->dev, data); } | 469 | { dev_set_drvdata(&gadget->dev, data); } |
474 | static inline void *get_gadget_data (struct usb_gadget *gadget) | 470 | static inline void *get_gadget_data(struct usb_gadget *gadget) |
475 | { return dev_get_drvdata (&gadget->dev); } | 471 | { return dev_get_drvdata(&gadget->dev); } |
476 | 472 | ||
477 | /* iterates the non-control endpoints; 'tmp' is a struct usb_ep pointer */ | 473 | /* iterates the non-control endpoints; 'tmp' is a struct usb_ep pointer */ |
478 | #define gadget_for_each_ep(tmp,gadget) \ | 474 | #define gadget_for_each_ep(tmp,gadget) \ |
@@ -511,7 +507,6 @@ static inline int gadget_is_otg(struct usb_gadget *g) | |||
511 | #endif | 507 | #endif |
512 | } | 508 | } |
513 | 509 | ||
514 | |||
515 | /** | 510 | /** |
516 | * usb_gadget_frame_number - returns the current frame number | 511 | * usb_gadget_frame_number - returns the current frame number |
517 | * @gadget: controller that reports the frame number | 512 | * @gadget: controller that reports the frame number |
@@ -519,9 +514,9 @@ static inline int gadget_is_otg(struct usb_gadget *g) | |||
519 | * Returns the usb frame number, normally eleven bits from a SOF packet, | 514 | * Returns the usb frame number, normally eleven bits from a SOF packet, |
520 | * or negative errno if this device doesn't support this capability. | 515 | * or negative errno if this device doesn't support this capability. |
521 | */ | 516 | */ |
522 | static inline int usb_gadget_frame_number (struct usb_gadget *gadget) | 517 | static inline int usb_gadget_frame_number(struct usb_gadget *gadget) |
523 | { | 518 | { |
524 | return gadget->ops->get_frame (gadget); | 519 | return gadget->ops->get_frame(gadget); |
525 | } | 520 | } |
526 | 521 | ||
527 | /** | 522 | /** |
@@ -537,11 +532,11 @@ static inline int usb_gadget_frame_number (struct usb_gadget *gadget) | |||
537 | * even if OTG isn't otherwise in use. OTG devices may also start | 532 | * even if OTG isn't otherwise in use. OTG devices may also start |
538 | * remote wakeup even when hosts don't explicitly enable it. | 533 | * remote wakeup even when hosts don't explicitly enable it. |
539 | */ | 534 | */ |
540 | static inline int usb_gadget_wakeup (struct usb_gadget *gadget) | 535 | static inline int usb_gadget_wakeup(struct usb_gadget *gadget) |
541 | { | 536 | { |
542 | if (!gadget->ops->wakeup) | 537 | if (!gadget->ops->wakeup) |
543 | return -EOPNOTSUPP; | 538 | return -EOPNOTSUPP; |
544 | return gadget->ops->wakeup (gadget); | 539 | return gadget->ops->wakeup(gadget); |
545 | } | 540 | } |
546 | 541 | ||
547 | /** | 542 | /** |
@@ -553,12 +548,11 @@ static inline int usb_gadget_wakeup (struct usb_gadget *gadget) | |||
553 | * | 548 | * |
554 | * returns zero on success, else negative errno. | 549 | * returns zero on success, else negative errno. |
555 | */ | 550 | */ |
556 | static inline int | 551 | static inline int usb_gadget_set_selfpowered(struct usb_gadget *gadget) |
557 | usb_gadget_set_selfpowered (struct usb_gadget *gadget) | ||
558 | { | 552 | { |
559 | if (!gadget->ops->set_selfpowered) | 553 | if (!gadget->ops->set_selfpowered) |
560 | return -EOPNOTSUPP; | 554 | return -EOPNOTSUPP; |
561 | return gadget->ops->set_selfpowered (gadget, 1); | 555 | return gadget->ops->set_selfpowered(gadget, 1); |
562 | } | 556 | } |
563 | 557 | ||
564 | /** | 558 | /** |
@@ -571,12 +565,11 @@ usb_gadget_set_selfpowered (struct usb_gadget *gadget) | |||
571 | * | 565 | * |
572 | * returns zero on success, else negative errno. | 566 | * returns zero on success, else negative errno. |
573 | */ | 567 | */ |
574 | static inline int | 568 | static inline int usb_gadget_clear_selfpowered(struct usb_gadget *gadget) |
575 | usb_gadget_clear_selfpowered (struct usb_gadget *gadget) | ||
576 | { | 569 | { |
577 | if (!gadget->ops->set_selfpowered) | 570 | if (!gadget->ops->set_selfpowered) |
578 | return -EOPNOTSUPP; | 571 | return -EOPNOTSUPP; |
579 | return gadget->ops->set_selfpowered (gadget, 0); | 572 | return gadget->ops->set_selfpowered(gadget, 0); |
580 | } | 573 | } |
581 | 574 | ||
582 | /** | 575 | /** |
@@ -591,12 +584,11 @@ usb_gadget_clear_selfpowered (struct usb_gadget *gadget) | |||
591 | * | 584 | * |
592 | * Returns zero on success, else negative errno. | 585 | * Returns zero on success, else negative errno. |
593 | */ | 586 | */ |
594 | static inline int | 587 | static inline int usb_gadget_vbus_connect(struct usb_gadget *gadget) |
595 | usb_gadget_vbus_connect(struct usb_gadget *gadget) | ||
596 | { | 588 | { |
597 | if (!gadget->ops->vbus_session) | 589 | if (!gadget->ops->vbus_session) |
598 | return -EOPNOTSUPP; | 590 | return -EOPNOTSUPP; |
599 | return gadget->ops->vbus_session (gadget, 1); | 591 | return gadget->ops->vbus_session(gadget, 1); |
600 | } | 592 | } |
601 | 593 | ||
602 | /** | 594 | /** |
@@ -611,12 +603,11 @@ usb_gadget_vbus_connect(struct usb_gadget *gadget) | |||
611 | * | 603 | * |
612 | * Returns zero on success, else negative errno. | 604 | * Returns zero on success, else negative errno. |
613 | */ | 605 | */ |
614 | static inline int | 606 | static inline int usb_gadget_vbus_draw(struct usb_gadget *gadget, unsigned mA) |
615 | usb_gadget_vbus_draw(struct usb_gadget *gadget, unsigned mA) | ||
616 | { | 607 | { |
617 | if (!gadget->ops->vbus_draw) | 608 | if (!gadget->ops->vbus_draw) |
618 | return -EOPNOTSUPP; | 609 | return -EOPNOTSUPP; |
619 | return gadget->ops->vbus_draw (gadget, mA); | 610 | return gadget->ops->vbus_draw(gadget, mA); |
620 | } | 611 | } |
621 | 612 | ||
622 | /** | 613 | /** |
@@ -629,12 +620,11 @@ usb_gadget_vbus_draw(struct usb_gadget *gadget, unsigned mA) | |||
629 | * | 620 | * |
630 | * Returns zero on success, else negative errno. | 621 | * Returns zero on success, else negative errno. |
631 | */ | 622 | */ |
632 | static inline int | 623 | static inline int usb_gadget_vbus_disconnect(struct usb_gadget *gadget) |
633 | usb_gadget_vbus_disconnect(struct usb_gadget *gadget) | ||
634 | { | 624 | { |
635 | if (!gadget->ops->vbus_session) | 625 | if (!gadget->ops->vbus_session) |
636 | return -EOPNOTSUPP; | 626 | return -EOPNOTSUPP; |
637 | return gadget->ops->vbus_session (gadget, 0); | 627 | return gadget->ops->vbus_session(gadget, 0); |
638 | } | 628 | } |
639 | 629 | ||
640 | /** | 630 | /** |
@@ -648,12 +638,11 @@ usb_gadget_vbus_disconnect(struct usb_gadget *gadget) | |||
648 | * | 638 | * |
649 | * Returns zero on success, else negative errno. | 639 | * Returns zero on success, else negative errno. |
650 | */ | 640 | */ |
651 | static inline int | 641 | static inline int usb_gadget_connect(struct usb_gadget *gadget) |
652 | usb_gadget_connect (struct usb_gadget *gadget) | ||
653 | { | 642 | { |
654 | if (!gadget->ops->pullup) | 643 | if (!gadget->ops->pullup) |
655 | return -EOPNOTSUPP; | 644 | return -EOPNOTSUPP; |
656 | return gadget->ops->pullup (gadget, 1); | 645 | return gadget->ops->pullup(gadget, 1); |
657 | } | 646 | } |
658 | 647 | ||
659 | /** | 648 | /** |
@@ -671,16 +660,14 @@ usb_gadget_connect (struct usb_gadget *gadget) | |||
671 | * | 660 | * |
672 | * Returns zero on success, else negative errno. | 661 | * Returns zero on success, else negative errno. |
673 | */ | 662 | */ |
674 | static inline int | 663 | static inline int usb_gadget_disconnect(struct usb_gadget *gadget) |
675 | usb_gadget_disconnect (struct usb_gadget *gadget) | ||
676 | { | 664 | { |
677 | if (!gadget->ops->pullup) | 665 | if (!gadget->ops->pullup) |
678 | return -EOPNOTSUPP; | 666 | return -EOPNOTSUPP; |
679 | return gadget->ops->pullup (gadget, 0); | 667 | return gadget->ops->pullup(gadget, 0); |
680 | } | 668 | } |
681 | 669 | ||
682 | 670 | ||
683 | |||
684 | /*-------------------------------------------------------------------------*/ | 671 | /*-------------------------------------------------------------------------*/ |
685 | 672 | ||
686 | /** | 673 | /** |
@@ -764,7 +751,7 @@ struct usb_gadget_driver { | |||
764 | void (*suspend)(struct usb_gadget *); | 751 | void (*suspend)(struct usb_gadget *); |
765 | void (*resume)(struct usb_gadget *); | 752 | void (*resume)(struct usb_gadget *); |
766 | 753 | ||
767 | // FIXME support safe rmmod | 754 | /* FIXME support safe rmmod */ |
768 | struct device_driver driver; | 755 | struct device_driver driver; |
769 | }; | 756 | }; |
770 | 757 | ||
@@ -790,7 +777,7 @@ struct usb_gadget_driver { | |||
790 | * the bind() functions will be in init sections. | 777 | * the bind() functions will be in init sections. |
791 | * This function must be called in a context that can sleep. | 778 | * This function must be called in a context that can sleep. |
792 | */ | 779 | */ |
793 | int usb_gadget_register_driver (struct usb_gadget_driver *driver); | 780 | int usb_gadget_register_driver(struct usb_gadget_driver *driver); |
794 | 781 | ||
795 | /** | 782 | /** |
796 | * usb_gadget_unregister_driver - unregister a gadget driver | 783 | * usb_gadget_unregister_driver - unregister a gadget driver |
@@ -805,7 +792,7 @@ int usb_gadget_register_driver (struct usb_gadget_driver *driver); | |||
805 | * will in in exit sections, so may not be linked in some kernels. | 792 | * will in in exit sections, so may not be linked in some kernels. |
806 | * This function must be called in a context that can sleep. | 793 | * This function must be called in a context that can sleep. |
807 | */ | 794 | */ |
808 | int usb_gadget_unregister_driver (struct usb_gadget_driver *driver); | 795 | int usb_gadget_unregister_driver(struct usb_gadget_driver *driver); |
809 | 796 | ||
810 | /*-------------------------------------------------------------------------*/ | 797 | /*-------------------------------------------------------------------------*/ |
811 | 798 | ||
@@ -838,7 +825,7 @@ struct usb_gadget_strings { | |||
838 | }; | 825 | }; |
839 | 826 | ||
840 | /* put descriptor for string with that id into buf (buflen >= 256) */ | 827 | /* put descriptor for string with that id into buf (buflen >= 256) */ |
841 | int usb_gadget_get_string (struct usb_gadget_strings *table, int id, u8 *buf); | 828 | int usb_gadget_get_string(struct usb_gadget_strings *table, int id, u8 *buf); |
842 | 829 | ||
843 | /*-------------------------------------------------------------------------*/ | 830 | /*-------------------------------------------------------------------------*/ |
844 | 831 | ||
@@ -856,10 +843,10 @@ int usb_gadget_config_buf(const struct usb_config_descriptor *config, | |||
856 | 843 | ||
857 | /* utility wrapping a simple endpoint selection policy */ | 844 | /* utility wrapping a simple endpoint selection policy */ |
858 | 845 | ||
859 | extern struct usb_ep *usb_ep_autoconfig (struct usb_gadget *, | 846 | extern struct usb_ep *usb_ep_autoconfig(struct usb_gadget *, |
860 | struct usb_endpoint_descriptor *) __devinit; | 847 | struct usb_endpoint_descriptor *) __devinit; |
861 | 848 | ||
862 | extern void usb_ep_autoconfig_reset (struct usb_gadget *) __devinit; | 849 | extern void usb_ep_autoconfig_reset(struct usb_gadget *) __devinit; |
863 | 850 | ||
864 | #endif /* __KERNEL__ */ | 851 | #endif /* __KERNEL__ */ |
865 | 852 | ||