diff options
author | Sebastian Andrzej Siewior <bigeasy@linutronix.de> | 2011-06-28 09:33:47 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2011-06-28 14:13:35 -0400 |
commit | 0f91349b89f37dfad7b77f7829a105b6a0f526ec (patch) | |
tree | 4a2b109d3d736318913d0209a5f4ce89aaad1d24 /drivers/usb/gadget/dummy_hcd.c | |
parent | 2ccea03a8f7ec93641791f2760d7cdc6cab6205f (diff) |
usb: gadget: convert all users to the new udc infrastructure
peripheral drivers are using usb_add_gadget()/usb_del_gadget() to
register/unregister to the udc-core.
The udc-core will take the first available gadget driver and attach
function driver which is calling usb_gadget_register_driver(). This is
the same behaviour we have right now.
Only dummy_hcd was tested, the others were compiled tested.
Cc: Alan Stern <stern@rowland.harvard.edu>
Cc: Anton Tikhomirov <av.tikhomirov@samsung.com>
Cc: Ben Dooks <ben-linux@fluff.org>
Cc: Dan Carpenter <error27@gmail.com>
Cc: Darius Augulis <augulis.darius@gmail.com>
Cc: Eric Miao <eric.y.miao@gmail.com>
Cc: Jingoo Han <jg1.han@samsung.com>
Cc: Kukjin Kim <kgene.kim@samsung.com>
Cc: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Cc: Li Yang <leoli@freescale.com>
Cc: Michael Hennerich <michael.hennerich@analog.com>
Acked-by: Mike Frysinger <vapier@gentoo.org>
Cc: Nicolas Ferre <nicolas.ferre@atmel.com>
Cc: Pavankumar Kondeti <pkondeti@codeaurora.org>
Cc: Roy Huang <roy.huang@analog.com>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: Toshiharu Okada <toshiharu-linux@dsn.okisemi.com>
Cc: Xiaochen Shen <xiaochen.shen@intel.com>
Cc: Yoshihiro Shimoda <shimoda.yoshihiro@renesas.com>
Cc: Yuan-Hsin Chen <yhchen@faraday-tech.com>
Cc: cxie4 <cxie4@marvell.com>
Cc: linux-geode@lists.infradead.org
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/gadget/dummy_hcd.c')
-rw-r--r-- | drivers/usb/gadget/dummy_hcd.c | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/drivers/usb/gadget/dummy_hcd.c b/drivers/usb/gadget/dummy_hcd.c index d3dcabc1a5fc..d47a565d085c 100644 --- a/drivers/usb/gadget/dummy_hcd.c +++ b/drivers/usb/gadget/dummy_hcd.c | |||
@@ -710,11 +710,17 @@ static int dummy_pullup (struct usb_gadget *_gadget, int value) | |||
710 | return 0; | 710 | return 0; |
711 | } | 711 | } |
712 | 712 | ||
713 | static int dummy_udc_start(struct usb_gadget_driver *driver, | ||
714 | int (*bind)(struct usb_gadget *)); | ||
715 | static int dummy_udc_stop(struct usb_gadget_driver *driver); | ||
716 | |||
713 | static const struct usb_gadget_ops dummy_ops = { | 717 | static const struct usb_gadget_ops dummy_ops = { |
714 | .get_frame = dummy_g_get_frame, | 718 | .get_frame = dummy_g_get_frame, |
715 | .wakeup = dummy_wakeup, | 719 | .wakeup = dummy_wakeup, |
716 | .set_selfpowered = dummy_set_selfpowered, | 720 | .set_selfpowered = dummy_set_selfpowered, |
717 | .pullup = dummy_pullup, | 721 | .pullup = dummy_pullup, |
722 | .start = dummy_udc_start, | ||
723 | .stop = dummy_udc_stop, | ||
718 | }; | 724 | }; |
719 | 725 | ||
720 | /*-------------------------------------------------------------------------*/ | 726 | /*-------------------------------------------------------------------------*/ |
@@ -747,8 +753,7 @@ static DEVICE_ATTR (function, S_IRUGO, show_function, NULL); | |||
747 | * for each driver that registers: just add to a big root hub. | 753 | * for each driver that registers: just add to a big root hub. |
748 | */ | 754 | */ |
749 | 755 | ||
750 | int | 756 | static int dummy_udc_start(struct usb_gadget_driver *driver, |
751 | usb_gadget_probe_driver(struct usb_gadget_driver *driver, | ||
752 | int (*bind)(struct usb_gadget *)) | 757 | int (*bind)(struct usb_gadget *)) |
753 | { | 758 | { |
754 | struct dummy *dum = the_controller; | 759 | struct dummy *dum = the_controller; |
@@ -812,10 +817,8 @@ usb_gadget_probe_driver(struct usb_gadget_driver *driver, | |||
812 | usb_hcd_poll_rh_status (dummy_to_hcd (dum)); | 817 | usb_hcd_poll_rh_status (dummy_to_hcd (dum)); |
813 | return 0; | 818 | return 0; |
814 | } | 819 | } |
815 | EXPORT_SYMBOL(usb_gadget_probe_driver); | ||
816 | 820 | ||
817 | int | 821 | static int dummy_udc_stop(struct usb_gadget_driver *driver) |
818 | usb_gadget_unregister_driver (struct usb_gadget_driver *driver) | ||
819 | { | 822 | { |
820 | struct dummy *dum = the_controller; | 823 | struct dummy *dum = the_controller; |
821 | unsigned long flags; | 824 | unsigned long flags; |
@@ -845,7 +848,6 @@ usb_gadget_unregister_driver (struct usb_gadget_driver *driver) | |||
845 | usb_hcd_poll_rh_status (dummy_to_hcd (dum)); | 848 | usb_hcd_poll_rh_status (dummy_to_hcd (dum)); |
846 | return 0; | 849 | return 0; |
847 | } | 850 | } |
848 | EXPORT_SYMBOL (usb_gadget_unregister_driver); | ||
849 | 851 | ||
850 | #undef is_enabled | 852 | #undef is_enabled |
851 | 853 | ||
@@ -892,11 +894,20 @@ static int dummy_udc_probe (struct platform_device *pdev) | |||
892 | return rc; | 894 | return rc; |
893 | } | 895 | } |
894 | 896 | ||
897 | rc = usb_add_gadget_udc(&pdev->dev, &dum->gadget); | ||
898 | if (rc < 0) | ||
899 | goto err_udc; | ||
900 | |||
895 | rc = device_create_file (&dum->gadget.dev, &dev_attr_function); | 901 | rc = device_create_file (&dum->gadget.dev, &dev_attr_function); |
896 | if (rc < 0) | 902 | if (rc < 0) |
897 | device_unregister (&dum->gadget.dev); | 903 | goto err_dev; |
898 | else | 904 | platform_set_drvdata(pdev, dum); |
899 | platform_set_drvdata(pdev, dum); | 905 | return rc; |
906 | |||
907 | err_dev: | ||
908 | usb_del_gadget_udc(&dum->gadget); | ||
909 | err_udc: | ||
910 | device_unregister(&dum->gadget.dev); | ||
900 | return rc; | 911 | return rc; |
901 | } | 912 | } |
902 | 913 | ||
@@ -904,6 +915,7 @@ static int dummy_udc_remove (struct platform_device *pdev) | |||
904 | { | 915 | { |
905 | struct dummy *dum = platform_get_drvdata (pdev); | 916 | struct dummy *dum = platform_get_drvdata (pdev); |
906 | 917 | ||
918 | usb_del_gadget_udc(&dum->gadget); | ||
907 | platform_set_drvdata (pdev, NULL); | 919 | platform_set_drvdata (pdev, NULL); |
908 | device_remove_file (&dum->gadget.dev, &dev_attr_function); | 920 | device_remove_file (&dum->gadget.dev, &dev_attr_function); |
909 | device_unregister (&dum->gadget.dev); | 921 | device_unregister (&dum->gadget.dev); |
@@ -1863,7 +1875,6 @@ static void dummy_stop (struct usb_hcd *hcd) | |||
1863 | dum = hcd_to_dummy (hcd); | 1875 | dum = hcd_to_dummy (hcd); |
1864 | 1876 | ||
1865 | device_remove_file (dummy_dev(dum), &dev_attr_urbs); | 1877 | device_remove_file (dummy_dev(dum), &dev_attr_urbs); |
1866 | usb_gadget_unregister_driver (dum->driver); | ||
1867 | dev_info (dummy_dev(dum), "stopped\n"); | 1878 | dev_info (dummy_dev(dum), "stopped\n"); |
1868 | } | 1879 | } |
1869 | 1880 | ||