diff options
Diffstat (limited to 'drivers/usb/gadget/udc')
28 files changed, 162 insertions, 141 deletions
diff --git a/drivers/usb/gadget/udc/Kconfig b/drivers/usb/gadget/udc/Kconfig index 3a7179e90f4e..1a12aab208b4 100644 --- a/drivers/usb/gadget/udc/Kconfig +++ b/drivers/usb/gadget/udc/Kconfig @@ -474,7 +474,7 @@ config USB_DUMMY_HCD help This host controller driver emulates USB, looping all data transfer requests back to a USB "gadget driver" in the same host. The host - side is the master; the gadget side is the slave. Gadget drivers + side is the controller; the gadget side is the device. Gadget drivers can be high, full, or low speed; and they have access to endpoints like those from NET2280, PXA2xx, or SA1100 hardware. diff --git a/drivers/usb/gadget/udc/amd5536udc.h b/drivers/usb/gadget/udc/amd5536udc.h index 0262383f8c79..3296f3fcee48 100644 --- a/drivers/usb/gadget/udc/amd5536udc.h +++ b/drivers/usb/gadget/udc/amd5536udc.h @@ -2,7 +2,7 @@ /* * amd5536.h -- header for AMD 5536 UDC high/full speed USB device controller * - * Copyright (C) 2007 AMD (http://www.amd.com) + * Copyright (C) 2007 AMD (https://www.amd.com) * Author: Thomas Dahlmann */ diff --git a/drivers/usb/gadget/udc/amd5536udc_pci.c b/drivers/usb/gadget/udc/amd5536udc_pci.c index 80685e4306f3..8d387e0e4d91 100644 --- a/drivers/usb/gadget/udc/amd5536udc_pci.c +++ b/drivers/usb/gadget/udc/amd5536udc_pci.c @@ -2,7 +2,7 @@ /* * amd5536udc_pci.c -- AMD 5536 UDC high/full speed USB device controller * - * Copyright (C) 2005-2007 AMD (http://www.amd.com) + * Copyright (C) 2005-2007 AMD (https://www.amd.com) * Author: Thomas Dahlmann */ @@ -49,7 +49,6 @@ static struct udc *udc; /* description */ -static const char mod_desc[] = UDC_MOD_DESCRIPTION; static const char name[] = "amd5536udc-pci"; /* Reset all pci context */ diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c b/drivers/usb/gadget/udc/atmel_usba_udc.c index 9342a3d24963..fa6793065c7c 100644 --- a/drivers/usb/gadget/udc/atmel_usba_udc.c +++ b/drivers/usb/gadget/udc/atmel_usba_udc.c @@ -1028,6 +1028,7 @@ usba_udc_set_selfpowered(struct usb_gadget *gadget, int is_selfpowered) return 0; } +static int atmel_usba_pullup(struct usb_gadget *gadget, int is_on); static int atmel_usba_start(struct usb_gadget *gadget, struct usb_gadget_driver *driver); static int atmel_usba_stop(struct usb_gadget *gadget); @@ -1101,6 +1102,7 @@ static const struct usb_gadget_ops usba_udc_ops = { .get_frame = usba_udc_get_frame, .wakeup = usba_udc_wakeup, .set_selfpowered = usba_udc_set_selfpowered, + .pullup = atmel_usba_pullup, .udc_start = atmel_usba_start, .udc_stop = atmel_usba_stop, .match_ep = atmel_usba_match_ep, @@ -1957,6 +1959,24 @@ static irqreturn_t usba_vbus_irq_thread(int irq, void *devid) return IRQ_HANDLED; } +static int atmel_usba_pullup(struct usb_gadget *gadget, int is_on) +{ + struct usba_udc *udc = container_of(gadget, struct usba_udc, gadget); + unsigned long flags; + u32 ctrl; + + spin_lock_irqsave(&udc->lock, flags); + ctrl = usba_readl(udc, CTRL); + if (is_on) + ctrl &= ~USBA_DETACH; + else + ctrl |= USBA_DETACH; + usba_writel(udc, CTRL, ctrl); + spin_unlock_irqrestore(&udc->lock, flags); + + return 0; +} + static int atmel_usba_start(struct usb_gadget *gadget, struct usb_gadget_driver *driver) { @@ -2097,7 +2117,6 @@ static struct usba_ep * atmel_udc_of_init(struct platform_device *pdev, { struct device_node *np = pdev->dev.of_node; const struct of_device_id *match; - struct device_node *pp; int i, ret; struct usba_ep *eps, *ep; const struct usba_udc_config *udc_config; @@ -2122,7 +2141,6 @@ static struct usba_ep * atmel_udc_of_init(struct platform_device *pdev, GPIOD_IN); if (fifo_mode == 0) { - pp = NULL; udc->num_ep = udc_config->num_ep; udc->configured_ep = 1; } else { @@ -2138,7 +2156,6 @@ static struct usba_ep * atmel_udc_of_init(struct platform_device *pdev, INIT_LIST_HEAD(&eps[0].ep.ep_list); - pp = NULL; i = 0; while (i < udc->num_ep) { const struct usba_ep_config *ep_cfg = &udc_config->config[i]; diff --git a/drivers/usb/gadget/udc/bcm63xx_udc.c b/drivers/usb/gadget/udc/bcm63xx_udc.c index 54501814dc3f..feaec00a3c16 100644 --- a/drivers/usb/gadget/udc/bcm63xx_udc.c +++ b/drivers/usb/gadget/udc/bcm63xx_udc.c @@ -266,8 +266,8 @@ struct bcm63xx_req { * @pd: Platform data (board/port info). * @usbd_clk: Clock descriptor for the USB device block. * @usbh_clk: Clock descriptor for the USB host block. - * @gadget: USB slave device. - * @driver: Driver for USB slave devices. + * @gadget: USB device. + * @driver: Driver for USB device. * @usbd_regs: Base address of the USBD/USB20D block. * @iudma_regs: Base address of the USBD's associated IUDMA block. * @bep: Array of endpoints, including ep0. @@ -1744,7 +1744,7 @@ static void bcm63xx_ep0_process(struct work_struct *w) /** * bcm63xx_udc_get_frame - Read current SOF frame number from the HW. - * @gadget: USB slave device. + * @gadget: USB device. */ static int bcm63xx_udc_get_frame(struct usb_gadget *gadget) { @@ -1756,7 +1756,7 @@ static int bcm63xx_udc_get_frame(struct usb_gadget *gadget) /** * bcm63xx_udc_pullup - Enable/disable pullup on D+ line. - * @gadget: USB slave device. + * @gadget: USB device. * @is_on: 0 to disable pullup, 1 to enable. * * See notes in bcm63xx_select_pullup(). @@ -1805,8 +1805,8 @@ static int bcm63xx_udc_pullup(struct usb_gadget *gadget, int is_on) /** * bcm63xx_udc_start - Start the controller. - * @gadget: USB slave device. - * @driver: Driver for USB slave devices. + * @gadget: USB device. + * @driver: Driver for USB device. */ static int bcm63xx_udc_start(struct usb_gadget *gadget, struct usb_gadget_driver *driver) @@ -1842,8 +1842,8 @@ static int bcm63xx_udc_start(struct usb_gadget *gadget, /** * bcm63xx_udc_stop - Shut down the controller. - * @gadget: USB slave device. - * @driver: Driver for USB slave devices. + * @gadget: USB device. + * @driver: Driver for USB device. */ static int bcm63xx_udc_stop(struct usb_gadget *gadget) { diff --git a/drivers/usb/gadget/udc/bdc/bdc.h b/drivers/usb/gadget/udc/bdc/bdc.h index 6e1e881dc51e..ac75e25c3b6a 100644 --- a/drivers/usb/gadget/udc/bdc/bdc.h +++ b/drivers/usb/gadget/udc/bdc/bdc.h @@ -44,7 +44,7 @@ #define NUM_SR_ENTRIES 64 /* Num of bds per table */ -#define NUM_BDS_PER_TABLE 32 +#define NUM_BDS_PER_TABLE 64 /* Num of tables in bd list for control,bulk and Int ep */ #define NUM_TABLES 2 diff --git a/drivers/usb/gadget/udc/bdc/bdc_core.c b/drivers/usb/gadget/udc/bdc/bdc_core.c index 02a3a774670b..5ff36525044e 100644 --- a/drivers/usb/gadget/udc/bdc/bdc_core.c +++ b/drivers/usb/gadget/udc/bdc/bdc_core.c @@ -12,6 +12,7 @@ #include <linux/spinlock.h> #include <linux/platform_device.h> #include <linux/interrupt.h> +#include <linux/iopoll.h> #include <linux/ioport.h> #include <linux/io.h> #include <linux/list.h> @@ -29,24 +30,19 @@ #include "bdc_dbg.h" /* Poll till controller status is not OIP */ -static int poll_oip(struct bdc *bdc, int usec) +static int poll_oip(struct bdc *bdc, u32 usec) { u32 status; - /* Poll till STS!= OIP */ - while (usec) { - status = bdc_readl(bdc->regs, BDC_BDCSC); - if (BDC_CSTS(status) != BDC_OIP) { - dev_dbg(bdc->dev, - "poll_oip complete status=%d", - BDC_CSTS(status)); - return 0; - } - udelay(10); - usec -= 10; - } - dev_err(bdc->dev, "Err: operation timedout BDCSC: 0x%08x\n", status); + int ret; - return -ETIMEDOUT; + ret = readl_poll_timeout(bdc->regs + BDC_BDCSC, status, + (BDC_CSTS(status) != BDC_OIP), 10, usec); + if (ret) + dev_err(bdc->dev, "operation timedout BDCSC: 0x%08x\n", status); + else + dev_dbg(bdc->dev, "%s complete status=%d", __func__, BDC_CSTS(status)); + + return ret; } /* Stop the BDC controller */ @@ -282,6 +278,7 @@ static void bdc_mem_init(struct bdc *bdc, bool reinit) * in that case reinit is passed as 1 */ if (reinit) { + int i; /* Enable interrupts */ temp = bdc_readl(bdc->regs, BDC_BDCSC); temp |= BDC_GIE; @@ -291,6 +288,13 @@ static void bdc_mem_init(struct bdc *bdc, bool reinit) /* Initialize SRR to 0 */ memset(bdc->srr.sr_bds, 0, NUM_SR_ENTRIES * sizeof(struct bdc_bd)); + /* + * clear ep flags to avoid post disconnect stops/deconfigs but + * not during S2 exit + */ + if (!bdc->gadget.speed) + for (i = 1; i < bdc->num_eps; ++i) + bdc->bdc_ep_array[i]->flags = 0; } else { /* One time initiaization only */ /* Enable status report function pointers */ @@ -489,11 +493,9 @@ static int bdc_probe(struct platform_device *pdev) dev_dbg(dev, "%s()\n", __func__); - clk = devm_clk_get(dev, "sw_usbd"); - if (IS_ERR(clk)) { - dev_info(dev, "Clock not found in Device Tree\n"); - clk = NULL; - } + clk = devm_clk_get_optional(dev, "sw_usbd"); + if (IS_ERR(clk)) + return PTR_ERR(clk); ret = clk_prepare_enable(clk); if (ret) { @@ -599,9 +601,14 @@ static int bdc_remove(struct platform_device *pdev) static int bdc_suspend(struct device *dev) { struct bdc *bdc = dev_get_drvdata(dev); + int ret; - clk_disable_unprepare(bdc->clk); - return 0; + /* Halt the controller */ + ret = bdc_stop(bdc); + if (!ret) + clk_disable_unprepare(bdc->clk); + + return ret; } static int bdc_resume(struct device *dev) @@ -629,7 +636,7 @@ static SIMPLE_DEV_PM_OPS(bdc_pm_ops, bdc_suspend, bdc_resume); static const struct of_device_id bdc_of_match[] = { - { .compatible = "brcm,bdc-v0.16" }, + { .compatible = "brcm,bdc-udc-v2" }, { .compatible = "brcm,bdc" }, { /* sentinel */ } }; diff --git a/drivers/usb/gadget/udc/bdc/bdc_ep.c b/drivers/usb/gadget/udc/bdc/bdc_ep.c index d49c6dc1082d..fafdc9fdb4a5 100644 --- a/drivers/usb/gadget/udc/bdc/bdc_ep.c +++ b/drivers/usb/gadget/udc/bdc/bdc_ep.c @@ -615,7 +615,6 @@ int bdc_ep_enable(struct bdc_ep *ep) } bdc_dbg_bd_list(bdc, ep); /* only for ep0: config ep is called for ep0 from connect event */ - ep->flags |= BDC_EP_ENABLED; if (ep->ep_num == 1) return ret; @@ -759,10 +758,13 @@ static int ep_dequeue(struct bdc_ep *ep, struct bdc_req *req) __func__, ep->name, start_bdi, end_bdi); dev_dbg(bdc->dev, "ep_dequeue ep=%p ep->desc=%p\n", ep, (void *)ep->usb_ep.desc); - /* Stop the ep to see where the HW is ? */ - ret = bdc_stop_ep(bdc, ep->ep_num); - /* if there is an issue with stopping ep, then no need to go further */ - if (ret) + /* if still connected, stop the ep to see where the HW is ? */ + if (!(bdc_readl(bdc->regs, BDC_USPC) & BDC_PST_MASK)) { + ret = bdc_stop_ep(bdc, ep->ep_num); + /* if there is an issue, then no need to go further */ + if (ret) + return 0; + } else return 0; /* @@ -927,11 +929,11 @@ static int bdc_set_test_mode(struct bdc *bdc) usb2_pm &= ~BDC_PTC_MASK; dev_dbg(bdc->dev, "%s\n", __func__); switch (bdc->test_mode) { - case TEST_J: - case TEST_K: - case TEST_SE0_NAK: - case TEST_PACKET: - case TEST_FORCE_EN: + case USB_TEST_J: + case USB_TEST_K: + case USB_TEST_SE0_NAK: + case USB_TEST_PACKET: + case USB_TEST_FORCE_ENABLE: usb2_pm |= bdc->test_mode << 28; break; default: @@ -1911,7 +1913,9 @@ static int bdc_gadget_ep_disable(struct usb_ep *_ep) __func__, ep->name, ep->flags); if (!(ep->flags & BDC_EP_ENABLED)) { - dev_warn(bdc->dev, "%s is already disabled\n", ep->name); + if (bdc->gadget.speed != USB_SPEED_UNKNOWN) + dev_warn(bdc->dev, "%s is already disabled\n", + ep->name); return 0; } spin_lock_irqsave(&bdc->lock, flags); diff --git a/drivers/usb/gadget/udc/core.c b/drivers/usb/gadget/udc/core.c index 2e28dde8376f..4f82bcd31fd3 100644 --- a/drivers/usb/gadget/udc/core.c +++ b/drivers/usb/gadget/udc/core.c @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 -/** +/* * udc.c - Core UDC Framework * * Copyright (C) 2010 Texas Instruments @@ -23,11 +23,11 @@ /** * struct usb_udc - describes one usb device controller - * @driver - the gadget driver pointer. For use by the class code - * @dev - the child device to the actual controller - * @gadget - the gadget. For use by the class code - * @list - for use by the udc class driver - * @vbus - for udcs who care about vbus status, this value is real vbus status; + * @driver: the gadget driver pointer. For use by the class code + * @dev: the child device to the actual controller + * @gadget: the gadget. For use by the class code + * @list: for use by the udc class driver + * @vbus: for udcs who care about vbus status, this value is real vbus status; * for udcs who do not care about vbus status, this value is always true * * This represents the internal data structure which is used by the UDC-class @@ -85,7 +85,7 @@ EXPORT_SYMBOL_GPL(usb_ep_set_maxpacket_limit); * for interrupt transfers as well as bulk, but it likely couldn't be used * for iso transfers or for endpoint 14. some endpoints are fully * configurable, with more generic names like "ep-a". (remember that for - * USB, "in" means "towards the USB master".) + * USB, "in" means "towards the USB host".) * * This routine must be called in process context. * @@ -891,6 +891,9 @@ EXPORT_SYMBOL_GPL(usb_gadget_unmap_request); /** * usb_gadget_giveback_request - give the request back to the gadget layer + * @ep: the endpoint to be used with with the request + * @req: the request being given back + * * Context: in_interrupt() * * This is called by device controller drivers in order to return the @@ -1084,8 +1087,7 @@ static inline int usb_gadget_udc_start(struct usb_udc *udc) /** * usb_gadget_udc_stop - tells usb device controller we don't need it anymore - * @gadget: The device we want to stop activity - * @driver: The driver to unbind from @gadget + * @udc: The UDC to be stopped * * This call is issued by the UDC Class driver after calling * gadget driver's unbind() method. @@ -1228,6 +1230,7 @@ int usb_add_gadget_udc_release(struct device *parent, struct usb_gadget *gadget, return 0; err_del_udc: + flush_work(&gadget->work); device_del(&udc->dev); err_unlist_udc: diff --git a/drivers/usb/gadget/udc/dummy_hcd.c b/drivers/usb/gadget/udc/dummy_hcd.c index 0eeaead5acea..53a227217f1c 100644 --- a/drivers/usb/gadget/udc/dummy_hcd.c +++ b/drivers/usb/gadget/udc/dummy_hcd.c @@ -14,7 +14,7 @@ * Linux-USB host controller driver. USB traffic is simulated; there's * no need for USB hardware. Use this with two other drivers: * - * - Gadget driver, responding to requests (slave); + * - Gadget driver, responding to requests (device); * - Host-side device driver, as already familiar in Linux. * * Having this all in one kernel can help some stages of development, @@ -261,7 +261,7 @@ struct dummy { spinlock_t lock; /* - * SLAVE/GADGET side support + * DEVICE/GADGET side support */ struct dummy_ep ep[DUMMY_ENDPOINTS]; int address; @@ -276,7 +276,7 @@ struct dummy { unsigned pullup:1; /* - * MASTER/HOST side support + * HOST side support */ struct dummy_hcd *hs_hcd; struct dummy_hcd *ss_hcd; @@ -323,7 +323,7 @@ static inline struct dummy *gadget_dev_to_dummy(struct device *dev) /*-------------------------------------------------------------------------*/ -/* SLAVE/GADGET SIDE UTILITY ROUTINES */ +/* DEVICE/GADGET SIDE UTILITY ROUTINES */ /* called with spinlock held */ static void nuke(struct dummy *dum, struct dummy_ep *ep) @@ -486,7 +486,7 @@ static void set_link_state(struct dummy_hcd *dum_hcd) /*-------------------------------------------------------------------------*/ -/* SLAVE/GADGET SIDE DRIVER +/* DEVICE/GADGET SIDE DRIVER * * This only tracks gadget state. All the work is done when the host * side tries some (emulated) i/o operation. Real device controller @@ -567,12 +567,12 @@ static int dummy_enable(struct usb_ep *_ep, if (max <= 1024) break; /* save a return statement */ - /* fall through */ + fallthrough; case USB_SPEED_FULL: if (max <= 64) break; /* save a return statement */ - /* fall through */ + fallthrough; default: if (max <= 8) break; @@ -590,7 +590,7 @@ static int dummy_enable(struct usb_ep *_ep, if (max <= 1024) break; /* save a return statement */ - /* fall through */ + fallthrough; case USB_SPEED_FULL: if (max <= 1023) break; @@ -957,7 +957,7 @@ static DEVICE_ATTR_RO(function); * hardware can be built with discrete components, so the gadget API doesn't * require that assumption. * - * For this emulator, it might be convenient to create a usb slave device + * For this emulator, it might be convenient to create a usb device * for each driver that registers: just add to a big root hub. */ @@ -981,7 +981,7 @@ static int dummy_udc_start(struct usb_gadget *g, } /* - * SLAVE side init ... the layer above hardware, which + * DEVICE side init ... the layer above hardware, which * can't enumerate without help from the driver we're binding. */ @@ -1151,7 +1151,7 @@ static unsigned int dummy_get_ep_idx(const struct usb_endpoint_descriptor *desc) return index; } -/* MASTER/HOST SIDE DRIVER +/* HOST SIDE DRIVER * * this uses the hcd framework to hook up to host side drivers. * its root hub will only have one device, otherwise it acts like @@ -1581,7 +1581,7 @@ static struct dummy_ep *find_endpoint(struct dummy *dum, u8 address) /** * handle_control_request() - handles all control transfers - * @dum: pointer to dummy (the_controller) + * @dum_hcd: pointer to dummy (the_controller) * @urb: the urb request to handle * @setup: pointer to the setup data for a USB device control * request @@ -1943,7 +1943,7 @@ restart: * this almost certainly polls too fast. */ limit = max(limit, periodic_bytes(dum, ep)); - /* FALLTHROUGH */ + fallthrough; default: treat_control_like_bulk: @@ -2252,7 +2252,7 @@ static int dummy_hub_control( "supported for USB 2.0 roothub\n"); goto error; } - /* FALLS THROUGH */ + fallthrough; case USB_PORT_FEAT_RESET: /* if it's already enabled, disable */ if (hcd->speed == HCD_USB3) { @@ -2276,7 +2276,7 @@ static int dummy_hub_control( * interval? Is it still 50msec as for HS? */ dum_hcd->re_timeout = jiffies + msecs_to_jiffies(50); - /* FALLS THROUGH */ + fallthrough; default: if (hcd->speed == HCD_USB3) { if ((dum_hcd->port_status & @@ -2451,8 +2451,8 @@ static int dummy_start(struct usb_hcd *hcd) struct dummy_hcd *dum_hcd = hcd_to_dummy_hcd(hcd); /* - * MASTER side init ... we emulate a root hub that'll only ever - * talk to one device (the slave side). Also appears in sysfs, + * HOST side init ... we emulate a root hub that'll only ever + * talk to one device (the gadget side). Also appears in sysfs, * just like more familiar pci-based HCDs. */ if (!usb_hcd_is_primary_hcd(hcd)) diff --git a/drivers/usb/gadget/udc/goku_udc.c b/drivers/usb/gadget/udc/goku_udc.c index 91dcb1995c27..25c1d6ab5adb 100644 --- a/drivers/usb/gadget/udc/goku_udc.c +++ b/drivers/usb/gadget/udc/goku_udc.c @@ -125,11 +125,14 @@ goku_ep_enable(struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc) max = get_unaligned_le16(&desc->wMaxPacketSize); switch (max) { case 64: - mode++; /* fall through */ + mode++; + fallthrough; case 32: - mode++; /* fall through */ + mode++; + fallthrough; case 16: - mode++; /* fall through */ + mode++; + fallthrough; case 8: mode <<= 3; break; diff --git a/drivers/usb/gadget/udc/gr_udc.c b/drivers/usb/gadget/udc/gr_udc.c index 7419889ebe9a..f8f3aa52383b 100644 --- a/drivers/usb/gadget/udc/gr_udc.c +++ b/drivers/usb/gadget/udc/gr_udc.c @@ -8,7 +8,7 @@ * GRLIB VHDL IP core library. * * Full documentation of the GRUSBDC core can be found here: - * http://www.gaisler.com/products/grlib/grip.pdf + * https://www.gaisler.com/products/grlib/grip.pdf * * Contributors: * - Andreas Larsson <andreas@gaisler.com> @@ -912,9 +912,9 @@ static int gr_device_request(struct gr_udc *dev, u8 type, u8 request, return gr_ep0_respond_empty(dev); case USB_DEVICE_TEST_MODE: - /* The hardware does not support TEST_FORCE_EN */ + /* The hardware does not support USB_TEST_FORCE_ENABLE */ test = index >> 8; - if (test >= TEST_J && test <= TEST_PACKET) { + if (test >= USB_TEST_J && test <= USB_TEST_PACKET) { dev->test_mode = test; return gr_ep0_respond(dev, NULL, 0, gr_ep0_testmode_complete); diff --git a/drivers/usb/gadget/udc/gr_udc.h b/drivers/usb/gadget/udc/gr_udc.h index 417ad2aa2cc7..ac5b3f65adb5 100644 --- a/drivers/usb/gadget/udc/gr_udc.h +++ b/drivers/usb/gadget/udc/gr_udc.h @@ -8,7 +8,7 @@ * GRLIB VHDL IP core library. * * Full documentation of the GRUSBDC core can be found here: - * http://www.gaisler.com/products/grlib/grip.pdf + * https://www.gaisler.com/products/grlib/grip.pdf * * Contributors: * - Andreas Larsson <andreas@gaisler.com> diff --git a/drivers/usb/gadget/udc/lpc32xx_udc.c b/drivers/usb/gadget/udc/lpc32xx_udc.c index 4a112670cc6c..e8a4637a9a17 100644 --- a/drivers/usb/gadget/udc/lpc32xx_udc.c +++ b/drivers/usb/gadget/udc/lpc32xx_udc.c @@ -2986,7 +2986,7 @@ static void lpc32xx_rmwkup_chg(int remote_wakup_enable) /* Enable or disable USB remote wakeup */ } -struct lpc32xx_usbd_cfg lpc32xx_usbddata = { +static struct lpc32xx_usbd_cfg lpc32xx_usbddata = { .vbus_drv_pol = 0, .conn_chgb = &lpc32xx_usbd_conn_chg, .susp_chgb = &lpc32xx_usbd_susp_chg, diff --git a/drivers/usb/gadget/udc/max3420_udc.c b/drivers/usb/gadget/udc/max3420_udc.c index 23f33946d80c..35179543c327 100644 --- a/drivers/usb/gadget/udc/max3420_udc.c +++ b/drivers/usb/gadget/udc/max3420_udc.c @@ -7,7 +7,7 @@ * * Based on: * o MAX3420E datasheet - * http://datasheets.maximintegrated.com/en/ds/MAX3420E.pdf + * https://datasheets.maximintegrated.com/en/ds/MAX3420E.pdf * o MAX342{0,1}E Programming Guides * https://pdfserv.maximintegrated.com/en/an/AN3598.pdf * https://pdfserv.maximintegrated.com/en/an/AN3785.pdf @@ -623,7 +623,6 @@ static void max3420_set_clear_feature(struct max3420_udc *udc) static void max3420_handle_setup(struct max3420_udc *udc) { struct usb_ctrlrequest setup; - u8 addr; spi_rd_buf(udc, MAX3420_REG_SUDFIFO, (void *)&setup, 8); @@ -647,7 +646,7 @@ static void max3420_handle_setup(struct max3420_udc *udc) USB_TYPE_STANDARD | USB_RECIP_DEVICE)) { break; } - addr = spi_rd8_ack(udc, MAX3420_REG_FNADDR, 1); + spi_rd8_ack(udc, MAX3420_REG_FNADDR, 1); dev_dbg(udc->dev, "Assigned Address=%d\n", udc->setup.wValue); return; case USB_REQ_CLEAR_FEATURE: diff --git a/drivers/usb/gadget/udc/mv_u3d_core.c b/drivers/usb/gadget/udc/mv_u3d_core.c index 5bb0568b934e..5486f5a70868 100644 --- a/drivers/usb/gadget/udc/mv_u3d_core.c +++ b/drivers/usb/gadget/udc/mv_u3d_core.c @@ -32,7 +32,6 @@ #define DRIVER_DESC "Marvell PXA USB3.0 Device Controller driver" static const char driver_name[] = "mv_u3d"; -static const char driver_desc[] = DRIVER_DESC; static void mv_u3d_nuke(struct mv_u3d_ep *ep, int status); static void mv_u3d_stop_activity(struct mv_u3d *u3d, diff --git a/drivers/usb/gadget/udc/mv_udc_core.c b/drivers/usb/gadget/udc/mv_udc_core.c index 80a1b52c656e..0fb4ef464321 100644 --- a/drivers/usb/gadget/udc/mv_udc_core.c +++ b/drivers/usb/gadget/udc/mv_udc_core.c @@ -53,7 +53,6 @@ static DECLARE_COMPLETION(release_done); static const char driver_name[] = "mv_udc"; -static const char driver_desc[] = DRIVER_DESC; static void nuke(struct mv_ep *ep, int status); static void stop_activity(struct mv_udc *udc, struct usb_gadget_driver *driver); @@ -1502,7 +1501,7 @@ out: static void mv_udc_testmode(struct mv_udc *udc, u16 index) { - if (index <= TEST_FORCE_EN) { + if (index <= USB_TEST_FORCE_ENABLE) { udc->test_mode = index; if (udc_prime_status(udc, EP_DIR_IN, 0, true)) ep0_stall(udc); diff --git a/drivers/usb/gadget/udc/net2272.c b/drivers/usb/gadget/udc/net2272.c index 928057b206f1..44d1ea2307bb 100644 --- a/drivers/usb/gadget/udc/net2272.c +++ b/drivers/usb/gadget/udc/net2272.c @@ -1688,7 +1688,7 @@ net2272_set_test_mode(struct net2272 *dev, int mode) net2272_write(dev, USBTEST, mode); /* load test packet */ - if (mode == TEST_PACKET) { + if (mode == USB_TEST_PACKET) { /* switch to 8 bit mode */ net2272_write(dev, LOCCTL, net2272_read(dev, LOCCTL) & ~(1 << DATA_WIDTH)); @@ -2370,6 +2370,8 @@ net2272_rdk1_probe(struct pci_dev *pdev, struct net2272 *dev) err: while (--i >= 0) { + if (i == 1) + continue; /* BAR1 unused */ iounmap(mem_mapped_addr[i]); release_mem_region(pci_resource_start(pdev, i), pci_resource_len(pdev, i)); diff --git a/drivers/usb/gadget/udc/net2272.h b/drivers/usb/gadget/udc/net2272.h index 8e644627992d..87d0ab9ffeeb 100644 --- a/drivers/usb/gadget/udc/net2272.h +++ b/drivers/usb/gadget/udc/net2272.h @@ -105,11 +105,6 @@ #define USBTEST 0x32 #define TEST_MODE_SELECT 0 #define NORMAL_OPERATION 0 -#define TEST_J 1 -#define TEST_K 2 -#define TEST_SE0_NAK 3 -#define TEST_PACKET 4 -#define TEST_FORCE_ENABLE 5 #define XCVRDIAG 0x33 #define FORCE_FULL_SPEED 2 #define FORCE_HIGH_SPEED 3 diff --git a/drivers/usb/gadget/udc/net2280.c b/drivers/usb/gadget/udc/net2280.c index 5eff85eeaa5a..7530bd9a08c4 100644 --- a/drivers/usb/gadget/udc/net2280.c +++ b/drivers/usb/gadget/udc/net2280.c @@ -3781,8 +3781,10 @@ static int net2280_probe(struct pci_dev *pdev, const struct pci_device_id *id) return 0; done: - if (dev) + if (dev) { net2280_remove(pdev); + kfree(dev); + } return retval; } diff --git a/drivers/usb/gadget/udc/omap_udc.c b/drivers/usb/gadget/udc/omap_udc.c index 4139da885651..494da00398d7 100644 --- a/drivers/usb/gadget/udc/omap_udc.c +++ b/drivers/usb/gadget/udc/omap_udc.c @@ -2831,7 +2831,7 @@ static int omap_udc_probe(struct platform_device *pdev) type = "integrated"; break; } - /* FALL THROUGH */ + fallthrough; case 3: case 11: case 16: @@ -2848,7 +2848,7 @@ static int omap_udc_probe(struct platform_device *pdev) case 14: /* transceiverless */ if (cpu_is_omap1710()) goto bad_on_1710; - /* FALL THROUGH */ + fallthrough; case 13: case 15: type = "no"; diff --git a/drivers/usb/gadget/udc/pch_udc.c b/drivers/usb/gadget/udc/pch_udc.c index 3344fb8c4181..8afc31d94b0e 100644 --- a/drivers/usb/gadget/udc/pch_udc.c +++ b/drivers/usb/gadget/udc/pch_udc.c @@ -229,8 +229,7 @@ struct pch_udc_data_dma_desc { * for control data * @status: Status * @reserved: Reserved - * @data12: First setup word - * @data34: Second setup word + * @request: Control Request */ struct pch_udc_stp_dma_desc { u32 status; @@ -304,8 +303,8 @@ struct pch_udc_ep { * for detecting VBUS * @port: gpio port number * @intr: gpio interrupt number - * @irq_work_fall Structure for WorkQueue - * @irq_work_rise Structure for WorkQueue + * @irq_work_fall: Structure for WorkQueue + * @irq_work_rise: Structure for WorkQueue */ struct pch_vbus_gpio_data { int port; @@ -475,7 +474,7 @@ static void pch_udc_csr_busy(struct pch_udc_dev *dev) * pch_udc_write_csr() - Write the command and status registers. * @dev: Reference to pch_udc_dev structure * @val: value to be written to CSR register - * @addr: address of CSR register + * @ep: end-point number */ static void pch_udc_write_csr(struct pch_udc_dev *dev, unsigned long val, unsigned int ep) @@ -490,7 +489,7 @@ static void pch_udc_write_csr(struct pch_udc_dev *dev, unsigned long val, /** * pch_udc_read_csr() - Read the command and status registers. * @dev: Reference to pch_udc_dev structure - * @addr: address of CSR register + * @ep: end-point number * * Return codes: content of CSR register */ @@ -656,6 +655,7 @@ static inline void pch_udc_ep_set_trfr_type(struct pch_udc_ep *ep, * pch_udc_ep_set_bufsz() - Set the maximum packet size for the endpoint * @ep: Reference to structure of type pch_udc_ep_regs * @buf_size: The buffer word size + * @ep_in: EP is IN */ static void pch_udc_ep_set_bufsz(struct pch_udc_ep *ep, u32 buf_size, u32 ep_in) @@ -968,7 +968,8 @@ static void pch_udc_ep_fifo_flush(struct pch_udc_ep *ep, int dir) /** * pch_udc_ep_enable() - This api enables endpoint - * @regs: Reference to structure pch_udc_ep_regs + * @ep: reference to structure of type pch_udc_ep_regs + * @cfg: current configuration information * @desc: endpoint descriptor */ static void pch_udc_ep_enable(struct pch_udc_ep *ep, @@ -1004,7 +1005,7 @@ static void pch_udc_ep_enable(struct pch_udc_ep *ep, /** * pch_udc_ep_disable() - This api disables endpoint - * @regs: Reference to structure pch_udc_ep_regs + * @ep: reference to structure of type pch_udc_ep_regs */ static void pch_udc_ep_disable(struct pch_udc_ep *ep) { @@ -1024,7 +1025,7 @@ static void pch_udc_ep_disable(struct pch_udc_ep *ep) /** * pch_udc_wait_ep_stall() - Wait EP stall. - * @dev: Reference to pch_udc_dev structure + * @ep: reference to structure of type pch_udc_ep_regs */ static void pch_udc_wait_ep_stall(struct pch_udc_ep *ep) { @@ -1331,7 +1332,7 @@ static void pch_vbus_gpio_work_rise(struct work_struct *irq_work) /** * pch_vbus_gpio_irq() - IRQ handler for GPIO interrupt for changing VBUS * @irq: Interrupt request number - * @dev: Reference to the device structure + * @data: Reference to the device structure * * Return codes: * 0: Success @@ -1354,8 +1355,8 @@ static irqreturn_t pch_vbus_gpio_irq(int irq, void *data) /** * pch_vbus_gpio_init() - This API initializes GPIO port detecting VBUS. - * @dev: Reference to the driver structure - * @vbus_gpio Number of GPIO port to detect gpio + * @dev: Reference to the driver structure + * @vbus_gpio_port: Number of GPIO port to detect gpio * * Return codes: * 0: Success @@ -1499,8 +1500,8 @@ static void empty_req_queue(struct pch_udc_ep *ep) /** * pch_udc_free_dma_chain() - This function frees the DMA chain created * for the request - * @dev Reference to the driver structure - * @req Reference to the request to be freed + * @dev: Reference to the driver structure + * @req: Reference to the request to be freed * * Return codes: * 0: Success @@ -1707,7 +1708,7 @@ static int pch_udc_pcd_ep_enable(struct usb_ep *usbep, /** * pch_udc_pcd_ep_disable() - This API disables endpoint and is called * from gadget driver - * @usbep Reference to the USB endpoint structure + * @usbep: Reference to the USB endpoint structure * * Return codes: * 0: Success @@ -1996,7 +1997,6 @@ static int pch_udc_pcd_set_halt(struct usb_ep *usbep, int halt) * pch_udc_pcd_set_wedge() - This function Sets or clear the endpoint * halt feature * @usbep: Reference to the USB endpoint structure - * @halt: Specifies whether to set or clear the feature * * Return codes: * 0: Success @@ -2750,7 +2750,7 @@ static void pch_udc_dev_isr(struct pch_udc_dev *dev, u32 dev_intr) /** * pch_udc_isr() - This function handles interrupts from the PCH USB Device * @irq: Interrupt request number - * @dev: Reference to the device structure + * @pdev: Reference to the device structure */ static irqreturn_t pch_udc_isr(int irq, void *pdev) { @@ -2900,7 +2900,7 @@ static int pch_udc_pcd_init(struct pch_udc_dev *dev) /** * init_dma_pools() - create dma pools during initialization - * @pdev: reference to struct pci_dev + * @dev: reference to struct pci_dev */ static int init_dma_pools(struct pch_udc_dev *dev) { diff --git a/drivers/usb/gadget/udc/pxa27x_udc.c b/drivers/usb/gadget/udc/pxa27x_udc.c index 78902d13fc27..cfaeca457fa7 100644 --- a/drivers/usb/gadget/udc/pxa27x_udc.c +++ b/drivers/usb/gadget/udc/pxa27x_udc.c @@ -386,7 +386,7 @@ static inline void udc_clear_mask_UDCCR(struct pxa_udc *udc, int mask) /** * ep_write_UDCCSR - set bits in UDCCSR - * @udc: udc device + * @ep: udc endpoint * @mask: bits to set in UDCCR * * Sets bits in UDCCSR (UDCCSR0 and UDCCSR*). @@ -472,7 +472,7 @@ static int epout_has_pkt(struct pxa_ep *ep) /** * set_ep0state - Set ep0 automata state - * @dev: udc device + * @udc: udc device * @state: state */ static void set_ep0state(struct pxa_udc *udc, int state) @@ -498,7 +498,6 @@ static void ep0_idle(struct pxa_udc *dev) /** * inc_ep_stats_reqs - Update ep stats counts * @ep: physical endpoint - * @req: usb request * @is_in: ep direction (USB_DIR_IN or 0) * */ @@ -1473,7 +1472,6 @@ static void udc_disable(struct pxa_udc *udc); * Context: any * * The UDC should be enabled if : - * - the pullup resistor is connected * - and a gadget driver is bound * - and vbus is sensed (or no vbus sense is available) @@ -1688,7 +1686,7 @@ static void udc_init_data(struct pxa_udc *dev) /** * udc_enable - Enables the udc device - * @dev: udc device + * @udc: udc device * * Enables the udc device : enables clocks, udc interrupts, control endpoint * interrupts, sets usb as UDC client and setups endpoints. @@ -1732,8 +1730,8 @@ static void udc_enable(struct pxa_udc *udc) /** * pxa27x_start - Register gadget driver + * @g: gadget * @driver: gadget driver - * @bind: bind function * * When a driver is successfully registered, it will receive control requests * including set_configuration(), which enables non-control requests. Then @@ -1775,7 +1773,6 @@ fail: /** * stop_activity - Stops udc endpoints * @udc: udc device - * @driver: gadget driver * * Disables all udc endpoints (even control endpoint), report disconnect to * the gadget user. @@ -1792,7 +1789,7 @@ static void stop_activity(struct pxa_udc *udc) /** * pxa27x_udc_stop - Unregister the gadget driver - * @driver: gadget driver + * @g: gadget * * Returns 0 if no error, -ENODEV, -EINVAL otherwise */ @@ -2349,7 +2346,7 @@ MODULE_DEVICE_TABLE(of, udc_pxa_dt_ids); /** * pxa_udc_probe - probes the udc device - * @_dev: platform device + * @pdev: platform device * * Perform basic init : allocates udc clock, creates sysfs files, requests * irq. diff --git a/drivers/usb/gadget/udc/r8a66597-udc.c b/drivers/usb/gadget/udc/r8a66597-udc.c index 537094b485bf..896c1a016d55 100644 --- a/drivers/usb/gadget/udc/r8a66597-udc.c +++ b/drivers/usb/gadget/udc/r8a66597-udc.c @@ -1827,10 +1827,8 @@ static void nop_completion(struct usb_ep *ep, struct usb_request *r) static int r8a66597_sudmac_ioremap(struct r8a66597 *r8a66597, struct platform_device *pdev) { - struct resource *res; - - res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "sudmac"); - r8a66597->sudmac_reg = devm_ioremap_resource(&pdev->dev, res); + r8a66597->sudmac_reg = + devm_platform_ioremap_resource_byname(pdev, "sudmac"); return PTR_ERR_OR_ZERO(r8a66597->sudmac_reg); } diff --git a/drivers/usb/gadget/udc/s3c2410_udc.c b/drivers/usb/gadget/udc/s3c2410_udc.c index 80002d97b59d..bc2e8eb737c3 100644 --- a/drivers/usb/gadget/udc/s3c2410_udc.c +++ b/drivers/usb/gadget/udc/s3c2410_udc.c @@ -308,7 +308,7 @@ static int s3c2410_udc_write_fifo(struct s3c2410_ep *ep, switch (idx) { default: idx = 0; - /* fall through */ + fallthrough; case 0: fifo_reg = S3C2410_UDC_EP0_FIFO_REG; break; @@ -413,7 +413,7 @@ static int s3c2410_udc_read_fifo(struct s3c2410_ep *ep, switch (idx) { default: idx = 0; - /* fall through */ + fallthrough; case 0: fifo_reg = S3C2410_UDC_EP0_FIFO_REG; break; diff --git a/drivers/usb/gadget/udc/snps_udc_core.c b/drivers/usb/gadget/udc/snps_udc_core.c index e76f1a50b0fc..6c726d2e1788 100644 --- a/drivers/usb/gadget/udc/snps_udc_core.c +++ b/drivers/usb/gadget/udc/snps_udc_core.c @@ -2,7 +2,7 @@ /* * amd5536.c -- AMD 5536 UDC high/full speed USB device controller * - * Copyright (C) 2005-2007 AMD (http://www.amd.com) + * Copyright (C) 2005-2007 AMD (https://www.amd.com) * Author: Thomas Dahlmann */ diff --git a/drivers/usb/gadget/udc/tegra-xudc.c b/drivers/usb/gadget/udc/tegra-xudc.c index bbe1a04686da..d6ff68c06911 100644 --- a/drivers/usb/gadget/udc/tegra-xudc.c +++ b/drivers/usb/gadget/udc/tegra-xudc.c @@ -2742,7 +2742,7 @@ static void tegra_xudc_handle_transfer_event(struct tegra_xudc *xudc, ep_wait_for_stopped(xudc, ep_index); ep->enq_ptr = ep->deq_ptr; tegra_xudc_ep_nuke(ep, -EIO); - /* FALLTHROUGH */ + fallthrough; case TRB_CMPL_CODE_STREAM_NUMP_ERROR: case TRB_CMPL_CODE_CTRL_DIR_ERR: case TRB_CMPL_CODE_INVALID_STREAM_TYPE_ERR: @@ -3750,15 +3750,12 @@ static int tegra_xudc_probe(struct platform_device *pdev) return PTR_ERR(xudc->base); xudc->phys_base = res->start; - res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "fpci"); - xudc->fpci = devm_ioremap_resource(&pdev->dev, res); + xudc->fpci = devm_platform_ioremap_resource_byname(pdev, "fpci"); if (IS_ERR(xudc->fpci)) return PTR_ERR(xudc->fpci); if (xudc->soc->has_ipfs) { - res = platform_get_resource_byname(pdev, IORESOURCE_MEM, - "ipfs"); - xudc->ipfs = devm_ioremap_resource(&pdev->dev, res); + xudc->ipfs = devm_platform_ioremap_resource_byname(pdev, "ipfs"); if (IS_ERR(xudc->ipfs)) return PTR_ERR(xudc->ipfs); } diff --git a/drivers/usb/gadget/udc/udc-xilinx.c b/drivers/usb/gadget/udc/udc-xilinx.c index 709553bdb233..d5e9d20c097d 100644 --- a/drivers/usb/gadget/udc/udc-xilinx.c +++ b/drivers/usb/gadget/udc/udc-xilinx.c @@ -2097,9 +2097,9 @@ static int xudc_probe(struct platform_device *pdev) /* Check for IP endianness */ udc->write_fn = xudc_write32_be; udc->read_fn = xudc_read32_be; - udc->write_fn(udc->addr, XUSB_TESTMODE_OFFSET, TEST_J); + udc->write_fn(udc->addr, XUSB_TESTMODE_OFFSET, USB_TEST_J); if ((udc->read_fn(udc->addr + XUSB_TESTMODE_OFFSET)) - != TEST_J) { + != USB_TEST_J) { udc->write_fn = xudc_write32; udc->read_fn = xudc_read32; } |