aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/gadget/ci13xxx_udc.c
diff options
context:
space:
mode:
authorSebastian Andrzej Siewior <bigeasy@linutronix.de>2011-06-28 09:33:47 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2011-06-28 14:13:35 -0400
commit0f91349b89f37dfad7b77f7829a105b6a0f526ec (patch)
tree4a2b109d3d736318913d0209a5f4ce89aaad1d24 /drivers/usb/gadget/ci13xxx_udc.c
parent2ccea03a8f7ec93641791f2760d7cdc6cab6205f (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/ci13xxx_udc.c')
-rw-r--r--drivers/usb/gadget/ci13xxx_udc.c43
1 files changed, 29 insertions, 14 deletions
diff --git a/drivers/usb/gadget/ci13xxx_udc.c b/drivers/usb/gadget/ci13xxx_udc.c
index baaf87ed7685..909bc45c0be0 100644
--- a/drivers/usb/gadget/ci13xxx_udc.c
+++ b/drivers/usb/gadget/ci13xxx_udc.c
@@ -857,7 +857,7 @@ static void dbg_print(u8 addr, const char *name, int status, const char *extra)
857 stamp = stamp * 1000000 + tval.tv_usec; 857 stamp = stamp * 1000000 + tval.tv_usec;
858 858
859 scnprintf(dbg_data.buf[dbg_data.idx], DBG_DATA_MSG, 859 scnprintf(dbg_data.buf[dbg_data.idx], DBG_DATA_MSG,
860 "%04X\t» %02X %-7.7s %4i «\t%s\n", 860 "%04X\t? %02X %-7.7s %4i ?\t%s\n",
861 stamp, addr, name, status, extra); 861 stamp, addr, name, status, extra);
862 862
863 dbg_inc(&dbg_data.idx); 863 dbg_inc(&dbg_data.idx);
@@ -865,7 +865,7 @@ static void dbg_print(u8 addr, const char *name, int status, const char *extra)
865 write_unlock_irqrestore(&dbg_data.lck, flags); 865 write_unlock_irqrestore(&dbg_data.lck, flags);
866 866
867 if (dbg_data.tty != 0) 867 if (dbg_data.tty != 0)
868 pr_notice("%04X\t» %02X %-7.7s %4i «\t%s\n", 868 pr_notice("%04X\t? %02X %-7.7s %4i ?\t%s\n",
869 stamp, addr, name, status, extra); 869 stamp, addr, name, status, extra);
870} 870}
871 871
@@ -1025,15 +1025,15 @@ static ssize_t show_inters(struct device *dev, struct device_attribute *attr,
1025 1025
1026 n += scnprintf(buf + n, PAGE_SIZE - n, "*test = %d\n", 1026 n += scnprintf(buf + n, PAGE_SIZE - n, "*test = %d\n",
1027 isr_statistics.test); 1027 isr_statistics.test);
1028 n += scnprintf(buf + n, PAGE_SIZE - n, "» ui = %d\n", 1028 n += scnprintf(buf + n, PAGE_SIZE - n, "? ui = %d\n",
1029 isr_statistics.ui); 1029 isr_statistics.ui);
1030 n += scnprintf(buf + n, PAGE_SIZE - n, "» uei = %d\n", 1030 n += scnprintf(buf + n, PAGE_SIZE - n, "? uei = %d\n",
1031 isr_statistics.uei); 1031 isr_statistics.uei);
1032 n += scnprintf(buf + n, PAGE_SIZE - n, "» pci = %d\n", 1032 n += scnprintf(buf + n, PAGE_SIZE - n, "? pci = %d\n",
1033 isr_statistics.pci); 1033 isr_statistics.pci);
1034 n += scnprintf(buf + n, PAGE_SIZE - n, "» uri = %d\n", 1034 n += scnprintf(buf + n, PAGE_SIZE - n, "? uri = %d\n",
1035 isr_statistics.uri); 1035 isr_statistics.uri);
1036 n += scnprintf(buf + n, PAGE_SIZE - n, "» sli = %d\n", 1036 n += scnprintf(buf + n, PAGE_SIZE - n, "? sli = %d\n",
1037 isr_statistics.sli); 1037 isr_statistics.sli);
1038 n += scnprintf(buf + n, PAGE_SIZE - n, "*none = %d\n", 1038 n += scnprintf(buf + n, PAGE_SIZE - n, "*none = %d\n",
1039 isr_statistics.none); 1039 isr_statistics.none);
@@ -2515,6 +2515,9 @@ static int ci13xxx_vbus_draw(struct usb_gadget *_gadget, unsigned mA)
2515 return -ENOTSUPP; 2515 return -ENOTSUPP;
2516} 2516}
2517 2517
2518static int ci13xxx_start(struct usb_gadget_driver *driver,
2519 int (*bind)(struct usb_gadget *));
2520static int ci13xxx_stop(struct usb_gadget_driver *driver);
2518/** 2521/**
2519 * Device operations part of the API to the USB controller hardware, 2522 * Device operations part of the API to the USB controller hardware,
2520 * which don't involve endpoints (or i/o) 2523 * which don't involve endpoints (or i/o)
@@ -2524,17 +2527,19 @@ static const struct usb_gadget_ops usb_gadget_ops = {
2524 .vbus_session = ci13xxx_vbus_session, 2527 .vbus_session = ci13xxx_vbus_session,
2525 .wakeup = ci13xxx_wakeup, 2528 .wakeup = ci13xxx_wakeup,
2526 .vbus_draw = ci13xxx_vbus_draw, 2529 .vbus_draw = ci13xxx_vbus_draw,
2530 .start = ci13xxx_start,
2531 .stop = ci13xxx_stop,
2527}; 2532};
2528 2533
2529/** 2534/**
2530 * usb_gadget_probe_driver: register a gadget driver 2535 * ci13xxx_start: register a gadget driver
2531 * @driver: the driver being registered 2536 * @driver: the driver being registered
2532 * @bind: the driver's bind callback 2537 * @bind: the driver's bind callback
2533 * 2538 *
2534 * Check usb_gadget_probe_driver() at <linux/usb/gadget.h> for details. 2539 * Check ci13xxx_start() at <linux/usb/gadget.h> for details.
2535 * Interrupts are enabled here. 2540 * Interrupts are enabled here.
2536 */ 2541 */
2537int usb_gadget_probe_driver(struct usb_gadget_driver *driver, 2542static int ci13xxx_start(struct usb_gadget_driver *driver,
2538 int (*bind)(struct usb_gadget *)) 2543 int (*bind)(struct usb_gadget *))
2539{ 2544{
2540 struct ci13xxx *udc = _udc; 2545 struct ci13xxx *udc = _udc;
@@ -2657,14 +2662,13 @@ int usb_gadget_probe_driver(struct usb_gadget_driver *driver,
2657 spin_unlock_irqrestore(udc->lock, flags); 2662 spin_unlock_irqrestore(udc->lock, flags);
2658 return retval; 2663 return retval;
2659} 2664}
2660EXPORT_SYMBOL(usb_gadget_probe_driver);
2661 2665
2662/** 2666/**
2663 * usb_gadget_unregister_driver: unregister a gadget driver 2667 * ci13xxx_stop: unregister a gadget driver
2664 * 2668 *
2665 * Check usb_gadget_unregister_driver() at "usb_gadget.h" for details 2669 * Check usb_gadget_unregister_driver() at "usb_gadget.h" for details
2666 */ 2670 */
2667int usb_gadget_unregister_driver(struct usb_gadget_driver *driver) 2671static int ci13xxx_stop(struct usb_gadget_driver *driver)
2668{ 2672{
2669 struct ci13xxx *udc = _udc; 2673 struct ci13xxx *udc = _udc;
2670 unsigned long i, flags; 2674 unsigned long i, flags;
@@ -2726,7 +2730,6 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
2726 2730
2727 return 0; 2731 return 0;
2728} 2732}
2729EXPORT_SYMBOL(usb_gadget_unregister_driver);
2730 2733
2731/****************************************************************************** 2734/******************************************************************************
2732 * BUS block 2735 * BUS block
@@ -2901,12 +2904,23 @@ static int udc_probe(struct ci13xxx_udc_driver *driver, struct device *dev,
2901 if (retval) 2904 if (retval)
2902 goto remove_dbg; 2905 goto remove_dbg;
2903 } 2906 }
2907
2908 retval = usb_add_gadget_udc(dev, &udc->gadget);
2909 if (retval)
2910 goto remove_trans;
2911
2904 pm_runtime_no_callbacks(&udc->gadget.dev); 2912 pm_runtime_no_callbacks(&udc->gadget.dev);
2905 pm_runtime_enable(&udc->gadget.dev); 2913 pm_runtime_enable(&udc->gadget.dev);
2906 2914
2907 _udc = udc; 2915 _udc = udc;
2908 return retval; 2916 return retval;
2909 2917
2918remove_trans:
2919 if (udc->transceiver) {
2920 otg_set_peripheral(udc->transceiver, &udc->gadget);
2921 otg_put_transceiver(udc->transceiver);
2922 }
2923
2910 err("error = %i", retval); 2924 err("error = %i", retval);
2911remove_dbg: 2925remove_dbg:
2912#ifdef CONFIG_USB_GADGET_DEBUG_FILES 2926#ifdef CONFIG_USB_GADGET_DEBUG_FILES
@@ -2936,6 +2950,7 @@ static void udc_remove(void)
2936 err("EINVAL"); 2950 err("EINVAL");
2937 return; 2951 return;
2938 } 2952 }
2953 usb_del_gadget_udc(&udc->gadget);
2939 2954
2940 if (udc->transceiver) { 2955 if (udc->transceiver) {
2941 otg_set_peripheral(udc->transceiver, &udc->gadget); 2956 otg_set_peripheral(udc->transceiver, &udc->gadget);