From 38145ed12ed9935377fec40e0c3f50fbdda1e148 Mon Sep 17 00:00:00 2001 From: Peter Chen Date: Wed, 10 Jun 2020 11:37:41 +0800 Subject: usb: chipidea: udc: fix the ENDIAN issue Fix the ENDIAN issue when assign dTD entry. Reported-by: kbuild test robot Signed-off-by: Peter Chen --- drivers/usb/chipidea/udc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c index db0cfde0cc3c..ff9de91d98ca 100644 --- a/drivers/usb/chipidea/udc.c +++ b/drivers/usb/chipidea/udc.c @@ -473,9 +473,10 @@ static void ci_add_buffer_entry(struct td_node *node, struct scatterlist *s) int empty_td_slot_index = (CI_MAX_BUF_SIZE - node->td_remaining_size) / CI_HDRC_PAGE_SIZE; int i; + u32 token; - node->ptr->token += - cpu_to_le32(sg_dma_len(s) << __ffs(TD_TOTAL_BYTES)); + token = le32_to_cpu(node->ptr->token) + (sg_dma_len(s) << __ffs(TD_TOTAL_BYTES)); + node->ptr->token = cpu_to_le32(token); for (i = empty_td_slot_index; i < TD_PAGE_COUNT; i++) { u32 page = (u32) sg_dma_address(s) + -- cgit v1.2.3-70-g09d2 From 03cc8353c2244c8b790c3c81a0f1532d34a9d738 Mon Sep 17 00:00:00 2001 From: Rob Gill Date: Mon, 1 Jun 2020 21:17:56 +0000 Subject: USB: core: additional Device Classes to debug/usb/devices Several newer USB Device classes are not presently reported individually at /sys/kernel/debug/usb/devices, (reported as "unk."). This patch adds the following classes: 0fh (Personal Healthcare devices), 10h (USB Type-C combined Audio/Video devices) 11h (USB billboard), 12h (USB Type-C Bridge). As defined at [https://www.usb.org/defined-class-codes] Corresponding classes defined in include/linux/usb/ch9.h. Signed-off-by: Rob Gill Link: https://lore.kernel.org/r/20200601211749.6878-1-rrobgill@protonmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/core/devices.c | 4 ++++ include/uapi/linux/usb/ch9.h | 4 ++++ 2 files changed, 8 insertions(+) (limited to 'drivers/usb') diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c index 94b6fa6e585e..696b2b692b83 100644 --- a/drivers/usb/core/devices.c +++ b/drivers/usb/core/devices.c @@ -133,6 +133,10 @@ static const struct class_info clas_info[] = { {USB_CLASS_CSCID, "scard"}, {USB_CLASS_CONTENT_SEC, "c-sec"}, {USB_CLASS_VIDEO, "video"}, + {USB_CLASS_PERSONAL_HEALTHCARE, "perhc"}, + {USB_CLASS_AUDIO_VIDEO, "av"}, + {USB_CLASS_BILLBOARD, "blbrd"}, + {USB_CLASS_USB_TYPE_C_BRIDGE, "bridg"}, {USB_CLASS_WIRELESS_CONTROLLER, "wlcon"}, {USB_CLASS_MISC, "misc"}, {USB_CLASS_APP_SPEC, "app."}, diff --git a/include/uapi/linux/usb/ch9.h b/include/uapi/linux/usb/ch9.h index 2b623f36af6b..456ab0c2b586 100644 --- a/include/uapi/linux/usb/ch9.h +++ b/include/uapi/linux/usb/ch9.h @@ -326,6 +326,10 @@ struct usb_device_descriptor { #define USB_CLASS_CONTENT_SEC 0x0d /* content security */ #define USB_CLASS_VIDEO 0x0e #define USB_CLASS_WIRELESS_CONTROLLER 0xe0 +#define USB_CLASS_PERSONAL_HEALTHCARE 0x0f +#define USB_CLASS_AUDIO_VIDEO 0x10 +#define USB_CLASS_BILLBOARD 0x11 +#define USB_CLASS_USB_TYPE_C_BRIDGE 0x12 #define USB_CLASS_MISC 0xef #define USB_CLASS_APP_SPEC 0xfe #define USB_CLASS_VENDOR_SPEC 0xff -- cgit v1.2.3-70-g09d2 From 9f3aedbe98fe5afaf68b74cc1b242eca77fe3119 Mon Sep 17 00:00:00 2001 From: Kieran Bingham Date: Tue, 9 Jun 2020 13:46:00 +0100 Subject: drivers: usb: Fix trivial spelling The word 'descriptor' is misspelled throughout the tree. Fix it up accordingly: decriptors -> descriptors Signed-off-by: Kieran Bingham Link: https://lore.kernel.org/r/20200609124610.3445662-8-kieran.bingham+renesas@ideasonboard.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/core/of.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/usb') diff --git a/drivers/usb/core/of.c b/drivers/usb/core/of.c index 651708d8c908..617e92569b2c 100644 --- a/drivers/usb/core/of.c +++ b/drivers/usb/core/of.c @@ -45,7 +45,7 @@ EXPORT_SYMBOL_GPL(usb_of_get_device_node); * * Determine whether a USB device has a so called combined node which is * shared with its sole interface. This is the case if and only if the device - * has a node and its decriptors report the following: + * has a node and its descriptors report the following: * * 1) bDeviceClass is 0 or 9, and * 2) bNumConfigurations is 1, and -- cgit v1.2.3-70-g09d2 From 07d9878fa18f5283182f4c13e708e22c11016efe Mon Sep 17 00:00:00 2001 From: Jisheng Zhang Date: Tue, 16 Jun 2020 16:26:17 +0800 Subject: usb: dwc2: use well defined macros for power_down Use the well defined macros such as DWC2_POWER_DOWN_PARAM_NONE, DWC2_POWER_DOWN_PARAM_PARTIAL and DWC2_POWER_DOWN_PARAM_HIBERNATION to make code more readable. Signed-off-by: Jisheng Zhang Acked-by: Minas Harutyunyan Link: https://lore.kernel.org/r/20200616162617.38365cc8@xhacker.debian Signed-off-by: Greg Kroah-Hartman --- drivers/usb/dwc2/hcd.c | 4 ++-- drivers/usb/dwc2/params.c | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c index b90f858af960..e9ac215b9663 100644 --- a/drivers/usb/dwc2/hcd.c +++ b/drivers/usb/dwc2/hcd.c @@ -3628,7 +3628,7 @@ static int dwc2_hcd_hub_control(struct dwc2_hsotg *hsotg, u16 typereq, "SetPortFeature - USB_PORT_FEAT_SUSPEND\n"); if (windex != hsotg->otg_port) goto error; - if (hsotg->params.power_down == 2) + if (hsotg->params.power_down == DWC2_POWER_DOWN_PARAM_HIBERNATION) dwc2_enter_hibernation(hsotg, 1); else dwc2_port_suspend(hsotg, windex); @@ -3646,7 +3646,7 @@ static int dwc2_hcd_hub_control(struct dwc2_hsotg *hsotg, u16 typereq, break; case USB_PORT_FEAT_RESET: - if (hsotg->params.power_down == 2 && + if (hsotg->params.power_down == DWC2_POWER_DOWN_PARAM_HIBERNATION && hsotg->hibernated) dwc2_exit_hibernation(hsotg, 0, 1, 1); hprt0 = dwc2_read_hprt0(hsotg); diff --git a/drivers/usb/dwc2/params.c b/drivers/usb/dwc2/params.c index ce736d67c7c3..8f9d061c4d5f 100644 --- a/drivers/usb/dwc2/params.c +++ b/drivers/usb/dwc2/params.c @@ -68,14 +68,14 @@ static void dwc2_set_his_params(struct dwc2_hsotg *hsotg) p->ahbcfg = GAHBCFG_HBSTLEN_INCR16 << GAHBCFG_HBSTLEN_SHIFT; p->change_speed_quirk = true; - p->power_down = false; + p->power_down = DWC2_POWER_DOWN_PARAM_NONE; } static void dwc2_set_s3c6400_params(struct dwc2_hsotg *hsotg) { struct dwc2_core_params *p = &hsotg->params; - p->power_down = 0; + p->power_down = DWC2_POWER_DOWN_PARAM_NONE; p->phy_utmi_width = 8; } @@ -89,7 +89,7 @@ static void dwc2_set_rk_params(struct dwc2_hsotg *hsotg) p->host_perio_tx_fifo_size = 256; p->ahbcfg = GAHBCFG_HBSTLEN_INCR16 << GAHBCFG_HBSTLEN_SHIFT; - p->power_down = 0; + p->power_down = DWC2_POWER_DOWN_PARAM_NONE; } static void dwc2_set_ltq_params(struct dwc2_hsotg *hsotg) @@ -319,11 +319,11 @@ static void dwc2_set_param_power_down(struct dwc2_hsotg *hsotg) int val; if (hsotg->hw_params.hibernation) - val = 2; + val = DWC2_POWER_DOWN_PARAM_HIBERNATION; else if (hsotg->hw_params.power_optimized) - val = 1; + val = DWC2_POWER_DOWN_PARAM_PARTIAL; else - val = 0; + val = DWC2_POWER_DOWN_PARAM_NONE; hsotg->params.power_down = val; } -- cgit v1.2.3-70-g09d2 From 9ffcc3053f3b6950da6e8b98ab2733d7eee70800 Mon Sep 17 00:00:00 2001 From: Macpaul Lin Date: Tue, 16 Jun 2020 13:56:17 +0800 Subject: usb: gadget: u_serial.h: increase MAX_U_SERIAL_PORTS to 8 Mediatek's LTE modem needs up to 8 ports to connect to PC for logging and debugging under some scenarios. Hence we suggest to increase the definition of MAX_U_SERIAL_PORTS to 8 for some complex embedded systems. Signed-off-by: Macpaul Lin Link: https://lore.kernel.org/r/1592286977-30483-1-git-send-email-macpaul.lin@mediatek.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/function/u_serial.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/usb') diff --git a/drivers/usb/gadget/function/u_serial.h b/drivers/usb/gadget/function/u_serial.h index cadb76eecbc7..102a7323a1fd 100644 --- a/drivers/usb/gadget/function/u_serial.h +++ b/drivers/usb/gadget/function/u_serial.h @@ -12,7 +12,7 @@ #include #include -#define MAX_U_SERIAL_PORTS 4 +#define MAX_U_SERIAL_PORTS 8 struct f_serial_opts { struct usb_function_instance func_inst; -- cgit v1.2.3-70-g09d2 From 153de2d66e53b1729a7761b926ca0b89392b3127 Mon Sep 17 00:00:00 2001 From: "Gustavo A. R. Silva" Date: Mon, 15 Jun 2020 18:18:27 -0500 Subject: usb: sisusb_con: Use array_size() helper in memcpy() Use array_size() helper instead of the open-coded version in memcpy(). These sorts of multiplication factors need to be wrapped in array_size(). This issue was found with the help of Coccinelle and, audited and fixed manually. Addresses-KSPP-ID: https://github.com/KSPP/linux/issues/83 Signed-off-by: Gustavo A. R. Silva Link: https://lore.kernel.org/r/20200615231827.GA21348@embeddedor Signed-off-by: Greg Kroah-Hartman --- drivers/usb/misc/sisusbvga/sisusb_con.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/usb') diff --git a/drivers/usb/misc/sisusbvga/sisusb_con.c b/drivers/usb/misc/sisusbvga/sisusb_con.c index cd0155310fea..586d6b01c3c4 100644 --- a/drivers/usb/misc/sisusbvga/sisusb_con.c +++ b/drivers/usb/misc/sisusbvga/sisusb_con.c @@ -1226,7 +1226,7 @@ sisusbcon_font_set(struct vc_data *c, struct console_font *font, sisusb->font_backup = vmalloc(array_size(charcount, 32)); if (sisusb->font_backup) { - memcpy(sisusb->font_backup, font->data, charcount * 32); + memcpy(sisusb->font_backup, font->data, array_size(charcount, 32)); sisusb->font_backup_size = charcount; sisusb->font_backup_height = font->height; sisusb->font_backup_512 = (charcount == 512) ? 1 : 0; -- cgit v1.2.3-70-g09d2 From 41ecdcfce1772b7781059ebbeaed883206ab9479 Mon Sep 17 00:00:00 2001 From: Thierry Reding Date: Fri, 12 Jun 2020 16:02:05 +0200 Subject: usb: xhci: tegra: Remove PLL power supplies The Tegra XUSB controller driver doesn't need to control the PLL power supplies directly, but rather uses the pads provided by the XUSB pad controller, which in turn is responsible for supplying power to the PLLs. Signed-off-by: Thierry Reding Link: https://lore.kernel.org/r/20200612140205.2342900-1-thierry.reding@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/xhci-tegra.c | 8 -------- 1 file changed, 8 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/host/xhci-tegra.c b/drivers/usb/host/xhci-tegra.c index 2eaf5c0af80c..9ce28ab47f4b 100644 --- a/drivers/usb/host/xhci-tegra.c +++ b/drivers/usb/host/xhci-tegra.c @@ -1853,11 +1853,7 @@ static const char * const tegra124_supply_names[] = { "avddio-pex", "dvddio-pex", "avdd-usb", - "avdd-pll-utmip", - "avdd-pll-erefe", - "avdd-usb-ss-pll", "hvdd-usb-ss", - "hvdd-usb-ss-pll-e", }; static const struct tegra_xusb_phy_type tegra124_phy_types[] = { @@ -1931,10 +1927,6 @@ static const char * const tegra210_supply_names[] = { "dvddio-pex", "hvddio-pex", "avdd-usb", - "avdd-pll-utmip", - "avdd-pll-uerefe", - "dvdd-pex-pll", - "hvdd-pex-pll-e", }; static const struct tegra_xusb_phy_type tegra210_phy_types[] = { -- cgit v1.2.3-70-g09d2 From e9ec6cc74e0add3d4f27348fc93ba9d0a705d75e Mon Sep 17 00:00:00 2001 From: Changming Liu Date: Fri, 29 May 2020 21:48:15 -0400 Subject: USB: sisusbvga: change char to u8 for sisusb_copy_memory sisusb_copy_memory is called in several places. sisusb_copy_memory calls sisusb_write_mem_bulk which is called by sisusb_write and sisusb_send_bulk_msg. change the related parameters from char to u8 accordingly Signed-off-by: Changming Liu Link: https://lore.kernel.org/r/20200530014820.9967-2-liu.changm@northeastern.edu Signed-off-by: Greg Kroah-Hartman --- drivers/usb/misc/sisusbvga/sisusb.c | 6 +++--- drivers/usb/misc/sisusbvga/sisusb_con.c | 10 +++++----- drivers/usb/misc/sisusbvga/sisusb_init.h | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/misc/sisusbvga/sisusb.c b/drivers/usb/misc/sisusbvga/sisusb.c index fc8a5da4a07c..88c4975e303d 100644 --- a/drivers/usb/misc/sisusbvga/sisusb.c +++ b/drivers/usb/misc/sisusbvga/sisusb.c @@ -1283,7 +1283,7 @@ int sisusb_readb(struct sisusb_usb_data *sisusb, u32 adr, u8 *data) return sisusb_read_memio_byte(sisusb, SISUSB_TYPE_MEM, adr, data); } -int sisusb_copy_memory(struct sisusb_usb_data *sisusb, char *src, +int sisusb_copy_memory(struct sisusb_usb_data *sisusb, u8 *src, u32 dest, int length) { size_t dummy; @@ -1307,7 +1307,7 @@ static int sisusb_read_memory(struct sisusb_usb_data *sisusb, char *dest, #ifdef SISUSBENDIANTEST static void sisusb_testreadwrite(struct sisusb_usb_data *sisusb) { - static char srcbuffer[] = { 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77 }; + static u8 srcbuffer[] = { 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77 }; char destbuffer[10]; int i, j; @@ -2340,7 +2340,7 @@ int sisusb_reset_text_mode(struct sisusb_usb_data *sisusb, int init) } } else if (sisusb->scrbuf) { - ret |= sisusb_copy_memory(sisusb, (char *)sisusb->scrbuf, + ret |= sisusb_copy_memory(sisusb, (u8 *)sisusb->scrbuf, sisusb->vrambase, sisusb->scrbuf_size); } diff --git a/drivers/usb/misc/sisusbvga/sisusb_con.c b/drivers/usb/misc/sisusbvga/sisusb_con.c index 586d6b01c3c4..15e62a2e9b1b 100644 --- a/drivers/usb/misc/sisusbvga/sisusb_con.c +++ b/drivers/usb/misc/sisusbvga/sisusb_con.c @@ -509,7 +509,7 @@ sisusbcon_switch(struct vc_data *c) /* Restore the screen contents */ memcpy((u16 *)c->vc_origin, (u16 *)c->vc_screenbuf, length); - sisusb_copy_memory(sisusb, (char *)c->vc_origin, + sisusb_copy_memory(sisusb, (u8 *)c->vc_origin, sisusb_haddr(sisusb, c, 0, 0), length); mutex_unlock(&sisusb->lock); @@ -615,7 +615,7 @@ sisusbcon_blank(struct vc_data *c, int blank, int mode_switch) sisusbcon_memsetw((u16 *)c->vc_origin, c->vc_video_erase_char, c->vc_screenbuf_size); - sisusb_copy_memory(sisusb, (char *)c->vc_origin, + sisusb_copy_memory(sisusb, (u8 *)c->vc_origin, sisusb_haddr(sisusb, c, 0, 0), c->vc_screenbuf_size); sisusb->con_blanked = 1; @@ -897,18 +897,18 @@ sisusbcon_scroll(struct vc_data *c, unsigned int t, unsigned int b, if (copyall) sisusb_copy_memory(sisusb, - (char *)c->vc_origin, + (u8 *)c->vc_origin, sisusb_haddr(sisusb, c, 0, 0), c->vc_screenbuf_size); else if (dir == SM_UP) sisusb_copy_memory(sisusb, - (char *)c->vc_origin + c->vc_screenbuf_size - delta, + (u8 *)c->vc_origin + c->vc_screenbuf_size - delta, sisusb_haddr(sisusb, c, 0, 0) + c->vc_screenbuf_size - delta, delta); else sisusb_copy_memory(sisusb, - (char *)c->vc_origin, + (u8 *)c->vc_origin, sisusb_haddr(sisusb, c, 0, 0), delta); diff --git a/drivers/usb/misc/sisusbvga/sisusb_init.h b/drivers/usb/misc/sisusbvga/sisusb_init.h index aa33bc81ee52..b79bdf989933 100644 --- a/drivers/usb/misc/sisusbvga/sisusb_init.h +++ b/drivers/usb/misc/sisusbvga/sisusb_init.h @@ -828,7 +828,7 @@ extern int sisusb_setidxregand(struct sisusb_usb_data *sisusb, u32 port, void sisusb_delete(struct kref *kref); int sisusb_writeb(struct sisusb_usb_data *sisusb, u32 adr, u8 data); int sisusb_readb(struct sisusb_usb_data *sisusb, u32 adr, u8 * data); -int sisusb_copy_memory(struct sisusb_usb_data *sisusb, char *src, +int sisusb_copy_memory(struct sisusb_usb_data *sisusb, u8 *src, u32 dest, int length); int sisusb_reset_text_mode(struct sisusb_usb_data *sisusb, int init); int sisusbcon_do_font_op(struct sisusb_usb_data *sisusb, int set, int slot, -- cgit v1.2.3-70-g09d2 From cda37dbbf17a3a49d434bd1c85eff762faebf3ef Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Thu, 18 Jun 2020 10:32:24 +0100 Subject: usb: xhci: fix spelling mistake in Kconfig "firwmare" -> "firmware" There are two spelling mistakes in the Kconfig text. Fix these. Signed-off-by: Colin Ian King Link: https://lore.kernel.org/r/20200618093224.10179-1-colin.king@canonical.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/Kconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig index 1cb3004ea7b2..ab12c4bf0ef1 100644 --- a/drivers/usb/host/Kconfig +++ b/drivers/usb/host/Kconfig @@ -44,10 +44,10 @@ config USB_XHCI_PCI default y config USB_XHCI_PCI_RENESAS - tristate "Support for additional Renesas xHCI controller with firwmare" + tristate "Support for additional Renesas xHCI controller with firmware" help Say 'Y' to enable the support for the Renesas xHCI controller with - firwmare. Make sure you have the firwmare for the device and + firmware. Make sure you have the firwmare for the device and installed on your system for this device to work. If unsure, say 'N'. -- cgit v1.2.3-70-g09d2 From 81c7462883b0cc0a4eeef0687f80ad5b5baee5f6 Mon Sep 17 00:00:00 2001 From: Macpaul Lin Date: Thu, 18 Jun 2020 17:13:38 +0800 Subject: USB: replace hardcode maximum usb string length by definition Replace hardcoded maximum USB string length (126 bytes) by definition "USB_MAX_STRING_LEN". Signed-off-by: Macpaul Lin Acked-by: Alan Stern Link: https://lore.kernel.org/r/1592471618-29428-1-git-send-email-macpaul.lin@mediatek.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/composite.c | 4 ++-- drivers/usb/gadget/configfs.c | 2 +- drivers/usb/gadget/usbstring.c | 4 ++-- include/uapi/linux/usb/ch9.h | 3 +++ 4 files changed, 8 insertions(+), 5 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c index 5c1eb96a5c57..8fbf73467fef 100644 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c @@ -1085,7 +1085,7 @@ static void collect_langs(struct usb_gadget_strings **sp, __le16 *buf) while (*sp) { s = *sp; language = cpu_to_le16(s->language); - for (tmp = buf; *tmp && tmp < &buf[126]; tmp++) { + for (tmp = buf; *tmp && tmp < &buf[USB_MAX_STRING_LEN]; tmp++) { if (*tmp == language) goto repeat; } @@ -1160,7 +1160,7 @@ static int get_string(struct usb_composite_dev *cdev, collect_langs(sp, s->wData); } - for (len = 0; len <= 126 && s->wData[len]; len++) + for (len = 0; len <= USB_MAX_STRING_LEN && s->wData[len]; len++) continue; if (!len) return -EINVAL; diff --git a/drivers/usb/gadget/configfs.c b/drivers/usb/gadget/configfs.c index 9dc06a4e1b30..56051bb97349 100644 --- a/drivers/usb/gadget/configfs.c +++ b/drivers/usb/gadget/configfs.c @@ -103,7 +103,7 @@ static int usb_string_copy(const char *s, char **s_copy) char *str; char *copy = *s_copy; ret = strlen(s); - if (ret > 126) + if (ret > USB_MAX_STRING_LEN) return -EOVERFLOW; str = kstrdup(s, GFP_KERNEL); diff --git a/drivers/usb/gadget/usbstring.c b/drivers/usb/gadget/usbstring.c index 58a4d3325090..30f889ad3ad2 100644 --- a/drivers/usb/gadget/usbstring.c +++ b/drivers/usb/gadget/usbstring.c @@ -55,9 +55,9 @@ usb_gadget_get_string (const struct usb_gadget_strings *table, int id, u8 *buf) return -EINVAL; /* string descriptors have length, tag, then UTF16-LE text */ - len = min ((size_t) 126, strlen (s->s)); + len = min((size_t)USB_MAX_STRING_LEN, strlen(s->s)); len = utf8s_to_utf16s(s->s, len, UTF16_LITTLE_ENDIAN, - (wchar_t *) &buf[2], 126); + (wchar_t *) &buf[2], USB_MAX_STRING_LEN); if (len < 0) return -EINVAL; buf [0] = (len + 1) * 2; diff --git a/include/uapi/linux/usb/ch9.h b/include/uapi/linux/usb/ch9.h index 456ab0c2b586..b1ed2ccfe9cf 100644 --- a/include/uapi/linux/usb/ch9.h +++ b/include/uapi/linux/usb/ch9.h @@ -368,6 +368,9 @@ struct usb_config_descriptor { /*-------------------------------------------------------------------------*/ +/* USB String descriptors can contain at most 126 characters. */ +#define USB_MAX_STRING_LEN 126 + /* USB_DT_STRING: String descriptor */ struct usb_string_descriptor { __u8 bLength; -- cgit v1.2.3-70-g09d2 From 91c7eaa686c3b7ae2d5b2aed22a45a02c8baa30e Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Thu, 18 Jun 2020 11:42:53 +0200 Subject: USB: rename USB quirk to USB_QUIRK_ENDPOINT_IGNORE MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The USB core has a quirk flag to ignore specific endpoints, so rename it to be more obvious what this quirk does. Cc: Johan Hovold Cc: Alan Stern Cc: Richard Dodd Cc: Hans de Goede Cc: Jonathan Cox Cc: Bastien Nocera Cc: "Thiébaud Weksteen" Cc: Nishad Kamdar Link: https://lore.kernel.org/r/20200618094300.1887727-2-gregkh@linuxfoundation.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/core/config.c | 8 ++++---- drivers/usb/core/quirks.c | 18 +++++++++--------- drivers/usb/core/usb.h | 2 +- include/linux/usb/quirks.h | 4 ++-- 4 files changed, 16 insertions(+), 16 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c index b7918f695434..37442f423a41 100644 --- a/drivers/usb/core/config.c +++ b/drivers/usb/core/config.c @@ -298,10 +298,10 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno, goto skip_to_next_endpoint_or_interface_descriptor; } - /* Ignore blacklisted endpoints */ - if (udev->quirks & USB_QUIRK_ENDPOINT_BLACKLIST) { - if (usb_endpoint_is_blacklisted(udev, ifp, d)) { - dev_warn(ddev, "config %d interface %d altsetting %d has a blacklisted endpoint with address 0x%X, skipping\n", + /* Ignore some endpoints */ + if (udev->quirks & USB_QUIRK_ENDPOINT_IGNORE) { + if (usb_endpoint_is_ignored(udev, ifp, d)) { + dev_warn(ddev, "config %d interface %d altsetting %d has an ignored endpoint with address 0x%X, skipping\n", cfgno, inum, asnum, d->bEndpointAddress); goto skip_to_next_endpoint_or_interface_descriptor; diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c index 3e8efe759c3e..20dccf34182d 100644 --- a/drivers/usb/core/quirks.c +++ b/drivers/usb/core/quirks.c @@ -359,7 +359,7 @@ static const struct usb_device_id usb_quirk_list[] = { /* Sound Devices USBPre2 */ { USB_DEVICE(0x0926, 0x0202), .driver_info = - USB_QUIRK_ENDPOINT_BLACKLIST }, + USB_QUIRK_ENDPOINT_IGNORE }, /* Keytouch QWERTY Panel keyboard */ { USB_DEVICE(0x0926, 0x3333), .driver_info = @@ -493,24 +493,24 @@ static const struct usb_device_id usb_amd_resume_quirk_list[] = { }; /* - * Entries for blacklisted endpoints that should be ignored when parsing - * configuration descriptors. + * Entries for endpoints that should be ignored when parsing configuration + * descriptors. * - * Matched for devices with USB_QUIRK_ENDPOINT_BLACKLIST. + * Matched for devices with USB_QUIRK_ENDPOINT_IGNORE. */ -static const struct usb_device_id usb_endpoint_blacklist[] = { +static const struct usb_device_id usb_endpoint_ignore[] = { { USB_DEVICE_INTERFACE_NUMBER(0x0926, 0x0202, 1), .driver_info = 0x85 }, { } }; -bool usb_endpoint_is_blacklisted(struct usb_device *udev, - struct usb_host_interface *intf, - struct usb_endpoint_descriptor *epd) +bool usb_endpoint_is_ignored(struct usb_device *udev, + struct usb_host_interface *intf, + struct usb_endpoint_descriptor *epd) { const struct usb_device_id *id; unsigned int address; - for (id = usb_endpoint_blacklist; id->match_flags; ++id) { + for (id = usb_endpoint_ignore; id->match_flags; ++id) { if (!usb_match_device(udev, id)) continue; diff --git a/drivers/usb/core/usb.h b/drivers/usb/core/usb.h index 19e4c550bc73..98e7d1ee63dc 100644 --- a/drivers/usb/core/usb.h +++ b/drivers/usb/core/usb.h @@ -37,7 +37,7 @@ extern void usb_authorize_interface(struct usb_interface *); extern void usb_detect_quirks(struct usb_device *udev); extern void usb_detect_interface_quirks(struct usb_device *udev); extern void usb_release_quirk_list(void); -extern bool usb_endpoint_is_blacklisted(struct usb_device *udev, +extern bool usb_endpoint_is_ignored(struct usb_device *udev, struct usb_host_interface *intf, struct usb_endpoint_descriptor *epd); extern int usb_remove_device(struct usb_device *udev); diff --git a/include/linux/usb/quirks.h b/include/linux/usb/quirks.h index 22c1f579afe3..5e4c497f54d6 100644 --- a/include/linux/usb/quirks.h +++ b/include/linux/usb/quirks.h @@ -69,7 +69,7 @@ /* Hub needs extra delay after resetting its port. */ #define USB_QUIRK_HUB_SLOW_RESET BIT(14) -/* device has blacklisted endpoints */ -#define USB_QUIRK_ENDPOINT_BLACKLIST BIT(15) +/* device has endpoints that should be ignored */ +#define USB_QUIRK_ENDPOINT_IGNORE BIT(15) #endif /* __LINUX_USB_QUIRKS_H */ -- cgit v1.2.3-70-g09d2 From 9af54301b643eca4544970037409efc986a47a9c Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Thu, 18 Jun 2020 11:42:54 +0200 Subject: USB: rename USB OTG hub configuration option The USB OTG code has the ability to disable external hubs, but the configuration option for it is oddly named. Rename it to be more obvious as to what it does. Cc: Thomas Bogendoerfer Cc: Bin Liu Cc: Paul Cercueil Cc: Alan Stern Cc: Eugeniu Rosca Cc: Kai-Heng Feng Cc: David Heinzelmann Cc: "Lee, Chiasheng" Cc: Keiya Nobuta Cc: Hardik Gajjar Link: https://lore.kernel.org/r/20200618094300.1887727-3-gregkh@linuxfoundation.org Signed-off-by: Greg Kroah-Hartman --- arch/mips/configs/gcw0_defconfig | 2 +- drivers/usb/core/Kconfig | 2 +- drivers/usb/core/hub.c | 2 +- drivers/usb/musb/Kconfig | 2 +- drivers/usb/musb/musb_core.c | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) (limited to 'drivers/usb') diff --git a/arch/mips/configs/gcw0_defconfig b/arch/mips/configs/gcw0_defconfig index 48131cb47e66..4994749b9eaa 100644 --- a/arch/mips/configs/gcw0_defconfig +++ b/arch/mips/configs/gcw0_defconfig @@ -96,7 +96,7 @@ CONFIG_SND_SIMPLE_CARD=y CONFIG_USB_CONN_GPIO=y CONFIG_USB=y CONFIG_USB_OTG=y -CONFIG_USB_OTG_BLACKLIST_HUB=y +CONFIG_USB_OTG_DISABLE_EXTERNAL_HUB=y CONFIG_USB_OHCI_HCD=y CONFIG_USB_OHCI_HCD_PLATFORM=y CONFIG_USB_MUSB_HDRC=y diff --git a/drivers/usb/core/Kconfig b/drivers/usb/core/Kconfig index ecaacc8ed311..06bae55860e4 100644 --- a/drivers/usb/core/Kconfig +++ b/drivers/usb/core/Kconfig @@ -66,7 +66,7 @@ config USB_OTG_WHITELIST "Targeted Peripherals List". "Embedded Hosts" are likewise allowed to support only a limited number of peripherals. -config USB_OTG_BLACKLIST_HUB +config USB_OTG_DISABLE_EXTERNAL_HUB bool "Disable external hubs" depends on USB_OTG || EXPERT help diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index b1e14beaac5f..ab26ac0147f7 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -1834,7 +1834,7 @@ static int hub_probe(struct usb_interface *intf, const struct usb_device_id *id) return -E2BIG; } -#ifdef CONFIG_USB_OTG_BLACKLIST_HUB +#ifdef CONFIG_USB_OTG_DISABLE_EXTERNAL_HUB if (hdev->parent) { dev_warn(&intf->dev, "ignoring external hub\n"); return -ENODEV; diff --git a/drivers/usb/musb/Kconfig b/drivers/usb/musb/Kconfig index 3b0d1c20ebe6..8de143807c1a 100644 --- a/drivers/usb/musb/Kconfig +++ b/drivers/usb/musb/Kconfig @@ -113,7 +113,7 @@ config USB_MUSB_JZ4740 depends on OF depends on MIPS || COMPILE_TEST depends on USB_MUSB_GADGET - depends on USB=n || USB_OTG_BLACKLIST_HUB + depends on USB=n || USB_OTG_DISABLE_EXTERNAL_HUB select USB_ROLE_SWITCH config USB_MUSB_MEDIATEK diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c index 384a8039a7fd..5a56a03996b1 100644 --- a/drivers/usb/musb/musb_core.c +++ b/drivers/usb/musb/musb_core.c @@ -1637,8 +1637,8 @@ static int musb_core_init(u16 musb_type, struct musb *musb) musb->is_multipoint = 0; type = ""; if (IS_ENABLED(CONFIG_USB) && - !IS_ENABLED(CONFIG_USB_OTG_BLACKLIST_HUB)) { - pr_err("%s: kernel must blacklist external hubs\n", + !IS_ENABLED(CONFIG_USB_OTG_DISABLE_EXTERNAL_HUB)) { + pr_err("%s: kernel must disable external hubs, please fix the configuration\n", musb_driver_name); } } -- cgit v1.2.3-70-g09d2 From 8adbe334a15014ee69ae6841e599677f8d4253c4 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Thu, 18 Jun 2020 11:42:55 +0200 Subject: USB: OHCI: remove obsolete FIXME comment This comment has been present since the start of git. Since no one is going to do anything about it, and all seems to work well, just drop the thing entirely. Cc: Alan Stern Link: https://lore.kernel.org/r/20200618094300.1887727-4-gregkh@linuxfoundation.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/ohci-pci.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/host/ohci-pci.c b/drivers/usb/host/ohci-pci.c index 585222af24ff..41efe927d8f3 100644 --- a/drivers/usb/host/ohci-pci.c +++ b/drivers/usb/host/ohci-pci.c @@ -232,10 +232,6 @@ static const struct pci_device_id ohci_pci_quirks[] = { .driver_data = (unsigned long)ohci_quirk_qemu, }, - /* FIXME for some of the early AMD 760 southbridges, OHCI - * won't work at all. blacklist them. - */ - {}, }; -- cgit v1.2.3-70-g09d2 From 4a7375edf29c6e9a095e4fe674b28e536ae590de Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Thu, 18 Jun 2020 11:42:56 +0200 Subject: USB: serial: qcserial: fix up wording in a comment Better describe what is happening with a list of devices that are being ignored by the driver. Cc: Johan Hovold Link: https://lore.kernel.org/r/20200618094300.1887727-5-gregkh@linuxfoundation.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/serial/qcserial.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/serial/qcserial.c b/drivers/usb/serial/qcserial.c index d147feae83e6..5dfbbaef38bb 100644 --- a/drivers/usb/serial/qcserial.c +++ b/drivers/usb/serial/qcserial.c @@ -365,9 +365,8 @@ static int qcprobe(struct usb_serial *serial, const struct usb_device_id *id) * a specific function, while the subclass indicate a * specific firmware source * - * This is a blacklist of functions known to be - * non-serial. The rest are assumed to be serial and - * will be handled by this driver + * This is a list of functions known to be non-serial. The rest + * are assumed to be serial and will be handled by this driver */ switch (intf->desc.bInterfaceProtocol) { /* QMI combined (qmi_wwan) */ -- cgit v1.2.3-70-g09d2 From 66f092ed3b94de867a28f77d39bac53395b872e4 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Thu, 18 Jun 2020 11:42:57 +0200 Subject: USB: serial: sierra: unify quirk handling logic The sierra driver had two different functions for trying to determine different quirks that did the same exact thing. Remove one and rename things to make it more obvious exactly what the different lists do. Cc: Johan Hovold Link: https://lore.kernel.org/r/20200618094300.1887727-6-gregkh@linuxfoundation.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/serial/sierra.c | 57 +++++++++++++++------------------------------ 1 file changed, 19 insertions(+), 38 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/serial/sierra.c b/drivers/usb/serial/sierra.c index a43263a0edd8..e8b130157b57 100644 --- a/drivers/usb/serial/sierra.c +++ b/drivers/usb/serial/sierra.c @@ -45,9 +45,9 @@ static bool nmea; -/* Used in interface blacklisting */ -struct sierra_iface_info { - const u32 infolen; /* number of interface numbers on blacklist */ +/* Used in interface quirks */ +struct sierra_iface_quirk { + const u32 infolen; /* number of interface numbers on the list */ const u8 *ifaceinfo; /* pointer to the array holding the numbers */ }; @@ -101,33 +101,15 @@ static int sierra_calc_num_ports(struct usb_serial *serial, return num_ports; } -static int is_blacklisted(const u8 ifnum, - const struct sierra_iface_info *blacklist) +static int is_quirk(const u8 ifnum, const struct sierra_iface_quirk *quirk) { const u8 *info; int i; - if (blacklist) { - info = blacklist->ifaceinfo; + if (quirk) { + info = quirk->ifaceinfo; - for (i = 0; i < blacklist->infolen; i++) { - if (info[i] == ifnum) - return 1; - } - } - return 0; -} - -static int is_himemory(const u8 ifnum, - const struct sierra_iface_info *himemorylist) -{ - const u8 *info; - int i; - - if (himemorylist) { - info = himemorylist->ifaceinfo; - - for (i=0; i < himemorylist->infolen; i++) { + for (i = 0; i < quirk->infolen; i++) { if (info[i] == ifnum) return 1; } @@ -161,10 +143,9 @@ static int sierra_probe(struct usb_serial *serial, usb_set_interface(udev, ifnum, 1); } - if (is_blacklisted(ifnum, - (struct sierra_iface_info *)id->driver_info)) { + if (is_quirk(ifnum, (struct sierra_iface_quirk *)id->driver_info)) { dev_dbg(&serial->dev->dev, - "Ignoring blacklisted interface #%d\n", ifnum); + "Ignoring interface #%d\n", ifnum); return -ENODEV; } @@ -173,20 +154,20 @@ static int sierra_probe(struct usb_serial *serial, /* interfaces with higher memory requirements */ static const u8 hi_memory_typeA_ifaces[] = { 0, 2 }; -static const struct sierra_iface_info typeA_interface_list = { +static const struct sierra_iface_quirk typeA_interface_list = { .infolen = ARRAY_SIZE(hi_memory_typeA_ifaces), .ifaceinfo = hi_memory_typeA_ifaces, }; static const u8 hi_memory_typeB_ifaces[] = { 3, 4, 5, 6 }; -static const struct sierra_iface_info typeB_interface_list = { +static const struct sierra_iface_quirk typeB_interface_list = { .infolen = ARRAY_SIZE(hi_memory_typeB_ifaces), .ifaceinfo = hi_memory_typeB_ifaces, }; -/* 'blacklist' of interfaces not served by this driver */ +/* 'ignorelist' of interfaces not served by this driver */ static const u8 direct_ip_non_serial_ifaces[] = { 7, 8, 9, 10, 11, 19, 20 }; -static const struct sierra_iface_info direct_ip_interface_blacklist = { +static const struct sierra_iface_quirk direct_ip_interface_ignore = { .infolen = ARRAY_SIZE(direct_ip_non_serial_ifaces), .ifaceinfo = direct_ip_non_serial_ifaces, }; @@ -264,19 +245,19 @@ static const struct usb_device_id id_table[] = { { USB_DEVICE(0x1199, 0x6893) }, /* Sierra Wireless Device */ /* Sierra Wireless Direct IP modems */ { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x68A3, 0xFF, 0xFF, 0xFF), - .driver_info = (kernel_ulong_t)&direct_ip_interface_blacklist + .driver_info = (kernel_ulong_t)&direct_ip_interface_ignore }, { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x68AA, 0xFF, 0xFF, 0xFF), - .driver_info = (kernel_ulong_t)&direct_ip_interface_blacklist + .driver_info = (kernel_ulong_t)&direct_ip_interface_ignore }, { USB_DEVICE(0x1199, 0x68AB) }, /* Sierra Wireless AR8550 */ /* AT&T Direct IP LTE modems */ { USB_DEVICE_AND_INTERFACE_INFO(0x0F3D, 0x68AA, 0xFF, 0xFF, 0xFF), - .driver_info = (kernel_ulong_t)&direct_ip_interface_blacklist + .driver_info = (kernel_ulong_t)&direct_ip_interface_ignore }, /* Airprime/Sierra Wireless Direct IP modems */ { USB_DEVICE_AND_INTERFACE_INFO(0x0F3D, 0x68A3, 0xFF, 0xFF, 0xFF), - .driver_info = (kernel_ulong_t)&direct_ip_interface_blacklist + .driver_info = (kernel_ulong_t)&direct_ip_interface_ignore }, { } @@ -879,7 +860,7 @@ static int sierra_port_probe(struct usb_serial_port *port) { struct usb_serial *serial = port->serial; struct sierra_port_private *portdata; - const struct sierra_iface_info *himemoryp; + const struct sierra_iface_quirk *himemoryp; u8 ifnum; portdata = kzalloc(sizeof(*portdata), GFP_KERNEL); @@ -907,7 +888,7 @@ static int sierra_port_probe(struct usb_serial_port *port) himemoryp = &typeA_interface_list; } - if (is_himemory(ifnum, himemoryp)) { + if (is_quirk(ifnum, himemoryp)) { portdata->num_out_urbs = N_OUT_URB_HM; portdata->num_in_urbs = N_IN_URB_HM; } -- cgit v1.2.3-70-g09d2 From c83a74ed5f2220f9d5792471eda7d3b8378c9d59 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Thu, 18 Jun 2020 11:42:58 +0200 Subject: USB: storage: fix wording in error message Make it obvious that the UAS driver is being ignored for a specific device by fixing up the wording to be more clear. Cc: Alan Stern Link: https://lore.kernel.org/r/20200618094300.1887727-7-gregkh@linuxfoundation.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/storage/uas-detect.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/usb') diff --git a/drivers/usb/storage/uas-detect.h b/drivers/usb/storage/uas-detect.h index 3734a25e09e5..3f720faa6f97 100644 --- a/drivers/usb/storage/uas-detect.h +++ b/drivers/usb/storage/uas-detect.h @@ -120,7 +120,7 @@ static int uas_use_uas_driver(struct usb_interface *intf, if (flags & US_FL_IGNORE_UAS) { dev_warn(&udev->dev, - "UAS is blacklisted for this device, using usb-storage instead\n"); + "UAS is ignored for this device, using usb-storage instead\n"); return 0; } -- cgit v1.2.3-70-g09d2 From 19246d273e580037b1773b3eda4c713d5bf2f69c Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Thu, 18 Jun 2020 11:42:59 +0200 Subject: USB: storage: scsi: fix up comment to be more specific Fix up the wording in a comment for the scsi driver saying what it does using better terminology. Cc: Alan Stern Link: https://lore.kernel.org/r/20200618094300.1887727-8-gregkh@linuxfoundation.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/storage/scsiglue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/usb') diff --git a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c index f4c2359abb1b..e5a971b83e3f 100644 --- a/drivers/usb/storage/scsiglue.c +++ b/drivers/usb/storage/scsiglue.c @@ -298,7 +298,7 @@ static int slave_configure(struct scsi_device *sdev) } else { /* - * Non-disk-type devices don't need to blacklist any pages + * Non-disk-type devices don't need to ignore any pages * or to force 192-byte transfer lengths for MODE SENSE. * But they do need to use MODE SENSE(10). */ -- cgit v1.2.3-70-g09d2 From f8f02d5c671f79c4e80acbd0fca324566968cea8 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Thu, 18 Jun 2020 11:43:00 +0200 Subject: USB: OTG: rename product list of devices MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Rename the list of specific devices that an OTG device could support to make it more obvious as to what this list is for and what it is doing. Also rename the configuration option to make it more obvious as well. Cc: Thomas Bogendoerfer Cc: Paul Burton Cc: "Diego Elio Pettenò" Cc: "Martin K. Petersen" Cc: Jens Axboe Cc: Jiaxun Yang Cc: Krzysztof Kozlowski Cc: "Philippe Mathieu-Daudé" Cc: Alan Stern Cc: Eugeniu Rosca Cc: Qi Zhou Cc: Andrey Konovalov Cc: Hardik Gajjar Cc: Harry Pan Cc: David Heinzelmann Cc: Nishad Kamdar Link: https://lore.kernel.org/r/20200618094300.1887727-9-gregkh@linuxfoundation.org Signed-off-by: Greg Kroah-Hartman --- arch/mips/configs/fuloong2e_defconfig | 2 +- arch/mips/configs/lemote2f_defconfig | 2 +- drivers/usb/core/Kconfig | 6 +- drivers/usb/core/hub.c | 4 +- drivers/usb/core/otg_productlist.h | 102 ++++++++++++++++++++++++++++++++ drivers/usb/core/otg_whitelist.h | 106 ---------------------------------- 6 files changed, 109 insertions(+), 113 deletions(-) create mode 100644 drivers/usb/core/otg_productlist.h delete mode 100644 drivers/usb/core/otg_whitelist.h (limited to 'drivers/usb') diff --git a/arch/mips/configs/fuloong2e_defconfig b/arch/mips/configs/fuloong2e_defconfig index 6466e83067b4..023b4e644b1c 100644 --- a/arch/mips/configs/fuloong2e_defconfig +++ b/arch/mips/configs/fuloong2e_defconfig @@ -159,7 +159,7 @@ CONFIG_USB_KBD=y CONFIG_USB_MOUSE=y CONFIG_USB=y CONFIG_USB_ANNOUNCE_NEW_DEVICES=y -CONFIG_USB_OTG_WHITELIST=y +CONFIG_USB_OTG_PRODUCTLIST=y CONFIG_USB_WUSB_CBAF=m CONFIG_USB_C67X00_HCD=m CONFIG_USB_EHCI_HCD=y diff --git a/arch/mips/configs/lemote2f_defconfig b/arch/mips/configs/lemote2f_defconfig index 8254d7d1396f..3a9a453b1264 100644 --- a/arch/mips/configs/lemote2f_defconfig +++ b/arch/mips/configs/lemote2f_defconfig @@ -207,7 +207,7 @@ CONFIG_ZEROPLUS_FF=y CONFIG_USB_HIDDEV=y CONFIG_USB=y CONFIG_USB_DYNAMIC_MINORS=y -CONFIG_USB_OTG_WHITELIST=y +CONFIG_USB_OTG_PRODUCTLIST=y CONFIG_USB_MON=y CONFIG_USB_EHCI_HCD=y CONFIG_USB_EHCI_ROOT_HUB_TT=y diff --git a/drivers/usb/core/Kconfig b/drivers/usb/core/Kconfig index 06bae55860e4..dfacc478a8fc 100644 --- a/drivers/usb/core/Kconfig +++ b/drivers/usb/core/Kconfig @@ -55,12 +55,12 @@ config USB_OTG Select this only if your board has Mini-AB/Micro-AB connector. -config USB_OTG_WHITELIST +config USB_OTG_PRODUCTLIST bool "Rely on OTG and EH Targeted Peripherals List" depends on USB help - If you say Y here, the "otg_whitelist.h" file will be used as a - product whitelist, so USB peripherals not listed there will be + If you say Y here, the "otg_productlist.h" file will be used as a + product list, so USB peripherals not listed there will be rejected during enumeration. This behavior is required by the USB OTG and EH specification for all devices not on your product's "Targeted Peripherals List". "Embedded Hosts" are likewise diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index ab26ac0147f7..71bbd2eed7c6 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -35,7 +35,7 @@ #include #include "hub.h" -#include "otg_whitelist.h" +#include "otg_productlist.h" #define USB_VENDOR_GENESYS_LOGIC 0x05e3 #define USB_VENDOR_SMSC 0x0424 @@ -2403,7 +2403,7 @@ static int usb_enumerate_device(struct usb_device *udev) if (err < 0) return err; - if (IS_ENABLED(CONFIG_USB_OTG_WHITELIST) && hcd->tpl_support && + if (IS_ENABLED(CONFIG_USB_OTG_PRODUCTLIST) && hcd->tpl_support && !is_targeted(udev)) { /* Maybe it can talk to us, though we can't talk to it. * (Includes HNP test device.) diff --git a/drivers/usb/core/otg_productlist.h b/drivers/usb/core/otg_productlist.h new file mode 100644 index 000000000000..db67df29fb2b --- /dev/null +++ b/drivers/usb/core/otg_productlist.h @@ -0,0 +1,102 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* Copyright (C) 2004 Texas Instruments */ + +/* + * This OTG and Embedded Host list is "Targeted Peripheral List". + * It should mostly use of USB_DEVICE() or USB_DEVICE_VER() entries.. + * + * YOU _SHOULD_ CHANGE THIS LIST TO MATCH YOUR PRODUCT AND ITS TESTING! + */ + +static struct usb_device_id productlist_table[] = { + +/* hubs are optional in OTG, but very handy ... */ +{ USB_DEVICE_INFO(USB_CLASS_HUB, 0, 0), }, +{ USB_DEVICE_INFO(USB_CLASS_HUB, 0, 1), }, + +#ifdef CONFIG_USB_PRINTER /* ignoring nonstatic linkage! */ +/* FIXME actually, printers are NOT supposed to use device classes; + * they're supposed to use interface classes... + */ +{ USB_DEVICE_INFO(7, 1, 1) }, +{ USB_DEVICE_INFO(7, 1, 2) }, +{ USB_DEVICE_INFO(7, 1, 3) }, +#endif + +#ifdef CONFIG_USB_NET_CDCETHER +/* Linux-USB CDC Ethernet gadget */ +{ USB_DEVICE(0x0525, 0xa4a1), }, +/* Linux-USB CDC Ethernet + RNDIS gadget */ +{ USB_DEVICE(0x0525, 0xa4a2), }, +#endif + +#if IS_ENABLED(CONFIG_USB_TEST) +/* gadget zero, for testing */ +{ USB_DEVICE(0x0525, 0xa4a0), }, +#endif + +{ } /* Terminating entry */ +}; + +static int is_targeted(struct usb_device *dev) +{ + struct usb_device_id *id = productlist_table; + + /* HNP test device is _never_ targeted (see OTG spec 6.6.6) */ + if ((le16_to_cpu(dev->descriptor.idVendor) == 0x1a0a && + le16_to_cpu(dev->descriptor.idProduct) == 0xbadd)) + return 0; + + /* OTG PET device is always targeted (see OTG 2.0 ECN 6.4.2) */ + if ((le16_to_cpu(dev->descriptor.idVendor) == 0x1a0a && + le16_to_cpu(dev->descriptor.idProduct) == 0x0200)) + return 1; + + /* NOTE: can't use usb_match_id() since interface caches + * aren't set up yet. this is cut/paste from that code. + */ + for (id = productlist_table; id->match_flags; id++) { + if ((id->match_flags & USB_DEVICE_ID_MATCH_VENDOR) && + id->idVendor != le16_to_cpu(dev->descriptor.idVendor)) + continue; + + if ((id->match_flags & USB_DEVICE_ID_MATCH_PRODUCT) && + id->idProduct != le16_to_cpu(dev->descriptor.idProduct)) + continue; + + /* No need to test id->bcdDevice_lo != 0, since 0 is never + greater than any unsigned number. */ + if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_LO) && + (id->bcdDevice_lo > le16_to_cpu(dev->descriptor.bcdDevice))) + continue; + + if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_HI) && + (id->bcdDevice_hi < le16_to_cpu(dev->descriptor.bcdDevice))) + continue; + + if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_CLASS) && + (id->bDeviceClass != dev->descriptor.bDeviceClass)) + continue; + + if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_SUBCLASS) && + (id->bDeviceSubClass != dev->descriptor.bDeviceSubClass)) + continue; + + if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_PROTOCOL) && + (id->bDeviceProtocol != dev->descriptor.bDeviceProtocol)) + continue; + + return 1; + } + + /* add other match criteria here ... */ + + + /* OTG MESSAGE: report errors here, customize to match your product */ + dev_err(&dev->dev, "device v%04x p%04x is not supported\n", + le16_to_cpu(dev->descriptor.idVendor), + le16_to_cpu(dev->descriptor.idProduct)); + + return 0; +} + diff --git a/drivers/usb/core/otg_whitelist.h b/drivers/usb/core/otg_whitelist.h deleted file mode 100644 index fdd4897401e2..000000000000 --- a/drivers/usb/core/otg_whitelist.h +++ /dev/null @@ -1,106 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0+ */ -/* - * drivers/usb/core/otg_whitelist.h - * - * Copyright (C) 2004 Texas Instruments - */ - -/* - * This OTG and Embedded Host Whitelist is "Targeted Peripheral List". - * It should mostly use of USB_DEVICE() or USB_DEVICE_VER() entries.. - * - * YOU _SHOULD_ CHANGE THIS LIST TO MATCH YOUR PRODUCT AND ITS TESTING! - */ - -static struct usb_device_id whitelist_table[] = { - -/* hubs are optional in OTG, but very handy ... */ -{ USB_DEVICE_INFO(USB_CLASS_HUB, 0, 0), }, -{ USB_DEVICE_INFO(USB_CLASS_HUB, 0, 1), }, - -#ifdef CONFIG_USB_PRINTER /* ignoring nonstatic linkage! */ -/* FIXME actually, printers are NOT supposed to use device classes; - * they're supposed to use interface classes... - */ -{ USB_DEVICE_INFO(7, 1, 1) }, -{ USB_DEVICE_INFO(7, 1, 2) }, -{ USB_DEVICE_INFO(7, 1, 3) }, -#endif - -#ifdef CONFIG_USB_NET_CDCETHER -/* Linux-USB CDC Ethernet gadget */ -{ USB_DEVICE(0x0525, 0xa4a1), }, -/* Linux-USB CDC Ethernet + RNDIS gadget */ -{ USB_DEVICE(0x0525, 0xa4a2), }, -#endif - -#if IS_ENABLED(CONFIG_USB_TEST) -/* gadget zero, for testing */ -{ USB_DEVICE(0x0525, 0xa4a0), }, -#endif - -{ } /* Terminating entry */ -}; - -static int is_targeted(struct usb_device *dev) -{ - struct usb_device_id *id = whitelist_table; - - /* HNP test device is _never_ targeted (see OTG spec 6.6.6) */ - if ((le16_to_cpu(dev->descriptor.idVendor) == 0x1a0a && - le16_to_cpu(dev->descriptor.idProduct) == 0xbadd)) - return 0; - - /* OTG PET device is always targeted (see OTG 2.0 ECN 6.4.2) */ - if ((le16_to_cpu(dev->descriptor.idVendor) == 0x1a0a && - le16_to_cpu(dev->descriptor.idProduct) == 0x0200)) - return 1; - - /* NOTE: can't use usb_match_id() since interface caches - * aren't set up yet. this is cut/paste from that code. - */ - for (id = whitelist_table; id->match_flags; id++) { - if ((id->match_flags & USB_DEVICE_ID_MATCH_VENDOR) && - id->idVendor != le16_to_cpu(dev->descriptor.idVendor)) - continue; - - if ((id->match_flags & USB_DEVICE_ID_MATCH_PRODUCT) && - id->idProduct != le16_to_cpu(dev->descriptor.idProduct)) - continue; - - /* No need to test id->bcdDevice_lo != 0, since 0 is never - greater than any unsigned number. */ - if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_LO) && - (id->bcdDevice_lo > le16_to_cpu(dev->descriptor.bcdDevice))) - continue; - - if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_HI) && - (id->bcdDevice_hi < le16_to_cpu(dev->descriptor.bcdDevice))) - continue; - - if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_CLASS) && - (id->bDeviceClass != dev->descriptor.bDeviceClass)) - continue; - - if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_SUBCLASS) && - (id->bDeviceSubClass != dev->descriptor.bDeviceSubClass)) - continue; - - if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_PROTOCOL) && - (id->bDeviceProtocol != dev->descriptor.bDeviceProtocol)) - continue; - - return 1; - } - - /* add other match criteria here ... */ - - - /* OTG MESSAGE: report errors here, customize to match your product */ - dev_err(&dev->dev, "device v%04x p%04x is not supported\n", - le16_to_cpu(dev->descriptor.idVendor), - le16_to_cpu(dev->descriptor.idProduct)); - - return 0; -} - -- cgit v1.2.3-70-g09d2 From 62fb45d317c5fa08e4db093441835bb6f33acbd7 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Thu, 18 Jun 2020 16:42:06 +0200 Subject: USB: ch9: add "USB_" prefix in front of TEST defines For some reason, the TEST_ defines in the usb/ch9.h files did not have the USB_ prefix on it, making it a bit confusing when reading the file, as well as not the nicest thing to do in a uapi file. So fix that up and add the USB_ prefix on to them, and fix up all in-kernel usages. This included deleting the duplicate copy in the net2272.h file. Cc: Felipe Balbi Cc: Michal Simek Cc: Mathias Nyman Cc: Pawel Laszczak Cc: YueHaibing Cc: Nathan Chancellor Cc: Jason Yan Cc: Jia-Ju Bai Cc: Stephen Boyd Cc: Christophe JAILLET Cc: Arnd Bergmann Cc: Jules Irenge Cc: Alan Stern Cc: Thinh Nguyen Cc: Rob Gill Cc: Macpaul Lin Acked-by: Minas Harutyunyan Acked-by: Bin Liu Acked-by: Chunfeng Yun Acked-by: Peter Chen Link: https://lore.kernel.org/r/20200618144206.2655890-1-gregkh@linuxfoundation.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/cdns3/ep0.c | 8 ++++---- drivers/usb/chipidea/udc.c | 10 +++++----- drivers/usb/common/debug.c | 10 +++++----- drivers/usb/dwc2/debugfs.c | 20 ++++++++++---------- drivers/usb/dwc2/gadget.c | 10 +++++----- drivers/usb/dwc3/debugfs.c | 20 ++++++++++---------- drivers/usb/dwc3/ep0.c | 10 +++++----- drivers/usb/dwc3/gadget.c | 10 +++++----- drivers/usb/gadget/udc/bdc/bdc_ep.c | 10 +++++----- drivers/usb/gadget/udc/gr_udc.c | 4 ++-- drivers/usb/gadget/udc/mv_udc_core.c | 2 +- drivers/usb/gadget/udc/net2272.c | 2 +- drivers/usb/gadget/udc/net2272.h | 5 ----- drivers/usb/gadget/udc/udc-xilinx.c | 4 ++-- drivers/usb/host/xhci-hub.c | 7 ++++--- drivers/usb/misc/ehset.c | 8 ++++---- drivers/usb/mtu3/mtu3_gadget_ep0.c | 16 ++++++++-------- drivers/usb/musb/musb_gadget_ep0.c | 20 ++++++++------------ drivers/usb/musb/musb_virthub.c | 20 ++++++++++---------- include/uapi/linux/usb/ch9.h | 10 +++++----- 20 files changed, 99 insertions(+), 107 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/cdns3/ep0.c b/drivers/usb/cdns3/ep0.c index 82645a2a0f52..04a522f5ae58 100644 --- a/drivers/usb/cdns3/ep0.c +++ b/drivers/usb/cdns3/ep0.c @@ -328,10 +328,10 @@ static int cdns3_ep0_feature_handle_device(struct cdns3_device *priv_dev, return -EINVAL; switch (tmode >> 8) { - case TEST_J: - case TEST_K: - case TEST_SE0_NAK: - case TEST_PACKET: + case USB_TEST_J: + case USB_TEST_K: + case USB_TEST_SE0_NAK: + case USB_TEST_PACKET: cdns3_set_register_bit(&priv_dev->regs->usb_cmd, USB_CMD_STMODE | USB_STS_TMODE_SEL(tmode - 1)); diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c index db0cfde0cc3c..4beb25888917 100644 --- a/drivers/usb/chipidea/udc.c +++ b/drivers/usb/chipidea/udc.c @@ -1215,11 +1215,11 @@ __acquires(ci->lock) case USB_DEVICE_TEST_MODE: tmode = le16_to_cpu(req.wIndex) >> 8; switch (tmode) { - 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: ci->test_mode = tmode; err = isr_setup_status_phase( ci); diff --git a/drivers/usb/common/debug.c b/drivers/usb/common/debug.c index 92a986aeaa5d..410acd670ca7 100644 --- a/drivers/usb/common/debug.c +++ b/drivers/usb/common/debug.c @@ -53,15 +53,15 @@ static const char *usb_decode_device_feature(u16 wValue) static const char *usb_decode_test_mode(u16 wIndex) { switch (wIndex) { - case TEST_J: + case USB_TEST_J: return ": TEST_J"; - case TEST_K: + case USB_TEST_K: return ": TEST_K"; - case TEST_SE0_NAK: + case USB_TEST_SE0_NAK: return ": TEST_SE0_NAK"; - case TEST_PACKET: + case USB_TEST_PACKET: return ": TEST_PACKET"; - case TEST_FORCE_EN: + case USB_TEST_FORCE_ENABLE: return ": TEST_FORCE_EN"; default: return ": UNKNOWN"; diff --git a/drivers/usb/dwc2/debugfs.c b/drivers/usb/dwc2/debugfs.c index 3a0dcbfbc827..aaafd463d72a 100644 --- a/drivers/usb/dwc2/debugfs.c +++ b/drivers/usb/dwc2/debugfs.c @@ -37,15 +37,15 @@ static ssize_t testmode_write(struct file *file, const char __user *ubuf, size_t return -EFAULT; if (!strncmp(buf, "test_j", 6)) - testmode = TEST_J; + testmode = USB_TEST_J; else if (!strncmp(buf, "test_k", 6)) - testmode = TEST_K; + testmode = USB_TEST_K; else if (!strncmp(buf, "test_se0_nak", 12)) - testmode = TEST_SE0_NAK; + testmode = USB_TEST_SE0_NAK; else if (!strncmp(buf, "test_packet", 11)) - testmode = TEST_PACKET; + testmode = USB_TEST_PACKET; else if (!strncmp(buf, "test_force_enable", 17)) - testmode = TEST_FORCE_EN; + testmode = USB_TEST_FORCE_ENABLE; else testmode = 0; @@ -78,19 +78,19 @@ static int testmode_show(struct seq_file *s, void *unused) case 0: seq_puts(s, "no test\n"); break; - case TEST_J: + case USB_TEST_J: seq_puts(s, "test_j\n"); break; - case TEST_K: + case USB_TEST_K: seq_puts(s, "test_k\n"); break; - case TEST_SE0_NAK: + case USB_TEST_SE0_NAK: seq_puts(s, "test_se0_nak\n"); break; - case TEST_PACKET: + case USB_TEST_PACKET: seq_puts(s, "test_packet\n"); break; - case TEST_FORCE_EN: + case USB_TEST_FORCE_ENABLE: seq_puts(s, "test_force_enable\n"); break; default: diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index 12b98b466287..38fc46b0c026 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -1561,11 +1561,11 @@ int dwc2_hsotg_set_test_mode(struct dwc2_hsotg *hsotg, int testmode) dctl &= ~DCTL_TSTCTL_MASK; switch (testmode) { - 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: dctl |= testmode << DCTL_TSTCTL_SHIFT; break; default: diff --git a/drivers/usb/dwc3/debugfs.c b/drivers/usb/dwc3/debugfs.c index 6d9de334e46a..14dc6a37305d 100644 --- a/drivers/usb/dwc3/debugfs.c +++ b/drivers/usb/dwc3/debugfs.c @@ -466,19 +466,19 @@ static int dwc3_testmode_show(struct seq_file *s, void *unused) case 0: seq_printf(s, "no test\n"); break; - case TEST_J: + case USB_TEST_J: seq_printf(s, "test_j\n"); break; - case TEST_K: + case USB_TEST_K: seq_printf(s, "test_k\n"); break; - case TEST_SE0_NAK: + case USB_TEST_SE0_NAK: seq_printf(s, "test_se0_nak\n"); break; - case TEST_PACKET: + case USB_TEST_PACKET: seq_printf(s, "test_packet\n"); break; - case TEST_FORCE_EN: + case USB_TEST_FORCE_ENABLE: seq_printf(s, "test_force_enable\n"); break; default: @@ -506,15 +506,15 @@ static ssize_t dwc3_testmode_write(struct file *file, return -EFAULT; if (!strncmp(buf, "test_j", 6)) - testmode = TEST_J; + testmode = USB_TEST_J; else if (!strncmp(buf, "test_k", 6)) - testmode = TEST_K; + testmode = USB_TEST_K; else if (!strncmp(buf, "test_se0_nak", 12)) - testmode = TEST_SE0_NAK; + testmode = USB_TEST_SE0_NAK; else if (!strncmp(buf, "test_packet", 11)) - testmode = TEST_PACKET; + testmode = USB_TEST_PACKET; else if (!strncmp(buf, "test_force_enable", 17)) - testmode = TEST_FORCE_EN; + testmode = USB_TEST_FORCE_ENABLE; else testmode = 0; diff --git a/drivers/usb/dwc3/ep0.c b/drivers/usb/dwc3/ep0.c index 6dee4dabc0a4..8dd69728add3 100644 --- a/drivers/usb/dwc3/ep0.c +++ b/drivers/usb/dwc3/ep0.c @@ -425,11 +425,11 @@ static int dwc3_ep0_handle_test(struct dwc3 *dwc, enum usb_device_state state, return -EINVAL; switch (wIndex >> 8) { - 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: dwc->test_mode_nr = wIndex >> 8; dwc->test_mode = true; break; diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index 80c3ef134e41..0b59b2f1cf26 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -46,11 +46,11 @@ int dwc3_gadget_set_test_mode(struct dwc3 *dwc, int mode) reg &= ~DWC3_DCTL_TSTCTRL_MASK; switch (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: reg |= mode << 1; break; default: diff --git a/drivers/usb/gadget/udc/bdc/bdc_ep.c b/drivers/usb/gadget/udc/bdc/bdc_ep.c index d49c6dc1082d..ba250cf75bef 100644 --- a/drivers/usb/gadget/udc/bdc/bdc_ep.c +++ b/drivers/usb/gadget/udc/bdc/bdc_ep.c @@ -927,11 +927,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: diff --git a/drivers/usb/gadget/udc/gr_udc.c b/drivers/usb/gadget/udc/gr_udc.c index 7164ad9800f1..345e28d76709 100644 --- a/drivers/usb/gadget/udc/gr_udc.c +++ b/drivers/usb/gadget/udc/gr_udc.c @@ -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/mv_udc_core.c b/drivers/usb/gadget/udc/mv_udc_core.c index cafde053788b..69289717d856 100644 --- a/drivers/usb/gadget/udc/mv_udc_core.c +++ b/drivers/usb/gadget/udc/mv_udc_core.c @@ -1502,7 +1502,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..fbbe62513545 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)); 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/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; } diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c index f37316d2c8fa..073c54e42223 100644 --- a/drivers/usb/host/xhci-hub.c +++ b/drivers/usb/host/xhci-hub.c @@ -612,7 +612,7 @@ static void xhci_port_set_test_mode(struct xhci_hcd *xhci, temp |= test_mode << PORT_TEST_MODE_SHIFT; writel(temp, port->addr + PORTPMSC); xhci->test_mode = test_mode; - if (test_mode == TEST_FORCE_EN) + if (test_mode == USB_TEST_FORCE_ENABLE) xhci_start(xhci); } @@ -666,7 +666,7 @@ static int xhci_exit_test_mode(struct xhci_hcd *xhci) xhci_err(xhci, "Not in test mode, do nothing.\n"); return 0; } - if (xhci->test_mode == TEST_FORCE_EN && + if (xhci->test_mode == USB_TEST_FORCE_ENABLE && !(xhci->xhc_state & XHCI_STATE_HALTED)) { retval = xhci_halt(xhci); if (retval) @@ -1421,7 +1421,8 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, /* 4.19.6 Port Test Modes (USB2 Test Mode) */ if (hcd->speed != HCD_USB2) goto error; - if (test_mode > TEST_FORCE_EN || test_mode < TEST_J) + if (test_mode > USB_TEST_FORCE_ENABLE || + test_mode < USB_TEST_J) goto error; retval = xhci_enter_test_mode(xhci, test_mode, wIndex, &flags); diff --git a/drivers/usb/misc/ehset.c b/drivers/usb/misc/ehset.c index 7895d61e733b..2752e1f4f4d0 100644 --- a/drivers/usb/misc/ehset.c +++ b/drivers/usb/misc/ehset.c @@ -33,28 +33,28 @@ static int ehset_probe(struct usb_interface *intf, ret = usb_control_msg(hub_udev, usb_sndctrlpipe(hub_udev, 0), USB_REQ_SET_FEATURE, USB_RT_PORT, USB_PORT_FEAT_TEST, - (TEST_SE0_NAK << 8) | portnum, + (USB_TEST_SE0_NAK << 8) | portnum, NULL, 0, 1000); break; case TEST_J_PID: ret = usb_control_msg(hub_udev, usb_sndctrlpipe(hub_udev, 0), USB_REQ_SET_FEATURE, USB_RT_PORT, USB_PORT_FEAT_TEST, - (TEST_J << 8) | portnum, + (USB_TEST_J << 8) | portnum, NULL, 0, 1000); break; case TEST_K_PID: ret = usb_control_msg(hub_udev, usb_sndctrlpipe(hub_udev, 0), USB_REQ_SET_FEATURE, USB_RT_PORT, USB_PORT_FEAT_TEST, - (TEST_K << 8) | portnum, + (USB_TEST_K << 8) | portnum, NULL, 0, 1000); break; case TEST_PACKET_PID: ret = usb_control_msg(hub_udev, usb_sndctrlpipe(hub_udev, 0), USB_REQ_SET_FEATURE, USB_RT_PORT, USB_PORT_FEAT_TEST, - (TEST_PACKET << 8) | portnum, + (USB_TEST_PACKET << 8) | portnum, NULL, 0, 1000); break; case TEST_HS_HOST_PORT_SUSPEND_RESUME: diff --git a/drivers/usb/mtu3/mtu3_gadget_ep0.c b/drivers/usb/mtu3/mtu3_gadget_ep0.c index 2be182bd793a..563a0a2e970d 100644 --- a/drivers/usb/mtu3/mtu3_gadget_ep0.c +++ b/drivers/usb/mtu3/mtu3_gadget_ep0.c @@ -278,20 +278,20 @@ static int handle_test_mode(struct mtu3 *mtu, struct usb_ctrlrequest *setup) u32 value; switch (le16_to_cpu(setup->wIndex) >> 8) { - case TEST_J: - dev_dbg(mtu->dev, "TEST_J\n"); + case USB_TEST_J: + dev_dbg(mtu->dev, "USB_TEST_J\n"); mtu->test_mode_nr = TEST_J_MODE; break; - case TEST_K: - dev_dbg(mtu->dev, "TEST_K\n"); + case USB_TEST_K: + dev_dbg(mtu->dev, "USB_TEST_K\n"); mtu->test_mode_nr = TEST_K_MODE; break; - case TEST_SE0_NAK: - dev_dbg(mtu->dev, "TEST_SE0_NAK\n"); + case USB_TEST_SE0_NAK: + dev_dbg(mtu->dev, "USB_TEST_SE0_NAK\n"); mtu->test_mode_nr = TEST_SE0_NAK_MODE; break; - case TEST_PACKET: - dev_dbg(mtu->dev, "TEST_PACKET\n"); + case USB_TEST_PACKET: + dev_dbg(mtu->dev, "USB_TEST_PACKET\n"); mtu->test_mode_nr = TEST_PACKET_MODE; break; default: diff --git a/drivers/usb/musb/musb_gadget_ep0.c b/drivers/usb/musb/musb_gadget_ep0.c index 91a5027b5c1f..0ae3e0be043e 100644 --- a/drivers/usb/musb/musb_gadget_ep0.c +++ b/drivers/usb/musb/musb_gadget_ep0.c @@ -311,27 +311,23 @@ __acquires(musb->lock) goto stall; switch (ctrlrequest->wIndex >> 8) { - case 1: - pr_debug("TEST_J\n"); - /* TEST_J */ + case USB_TEST_J: + pr_debug("USB_TEST_J\n"); musb->test_mode_nr = MUSB_TEST_J; break; - case 2: - /* TEST_K */ - pr_debug("TEST_K\n"); + case USB_TEST_K: + pr_debug("USB_TEST_K\n"); musb->test_mode_nr = MUSB_TEST_K; break; - case 3: - /* TEST_SE0_NAK */ - pr_debug("TEST_SE0_NAK\n"); + case USB_TEST_SE0_NAK: + pr_debug("USB_TEST_SE0_NAK\n"); musb->test_mode_nr = MUSB_TEST_SE0_NAK; break; - case 4: - /* TEST_PACKET */ - pr_debug("TEST_PACKET\n"); + case USB_TEST_PACKET: + pr_debug("USB_TEST_PACKET\n"); musb->test_mode_nr = MUSB_TEST_PACKET; break; diff --git a/drivers/usb/musb/musb_virthub.c b/drivers/usb/musb/musb_virthub.c index a84ec27c4c12..cb7ae297a3af 100644 --- a/drivers/usb/musb/musb_virthub.c +++ b/drivers/usb/musb/musb_virthub.c @@ -385,25 +385,25 @@ int musb_hub_control( wIndex >>= 8; switch (wIndex) { - case 1: - pr_debug("TEST_J\n"); + case USB_TEST_J: + pr_debug("USB_TEST_J\n"); temp = MUSB_TEST_J; break; - case 2: - pr_debug("TEST_K\n"); + case USB_TEST_K: + pr_debug("USB_TEST_K\n"); temp = MUSB_TEST_K; break; - case 3: - pr_debug("TEST_SE0_NAK\n"); + case USB_TEST_SE0_NAK: + pr_debug("USB_TEST_SE0_NAK\n"); temp = MUSB_TEST_SE0_NAK; break; - case 4: - pr_debug("TEST_PACKET\n"); + case USB_TEST_PACKET: + pr_debug("USB_TEST_PACKET\n"); temp = MUSB_TEST_PACKET; musb_load_testpacket(musb); break; - case 5: - pr_debug("TEST_FORCE_ENABLE\n"); + case USB_TEST_FORCE_ENABLE: + pr_debug("USB_TEST_FORCE_ENABLE\n"); temp = MUSB_TEST_FORCE_HOST | MUSB_TEST_FORCE_HS; diff --git a/include/uapi/linux/usb/ch9.h b/include/uapi/linux/usb/ch9.h index b1ed2ccfe9cf..48766fdf6580 100644 --- a/include/uapi/linux/usb/ch9.h +++ b/include/uapi/linux/usb/ch9.h @@ -138,11 +138,11 @@ * Test Mode Selectors * See USB 2.0 spec Table 9-7 */ -#define TEST_J 1 -#define TEST_K 2 -#define TEST_SE0_NAK 3 -#define TEST_PACKET 4 -#define TEST_FORCE_EN 5 +#define USB_TEST_J 1 +#define USB_TEST_K 2 +#define USB_TEST_SE0_NAK 3 +#define USB_TEST_PACKET 4 +#define USB_TEST_FORCE_ENABLE 5 /* Status Type */ #define USB_STATUS_TYPE_STANDARD 0 -- cgit v1.2.3-70-g09d2 From b3a5ce874c2619c9b8a6c5bbcfefdb95e0227600 Mon Sep 17 00:00:00 2001 From: Nicolas Boichat Date: Sat, 27 Jun 2020 15:03:04 +0800 Subject: usb: cdns3: gadget: Replace trace_printk by dev_dbg trace_printk should not be used in production code, replace it call with dev_dbg. Signed-off-by: Nicolas Boichat Link: https://lore.kernel.org/r/20200627070307.516803-2-drinkcat@chromium.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/cdns3/gadget.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/usb') diff --git a/drivers/usb/cdns3/gadget.c b/drivers/usb/cdns3/gadget.c index 5e24c2e57c0d..c303ab7c62d1 100644 --- a/drivers/usb/cdns3/gadget.c +++ b/drivers/usb/cdns3/gadget.c @@ -421,7 +421,7 @@ static int cdns3_start_all_request(struct cdns3_device *priv_dev, if ((priv_req->flags & REQUEST_INTERNAL) || (priv_ep->flags & EP_TDLCHK_EN) || priv_ep->use_streams) { - trace_printk("Blocking external request\n"); + dev_dbg(priv_dev->dev, "Blocking external request\n"); return ret; } } -- cgit v1.2.3-70-g09d2 From 2c509d1cc86dfe8eb70042a055dc039cbe850cf7 Mon Sep 17 00:00:00 2001 From: Michael Hanselmann Date: Wed, 27 May 2020 22:59:53 +0200 Subject: USB: serial: ch341: name prescaler, divisor registers Add constants for the prescaler and divisor registers. Document and name register 0x25, and put the LCR define to more use. The 0x25 register (CH341_REG_LCR2) is only used by CH341 chips before version 0x30 and is involved in configuring the line control parameters. It's not known to the author whether there any such chips in the wild, and Linux' ch341 driver never supported them. For chip version 0x30 and above the 0x25 register is always set to zero. The alternative would've been to not set the register at all, but that may have unintended effects. Signed-off-by: Michael Hanselmann Link: https://lore.kernel.org/r/2e80916d-1be8-dc0f-abf9-adc0feea1803@msgid.hansmi.ch [ johan: fix up comment ] Signed-off-by: Johan Hovold --- drivers/usb/serial/ch341.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/serial/ch341.c b/drivers/usb/serial/ch341.c index 89675ee29645..684d595e7630 100644 --- a/drivers/usb/serial/ch341.c +++ b/drivers/usb/serial/ch341.c @@ -59,7 +59,11 @@ #define CH341_REQ_MODEM_CTRL 0xA4 #define CH341_REG_BREAK 0x05 +#define CH341_REG_PRESCALER 0x12 +#define CH341_REG_DIVISOR 0x13 #define CH341_REG_LCR 0x18 +#define CH341_REG_LCR2 0x25 + #define CH341_NBREAK_BITS 0x01 #define CH341_LCR_ENABLE_RX 0x80 @@ -246,11 +250,20 @@ static int ch341_set_baudrate_lcr(struct usb_device *dev, */ val |= BIT(7); - r = ch341_control_out(dev, CH341_REQ_WRITE_REG, 0x1312, val); + r = ch341_control_out(dev, CH341_REQ_WRITE_REG, + CH341_REG_DIVISOR << 8 | CH341_REG_PRESCALER, + val); if (r) return r; - r = ch341_control_out(dev, CH341_REQ_WRITE_REG, 0x2518, lcr); + /* + * Chip versions before version 0x30 as read using + * CH341_REQ_READ_VERSION used separate registers for line control + * (stop bits, parity and word length). Version 0x30 and above use + * CH341_REG_LCR only and CH341_REG_LCR2 is always set to zero. + */ + r = ch341_control_out(dev, CH341_REQ_WRITE_REG, + CH341_REG_LCR2 << 8 | CH341_REG_LCR, lcr); if (r) return r; -- cgit v1.2.3-70-g09d2 From 86f6da2951db571255ea0b1af7c6115ab870b757 Mon Sep 17 00:00:00 2001 From: Johan Hovold Date: Tue, 30 Jun 2020 11:57:56 +0200 Subject: USB: serial: ch341: add min and max line-speed macros The line-speed algorithm clamps the requested value to the supported range instead of bailing out on unsupported values. Provide min and max macros and indicate how they are derived instead of hardcoding the limits. Note that the algorithm depends on the minimum rate (45.78 bps) being rounded up (and the maximum rate being rounded down) to avoid special casing. Suggested-by: Michael Hanselmann Link: https://lore.kernel.org/r/20200630095756.GZ3334@localhost Signed-off-by: Johan Hovold --- drivers/usb/serial/ch341.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'drivers/usb') diff --git a/drivers/usb/serial/ch341.c b/drivers/usb/serial/ch341.c index 684d595e7630..55a1c6dbeeb2 100644 --- a/drivers/usb/serial/ch341.c +++ b/drivers/usb/serial/ch341.c @@ -156,6 +156,10 @@ static const speed_t ch341_min_rates[] = { CH341_MIN_RATE(3), }; +/* Supported range is 46 to 3000000 bps. */ +#define CH341_MIN_BPS DIV_ROUND_UP(CH341_CLKRATE, CH341_CLK_DIV(0, 0) * 256) +#define CH341_MAX_BPS (CH341_CLKRATE / (CH341_CLK_DIV(3, 0) * 2)) + /* * The device line speed is given by the following equation: * @@ -177,7 +181,7 @@ static int ch341_get_divisor(struct ch341_private *priv) * Clamp to supported range, this makes the (ps < 0) and (div < 2) * sanity checks below redundant. */ - speed = clamp(speed, 46U, 3000000U); + speed = clamp_val(speed, CH341_MIN_BPS, CH341_MAX_BPS); /* * Start with highest possible base clock (fact = 1) that will give a -- cgit v1.2.3-70-g09d2 From 8a58264128d51b8304f800fc34dc184ea9d9bd2a Mon Sep 17 00:00:00 2001 From: Peter Chen Date: Tue, 23 Jun 2020 11:09:59 +0800 Subject: usb: cdns3: ep0: delete the duplicate code The value '0' is duplicated with USB_DIR_OUT Signed-off-by: Peter Chen Acked-by: Roger Quadros Link: https://lore.kernel.org/r/20200623031001.8469-2-peter.chen@nxp.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/cdns3/ep0.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/usb') diff --git a/drivers/usb/cdns3/ep0.c b/drivers/usb/cdns3/ep0.c index 4bca730f6876..cdf09c09b486 100644 --- a/drivers/usb/cdns3/ep0.c +++ b/drivers/usb/cdns3/ep0.c @@ -610,7 +610,7 @@ static bool cdns3_check_new_setup(struct cdns3_device *priv_dev) { u32 ep_sts_reg; - cdns3_select_ep(priv_dev, 0 | USB_DIR_OUT); + cdns3_select_ep(priv_dev, USB_DIR_OUT); ep_sts_reg = readl(&priv_dev->regs->ep_sts); return !!(ep_sts_reg & (EP_STS_SETUP | EP_STS_STPWAIT)); -- cgit v1.2.3-70-g09d2 From 8685c46d39910a6335cf120d2d2a5295ec0a60a5 Mon Sep 17 00:00:00 2001 From: Peter Chen Date: Tue, 23 Jun 2020 11:10:00 +0800 Subject: usb: cdns3: gadget: unsigned int is dereferenced as a wider unsigned long It is reported by Coverity scan, and fixed it by declare the reg as unsigned long. Reviewed-by: Jun Li Signed-off-by: Peter Chen Acked-by: Roger Quadros Link: https://lore.kernel.org/r/20200623031001.8469-3-peter.chen@nxp.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/cdns3/gadget.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/cdns3/gadget.c b/drivers/usb/cdns3/gadget.c index c303ab7c62d1..bed7ee7e9880 100644 --- a/drivers/usb/cdns3/gadget.c +++ b/drivers/usb/cdns3/gadget.c @@ -1810,7 +1810,7 @@ static irqreturn_t cdns3_device_thread_irq_handler(int irq, void *data) irqreturn_t ret = IRQ_NONE; unsigned long flags; int bit; - u32 reg; + unsigned long reg; spin_lock_irqsave(&priv_dev->lock, flags); @@ -1841,7 +1841,7 @@ static irqreturn_t cdns3_device_thread_irq_handler(int irq, void *data) if (!reg) goto irqend; - for_each_set_bit(bit, (unsigned long *)®, + for_each_set_bit(bit, ®, sizeof(u32) * BITS_PER_BYTE) { cdns3_check_ep_interrupt_proceed(priv_dev->eps[bit]); ret = IRQ_HANDLED; -- cgit v1.2.3-70-g09d2 From 06825ca0182cec9444fb2fd05e759757f30f4b37 Mon Sep 17 00:00:00 2001 From: Peter Chen Date: Tue, 23 Jun 2020 11:10:01 +0800 Subject: usb: cdns3: gadget: use unsigned int for 32-bit number If it is 'int', it can't stands for the highest bit for 32-bit number, since the largest 'int' is 0x7fffffff. Reviewed-by: Jun Li Signed-off-by: Peter Chen Acked-by: Roger Quadros Link: https://lore.kernel.org/r/20200623031001.8469-4-peter.chen@nxp.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/cdns3/gadget.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/usb') diff --git a/drivers/usb/cdns3/gadget.c b/drivers/usb/cdns3/gadget.c index bed7ee7e9880..7c2913bc8bd7 100644 --- a/drivers/usb/cdns3/gadget.c +++ b/drivers/usb/cdns3/gadget.c @@ -1809,7 +1809,7 @@ static irqreturn_t cdns3_device_thread_irq_handler(int irq, void *data) struct cdns3_device *priv_dev = data; irqreturn_t ret = IRQ_NONE; unsigned long flags; - int bit; + unsigned int bit; unsigned long reg; spin_lock_irqsave(&priv_dev->lock, flags); -- cgit v1.2.3-70-g09d2 From b9b70170db4d682049040608369e5103f43289d3 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Tue, 30 Jun 2020 19:41:23 +0200 Subject: USB: Fix up terminology USB is a HOST/DEVICE protocol, as per the specification and all documentation. Fix up terms that are not applicable to make things match up with the terms used through the rest of the USB stack. Signed-off-by: Greg Kroah-Hartman Acked-by: Felipe Balbi Link: https://lore.kernel.org/r/20200630174123.GA1906678@kroah.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/core/usb.c | 5 ++--- drivers/usb/dwc2/core.h | 2 +- drivers/usb/gadget/Kconfig | 4 ++-- drivers/usb/gadget/legacy/zero.c | 4 ++-- drivers/usb/gadget/udc/Kconfig | 2 +- drivers/usb/gadget/udc/bcm63xx_udc.c | 16 ++++++++-------- drivers/usb/gadget/udc/core.c | 2 +- drivers/usb/gadget/udc/dummy_hcd.c | 20 ++++++++++---------- drivers/usb/serial/ftdi_sio.h | 4 ++-- 9 files changed, 29 insertions(+), 30 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c index f16c26dc079d..bafc113f2b3e 100644 --- a/drivers/usb/core/usb.c +++ b/drivers/usb/core/usb.c @@ -19,9 +19,8 @@ * just a collection of helper routines that implement the * generic USB things that the real drivers can use.. * - * Think of this as a "USB library" rather than anything else. - * It should be considered a slave, with no callbacks. Callbacks - * are evil. + * Think of this as a "USB library" rather than anything else, + * with no callbacks. Callbacks are evil. */ #include diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h index 132d687f1590..9deff0400a92 100644 --- a/drivers/usb/dwc2/core.h +++ b/drivers/usb/dwc2/core.h @@ -1036,7 +1036,7 @@ struct dwc2_hregs_backup { * @fifo_mem: Total internal RAM for FIFOs (bytes) * @fifo_map: Each bit intend for concrete fifo. If that bit is set, * then that fifo is used - * @gadget: Represents a usb slave device + * @gadget: Represents a usb gadget device * @connected: Used in slave mode. True if device connected with host * @eps_in: The IN endpoints being supplied to the gadget framework * @eps_out: The OUT endpoints being supplied to the gadget framework diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig index c6db0a0a340c..7e47e6223089 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig @@ -19,8 +19,8 @@ menuconfig USB_GADGET select USB_COMMON select NLS help - USB is a master/slave protocol, organized with one master - host (such as a PC) controlling up to 127 peripheral devices. + USB is a host/device protocol, organized with one host (such as a + PC) controlling up to 127 peripheral devices. The USB hardware is asymmetric, which makes it easier to set up: you can't connect a "to-the-host" connector to a peripheral. diff --git a/drivers/usb/gadget/legacy/zero.c b/drivers/usb/gadget/legacy/zero.c index 6e84b44c8a3b..23312a07efb4 100644 --- a/drivers/usb/gadget/legacy/zero.c +++ b/drivers/usb/gadget/legacy/zero.c @@ -11,8 +11,8 @@ * can write a hardware-agnostic gadget driver running inside a USB device. * Some hardware details are visible, but don't affect most of the driver. * - * Use it with the Linux host/master side "usbtest" driver to get a basic - * functional test of your device-side usb stack, or with "usb-skeleton". + * Use it with the Linux host side "usbtest" driver to get a basic functional + * test of your device-side usb stack, or with "usb-skeleton". * * It supports two similar configurations. One sinks whatever the usb host * writes, and in return sources zeroes. The other loops whatever the host 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/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/core.c b/drivers/usb/gadget/udc/core.c index 2e28dde8376f..ee226ad802a4 100644 --- a/drivers/usb/gadget/udc/core.c +++ b/drivers/usb/gadget/udc/core.c @@ -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. * diff --git a/drivers/usb/gadget/udc/dummy_hcd.c b/drivers/usb/gadget/udc/dummy_hcd.c index 0eeaead5acea..425a97926590 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 @@ -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 @@ -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/serial/ftdi_sio.h b/drivers/usb/serial/ftdi_sio.h index a79a1325b4d9..be1641e0408b 100644 --- a/drivers/usb/serial/ftdi_sio.h +++ b/drivers/usb/serial/ftdi_sio.h @@ -302,7 +302,7 @@ enum ftdi_sio_baudrate { /* * FTDI_SIO_GET_LATENCY_TIMER * - * Set the timeout interval. The FTDI collects data from the slave + * Set the timeout interval. The FTDI collects data from the * device, transmitting it to the host when either A) 62 bytes are * received, or B) the timeout interval has elapsed and the buffer * contains at least 1 byte. Setting this value to a small number @@ -324,7 +324,7 @@ enum ftdi_sio_baudrate { /* * FTDI_SIO_SET_LATENCY_TIMER * - * Set the timeout interval. The FTDI collects data from the slave + * Set the timeout interval. The FTDI collects data from the * device, transmitting it to the host when either A) 62 bytes are * received, or B) the timeout interval has elapsed and the buffer * contains at least 1 byte. Setting this value to a small number -- cgit v1.2.3-70-g09d2 From b7404a29cd3db0bf9537addf36b0fa33b58a645a Mon Sep 17 00:00:00 2001 From: Heikki Krogerus Date: Wed, 1 Jul 2020 14:56:17 +0300 Subject: usb: typec: intel_pmc_mux: Definitions for response status bits Adding definitions for the two status bits that we have in the command response data structure. Also, from now on only considering the second status bit, which tells was the failure fatal or not, if the first bit is set. If the first bit is not set, then the command was successful, and we need to ignore the second bit. Signed-off-by: Heikki Krogerus Link: https://lore.kernel.org/r/20200701115618.22482-4-heikki.krogerus@linux.intel.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/typec/mux/intel_pmc_mux.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/typec/mux/intel_pmc_mux.c b/drivers/usb/typec/mux/intel_pmc_mux.c index 70ddc9d6d49e..31fa62f968fb 100644 --- a/drivers/usb/typec/mux/intel_pmc_mux.c +++ b/drivers/usb/typec/mux/intel_pmc_mux.c @@ -19,6 +19,10 @@ #define PMC_USBC_CMD 0xa7 +/* Response status bits */ +#define PMC_USB_RESP_STATUS_FAILURE BIT(0) +#define PMC_USB_RESP_STATUS_FATAL BIT(1) + /* "Usage" OOB Message field values */ enum { PMC_USB_CONNECT, @@ -130,8 +134,8 @@ static int pmc_usb_command(struct pmc_usb_port *port, u8 *msg, u32 len) */ intel_scu_ipc_dev_command(port->pmc->ipc, PMC_USBC_CMD, 0, msg, len, response, sizeof(response)); - if (response[2]) { - if (response[2] & BIT(1)) + if (response[2] & PMC_USB_RESP_STATUS_FAILURE) { + if (response[2] & PMC_USB_RESP_STATUS_FATAL) return -EIO; return -EBUSY; } -- cgit v1.2.3-70-g09d2 From f3c1c41ebc67f0954fb47cec512ab23519223634 Mon Sep 17 00:00:00 2001 From: Heikki Krogerus Date: Wed, 1 Jul 2020 14:56:18 +0300 Subject: usb: typec: intel_pmc_mux: Add support for USB4 The PMC mux-agent can be used also to enter USB4 mode. The mux-agent does not have USB4 specific message, but it can be put into the TBT3 alternate mode also with USB4. That is OK because the controller is in any case the same with TBT3 and USB4. Signed-off-by: Heikki Krogerus Link: https://lore.kernel.org/r/20200701115618.22482-5-heikki.krogerus@linux.intel.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/typec/mux/intel_pmc_mux.c | 67 ++++++++++++++++++++++++++++++----- 1 file changed, 58 insertions(+), 9 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/typec/mux/intel_pmc_mux.c b/drivers/usb/typec/mux/intel_pmc_mux.c index 31fa62f968fb..2aba07c7b221 100644 --- a/drivers/usb/typec/mux/intel_pmc_mux.c +++ b/drivers/usb/typec/mux/intel_pmc_mux.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -231,6 +232,43 @@ pmc_usb_mux_tbt(struct pmc_usb_port *port, struct typec_mux_state *state) return pmc_usb_command(port, (void *)&req, sizeof(req)); } +static int +pmc_usb_mux_usb4(struct pmc_usb_port *port, struct typec_mux_state *state) +{ + struct enter_usb_data *data = state->data; + struct altmode_req req = { }; + u8 cable_speed; + + req.usage = PMC_USB_ALT_MODE; + req.usage |= port->usb3_port << PMC_USB_MSG_USB3_PORT_SHIFT; + req.mode_type = PMC_USB_MODE_TYPE_TBT << PMC_USB_MODE_TYPE_SHIFT; + + /* USB4 Mode */ + req.mode_data = PMC_USB_ALTMODE_FORCE_LSR; + + if (data->active_link_training) + req.mode_data |= PMC_USB_ALTMODE_ACTIVE_LINK; + + req.mode_data |= (port->orientation - 1) << PMC_USB_ALTMODE_ORI_SHIFT; + req.mode_data |= (port->role - 1) << PMC_USB_ALTMODE_UFP_SHIFT; + + switch ((data->eudo & EUDO_CABLE_TYPE_MASK) >> EUDO_CABLE_TYPE_SHIFT) { + case EUDO_CABLE_TYPE_PASSIVE: + break; + case EUDO_CABLE_TYPE_OPTICAL: + req.mode_data |= PMC_USB_ALTMODE_CABLE_TYPE; + fallthrough; + default: + req.mode_data |= PMC_USB_ALTMODE_ACTIVE_CABLE; + break; + } + + cable_speed = (data->eudo & EUDO_CABLE_SPEED_MASK) >> EUDO_CABLE_SPEED_SHIFT; + req.mode_data |= PMC_USB_ALTMODE_CABLE_SPD(cable_speed); + + return pmc_usb_command(port, (void *)&req, sizeof(req)); +} + static int pmc_usb_mux_safe_state(struct pmc_usb_port *port) { u8 msg; @@ -272,17 +310,28 @@ pmc_usb_mux_set(struct typec_mux *mux, struct typec_mux_state *state) { struct pmc_usb_port *port = typec_mux_get_drvdata(mux); - if (!state->alt) - return 0; - if (state->mode == TYPEC_STATE_SAFE) return pmc_usb_mux_safe_state(port); - - switch (state->alt->svid) { - case USB_TYPEC_TBT_SID: - return pmc_usb_mux_tbt(port, state); - case USB_TYPEC_DP_SID: - return pmc_usb_mux_dp(port, state); + if (state->mode == TYPEC_STATE_USB) + return pmc_usb_connect(port); + + if (state->alt) { + switch (state->alt->svid) { + case USB_TYPEC_TBT_SID: + return pmc_usb_mux_tbt(port, state); + case USB_TYPEC_DP_SID: + return pmc_usb_mux_dp(port, state); + } + } else { + switch (state->mode) { + case TYPEC_MODE_USB2: + /* REVISIT: Try with usb3_port set to 0? */ + break; + case TYPEC_MODE_USB3: + return pmc_usb_connect(port); + case TYPEC_MODE_USB4: + return pmc_usb_mux_usb4(port, state); + } } return -EOPNOTSUPP; -- cgit v1.2.3-70-g09d2 From 00b22b61b78fbf159c6b9119e7e79f22b1583d19 Mon Sep 17 00:00:00 2001 From: Johan Hovold Date: Wed, 1 Jul 2020 18:53:38 +0200 Subject: USB: serial: garmin_gps: don't compile unused packet definitions Don't compile the four unused packet definitions but keep them around for documentation purposes. This avoids the corresponding W=1 (-Wunused-const-variable) warning. Reviewed-by: Greg Kroah-Hartman Signed-off-by: Johan Hovold --- drivers/usb/serial/garmin_gps.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/serial/garmin_gps.c b/drivers/usb/serial/garmin_gps.c index d63072fee099..c02c19bb1183 100644 --- a/drivers/usb/serial/garmin_gps.c +++ b/drivers/usb/serial/garmin_gps.c @@ -179,19 +179,22 @@ static unsigned char const GARMIN_START_SESSION_REPLY[] = { 0, 0, 0, 0, 6, 0, 0, 0, 4, 0, 0, 0 }; static unsigned char const GARMIN_BULK_IN_AVAIL_REPLY[] = { 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0 }; +static unsigned char const GARMIN_STOP_TRANSFER_REQ[] + = { 20, 0, 0, 0, 10, 0, 0, 0, 2, 0, 0, 0, 0, 0 }; +static unsigned char const GARMIN_STOP_TRANSFER_REQ_V2[] + = { 20, 0, 0, 0, 10, 0, 0, 0, 1, 0, 0, 0, 0 }; + +/* packets currently unused, left as documentation */ +#if 0 static unsigned char const GARMIN_APP_LAYER_REPLY[] = { 0x14, 0, 0, 0 }; static unsigned char const GARMIN_START_PVT_REQ[] = { 20, 0, 0, 0, 10, 0, 0, 0, 2, 0, 0, 0, 49, 0 }; static unsigned char const GARMIN_STOP_PVT_REQ[] = { 20, 0, 0, 0, 10, 0, 0, 0, 2, 0, 0, 0, 50, 0 }; -static unsigned char const GARMIN_STOP_TRANSFER_REQ[] - = { 20, 0, 0, 0, 10, 0, 0, 0, 2, 0, 0, 0, 0, 0 }; -static unsigned char const GARMIN_STOP_TRANSFER_REQ_V2[] - = { 20, 0, 0, 0, 10, 0, 0, 0, 1, 0, 0, 0, 0 }; static unsigned char const PRIVATE_REQ[] = { 0x4B, 0x6E, 0x10, 0x01, 0xFF, 0, 0, 0, 0xFF, 0, 0, 0 }; - +#endif static const struct usb_device_id id_table[] = { -- cgit v1.2.3-70-g09d2 From 21c2ddc1a91f87aca6465756ee6061158d591b47 Mon Sep 17 00:00:00 2001 From: Johan Hovold Date: Wed, 1 Jul 2020 18:53:39 +0200 Subject: USB: serial: iuu_phoenix: drop unused URB submission results The driver is submitting URBs in various completion callbacks without bothering to log errors yet still assigned the return value to temporary variables. Let's drop those temporaries. This suppresses the corresponding W=1 (-Wunused-but-set-variable) warnings. Reviewed-by: Greg Kroah-Hartman Signed-off-by: Johan Hovold --- drivers/usb/serial/iuu_phoenix.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/serial/iuu_phoenix.c b/drivers/usb/serial/iuu_phoenix.c index d5bff69b1769..6336616fee49 100644 --- a/drivers/usb/serial/iuu_phoenix.c +++ b/drivers/usb/serial/iuu_phoenix.c @@ -158,7 +158,6 @@ static int iuu_tiocmget(struct tty_struct *tty) static void iuu_rxcmd(struct urb *urb) { struct usb_serial_port *port = urb->context; - int result; int status = urb->status; if (status) { @@ -174,7 +173,7 @@ static void iuu_rxcmd(struct urb *urb) port->bulk_out_endpointAddress), port->write_urb->transfer_buffer, 1, read_rxcmd_callback, port); - result = usb_submit_urb(port->write_urb, GFP_ATOMIC); + usb_submit_urb(port->write_urb, GFP_ATOMIC); } static int iuu_reset(struct usb_serial_port *port, u8 wt) @@ -241,7 +240,6 @@ static void iuu_update_status_callback(struct urb *urb) static void iuu_status_callback(struct urb *urb) { struct usb_serial_port *port = urb->context; - int result; int status = urb->status; dev_dbg(&port->dev, "%s - status = %d\n", __func__, status); @@ -250,7 +248,7 @@ static void iuu_status_callback(struct urb *urb) port->bulk_in_endpointAddress), port->read_urb->transfer_buffer, 256, iuu_update_status_callback, port); - result = usb_submit_urb(port->read_urb, GFP_ATOMIC); + usb_submit_urb(port->read_urb, GFP_ATOMIC); } static int iuu_status(struct usb_serial_port *port) @@ -351,7 +349,6 @@ static void iuu_rgbf_fill_buffer(u8 *buf, u8 r1, u8 r2, u8 g1, u8 g2, u8 b1, static void iuu_led_activity_on(struct urb *urb) { struct usb_serial_port *port = urb->context; - int result; char *buf_ptr = port->write_urb->transfer_buffer; *buf_ptr++ = IUU_SET_LED; if (xmas) { @@ -366,13 +363,12 @@ static void iuu_led_activity_on(struct urb *urb) port->bulk_out_endpointAddress), port->write_urb->transfer_buffer, 8 , iuu_rxcmd, port); - result = usb_submit_urb(port->write_urb, GFP_ATOMIC); + usb_submit_urb(port->write_urb, GFP_ATOMIC); } static void iuu_led_activity_off(struct urb *urb) { struct usb_serial_port *port = urb->context; - int result; char *buf_ptr = port->write_urb->transfer_buffer; if (xmas) { iuu_rxcmd(urb); @@ -386,7 +382,7 @@ static void iuu_led_activity_off(struct urb *urb) port->bulk_out_endpointAddress), port->write_urb->transfer_buffer, 8 , iuu_rxcmd, port); - result = usb_submit_urb(port->write_urb, GFP_ATOMIC); + usb_submit_urb(port->write_urb, GFP_ATOMIC); } -- cgit v1.2.3-70-g09d2 From 1bf2cda6597f08cef06db7b1804e5ff1d5bc5ee8 Mon Sep 17 00:00:00 2001 From: Johan Hovold Date: Wed, 1 Jul 2020 18:53:40 +0200 Subject: USB: serial: keyspan_pda: drop unused firmware reset status Drop the unused firmware reset status which would already have been logged. This suppresses the corresponding W=1 (-Wunused-but-set-variable) warning. Reviewed-by: Greg Kroah-Hartman Signed-off-by: Johan Hovold --- drivers/usb/serial/keyspan_pda.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/serial/keyspan_pda.c b/drivers/usb/serial/keyspan_pda.c index bf988f77d400..c1333919716b 100644 --- a/drivers/usb/serial/keyspan_pda.c +++ b/drivers/usb/serial/keyspan_pda.c @@ -664,11 +664,10 @@ static void keyspan_pda_close(struct usb_serial_port *port) /* download the firmware to a "fake" device (pre-renumeration) */ static int keyspan_pda_fake_startup(struct usb_serial *serial) { - int response; const char *fw_name; /* download the firmware here ... */ - response = ezusb_fx1_set_reset(serial->dev, 1); + ezusb_fx1_set_reset(serial->dev, 1); if (0) { ; } #ifdef KEYSPAN -- cgit v1.2.3-70-g09d2 From c34a917aeff44fb5b2afeef7f5e946e4de405d5a Mon Sep 17 00:00:00 2001 From: Johan Hovold Date: Wed, 1 Jul 2020 18:53:41 +0200 Subject: USB: serial: kobil_sct: log failure to update line settings Log failure to update the line settings in set_termios(). This also avoids a W=1 (-Wunused-but-set-variable) warning. Reviewed-by: Greg Kroah-Hartman Signed-off-by: Johan Hovold --- drivers/usb/serial/kobil_sct.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'drivers/usb') diff --git a/drivers/usb/serial/kobil_sct.c b/drivers/usb/serial/kobil_sct.c index e9882ba20933..79ce0219fdde 100644 --- a/drivers/usb/serial/kobil_sct.c +++ b/drivers/usb/serial/kobil_sct.c @@ -526,6 +526,10 @@ static void kobil_set_termios(struct tty_struct *tty, 0, KOBIL_TIMEOUT ); + if (result) { + dev_err(&port->dev, "failed to update line settings: %d\n", + result); + } } static int kobil_ioctl(struct tty_struct *tty, -- cgit v1.2.3-70-g09d2 From b83076a94dfa1d804a15d8639f5dff67b50fc265 Mon Sep 17 00:00:00 2001 From: Johan Hovold Date: Wed, 1 Jul 2020 18:53:42 +0200 Subject: USB: serial: quatech2: drop two stub functions Drop two unused stub functions which only served as documentation. This also avoids a W=1 (-Wunused-but-set-variable) warning. Reviewed-by: Greg Kroah-Hartman Signed-off-by: Johan Hovold --- drivers/usb/serial/quatech2.c | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/serial/quatech2.c b/drivers/usb/serial/quatech2.c index f93b81a297d6..872d1bc86ab4 100644 --- a/drivers/usb/serial/quatech2.c +++ b/drivers/usb/serial/quatech2.c @@ -480,21 +480,6 @@ static void qt2_process_status(struct usb_serial_port *port, unsigned char *ch) } } -/* not needed, kept to document functionality */ -static void qt2_process_xmit_empty(struct usb_serial_port *port, - unsigned char *ch) -{ - int bytes_written; - - bytes_written = (int)(*ch) + (int)(*(ch + 1) << 4); -} - -/* not needed, kept to document functionality */ -static void qt2_process_flush(struct usb_serial_port *port, unsigned char *ch) -{ - return; -} - static void qt2_process_read_urb(struct urb *urb) { struct usb_serial *serial; @@ -540,7 +525,7 @@ static void qt2_process_read_urb(struct urb *urb) __func__); break; } - qt2_process_xmit_empty(port, ch + 3); + /* bytes_written = (ch[1] << 4) + ch[0]; */ i += 4; escapeflag = true; break; @@ -569,7 +554,6 @@ static void qt2_process_read_urb(struct urb *urb) break; case QT2_REC_FLUSH: case QT2_XMIT_FLUSH: - qt2_process_flush(port, ch + 2); i += 2; escapeflag = true; break; -- cgit v1.2.3-70-g09d2 From cabe0785ff14e944ab1d828bed64e796e8f96594 Mon Sep 17 00:00:00 2001 From: Johan Hovold Date: Wed, 1 Jul 2020 19:37:22 +0200 Subject: USB: serial: console: add support for flow control Add support for enabling hardware flow control using the 'r' command line option. This also avoids a W=1 (-Wunused-but-set-variable) warning. Reviewed-by: Greg Kroah-Hartman Signed-off-by: Johan Hovold --- drivers/usb/serial/console.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'drivers/usb') diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c index 7d289302ff6c..b97aa40ca4d1 100644 --- a/drivers/usb/serial/console.c +++ b/drivers/usb/serial/console.c @@ -79,7 +79,7 @@ static int usb_console_setup(struct console *co, char *options) if (*s) doflow = (*s++ == 'r'); } - + /* Sane default */ if (baud == 0) baud = 9600; @@ -102,6 +102,9 @@ static int usb_console_setup(struct console *co, char *options) break; } + if (doflow) + cflag |= CRTSCTS; + /* * no need to check the index here: if the index is wrong, console * code won't call us -- cgit v1.2.3-70-g09d2 From 529427b92879545607460eb2fe9dd7a0ba02ee1a Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Thu, 2 Jul 2020 15:45:56 +0100 Subject: usb: phy: phy: Fix-up a whole bunch of formatting issues Kerneldoc expects arg descriptions to be in the format '@.*: '. If either the '@' or the ':' is omitted then kerneldoc complains that the description is missing. Add the missing ':'s here. Also provide a new description for 'event'. Fixes the following kernel build W=1 warnings: drivers/usb/phy/phy.c:106: warning: Function parameter or member 'work' not described in 'usb_phy_notify_charger_work' drivers/usb/phy/phy.c:172: warning: Function parameter or member 'nb' not described in 'usb_phy_get_charger_type' drivers/usb/phy/phy.c:172: warning: Function parameter or member 'state' not described in 'usb_phy_get_charger_type' drivers/usb/phy/phy.c:172: warning: Function parameter or member 'data' not described in 'usb_phy_get_charger_type' drivers/usb/phy/phy.c:194: warning: Function parameter or member 'usb_phy' not described in 'usb_phy_set_charger_current' drivers/usb/phy/phy.c:194: warning: Function parameter or member 'mA' not described in 'usb_phy_set_charger_current' drivers/usb/phy/phy.c:244: warning: Function parameter or member 'usb_phy' not described in 'usb_phy_get_charger_current' drivers/usb/phy/phy.c:244: warning: Function parameter or member 'min' not described in 'usb_phy_get_charger_current' drivers/usb/phy/phy.c:244: warning: Function parameter or member 'max' not described in 'usb_phy_get_charger_current' drivers/usb/phy/phy.c:281: warning: Function parameter or member 'usb_phy' not described in 'usb_phy_set_charger_state' drivers/usb/phy/phy.c:281: warning: Function parameter or member 'state' not described in 'usb_phy_set_charger_state' drivers/usb/phy/phy.c:427: warning: Function parameter or member 'dev' not described in 'devm_usb_get_phy' drivers/usb/phy/phy.c:427: warning: Function parameter or member 'type' not described in 'devm_usb_get_phy' drivers/usb/phy/phy.c:456: warning: Function parameter or member 'type' not described in 'usb_get_phy' drivers/usb/phy/phy.c:500: warning: Function parameter or member 'dev' not described in 'devm_usb_get_phy_by_node' drivers/usb/phy/phy.c:500: warning: Function parameter or member 'node' not described in 'devm_usb_get_phy_by_node' drivers/usb/phy/phy.c:500: warning: Function parameter or member 'nb' not described in 'devm_usb_get_phy_by_node' drivers/usb/phy/phy.c:558: warning: Function parameter or member 'dev' not described in 'devm_usb_get_phy_by_phandle' drivers/usb/phy/phy.c:558: warning: Function parameter or member 'phandle' not described in 'devm_usb_get_phy_by_phandle' drivers/usb/phy/phy.c:558: warning: Function parameter or member 'index' not described in 'devm_usb_get_phy_by_phandle' drivers/usb/phy/phy.c:590: warning: Function parameter or member 'dev' not described in 'devm_usb_put_phy' drivers/usb/phy/phy.c:590: warning: Function parameter or member 'phy' not described in 'devm_usb_put_phy' drivers/usb/phy/phy.c:627: warning: Function parameter or member 'type' not described in 'usb_add_phy' drivers/usb/phy/phy.c:721: warning: Function parameter or member 'event' not described in 'usb_phy_set_event' Cc: Felipe Balbi Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20200702144625.2533530-2-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/phy/phy.c | 49 +++++++++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 24 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/phy/phy.c b/drivers/usb/phy/phy.c index ad2554630889..b47285f023cf 100644 --- a/drivers/usb/phy/phy.c +++ b/drivers/usb/phy/phy.c @@ -88,7 +88,7 @@ static void usb_phy_set_default_current(struct usb_phy *usb_phy) /** * usb_phy_notify_charger_work - notify the USB charger state - * @work - the charger work to notify the USB charger state + * @work: the charger work to notify the USB charger state * * This work can be issued when USB charger state has been changed or * USB charger current has been changed, then we can notify the current @@ -160,9 +160,9 @@ static void __usb_phy_get_charger_type(struct usb_phy *usb_phy) /** * usb_phy_get_charger_type - get charger type from extcon subsystem - * @nb -the notifier block to determine charger type - * @state - the cable state - * @data - private data + * @nb: the notifier block to determine charger type + * @state: the cable state + * @data: private data * * Determin the charger type from extcon subsystem which also means the * charger state has been chaned, then we should notify this event. @@ -178,8 +178,8 @@ static int usb_phy_get_charger_type(struct notifier_block *nb, /** * usb_phy_set_charger_current - set the USB charger current - * @usb_phy - the USB phy to be used - * @mA - the current need to be set + * @usb_phy: the USB phy to be used + * @mA: the current need to be set * * Usually we only change the charger default current when USB finished the * enumeration as one SDP charger. As one SDP charger, usb_phy_set_power() @@ -231,9 +231,9 @@ EXPORT_SYMBOL_GPL(usb_phy_set_charger_current); /** * usb_phy_get_charger_current - get the USB charger current - * @usb_phy - the USB phy to be used - * @min - the minimum current - * @max - the maximum current + * @usb_phy: the USB phy to be used + * @min: the minimum current + * @max: the maximum current * * Usually we will notify the maximum current to power user, but for some * special case, power user also need the minimum current value. Then the @@ -269,8 +269,8 @@ EXPORT_SYMBOL_GPL(usb_phy_get_charger_current); /** * usb_phy_set_charger_state - set the USB charger state - * @usb_phy - the USB phy to be used - * @state - the new state need to be set for charger + * @usb_phy: the USB phy to be used + * @state: the new state need to be set for charger * * The usb phy driver can issue this function when the usb phy driver * detected the charger state has been changed, in this case the charger @@ -414,8 +414,8 @@ static int usb_add_extcon(struct usb_phy *x) /** * devm_usb_get_phy - find the USB PHY - * @dev - device that requests this phy - * @type - the type of the phy the controller requires + * @dev: device that requests this phy + * @type: the type of the phy the controller requires * * Gets the phy using usb_get_phy(), and associates a device with it using * devres. On driver detach, release function is invoked on the devres data, @@ -444,7 +444,7 @@ EXPORT_SYMBOL_GPL(devm_usb_get_phy); /** * usb_get_phy - find the USB PHY - * @type - the type of the phy the controller requires + * @type: the type of the phy the controller requires * * Returns the phy driver, after getting a refcount to it; or * -ENODEV if there is no such phy. The caller is responsible for @@ -480,9 +480,9 @@ EXPORT_SYMBOL_GPL(usb_get_phy); /** * devm_usb_get_phy_by_node - find the USB PHY by device_node - * @dev - device that requests this phy - * @node - the device_node for the phy device. - * @nb - a notifier_block to register with the phy. + * @dev: device that requests this phy + * @node: the device_node for the phy device. + * @nb: a notifier_block to register with the phy. * * Returns the phy driver associated with the given device_node, * after getting a refcount to it, -ENODEV if there is no such phy or @@ -540,9 +540,9 @@ EXPORT_SYMBOL_GPL(devm_usb_get_phy_by_node); /** * devm_usb_get_phy_by_phandle - find the USB PHY by phandle - * @dev - device that requests this phy - * @phandle - name of the property holding the phy phandle value - * @index - the index of the phy + * @dev: device that requests this phy + * @phandle: name of the property holding the phy phandle value + * @index: the index of the phy * * Returns the phy driver associated with the given phandle value, * after getting a refcount to it, -ENODEV if there is no such phy or @@ -578,8 +578,8 @@ EXPORT_SYMBOL_GPL(devm_usb_get_phy_by_phandle); /** * devm_usb_put_phy - release the USB PHY - * @dev - device that wants to release this phy - * @phy - the phy returned by devm_usb_get_phy() + * @dev: device that wants to release this phy + * @phy: the phy returned by devm_usb_get_phy() * * destroys the devres associated with this phy and invokes usb_put_phy * to release the phy. @@ -615,9 +615,9 @@ void usb_put_phy(struct usb_phy *x) EXPORT_SYMBOL_GPL(usb_put_phy); /** - * usb_add_phy - declare the USB PHY + * usb_add_phy: declare the USB PHY * @x: the USB phy to be used; or NULL - * @type - the type of this PHY + * @type: the type of this PHY * * This call is exclusively for use by phy drivers, which * coordinate the activities of drivers for host and peripheral @@ -714,6 +714,7 @@ EXPORT_SYMBOL_GPL(usb_remove_phy); /** * usb_phy_set_event - set event to phy event * @x: the phy returned by usb_get_phy(); + * @event: event to set * * This sets event to phy event */ -- cgit v1.2.3-70-g09d2 From 82511e2d99ee79833a56252c2343f4e722db7967 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Thu, 2 Jul 2020 15:45:57 +0100 Subject: usb: host: pci-quirks: Demote function header from kerneldoc to comment block quirk_usb_handoff_xhci()'s function header is the only one across the sourcefile which is denoted as a kerneldoc header. Despite no attempt to document its arguments. Drop it down in status from kerneldoc to a standard comment block to match the other headers in the file. Fixes the following W=1 kernel build warning: drivers/usb/host/pci-quirks.c:1145: warning: Function parameter or member 'pdev' not described in 'quirk_usb_handoff_xhci' Cc: Mathias Nyman Cc: Martin Mares Cc: aleksey_gorelov@phoenix.com Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20200702144625.2533530-3-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/pci-quirks.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/usb') diff --git a/drivers/usb/host/pci-quirks.c b/drivers/usb/host/pci-quirks.c index 0b949acfa258..b8961c0381cf 100644 --- a/drivers/usb/host/pci-quirks.c +++ b/drivers/usb/host/pci-quirks.c @@ -1133,7 +1133,7 @@ void usb_disable_xhci_ports(struct pci_dev *xhci_pdev) } EXPORT_SYMBOL_GPL(usb_disable_xhci_ports); -/** +/* * PCI Quirks for xHCI. * * Takes care of the handoff between the Pre-OS (i.e. BIOS) and the OS. -- cgit v1.2.3-70-g09d2 From 3e682e6fcaea3099cf93eeafef150108556b77e9 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Thu, 2 Jul 2020 15:45:58 +0100 Subject: usb: common: debug: Demote comment blocks which are obviously not kerneldoc File headers and simple comments are not kerneldoc worthy. Fixes the following W=1 warnings: drivers/usb/common/debug.c:15: warning: Function parameter or member 'bRequestType' not described in 'usb_decode_get_status' drivers/usb/common/debug.c:15: warning: Function parameter or member 'wIndex' not described in 'usb_decode_get_status' drivers/usb/common/debug.c:15: warning: Function parameter or member 'wLength' not described in 'usb_decode_get_status' drivers/usb/common/debug.c:15: warning: Function parameter or member 'str' not described in 'usb_decode_get_status' drivers/usb/common/debug.c:15: warning: Function parameter or member 'size' not described in 'usb_decode_get_status' drivers/usb/common/debug.c:216: warning: Function parameter or member 'str' not described in 'usb_decode_ctrl' drivers/usb/common/debug.c:216: warning: Function parameter or member 'size' not described in 'usb_decode_ctrl' drivers/usb/common/debug.c:216: warning: Function parameter or member 'bRequestType' not described in 'usb_decode_ctrl' drivers/usb/common/debug.c:216: warning: Function parameter or member 'bRequest' not described in 'usb_decode_ctrl' drivers/usb/common/debug.c:216: warning: Function parameter or member 'wValue' not described in 'usb_decode_ctrl' drivers/usb/common/debug.c:216: warning: Function parameter or member 'wIndex' not described in 'usb_decode_ctrl' drivers/usb/common/debug.c:216: warning: Function parameter or member 'wLength' not described in 'usb_decode_ctrl' Cc: Pawel Laszczak Cc: Felipe Balbi Cc: Andrzej Siewior Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20200702144625.2533530-4-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/common/debug.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/common/debug.c b/drivers/usb/common/debug.c index 410acd670ca7..54c8f984c7b4 100644 --- a/drivers/usb/common/debug.c +++ b/drivers/usb/common/debug.c @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 -/** +/* * Common USB debugging functions * * Copyright (C) 2010-2011 Texas Instruments Incorporated - http://www.ti.com @@ -207,7 +207,7 @@ static void usb_decode_set_isoch_delay(__u8 wValue, char *str, size_t size) snprintf(str, size, "Set Isochronous Delay(Delay = %d ns)", wValue); } -/** +/* * usb_decode_ctrl - returns a string representation of ctrl request */ const char *usb_decode_ctrl(char *str, size_t size, __u8 bRequestType, -- cgit v1.2.3-70-g09d2 From 11d96a5912311a60332be62139aec3b1af248f45 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Thu, 2 Jul 2020 15:45:59 +0100 Subject: usb: common: usb-conn-gpio: Demote comment block which is clearly not kerneldoc This block lacks a title and argument descriptions. Fixes the following W=1 kernel build warning: drivers/usb/common/usb-conn-gpio.c:44: warning: Cannot understand * "DEVICE" = VBUS and "HOST" = !ID, so we have: on line 44 - I thought it was a doc line Cc: Chunfeng Yun Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20200702144625.2533530-5-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/common/usb-conn-gpio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/usb') diff --git a/drivers/usb/common/usb-conn-gpio.c b/drivers/usb/common/usb-conn-gpio.c index ed204cbb63ea..b4051f042c79 100644 --- a/drivers/usb/common/usb-conn-gpio.c +++ b/drivers/usb/common/usb-conn-gpio.c @@ -40,7 +40,7 @@ struct usb_conn_info { int vbus_irq; }; -/** +/* * "DEVICE" = VBUS and "HOST" = !ID, so we have: * Both "DEVICE" and "HOST" can't be set as active at the same time * so if "HOST" is active (i.e. ID is 0) we keep "DEVICE" inactive -- cgit v1.2.3-70-g09d2 From 7679defc3e290d4cb8377f8fc2d8b6f3cca32eb2 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Thu, 2 Jul 2020 15:46:00 +0100 Subject: usb: dwc3: drd: File headers are not doc headers Demote drd.c's file header to a standard comment block. Fixes the following W=1 build warnings: drivers/usb/dwc3/drd.c:20: warning: Function parameter or member 'dwc' not described in 'dwc3_otg_disable_events' drivers/usb/dwc3/drd.c:20: warning: Function parameter or member 'disable_mask' not described in 'dwc3_otg_disable_events' Cc: Felipe Balbi Cc: Roger Quadros Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20200702144625.2533530-6-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/dwc3/drd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/usb') diff --git a/drivers/usb/dwc3/drd.c b/drivers/usb/dwc3/drd.c index 2e483448d695..fd7f9a9f67dc 100644 --- a/drivers/usb/dwc3/drd.c +++ b/drivers/usb/dwc3/drd.c @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 -/** +/* * drd.c - DesignWare USB3 DRD Controller Dual-role support * * Copyright (C) 2017 Texas Instruments Incorporated - http://www.ti.com -- cgit v1.2.3-70-g09d2 From fb678a5a76a4675e783cdef74b3e7117cf596cb0 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Thu, 2 Jul 2020 15:46:01 +0100 Subject: usb: dwc3: ulpi: File headers are not doc headers Demote ulpi.c's file header to a standard comment block. Fixes the following W=1 build warning: drivers/usb/dwc3/ulpi.c:18: warning: Function parameter or member 'a' not described in 'DWC3_ULPI_ADDR' Cc: Felipe Balbi Cc: Heikki Krogerus Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20200702144625.2533530-7-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/dwc3/ulpi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/usb') diff --git a/drivers/usb/dwc3/ulpi.c b/drivers/usb/dwc3/ulpi.c index f62b5f3c2d67..e6e6176386a4 100644 --- a/drivers/usb/dwc3/ulpi.c +++ b/drivers/usb/dwc3/ulpi.c @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 -/** +/* * ulpi.c - DesignWare USB3 Controller's ULPI PHY interface * * Copyright (C) 2015 Intel Corporation -- cgit v1.2.3-70-g09d2 From 246d7a1103b3cb00357939a01284679c844ee27d Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Thu, 2 Jul 2020 15:46:02 +0100 Subject: usb: common: ulpi: Fix a few kerneldoc related issues Firstly, demote function header to standard comment block as they are not suitable for kerneldoc. Then provide description for ulpi_register_driver()'s argument 'module'. Finally rename description for ulpi_unregister_interface()'s 'ulpi' arg. Fixes the following W=1 warnings: drivers/usb/common/ulpi.c:23: warning: Function parameter or member 'ulpi' not described in 'ulpi_read' drivers/usb/common/ulpi.c:23: warning: Function parameter or member 'addr' not described in 'ulpi_read' drivers/usb/common/ulpi.c:150: warning: Function parameter or member 'module' not described in '__ulpi_register_driver' drivers/usb/common/ulpi.c:299: warning: Function parameter or member 'ulpi' not described in 'ulpi_unregister_interface' drivers/usb/common/ulpi.c:299: warning: Excess function parameter 'intrf' description in 'ulpi_unregister_interface' Cc: Felipe Balbi Cc: Heikki Krogerus Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20200702144625.2533530-8-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/common/ulpi.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/common/ulpi.c b/drivers/usb/common/ulpi.c index 9a2ab6751a23..a18d7c4222dd 100644 --- a/drivers/usb/common/ulpi.c +++ b/drivers/usb/common/ulpi.c @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 -/** +/* * ulpi.c - USB ULPI PHY bus * * Copyright (C) 2015 Intel Corporation @@ -143,6 +143,7 @@ static const struct device_type ulpi_dev_type = { /** * ulpi_register_driver - register a driver with the ULPI bus * @drv: driver being registered + * @module: ends up being THIS_MODULE * * Registers a driver with the ULPI bus. */ @@ -290,7 +291,7 @@ EXPORT_SYMBOL_GPL(ulpi_register_interface); /** * ulpi_unregister_interface - unregister ULPI interface - * @intrf: struct ulpi_interface + * @ulpi: struct ulpi_interface * * Unregisters a ULPI device and it's interface that was created with * ulpi_create_interface(). -- cgit v1.2.3-70-g09d2 From 3c373454a9f288d81d5780e4a4ed9cfe245552da Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Thu, 2 Jul 2020 15:46:03 +0100 Subject: usb: dwc3: dwc3-omap: Do not read DMA status MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Commit af566a0be6e49 ("usb: dwc3: omap: get rid of dma_status") rendered reading DMA status from the H/W even more redundant. The variable hasn't been read/used since 2016. Remove the set but unused variable and the call which populates it. Fixes the following W=1 warning: drivers/usb/dwc3/dwc3-omap.c: In function ‘dwc3_omap_probe’: drivers/usb/dwc3/dwc3-omap.c:460:8: warning: variable ‘reg’ set but not used [-Wunused-but-set-variable] 460 | u32 reg; | ^~~ Cc: Felipe Balbi Cc: Andrzej Siewior Cc: linux-omap@vger.kernel.org Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20200702144625.2533530-9-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/dwc3/dwc3-omap.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c index 8c3de2d258bf..11288a370828 100644 --- a/drivers/usb/dwc3/dwc3-omap.c +++ b/drivers/usb/dwc3/dwc3-omap.c @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 -/** +/* * dwc3-omap.c - OMAP Specific Glue layer * * Copyright (C) 2010-2011 Texas Instruments Incorporated - http://www.ti.com @@ -457,8 +457,6 @@ static int dwc3_omap_probe(struct platform_device *pdev) int ret; int irq; - u32 reg; - void __iomem *base; if (!node) { @@ -503,9 +501,6 @@ static int dwc3_omap_probe(struct platform_device *pdev) dwc3_omap_map_offset(omap); dwc3_omap_set_utmi_mode(omap); - /* check the DMA Status */ - reg = dwc3_omap_readl(omap->base, USBOTGSS_SYSCONFIG); - ret = dwc3_omap_extcon_register(omap); if (ret < 0) goto err1; -- cgit v1.2.3-70-g09d2 From ede175a529b112c0fbff02c51a3fcec191d01e30 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Thu, 2 Jul 2020 15:46:07 +0100 Subject: usb: host: ehci-omap: Provide documentation for ehci_hcd_omap_probe()'s arg 'pdev' Description for 'pdev' argument was missing from the function header. Fixes the following W=1 warning: drivers/usb/host/ehci-omap.c:87: warning: Function parameter or member 'pdev' not described in 'ehci_hcd_omap_probe' Cc: Alan Stern Cc: Vikram Pandita Cc: Anand Gadiyar Cc: Keshava Munegowda Cc: Roger Quadros Cc: Felipe Balbi Cc: linux-omap@vger.kernel.org Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20200702144625.2533530-13-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/ehci-omap.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/usb') diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c index fc125b3d06e7..2ec686e28582 100644 --- a/drivers/usb/host/ehci-omap.c +++ b/drivers/usb/host/ehci-omap.c @@ -78,6 +78,7 @@ static const struct ehci_driver_overrides ehci_omap_overrides __initconst = { /** * ehci_hcd_omap_probe - initialize TI-based HCDs + * @pdev: Pointer to this platform device's information * * Allocates basic resources for this USB host controller, and * then invokes the start() method for the HCD associated with it -- cgit v1.2.3-70-g09d2 From 6e29619fd2558dd5d55ee23f05330d563cdbea73 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Thu, 2 Jul 2020 15:46:08 +0100 Subject: usb: cdns3: core: Fix incorrect formatting and misspelled function arg docs There are 3 misspellings and 1 incorrect format used in this file's kerneldoc function headers. Fixing them squashes the following W=1 kernel build warnings: drivers/usb/cdns3/gadget.c:653: warning: Function parameter or member 'priv_ep' not described in 'cdns3_wa2_descmissing_packet' drivers/usb/cdns3/gadget.c:653: warning: Excess function parameter 'priv_dev' description in 'cdns3_wa2_descmissing_packet' drivers/usb/cdns3/gadget.c:1088: warning: Function parameter or member 'request' not described in 'cdns3_ep_run_transfer' drivers/usb/cdns3/gadget.c:2574: warning: Function parameter or member 'priv_ep' not described in '__cdns3_gadget_ep_set_halt' drivers/usb/cdns3/gadget.c:2574: warning: Excess function parameter 'ep' description in '__cdns3_gadget_ep_set_halt' drivers/usb/cdns3/gadget.c:2595: warning: Function parameter or member 'priv_ep' not described in '__cdns3_gadget_ep_clear_halt' drivers/usb/cdns3/gadget.c:2595: warning: Excess function parameter 'ep' description in '__cdns3_gadget_ep_clear_halt' drivers/usb/cdns3/gadget.c:2898: warning: Function parameter or member 'priv_dev' not described in 'cdns3_init_eps' drivers/usb/cdns3/gadget.c:2898: warning: Excess function parameter 'cdns3' description in 'cdns3_init_eps' drivers/usb/cdns3/gadget.c:3210: warning: Function parameter or member 'cdns' not described in 'cdns3_gadget_init' Cc: Pawel Laszczak Cc: Peter Chen Cc: Roger Quadros Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20200702144625.2533530-14-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/cdns3/core.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/cdns3/core.c b/drivers/usb/cdns3/core.c index 19bbb5b7e6b6..59e5e213a99b 100644 --- a/drivers/usb/cdns3/core.c +++ b/drivers/usb/cdns3/core.c @@ -282,7 +282,7 @@ static int cdns3_idle_init(struct cdns3 *cdns) /** * cdns3_hw_role_switch - switch roles based on HW state - * @cdns3: controller + * @cdns: controller */ int cdns3_hw_role_switch(struct cdns3 *cdns) { @@ -320,7 +320,7 @@ exit: /** * cdsn3_role_get - get current role of controller. * - * @dev: Pointer to device structure + * @sw: pointer to USB role switch structure * * Returns role */ @@ -334,8 +334,8 @@ static enum usb_role cdns3_role_get(struct usb_role_switch *sw) /** * cdns3_role_set - set current role of controller. * - * @dev: pointer to device object - * @role - the previous role + * @sw: pointer to USB role switch structure + * @role: the previous role * Handles below events: * - Role switch for dual-role devices * - USB_ROLE_GADGET <--> USB_ROLE_NONE for peripheral-only devices -- cgit v1.2.3-70-g09d2 From 9293b7db8c33b288cefe439d9e0c1b20cad55a96 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Thu, 2 Jul 2020 15:46:09 +0100 Subject: usb: cdns3: ep0: Fix a bunch of kerneldoc issues Add some missing function argument descriptions for 'ep', 'desc' and 'zlp', and correct spelling/bitrot issues surrounding the correct spelling of present args. Fixes the following W=1 warnings: drivers/usb/cdns3/ep0.c:36: warning: Function parameter or member 'zlp' not described in 'cdns3_ep0_run_transfer' drivers/usb/cdns3/ep0.c:236: warning: Function parameter or member 'ctrl' not described in 'cdns3_req_ep0_get_status' drivers/usb/cdns3/ep0.c:236: warning: Excess function parameter 'ctrl_req' description in 'cdns3_req_ep0_get_status' drivers/usb/cdns3/ep0.c:411: warning: Function parameter or member 'ctrl' not described in 'cdns3_req_ep0_handle_feature' drivers/usb/cdns3/ep0.c:411: warning: Excess function parameter 'ctrl_req' description in 'cdns3_req_ep0_handle_feature' drivers/usb/cdns3/ep0.c:661: warning: Function parameter or member 'ep' not described in 'cdns3_gadget_ep0_enable' drivers/usb/cdns3/ep0.c:661: warning: Function parameter or member 'desc' not described in 'cdns3_gadget_ep0_enable' drivers/usb/cdns3/ep0.c:671: warning: Function parameter or member 'ep' not described in 'cdns3_gadget_ep0_disable' drivers/usb/cdns3/ep0.c:867: warning: Function parameter or member 'priv_ep' not described in 'cdns3_init_ep0' drivers/usb/cdns3/ep0.c:867: warning: Excess function parameter 'ep_priv' description in 'cdns3_init_ep0' Cc: Pawel Laszczak Cc: Pawel Jez Cc: Peter Chen Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20200702144625.2533530-15-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/cdns3/ep0.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/cdns3/ep0.c b/drivers/usb/cdns3/ep0.c index cdf09c09b486..b7e78146ba64 100644 --- a/drivers/usb/cdns3/ep0.c +++ b/drivers/usb/cdns3/ep0.c @@ -227,7 +227,7 @@ static int cdns3_req_ep0_set_address(struct cdns3_device *priv_dev, /** * cdns3_req_ep0_get_status - Handling of GET_STATUS standard USB request * @priv_dev: extended gadget object - * @ctrl_req: pointer to received setup packet + * @ctrl: pointer to received setup packet * * Returns 0 if success, error code on error */ @@ -401,7 +401,7 @@ static int cdns3_ep0_feature_handle_endpoint(struct cdns3_device *priv_dev, * Handling of GET/SET_FEATURE standard USB request * * @priv_dev: extended gadget object - * @ctrl_req: pointer to received setup packet + * @ctrl: pointer to received setup packet * @set: must be set to 1 for SET_FEATURE request * * Returns 0 if success, error code on error @@ -654,6 +654,9 @@ void cdns3_check_ep0_interrupt_proceed(struct cdns3_device *priv_dev, int dir) /** * cdns3_gadget_ep0_enable + * @ep: pointer to endpoint zero object + * @desc: pointer to usb endpoint descriptor + * * Function shouldn't be called by gadget driver, * endpoint 0 is allways active */ @@ -665,6 +668,8 @@ static int cdns3_gadget_ep0_enable(struct usb_ep *ep, /** * cdns3_gadget_ep0_disable + * @ep: pointer to endpoint zero object + * * Function shouldn't be called by gadget driver, * endpoint 0 is allways active */ @@ -691,6 +696,7 @@ static int cdns3_gadget_ep0_set_halt(struct usb_ep *ep, int value) * @ep: pointer to endpoint zero object * @request: pointer to request object * @gfp_flags: gfp flags + * @zlp: add zero length packet * * Returns 0 on success, error code elsewhere */ @@ -860,7 +866,7 @@ void cdns3_ep0_config(struct cdns3_device *priv_dev) /** * cdns3_init_ep0 Initializes software endpoint 0 of gadget * @priv_dev: extended gadget object - * @ep_priv: extended endpoint object + * @priv_ep: extended endpoint object * * Returns 0 on success else error code. */ -- cgit v1.2.3-70-g09d2 From 4d72cf0cb9e23374cedbde9f1ee0ae643a235663 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Thu, 2 Jul 2020 15:46:10 +0100 Subject: usb: dwc3: dwc3-haps: Function headers are not suitable for kerneldoc Fixes the following W=1 kernel build warnings: drivers/usb/dwc3/dwc3-haps.c:19: warning: Incorrect use of kernel-doc format: * struct dwc3_haps - Driver private structure drivers/usb/dwc3/dwc3-haps.c:23: warning: cannot understand function prototype: 'struct dwc3_haps ' Cc: Felipe Balbi Cc: Thinh Nguyen Cc: John Youn Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20200702144625.2533530-16-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/dwc3/dwc3-haps.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/usb') diff --git a/drivers/usb/dwc3/dwc3-haps.c b/drivers/usb/dwc3/dwc3-haps.c index 3cecbf169452..55b4a901168e 100644 --- a/drivers/usb/dwc3/dwc3-haps.c +++ b/drivers/usb/dwc3/dwc3-haps.c @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 -/** +/* * dwc3-haps.c - Synopsys HAPS PCI Specific glue layer * * Copyright (C) 2018 Synopsys, Inc. -- cgit v1.2.3-70-g09d2 From 4a35aa6d3c626bcc23639a1113e3bf0925788e14 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Thu, 2 Jul 2020 15:46:12 +0100 Subject: usb: cdns3: gadget: Fix a bunch of kernel doc issues Mainline misspelled function argument descriptions. Also one formatting issue with a missing '@' identifier. Fixes the following W=1 build warnings: drivers/usb/cdns3/gadget.c:653: warning: Function parameter or member 'priv_ep' not described in 'cdns3_wa2_descmissing_packet' drivers/usb/cdns3/gadget.c:653: warning: Excess function parameter 'priv_dev' description in 'cdns3_wa2_descmissing_packet' drivers/usb/cdns3/gadget.c:1088: warning: Function parameter or member 'request' not described in 'cdns3_ep_run_transfer' drivers/usb/cdns3/gadget.c:2574: warning: Function parameter or member 'priv_ep' not described in '__cdns3_gadget_ep_set_halt' drivers/usb/cdns3/gadget.c:2574: warning: Excess function parameter 'ep' description in '__cdns3_gadget_ep_set_halt' drivers/usb/cdns3/gadget.c:2595: warning: Function parameter or member 'priv_ep' not described in '__cdns3_gadget_ep_clear_halt' drivers/usb/cdns3/gadget.c:2595: warning: Excess function parameter 'ep' description in '__cdns3_gadget_ep_clear_halt' drivers/usb/cdns3/gadget.c:2898: warning: Function parameter or member 'priv_dev' not described in 'cdns3_init_eps' drivers/usb/cdns3/gadget.c:2898: warning: Excess function parameter 'cdns3' description in 'cdns3_init_eps' drivers/usb/cdns3/gadget.c:3210: warning: Function parameter or member 'cdns' not described in 'cdns3_gadget_init' Cc: Pawel Laszczak Cc: Pawel Jez Cc: Peter Chen Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20200702144625.2533530-18-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/cdns3/gadget.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/cdns3/gadget.c b/drivers/usb/cdns3/gadget.c index 7c2913bc8bd7..64a801c7a03c 100644 --- a/drivers/usb/cdns3/gadget.c +++ b/drivers/usb/cdns3/gadget.c @@ -644,7 +644,7 @@ static void cdns3_wa2_remove_old_request(struct cdns3_endpoint *priv_ep) /** * cdns3_wa2_descmissing_packet - handles descriptor missing event. - * @priv_dev: extended gadget object + * @priv_ep: extended gadget object * * This function is used only for WA2. For more information see Work around 2 * description. @@ -1080,6 +1080,7 @@ static int cdns3_ep_run_stream_transfer(struct cdns3_endpoint *priv_ep, /** * cdns3_ep_run_transfer - start transfer on no-default endpoint hardware * @priv_ep: endpoint object + * @request: request object * * Returns zero on success or negative value on failure */ @@ -2568,7 +2569,7 @@ not_found: /** * __cdns3_gadget_ep_set_halt Sets stall on selected endpoint * Should be called after acquiring spin_lock and selecting ep - * @ep: endpoint object to set stall on. + * @priv_ep: endpoint object to set stall on. */ void __cdns3_gadget_ep_set_halt(struct cdns3_endpoint *priv_ep) { @@ -2589,7 +2590,7 @@ void __cdns3_gadget_ep_set_halt(struct cdns3_endpoint *priv_ep) /** * __cdns3_gadget_ep_clear_halt Clears stall on selected endpoint * Should be called after acquiring spin_lock and selecting ep - * @ep: endpoint object to clear stall on + * @priv_ep: endpoint object to clear stall on */ int __cdns3_gadget_ep_clear_halt(struct cdns3_endpoint *priv_ep) { @@ -2890,7 +2891,7 @@ static void cdns3_free_all_eps(struct cdns3_device *priv_dev) /** * cdns3_init_eps Initializes software endpoints of gadget - * @cdns3: extended gadget object + * @priv_dev: extended gadget object * * Returns 0 on success, error code elsewhere */ @@ -3202,7 +3203,7 @@ static int cdns3_gadget_resume(struct cdns3 *cdns, bool hibernated) /** * cdns3_gadget_init - initialize device structure * - * cdns: cdns3 instance + * @cdns: cdns3 instance * * This function initializes the gadget. */ -- cgit v1.2.3-70-g09d2 From 26ef796f9306ce82fbd7c7f0142ed4674698a333 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Thu, 2 Jul 2020 15:46:13 +0100 Subject: usb: dwc3: dwc3-of-simple: Function headers are not good candidates for kerneldoc Fixes the following kernel build warning(s): drivers/usb/dwc3/dwc3-of-simple.c:25: warning: cannot understand function prototype: 'struct dwc3_of_simple ' Cc: Felipe Balbi Cc: iivanov@mm-sol.com Cc: Sundeep Bhatta Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20200702144625.2533530-19-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/dwc3/dwc3-of-simple.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/usb') diff --git a/drivers/usb/dwc3/dwc3-of-simple.c b/drivers/usb/dwc3/dwc3-of-simple.c index 8852fbfdead4..34c828c22197 100644 --- a/drivers/usb/dwc3/dwc3-of-simple.c +++ b/drivers/usb/dwc3/dwc3-of-simple.c @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 -/** +/* * dwc3-of-simple.c - OF glue layer for simple integrations * * Copyright (c) 2015 Texas Instruments Incorporated - http://www.ti.com -- cgit v1.2.3-70-g09d2 From 048715c070bc3226bbf56c37d1a8ec4aee215ff7 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Thu, 2 Jul 2020 15:46:14 +0100 Subject: usb: host: isp1362: Mark the many unused ISP1362_REG entries as __maybe_unused MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It would seem a shame to strip out all of the unused register entries, since they can act as a fair source of documentation. Instead, mark them all as __maybe_unused to show the build system that this behaviour is known and intentional. Fixes the following kernel build warning(s): In file included from drivers/usb/host/isp1362-hcd.c:96: drivers/usb/host/isp1362.h:59:22: warning: ‘ISP1362_REG_OTGALTTMR’ defined but not used [-Wunused-const-variable=] 59 | static isp1362_reg_t ISP1362_REG_##name = addr | ^~~~~~~~~~~~ drivers/usb/host/isp1362.h:199:1: note: in expansion of macro ‘ISP1362_REG’ 199 | ISP1362_REG(OTGALTTMR, 0x6C, REG_WIDTH_16, REG_ACCESS_RW); | ^~~~~~~~~~~ drivers/usb/host/isp1362.h:59:22: warning: ‘ISP1362_REG_OTGTIMER’ defined but not used [-Wunused-const-variable=] 59 | static isp1362_reg_t ISP1362_REG_##name = addr | ^~~~~~~~~~~~ drivers/usb/host/isp1362.h:198:1: note: in expansion of macro ‘ISP1362_REG’ 198 | ISP1362_REG(OTGTIMER, 0x6A, REG_WIDTH_16, REG_ACCESS_RW); | ^~~~~~~~~~~ drivers/usb/host/isp1362.h:59:22: warning: ‘ISP1362_REG_OTGINTENB’ defined but not used [-Wunused-const-variable=] 59 | static isp1362_reg_t ISP1362_REG_##name = addr | ^~~~~~~~~~~~ drivers/usb/host/isp1362.h:197:1: note: in expansion of macro ‘ISP1362_REG’ 197 | ISP1362_REG(OTGINTENB, 0x69, REG_WIDTH_16, REG_ACCESS_RW); | ^~~~~~~~~~~ drivers/usb/host/isp1362.h:59:22: warning: ‘ISP1362_REG_OTGINT’ defined but not used [-Wunused-const-variable=] 59 | static isp1362_reg_t ISP1362_REG_##name = addr | ^~~~~~~~~~~~ drivers/usb/host/isp1362.h:196:1: note: in expansion of macro ‘ISP1362_REG’ 196 | ISP1362_REG(OTGINT, 0x68, REG_WIDTH_16, REG_ACCESS_RW); | ^~~~~~~~~~~ drivers/usb/host/isp1362.h:59:22: warning: ‘ISP1362_REG_OTGSTATUS’ defined but not used [-Wunused-const-variable=] 59 | static isp1362_reg_t ISP1362_REG_##name = addr | ^~~~~~~~~~~~ drivers/usb/host/isp1362.h:195:1: note: in expansion of macro ‘ISP1362_REG’ 195 | ISP1362_REG(OTGSTATUS, 0x67, REG_WIDTH_16, REG_ACCESS_R); | ^~~~~~~~~~~ drivers/usb/host/isp1362.h:59:22: warning: ‘ISP1362_REG_OTGCONTROL’ defined but not used [-Wunused-const-variable=] 59 | static isp1362_reg_t ISP1362_REG_##name = addr | ^~~~~~~~~~~~ drivers/usb/host/isp1362.h:194:1: note: in expansion of macro ‘ISP1362_REG’ 194 | ISP1362_REG(OTGCONTROL, 0x62, REG_WIDTH_16, REG_ACCESS_RW); | ^~~~~~~~~~~ drivers/usb/host/isp1362.h:59:22: warning: ‘ISP1362_REG_HCATLPORT’ defined but not used [-Wunused-const-variable=] 59 | static isp1362_reg_t ISP1362_REG_##name = addr | ^~~~~~~~~~~~ drivers/usb/host/isp1362.h:183:1: note: in expansion of macro ‘ISP1362_REG’ 183 | ISP1362_REG(HCATLPORT, 0x44, REG_WIDTH_16, REG_ACCESS_RW); | ^~~~~~~~~~~ drivers/usb/host/isp1362.h:59:22: warning: ‘ISP1362_REG_HCINTLPORT’ defined but not used [-Wunused-const-variable=] 59 | static isp1362_reg_t ISP1362_REG_##name = addr | ^~~~~~~~~~~~ drivers/usb/host/isp1362.h:175:1: note: in expansion of macro ‘ISP1362_REG’ 175 | ISP1362_REG(HCINTLPORT, 0x43, REG_WIDTH_16, REG_ACCESS_RW); | ^~~~~~~~~~~ drivers/usb/host/isp1362.h:59:22: warning: ‘ISP1362_REG_HCISTL1PORT’ defined but not used [-Wunused-const-variable=] 59 | static isp1362_reg_t ISP1362_REG_##name = addr | ^~~~~~~~~~~~ drivers/usb/host/isp1362.h:171:1: note: in expansion of macro ‘ISP1362_REG’ 171 | ISP1362_REG(HCISTL1PORT, 0x42, REG_WIDTH_16, REG_ACCESS_RW); | ^~~~~~~~~~~ drivers/usb/host/isp1362.h:59:22: warning: ‘ISP1362_REG_HCISTL0PORT’ defined but not used [-Wunused-const-variable=] 59 | static isp1362_reg_t ISP1362_REG_##name = addr | ^~~~~~~~~~~~ drivers/usb/host/isp1362.h:170:1: note: in expansion of macro ‘ISP1362_REG’ 170 | ISP1362_REG(HCISTL0PORT, 0x40, REG_WIDTH_16, REG_ACCESS_RW); | ^~~~~~~~~~~ drivers/usb/host/isp1362.h:59:22: warning: ‘ISP1362_REG_HCINTDIS’ defined but not used [-Wunused-const-variable=] 59 | static isp1362_reg_t ISP1362_REG_##name = addr | ^~~~~~~~~~~~ drivers/usb/host/isp1362.h:77:1: note: in expansion of macro ‘ISP1362_REG’ 77 | ISP1362_REG(HCINTDIS, 0x05, REG_WIDTH_32, REG_ACCESS_RW); | ^~~~~~~~~~~ Cc: "by L. Wassmann" Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20200702144625.2533530-20-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/isp1362.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/usb') diff --git a/drivers/usb/host/isp1362.h b/drivers/usb/host/isp1362.h index 4c49688a069d..9bbfcc3fdd3c 100644 --- a/drivers/usb/host/isp1362.h +++ b/drivers/usb/host/isp1362.h @@ -56,7 +56,7 @@ typedef const unsigned char isp1362_reg_t; #define ISP1362_REG_NO(r) (r) #define ISP1362_REG(name, addr, width, rw) \ -static isp1362_reg_t ISP1362_REG_##name = addr +static isp1362_reg_t __maybe_unused ISP1362_REG_##name = addr #define REG_ACCESS_TEST(r) do {} while (0) #define REG_WIDTH_TEST(r, w) do {} while (0) -- cgit v1.2.3-70-g09d2 From f73a8db011441654f9ccd97405757cd95405c86f Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Thu, 2 Jul 2020 15:46:15 +0100 Subject: usb: host: ohci-at91: Demote kerneldoc headers down to basic comment blocks Neither usb_hcd_at91_probe() nor usb_hcd_at91_remove()'s function headers reach the standards required of a kerneldoc entry. Only one attempt at describing an argument was made, as it is not correct (we're removing that too to save confusion). Fixes the following kernel build warning(s): drivers/usb/host/ohci-at91.c:166: warning: Function parameter or member 'driver' not described in 'usb_hcd_at91_probe' drivers/usb/host/ohci-at91.c:166: warning: Function parameter or member 'pdev' not described in 'usb_hcd_at91_probe' drivers/usb/host/ohci-at91.c:259: warning: Function parameter or member 'hcd' not described in 'usb_hcd_at91_remove' drivers/usb/host/ohci-at91.c:259: warning: Function parameter or member 'pdev' not described in 'usb_hcd_at91_remove' drivers/usb/host/ohci-at91.c:259: warning: Excess function parameter 'dev' description in 'usb_hcd_at91_remove' Cc: Alan Stern Cc: Nicolas Ferre Cc: Alexandre Belloni Cc: Ludovic Desroches Cc: Thibaut VARENE Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20200702144625.2533530-21-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/ohci-at91.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c index b635c6a1b1a9..0487a4b0501e 100644 --- a/drivers/usb/host/ohci-at91.c +++ b/drivers/usb/host/ohci-at91.c @@ -153,7 +153,7 @@ static struct regmap *at91_dt_syscon_sfr(void) /* always called with process context; sleeping is OK */ -/** +/* * usb_hcd_at91_probe - initialize AT91-based HCDs * Context: !in_interrupt() * @@ -244,9 +244,8 @@ static int usb_hcd_at91_probe(const struct hc_driver *driver, /* may be called with controller, bus, and devices active */ -/** +/* * usb_hcd_at91_remove - shutdown processing for AT91-based HCDs - * @dev: USB Host Controller being removed * Context: !in_interrupt() * * Reverses the effect of usb_hcd_at91_probe(), first invoking -- cgit v1.2.3-70-g09d2 From 9dac16e448a399b154e4a981be9dc0ad065bdb08 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Thu, 2 Jul 2020 15:46:16 +0100 Subject: usb: host: ohci: Mark cc_to_error as __maybe_unused MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit drivers/usb/host/ohci.h in included by a whole much of different sourcefiles. Not all of them make use of cc_to_error. So mark it as __maybe_used to convey that this behaviour is not only acceptable it's expected. Fixes the following kernel build warning(s): In file included from drivers/usb/host/ohci-pci.c:25: drivers/usb/host/ohci.h:165:18: warning: ‘cc_to_error’ defined but not used [-Wunused-const-variable=] 165 | static const int cc_to_error 1 = { | ^~~~~~~~~~~ In file included from drivers/usb/host/ohci-platform.c:32: drivers/usb/host/ohci.h:165:18: warning: ‘cc_to_error’ defined but not used [-Wunused-const-variable=] 165 | static const int cc_to_error 1 = { | ^~~~~~~~~~~ In file included from drivers/usb/host/ohci-exynos.c:20: drivers/usb/host/ohci.h:165:18: warning: ‘cc_to_error’ defined but not used [-Wunused-const-variable=] 165 | static const int cc_to_error 1 = { | ^~~~~~~~~~~ In file included from drivers/usb/host/ohci-spear.c:22: drivers/usb/host/ohci.h:165:18: warning: ‘cc_to_error’ defined but not used [-Wunused-const-variable=] 165 | static const int cc_to_error 1 = { | ^~~~~~~~~~~ In file included from drivers/usb/host/ohci-st.c:26: drivers/usb/host/ohci.h:165:18: warning: ‘cc_to_error’ defined but not used [-Wunused-const-variable=] 165 | static const int cc_to_error 1 = { | ^~~~~~~~~~~ In file included from drivers/usb/host/ohci-at91.c:31: drivers/usb/host/ohci.h:165:18: warning: ‘cc_to_error’ defined but not used [-Wunused-const-variable=] 165 | static const int cc_to_error 1 = { | ^~~~~~~~~~~ In file included from drivers/usb/host/ohci-s3c2410.c:32: drivers/usb/host/ohci.h:165:18: warning: ‘cc_to_error’ defined but not used [-Wunused-const-variable=] 165 | static const int cc_to_error 1 = { | ^~~~~~~~~~~ Cc: Alan Stern Cc: Roman Weissgaerber Cc: David Brownell Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20200702144625.2533530-22-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/ohci.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/usb') diff --git a/drivers/usb/host/ohci.h b/drivers/usb/host/ohci.h index b85a39588f9d..aac6285b37f8 100644 --- a/drivers/usb/host/ohci.h +++ b/drivers/usb/host/ohci.h @@ -162,7 +162,7 @@ struct td { /* map OHCI TD status codes (CC) to errno values */ -static const int cc_to_error [16] = { +static const int __maybe_unused cc_to_error [16] = { /* No Error */ 0, /* CRC Error */ -EILSEQ, /* Bit Stuff */ -EPROTO, -- cgit v1.2.3-70-g09d2 From ff5e445e8533ec87fcf01f260ab8ee405efc3a9a Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Thu, 2 Jul 2020 15:46:17 +0100 Subject: usb: cdns3: ep0: Move 'zlp' description to appropriate function header 'zlp' was documented, but in the wrong place. Fixes the following W=1 kernel build warning(s): drivers/usb/cdns3/ep0.c:36: warning: Function parameter or member 'zlp' not described in 'cdns3_ep0_run_transfer' drivers/usb/cdns3/ep0.c:705: warning: Excess function parameter 'zlp' description in 'cdns3_gadget_ep0_queue' Cc: Pawel Laszczak Cc: Pawel Jez Cc: Peter Chen Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20200702144625.2533530-23-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/cdns3/ep0.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/usb') diff --git a/drivers/usb/cdns3/ep0.c b/drivers/usb/cdns3/ep0.c index b7e78146ba64..11ba0c5b3a8e 100644 --- a/drivers/usb/cdns3/ep0.c +++ b/drivers/usb/cdns3/ep0.c @@ -29,6 +29,7 @@ static struct usb_endpoint_descriptor cdns3_gadget_ep0_desc = { * @length: data length * @erdy: set it to 1 when ERDY packet should be sent - * exit from flow control state + * @zlp: add zero length packet */ static void cdns3_ep0_run_transfer(struct cdns3_device *priv_dev, dma_addr_t dma_addr, @@ -696,7 +697,6 @@ static int cdns3_gadget_ep0_set_halt(struct usb_ep *ep, int value) * @ep: pointer to endpoint zero object * @request: pointer to request object * @gfp_flags: gfp flags - * @zlp: add zero length packet * * Returns 0 on success, error code elsewhere */ -- cgit v1.2.3-70-g09d2 From 8709e36729ef540dc5615c3392667547fe0d1ed5 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Thu, 2 Jul 2020 15:46:20 +0100 Subject: usb: mtu3: mtu3_core: Demote obvious misuse of kerneldoc to standard comment block No attempt has been made to document the function. Fixes the following W=1 kernel build warning(s): drivers/usb/mtu3/mtu3_core.c:805: warning: Function parameter or member 'mtu' not described in 'mtu3_set_dma_mask' Cc: Chunfeng Yun Cc: linux-arm-kernel@lists.infradead.org Cc: linux-mediatek@lists.infradead.org Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20200702144625.2533530-26-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/mtu3/mtu3_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/usb') diff --git a/drivers/usb/mtu3/mtu3_core.c b/drivers/usb/mtu3/mtu3_core.c index 9dd02160cca9..6d515eb67ea7 100644 --- a/drivers/usb/mtu3/mtu3_core.c +++ b/drivers/usb/mtu3/mtu3_core.c @@ -797,7 +797,7 @@ static void mtu3_hw_exit(struct mtu3 *mtu) mtu3_mem_free(mtu); } -/** +/* * we set 32-bit DMA mask by default, here check whether the controller * supports 36-bit DMA or not, if it does, set 36-bit DMA mask. */ -- cgit v1.2.3-70-g09d2 From b5993881e27c01f38ae6f827c59ef8dec4c1bddc Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Thu, 2 Jul 2020 15:46:21 +0100 Subject: usb: c67x00: c67x00-ll-hpi: Demote obvious misuse of kerneldoc to standard comment blocks No attempt has been made to document any of the functions here. Fixes the following W=1 kernel build warning(s): drivers/usb/c67x00/c67x00-ll-hpi.c:269: warning: Function parameter or member 'sie' not described in 'c67x00_ll_usb_clear_status' drivers/usb/c67x00/c67x00-ll-hpi.c:269: warning: Function parameter or member 'bits' not described in 'c67x00_ll_usb_clear_status' drivers/usb/c67x00/c67x00-ll-hpi.c:404: warning: Function parameter or member 'dev' not described in 'c67x00_ll_write_mem_le16' drivers/usb/c67x00/c67x00-ll-hpi.c:404: warning: Function parameter or member 'addr' not described in 'c67x00_ll_write_mem_le16' drivers/usb/c67x00/c67x00-ll-hpi.c:404: warning: Function parameter or member 'data' not described in 'c67x00_ll_write_mem_le16' drivers/usb/c67x00/c67x00-ll-hpi.c:404: warning: Function parameter or member 'len' not described in 'c67x00_ll_write_mem_le16' drivers/usb/c67x00/c67x00-ll-hpi.c:443: warning: Function parameter or member 'dev' not described in 'c67x00_ll_read_mem_le16' drivers/usb/c67x00/c67x00-ll-hpi.c:443: warning: Function parameter or member 'addr' not described in 'c67x00_ll_read_mem_le16' drivers/usb/c67x00/c67x00-ll-hpi.c:443: warning: Function parameter or member 'data' not described in 'c67x00_ll_read_mem_le16' drivers/usb/c67x00/c67x00-ll-hpi.c:443: warning: Function parameter or member 'len' not described in 'c67x00_ll_read_mem_le16' Cc: Peter Korsgaard Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20200702144625.2533530-27-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/c67x00/c67x00-ll-hpi.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/c67x00/c67x00-ll-hpi.c b/drivers/usb/c67x00/c67x00-ll-hpi.c index e1fe3603140a..7a214a3a6cc7 100644 --- a/drivers/usb/c67x00/c67x00-ll-hpi.c +++ b/drivers/usb/c67x00/c67x00-ll-hpi.c @@ -262,7 +262,7 @@ u16 c67x00_ll_get_usb_ctl(struct c67x00_sie *sie) return hpi_read_word(sie->dev, USB_CTL_REG(sie->sie_num)); } -/** +/* * c67x00_ll_usb_clear_status - clear the USB status bits */ void c67x00_ll_usb_clear_status(struct c67x00_sie *sie, u16 bits) @@ -395,7 +395,7 @@ int c67x00_ll_reset(struct c67x00_device *dev) /* -------------------------------------------------------------------------- */ -/** +/* * c67x00_ll_write_mem_le16 - write into c67x00 memory * Only data is little endian, addr has cpu endianess. */ @@ -434,7 +434,7 @@ void c67x00_ll_write_mem_le16(struct c67x00_device *dev, u16 addr, } } -/** +/* * c67x00_ll_read_mem_le16 - read from c67x00 memory * Only data is little endian, addr has cpu endianess. */ -- cgit v1.2.3-70-g09d2 From aa37c246f292b1fe7e5cd3767188ada553a3770f Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Thu, 2 Jul 2020 15:46:24 +0100 Subject: usb: class: usbtmc: File headers are not good candidates for kerneldoc Demote usbtmc's file header to a standard comment block. Fixes the following W=1 kernel build warning(s): drivers/usb/class/usbtmc.c:11: warning: Function parameter or member 'fmt' not described in 'pr_fmt' Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20200702144625.2533530-30-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/class/usbtmc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/usb') diff --git a/drivers/usb/class/usbtmc.c b/drivers/usb/class/usbtmc.c index ffc9c6fdd7e1..4b52758d3a38 100644 --- a/drivers/usb/class/usbtmc.c +++ b/drivers/usb/class/usbtmc.c @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0+ -/** +/* * drivers/usb/class/usbtmc.c - USB Test & Measurement class driver * * Copyright (C) 2007 Stefan Kopp, Gechingen, Germany -- cgit v1.2.3-70-g09d2 From aa88cddf4c9e03224db794168fa34501657ec3d6 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Thu, 2 Jul 2020 15:46:25 +0100 Subject: usb: c67x00: c67x00-sched: Demote obvious misuse of kerneldoc to standard comment blocks No attempt has been made to document any of the functions here. Fixes the following W=1 kernel build warning(s): drivers/usb/c67x00/c67x00-sched.c:35: warning: Function parameter or member 'queue' not described in 'c67x00_ep_data' drivers/usb/c67x00/c67x00-sched.c:35: warning: Function parameter or member 'node' not described in 'c67x00_ep_data' drivers/usb/c67x00/c67x00-sched.c:35: warning: Function parameter or member 'hep' not described in 'c67x00_ep_data' drivers/usb/c67x00/c67x00-sched.c:35: warning: Function parameter or member 'dev' not described in 'c67x00_ep_data' drivers/usb/c67x00/c67x00-sched.c:35: warning: Function parameter or member 'next_frame' not described in 'c67x00_ep_data' drivers/usb/c67x00/c67x00-sched.c:71: warning: Function parameter or member 'ly_base_addr' not described in 'c67x00_td' drivers/usb/c67x00/c67x00-sched.c:71: warning: Function parameter or member 'port_length' not described in 'c67x00_td' drivers/usb/c67x00/c67x00-sched.c:71: warning: Function parameter or member 'pid_ep' not described in 'c67x00_td' drivers/usb/c67x00/c67x00-sched.c:71: warning: Function parameter or member 'dev_addr' not described in 'c67x00_td' drivers/usb/c67x00/c67x00-sched.c:71: warning: Function parameter or member 'ctrl_reg' not described in 'c67x00_td' drivers/usb/c67x00/c67x00-sched.c:71: warning: Function parameter or member 'status' not described in 'c67x00_td' drivers/usb/c67x00/c67x00-sched.c:71: warning: Function parameter or member 'retry_cnt' not described in 'c67x00_td' drivers/usb/c67x00/c67x00-sched.c:71: warning: Function parameter or member 'residue' not described in 'c67x00_td' drivers/usb/c67x00/c67x00-sched.c:71: warning: Function parameter or member 'next_td_addr' not described in 'c67x00_td' drivers/usb/c67x00/c67x00-sched.c:71: warning: Function parameter or member 'td_list' not described in 'c67x00_td' drivers/usb/c67x00/c67x00-sched.c:71: warning: Function parameter or member 'td_addr' not described in 'c67x00_td' drivers/usb/c67x00/c67x00-sched.c:71: warning: Function parameter or member 'data' not described in 'c67x00_td' drivers/usb/c67x00/c67x00-sched.c:71: warning: Function parameter or member 'urb' not described in 'c67x00_td' drivers/usb/c67x00/c67x00-sched.c:71: warning: Function parameter or member 'privdata' not described in 'c67x00_td' drivers/usb/c67x00/c67x00-sched.c:71: warning: Function parameter or member 'ep_data' not described in 'c67x00_td' drivers/usb/c67x00/c67x00-sched.c:71: warning: Function parameter or member 'pipe' not described in 'c67x00_td' drivers/usb/c67x00/c67x00-sched.c:137: warning: Function parameter or member 'c67x00' not described in 'dbg_td' drivers/usb/c67x00/c67x00-sched.c:137: warning: Function parameter or member 'td' not described in 'dbg_td' drivers/usb/c67x00/c67x00-sched.c:137: warning: Function parameter or member 'msg' not described in 'dbg_td' drivers/usb/c67x00/c67x00-sched.c:169: warning: Function parameter or member 'a' not described in 'frame_add' drivers/usb/c67x00/c67x00-sched.c:169: warning: Function parameter or member 'b' not described in 'frame_add' drivers/usb/c67x00/c67x00-sched.c:177: warning: Function parameter or member 'a' not described in 'frame_after' drivers/usb/c67x00/c67x00-sched.c:177: warning: Function parameter or member 'b' not described in 'frame_after' drivers/usb/c67x00/c67x00-sched.c:186: warning: Function parameter or member 'a' not described in 'frame_after_eq' drivers/usb/c67x00/c67x00-sched.c:186: warning: Function parameter or member 'b' not described in 'frame_after_eq' drivers/usb/c67x00/c67x00-sched.c:199: warning: Function parameter or member 'c67x00' not described in 'c67x00_release_urb' drivers/usb/c67x00/c67x00-sched.c:199: warning: Function parameter or member 'urb' not described in 'c67x00_release_urb' drivers/usb/c67x00/c67x00-sched.c:566: warning: Function parameter or member 'c67x00' not described in 'c67x00_create_td' drivers/usb/c67x00/c67x00-sched.c:566: warning: Function parameter or member 'urb' not described in 'c67x00_create_td' drivers/usb/c67x00/c67x00-sched.c:566: warning: Function parameter or member 'data' not described in 'c67x00_create_td' drivers/usb/c67x00/c67x00-sched.c:566: warning: Function parameter or member 'len' not described in 'c67x00_create_td' drivers/usb/c67x00/c67x00-sched.c:566: warning: Function parameter or member 'pid' not described in 'c67x00_create_td' drivers/usb/c67x00/c67x00-sched.c:566: warning: Function parameter or member 'toggle' not described in 'c67x00_create_td' drivers/usb/c67x00/c67x00-sched.c:566: warning: Function parameter or member 'privdata' not described in 'c67x00_create_td' drivers/usb/c67x00/c67x00-sched.c:692: warning: Function parameter or member 'c67x00' not described in 'c67x00_add_ctrl_urb' drivers/usb/c67x00/c67x00-sched.c:692: warning: Function parameter or member 'urb' not described in 'c67x00_add_ctrl_urb' drivers/usb/c67x00/c67x00-sched.c:830: warning: Function parameter or member 'c67x00' not described in 'c67x00_parse_td' drivers/usb/c67x00/c67x00-sched.c:830: warning: Function parameter or member 'td' not described in 'c67x00_parse_td' drivers/usb/c67x00/c67x00-sched.c:978: warning: Function parameter or member 'c67x00' not described in 'c67x00_check_td_list' drivers/usb/c67x00/c67x00-sched.c:1052: warning: Function parameter or member 'c67x00' not described in 'c67x00_send_td' drivers/usb/c67x00/c67x00-sched.c:1052: warning: Function parameter or member 'td' not described in 'c67x00_send_td' drivers/usb/c67x00/c67x00-sched.c:1088: warning: Function parameter or member 'c67x00' not described in 'c67x00_do_work' Cc: Peter Korsgaard Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20200702144625.2533530-31-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/c67x00/c67x00-sched.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/c67x00/c67x00-sched.c b/drivers/usb/c67x00/c67x00-sched.c index 633c52de3bb3..ef1e4ecaee99 100644 --- a/drivers/usb/c67x00/c67x00-sched.c +++ b/drivers/usb/c67x00/c67x00-sched.c @@ -23,7 +23,7 @@ /* -------------------------------------------------------------------------- */ -/** +/* * struct c67x00_ep_data: Host endpoint data structure */ struct c67x00_ep_data { @@ -34,7 +34,7 @@ struct c67x00_ep_data { u16 next_frame; /* For int/isoc transactions */ }; -/** +/* * struct c67x00_td * * Hardware parts are little endiannes, SW in CPU endianess. @@ -130,7 +130,7 @@ struct c67x00_urb_priv { /* -------------------------------------------------------------------------- */ -/** +/* * dbg_td - Dump the contents of the TD */ static void dbg_td(struct c67x00_hcd *c67x00, struct c67x00_td *td, char *msg) @@ -161,7 +161,7 @@ static inline u16 c67x00_get_current_frame_number(struct c67x00_hcd *c67x00) return c67x00_ll_husb_get_frame(c67x00->sie) & HOST_FRAME_MASK; } -/** +/* * frame_add * Software wraparound for framenumbers. */ @@ -170,7 +170,7 @@ static inline u16 frame_add(u16 a, u16 b) return (a + b) & HOST_FRAME_MASK; } -/** +/* * frame_after - is frame a after frame b */ static inline int frame_after(u16 a, u16 b) @@ -179,7 +179,7 @@ static inline int frame_after(u16 a, u16 b) (HOST_FRAME_MASK / 2); } -/** +/* * frame_after_eq - is frame a after or equal to frame b */ static inline int frame_after_eq(u16 a, u16 b) @@ -190,7 +190,7 @@ static inline int frame_after_eq(u16 a, u16 b) /* -------------------------------------------------------------------------- */ -/** +/* * c67x00_release_urb - remove link from all tds to this urb * Disconnects the urb from it's tds, so that it can be given back. * pre: urb->hcpriv != NULL @@ -557,7 +557,7 @@ static int c67x00_claim_frame_bw(struct c67x00_hcd *c67x00, struct urb *urb, /* -------------------------------------------------------------------------- */ -/** +/* * td_addr and buf_addr must be word aligned */ static int c67x00_create_td(struct c67x00_hcd *c67x00, struct urb *urb, @@ -685,7 +685,7 @@ static int c67x00_add_data_urb(struct c67x00_hcd *c67x00, struct urb *urb) return 0; } -/** +/* * return 0 in case more bandwidth is available, else errorcode */ static int c67x00_add_ctrl_urb(struct c67x00_hcd *c67x00, struct urb *urb) @@ -822,7 +822,7 @@ static void c67x00_fill_frame(struct c67x00_hcd *c67x00) /* -------------------------------------------------------------------------- */ -/** +/* * Get TD from C67X00 */ static inline void @@ -970,7 +970,7 @@ static void c67x00_handle_isoc(struct c67x00_hcd *c67x00, struct c67x00_td *td) /* -------------------------------------------------------------------------- */ -/** +/* * c67x00_check_td_list - handle tds which have been processed by the c67x00 * pre: current_td == 0 */ @@ -1045,7 +1045,7 @@ static inline int c67x00_all_tds_processed(struct c67x00_hcd *c67x00) return !c67x00_ll_husb_get_current_td(c67x00->sie); } -/** +/* * Send td to C67X00 */ static void c67x00_send_td(struct c67x00_hcd *c67x00, struct c67x00_td *td) @@ -1081,7 +1081,7 @@ static void c67x00_send_frame(struct c67x00_hcd *c67x00) /* -------------------------------------------------------------------------- */ -/** +/* * c67x00_do_work - Schedulers state machine */ static void c67x00_do_work(struct c67x00_hcd *c67x00) -- cgit v1.2.3-70-g09d2 From 6181aa1bc446e2fa48ed4f2ff97a4e0503c8931b Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Thu, 2 Jul 2020 15:46:18 +0100 Subject: usb: host: oxu210hp-hcd: Move declaration of 'qtd' into 'ifdef OXU_URB_TRACE' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If we assign 'epnum' during the declaration we can also avoid "ISO C90 forbids mixed declarations" issues. So it does looks like we can have our cake and eat it in this scenario. Fixes the following W=1 kernel build warning(s): drivers/usb/host/oxu210hp-hcd.c: In function ‘submit_async’: drivers/usb/host/oxu210hp-hcd.c:2040:19: warning: variable ‘qtd’ set but not used [-Wunused-but-set-variable] 2040 | struct ehci_qtd *qtd; | ^~~ Cc: Masahiro Yamada Cc: Rodolfo Giometti Cc: "Eurotech S.p.A" Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20200702144625.2533530-24-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/oxu210hp-hcd.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/host/oxu210hp-hcd.c b/drivers/usb/host/oxu210hp-hcd.c index 120666a0d590..b00673295c9f 100644 --- a/drivers/usb/host/oxu210hp-hcd.c +++ b/drivers/usb/host/oxu210hp-hcd.c @@ -2037,16 +2037,15 @@ static struct ehci_qh *qh_append_tds(struct oxu_hcd *oxu, static int submit_async(struct oxu_hcd *oxu, struct urb *urb, struct list_head *qtd_list, gfp_t mem_flags) { - struct ehci_qtd *qtd; - int epnum; + int epnum = urb->ep->desc.bEndpointAddress; unsigned long flags; struct ehci_qh *qh = NULL; int rc = 0; +#ifdef OXU_URB_TRACE + struct ehci_qtd *qtd; qtd = list_entry(qtd_list->next, struct ehci_qtd, qtd_list); - epnum = urb->ep->desc.bEndpointAddress; -#ifdef OXU_URB_TRACE oxu_dbg(oxu, "%s %s urb %p ep%d%s len %d, qtd %p [qh %p]\n", __func__, urb->dev->devpath, urb, epnum & 0x0f, (epnum & USB_DIR_IN) ? "in" : "out", -- cgit v1.2.3-70-g09d2 From cc72a2ca1f2ab075d56fc38ba941c4240968f963 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Thu, 2 Jul 2020 09:29:13 +0200 Subject: USB: phy: fsl-usb: remove sysfs abuse This file has a HUGE debugging sysfs file that spews out a lot of information all at once, which violates the one-value-per-file rule for sysfs. If this is really needed, it should go into debugfs, but given the age of this driver, I strongly doubt anyone is using it anymore. So just remove the file entirely, it was never documented, so obviously, no one actually needed it :) Cc: Felipe Balbi Reviewed-by: Ran Wang Link: https://lore.kernel.org/r/20200702072914.1072878-1-gregkh@linuxfoundation.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/phy/phy-fsl-usb.c | 93 ------------------------------------------- 1 file changed, 93 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/phy/phy-fsl-usb.c b/drivers/usb/phy/phy-fsl-usb.c index b451f4695f3f..93d2257aeec8 100644 --- a/drivers/usb/phy/phy-fsl-usb.c +++ b/drivers/usb/phy/phy-fsl-usb.c @@ -957,98 +957,6 @@ int usb_otg_start(struct platform_device *pdev) return 0; } -/* - * state file in sysfs - */ -static ssize_t show_fsl_usb2_otg_state(struct device *dev, - struct device_attribute *attr, char *buf) -{ - struct otg_fsm *fsm = &fsl_otg_dev->fsm; - char *next = buf; - unsigned size = PAGE_SIZE; - int t; - - mutex_lock(&fsm->lock); - - /* basic driver infomation */ - t = scnprintf(next, size, - DRIVER_DESC "\n" "fsl_usb2_otg version: %s\n\n", - DRIVER_VERSION); - size -= t; - next += t; - - /* Registers */ - t = scnprintf(next, size, - "OTGSC: 0x%08x\n" - "PORTSC: 0x%08x\n" - "USBMODE: 0x%08x\n" - "USBCMD: 0x%08x\n" - "USBSTS: 0x%08x\n" - "USBINTR: 0x%08x\n", - fsl_readl(&usb_dr_regs->otgsc), - fsl_readl(&usb_dr_regs->portsc), - fsl_readl(&usb_dr_regs->usbmode), - fsl_readl(&usb_dr_regs->usbcmd), - fsl_readl(&usb_dr_regs->usbsts), - fsl_readl(&usb_dr_regs->usbintr)); - size -= t; - next += t; - - /* State */ - t = scnprintf(next, size, - "OTG state: %s\n\n", - usb_otg_state_string(fsl_otg_dev->phy.otg->state)); - size -= t; - next += t; - - /* State Machine Variables */ - t = scnprintf(next, size, - "a_bus_req: %d\n" - "b_bus_req: %d\n" - "a_bus_resume: %d\n" - "a_bus_suspend: %d\n" - "a_conn: %d\n" - "a_sess_vld: %d\n" - "a_srp_det: %d\n" - "a_vbus_vld: %d\n" - "b_bus_resume: %d\n" - "b_bus_suspend: %d\n" - "b_conn: %d\n" - "b_se0_srp: %d\n" - "b_ssend_srp: %d\n" - "b_sess_vld: %d\n" - "id: %d\n", - fsm->a_bus_req, - fsm->b_bus_req, - fsm->a_bus_resume, - fsm->a_bus_suspend, - fsm->a_conn, - fsm->a_sess_vld, - fsm->a_srp_det, - fsm->a_vbus_vld, - fsm->b_bus_resume, - fsm->b_bus_suspend, - fsm->b_conn, - fsm->b_se0_srp, - fsm->b_ssend_srp, - fsm->b_sess_vld, - fsm->id); - size -= t; - next += t; - - mutex_unlock(&fsm->lock); - - return PAGE_SIZE - size; -} - -static DEVICE_ATTR(fsl_usb2_otg_state, S_IRUGO, show_fsl_usb2_otg_state, NULL); - -static struct attribute *fsl_otg_attrs[] = { - &dev_attr_fsl_usb2_otg_state.attr, - NULL, -}; -ATTRIBUTE_GROUPS(fsl_otg); - /* Char driver interface to control some OTG input */ /* @@ -1167,7 +1075,6 @@ struct platform_driver fsl_otg_driver = { .driver = { .name = driver_name, .owner = THIS_MODULE, - .dev_groups = fsl_otg_groups, }, }; -- cgit v1.2.3-70-g09d2 From 8c4a09cb1bfb84eb4acc88eb5eb5709b76403f9e Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Thu, 2 Jul 2020 09:29:14 +0200 Subject: USB: phy: fsl-usb: remove character device usage No idea why this driver is using a char device node, statically allocated, with no dynamic allocation or hook up with devtmpfs, along with a reserverd major number, for "special" operations, not all of which ever were implemented. So just rip it out, as no one must be using it because no modern system will ever actually create the /dev/ node it needs. Cc: Felipe Balbi Reviewed-by: Ran Wang Signed-off-by: Greg Kroah-Hartman Link: https://lore.kernel.org/r/20200702072914.1072878-2-gregkh@linuxfoundation.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/phy/phy-fsl-usb.c | 69 ------------------------------------------- drivers/usb/phy/phy-fsl-usb.h | 14 --------- 2 files changed, 83 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/phy/phy-fsl-usb.c b/drivers/usb/phy/phy-fsl-usb.c index 93d2257aeec8..0c6d9f9f2994 100644 --- a/drivers/usb/phy/phy-fsl-usb.c +++ b/drivers/usb/phy/phy-fsl-usb.c @@ -957,67 +957,6 @@ int usb_otg_start(struct platform_device *pdev) return 0; } -/* Char driver interface to control some OTG input */ - -/* - * Handle some ioctl command, such as get otg - * status and set host suspend - */ -static long fsl_otg_ioctl(struct file *file, unsigned int cmd, - unsigned long arg) -{ - u32 retval = 0; - - switch (cmd) { - case GET_OTG_STATUS: - retval = fsl_otg_dev->host_working; - break; - - case SET_A_SUSPEND_REQ: - fsl_otg_dev->fsm.a_suspend_req_inf = arg; - break; - - case SET_A_BUS_DROP: - fsl_otg_dev->fsm.a_bus_drop = arg; - break; - - case SET_A_BUS_REQ: - fsl_otg_dev->fsm.a_bus_req = arg; - break; - - case SET_B_BUS_REQ: - fsl_otg_dev->fsm.b_bus_req = arg; - break; - - default: - break; - } - - otg_statemachine(&fsl_otg_dev->fsm); - - return retval; -} - -static int fsl_otg_open(struct inode *inode, struct file *file) -{ - return 0; -} - -static int fsl_otg_release(struct inode *inode, struct file *file) -{ - return 0; -} - -static const struct file_operations otg_fops = { - .owner = THIS_MODULE, - .llseek = NULL, - .read = NULL, - .write = NULL, - .unlocked_ioctl = fsl_otg_ioctl, - .open = fsl_otg_open, - .release = fsl_otg_release, -}; - static int fsl_otg_probe(struct platform_device *pdev) { int ret; @@ -1039,12 +978,6 @@ static int fsl_otg_probe(struct platform_device *pdev) return ret; } - ret = register_chrdev(FSL_OTG_MAJOR, FSL_OTG_NAME, &otg_fops); - if (ret) { - dev_err(&pdev->dev, "unable to register FSL OTG device\n"); - return ret; - } - return ret; } @@ -1061,8 +994,6 @@ static int fsl_otg_remove(struct platform_device *pdev) kfree(fsl_otg_dev->phy.otg); kfree(fsl_otg_dev); - unregister_chrdev(FSL_OTG_MAJOR, FSL_OTG_NAME); - if (pdata->exit) pdata->exit(pdev); diff --git a/drivers/usb/phy/phy-fsl-usb.h b/drivers/usb/phy/phy-fsl-usb.h index fbcc28ad9964..d70341ae5a92 100644 --- a/drivers/usb/phy/phy-fsl-usb.h +++ b/drivers/usb/phy/phy-fsl-usb.h @@ -371,21 +371,7 @@ struct fsl_otg_config { u8 otg_port; }; -/* For SRP and HNP handle */ -#define FSL_OTG_MAJOR 240 #define FSL_OTG_NAME "fsl-usb2-otg" -/* Command to OTG driver ioctl */ -#define OTG_IOCTL_MAGIC FSL_OTG_MAJOR -/* if otg work as host, it should return 1, otherwise return 0 */ -#define GET_OTG_STATUS _IOR(OTG_IOCTL_MAGIC, 1, int) -#define SET_A_SUSPEND_REQ _IOW(OTG_IOCTL_MAGIC, 2, int) -#define SET_A_BUS_DROP _IOW(OTG_IOCTL_MAGIC, 3, int) -#define SET_A_BUS_REQ _IOW(OTG_IOCTL_MAGIC, 4, int) -#define SET_B_BUS_REQ _IOW(OTG_IOCTL_MAGIC, 5, int) -#define GET_A_SUSPEND_REQ _IOR(OTG_IOCTL_MAGIC, 6, int) -#define GET_A_BUS_DROP _IOR(OTG_IOCTL_MAGIC, 7, int) -#define GET_A_BUS_REQ _IOR(OTG_IOCTL_MAGIC, 8, int) -#define GET_B_BUS_REQ _IOR(OTG_IOCTL_MAGIC, 9, int) void fsl_otg_add_timer(struct otg_fsm *fsm, void *timer); void fsl_otg_del_timer(struct otg_fsm *fsm, void *timer); -- cgit v1.2.3-70-g09d2 From 768a0741284315d3a454f5f4e2fa88f62b5abfe9 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Thu, 2 Jul 2020 15:46:05 +0100 Subject: usb: dwc2: gadget: Remove assigned but never used 'maxsize' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The value of 'maxsize' has not been checked since commit 729cac693eecf ("usb: dwc2: Change ISOC DDMA flow") back in 2018, so remove the set but unused variable, which fixes the following W=1 kernel build warning: drivers/usb/dwc2/gadget.c: In function ‘dwc2_gadget_fill_isoc_desc’: drivers/usb/dwc2/gadget.c:885:6: warning: variable ‘maxsize’ set but not used [-Wunused-but-set-variable] 885 | u32 maxsize = 0; | ^~~~~~~ Cc: Minas Harutyunyan Cc: Ben Dooks Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20200702144625.2533530-11-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/dwc2/gadget.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index 1def9000f936..df5fedaca60a 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -882,11 +882,10 @@ static int dwc2_gadget_fill_isoc_desc(struct dwc2_hsotg_ep *hs_ep, struct dwc2_dma_desc *desc; struct dwc2_hsotg *hsotg = hs_ep->parent; u32 index; - u32 maxsize = 0; u32 mask = 0; u8 pid = 0; - maxsize = dwc2_gadget_get_desc_params(hs_ep, &mask); + dwc2_gadget_get_desc_params(hs_ep, &mask); index = hs_ep->next_desc; desc = &hs_ep->desc_list[index]; -- cgit v1.2.3-70-g09d2 From 0580baa46ef67069217bfeabd511ea036e58c1c0 Mon Sep 17 00:00:00 2001 From: Michael Hanselmann Date: Sat, 4 Jul 2020 20:25:03 +0200 Subject: USB: serial: ch341: simulate break condition if not supported A subset of all CH341 devices don't support a real break condition. This fact is already used in the "ch341_detect_quirks" function. With this change a quirk is implemented to simulate a break condition by temporarily lowering the baud rate and sending a NUL byte. The primary drawbacks of this approach are that the duration of the break can't be controlled by userland and that data incoming during a simulated break is corrupted. The "TTY_DRIVER_HARDWARE_BREAK" serial driver flag was investigated as an alternative. It's a driver-wide flag and would've required significant changes to the serial and USB-serial driver frameworks to expose it for individual USB-serial adapters. Tested by sending a break condition and watching the TX pin using an oscilloscope. Signed-off-by: Michael Hanselmann Link: https://lore.kernel.org/r/f34a9b6e-ec2a-0873-e97b-2d5b2170e2ff@msgid.hansmi.ch [ johan: condense info message ] Signed-off-by: Johan Hovold --- drivers/usb/serial/ch341.c | 102 +++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 93 insertions(+), 9 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/serial/ch341.c b/drivers/usb/serial/ch341.c index 55a1c6dbeeb2..011d7953f087 100644 --- a/drivers/usb/serial/ch341.c +++ b/drivers/usb/serial/ch341.c @@ -78,6 +78,7 @@ #define CH341_LCR_CS5 0x00 #define CH341_QUIRK_LIMITED_PRESCALER BIT(0) +#define CH341_QUIRK_SIMULATE_BREAK BIT(1) static const struct usb_device_id id_table[] = { { USB_DEVICE(0x4348, 0x5523) }, @@ -94,6 +95,7 @@ struct ch341_private { u8 msr; u8 lcr; unsigned long quirks; + unsigned long break_end; }; static void ch341_set_termios(struct tty_struct *tty, @@ -170,10 +172,9 @@ static const speed_t ch341_min_rates[] = { * 2 <= div <= 256 if fact = 0, or * 9 <= div <= 256 if fact = 1 */ -static int ch341_get_divisor(struct ch341_private *priv) +static int ch341_get_divisor(struct ch341_private *priv, speed_t speed) { unsigned int fact, div, clk_div; - speed_t speed = priv->baud_rate; bool force_fact0 = false; int ps; @@ -236,15 +237,16 @@ static int ch341_get_divisor(struct ch341_private *priv) } static int ch341_set_baudrate_lcr(struct usb_device *dev, - struct ch341_private *priv, u8 lcr) + struct ch341_private *priv, + speed_t baud_rate, u8 lcr) { int val; int r; - if (!priv->baud_rate) + if (!baud_rate) return -EINVAL; - val = ch341_get_divisor(priv); + val = ch341_get_divisor(priv, baud_rate); if (val < 0) return -EINVAL; @@ -324,7 +326,7 @@ static int ch341_configure(struct usb_device *dev, struct ch341_private *priv) if (r < 0) goto out; - r = ch341_set_baudrate_lcr(dev, priv, priv->lcr); + r = ch341_set_baudrate_lcr(dev, priv, priv->baud_rate, priv->lcr); if (r < 0) goto out; @@ -357,8 +359,8 @@ static int ch341_detect_quirks(struct usb_serial_port *port) USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, CH341_REG_BREAK, 0, buffer, size, DEFAULT_TIMEOUT); if (r == -EPIPE) { - dev_dbg(&port->dev, "break control not supported\n"); - quirks = CH341_QUIRK_LIMITED_PRESCALER; + dev_info(&port->dev, "break control not supported, using simulated break\n"); + quirks = CH341_QUIRK_LIMITED_PRESCALER | CH341_QUIRK_SIMULATE_BREAK; r = 0; goto out; } @@ -539,7 +541,8 @@ static void ch341_set_termios(struct tty_struct *tty, if (baud_rate) { priv->baud_rate = baud_rate; - r = ch341_set_baudrate_lcr(port->serial->dev, priv, lcr); + r = ch341_set_baudrate_lcr(port->serial->dev, priv, + priv->baud_rate, lcr); if (r < 0 && old_termios) { priv->baud_rate = tty_termios_baud_rate(old_termios); tty_termios_copy_hw(&tty->termios, old_termios); @@ -558,15 +561,96 @@ static void ch341_set_termios(struct tty_struct *tty, ch341_set_handshake(port->serial->dev, priv->mcr); } +/* + * A subset of all CH34x devices don't support a real break condition and + * reading CH341_REG_BREAK fails (see also ch341_detect_quirks). This function + * simulates a break condition by lowering the baud rate to the minimum + * supported by the hardware upon enabling the break condition and sending + * a NUL byte. + * + * Incoming data is corrupted while the break condition is being simulated. + * + * Normally the duration of the break condition can be controlled individually + * by userspace using TIOCSBRK and TIOCCBRK or by passing an argument to + * TCSBRKP. Due to how the simulation is implemented the duration can't be + * controlled. The duration is always about (1s / 46bd * 9bit) = 196ms. + */ +static void ch341_simulate_break(struct tty_struct *tty, int break_state) +{ + struct usb_serial_port *port = tty->driver_data; + struct ch341_private *priv = usb_get_serial_port_data(port); + unsigned long now, delay; + int r; + + if (break_state != 0) { + dev_dbg(&port->dev, "enter break state requested\n"); + + r = ch341_set_baudrate_lcr(port->serial->dev, priv, + CH341_MIN_BPS, + CH341_LCR_ENABLE_RX | CH341_LCR_ENABLE_TX | CH341_LCR_CS8); + if (r < 0) { + dev_err(&port->dev, + "failed to change baud rate to %u: %d\n", + CH341_MIN_BPS, r); + goto restore; + } + + r = tty_put_char(tty, '\0'); + if (r < 0) { + dev_err(&port->dev, + "failed to write NUL byte for simulated break condition: %d\n", + r); + goto restore; + } + + /* + * Compute expected transmission duration and add a single bit + * of safety margin (the actual NUL byte transmission is 8 bits + * plus one stop bit). + */ + priv->break_end = jiffies + (10 * HZ / CH341_MIN_BPS); + + return; + } + + dev_dbg(&port->dev, "leave break state requested\n"); + + now = jiffies; + + if (time_before(now, priv->break_end)) { + /* Wait until NUL byte is written */ + delay = priv->break_end - now; + dev_dbg(&port->dev, + "wait %d ms while transmitting NUL byte at %u baud\n", + jiffies_to_msecs(delay), CH341_MIN_BPS); + schedule_timeout_interruptible(delay); + } + +restore: + /* Restore original baud rate */ + r = ch341_set_baudrate_lcr(port->serial->dev, priv, priv->baud_rate, + priv->lcr); + if (r < 0) + dev_err(&port->dev, + "restoring original baud rate of %u failed: %d\n", + priv->baud_rate, r); +} + static void ch341_break_ctl(struct tty_struct *tty, int break_state) { const uint16_t ch341_break_reg = ((uint16_t) CH341_REG_LCR << 8) | CH341_REG_BREAK; struct usb_serial_port *port = tty->driver_data; + struct ch341_private *priv = usb_get_serial_port_data(port); int r; uint16_t reg_contents; uint8_t *break_reg; + if (priv->quirks & CH341_QUIRK_SIMULATE_BREAK) { + ch341_simulate_break(tty, break_state); + return; + } + break_reg = kmalloc(2, GFP_KERNEL); if (!break_reg) return; -- cgit v1.2.3-70-g09d2 From 4387b3dbb079d482d3c2b43a703ceed4dd27ed28 Mon Sep 17 00:00:00 2001 From: Brant Merryman Date: Fri, 26 Jun 2020 04:22:58 +0000 Subject: USB: serial: cp210x: enable usb generic throttle/unthrottle Assign the .throttle and .unthrottle functions to be generic function in the driver structure to prevent data loss that can otherwise occur if the host does not enable USB throttling. Signed-off-by: Brant Merryman Co-developed-by: Phu Luu Signed-off-by: Phu Luu Link: https://lore.kernel.org/r/57401AF3-9961-461F-95E1-F8AFC2105F5E@silabs.com [ johan: fix up tags ] Fixes: 39a66b8d22a3 ("[PATCH] USB: CP2101 Add support for flow control") Cc: stable # 2.6.12 Signed-off-by: Johan Hovold --- drivers/usb/serial/cp210x.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers/usb') diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c index f5143eedbc48..bcceb4ad8be0 100644 --- a/drivers/usb/serial/cp210x.c +++ b/drivers/usb/serial/cp210x.c @@ -272,6 +272,8 @@ static struct usb_serial_driver cp210x_device = { .break_ctl = cp210x_break_ctl, .set_termios = cp210x_set_termios, .tx_empty = cp210x_tx_empty, + .throttle = usb_serial_generic_throttle, + .unthrottle = usb_serial_generic_unthrottle, .tiocmget = cp210x_tiocmget, .tiocmset = cp210x_tiocmset, .attach = cp210x_attach, -- cgit v1.2.3-70-g09d2 From c7614ff9b73a1e6fb2b1b51396da132ed22fecdb Mon Sep 17 00:00:00 2001 From: Brant Merryman Date: Fri, 26 Jun 2020 04:24:20 +0000 Subject: USB: serial: cp210x: re-enable auto-RTS on open CP210x hardware disables auto-RTS but leaves auto-CTS when in hardware flow control mode and UART on cp210x hardware is disabled. When re-opening the port, if auto-CTS is enabled on the cp210x, then auto-RTS must be re-enabled in the driver. Signed-off-by: Brant Merryman Co-developed-by: Phu Luu Signed-off-by: Phu Luu Link: https://lore.kernel.org/r/ECCF8E73-91F3-4080-BE17-1714BC8818FB@silabs.com [ johan: fix up tags and problem description ] Fixes: 39a66b8d22a3 ("[PATCH] USB: CP2101 Add support for flow control") Cc: stable # 2.6.12 Signed-off-by: Johan Hovold --- drivers/usb/serial/cp210x.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'drivers/usb') diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c index bcceb4ad8be0..a90801ef0055 100644 --- a/drivers/usb/serial/cp210x.c +++ b/drivers/usb/serial/cp210x.c @@ -917,6 +917,7 @@ static void cp210x_get_termios_port(struct usb_serial_port *port, u32 baud; u16 bits; u32 ctl_hs; + u32 flow_repl; cp210x_read_u32_reg(port, CP210X_GET_BAUDRATE, &baud); @@ -1017,6 +1018,22 @@ static void cp210x_get_termios_port(struct usb_serial_port *port, ctl_hs = le32_to_cpu(flow_ctl.ulControlHandshake); if (ctl_hs & CP210X_SERIAL_CTS_HANDSHAKE) { dev_dbg(dev, "%s - flow control = CRTSCTS\n", __func__); + /* + * When the port is closed, the CP210x hardware disables + * auto-RTS and RTS is deasserted but it leaves auto-CTS when + * in hardware flow control mode. When re-opening the port, if + * auto-CTS is enabled on the cp210x, then auto-RTS must be + * re-enabled in the driver. + */ + flow_repl = le32_to_cpu(flow_ctl.ulFlowReplace); + flow_repl &= ~CP210X_SERIAL_RTS_MASK; + flow_repl |= CP210X_SERIAL_RTS_SHIFT(CP210X_SERIAL_RTS_FLOW_CTL); + flow_ctl.ulFlowReplace = cpu_to_le32(flow_repl); + cp210x_write_reg_block(port, + CP210X_SET_FLOW, + &flow_ctl, + sizeof(flow_ctl)); + cflag |= CRTSCTS; } else { dev_dbg(dev, "%s - flow control = NONE\n", __func__); -- cgit v1.2.3-70-g09d2 From 6d0bdc42842a8507c8218244b4ced09ca698d965 Mon Sep 17 00:00:00 2001 From: Michael Hanselmann Date: Tue, 7 Jul 2020 16:53:22 +0200 Subject: USB: serial: ch341: fix missing simulated-break margin On devices which do not support break signalling a break condition is simulated by sending a NUL byte at the lowest possible speed. The break condition will be 9 bit periods long (start bit and eight data bits), but the transmission itself also includes the stop bit. Add the missing safety margin of one bit which is intended to account for timing differences, and fix up the corresponding comment. Signed-off-by: Michael Hanselmann Link: https://lore.kernel.org/r/9909b288-294d-16b9-9f14-51eb79c63b6c@msgid.hansmi.ch [ johan: amend commit message ] Signed-off-by: Johan Hovold --- drivers/usb/serial/ch341.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/serial/ch341.c b/drivers/usb/serial/ch341.c index 011d7953f087..d21427aacee1 100644 --- a/drivers/usb/serial/ch341.c +++ b/drivers/usb/serial/ch341.c @@ -604,11 +604,13 @@ static void ch341_simulate_break(struct tty_struct *tty, int break_state) } /* - * Compute expected transmission duration and add a single bit - * of safety margin (the actual NUL byte transmission is 8 bits - * plus one stop bit). + * Compute expected transmission duration including safety + * margin. The original baud rate is only restored after the + * computed point in time. + * + * 11 bits = 1 start, 8 data, 1 stop, 1 margin */ - priv->break_end = jiffies + (10 * HZ / CH341_MIN_BPS); + priv->break_end = jiffies + (11 * HZ / CH341_MIN_BPS); return; } -- cgit v1.2.3-70-g09d2 From 69f6a918ff4b5a04bf9474fb4c3f9e8c9abd39f1 Mon Sep 17 00:00:00 2001 From: Colton Lewis Date: Tue, 7 Jul 2020 04:52:32 +0000 Subject: usb: correct kernel-doc inconsistency Silence documentation build warning by correcting kernel-doc comment for sub_validate_langid function. ./drivers/usb/gadget/usbstring.c:77: warning: Function parameter or member 'langid' not described in 'usb_validate_langid' ./drivers/usb/gadget/usbstring.c:77: warning: Excess function parameter 'lang' description in 'usb_validate_langid' Signed-off-by: Colton Lewis Link: https://lore.kernel.org/r/20200707045207.235540-1-colton.w.lewis@protonmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/usbstring.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/usb') diff --git a/drivers/usb/gadget/usbstring.c b/drivers/usb/gadget/usbstring.c index 30f889ad3ad2..75f6f99f8173 100644 --- a/drivers/usb/gadget/usbstring.c +++ b/drivers/usb/gadget/usbstring.c @@ -68,7 +68,7 @@ EXPORT_SYMBOL_GPL(usb_gadget_get_string); /** * usb_validate_langid - validate usb language identifiers - * @lang: usb language identifier + * @langid: usb language identifier * * Returns true for valid language identifier, otherwise false. */ -- cgit v1.2.3-70-g09d2 From 74b76256f3d9096431556e2afdc60027b81f41b2 Mon Sep 17 00:00:00 2001 From: "Gustavo A. R. Silva" Date: Tue, 7 Jul 2020 14:57:47 -0500 Subject: USB: serial: use fallthrough pseudo-keyword Replace the existing /* fall through */ comments and its variants with the new pseudo-keyword macro fallthrough[1]. Also, remove unnecessary fall-through markings when it is the case. [1] https://www.kernel.org/doc/html/latest/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through Signed-off-by: Gustavo A. R. Silva Signed-off-by: Johan Hovold --- drivers/usb/serial/cypress_m8.c | 4 ++-- drivers/usb/serial/io_edgeport.c | 4 ++-- drivers/usb/serial/kobil_sct.c | 2 +- drivers/usb/serial/upd78f0730.c | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/serial/cypress_m8.c b/drivers/usb/serial/cypress_m8.c index 216edd5826ca..53e3051b0a71 100644 --- a/drivers/usb/serial/cypress_m8.c +++ b/drivers/usb/serial/cypress_m8.c @@ -1046,7 +1046,7 @@ static void cypress_read_int_callback(struct urb *urb) return; case -EPIPE: /* Can't call usb_clear_halt while in_interrupt */ - /* FALLS THROUGH */ + fallthrough; default: /* something ugly is going on... */ dev_err(dev, "%s - unexpected nonzero read status received: %d\n", @@ -1195,7 +1195,7 @@ static void cypress_write_int_callback(struct urb *urb) return; case -EPIPE: /* Cannot call usb_clear_halt while in_interrupt */ - /* FALLTHROUGH */ + fallthrough; default: dev_err(dev, "%s - unexpected nonzero write status received: %d\n", __func__, status); diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c index 4cca0b836f43..ba5d8df69518 100644 --- a/drivers/usb/serial/io_edgeport.c +++ b/drivers/usb/serial/io_edgeport.c @@ -1752,7 +1752,7 @@ static void process_rcvd_data(struct edgeport_serial *edge_serial, edge_serial->rxState = EXPECT_HDR2; break; } - /* Fall through */ + fallthrough; case EXPECT_HDR2: edge_serial->rxHeader2 = *buffer; ++buffer; @@ -1804,7 +1804,7 @@ static void process_rcvd_data(struct edgeport_serial *edge_serial, edge_serial->rxState = EXPECT_DATA; break; } - /* Fall through */ + fallthrough; case EXPECT_DATA: /* Expect data */ if (bufferLength < edge_serial->rxBytesRemaining) { rxLen = bufferLength; diff --git a/drivers/usb/serial/kobil_sct.c b/drivers/usb/serial/kobil_sct.c index 79ce0219fdde..49aacb0a327c 100644 --- a/drivers/usb/serial/kobil_sct.c +++ b/drivers/usb/serial/kobil_sct.c @@ -499,7 +499,7 @@ static void kobil_set_termios(struct tty_struct *tty, break; default: speed = 9600; - /* fall through */ + fallthrough; case 9600: urb_val = SUSBCR_SBR_9600; break; diff --git a/drivers/usb/serial/upd78f0730.c b/drivers/usb/serial/upd78f0730.c index 1ba1401d27d7..0a2268c479af 100644 --- a/drivers/usb/serial/upd78f0730.c +++ b/drivers/usb/serial/upd78f0730.c @@ -332,7 +332,7 @@ static void upd78f0730_set_termios(struct tty_struct *tty, tty->termios.c_cflag &= ~CSIZE; tty->termios.c_cflag |= CS8; dev_warn(dev, "data size is not supported, using 8 bits\n"); - /* fall through */ + fallthrough; case CS8: request.params |= UPD78F0730_DATA_SIZE_8_BITS; dev_dbg(dev, "%s - 8 data bits\n", __func__); -- cgit v1.2.3-70-g09d2 From ab4cc4ef6724ea588e835fc1e764c4b4407a70b7 Mon Sep 17 00:00:00 2001 From: Johan Hovold Date: Wed, 8 Jul 2020 14:49:51 +0200 Subject: USB: serial: ftdi_sio: make process-packet buffer unsigned Use an unsigned type for the process-packet buffer argument and give it a more apt name. Reviewed-by: Greg Kroah-Hartman Signed-off-by: Johan Hovold --- drivers/usb/serial/ftdi_sio.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c index 9ad44a96dfe3..96b9e2768ac5 100644 --- a/drivers/usb/serial/ftdi_sio.c +++ b/drivers/usb/serial/ftdi_sio.c @@ -2480,12 +2480,12 @@ static int ftdi_prepare_write_buffer(struct usb_serial_port *port, #define FTDI_RS_ERR_MASK (FTDI_RS_BI | FTDI_RS_PE | FTDI_RS_FE | FTDI_RS_OE) static int ftdi_process_packet(struct usb_serial_port *port, - struct ftdi_private *priv, char *packet, int len) + struct ftdi_private *priv, unsigned char *buf, int len) { + unsigned char status; + unsigned char *ch; int i; - char status; char flag; - char *ch; if (len < 2) { dev_dbg(&port->dev, "malformed packet\n"); @@ -2495,7 +2495,7 @@ static int ftdi_process_packet(struct usb_serial_port *port, /* Compare new line status to the old one, signal if different/ N.B. packet may be processed more than once, but differences are only processed once. */ - status = packet[0] & FTDI_STATUS_B0_MASK; + status = buf[0] & FTDI_STATUS_B0_MASK; if (status != priv->prev_status) { char diff_status = status ^ priv->prev_status; @@ -2521,7 +2521,7 @@ static int ftdi_process_packet(struct usb_serial_port *port, } /* save if the transmitter is empty or not */ - if (packet[1] & FTDI_RS_TEMT) + if (buf[1] & FTDI_RS_TEMT) priv->transmit_empty = 1; else priv->transmit_empty = 0; @@ -2535,29 +2535,29 @@ static int ftdi_process_packet(struct usb_serial_port *port, * data payload to avoid over-reporting. */ flag = TTY_NORMAL; - if (packet[1] & FTDI_RS_ERR_MASK) { + if (buf[1] & FTDI_RS_ERR_MASK) { /* Break takes precedence over parity, which takes precedence * over framing errors */ - if (packet[1] & FTDI_RS_BI) { + if (buf[1] & FTDI_RS_BI) { flag = TTY_BREAK; port->icount.brk++; usb_serial_handle_break(port); - } else if (packet[1] & FTDI_RS_PE) { + } else if (buf[1] & FTDI_RS_PE) { flag = TTY_PARITY; port->icount.parity++; - } else if (packet[1] & FTDI_RS_FE) { + } else if (buf[1] & FTDI_RS_FE) { flag = TTY_FRAME; port->icount.frame++; } /* Overrun is special, not associated with a char */ - if (packet[1] & FTDI_RS_OE) { + if (buf[1] & FTDI_RS_OE) { port->icount.overrun++; tty_insert_flip_char(&port->port, 0, TTY_OVERRUN); } } port->icount.rx += len; - ch = packet + 2; + ch = buf + 2; if (port->port.console && port->sysrq) { for (i = 0; i < len; i++, ch++) { -- cgit v1.2.3-70-g09d2 From ce054039ba5e47b75a3be02a00274e52b06a6456 Mon Sep 17 00:00:00 2001 From: Johan Hovold Date: Wed, 8 Jul 2020 14:49:52 +0200 Subject: USB: serial: ftdi_sio: clean up receive processing Clean up receive processing by dropping the character pointer and keeping the length argument unchanged throughout the function. Also make it more apparent that sysrq processing can consume a characters by adding an explicit continue. Reviewed-by: Greg Kroah-Hartman Signed-off-by: Johan Hovold --- drivers/usb/serial/ftdi_sio.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c index 96b9e2768ac5..33f1cca7eaa6 100644 --- a/drivers/usb/serial/ftdi_sio.c +++ b/drivers/usb/serial/ftdi_sio.c @@ -2483,7 +2483,6 @@ static int ftdi_process_packet(struct usb_serial_port *port, struct ftdi_private *priv, unsigned char *buf, int len) { unsigned char status; - unsigned char *ch; int i; char flag; @@ -2526,8 +2525,7 @@ static int ftdi_process_packet(struct usb_serial_port *port, else priv->transmit_empty = 0; - len -= 2; - if (!len) + if (len == 2) return 0; /* status only */ /* @@ -2556,19 +2554,20 @@ static int ftdi_process_packet(struct usb_serial_port *port, } } - port->icount.rx += len; - ch = buf + 2; + port->icount.rx += len - 2; if (port->port.console && port->sysrq) { - for (i = 0; i < len; i++, ch++) { - if (!usb_serial_handle_sysrq_char(port, *ch)) - tty_insert_flip_char(&port->port, *ch, flag); + for (i = 2; i < len; i++) { + if (usb_serial_handle_sysrq_char(port, buf[i])) + continue; + tty_insert_flip_char(&port->port, buf[i], flag); } } else { - tty_insert_flip_string_fixed_flag(&port->port, ch, flag, len); + tty_insert_flip_string_fixed_flag(&port->port, buf + 2, flag, + len - 2); } - return len; + return len - 2; } static void ftdi_process_read_urb(struct urb *urb) -- cgit v1.2.3-70-g09d2 From 733fff67941dad64b8a630450b8372b1873edc41 Mon Sep 17 00:00:00 2001 From: Johan Hovold Date: Wed, 8 Jul 2020 14:49:53 +0200 Subject: USB: serial: ftdi_sio: fix break and sysrq handling Only the last NUL in a packet should be flagged as a break character, for example, to avoid dropping unrelated characters when IGNBRK is set. Also make sysrq work by consuming the break character instead of having it immediately cancel the sysrq request, and by not processing it prematurely to avoid triggering a sysrq based on an unrelated character received in the same packet (which was received *before* the break). Note that the break flag can be left set also for a packet received immediately following a break and that and an ending NUL in such a packet will continue to be reported as a break as there's no good way to tell it apart from an actual break. Tested on FT232R and FT232H. Fixes: 72fda3ca6fc1 ("USB: serial: ftd_sio: implement sysrq handling on break") Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Reviewed-by: Greg Kroah-Hartman Signed-off-by: Johan Hovold --- drivers/usb/serial/ftdi_sio.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c index 33f1cca7eaa6..07b146d7033a 100644 --- a/drivers/usb/serial/ftdi_sio.c +++ b/drivers/usb/serial/ftdi_sio.c @@ -2483,6 +2483,7 @@ static int ftdi_process_packet(struct usb_serial_port *port, struct ftdi_private *priv, unsigned char *buf, int len) { unsigned char status; + bool brkint = false; int i; char flag; @@ -2534,13 +2535,17 @@ static int ftdi_process_packet(struct usb_serial_port *port, */ flag = TTY_NORMAL; if (buf[1] & FTDI_RS_ERR_MASK) { - /* Break takes precedence over parity, which takes precedence - * over framing errors */ - if (buf[1] & FTDI_RS_BI) { - flag = TTY_BREAK; + /* + * Break takes precedence over parity, which takes precedence + * over framing errors. Note that break is only associated + * with the last character in the buffer and only when it's a + * NUL. + */ + if (buf[1] & FTDI_RS_BI && buf[len - 1] == '\0') { port->icount.brk++; - usb_serial_handle_break(port); - } else if (buf[1] & FTDI_RS_PE) { + brkint = true; + } + if (buf[1] & FTDI_RS_PE) { flag = TTY_PARITY; port->icount.parity++; } else if (buf[1] & FTDI_RS_FE) { @@ -2556,8 +2561,13 @@ static int ftdi_process_packet(struct usb_serial_port *port, port->icount.rx += len - 2; - if (port->port.console && port->sysrq) { + if (brkint || (port->port.console && port->sysrq)) { for (i = 2; i < len; i++) { + if (brkint && i == len - 1) { + if (usb_serial_handle_break(port)) + return len - 3; + flag = TTY_BREAK; + } if (usb_serial_handle_sysrq_char(port, buf[i])) continue; tty_insert_flip_char(&port->port, buf[i], flag); -- cgit v1.2.3-70-g09d2 From 37ae231554f401104bf21847f9093d647a47faa4 Mon Sep 17 00:00:00 2001 From: Johan Hovold Date: Wed, 8 Jul 2020 14:49:54 +0200 Subject: USB: serial: only set sysrq timestamp for consoles Only set the sysrq timestamp for console ports to avoid having every driver also check the console flag when processing incoming data. Reviewed-by: Greg Kroah-Hartman Signed-off-by: Johan Hovold --- drivers/usb/serial/f81232.c | 4 ++-- drivers/usb/serial/f81534.c | 2 +- drivers/usb/serial/ftdi_sio.c | 2 +- drivers/usb/serial/generic.c | 11 +++++++---- drivers/usb/serial/mxuport.c | 6 +++--- drivers/usb/serial/pl2303.c | 2 +- drivers/usb/serial/ssu100.c | 5 +++-- 7 files changed, 18 insertions(+), 14 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/serial/f81232.c b/drivers/usb/serial/f81232.c index dcda7fb164b4..0c7eacc630e0 100644 --- a/drivers/usb/serial/f81232.c +++ b/drivers/usb/serial/f81232.c @@ -424,7 +424,7 @@ static void f81232_process_read_urb(struct urb *urb) lsr = data[i]; tty_flag = f81232_handle_lsr(port, lsr); - if (port->port.console && port->sysrq) { + if (port->sysrq) { if (usb_serial_handle_sysrq_char(port, data[i + 1])) continue; } @@ -461,7 +461,7 @@ static void f81534a_process_read_urb(struct urb *urb) lsr = data[len - 1]; tty_flag = f81232_handle_lsr(port, lsr); - if (port->port.console && port->sysrq) { + if (port->sysrq) { for (i = 1; i < len - 1; ++i) { if (!usb_serial_handle_sysrq_char(port, data[i])) { tty_insert_flip_char(&port->port, data[i], diff --git a/drivers/usb/serial/f81534.c b/drivers/usb/serial/f81534.c index 2b39bda035c7..5661fd03e545 100644 --- a/drivers/usb/serial/f81534.c +++ b/drivers/usb/serial/f81534.c @@ -1238,7 +1238,7 @@ static void f81534_process_per_serial_block(struct usb_serial_port *port, schedule_work(&port_priv->lsr_work); } - if (port->port.console && port->sysrq) { + if (port->sysrq) { if (usb_serial_handle_sysrq_char(port, data[i])) continue; } diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c index 07b146d7033a..ade68405b015 100644 --- a/drivers/usb/serial/ftdi_sio.c +++ b/drivers/usb/serial/ftdi_sio.c @@ -2561,7 +2561,7 @@ static int ftdi_process_packet(struct usb_serial_port *port, port->icount.rx += len - 2; - if (brkint || (port->port.console && port->sysrq)) { + if (brkint || port->sysrq) { for (i = 2; i < len; i++) { if (brkint && i == len - 1) { if (usb_serial_handle_break(port)) diff --git a/drivers/usb/serial/generic.c b/drivers/usb/serial/generic.c index 5cdf180cda23..05a2a3aa3963 100644 --- a/drivers/usb/serial/generic.c +++ b/drivers/usb/serial/generic.c @@ -355,13 +355,13 @@ void usb_serial_generic_process_read_urb(struct urb *urb) * stuff like 3G modems, so shortcircuit it in the 99.9999999% of * cases where the USB serial is not a console anyway. */ - if (!port->port.console || !port->sysrq) { - tty_insert_flip_string(&port->port, ch, urb->actual_length); - } else { + if (port->sysrq) { for (i = 0; i < urb->actual_length; i++, ch++) { if (!usb_serial_handle_sysrq_char(port, *ch)) tty_insert_flip_char(&port->port, *ch, TTY_NORMAL); } + } else { + tty_insert_flip_string(&port->port, ch, urb->actual_length); } tty_flip_buffer_push(&port->port); } @@ -574,7 +574,7 @@ EXPORT_SYMBOL_GPL(usb_serial_generic_get_icount); #ifdef CONFIG_MAGIC_SYSRQ int usb_serial_handle_sysrq_char(struct usb_serial_port *port, unsigned int ch) { - if (port->sysrq && port->port.console) { + if (port->sysrq) { if (ch && time_before(jiffies, port->sysrq)) { handle_sysrq(ch); port->sysrq = 0; @@ -594,6 +594,9 @@ EXPORT_SYMBOL_GPL(usb_serial_handle_sysrq_char); int usb_serial_handle_break(struct usb_serial_port *port) { + if (!port->port.console) + return 0; + if (!port->sysrq) { port->sysrq = jiffies + HZ*5; return 1; diff --git a/drivers/usb/serial/mxuport.c b/drivers/usb/serial/mxuport.c index 2513ee902779..5d38c2a0f590 100644 --- a/drivers/usb/serial/mxuport.c +++ b/drivers/usb/serial/mxuport.c @@ -327,14 +327,14 @@ static void mxuport_process_read_urb_data(struct usb_serial_port *port, { int i; - if (!port->port.console || !port->sysrq) { - tty_insert_flip_string(&port->port, data, size); - } else { + if (port->sysrq) { for (i = 0; i < size; i++, data++) { if (!usb_serial_handle_sysrq_char(port, *data)) tty_insert_flip_char(&port->port, *data, TTY_NORMAL); } + } else { + tty_insert_flip_string(&port->port, data, size); } tty_flip_buffer_push(&port->port); } diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c index c5a2995dfa2e..048452d8a4a4 100644 --- a/drivers/usb/serial/pl2303.c +++ b/drivers/usb/serial/pl2303.c @@ -1101,7 +1101,7 @@ static void pl2303_process_read_urb(struct urb *urb) if (line_status & UART_OVERRUN_ERROR) tty_insert_flip_char(&port->port, 0, TTY_OVERRUN); - if (port->port.console && port->sysrq) { + if (port->sysrq) { for (i = 0; i < urb->actual_length; ++i) if (!usb_serial_handle_sysrq_char(port, data[i])) tty_insert_flip_char(&port->port, data[i], diff --git a/drivers/usb/serial/ssu100.c b/drivers/usb/serial/ssu100.c index f6aea9f1be1a..01472b96bf38 100644 --- a/drivers/usb/serial/ssu100.c +++ b/drivers/usb/serial/ssu100.c @@ -517,13 +517,14 @@ static void ssu100_process_read_urb(struct urb *urb) if (!len) return; /* status only */ - if (port->port.console && port->sysrq) { + if (port->sysrq) { for (i = 0; i < len; i++, ch++) { if (!usb_serial_handle_sysrq_char(port, *ch)) tty_insert_flip_char(&port->port, *ch, flag); } - } else + } else { tty_insert_flip_string_fixed_flag(&port->port, ch, flag, len); + } tty_flip_buffer_push(&port->port); } -- cgit v1.2.3-70-g09d2 From 8c6a223186a6c3fe7cd381ef7e1d60ea6fd8fd52 Mon Sep 17 00:00:00 2001 From: Johan Hovold Date: Wed, 8 Jul 2020 14:49:55 +0200 Subject: USB: serial: only process sysrq when enabled Do not set the sysrq timestamp unless CONFIG_MAGIC_SYSRQ is enabled to avoid unnecessary per-character processing for consoles. Reviewed-by: Greg Kroah-Hartman Signed-off-by: Johan Hovold --- drivers/usb/serial/generic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/usb') diff --git a/drivers/usb/serial/generic.c b/drivers/usb/serial/generic.c index 05a2a3aa3963..c5b35252c931 100644 --- a/drivers/usb/serial/generic.c +++ b/drivers/usb/serial/generic.c @@ -594,7 +594,7 @@ EXPORT_SYMBOL_GPL(usb_serial_handle_sysrq_char); int usb_serial_handle_break(struct usb_serial_port *port) { - if (!port->port.console) + if (!port->port.console || !IS_ENABLED(CONFIG_MAGIC_SYSRQ)) return 0; if (!port->sysrq) { -- cgit v1.2.3-70-g09d2 From 4fbfbdb5726ff15bdce1c371efa1281b28322f64 Mon Sep 17 00:00:00 2001 From: Johan Hovold Date: Wed, 8 Jul 2020 14:49:56 +0200 Subject: USB: serial: inline sysrq dummy function Inline the dummy sysrq character handling when either console support or magic-sysrq support isn't enabled to allow the compiler to eliminate unused code. Reviewed-by: Greg Kroah-Hartman Signed-off-by: Johan Hovold --- drivers/usb/serial/generic.c | 9 ++------- include/linux/usb/serial.h | 9 +++++++++ 2 files changed, 11 insertions(+), 7 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/serial/generic.c b/drivers/usb/serial/generic.c index c5b35252c931..a9b6d103aaf6 100644 --- a/drivers/usb/serial/generic.c +++ b/drivers/usb/serial/generic.c @@ -571,7 +571,7 @@ int usb_serial_generic_get_icount(struct tty_struct *tty, } EXPORT_SYMBOL_GPL(usb_serial_generic_get_icount); -#ifdef CONFIG_MAGIC_SYSRQ +#if defined(CONFIG_USB_SERIAL_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) int usb_serial_handle_sysrq_char(struct usb_serial_port *port, unsigned int ch) { if (port->sysrq) { @@ -584,13 +584,8 @@ int usb_serial_handle_sysrq_char(struct usb_serial_port *port, unsigned int ch) } return 0; } -#else -int usb_serial_handle_sysrq_char(struct usb_serial_port *port, unsigned int ch) -{ - return 0; -} -#endif EXPORT_SYMBOL_GPL(usb_serial_handle_sysrq_char); +#endif int usb_serial_handle_break(struct usb_serial_port *port) { diff --git a/include/linux/usb/serial.h b/include/linux/usb/serial.h index 14cac4a1ae8f..be73646706a9 100644 --- a/include/linux/usb/serial.h +++ b/include/linux/usb/serial.h @@ -365,8 +365,17 @@ extern int usb_serial_generic_submit_read_urbs(struct usb_serial_port *port, extern void usb_serial_generic_process_read_urb(struct urb *urb); extern int usb_serial_generic_prepare_write_buffer(struct usb_serial_port *port, void *dest, size_t size); + +#if defined(CONFIG_USB_SERIAL_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) extern int usb_serial_handle_sysrq_char(struct usb_serial_port *port, unsigned int ch); +#else +static inline int usb_serial_handle_sysrq_char(struct usb_serial_port *port, unsigned int ch) +{ + return 0; +} +#endif + extern int usb_serial_handle_break(struct usb_serial_port *port); extern void usb_serial_handle_dcd_change(struct usb_serial_port *usb_port, struct tty_struct *tty, -- cgit v1.2.3-70-g09d2 From 4b5cf2b8f90faf32bbb735b545510edefce094be Mon Sep 17 00:00:00 2001 From: Johan Hovold Date: Wed, 8 Jul 2020 14:49:57 +0200 Subject: USB: serial: add sysrq break-handler dummy Add inline sysrq break-handler dummy to allow the compiler to eliminate further code when either console or sysrq support isn't enabled and to clearly mark the two sysrq functions as belonging together. Reviewed-by: Greg Kroah-Hartman Signed-off-by: Johan Hovold --- drivers/usb/serial/generic.c | 4 ++-- include/linux/usb/serial.h | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/serial/generic.c b/drivers/usb/serial/generic.c index a9b6d103aaf6..e60f74f11acc 100644 --- a/drivers/usb/serial/generic.c +++ b/drivers/usb/serial/generic.c @@ -585,11 +585,10 @@ int usb_serial_handle_sysrq_char(struct usb_serial_port *port, unsigned int ch) return 0; } EXPORT_SYMBOL_GPL(usb_serial_handle_sysrq_char); -#endif int usb_serial_handle_break(struct usb_serial_port *port) { - if (!port->port.console || !IS_ENABLED(CONFIG_MAGIC_SYSRQ)) + if (!port->port.console) return 0; if (!port->sysrq) { @@ -600,6 +599,7 @@ int usb_serial_handle_break(struct usb_serial_port *port) return 0; } EXPORT_SYMBOL_GPL(usb_serial_handle_break); +#endif /** * usb_serial_handle_dcd_change - handle a change of carrier detect state diff --git a/include/linux/usb/serial.h b/include/linux/usb/serial.h index be73646706a9..c4ed4404335e 100644 --- a/include/linux/usb/serial.h +++ b/include/linux/usb/serial.h @@ -369,14 +369,18 @@ extern int usb_serial_generic_prepare_write_buffer(struct usb_serial_port *port, #if defined(CONFIG_USB_SERIAL_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) extern int usb_serial_handle_sysrq_char(struct usb_serial_port *port, unsigned int ch); +extern int usb_serial_handle_break(struct usb_serial_port *port); #else static inline int usb_serial_handle_sysrq_char(struct usb_serial_port *port, unsigned int ch) { return 0; } +static inline int usb_serial_handle_break(struct usb_serial_port *port) +{ + return 0; +} #endif -extern int usb_serial_handle_break(struct usb_serial_port *port); extern void usb_serial_handle_dcd_change(struct usb_serial_port *usb_port, struct tty_struct *tty, unsigned int status); -- cgit v1.2.3-70-g09d2 From eb0c68ea4246252ba56951c6cf5e5d544a342e9e Mon Sep 17 00:00:00 2001 From: Johan Hovold Date: Wed, 8 Jul 2020 14:50:00 +0200 Subject: USB: serial: drop redundant transfer-buffer casts Drop redundant URB transfer-buffer casts. Reviewed-by: Greg Kroah-Hartman Signed-off-by: Johan Hovold --- drivers/usb/serial/aircable.c | 2 +- drivers/usb/serial/ftdi_sio.c | 2 +- drivers/usb/serial/generic.c | 2 +- drivers/usb/serial/option.c | 3 +-- drivers/usb/serial/sierra.c | 3 +-- drivers/usb/serial/ssu100.c | 2 +- 6 files changed, 6 insertions(+), 8 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/serial/aircable.c b/drivers/usb/serial/aircable.c index 84d52953dd0a..a1df686c3066 100644 --- a/drivers/usb/serial/aircable.c +++ b/drivers/usb/serial/aircable.c @@ -117,7 +117,7 @@ static int aircable_process_packet(struct usb_serial_port *port, static void aircable_process_read_urb(struct urb *urb) { struct usb_serial_port *port = urb->context; - char *data = (char *)urb->transfer_buffer; + char *data = urb->transfer_buffer; int has_headers; int count; int len; diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c index ade68405b015..871cdccf3a5f 100644 --- a/drivers/usb/serial/ftdi_sio.c +++ b/drivers/usb/serial/ftdi_sio.c @@ -2584,7 +2584,7 @@ static void ftdi_process_read_urb(struct urb *urb) { struct usb_serial_port *port = urb->context; struct ftdi_private *priv = usb_get_serial_port_data(port); - char *data = (char *)urb->transfer_buffer; + char *data = urb->transfer_buffer; int i; int len; int count = 0; diff --git a/drivers/usb/serial/generic.c b/drivers/usb/serial/generic.c index e60f74f11acc..d10aa3d2ee49 100644 --- a/drivers/usb/serial/generic.c +++ b/drivers/usb/serial/generic.c @@ -345,7 +345,7 @@ EXPORT_SYMBOL_GPL(usb_serial_generic_submit_read_urbs); void usb_serial_generic_process_read_urb(struct urb *urb) { struct usb_serial_port *port = urb->context; - char *ch = (char *)urb->transfer_buffer; + char *ch = urb->transfer_buffer; int i; if (!urb->actual_length) diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c index 254a8bbeea67..8e74903352e7 100644 --- a/drivers/usb/serial/option.c +++ b/drivers/usb/serial/option.c @@ -2151,8 +2151,7 @@ static void option_instat_callback(struct urb *urb) dev_dbg(dev, "%s: urb %p port %p has data %p\n", __func__, urb, port, portdata); if (status == 0) { - struct usb_ctrlrequest *req_pkt = - (struct usb_ctrlrequest *)urb->transfer_buffer; + struct usb_ctrlrequest *req_pkt = urb->transfer_buffer; if (!req_pkt) { dev_dbg(dev, "%s: NULL req_pkt\n", __func__); diff --git a/drivers/usb/serial/sierra.c b/drivers/usb/serial/sierra.c index e8b130157b57..a862aa788a19 100644 --- a/drivers/usb/serial/sierra.c +++ b/drivers/usb/serial/sierra.c @@ -570,8 +570,7 @@ static void sierra_instat_callback(struct urb *urb) urb, port, portdata); if (status == 0) { - struct usb_ctrlrequest *req_pkt = - (struct usb_ctrlrequest *)urb->transfer_buffer; + struct usb_ctrlrequest *req_pkt = urb->transfer_buffer; if (!req_pkt) { dev_dbg(&port->dev, "%s: NULL req_pkt\n", diff --git a/drivers/usb/serial/ssu100.c b/drivers/usb/serial/ssu100.c index 01472b96bf38..7d39d35e52a1 100644 --- a/drivers/usb/serial/ssu100.c +++ b/drivers/usb/serial/ssu100.c @@ -495,7 +495,7 @@ static void ssu100_update_lsr(struct usb_serial_port *port, u8 lsr, static void ssu100_process_read_urb(struct urb *urb) { struct usb_serial_port *port = urb->context; - char *packet = (char *)urb->transfer_buffer; + char *packet = urb->transfer_buffer; char flag = TTY_NORMAL; u32 len = urb->actual_length; int i; -- cgit v1.2.3-70-g09d2 From acf916c2aae81f7f009c5a53ce7fb54ec41e4c10 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Fri, 3 Jul 2020 15:10:59 +0200 Subject: usb: ehci-omap: Drop surplus include The EHCI OMAP driver includes but does not use any symbols from this file, so drop it. Cc: Roger Quadros Cc: Tony Lindgren Signed-off-by: Linus Walleij Reviewed-by: Peter Ujfalusi Link: https://lore.kernel.org/r/20200703131059.515436-1-linus.walleij@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/ehci-omap.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers/usb') diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c index 2ec686e28582..8771a2ed6926 100644 --- a/drivers/usb/host/ehci-omap.c +++ b/drivers/usb/host/ehci-omap.c @@ -24,7 +24,6 @@ #include #include #include -#include #include #include #include -- cgit v1.2.3-70-g09d2 From 16eb9c0aae8da3ade9bb74464c2e3d151a39d504 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Fri, 3 Jul 2020 18:41:19 +0100 Subject: usb: mtu3: mtu3_debug: Add forward declaration of 'struct ssusb_mtk' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Without it, the build system complains that it was declared inside the parameter list. Fixes the following W=1 kernel build warning(s): In file included from drivers/usb/mtu3/mtu3_trace.c:11: drivers/usb/mtu3/mtu3_debug.h:29:36: warning: ‘struct ssusb_mtk’ declared inside parameter list will not be visible outside of this definition or declaration 29 | void ssusb_dev_debugfs_init(struct ssusb_mtk *ssusb); | ^~~~~~~~~ drivers/usb/mtu3/mtu3_debug.h:30:35: warning: ‘struct ssusb_mtk’ declared inside parameter list will not be visible outside of this definition or declaration 30 | void ssusb_dr_debugfs_init(struct ssusb_mtk *ssusb); | ^~~~~~~~~ drivers/usb/mtu3/mtu3_debug.h:31:39: warning: ‘struct ssusb_mtk’ declared inside parameter list will not be visible outside of this definition or declaration 31 | void ssusb_debugfs_create_root(struct ssusb_mtk *ssusb); | ^~~~~~~~~ drivers/usb/mtu3/mtu3_debug.h:32:39: warning: ‘struct ssusb_mtk’ declared inside parameter list will not be visible outside of this definition or declaration 32 | void ssusb_debugfs_remove_root(struct ssusb_mtk *ssusb); | ^~~~~~~~~ Cc: Chunfeng Yun Cc: linux-mediatek@lists.infradead.org Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20200703174148.2749969-2-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/mtu3/mtu3_debug.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers/usb') diff --git a/drivers/usb/mtu3/mtu3_debug.h b/drivers/usb/mtu3/mtu3_debug.h index fb6b28277c9b..3084c46017c3 100644 --- a/drivers/usb/mtu3/mtu3_debug.h +++ b/drivers/usb/mtu3/mtu3_debug.h @@ -12,6 +12,8 @@ #include +struct ssusb_mtk; + #define MTU3_DEBUGFS_NAME_LEN 32 struct mtu3_regset { -- cgit v1.2.3-70-g09d2 From 0459268acb66457434e81aedbdd2e17c3d4a37cc Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Fri, 3 Jul 2020 18:41:20 +0100 Subject: usb: host: ohci-s3c2410: Demote obvious misuse of kerneldoc to standard comment block No attempt has been made to document the function here. Fixes the following W=1 kernel build warning(s): drivers/usb/host/ohci-s3c2410.c:356: warning: Function parameter or member 'dev' not described in 'ohci_hcd_s3c2410_probe' Cc: Alan Stern Cc: Kukjin Kim Cc: Krzysztof Kozlowski Cc: Roman Weissgaerber Cc: David Brownell Cc: Christopher Hoover Cc: Ben Dooks Cc: linux-samsung-soc@vger.kernel.org Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20200703174148.2749969-3-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/ohci-s3c2410.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/usb') diff --git a/drivers/usb/host/ohci-s3c2410.c b/drivers/usb/host/ohci-s3c2410.c index d961097c90f0..de5e570c58ba 100644 --- a/drivers/usb/host/ohci-s3c2410.c +++ b/drivers/usb/host/ohci-s3c2410.c @@ -343,7 +343,7 @@ ohci_hcd_s3c2410_remove(struct platform_device *dev) return 0; } -/** +/* * ohci_hcd_s3c2410_probe - initialize S3C2410-based HCDs * Context: !in_interrupt() * -- cgit v1.2.3-70-g09d2 From 5bef1132561d861f439824f1d06c8f0a5018f621 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Fri, 3 Jul 2020 18:41:21 +0100 Subject: usb: core: ledtrig-usbport: Demote obvious misuse of kerneldoc to standard comment blocks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit No attempt has been made to document any of the functions here. Fixes the following W=1 kernel build warning(s): drivers/usb/core/ledtrig-usbport.c:42: warning: Function parameter or member 'usbport_data' not described in 'usbport_trig_usb_dev_observed' drivers/usb/core/ledtrig-usbport.c:42: warning: Function parameter or member 'usb_dev' not described in 'usbport_trig_usb_dev_observed' drivers/usb/core/ledtrig-usbport.c:71: warning: Function parameter or member 'usbport_data' not described in 'usbport_trig_update_count' drivers/usb/core/ledtrig-usbport.c:131: warning: Function parameter or member 'usbport_data' not described in 'usbport_trig_port_observed' drivers/usb/core/ledtrig-usbport.c:131: warning: Function parameter or member 'usb_dev' not described in 'usbport_trig_port_observed' drivers/usb/core/ledtrig-usbport.c:131: warning: Function parameter or member 'port1' not described in 'usbport_trig_port_observed' Cc: Rafał Miłecki Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20200703174148.2749969-4-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/core/ledtrig-usbport.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/core/ledtrig-usbport.c b/drivers/usb/core/ledtrig-usbport.c index c12ac56606c3..ba371a24ff78 100644 --- a/drivers/usb/core/ledtrig-usbport.c +++ b/drivers/usb/core/ledtrig-usbport.c @@ -34,7 +34,7 @@ struct usbport_trig_port { * Helpers ***************************************/ -/** +/* * usbport_trig_usb_dev_observed - Check if dev is connected to observed port */ static bool usbport_trig_usb_dev_observed(struct usbport_trig_data *usbport_data, @@ -64,7 +64,7 @@ static int usbport_trig_usb_dev_check(struct usb_device *usb_dev, void *data) return 0; } -/** +/* * usbport_trig_update_count - Recalculate amount of connected matching devices */ static void usbport_trig_update_count(struct usbport_trig_data *usbport_data) @@ -123,7 +123,7 @@ static const struct attribute_group ports_group = { * Adding & removing ports ***************************************/ -/** +/* * usbport_trig_port_observed - Check if port should be observed */ static bool usbport_trig_port_observed(struct usbport_trig_data *usbport_data, -- cgit v1.2.3-70-g09d2 From b2e3fa1ab433524dfa3dd38afb82a80c5b7319e8 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Fri, 3 Jul 2020 18:41:23 +0100 Subject: usb: atm: ueagle-atm: Demote obvious misuse of kerneldoc to standard comment blocks No attempt has been made to document any of the functions here. Fixes the following W=1 kernel build warning(s): drivers/usb/atm/ueagle-atm.c:578: warning: Function parameter or member 'usb' not described in 'uea_send_modem_cmd' drivers/usb/atm/ueagle-atm.c:578: warning: Function parameter or member 'addr' not described in 'uea_send_modem_cmd' drivers/usb/atm/ueagle-atm.c:578: warning: Function parameter or member 'size' not described in 'uea_send_modem_cmd' drivers/usb/atm/ueagle-atm.c:578: warning: Function parameter or member 'buff' not described in 'uea_send_modem_cmd' drivers/usb/atm/ueagle-atm.c:679: warning: Function parameter or member 'usb' not described in 'uea_load_firmware' drivers/usb/atm/ueagle-atm.c:679: warning: Function parameter or member 'ver' not described in 'uea_load_firmware' Cc: Matthieu CASTET Cc: Stanislaw Gruszka Cc: Damien Bergamini Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20200703174148.2749969-6-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/atm/ueagle-atm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/atm/ueagle-atm.c b/drivers/usb/atm/ueagle-atm.c index e9fed9a88737..786299892c7f 100644 --- a/drivers/usb/atm/ueagle-atm.c +++ b/drivers/usb/atm/ueagle-atm.c @@ -570,7 +570,7 @@ MODULE_PARM_DESC(annex, #define LOAD_INTERNAL 0xA0 #define F8051_USBCS 0x7f92 -/** +/* * uea_send_modem_cmd - Send a command for pre-firmware devices. */ static int uea_send_modem_cmd(struct usb_device *usb, @@ -672,7 +672,7 @@ err: uea_leaves(usb); } -/** +/* * uea_load_firmware - Load usb firmware for pre-firmware devices. */ static int uea_load_firmware(struct usb_device *usb, unsigned int ver) -- cgit v1.2.3-70-g09d2 From 874ae83880083e501afbe429efe47c32d53bcf7c Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Fri, 3 Jul 2020 18:41:24 +0100 Subject: usb: misc: adutux: Demote obvious misuse of kerneldoc to standard comment blocks No attempt has been made to document any of the functions here. Fixes the following W=1 kernel build warning(s): drivers/usb/misc/adutux.c:117: warning: Function parameter or member 'dev' not described in 'adu_abort_transfers' drivers/usb/misc/adutux.c:653: warning: Function parameter or member 'interface' not described in 'adu_probe' drivers/usb/misc/adutux.c:653: warning: Function parameter or member 'id' not described in 'adu_probe' drivers/usb/misc/adutux.c:762: warning: Function parameter or member 'interface' not described in 'adu_disconnect' Cc: Johan Hovold Cc: David Glance Cc: Juergen Stuber Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20200703174148.2749969-7-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/misc/adutux.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/misc/adutux.c b/drivers/usb/misc/adutux.c index d8d157c4c271..a7eefe11f31a 100644 --- a/drivers/usb/misc/adutux.c +++ b/drivers/usb/misc/adutux.c @@ -109,7 +109,7 @@ static inline void adu_debug_data(struct device *dev, const char *function, function, size, size, data); } -/** +/* * adu_abort_transfers * aborts transfers and frees associated data structures */ @@ -642,7 +642,7 @@ static struct usb_class_driver adu_class = { .minor_base = ADU_MINOR_BASE, }; -/** +/* * adu_probe * * Called by the usb core when a new device is connected that it thinks @@ -753,7 +753,7 @@ error: return retval; } -/** +/* * adu_disconnect * * Called by the usb core when the device is removed from the system. -- cgit v1.2.3-70-g09d2 From 8ac326ff5c9903dfc5e34cef66df591f376b2ec2 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Fri, 3 Jul 2020 18:41:25 +0100 Subject: usb: chipidea: core: Document hw_port_test_set()'s missing 'ci' argument Fixes the following W=1 kernel build warning(s): drivers/usb/chipidea/core.c:163: warning: Function parameter or member 'ci' not described in 'hw_port_test_set' Cc: Peter Chen Cc: David Lopo Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20200703174148.2749969-8-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/chipidea/core.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/usb') diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c index 9a7c53d09ab4..1016596532a9 100644 --- a/drivers/usb/chipidea/core.c +++ b/drivers/usb/chipidea/core.c @@ -155,6 +155,7 @@ u32 hw_read_intr_status(struct ci_hdrc *ci) /** * hw_port_test_set: writes port test mode (execute without interruption) + * @ci: the controller * @mode: new value * * This function returns an error code -- cgit v1.2.3-70-g09d2 From e21cd08f965766d014b021db207107a559a14e20 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Fri, 3 Jul 2020 18:41:26 +0100 Subject: usb: gadget: udc: core: Fix a bunch of kerneldoc misdemeanours Firstly, file headers should not be in kerneldoc format. Function args should be in the format '@.*: '. We also take the time to add some descriptions for various argument which have been previously left out. Finally we remove descriptions for absent arguments. Fixes the following W=1 kernel build warning(s): drivers/usb/gadget/udc/core.c:25: warning: Incorrect use of kernel-doc format: * struct usb_udc - describes one usb device controller drivers/usb/gadget/udc/core.c:36: warning: cannot understand function prototype: 'struct usb_udc ' drivers/usb/gadget/udc/core.c:901: warning: Function parameter or member 'ep' not described in 'usb_gadget_giveback_request' drivers/usb/gadget/udc/core.c:901: warning: Function parameter or member 'req' not described in 'usb_gadget_giveback_request' drivers/usb/gadget/udc/core.c:1098: warning: Function parameter or member 'udc' not described in 'usb_gadget_udc_stop' drivers/usb/gadget/udc/core.c:1098: warning: Excess function parameter 'gadget' description in 'usb_gadget_udc_stop' drivers/usb/gadget/udc/core.c:1098: warning: Excess function parameter 'driver' description in 'usb_gadget_udc_stop' Cc: Felipe Balbi Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20200703174148.2749969-9-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/udc/core.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/gadget/udc/core.c b/drivers/usb/gadget/udc/core.c index ee226ad802a4..c33ad8a333ad 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 @@ -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. -- cgit v1.2.3-70-g09d2 From 6a005f0fbf6e99555180fcbc608a8157134550d5 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Fri, 3 Jul 2020 18:41:27 +0100 Subject: usb: chipidea: otg: Fix kerneldoc issues relating to description of 'ci' Firstly we add some missing descriptions. Then we fix some formatting issues. Kerneldoc expects arguments to be in the format '@.*: '. If either the '@' or ':' is omitted, kerneldoc gets confused. Fixes the following W=1 kernel build warning(s): drivers/usb/chipidea/otg.c:29: warning: Function parameter or member 'ci' not described in 'hw_read_otgsc' drivers/usb/chipidea/otg.c:82: warning: Function parameter or member 'ci' not described in 'hw_write_otgsc' drivers/usb/chipidea/otg.c:235: warning: Function parameter or member 'ci' not described in 'ci_hdrc_otg_init' drivers/usb/chipidea/otg.c:254: warning: Function parameter or member 'ci' not described in 'ci_hdrc_otg_destroy' Cc: Peter Chen Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20200703174148.2749969-10-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/chipidea/otg.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/chipidea/otg.c b/drivers/usb/chipidea/otg.c index be63924ea82e..d3aada3ce7ec 100644 --- a/drivers/usb/chipidea/otg.c +++ b/drivers/usb/chipidea/otg.c @@ -23,6 +23,7 @@ /** * hw_read_otgsc returns otgsc register bits value. + * @ci: the controller * @mask: bitfield mask */ u32 hw_read_otgsc(struct ci_hdrc *ci, u32 mask) @@ -75,6 +76,7 @@ u32 hw_read_otgsc(struct ci_hdrc *ci, u32 mask) /** * hw_write_otgsc updates target bits of OTGSC register. + * @ci: the controller * @mask: bitfield mask * @data: to be written */ @@ -229,7 +231,7 @@ static void ci_otg_work(struct work_struct *work) /** * ci_hdrc_otg_init - initialize otg struct - * ci: the controller + * @ci: the controller */ int ci_hdrc_otg_init(struct ci_hdrc *ci) { @@ -248,7 +250,7 @@ int ci_hdrc_otg_init(struct ci_hdrc *ci) /** * ci_hdrc_otg_destroy - destroy otg struct - * ci: the controller + * @ci: the controller */ void ci_hdrc_otg_destroy(struct ci_hdrc *ci) { -- cgit v1.2.3-70-g09d2 From 5722a8efc6c8979159a62557ca8ea050228a1564 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Fri, 3 Jul 2020 18:41:28 +0100 Subject: usb: chipidea: debug: Demote obvious misuse of kerneldoc to standard comment blocks No attempt has been made to document any of the demoted functions here. Fixes the following W=1 kernel build warning(s): drivers/usb/chipidea/debug.c:25: warning: Function parameter or member 's' not described in 'ci_device_show' drivers/usb/chipidea/debug.c:25: warning: Function parameter or member 'data' not described in 'ci_device_show' drivers/usb/chipidea/debug.c:54: warning: Function parameter or member 's' not described in 'ci_port_test_show' drivers/usb/chipidea/debug.c:54: warning: Function parameter or member 'data' not described in 'ci_port_test_show' drivers/usb/chipidea/debug.c:75: warning: Function parameter or member 'file' not described in 'ci_port_test_write' drivers/usb/chipidea/debug.c:75: warning: Function parameter or member 'ubuf' not described in 'ci_port_test_write' drivers/usb/chipidea/debug.c:75: warning: Function parameter or member 'count' not described in 'ci_port_test_write' drivers/usb/chipidea/debug.c:75: warning: Function parameter or member 'ppos' not described in 'ci_port_test_write' drivers/usb/chipidea/debug.c:122: warning: Function parameter or member 's' not described in 'ci_qheads_show' drivers/usb/chipidea/debug.c:122: warning: Function parameter or member 'data' not described in 'ci_qheads_show' drivers/usb/chipidea/debug.c:154: warning: Function parameter or member 's' not described in 'ci_requests_show' drivers/usb/chipidea/debug.c:154: warning: Function parameter or member 'data' not described in 'ci_requests_show' Cc: Peter Chen Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20200703174148.2749969-11-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/chipidea/debug.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/chipidea/debug.c b/drivers/usb/chipidea/debug.c index e0376ee646ad..da5d18cf6840 100644 --- a/drivers/usb/chipidea/debug.c +++ b/drivers/usb/chipidea/debug.c @@ -18,7 +18,7 @@ #include "bits.h" #include "otg.h" -/** +/* * ci_device_show: prints information about device capabilities and status */ static int ci_device_show(struct seq_file *s, void *data) @@ -47,7 +47,7 @@ static int ci_device_show(struct seq_file *s, void *data) } DEFINE_SHOW_ATTRIBUTE(ci_device); -/** +/* * ci_port_test_show: reads port test mode */ static int ci_port_test_show(struct seq_file *s, void *data) @@ -67,7 +67,7 @@ static int ci_port_test_show(struct seq_file *s, void *data) return 0; } -/** +/* * ci_port_test_write: writes port test mode */ static ssize_t ci_port_test_write(struct file *file, const char __user *ubuf, @@ -115,7 +115,7 @@ static const struct file_operations ci_port_test_fops = { .release = single_release, }; -/** +/* * ci_qheads_show: DMA contents of all queue heads */ static int ci_qheads_show(struct seq_file *s, void *data) @@ -147,7 +147,7 @@ static int ci_qheads_show(struct seq_file *s, void *data) } DEFINE_SHOW_ATTRIBUTE(ci_qheads); -/** +/* * ci_requests_show: DMA contents of all requests currently queued (all endpts) */ static int ci_requests_show(struct seq_file *s, void *data) -- cgit v1.2.3-70-g09d2 From 22dfe6574b6f24d7739d3b6b2df5547253ec7d5d Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Fri, 3 Jul 2020 18:41:29 +0100 Subject: usb: chipidea: udc: Add missing descriptions for function arg 'ci' Looks like a very popular argument to omit descriptions for. Fixes the following W=1 kernel build warning(s): drivers/usb/chipidea/udc.c:80: warning: Function parameter or member 'ci' not described in 'hw_device_state' drivers/usb/chipidea/udc.c:100: warning: Function parameter or member 'ci' not described in 'hw_ep_flush' drivers/usb/chipidea/udc.c:121: warning: Function parameter or member 'ci' not described in 'hw_ep_disable' drivers/usb/chipidea/udc.c:136: warning: Function parameter or member 'ci' not described in 'hw_ep_enable' drivers/usb/chipidea/udc.c:170: warning: Function parameter or member 'ci' not described in 'hw_ep_get_halt' drivers/usb/chipidea/udc.c:185: warning: Function parameter or member 'ci' not described in 'hw_ep_prime' drivers/usb/chipidea/udc.c:215: warning: Function parameter or member 'ci' not described in 'hw_ep_set_halt' drivers/usb/chipidea/udc.c:238: warning: Function parameter or member 'ci' not described in 'hw_port_is_high_speed' drivers/usb/chipidea/udc.c:251: warning: Function parameter or member 'ci' not described in 'hw_test_and_clear_complete' drivers/usb/chipidea/udc.c:263: warning: Function parameter or member 'ci' not described in 'hw_test_and_clear_intr_active' drivers/usb/chipidea/udc.c:277: warning: Function parameter or member 'ci' not described in 'hw_test_and_clear_setup_guard' drivers/usb/chipidea/udc.c:288: warning: Function parameter or member 'ci' not described in 'hw_test_and_set_setup_guard' drivers/usb/chipidea/udc.c:300: warning: Function parameter or member 'ci' not described in 'hw_usb_set_address' drivers/usb/chipidea/udc.c:312: warning: Function parameter or member 'ci' not described in 'hw_usb_reset' Cc: Peter Chen Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20200703174148.2749969-12-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/chipidea/udc.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'drivers/usb') diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c index 4beb25888917..2e6f13622bb9 100644 --- a/drivers/usb/chipidea/udc.c +++ b/drivers/usb/chipidea/udc.c @@ -72,6 +72,7 @@ static inline int ep_to_bit(struct ci_hdrc *ci, int n) /** * hw_device_state: enables/disables interrupts (execute without interruption) + * @ci: the controller * @dma: 0 => disable, !0 => enable and set dma engine * * This function returns an error code @@ -91,6 +92,7 @@ static int hw_device_state(struct ci_hdrc *ci, u32 dma) /** * hw_ep_flush: flush endpoint fifo (execute without interruption) + * @ci: the controller * @num: endpoint number * @dir: endpoint direction * @@ -112,6 +114,7 @@ static int hw_ep_flush(struct ci_hdrc *ci, int num, int dir) /** * hw_ep_disable: disables endpoint (execute without interruption) + * @ci: the controller * @num: endpoint number * @dir: endpoint direction * @@ -126,6 +129,7 @@ static int hw_ep_disable(struct ci_hdrc *ci, int num, int dir) /** * hw_ep_enable: enables endpoint (execute without interruption) + * @ci: the controller * @num: endpoint number * @dir: endpoint direction * @type: endpoint type @@ -161,6 +165,7 @@ static int hw_ep_enable(struct ci_hdrc *ci, int num, int dir, int type) /** * hw_ep_get_halt: return endpoint halt status + * @ci: the controller * @num: endpoint number * @dir: endpoint direction * @@ -175,6 +180,7 @@ static int hw_ep_get_halt(struct ci_hdrc *ci, int num, int dir) /** * hw_ep_prime: primes endpoint (execute without interruption) + * @ci: the controller * @num: endpoint number * @dir: endpoint direction * @is_ctrl: true if control endpoint @@ -205,6 +211,7 @@ static int hw_ep_prime(struct ci_hdrc *ci, int num, int dir, int is_ctrl) /** * hw_ep_set_halt: configures ep halt & resets data toggle after clear (execute * without interruption) + * @ci: the controller * @num: endpoint number * @dir: endpoint direction * @value: true => stall, false => unstall @@ -243,6 +250,7 @@ static int hw_port_is_high_speed(struct ci_hdrc *ci) /** * hw_test_and_clear_complete: test & clear complete status (execute without * interruption) + * @ci: the controller * @n: endpoint number * * This function returns complete status @@ -291,6 +299,7 @@ static int hw_test_and_set_setup_guard(struct ci_hdrc *ci) /** * hw_usb_set_address: configures USB address (execute without interruption) + * @ci: the controller * @value: new USB address * * This function explicitly sets the address, without the "USBADRA" (advance) @@ -610,8 +619,9 @@ done: return ret; } -/* +/** * free_pending_td: remove a pending request for the endpoint + * @ci: the controller * @hwep: endpoint */ static void free_pending_td(struct ci_hw_ep *hwep) -- cgit v1.2.3-70-g09d2 From 92d08e070a103eedf8ec5a0c7c8dd03432fa5f56 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Fri, 3 Jul 2020 18:41:30 +0100 Subject: usb: chipidea: udc: Help out kerneldoc headers that have tried, demote the others Help with adding the odd description where they have been omitted or where the format isn't quite right. Demote all function headers which are lacking any attempt of describing their arguments. Fixes the following W=1 kernel build warning(s): drivers/usb/chipidea/udc.c:645: warning: Function parameter or member 'hwreq' not described in '_hardware_dequeue' drivers/usb/chipidea/udc.c:645: warning: Excess function parameter 'gadget' description in '_hardware_dequeue' drivers/usb/chipidea/udc.c:1326: warning: Function parameter or member 'ep' not described in 'ep_enable' drivers/usb/chipidea/udc.c:1326: warning: Function parameter or member 'desc' not described in 'ep_enable' drivers/usb/chipidea/udc.c:1393: warning: Function parameter or member 'ep' not described in 'ep_disable' drivers/usb/chipidea/udc.c:1433: warning: Function parameter or member 'ep' not described in 'ep_alloc_request' drivers/usb/chipidea/udc.c:1433: warning: Function parameter or member 'gfp_flags' not described in 'ep_alloc_request' drivers/usb/chipidea/udc.c:1454: warning: Function parameter or member 'ep' not described in 'ep_free_request' drivers/usb/chipidea/udc.c:1454: warning: Function parameter or member 'req' not described in 'ep_free_request' drivers/usb/chipidea/udc.c:1488: warning: Function parameter or member 'ep' not described in 'ep_queue' drivers/usb/chipidea/udc.c:1488: warning: Function parameter or member 'req' not described in 'ep_queue' drivers/usb/chipidea/udc.c:1488: warning: Function parameter or member 'gfp_flags' not described in 'ep_queue' drivers/usb/chipidea/udc.c:1512: warning: Function parameter or member 'ep' not described in 'ep_dequeue' drivers/usb/chipidea/udc.c:1512: warning: Function parameter or member 'req' not described in 'ep_dequeue' drivers/usb/chipidea/udc.c:1556: warning: Function parameter or member 'ep' not described in 'ep_set_halt' drivers/usb/chipidea/udc.c:1556: warning: Function parameter or member 'value' not described in 'ep_set_halt' drivers/usb/chipidea/udc.c:1566: warning: Function parameter or member 'ep' not described in 'ep_set_wedge' drivers/usb/chipidea/udc.c:1586: warning: Function parameter or member 'ep' not described in 'ep_fifo_flush' drivers/usb/chipidea/udc.c:1610: warning: cannot understand function prototype: 'const struct usb_ep_ops usb_ep_ops = ' drivers/usb/chipidea/udc.c:1629: warning: Function parameter or member '_gadget' not described in 'ci_hdrc_gadget_connect' drivers/usb/chipidea/udc.c:1629: warning: Function parameter or member 'is_active' not described in 'ci_hdrc_gadget_connect' drivers/usb/chipidea/udc.c:1780: warning: cannot understand function prototype: 'const struct usb_gadget_ops usb_gadget_ops = ' drivers/usb/chipidea/udc.c:1931: warning: Function parameter or member 'gadget' not described in 'ci_udc_stop' drivers/usb/chipidea/udc.c:1965: warning: Function parameter or member 'ci' not described in 'udc_irq' drivers/usb/chipidea/udc.c:2095: warning: Function parameter or member 'ci' not described in 'ci_hdrc_gadget_destroy' drivers/usb/chipidea/udc.c:2144: warning: Function parameter or member 'ci' not described in 'ci_hdrc_gadget_init' Cc: Peter Chen Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20200703174148.2749969-13-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/chipidea/udc.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c index 2e6f13622bb9..14e09cad96b9 100644 --- a/drivers/usb/chipidea/udc.c +++ b/drivers/usb/chipidea/udc.c @@ -647,7 +647,7 @@ static int reprime_dtd(struct ci_hdrc *ci, struct ci_hw_ep *hwep, /** * _hardware_dequeue: handles a request at hardware level * @gadget: gadget - * @hwep: endpoint + * @hwreq: request * * This function returns an error code */ @@ -1326,7 +1326,7 @@ __acquires(ci->lock) /****************************************************************************** * ENDPT block *****************************************************************************/ -/** +/* * ep_enable: configure endpoint, making it usable * * Check usb_ep_enable() at "usb_gadget.h" for details @@ -1394,7 +1394,7 @@ static int ep_enable(struct usb_ep *ep, return retval; } -/** +/* * ep_disable: endpoint is no longer usable * * Check usb_ep_disable() at "usb_gadget.h" for details @@ -1434,7 +1434,7 @@ static int ep_disable(struct usb_ep *ep) return retval; } -/** +/* * ep_alloc_request: allocate a request object to use with this endpoint * * Check usb_ep_alloc_request() at "usb_gadget.h" for details @@ -1455,7 +1455,7 @@ static struct usb_request *ep_alloc_request(struct usb_ep *ep, gfp_t gfp_flags) return (hwreq == NULL) ? NULL : &hwreq->req; } -/** +/* * ep_free_request: frees a request object * * Check usb_ep_free_request() at "usb_gadget.h" for details @@ -1488,7 +1488,7 @@ static void ep_free_request(struct usb_ep *ep, struct usb_request *req) spin_unlock_irqrestore(hwep->lock, flags); } -/** +/* * ep_queue: queues (submits) an I/O request to an endpoint * * Check usb_ep_queue()* at usb_gadget.h" for details @@ -1513,7 +1513,7 @@ static int ep_queue(struct usb_ep *ep, struct usb_request *req, return retval; } -/** +/* * ep_dequeue: dequeues (cancels, unlinks) an I/O request from an endpoint * * Check usb_ep_dequeue() at "usb_gadget.h" for details @@ -1557,7 +1557,7 @@ static int ep_dequeue(struct usb_ep *ep, struct usb_request *req) return 0; } -/** +/* * ep_set_halt: sets the endpoint halt feature * * Check usb_ep_set_halt() at "usb_gadget.h" for details @@ -1567,7 +1567,7 @@ static int ep_set_halt(struct usb_ep *ep, int value) return _ep_set_halt(ep, value, true); } -/** +/* * ep_set_wedge: sets the halt feature and ignores clear requests * * Check usb_ep_set_wedge() at "usb_gadget.h" for details @@ -1587,7 +1587,7 @@ static int ep_set_wedge(struct usb_ep *ep) return usb_ep_set_halt(ep); } -/** +/* * ep_fifo_flush: flushes contents of a fifo * * Check usb_ep_fifo_flush() at "usb_gadget.h" for details @@ -1613,7 +1613,7 @@ static void ep_fifo_flush(struct usb_ep *ep) spin_unlock_irqrestore(hwep->lock, flags); } -/** +/* * Endpoint-specific part of the API to the USB controller hardware * Check "usb_gadget.h" for details */ @@ -1632,7 +1632,7 @@ static const struct usb_ep_ops usb_ep_ops = { /****************************************************************************** * GADGET block *****************************************************************************/ -/** +/* * ci_hdrc_gadget_connect: caller makes sure gadget driver is binded */ static void ci_hdrc_gadget_connect(struct usb_gadget *_gadget, int is_active) @@ -1782,7 +1782,7 @@ static struct usb_ep *ci_udc_match_ep(struct usb_gadget *gadget, return NULL; } -/** +/* * Device operations part of the API to the USB controller hardware, * which don't involve endpoints (or i/o) * Check "usb_gadget.h" for details @@ -1934,7 +1934,7 @@ static void ci_udc_stop_for_otg_fsm(struct ci_hdrc *ci) mutex_unlock(&ci->fsm.lock); } -/** +/* * ci_udc_stop: unregister a gadget driver */ static int ci_udc_stop(struct usb_gadget *gadget) @@ -1965,7 +1965,7 @@ static int ci_udc_stop(struct usb_gadget *gadget) /****************************************************************************** * BUS block *****************************************************************************/ -/** +/* * udc_irq: ci interrupt handler * * This function returns IRQ_HANDLED if the IRQ has been handled @@ -2096,7 +2096,7 @@ free_qh_pool: return retval; } -/** +/* * ci_hdrc_gadget_destroy: parent remove must call this to remove UDC * * No interrupts active, the IRQ has been released @@ -2146,7 +2146,7 @@ static void udc_id_switch_for_host(struct ci_hdrc *ci) /** * ci_hdrc_gadget_init - initialize device related bits - * ci: the controller + * @ci: the controller * * This function initializes the gadget, if the device is "device capable". */ -- cgit v1.2.3-70-g09d2 From f3a9492bb92ccc430abb7b41fc790259ba4113f3 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Fri, 3 Jul 2020 18:41:31 +0100 Subject: usb: host: xhci: Demote obvious misuse of kerneldoc to standard comment block No attempt has been made to document the demoted function here. Fixes the following W=1 kernel build warning(s): drivers/usb/host/xhci.c:1285: warning: Function parameter or member 'desc' not described in 'xhci_get_endpoint_index' Cc: Mathias Nyman Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20200703174148.2749969-14-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/xhci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/usb') diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index ed468eed299c..3c41b14ecce7 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -1271,7 +1271,7 @@ static int xhci_map_urb_for_dma(struct usb_hcd *hcd, struct urb *urb, return usb_hcd_map_urb_for_dma(hcd, urb, mem_flags); } -/** +/* * xhci_get_endpoint_index - Used for passing endpoint bitmasks between the core and * HCDs. Find the index for an endpoint given its descriptor. Use the return * value to right shift 1 for the bitmask. -- cgit v1.2.3-70-g09d2 From c3fa4e0467ac533285f6111c426ef8785ea3becc Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Fri, 3 Jul 2020 18:41:32 +0100 Subject: usb: host: xhci-mem: Demote obvious misuse of kerneldoc to standard comment block No attempt has been made to document the demoted function here. Fixes the following W=1 kernel build warning(s): drivers/usb/host/xhci-mem.c:365: warning: Function parameter or member 'xhci' not described in 'xhci_ring_alloc' drivers/usb/host/xhci-mem.c:365: warning: Function parameter or member 'num_segs' not described in 'xhci_ring_alloc' drivers/usb/host/xhci-mem.c:365: warning: Function parameter or member 'cycle_state' not described in 'xhci_ring_alloc' drivers/usb/host/xhci-mem.c:365: warning: Function parameter or member 'type' not described in 'xhci_ring_alloc' drivers/usb/host/xhci-mem.c:365: warning: Function parameter or member 'max_packet' not described in 'xhci_ring_alloc' drivers/usb/host/xhci-mem.c:365: warning: Function parameter or member 'flags' not described in 'xhci_ring_alloc' Cc: Mathias Nyman Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20200703174148.2749969-15-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/xhci-mem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/usb') diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index 9764122c9cdf..fb221c091478 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c @@ -352,7 +352,7 @@ static int xhci_alloc_segments_for_ring(struct xhci_hcd *xhci, return 0; } -/** +/* * Create a new ring with zero or more segments. * * Link each segment together into a ring. -- cgit v1.2.3-70-g09d2 From e57bde588458c8519e87baaa99c9311f7f4c2d36 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Fri, 3 Jul 2020 18:41:33 +0100 Subject: usb: host: xhci-dbgcap: File headers are not good candidates for kerneldoc Demote xhci-dbgcap's file header to a standard comment block. Fixes the following W=1 kernel build warning(s): drivers/usb/host/xhci-dbgcap.c:20: warning: Function parameter or member 'xhci' not described in 'dbc_dma_alloc_coherent' drivers/usb/host/xhci-dbgcap.c:20: warning: Function parameter or member 'size' not described in 'dbc_dma_alloc_coherent' drivers/usb/host/xhci-dbgcap.c:20: warning: Function parameter or member 'dma_handle' not described in 'dbc_dma_alloc_coherent' drivers/usb/host/xhci-dbgcap.c:20: warning: Function parameter or member 'flags' not described in 'dbc_dma_alloc_coherent' Cc: Mathias Nyman Cc: Lu Baolu Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20200703174148.2749969-16-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/xhci-dbgcap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/usb') diff --git a/drivers/usb/host/xhci-dbgcap.c b/drivers/usb/host/xhci-dbgcap.c index 93e2cca5262d..987f893e941c 100644 --- a/drivers/usb/host/xhci-dbgcap.c +++ b/drivers/usb/host/xhci-dbgcap.c @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 -/** +/* * xhci-dbgcap.c - xHCI debug capability support * * Copyright (C) 2017 Intel Corporation -- cgit v1.2.3-70-g09d2 From 0e1acecad2f2702244f5ce06f6156d449176d054 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Fri, 3 Jul 2020 18:41:34 +0100 Subject: usb: host: xhci-dbgtty: File headers are not good candidates for kerneldoc Demote xhci-dbgtty's file header to a standard comment block. Fixes the following W=1 kernel build warning(s): drivers/usb/host/xhci-dbgtty.c:19: warning: Function parameter or member 'port' not described in 'dbc_send_packet' drivers/usb/host/xhci-dbgtty.c:19: warning: Function parameter or member 'packet' not described in 'dbc_send_packet' drivers/usb/host/xhci-dbgtty.c:19: warning: Function parameter or member 'size' not described in 'dbc_send_packet' Cc: Mathias Nyman Cc: Lu Baolu Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20200703174148.2749969-17-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/xhci-dbgtty.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/usb') diff --git a/drivers/usb/host/xhci-dbgtty.c b/drivers/usb/host/xhci-dbgtty.c index be726c791323..9a1d38442578 100644 --- a/drivers/usb/host/xhci-dbgtty.c +++ b/drivers/usb/host/xhci-dbgtty.c @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 -/** +/* * xhci-dbgtty.c - tty glue for xHCI debug capability * * Copyright (C) 2017 Intel Corporation -- cgit v1.2.3-70-g09d2 From f2926dd5938e278652cdec85cafe5f727997877a Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Fri, 3 Jul 2020 18:41:35 +0100 Subject: usb: chipidea: udc: Fix a few kerneldoc issues Descriptions were missing for 'ci' almost throughout. There was one instance of over-documenting. Finally one function argument was incorrectly documented (probably down to bitrot). Fixes the following W=1 kernel build warning(s): drivers/usb/chipidea/udc.c:245: warning: Function parameter or member 'ci' not described in 'hw_port_is_high_speed' drivers/usb/chipidea/udc.c:271: warning: Function parameter or member 'ci' not described in 'hw_test_and_clear_intr_active' drivers/usb/chipidea/udc.c:285: warning: Function parameter or member 'ci' not described in 'hw_test_and_clear_setup_guard' drivers/usb/chipidea/udc.c:296: warning: Function parameter or member 'ci' not described in 'hw_test_and_set_setup_guard' drivers/usb/chipidea/udc.c:321: warning: Function parameter or member 'ci' not described in 'hw_usb_reset' drivers/usb/chipidea/udc.c:628: warning: Excess function parameter 'ci' description in 'free_pending_td' drivers/usb/chipidea/udc.c:655: warning: Function parameter or member 'hwep' not described in '_hardware_dequeue' drivers/usb/chipidea/udc.c:655: warning: Excess function parameter 'gadget' description in '_hardware_dequeue' Cc: Peter Chen Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20200703174148.2749969-18-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/chipidea/udc.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c index 14e09cad96b9..6f173de1a5c1 100644 --- a/drivers/usb/chipidea/udc.c +++ b/drivers/usb/chipidea/udc.c @@ -238,6 +238,7 @@ static int hw_ep_set_halt(struct ci_hdrc *ci, int num, int dir, int value) /** * hw_is_port_high_speed: test if port is high speed + * @ci: the controller * * This function returns true if high speed port */ @@ -264,6 +265,7 @@ static int hw_test_and_clear_complete(struct ci_hdrc *ci, int n) /** * hw_test_and_clear_intr_active: test & clear active interrupts (execute * without interruption) + * @ci: the controller * * This function returns active interrutps */ @@ -278,6 +280,7 @@ static u32 hw_test_and_clear_intr_active(struct ci_hdrc *ci) /** * hw_test_and_clear_setup_guard: test & clear setup guard (execute without * interruption) + * @ci: the controller * * This function returns guard value */ @@ -289,6 +292,7 @@ static int hw_test_and_clear_setup_guard(struct ci_hdrc *ci) /** * hw_test_and_set_setup_guard: test & set setup guard (execute without * interruption) + * @ci: the controller * * This function returns guard value */ @@ -314,6 +318,7 @@ static void hw_usb_set_address(struct ci_hdrc *ci, u8 value) /** * hw_usb_reset: restart device after a bus reset (execute without * interruption) + * @ci: the controller * * This function returns an error code */ @@ -621,7 +626,6 @@ done: /** * free_pending_td: remove a pending request for the endpoint - * @ci: the controller * @hwep: endpoint */ static void free_pending_td(struct ci_hw_ep *hwep) @@ -646,7 +650,7 @@ static int reprime_dtd(struct ci_hdrc *ci, struct ci_hw_ep *hwep, /** * _hardware_dequeue: handles a request at hardware level - * @gadget: gadget + * @hwep: endpoint * @hwreq: request * * This function returns an error code -- cgit v1.2.3-70-g09d2 From 142c8bb6c516a4caed569a68589489d4d91377e6 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Fri, 3 Jul 2020 18:41:36 +0100 Subject: usb: host: xhci-debugfs: Use 'gnu_printf' format notation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes the following W=1 kernel build warning(s): drivers/usb/host/xhci-debugfs.c:128:2: warning: function ‘xhci_debugfs_regset’ might be a candidate for ‘gnu_printf’ format attribute [-Wsuggest-attribute=format] 128 | vsnprintf(rgs->name, sizeof(rgs->name), fmt, args); | ^~~~~~~~~ Cc: Mathias Nyman Cc: Lu Baolu Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20200703174148.2749969-19-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/xhci-debugfs.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/usb') diff --git a/drivers/usb/host/xhci-debugfs.c b/drivers/usb/host/xhci-debugfs.c index 76c3f29562d2..92e25a62fdb5 100644 --- a/drivers/usb/host/xhci-debugfs.c +++ b/drivers/usb/host/xhci-debugfs.c @@ -110,6 +110,7 @@ static void xhci_debugfs_free_regset(struct xhci_regset *regset) kfree(regset); } +__printf(6, 7) static void xhci_debugfs_regset(struct xhci_hcd *xhci, u32 base, const struct debugfs_reg32 *regs, size_t nregs, struct dentry *parent, -- cgit v1.2.3-70-g09d2 From 7565fce17d19d9f0ab9062cb30653608d5d0cfad Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Fri, 3 Jul 2020 18:41:37 +0100 Subject: usb: storage: alauda: Remove set but unchecked variable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The return value of alauda_get_media_status() hasn't been checked since the driver's inception back in 2005. If nothing have gone wrong/been detected until this point, it's probably safe to just remove the variable. Fixes the following W=1 kernel build warning(s): drivers/usb/storage/alauda.c: In function ‘alauda_check_media’: drivers/usb/storage/alauda.c:456:6: warning: variable ‘rc’ set but not used [-Wunused-but-set-variable] 456 | int rc; | ^~ Cc: Alan Stern Cc: Daniel Drake Cc: usb-storage@lists.one-eyed-alien.net Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20200703174148.2749969-20-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/storage/alauda.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/storage/alauda.c b/drivers/usb/storage/alauda.c index ddab2cd3d2e7..20b857e97e60 100644 --- a/drivers/usb/storage/alauda.c +++ b/drivers/usb/storage/alauda.c @@ -453,9 +453,8 @@ static int alauda_check_media(struct us_data *us) { struct alauda_info *info = (struct alauda_info *) us->extra; unsigned char status[2]; - int rc; - rc = alauda_get_media_status(us, status); + alauda_get_media_status(us, status); /* Check for no media or door open */ if ((status[0] & 0x80) || ((status[0] & 0x1F) == 0x10) -- cgit v1.2.3-70-g09d2 From 50c9bd05df6f53f255b1a303da06582009e6d0c5 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Fri, 3 Jul 2020 18:41:38 +0100 Subject: usb: typec: altmodes: displayport: File headers are not good candidates for kerneldoc Demote displayport's file header to a standard comment block. Fixes the following W=1 kernel build warning(s): drivers/usb/typec/altmodes/displayport.c:18: warning: Function parameter or member '_dp' not described in 'DP_HEADER' drivers/usb/typec/altmodes/displayport.c:18: warning: Function parameter or member 'cmd' not described in 'DP_HEADER' Cc: Heikki Krogerus Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20200703174148.2749969-21-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/typec/altmodes/displayport.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/usb') diff --git a/drivers/usb/typec/altmodes/displayport.c b/drivers/usb/typec/altmodes/displayport.c index 0edfb89e04a8..d617663b981d 100644 --- a/drivers/usb/typec/altmodes/displayport.c +++ b/drivers/usb/typec/altmodes/displayport.c @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 -/** +/* * USB Typec-C DisplayPort Alternate Mode driver * * Copyright (C) 2018 Intel Corporation -- cgit v1.2.3-70-g09d2 From 318ebed29718daa2ffbe7be52ad2279d01efdf08 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Fri, 3 Jul 2020 18:41:39 +0100 Subject: usb: typec: altmodes: displayport: Supply missing displayport.h include file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If the header file containing a function's prototype isn't included by the sourcefile containing the associated function, the build system complains of missing prototypes. Fixes the following W=1 kernel build warning(s): drivers/usb/typec/altmodes/displayport.c:511:5: warning: no previous prototype for ‘dp_altmode_probe’ [-Wmissing-prototypes] drivers/usb/typec/altmodes/displayport.c:551:6: warning: no previous prototype for ‘dp_altmode_remove’ [-Wmissing-prototypes] Cc: Heikki Krogerus Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20200703174148.2749969-22-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/typec/altmodes/displayport.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/usb') diff --git a/drivers/usb/typec/altmodes/displayport.c b/drivers/usb/typec/altmodes/displayport.c index d617663b981d..7b20073d7fc0 100644 --- a/drivers/usb/typec/altmodes/displayport.c +++ b/drivers/usb/typec/altmodes/displayport.c @@ -13,6 +13,7 @@ #include #include #include +#include "displayport.h" #define DP_HEADER(_dp, cmd) (VDO((_dp)->alt->svid, 1, cmd) | \ VDO_OPOS(USB_TYPEC_DP_MODE)) -- cgit v1.2.3-70-g09d2 From 71be1a8aef82e9fee27eab4eaa818492eb846e29 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Fri, 3 Jul 2020 18:41:40 +0100 Subject: usb: typec: tcpm: fusb302: Use 'gnu_printf' format notation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes the following W=1 kernel build warning(s): drivers/usb/typec/tcpm/fusb302.c: In function ‘fusb302_log’: drivers/usb/typec/tcpm/fusb302.c:186:2: warning: function ‘fusb302_log’ might be a candidate for ‘gnu_printf’ format attribute [-Wsuggest-attribute=format] 186 | _fusb302_log(chip, fmt, args); | ^~~~~~~~~~~~ Cc: Heikki Krogerus Cc: Yueyao Zhu Signed-off-by: Lee Jones Reviewed-by: Guenter Roeck Link: https://lore.kernel.org/r/20200703174148.2749969-23-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/typec/tcpm/fusb302.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/usb') diff --git a/drivers/usb/typec/tcpm/fusb302.c b/drivers/usb/typec/tcpm/fusb302.c index b28facece43c..99562cc65ca6 100644 --- a/drivers/usb/typec/tcpm/fusb302.c +++ b/drivers/usb/typec/tcpm/fusb302.c @@ -178,6 +178,7 @@ abort: mutex_unlock(&chip->logbuffer_lock); } +__printf(2, 3) static void fusb302_log(struct fusb302_chip *chip, const char *fmt, ...) { va_list args; -- cgit v1.2.3-70-g09d2 From 20f81da90145ee08a49e9d254957e001c237e467 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Fri, 3 Jul 2020 18:41:41 +0100 Subject: usb: chipidea: usbmisc_imx: Demote obvious misuse of kerneldoc to standard comment block No attempt has been made to document the demoted function here. Fixes the following W=1 kernel build warning(s): drivers/usb/chipidea/usbmisc_imx.c:801: warning: Function parameter or member 'data' not described in 'imx7d_charger_detection' Cc: Peter Chen Cc: Shawn Guo Cc: Sascha Hauer Cc: Pengutronix Kernel Team Cc: Fabio Estevam Cc: NXP Linux Team Cc: Richard Zhao Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20200703174148.2749969-24-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/chipidea/usbmisc_imx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/usb') diff --git a/drivers/usb/chipidea/usbmisc_imx.c b/drivers/usb/chipidea/usbmisc_imx.c index f136876cb4a3..8a8e7ad928a6 100644 --- a/drivers/usb/chipidea/usbmisc_imx.c +++ b/drivers/usb/chipidea/usbmisc_imx.c @@ -789,7 +789,7 @@ static int imx7d_charger_primary_detection(struct imx_usbmisc_data *data) return 0; } -/** +/* * Whole charger detection process: * 1. OPMODE override to be non-driving * 2. Data contact check -- cgit v1.2.3-70-g09d2 From 2ba277a0cff64d339f56471896ced46604d9f4ce Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Fri, 3 Jul 2020 18:41:42 +0100 Subject: usb: misc: iowarrior: Fix odd corruption issue in the file header Looks although Stephane's name was corrupted somehow. Cc: Johan Hovold Cc: Christian Lucht Cc: Stephane Dalton Cc: Stephane Doyon Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20200703174148.2749969-25-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/misc/iowarrior.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/usb') diff --git a/drivers/usb/misc/iowarrior.c b/drivers/usb/misc/iowarrior.c index dce20301e367..40e8c06894bf 100644 --- a/drivers/usb/misc/iowarrior.c +++ b/drivers/usb/misc/iowarrior.c @@ -9,7 +9,7 @@ * usb-skeleton.c by Greg Kroah-Hartman * brlvger.c by Stephane Dalton - * and St�hane Doyon + * and Stephane Doyon * * Released under the GPLv2. */ -- cgit v1.2.3-70-g09d2 From c16700ed237947977436d76525d8de65fbb3446c Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Fri, 3 Jul 2020 18:41:43 +0100 Subject: usb: misc: iowarrior: Demote obvious misuse of kerneldoc to standard comment blocks No attempt has been made to document any of the demoted functions here. Fixes the following W=1 kernel build warning(s): drivers/usb/misc/iowarrior.c:251: warning: Function parameter or member 'dev' not described in 'iowarrior_delete' drivers/usb/misc/iowarrior.c:279: warning: Function parameter or member 'file' not described in 'iowarrior_read' drivers/usb/misc/iowarrior.c:279: warning: Function parameter or member 'buffer' not described in 'iowarrior_read' drivers/usb/misc/iowarrior.c:279: warning: Function parameter or member 'count' not described in 'iowarrior_read' drivers/usb/misc/iowarrior.c:279: warning: Function parameter or member 'ppos' not described in 'iowarrior_read' drivers/usb/misc/iowarrior.c:483: warning: Function parameter or member 'file' not described in 'iowarrior_ioctl' drivers/usb/misc/iowarrior.c:483: warning: Function parameter or member 'cmd' not described in 'iowarrior_ioctl' drivers/usb/misc/iowarrior.c:483: warning: Function parameter or member 'arg' not described in 'iowarrior_ioctl' drivers/usb/misc/iowarrior.c:599: warning: Function parameter or member 'inode' not described in 'iowarrior_open' drivers/usb/misc/iowarrior.c:599: warning: Function parameter or member 'file' not described in 'iowarrior_open' drivers/usb/misc/iowarrior.c:647: warning: Function parameter or member 'inode' not described in 'iowarrior_release' drivers/usb/misc/iowarrior.c:647: warning: Function parameter or member 'file' not described in 'iowarrior_release' drivers/usb/misc/iowarrior.c:753: warning: Function parameter or member 'interface' not described in 'iowarrior_probe' drivers/usb/misc/iowarrior.c:753: warning: Function parameter or member 'id' not described in 'iowarrior_probe' drivers/usb/misc/iowarrior.c:879: warning: Function parameter or member 'interface' not described in 'iowarrior_disconnect' Cc: Johan Hovold Cc: Christian Lucht Cc: Stephane Dalton Cc: Stephane Doyon Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20200703174148.2749969-26-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/misc/iowarrior.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/misc/iowarrior.c b/drivers/usb/misc/iowarrior.c index 40e8c06894bf..4afd1ace3d32 100644 --- a/drivers/usb/misc/iowarrior.c +++ b/drivers/usb/misc/iowarrior.c @@ -244,7 +244,7 @@ static void iowarrior_write_callback(struct urb *urb) wake_up_interruptible(&dev->write_wait); } -/** +/* * iowarrior_delete */ static inline void iowarrior_delete(struct iowarrior *dev) @@ -271,7 +271,7 @@ static int read_index(struct iowarrior *dev) return (read_idx == intr_idx ? -1 : read_idx); } -/** +/* * iowarrior_read */ static ssize_t iowarrior_read(struct file *file, char __user *buffer, @@ -475,7 +475,7 @@ exit: return retval; } -/** +/* * iowarrior_ioctl */ static long iowarrior_ioctl(struct file *file, unsigned int cmd, @@ -592,7 +592,7 @@ error_out: return retval; } -/** +/* * iowarrior_open */ static int iowarrior_open(struct inode *inode, struct file *file) @@ -640,7 +640,7 @@ out: return retval; } -/** +/* * iowarrior_release */ static int iowarrior_release(struct inode *inode, struct file *file) @@ -742,7 +742,7 @@ static struct usb_class_driver iowarrior_class = { /*---------------------------------*/ /* probe and disconnect functions */ /*---------------------------------*/ -/** +/* * iowarrior_probe * * Called by the usb core when a new device is connected that it thinks @@ -870,7 +870,7 @@ error: return retval; } -/** +/* * iowarrior_disconnect * * Called by the usb core when the device is removed from the system. -- cgit v1.2.3-70-g09d2 From 1ba1f1414b543f53e00d43fee6f6239cb519dae1 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Fri, 3 Jul 2020 18:41:44 +0100 Subject: usb: gadget: function: u_serial: Repair misdocumented function argument MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Looks as though this has been an issue since the driver's inception back in 2014. Fixes the following W=1 kernel build warning(s): drivers/usb/gadget/function/u_serial.c:538: warning: Function parameter or member 'port' not described in 'gs_start_io' drivers/usb/gadget/function/u_serial.c:538: warning: Excess function parameter 'dev' description in 'gs_start_io' Cc: Felipe Balbi Cc: "Michał Mirosław" Cc: Al Borchers Cc: Peter Berger Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20200703174148.2749969-27-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/function/u_serial.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/usb') diff --git a/drivers/usb/gadget/function/u_serial.c b/drivers/usb/gadget/function/u_serial.c index 3cfc6e2eba71..c295defe7ecd 100644 --- a/drivers/usb/gadget/function/u_serial.c +++ b/drivers/usb/gadget/function/u_serial.c @@ -527,7 +527,7 @@ static int gs_alloc_requests(struct usb_ep *ep, struct list_head *head, /** * gs_start_io - start USB I/O streams - * @dev: encapsulates endpoints to use + * @port: port to use * Context: holding port_lock; port_tty and port_usb are non-null * * We only start I/O when something is connected to both sides of -- cgit v1.2.3-70-g09d2 From 7e8455b1585e241527105d850a6d261c289c1417 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Fri, 3 Jul 2020 18:41:45 +0100 Subject: usb: misc: ldusb: Demote obvious misuse of kerneldoc to standard comment blocks No attempt has been made to document any of the demoted functions here. Fixes the following W=1 kernel build warning(s): drivers/usb/misc/ldusb.c:192: warning: Function parameter or member 'dev' not described in 'ld_usb_abort_transfers' drivers/usb/misc/ldusb.c:206: warning: Function parameter or member 'dev' not described in 'ld_usb_delete' drivers/usb/misc/ldusb.c:220: warning: Function parameter or member 'urb' not described in 'ld_usb_interrupt_in_callback' drivers/usb/misc/ldusb.c:281: warning: Function parameter or member 'urb' not described in 'ld_usb_interrupt_out_callback' drivers/usb/misc/ldusb.c:301: warning: Function parameter or member 'inode' not described in 'ld_usb_open' drivers/usb/misc/ldusb.c:301: warning: Function parameter or member 'file' not described in 'ld_usb_open' drivers/usb/misc/ldusb.c:372: warning: Function parameter or member 'inode' not described in 'ld_usb_release' drivers/usb/misc/ldusb.c:372: warning: Function parameter or member 'file' not described in 'ld_usb_release' drivers/usb/misc/ldusb.c:414: warning: Function parameter or member 'file' not described in 'ld_usb_poll' drivers/usb/misc/ldusb.c:414: warning: Function parameter or member 'wait' not described in 'ld_usb_poll' drivers/usb/misc/ldusb.c:439: warning: Function parameter or member 'file' not described in 'ld_usb_read' drivers/usb/misc/ldusb.c:439: warning: Function parameter or member 'buffer' not described in 'ld_usb_read' drivers/usb/misc/ldusb.c:439: warning: Function parameter or member 'count' not described in 'ld_usb_read' drivers/usb/misc/ldusb.c:439: warning: Function parameter or member 'ppos' not described in 'ld_usb_read' drivers/usb/misc/ldusb.c:526: warning: Function parameter or member 'file' not described in 'ld_usb_write' drivers/usb/misc/ldusb.c:526: warning: Function parameter or member 'buffer' not described in 'ld_usb_write' drivers/usb/misc/ldusb.c:526: warning: Function parameter or member 'count' not described in 'ld_usb_write' drivers/usb/misc/ldusb.c:526: warning: Function parameter or member 'ppos' not described in 'ld_usb_write' drivers/usb/misc/ldusb.c:651: warning: Function parameter or member 'intf' not described in 'ld_usb_probe' drivers/usb/misc/ldusb.c:651: warning: Function parameter or member 'id' not described in 'ld_usb_probe' drivers/usb/misc/ldusb.c:754: warning: Function parameter or member 'intf' not described in 'ld_usb_disconnect' Cc: Johan Hovold Cc: Michael Hund Cc: David Glance Cc: Juergen Stuber Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20200703174148.2749969-28-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/misc/ldusb.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/misc/ldusb.c b/drivers/usb/misc/ldusb.c index 8f86b4ebca89..670e4d91e9ca 100644 --- a/drivers/usb/misc/ldusb.c +++ b/drivers/usb/misc/ldusb.c @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0+ -/** +/* * Generic USB driver for report based interrupt in/out devices * like LD Didactic's USB devices. LD Didactic's USB devices are * HID devices which do not use HID report definitons (they use @@ -184,7 +184,7 @@ struct ld_usb { static struct usb_driver ld_usb_driver; -/** +/* * ld_usb_abort_transfers * aborts transfers and frees associated data structures */ @@ -199,7 +199,7 @@ static void ld_usb_abort_transfers(struct ld_usb *dev) usb_kill_urb(dev->interrupt_out_urb); } -/** +/* * ld_usb_delete */ static void ld_usb_delete(struct ld_usb *dev) @@ -213,7 +213,7 @@ static void ld_usb_delete(struct ld_usb *dev) kfree(dev); } -/** +/* * ld_usb_interrupt_in_callback */ static void ld_usb_interrupt_in_callback(struct urb *urb) @@ -274,7 +274,7 @@ exit: wake_up_interruptible(&dev->read_wait); } -/** +/* * ld_usb_interrupt_out_callback */ static void ld_usb_interrupt_out_callback(struct urb *urb) @@ -294,7 +294,7 @@ static void ld_usb_interrupt_out_callback(struct urb *urb) wake_up_interruptible(&dev->write_wait); } -/** +/* * ld_usb_open */ static int ld_usb_open(struct inode *inode, struct file *file) @@ -365,7 +365,7 @@ unlock_exit: return retval; } -/** +/* * ld_usb_release */ static int ld_usb_release(struct inode *inode, struct file *file) @@ -407,7 +407,7 @@ exit: return retval; } -/** +/* * ld_usb_poll */ static __poll_t ld_usb_poll(struct file *file, poll_table *wait) @@ -431,7 +431,7 @@ static __poll_t ld_usb_poll(struct file *file, poll_table *wait) return mask; } -/** +/* * ld_usb_read */ static ssize_t ld_usb_read(struct file *file, char __user *buffer, size_t count, @@ -518,7 +518,7 @@ exit: return retval; } -/** +/* * ld_usb_write */ static ssize_t ld_usb_write(struct file *file, const char __user *buffer, @@ -641,7 +641,7 @@ static struct usb_class_driver ld_usb_class = { .minor_base = USB_LD_MINOR_BASE, }; -/** +/* * ld_usb_probe * * Called by the usb core when a new device is connected that it thinks @@ -745,7 +745,7 @@ error: return retval; } -/** +/* * ld_usb_disconnect * * Called by the usb core when the device is removed from the system. -- cgit v1.2.3-70-g09d2 From 09e03a89da11c78e53d1dfc3f324dd0ed89a1e8d Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Fri, 3 Jul 2020 18:41:46 +0100 Subject: usb: musb: musb_dsps: Demote obvious misuse of kerneldoc to standard comment blocks No attempt has been made to document any of the demoted functions here. Fixes the following W=1 kernel build warning(s): drivers/usb/musb/musb_dsps.c:44: warning: cannot understand function prototype: 'struct dsps_musb_wrapper ' drivers/usb/musb/musb_dsps.c:102: warning: cannot understand function prototype: 'struct dsps_glue ' drivers/usb/musb/musb_dsps.c:169: warning: Function parameter or member 'musb' not described in 'dsps_musb_enable' drivers/usb/musb/musb_dsps.c:195: warning: Function parameter or member 'musb' not described in 'dsps_musb_disable' Cc: Bin Liu Cc: Ravi B Cc: Kumar Gupta Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20200703174148.2749969-29-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/musb/musb_dsps.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c index 88923175f71e..71660491557f 100644 --- a/drivers/usb/musb/musb_dsps.c +++ b/drivers/usb/musb/musb_dsps.c @@ -36,7 +36,7 @@ static const struct of_device_id musb_dsps_of_match[]; -/** +/* * DSPS musb wrapper register offset. * FIXME: This should be expanded to have all the wrapper registers from TI DSPS * musb ips. @@ -96,7 +96,7 @@ struct dsps_context { u32 rx_mode; }; -/** +/* * DSPS glue structure. */ struct dsps_glue { @@ -162,7 +162,7 @@ static void dsps_mod_timer_optional(struct dsps_glue *glue) #define USBSS_IRQ_PD_COMP (1 << 2) -/** +/* * dsps_musb_enable - enable interrupts */ static void dsps_musb_enable(struct musb *musb) @@ -188,7 +188,7 @@ static void dsps_musb_enable(struct musb *musb) dsps_mod_timer(glue, -1); } -/** +/* * dsps_musb_disable - disable HDRC and flush interrupts */ static void dsps_musb_disable(struct musb *musb) -- cgit v1.2.3-70-g09d2 From 66f84901b0a70c4436e31c1a2359a862a2177fb8 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Fri, 3 Jul 2020 18:41:48 +0100 Subject: usb: gadget: udc: dummy_hcd: Repair misspelled function argument 'dummy_hcd' An attempt was made to document the functions in 'dummy_hcd', but a simple spelling mistake was made. Fixes the following W=1 kernel build warning(s): drivers/usb/gadget/udc/dummy_hcd.c:1597: warning: Function parameter or member 'dum_hcd' not described in 'handle_control_request' drivers/usb/gadget/udc/dummy_hcd.c:1597: warning: Excess function parameter 'dum' description in 'handle_control_request' Cc: Felipe Balbi Cc: Andrey Konovalov Cc: Alan Stern Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20200703174148.2749969-31-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/udc/dummy_hcd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/usb') diff --git a/drivers/usb/gadget/udc/dummy_hcd.c b/drivers/usb/gadget/udc/dummy_hcd.c index 425a97926590..de65d424fb65 100644 --- a/drivers/usb/gadget/udc/dummy_hcd.c +++ b/drivers/usb/gadget/udc/dummy_hcd.c @@ -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 -- cgit v1.2.3-70-g09d2 From 464b7d0e538ef26a0f431f0d734acbaeab3a5767 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Mon, 6 Jul 2020 14:33:10 +0100 Subject: usb: misc: legousbtower: Demote obvious misuse of kerneldoc to standard comment blocks No attempt has been made to document any of the demoted functions here. Fixes the following W=1 kernel build warning(s): drivers/usb/misc/legousbtower.c:280: warning: Function parameter or member 'dev' not described in 'lego_usb_tower_debug_data' drivers/usb/misc/legousbtower.c:280: warning: Function parameter or member 'function' not described in 'lego_usb_tower_debug_data' drivers/usb/misc/legousbtower.c:280: warning: Function parameter or member 'size' not described in 'lego_usb_tower_debug_data' drivers/usb/misc/legousbtower.c:280: warning: Function parameter or member 'data' not described in 'lego_usb_tower_debug_data' drivers/usb/misc/legousbtower.c:290: warning: Function parameter or member 'dev' not described in 'tower_delete' drivers/usb/misc/legousbtower.c:306: warning: Function parameter or member 'inode' not described in 'tower_open' drivers/usb/misc/legousbtower.c:306: warning: Function parameter or member 'file' not described in 'tower_open' drivers/usb/misc/legousbtower.c:405: warning: Function parameter or member 'inode' not described in 'tower_release' drivers/usb/misc/legousbtower.c:405: warning: Function parameter or member 'file' not described in 'tower_release' drivers/usb/misc/legousbtower.c:452: warning: Function parameter or member 'dev' not described in 'tower_check_for_read_packet' drivers/usb/misc/legousbtower.c:468: warning: Function parameter or member 'file' not described in 'tower_poll' drivers/usb/misc/legousbtower.c:468: warning: Function parameter or member 'wait' not described in 'tower_poll' drivers/usb/misc/legousbtower.c:494: warning: Function parameter or member 'file' not described in 'tower_llseek' drivers/usb/misc/legousbtower.c:494: warning: Function parameter or member 'off' not described in 'tower_llseek' drivers/usb/misc/legousbtower.c:494: warning: Function parameter or member 'whence' not described in 'tower_llseek' drivers/usb/misc/legousbtower.c:503: warning: Function parameter or member 'file' not described in 'tower_read' drivers/usb/misc/legousbtower.c:503: warning: Function parameter or member 'buffer' not described in 'tower_read' drivers/usb/misc/legousbtower.c:503: warning: Function parameter or member 'count' not described in 'tower_read' drivers/usb/misc/legousbtower.c:503: warning: Function parameter or member 'ppos' not described in 'tower_read' drivers/usb/misc/legousbtower.c:587: warning: Function parameter or member 'file' not described in 'tower_write' drivers/usb/misc/legousbtower.c:587: warning: Function parameter or member 'buffer' not described in 'tower_write' drivers/usb/misc/legousbtower.c:587: warning: Function parameter or member 'count' not described in 'tower_write' drivers/usb/misc/legousbtower.c:587: warning: Function parameter or member 'ppos' not described in 'tower_write' drivers/usb/misc/legousbtower.c:669: warning: Function parameter or member 'urb' not described in 'tower_interrupt_in_callback' drivers/usb/misc/legousbtower.c:724: warning: Function parameter or member 'urb' not described in 'tower_interrupt_out_callback' drivers/usb/misc/legousbtower.c:752: warning: Function parameter or member 'interface' not described in 'tower_probe' drivers/usb/misc/legousbtower.c:752: warning: Function parameter or member 'id' not described in 'tower_probe' drivers/usb/misc/legousbtower.c:863: warning: Function parameter or member 'interface' not described in 'tower_disconnect' Cc: Juergen Stuber Cc: David Glance Cc: david Cc: legousb-devel@lists.sourceforge.net Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20200706133341.476881-2-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/misc/legousbtower.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/misc/legousbtower.c b/drivers/usb/misc/legousbtower.c index ab4b98b04115..8aca55c4c95f 100644 --- a/drivers/usb/misc/legousbtower.c +++ b/drivers/usb/misc/legousbtower.c @@ -283,7 +283,7 @@ static inline void lego_usb_tower_debug_data(struct device *dev, } -/** +/* * tower_delete */ static inline void tower_delete(struct lego_usb_tower *dev) @@ -299,7 +299,7 @@ static inline void tower_delete(struct lego_usb_tower *dev) } -/** +/* * tower_open */ static int tower_open(struct inode *inode, struct file *file) @@ -398,7 +398,7 @@ exit: return retval; } -/** +/* * tower_release */ static int tower_release(struct inode *inode, struct file *file) @@ -440,7 +440,7 @@ exit: return retval; } -/** +/* * tower_check_for_read_packet * * To get correct semantics for signals and non-blocking I/O @@ -461,7 +461,7 @@ static void tower_check_for_read_packet(struct lego_usb_tower *dev) } -/** +/* * tower_poll */ static __poll_t tower_poll(struct file *file, poll_table *wait) @@ -487,7 +487,7 @@ static __poll_t tower_poll(struct file *file, poll_table *wait) } -/** +/* * tower_llseek */ static loff_t tower_llseek(struct file *file, loff_t off, int whence) @@ -496,7 +496,7 @@ static loff_t tower_llseek(struct file *file, loff_t off, int whence) } -/** +/* * tower_read */ static ssize_t tower_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos) @@ -580,7 +580,7 @@ exit: } -/** +/* * tower_write */ static ssize_t tower_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos) @@ -662,7 +662,7 @@ exit: } -/** +/* * tower_interrupt_in_callback */ static void tower_interrupt_in_callback(struct urb *urb) @@ -717,7 +717,7 @@ exit: } -/** +/* * tower_interrupt_out_callback */ static void tower_interrupt_out_callback(struct urb *urb) @@ -742,7 +742,7 @@ static void tower_interrupt_out_callback(struct urb *urb) } -/** +/* * tower_probe * * Called by the usb core when a new device is connected that it thinks @@ -854,7 +854,7 @@ error: } -/** +/* * tower_disconnect * * Called by the usb core when the device is removed from the system. -- cgit v1.2.3-70-g09d2 From f2db5f20bbfe2f459ad0b3ddec46fe3d002635e6 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Mon, 6 Jul 2020 14:33:11 +0100 Subject: usb: chipidea: ci_hdrc_pci: Fix improper use of kerneldoc format No attempt has been made to document any of the structure's properties here. Fixes the following W=1 kernel build warning(s): drivers/usb/chipidea/ci_hdrc_pci.c:132: warning: cannot understand function prototype: 'const struct pci_device_id ci_hdrc_pci_id_table[] = ' Cc: Peter Chen Cc: David Lopo Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20200706133341.476881-3-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/chipidea/ci_hdrc_pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/usb') diff --git a/drivers/usb/chipidea/ci_hdrc_pci.c b/drivers/usb/chipidea/ci_hdrc_pci.c index 49a61549cee6..d63479e1ad10 100644 --- a/drivers/usb/chipidea/ci_hdrc_pci.c +++ b/drivers/usb/chipidea/ci_hdrc_pci.c @@ -120,7 +120,7 @@ static void ci_hdrc_pci_remove(struct pci_dev *pdev) usb_phy_generic_unregister(ci->phy); } -/** +/* * PCI device table * PCI device structure * -- cgit v1.2.3-70-g09d2 From 89dd9a8c27f841704b527810f9180f06c351b89b Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Mon, 6 Jul 2020 14:33:12 +0100 Subject: usb: gadget: legacy: printer: Remove unused variable 'driver_desc' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes the following W=1 kernel build warning(s): drivers/usb/gadget/legacy/printer.c:24:19: warning: ‘driver_desc’ defined but not used [-Wunused-const-variable=] Cc: Felipe Balbi Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20200706133341.476881-4-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/legacy/printer.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers/usb') diff --git a/drivers/usb/gadget/legacy/printer.c b/drivers/usb/gadget/legacy/printer.c index 57858f0c2b6c..2cd389575084 100644 --- a/drivers/usb/gadget/legacy/printer.c +++ b/drivers/usb/gadget/legacy/printer.c @@ -21,7 +21,6 @@ USB_GADGET_COMPOSITE_OPTIONS(); #define DRIVER_VERSION "2015 FEB 17" static const char shortname [] = "printer"; -static const char driver_desc [] = DRIVER_DESC; #include "u_printer.h" -- cgit v1.2.3-70-g09d2 From 5307011537981459b2ba7bc1b7460cc7ceee74f2 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Mon, 6 Jul 2020 14:33:13 +0100 Subject: usb: gadget: udc: amd5536udc_pci: Remove unused variable 'mod_desc' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes the following W=1 kernel build warning(s): drivers/usb/gadget/udc/amd5536udc_pci.c:52:19: warning: ‘mod_desc’ defined but not used [-Wunused-const-variable=] Cc: Felipe Balbi Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20200706133341.476881-5-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/udc/amd5536udc_pci.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers/usb') diff --git a/drivers/usb/gadget/udc/amd5536udc_pci.c b/drivers/usb/gadget/udc/amd5536udc_pci.c index 80685e4306f3..56258d076abc 100644 --- a/drivers/usb/gadget/udc/amd5536udc_pci.c +++ b/drivers/usb/gadget/udc/amd5536udc_pci.c @@ -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 */ -- cgit v1.2.3-70-g09d2 From b1e4d550ca12eae06d5f3860a105cc9abeae5094 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Mon, 6 Jul 2020 14:33:14 +0100 Subject: usb: gadget: function: u_ether: Downgrade kerneldoc headers which to not make the mark Kerneldoc expects all function arguments to be documented. If any are missed it will complain. Downgrade one header with 3 missing argument descriptions and one which makes no attempt. Fixes the following W=1 kernel build warning(s): drivers/usb/gadget/function/u_ether.c:750: warning: Function parameter or member 'dev_addr' not described in 'gether_setup_name' drivers/usb/gadget/function/u_ether.c:750: warning: Function parameter or member 'host_addr' not described in 'gether_setup_name' drivers/usb/gadget/function/u_ether.c:750: warning: Function parameter or member 'qmult' not described in 'gether_setup_name' drivers/usb/gadget/function/u_ether.c:1022: warning: Function parameter or member 'dev' not described in 'gether_cleanup' Cc: Felipe Balbi Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20200706133341.476881-6-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/function/u_ether.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/gadget/function/u_ether.c b/drivers/usb/gadget/function/u_ether.c index fbe96ef1ac7a..f01e3e21ecf2 100644 --- a/drivers/usb/gadget/function/u_ether.c +++ b/drivers/usb/gadget/function/u_ether.c @@ -730,7 +730,7 @@ static struct device_type gadget_type = { .name = "gadget", }; -/** +/* * gether_setup_name - initialize one ethernet-over-usb link * @g: gadget to associated with these links * @ethaddr: NULL, or a buffer in which the ethernet address of the @@ -1012,7 +1012,7 @@ int gether_get_ifname(struct net_device *net, char *name, int len) } EXPORT_SYMBOL_GPL(gether_get_ifname); -/** +/* * gether_cleanup - remove Ethernet-over-USB device * Context: may sleep * -- cgit v1.2.3-70-g09d2 From 4ee383c7e050d65582206db409098ddd7c99f726 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Mon, 6 Jul 2020 14:33:15 +0100 Subject: usb: gadget: udc: pxa27x_udc: Fix a bunch of kerneldoc issues Mostly bitrotted argument descriptions/names. Also the removal of a blank line in the middle of a kerneldoc header, which is not allowed. Fixes the following W=1 kernel build warning(s): drivers/usb/gadget/udc/pxa27x_udc.c:398: warning: Function parameter or member 'ep' not described in 'ep_write_UDCCSR' drivers/usb/gadget/udc/pxa27x_udc.c:398: warning: Excess function parameter 'udc' description in 'ep_write_UDCCSR' drivers/usb/gadget/udc/pxa27x_udc.c:479: warning: Function parameter or member 'udc' not described in 'set_ep0state' drivers/usb/gadget/udc/pxa27x_udc.c:479: warning: Excess function parameter 'dev' description in 'set_ep0state' drivers/usb/gadget/udc/pxa27x_udc.c:506: warning: Excess function parameter 'req' description in 'inc_ep_stats_reqs' drivers/usb/gadget/udc/pxa27x_udc.c:1476: warning: bad line: drivers/usb/gadget/udc/pxa27x_udc.c:1697: warning: Function parameter or member 'udc' not described in 'udc_enable' drivers/usb/gadget/udc/pxa27x_udc.c:1697: warning: Excess function parameter 'dev' description in 'udc_enable' drivers/usb/gadget/udc/pxa27x_udc.c:1750: warning: Function parameter or member 'g' not described in 'pxa27x_udc_start' drivers/usb/gadget/udc/pxa27x_udc.c:1750: warning: Excess function parameter 'bind' description in 'pxa27x_udc_start' drivers/usb/gadget/udc/pxa27x_udc.c:1784: warning: Excess function parameter 'driver' description in 'stop_activity' drivers/usb/gadget/udc/pxa27x_udc.c:1800: warning: Function parameter or member 'g' not described in 'pxa27x_udc_stop' drivers/usb/gadget/udc/pxa27x_udc.c:1800: warning: Excess function parameter 'driver' description in 'pxa27x_udc_stop' drivers/usb/gadget/udc/pxa27x_udc.c:2358: warning: Function parameter or member 'pdev' not described in 'pxa_udc_probe' drivers/usb/gadget/udc/pxa27x_udc.c:2358: warning: Excess function parameter '_dev' description in 'pxa_udc_probe' Cc: Daniel Mack Cc: Haojian Zhuang Cc: Robert Jarzmik Cc: Felipe Balbi Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20200706133341.476881-7-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/udc/pxa27x_udc.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'drivers/usb') 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. -- cgit v1.2.3-70-g09d2 From 4ac2c4606ac8a796e397ff542fb9fda6d936e239 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Mon, 6 Jul 2020 14:33:16 +0100 Subject: usb: misc: legousbtower: Demote function header which is clearly not kerneldoc Fixes the following W=1 kernel build warning(s): drivers/usb/misc/legousbtower.c:280: warning: Function parameter or member 'dev' not described in 'lego_usb_tower_debug_data' drivers/usb/misc/legousbtower.c:280: warning: Function parameter or member 'function' not described in 'lego_usb_tower_debug_data' drivers/usb/misc/legousbtower.c:280: warning: Function parameter or member 'size' not described in 'lego_usb_tower_debug_data' drivers/usb/misc/legousbtower.c:280: warning: Function parameter or member 'data' not described in 'lego_usb_tower_debug_data' Cc: Juergen Stuber Cc: David Glance Cc: david Cc: legousb-devel@lists.sourceforge.net Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20200706133341.476881-8-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/misc/legousbtower.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/usb') diff --git a/drivers/usb/misc/legousbtower.c b/drivers/usb/misc/legousbtower.c index 8aca55c4c95f..f922544056de 100644 --- a/drivers/usb/misc/legousbtower.c +++ b/drivers/usb/misc/legousbtower.c @@ -271,7 +271,7 @@ static struct usb_driver tower_driver = { }; -/** +/* * lego_usb_tower_debug_data */ static inline void lego_usb_tower_debug_data(struct device *dev, -- cgit v1.2.3-70-g09d2 From 14602c55cb738303f2b48bd0392320f2911a58d6 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Mon, 6 Jul 2020 14:33:18 +0100 Subject: usb: gadget: udc: atmel_usba_udc: Remove set but unused variable 'pp' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Commit e78355b577c4b ("usb: gadget: udc: atmel: Don't use DT to configure end point") pulled out all functionality dealing with 'pp'. Fixes the following W=1 kernel build warning(s): drivers/usb/gadget/udc/atmel_usba_udc.c: In function ‘atmel_udc_of_init’: drivers/usb/gadget/udc/atmel_usba_udc.c:2106:22: warning: variable ‘pp’ set but not used [-Wunused-but-set-variable] 2106 | struct device_node *pp; | ^~ Cc: Cristian Birsan Cc: Felipe Balbi Cc: Nicolas Ferre Cc: Alexandre Belloni Cc: Ludovic Desroches Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20200706133341.476881-10-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/udc/atmel_usba_udc.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c b/drivers/usb/gadget/udc/atmel_usba_udc.c index d69f61ff0181..a10b8d406e62 100644 --- a/drivers/usb/gadget/udc/atmel_usba_udc.c +++ b/drivers/usb/gadget/udc/atmel_usba_udc.c @@ -2103,7 +2103,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; @@ -2128,7 +2127,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 { @@ -2144,7 +2142,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]; -- cgit v1.2.3-70-g09d2 From 5d1d4818d21d838b46f456af68fc53297716a529 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Mon, 6 Jul 2020 14:33:19 +0100 Subject: usb: gadget: legacy: nokia: Remove unused static variable 'product_nokia' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Looks as though it's never been used. Driver was introduced in 2010. Fixes the following W=1 kernel build warning(s): drivers/usb/gadget/legacy/nokia.c:65:19: warning: ‘product_nokia’ defined but not used [-Wunused-const-variable=] 65 | static const char product_nokia[] = NOKIA_LONG_NAME; | ^~~~~~~~~~~~~ Cc: Felipe Balbi Cc: Al Borchers Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20200706133341.476881-11-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/legacy/nokia.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers/usb') diff --git a/drivers/usb/gadget/legacy/nokia.c b/drivers/usb/gadget/legacy/nokia.c index 978c1a34a932..2e15f9a32ce9 100644 --- a/drivers/usb/gadget/legacy/nokia.c +++ b/drivers/usb/gadget/legacy/nokia.c @@ -62,7 +62,6 @@ FSG_MODULE_PARAMETERS(/* no prefix */, fsg_mod_data); #define STRING_DESCRIPTION_IDX USB_GADGET_FIRST_AVAIL_IDX static char manufacturer_nokia[] = "Nokia"; -static const char product_nokia[] = NOKIA_LONG_NAME; static const char description_nokia[] = "PC-Suite Configuration"; static struct usb_string strings_dev[] = { -- cgit v1.2.3-70-g09d2 From 8f9a0e10057e29ebaad76513c01924c2b82a0067 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Mon, 6 Jul 2020 14:33:20 +0100 Subject: usb: gadget: function: f_fs: Demote function header which is clearly not kerneldoc No attempt has been made to document the demoted function here. Fixes the following W=1 kernel build warning(s): drivers/usb/gadget/function/f_fs.c:2361: warning: Function parameter or member 'type' not described in '__ffs_data_do_os_desc' drivers/usb/gadget/function/f_fs.c:2361: warning: Function parameter or member 'h' not described in '__ffs_data_do_os_desc' drivers/usb/gadget/function/f_fs.c:2361: warning: Function parameter or member 'data' not described in '__ffs_data_do_os_desc' drivers/usb/gadget/function/f_fs.c:2361: warning: Function parameter or member 'len' not described in '__ffs_data_do_os_desc' drivers/usb/gadget/function/f_fs.c:2361: warning: Function parameter or member 'priv' not described in '__ffs_data_do_os_desc' Cc: Felipe Balbi Cc: David Howells Cc: Michal Nazarewicz Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20200706133341.476881-12-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/function/f_fs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/usb') diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c index 490d353d5fde..2d00ba072645 100644 --- a/drivers/usb/gadget/function/f_fs.c +++ b/drivers/usb/gadget/function/f_fs.c @@ -2352,7 +2352,7 @@ static int __must_check ffs_do_os_descs(unsigned count, return _len - len; } -/** +/* * Validate contents of the buffer from userspace related to OS descriptors. */ static int __ffs_data_do_os_desc(enum ffs_os_desc_type type, -- cgit v1.2.3-70-g09d2 From 120d91dae6c9121c82786c163bd414daae1db838 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Mon, 6 Jul 2020 14:33:21 +0100 Subject: usb: gadget: udc: lpc32xx_udc: Staticify 2 local functions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit These are not used outside of this sourcefile, so make them static. Fixes the following W=1 kernel build warning(s): drivers/usb/gadget/udc/lpc32xx_udc.c:1929:6: warning: no previous prototype for ‘udc_send_in_zlp’ [-Wmissing-prototypes] 1929 | void udc_send_in_zlp(struct lpc32xx_udc *udc, struct lpc32xx_ep *ep) | ^~~~~~~~~~~~~~~ drivers/usb/gadget/udc/lpc32xx_udc.c:1943:6: warning: no previous prototype for ‘udc_handle_eps’ [-Wmissing-prototypes] 1943 | void udc_handle_eps(struct lpc32xx_udc *udc, struct lpc32xx_ep *ep) | ^~~~~~~~~~~~~~ Cc: Felipe Balbi Cc: Sylvain Lemieux Cc: Kevin Wells Cc: Roland Stigge Signed-off-by: Lee Jones Acked-by: Vladimir Zapolskiy Link: https://lore.kernel.org/r/20200706133341.476881-13-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/udc/lpc32xx_udc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/gadget/udc/lpc32xx_udc.c b/drivers/usb/gadget/udc/lpc32xx_udc.c index 465d0b7c6522..4a112670cc6c 100644 --- a/drivers/usb/gadget/udc/lpc32xx_udc.c +++ b/drivers/usb/gadget/udc/lpc32xx_udc.c @@ -1926,7 +1926,7 @@ static const struct usb_ep_ops lpc32xx_ep_ops = { }; /* Send a ZLP on a non-0 IN EP */ -void udc_send_in_zlp(struct lpc32xx_udc *udc, struct lpc32xx_ep *ep) +static void udc_send_in_zlp(struct lpc32xx_udc *udc, struct lpc32xx_ep *ep) { /* Clear EP status */ udc_clearep_getsts(udc, ep->hwep_num); @@ -1940,7 +1940,7 @@ void udc_send_in_zlp(struct lpc32xx_udc *udc, struct lpc32xx_ep *ep) * This function will only be called when a delayed ZLP needs to be sent out * after a DMA transfer has filled both buffers. */ -void udc_handle_eps(struct lpc32xx_udc *udc, struct lpc32xx_ep *ep) +static void udc_handle_eps(struct lpc32xx_udc *udc, struct lpc32xx_ep *ep) { u32 epstatus; struct lpc32xx_request *req; -- cgit v1.2.3-70-g09d2 From 33a4eeb1a67390dd2d485ec4918e87e931bf993f Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Mon, 6 Jul 2020 14:33:22 +0100 Subject: usb: host: r8a66597-hcd: Remove set, then over-written, but never used variable 'tmp' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Looks like it's been this way since the driver's inception in 2007. Fixes the following W=1 kernel build warning(s): drivers/usb/host/r8a66597-hcd.c: In function ‘clear_all_buffer’: drivers/usb/host/r8a66597-hcd.c:478:6: warning: variable ‘tmp’ set but not used [-Wunused-but-set-variable] 478 | u16 tmp; | ^~~ Cc: Yoshihiro Shimoda Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20200706133341.476881-14-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/r8a66597-hcd.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/host/r8a66597-hcd.c b/drivers/usb/host/r8a66597-hcd.c index 0c03ac6b0213..63719cdf6a4e 100644 --- a/drivers/usb/host/r8a66597-hcd.c +++ b/drivers/usb/host/r8a66597-hcd.c @@ -475,16 +475,14 @@ static void pipe_stop(struct r8a66597 *r8a66597, struct r8a66597_pipe *pipe) static void clear_all_buffer(struct r8a66597 *r8a66597, struct r8a66597_pipe *pipe) { - u16 tmp; - if (!pipe || pipe->info.pipenum == 0) return; pipe_stop(r8a66597, pipe); r8a66597_bset(r8a66597, ACLRM, pipe->pipectr); - tmp = r8a66597_read(r8a66597, pipe->pipectr); - tmp = r8a66597_read(r8a66597, pipe->pipectr); - tmp = r8a66597_read(r8a66597, pipe->pipectr); + r8a66597_read(r8a66597, pipe->pipectr); + r8a66597_read(r8a66597, pipe->pipectr); + r8a66597_read(r8a66597, pipe->pipectr); r8a66597_bclr(r8a66597, ACLRM, pipe->pipectr); } -- cgit v1.2.3-70-g09d2 From 6327bf758093df5e95c2736143b92f03ff8a80e4 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Mon, 6 Jul 2020 14:33:23 +0100 Subject: usb: gadget: udc: mv_udc_core: Remove unused static const variable 'driver_desc' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Looks as though it's never been used. Driver was introduced in 2014. Fixes the following W=1 kernel build warning(s): drivers/usb/gadget/udc/mv_udc_core.c:56:19: warning: ‘driver_desc’ defined but not used [-Wunused-const-variable=] 56 | static const char driver_desc[] = DRIVER_DESC; | ^~~~~~~~~~~ Cc: Felipe Balbi Cc: Chao Xie Cc: Neil Zhang Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20200706133341.476881-15-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/udc/mv_udc_core.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers/usb') diff --git a/drivers/usb/gadget/udc/mv_udc_core.c b/drivers/usb/gadget/udc/mv_udc_core.c index 2384b55f9d3e..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); -- cgit v1.2.3-70-g09d2 From 4ef2dfbdcda67a8000a9042fc25f1ed21e75b4d7 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Mon, 6 Jul 2020 14:33:24 +0100 Subject: usb: gadget: udc: pch_udc: Fix a plethora of function documentation related issues Ranging from missing descriptions and formatting mishaps to over-documenting of missing arguments, likely due to bitrot. Fixes the following W=1 kernel build warning(s): drivers/usb/gadget/udc/pch_udc.c:239: warning: Function parameter or member 'request' not described in 'pch_udc_stp_dma_desc' drivers/usb/gadget/udc/pch_udc.c:315: warning: Function parameter or member 'irq_work_fall' not described in 'pch_vbus_gpio_data' drivers/usb/gadget/udc/pch_udc.c:315: warning: Function parameter or member 'irq_work_rise' not described in 'pch_vbus_gpio_data' drivers/usb/gadget/udc/pch_udc.c:482: warning: Function parameter or member 'ep' not described in 'pch_udc_write_csr' drivers/usb/gadget/udc/pch_udc.c:482: warning: Excess function parameter 'addr' description in 'pch_udc_write_csr' drivers/usb/gadget/udc/pch_udc.c:498: warning: Function parameter or member 'ep' not described in 'pch_udc_read_csr' drivers/usb/gadget/udc/pch_udc.c:498: warning: Excess function parameter 'addr' description in 'pch_udc_read_csr' drivers/usb/gadget/udc/pch_udc.c:662: warning: Function parameter or member 'ep_in' not described in 'pch_udc_ep_set_bufsz' drivers/usb/gadget/udc/pch_udc.c:977: warning: Function parameter or member 'ep' not described in 'pch_udc_ep_enable' drivers/usb/gadget/udc/pch_udc.c:977: warning: Function parameter or member 'cfg' not described in 'pch_udc_ep_enable' drivers/usb/gadget/udc/pch_udc.c:977: warning: Excess function parameter 'regs' description in 'pch_udc_ep_enable' drivers/usb/gadget/udc/pch_udc.c:1010: warning: Function parameter or member 'ep' not described in 'pch_udc_ep_disable' drivers/usb/gadget/udc/pch_udc.c:1010: warning: Excess function parameter 'regs' description in 'pch_udc_ep_disable' drivers/usb/gadget/udc/pch_udc.c:1030: warning: Function parameter or member 'ep' not described in 'pch_udc_wait_ep_stall' drivers/usb/gadget/udc/pch_udc.c:1030: warning: Excess function parameter 'dev' description in 'pch_udc_wait_ep_stall' drivers/usb/gadget/udc/pch_udc.c:1341: warning: Function parameter or member 'data' not described in 'pch_vbus_gpio_irq' drivers/usb/gadget/udc/pch_udc.c:1341: warning: Excess function parameter 'dev' description in 'pch_vbus_gpio_irq' drivers/usb/gadget/udc/pch_udc.c:1365: warning: Function parameter or member 'vbus_gpio_port' not described in 'pch_vbus_gpio_init' drivers/usb/gadget/udc/pch_udc.c:1510: warning: Function parameter or member 'dev' not described in 'pch_udc_free_dma_chain' drivers/usb/gadget/udc/pch_udc.c:1510: warning: Function parameter or member 'req' not described in 'pch_udc_free_dma_chain' drivers/usb/gadget/udc/pch_udc.c:1717: warning: Function parameter or member 'usbep' not described in 'pch_udc_pcd_ep_disable' drivers/usb/gadget/udc/pch_udc.c:2006: warning: Excess function parameter 'halt' description in 'pch_udc_pcd_set_wedge' drivers/usb/gadget/udc/pch_udc.c:2756: warning: Function parameter or member 'pdev' not described in 'pch_udc_isr' drivers/usb/gadget/udc/pch_udc.c:2756: warning: Excess function parameter 'dev' description in 'pch_udc_isr' drivers/usb/gadget/udc/pch_udc.c:2906: warning: Function parameter or member 'dev' not described in 'init_dma_pools' drivers/usb/gadget/udc/pch_udc.c:2906: warning: Excess function parameter 'pdev' description in 'init_dma_pools' Cc: Felipe Balbi Cc: Chuhong Yuan Cc: LAPIS Semiconductor Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20200706133341.476881-16-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/udc/pch_udc.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'drivers/usb') 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) { -- cgit v1.2.3-70-g09d2 From 709ba38e46f1b9085df0bb84cf0ee1d3494ad43a Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Mon, 6 Jul 2020 14:33:25 +0100 Subject: usb: host: imx21-hcd: Demote function header which is clearly not kerneldoc No attempt has been made to document the demoted function here. Fixes the following W=1 kernel build warning(s): drivers/usb/host/imx21-hcd.c:233: warning: Function parameter or member 'imx21' not described in 'copy_to_dmem' drivers/usb/host/imx21-hcd.c:233: warning: Function parameter or member 'dmem_offset' not described in 'copy_to_dmem' drivers/usb/host/imx21-hcd.c:233: warning: Function parameter or member 'src' not described in 'copy_to_dmem' drivers/usb/host/imx21-hcd.c:233: warning: Function parameter or member 'count' not described in 'copy_to_dmem' Cc: Shawn Guo Cc: Sascha Hauer Cc: Pengutronix Kernel Team Cc: Fabio Estevam Cc: NXP Linux Team Cc: Stephen Boyd Cc: Jay Monkman Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20200706133341.476881-17-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/imx21-hcd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/usb') diff --git a/drivers/usb/host/imx21-hcd.c b/drivers/usb/host/imx21-hcd.c index 5835f9966204..b2716cb72471 100644 --- a/drivers/usb/host/imx21-hcd.c +++ b/drivers/usb/host/imx21-hcd.c @@ -224,7 +224,7 @@ static void setup_etd_dword0(struct imx21 *imx21, ((u32) maxpacket << DW0_MAXPKTSIZ)); } -/** +/* * Copy buffer to data controller data memory. * We cannot use memcpy_toio() because the hardware requires 32bit writes */ -- cgit v1.2.3-70-g09d2 From 1a896833953781d613be7fbb0915840b0d2af216 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Mon, 6 Jul 2020 14:33:26 +0100 Subject: usb: host: ehci-fsl: Fix incorrectly named function argument Fixes the following W=1 kernel build warning(s): drivers/usb/host/ehci-fsl.c:694: warning: Function parameter or member 'pdev' not described in 'fsl_ehci_drv_remove' drivers/usb/host/ehci-fsl.c:694: warning: Excess function parameter 'dev' description in 'fsl_ehci_drv_remove' Cc: Alan Stern Cc: Randy Vinson Cc: Dave Liu Cc: Jerry Huang Cc: Anton Vorontsov Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20200706133341.476881-18-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/ehci-fsl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/usb') diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c index 9e9c232e896f..1ebe4d425277 100644 --- a/drivers/usb/host/ehci-fsl.c +++ b/drivers/usb/host/ehci-fsl.c @@ -683,7 +683,7 @@ static const struct ehci_driver_overrides ehci_fsl_overrides __initconst = { /** * fsl_ehci_drv_remove - shutdown processing for FSL-based HCDs - * @dev: USB Host Controller being removed + * @pdev: USB Host Controller being removed * Context: !in_interrupt() * * Reverses the effect of usb_hcd_fsl_probe(). -- cgit v1.2.3-70-g09d2 From 522514e599e3ceb9a34bcdd919db58e243a50cb2 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Mon, 6 Jul 2020 14:33:27 +0100 Subject: usb: host: fotg210-hcd: Remove unused variable 'hcc_params' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The result is actually read into fotg210->caps->hcc_params. No need to popuate an unused varible with the unchecked return value from fotg210_readl(). Fixes the following W=1 kernel build warning(s): drivers/usb/host/fotg210-hcd.c: In function ‘fotg210_run’: drivers/usb/host/fotg210-hcd.c:5013:6: warning: variable ‘hcc_params’ set but not used [-Wunused-but-set-variable] 5013 | u32 hcc_params; | ^~~~~~~~~~ Cc: Yuan-Hsin Chen Cc: Feng-Hsin Chiang Cc: Po-Yu Chuang Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20200706133341.476881-19-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/fotg210-hcd.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/host/fotg210-hcd.c b/drivers/usb/host/fotg210-hcd.c index f967adf2d8df..51dbbb0e768b 100644 --- a/drivers/usb/host/fotg210-hcd.c +++ b/drivers/usb/host/fotg210-hcd.c @@ -5010,7 +5010,6 @@ static int fotg210_run(struct usb_hcd *hcd) { struct fotg210_hcd *fotg210 = hcd_to_fotg210(hcd); u32 temp; - u32 hcc_params; hcd->uses_new_polling = 1; @@ -5033,7 +5032,7 @@ static int fotg210_run(struct usb_hcd *hcd) * Scsi_Host.highmem_io, and so forth. It's readonly to all * host side drivers though. */ - hcc_params = fotg210_readl(fotg210, &fotg210->caps->hcc_params); + fotg210_readl(fotg210, &fotg210->caps->hcc_params); /* * Philips, Intel, and maybe others need CMD_RUN before the -- cgit v1.2.3-70-g09d2 From b612b0fa8e6900c25c01dff507ce3e15ffb76bc2 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Mon, 6 Jul 2020 14:33:28 +0100 Subject: usb: gadget: function: u_uac1_legacy: Demote obvious misuse of kerneldoc to standard comment blocks No attempt has been made to document any of the demoted functions here. Fixes the following W=1 kernel build warning(s): drivers/usb/gadget/function/u_uac1_legacy.c:30: warning: Function parameter or member 'i' not described in 'snd_interval_refine_set' drivers/usb/gadget/function/u_uac1_legacy.c:30: warning: Function parameter or member 'val' not described in 'snd_interval_refine_set' drivers/usb/gadget/function/u_uac1_legacy.c:93: warning: Function parameter or member 'snd' not described in 'playback_default_hw_params' drivers/usb/gadget/function/u_uac1_legacy.c:153: warning: Function parameter or member 'card' not described in 'u_audio_playback' drivers/usb/gadget/function/u_uac1_legacy.c:153: warning: Function parameter or member 'buf' not described in 'u_audio_playback' drivers/usb/gadget/function/u_uac1_legacy.c:153: warning: Function parameter or member 'count' not described in 'u_audio_playback' drivers/usb/gadget/function/u_uac1_legacy.c:197: warning: Function parameter or member 'card' not described in 'gaudio_open_snd_dev' drivers/usb/gadget/function/u_uac1_legacy.c:257: warning: Function parameter or member 'gau' not described in 'gaudio_close_snd_dev' drivers/usb/gadget/function/u_uac1_legacy.c:286: warning: Function parameter or member 'card' not described in 'gaudio_setup' drivers/usb/gadget/function/u_uac1_legacy.c:303: warning: Function parameter or member 'the_card' not described in 'gaudio_cleanup' Cc: Felipe Balbi Cc: Bryan Wu Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20200706133341.476881-20-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/function/u_uac1_legacy.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/gadget/function/u_uac1_legacy.c b/drivers/usb/gadget/function/u_uac1_legacy.c index 5393e5c37a4b..60ae8b2d3f6a 100644 --- a/drivers/usb/gadget/function/u_uac1_legacy.c +++ b/drivers/usb/gadget/function/u_uac1_legacy.c @@ -23,7 +23,7 @@ /*-------------------------------------------------------------------------*/ -/** +/* * Some ALSA internal helper functions */ static int snd_interval_refine_set(struct snd_interval *i, unsigned int val) @@ -86,7 +86,7 @@ static int _snd_pcm_hw_param_set(struct snd_pcm_hw_params *params, } /*-------------------------------------------------------------------------*/ -/** +/* * Set default hardware params */ static int playback_default_hw_params(struct gaudio_snd_dev *snd) @@ -146,7 +146,7 @@ static int playback_default_hw_params(struct gaudio_snd_dev *snd) return 0; } -/** +/* * Playback audio buffer data by ALSA PCM device */ size_t u_audio_playback(struct gaudio *card, void *buf, size_t count) @@ -189,7 +189,7 @@ int u_audio_get_playback_rate(struct gaudio *card) return card->playback.rate; } -/** +/* * Open ALSA PCM and control device files * Initial the PCM or control device */ @@ -250,7 +250,7 @@ static int gaudio_open_snd_dev(struct gaudio *card) return 0; } -/** +/* * Close ALSA PCM and control device files */ static int gaudio_close_snd_dev(struct gaudio *gau) @@ -275,7 +275,7 @@ static int gaudio_close_snd_dev(struct gaudio *gau) return 0; } -/** +/* * gaudio_setup - setup ALSA interface and preparing for USB transfer * * This sets up PCM, mixer or MIDI ALSA devices fore USB gadget using. @@ -294,7 +294,7 @@ int gaudio_setup(struct gaudio *card) } -/** +/* * gaudio_cleanup - remove ALSA device interface * * This is called to free all resources allocated by @gaudio_setup(). -- cgit v1.2.3-70-g09d2 From edd935797461bdfe62dc8c8505ffedb6eba4e347 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Mon, 6 Jul 2020 14:33:29 +0100 Subject: usb: host: bcma-hcd: Demote obvious misuse of kerneldoc to standard comment blocks No attempt has been made to document either of the demoted functions here. Fixes the following W=1 kernel build warning(s): drivers/usb/host/bcma-hcd.c:180: warning: Function parameter or member 'usb_dev' not described in 'bcma_hcd_usb20_old_arm_init' drivers/usb/host/bcma-hcd.c:268: warning: Function parameter or member 'bcma_hcd' not described in 'bcma_hcd_usb20_ns_init' Cc: Chuhong Yuan Cc: Hauke Mehrtens Cc: Felix Fietkau Cc: Michael Buesch Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20200706133341.476881-21-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/bcma-hcd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/host/bcma-hcd.c b/drivers/usb/host/bcma-hcd.c index 652fa29beb27..b1b777f33521 100644 --- a/drivers/usb/host/bcma-hcd.c +++ b/drivers/usb/host/bcma-hcd.c @@ -168,7 +168,7 @@ static void bcma_hcd_init_chip_mips(struct bcma_device *dev) } } -/** +/* * bcma_hcd_usb20_old_arm_init - Initialize old USB 2.0 controller on ARM * * Old USB 2.0 core is identified as BCMA_CORE_USB20_HOST and was introduced @@ -261,7 +261,7 @@ static void bcma_hcd_usb20_ns_init_hc(struct bcma_device *dev) usleep_range(1000, 2000); } -/** +/* * bcma_hcd_usb20_ns_init - Initialize Northstar USB 2.0 controller */ static int bcma_hcd_usb20_ns_init(struct bcma_hcd_device *bcma_hcd) -- cgit v1.2.3-70-g09d2 From 15ee5d03d59bb543f2508b4d48993aca2f1afaf2 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Mon, 6 Jul 2020 14:33:30 +0100 Subject: usb: host: fotg210-hcd: Demote obvious misuse of kerneldoc to standard comment blocks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Only 2 functions attempted to use kerneldoc in this massive file. Fixes the following W=1 kernel build warning(s): drivers/usb/host/fotg210-hcd.c: In function ‘fotg210_run’: drivers/usb/host/fotg210-hcd.c:5013:6: warning: variable ‘hcc_params’ set but not used [-Wunused-but-set-variable] drivers/usb/host/fotg210-hcd.c:5569: warning: Function parameter or member 'pdev' not described in 'fotg210_hcd_probe' drivers/usb/host/fotg210-hcd.c:5666: warning: Function parameter or member 'pdev' not described in 'fotg210_hcd_remove' drivers/usb/host/fotg210-hcd.c:5666: warning: Excess function parameter 'dev' description in 'fotg210_hcd_remove' Cc: Yuan-Hsin Chen Cc: Feng-Hsin Chiang Cc: Po-Yu Chuang Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20200706133341.476881-22-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/fotg210-hcd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/host/fotg210-hcd.c b/drivers/usb/host/fotg210-hcd.c index 51dbbb0e768b..633df2e927bb 100644 --- a/drivers/usb/host/fotg210-hcd.c +++ b/drivers/usb/host/fotg210-hcd.c @@ -5557,7 +5557,7 @@ static void fotg210_init(struct fotg210_hcd *fotg210) iowrite32(value, &fotg210->regs->otgcsr); } -/** +/* * fotg210_hcd_probe - initialize faraday FOTG210 HCDs * * Allocates basic resources for this USB host controller, and @@ -5656,7 +5656,7 @@ fail_create_hcd: return retval; } -/** +/* * fotg210_hcd_remove - shutdown processing for EHCI HCDs * @dev: USB Host Controller being removed * -- cgit v1.2.3-70-g09d2 From 8834f60d6ba2dc3b3855c0b92bce1429ef7da6a5 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Mon, 6 Jul 2020 14:33:31 +0100 Subject: usb: gadget: udc: mv_u3d_core: Remove unused static const 'driver_desc' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Looks like it's never been used. Driver was mainlined in 2014. Fixes the following W=1 kernel build warning(s): drivers/usb/gadget/udc/mv_u3d_core.c:35:19: warning: ‘driver_desc’ defined but not used [-Wunused-const-variable=] 35 | static const char driver_desc[] = DRIVER_DESC; | ^~~~~~~~~~~ Cc: Felipe Balbi Cc: Jason Yan Cc: Yu Xu Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20200706133341.476881-23-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/udc/mv_u3d_core.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers/usb') 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, -- cgit v1.2.3-70-g09d2 From 1a4f38a6224a891dfec56c7459e4309fe5f073d6 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Mon, 6 Jul 2020 14:33:32 +0100 Subject: usb: gadget: udc: max3420_udc: Remove set, but never checked variable 'addr' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes the following W=1 kernel build warning(s): drivers/usb/gadget/udc/max3420_udc.c: In function ‘max3420_handle_setup’: drivers/usb/gadget/udc/max3420_udc.c:626:5: warning: variable ‘addr’ set but not used [-Wunused-but-set-variable] 626 | u8 addr; | ^~~~ Cc: Felipe Balbi Cc: Christophe JAILLET Signed-off-by: Lee Jones Acked-by: Jassi Brar Link: https://lore.kernel.org/r/20200706133341.476881-24-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/udc/max3420_udc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/gadget/udc/max3420_udc.c b/drivers/usb/gadget/udc/max3420_udc.c index 23f33946d80c..52884bae4af1 100644 --- a/drivers/usb/gadget/udc/max3420_udc.c +++ b/drivers/usb/gadget/udc/max3420_udc.c @@ -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: -- cgit v1.2.3-70-g09d2 From e6b073dea39bd8bfb02e05f46f27d94dc006e91c Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Mon, 6 Jul 2020 14:33:33 +0100 Subject: usb: typec: ucsi: ucsi: Staticify and stop export of ucsi_init() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It isn't called from anywhere outside of ucsi.c. Fixes the following W=1 kernel build warning(s): drivers/usb/typec/ucsi/ucsi.c:1005:5: warning: no previous prototype for ‘ucsi_init’ [-Wmissing-prototypes] 1005 | int ucsi_init(struct ucsi *ucsi) | ^~~~~~~~~ Cc: Heikki Krogerus Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20200706133341.476881-25-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/typec/ucsi/ucsi.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c index d0c63afaf345..affd024190c9 100644 --- a/drivers/usb/typec/ucsi/ucsi.c +++ b/drivers/usb/typec/ucsi/ucsi.c @@ -1002,7 +1002,7 @@ static int ucsi_register_port(struct ucsi *ucsi, int index) * * Registers all ports @ucsi has and enables all notification events. */ -int ucsi_init(struct ucsi *ucsi) +static int ucsi_init(struct ucsi *ucsi) { struct ucsi_connector *con; u64 command; @@ -1078,7 +1078,6 @@ err: return ret; } -EXPORT_SYMBOL_GPL(ucsi_init); static void ucsi_init_work(struct work_struct *work) { -- cgit v1.2.3-70-g09d2 From beb368a4b9cbe67894354b884fa34e8e2e701a92 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Mon, 6 Jul 2020 14:33:34 +0100 Subject: usb: early: ehci-dbgp: Remove set but never checked variable 'ret' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 'ret' hasn't been checked since the driver's inception in 2009. Fixes the following W=1 kernel build warning(s): drivers/usb/early/ehci-dbgp.c: In function ‘early_dbgp_write’: drivers/usb/early/ehci-dbgp.c:915:13: warning: variable ‘ret’ set but not used [-Wunused-but-set-variable] 915 | int chunk, ret; | ^~~ Cc: Sumit Garg Cc: Daniel Thompson Cc: Douglas Anderson Cc: Petr Mladek Cc: Yinghai Lu Cc: Jason Wessel Signed-off-by: Lee Jones Acked-by: "Eric W. Biederman" Link: https://lore.kernel.org/r/20200706133341.476881-26-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/early/ehci-dbgp.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/early/ehci-dbgp.c b/drivers/usb/early/ehci-dbgp.c index 775cf70cfb3e..b075dbfad730 100644 --- a/drivers/usb/early/ehci-dbgp.c +++ b/drivers/usb/early/ehci-dbgp.c @@ -912,7 +912,7 @@ int __init early_dbgp_init(char *s) static void early_dbgp_write(struct console *con, const char *str, u32 n) { - int chunk, ret; + int chunk; char buf[DBGP_MAX_PACKET]; int use_cr = 0; u32 cmd, ctrl; @@ -951,8 +951,8 @@ static void early_dbgp_write(struct console *con, const char *str, u32 n) buf[chunk] = *str; } if (chunk > 0) { - ret = dbgp_bulk_write(USB_DEBUG_DEVNUM, - dbgp_endpoint_out, buf, chunk); + dbgp_bulk_write(USB_DEBUG_DEVNUM, + dbgp_endpoint_out, buf, chunk); } } if (unlikely(reset_run)) { -- cgit v1.2.3-70-g09d2 From f0f705fcfe99301aa7268dbb080cb24ff7787042 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Mon, 6 Jul 2020 14:33:35 +0100 Subject: usb: early: xhci-dbc: Supply missing 'xhci-dbgp.h' headerfile MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If the header file containing a function's prototype isn't included by the sourcefile containing the associated function, the build system complains of missing prototypes. Fixes the following W=1 kernel build warning(s): drivers/usb/early/ehci-dbgp.c: In function ‘early_dbgp_write’: drivers/usb/early/ehci-dbgp.c:915:13: warning: variable ‘ret’ set but not used [-Wunused-but-set-variable] 915 | int chunk, ret; | ^~~ drivers/usb/early/xhci-dbc.c:600:12: warning: no previous prototype for ‘early_xdbc_parse_parameter’ [-Wmissing-prototypes] 600 | int __init early_xdbc_parse_parameter(char *s) | ^~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/usb/early/xhci-dbc.c:653:12: warning: no previous prototype for ‘early_xdbc_setup_hardware’ [-Wmissing-prototypes] 653 | int __init early_xdbc_setup_hardware(void) | ^~~~~~~~~~~~~~~~~~~~~~~~~ drivers/usb/early/xhci-dbc.c:910:13: warning: no previous prototype for ‘early_xdbc_register_console’ [-Wmissing-prototypes] 910 | void __init early_xdbc_register_console(void) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ Cc: Lu Baolu Signed-off-by: Lee Jones Reviewed-by: Jann Horn Link: https://lore.kernel.org/r/20200706133341.476881-27-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/early/xhci-dbc.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/usb') diff --git a/drivers/usb/early/xhci-dbc.c b/drivers/usb/early/xhci-dbc.c index 04ba11fff0ed..a9932c1ff20f 100644 --- a/drivers/usb/early/xhci-dbc.c +++ b/drivers/usb/early/xhci-dbc.c @@ -21,6 +21,7 @@ #include #include #include +#include #include "../host/xhci.h" #include "xhci-dbc.h" -- cgit v1.2.3-70-g09d2 From 02ec8a098fb3fa2e1d8c1c8ed32c27e70356dafb Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Mon, 6 Jul 2020 14:33:36 +0100 Subject: usb: early: xhci-dbc: File headers are not good candidates for kerneldoc Demote xhci-dbc's file header to a standard comment block. Fixes the following W=1 kernel build warning(s): drivers/usb/early/xhci-dbc.c:10: warning: Function parameter or member 'fmt' not described in 'pr_fmt' Cc: Lu Baolu Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20200706133341.476881-28-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/early/xhci-dbc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/usb') diff --git a/drivers/usb/early/xhci-dbc.c b/drivers/usb/early/xhci-dbc.c index a9932c1ff20f..c0507767a8e3 100644 --- a/drivers/usb/early/xhci-dbc.c +++ b/drivers/usb/early/xhci-dbc.c @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 -/** +/* * xhci-dbc.c - xHCI debug capability early driver * * Copyright (C) 2016 Intel Corporation -- cgit v1.2.3-70-g09d2 From 6dba06ceee70e83f6baa817867560b2272de0f0b Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Mon, 6 Jul 2020 14:33:37 +0100 Subject: usb: host: ehci-platform: Do not define 'struct acpi_device_id' when !CONFIG_ACPI MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since ACPI_PTR() is used to NULLify the value when !CONFIG_ACPI, struct ehci_acpi_match becomes defined by unused. Fixes the following W=1 kernel build warning(s): drivers/usb/host/ehci-platform.c:478:36: warning: ‘ehci_acpi_match’ defined but not used [-Wunused-const-variable=] 478 | static const struct acpi_device_id ehci_acpi_match[] = { | ^~~~~~~~~~~~~~~ Cc: Tony Prisk Cc: Alan Stern Cc: Philipp Zabel Cc: Steven Brown Cc: Hauke Mehrtens Cc: de Goede Cc: Michael Buesch Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20200706133341.476881-29-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/ehci-platform.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers/usb') diff --git a/drivers/usb/host/ehci-platform.c b/drivers/usb/host/ehci-platform.c index e9a49007cce4..006c4f6188a5 100644 --- a/drivers/usb/host/ehci-platform.c +++ b/drivers/usb/host/ehci-platform.c @@ -475,11 +475,13 @@ static const struct of_device_id vt8500_ehci_ids[] = { }; MODULE_DEVICE_TABLE(of, vt8500_ehci_ids); +#ifdef CONFIG_ACPI static const struct acpi_device_id ehci_acpi_match[] = { { "PNP0D20", 0 }, /* EHCI controller without debug */ { } }; MODULE_DEVICE_TABLE(acpi, ehci_acpi_match); +#endif static const struct platform_device_id ehci_platform_table[] = { { "ehci-platform", 0 }, -- cgit v1.2.3-70-g09d2 From b789710de583f069609cc626651556b81e6f23dc Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Mon, 6 Jul 2020 14:33:38 +0100 Subject: usb: dwc3: dwc3-qcom: Do not define 'struct acpi_device_id' when !CONFIG_ACPI MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since ACPI_PTR() is used to NULLify the value when !CONFIG_ACPI, struct dwc3_qcom_acpi_match becomes defined by unused. Also need to place the platform data obtained via the matching process inside the #ifdef, else that becomes unused too. Fixes the following W=1 kernel build warning(s): drivers/usb/dwc3/dwc3-qcom.c:761:36: warning: ‘dwc3_qcom_acpi_match’ defined but not used [-Wunused-const-variable=] 761 | static const struct acpi_device_id dwc3_qcom_acpi_match[] = { | ^~~~~~~~~~~~~~~~~~~~ Cc: Andy Gross Cc: Bjorn Andersson Cc: Felipe Balbi Cc: Philipp Zabel Cc: linux-arm-msm@vger.kernel.org Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20200706133341.476881-30-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/dwc3/dwc3-qcom.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c index 1dfd024cd06b..e1e78e9824b1 100644 --- a/drivers/usb/dwc3/dwc3-qcom.c +++ b/drivers/usb/dwc3/dwc3-qcom.c @@ -540,16 +540,6 @@ static int dwc3_qcom_of_register_core(struct platform_device *pdev) return 0; } -static const struct dwc3_acpi_pdata sdm845_acpi_pdata = { - .qscratch_base_offset = SDM845_QSCRATCH_BASE_OFFSET, - .qscratch_base_size = SDM845_QSCRATCH_SIZE, - .dwc3_core_base_size = SDM845_DWC3_CORE_SIZE, - .hs_phy_irq_index = 1, - .dp_hs_phy_irq_index = 4, - .dm_hs_phy_irq_index = 3, - .ss_phy_irq_index = 2 -}; - static int dwc3_qcom_probe(struct platform_device *pdev) { struct device_node *np = pdev->dev.of_node; @@ -758,11 +748,23 @@ static const struct of_device_id dwc3_qcom_of_match[] = { }; MODULE_DEVICE_TABLE(of, dwc3_qcom_of_match); +#ifdef CONFIG_ACPI +static const struct dwc3_acpi_pdata sdm845_acpi_pdata = { + .qscratch_base_offset = SDM845_QSCRATCH_BASE_OFFSET, + .qscratch_base_size = SDM845_QSCRATCH_SIZE, + .dwc3_core_base_size = SDM845_DWC3_CORE_SIZE, + .hs_phy_irq_index = 1, + .dp_hs_phy_irq_index = 4, + .dm_hs_phy_irq_index = 3, + .ss_phy_irq_index = 2 +}; + static const struct acpi_device_id dwc3_qcom_acpi_match[] = { { "QCOM2430", (unsigned long)&sdm845_acpi_pdata }, { }, }; MODULE_DEVICE_TABLE(acpi, dwc3_qcom_acpi_match); +#endif static struct platform_driver dwc3_qcom_driver = { .probe = dwc3_qcom_probe, -- cgit v1.2.3-70-g09d2 From d45f72bc3b19c0d3b6d0c8c534d210abc3268526 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Mon, 6 Jul 2020 14:33:39 +0100 Subject: usb: host: fhci-tds: Remove unused variables 'buf' and 'extra_data' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Neither have been used since the driver's inception in 2009. Fixes the following W=1 kernel build warning(s): drivers/usb/host/fhci-tds.c: In function ‘fhci_flush_bds’: drivers/usb/host/fhci-tds.c:472:6: warning: variable ‘buf’ set but not used [-Wunused-but-set-variable] 472 | u32 buf; | ^~~ drivers/usb/host/fhci-tds.c:470:6: warning: variable ‘extra_data’ set but not used [-Wunused-but-set-variable] 470 | u16 extra_data; | ^~~~~~~~~~ drivers/usb/host/fhci-tds.c: In function ‘fhci_flush_actual_frame’: drivers/usb/host/fhci-tds.c:527:6: warning: variable ‘extra_data’ set but not used [-Wunused-but-set-variable] 527 | u16 extra_data; | ^~~~~~~~~~ Cc: Shlomi Gridish Cc: Jerry Huang Cc: Peter Barada Cc: Anton Vorontsov Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20200706133341.476881-31-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/fhci-tds.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/host/fhci-tds.c b/drivers/usb/host/fhci-tds.c index f3308ce25043..d98fd9e1af0b 100644 --- a/drivers/usb/host/fhci-tds.c +++ b/drivers/usb/host/fhci-tds.c @@ -467,17 +467,15 @@ u32 fhci_host_transaction(struct fhci_usb *usb, /* Reset the Tx BD ring */ void fhci_flush_bds(struct fhci_usb *usb) { - u16 extra_data; u16 td_status; - u32 buf; struct usb_td __iomem *td; struct endpoint *ep = usb->ep0; td = ep->td_base; while (1) { td_status = in_be16(&td->status); - buf = in_be32(&td->buf_ptr); - extra_data = in_be16(&td->extra); + in_be32(&td->buf_ptr); + in_be16(&td->extra); /* if the TD is not empty - we'll confirm it as Timeout */ if (td_status & TD_R) @@ -524,7 +522,6 @@ void fhci_flush_actual_frame(struct fhci_usb *usb) { u8 mode; u16 tb_ptr; - u16 extra_data; u16 td_status; u32 buf_ptr; struct usb_td __iomem *td; @@ -538,7 +535,7 @@ void fhci_flush_actual_frame(struct fhci_usb *usb) td = cpm_muram_addr(tb_ptr); td_status = in_be16(&td->status); buf_ptr = in_be32(&td->buf_ptr); - extra_data = in_be16(&td->extra); + in_be16(&td->extra); do { if (td_status & TD_R) { out_be16(&td->status, (td_status & ~TD_R) | TD_TO); @@ -552,7 +549,7 @@ void fhci_flush_actual_frame(struct fhci_usb *usb) td = next_bd(ep->td_base, td, td_status); td_status = in_be16(&td->status); buf_ptr = in_be32(&td->buf_ptr); - extra_data = in_be16(&td->extra); + in_be16(&td->extra); } while ((td_status & TD_R) || buf_ptr); fhci_td_transaction_confirm(usb); -- cgit v1.2.3-70-g09d2 From a6a6d06f33af1414f0ce506b00d89d44d701fc36 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Mon, 6 Jul 2020 14:33:40 +0100 Subject: usb: host: fhci-sched: Remove unused variable 'td' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 'td' has been completely unused since the driver's inception in 2009. Fixes the following W=1 kernel build warning(s): drivers/usb/host/fhci-sched.c: In function ‘fhci_queue_urb’: drivers/usb/host/fhci-sched.c:704:13: warning: variable ‘td’ set but not used [-Wunused-but-set-variable] 704 | struct td *td; | ^~ Cc: Shlomi Gridish Cc: Jerry Huang Cc: Peter Barada Cc: Anton Vorontsov Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20200706133341.476881-32-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/fhci-sched.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/host/fhci-sched.c b/drivers/usb/host/fhci-sched.c index 3235d5307403..63c646c8f7d6 100644 --- a/drivers/usb/host/fhci-sched.c +++ b/drivers/usb/host/fhci-sched.c @@ -701,7 +701,6 @@ void fhci_queue_urb(struct fhci_hcd *fhci, struct urb *urb) u32 data_len = urb->transfer_buffer_length; int urb_state = 0; int toggle = 0; - struct td *td; u8 *data; u16 cnt = 0; @@ -770,7 +769,7 @@ void fhci_queue_urb(struct fhci_hcd *fhci, struct urb *urb) usb_endpoint_maxp(&urb->ep->desc)) == 0)) urb_state = US_BULK0; while (data_len > 4096) { - td = fhci_td_fill(fhci, urb, urb_priv, ed, cnt, + fhci_td_fill(fhci, urb, urb_priv, ed, cnt, usb_pipeout(urb->pipe) ? FHCI_TA_OUT : FHCI_TA_IN, cnt ? USB_TD_TOGGLE_CARRY : @@ -781,7 +780,7 @@ void fhci_queue_urb(struct fhci_hcd *fhci, struct urb *urb) cnt++; } - td = fhci_td_fill(fhci, urb, urb_priv, ed, cnt, + fhci_td_fill(fhci, urb, urb_priv, ed, cnt, usb_pipeout(urb->pipe) ? FHCI_TA_OUT : FHCI_TA_IN, cnt ? USB_TD_TOGGLE_CARRY : toggle, data, data_len, 0, 0, true); @@ -789,7 +788,7 @@ void fhci_queue_urb(struct fhci_hcd *fhci, struct urb *urb) if (urb->transfer_flags & URB_ZERO_PACKET && cnt < urb_priv->num_of_tds) { - td = fhci_td_fill(fhci, urb, urb_priv, ed, cnt, + fhci_td_fill(fhci, urb, urb_priv, ed, cnt, usb_pipeout(urb->pipe) ? FHCI_TA_OUT : FHCI_TA_IN, USB_TD_TOGGLE_CARRY, NULL, 0, 0, 0, true); @@ -798,7 +797,7 @@ void fhci_queue_urb(struct fhci_hcd *fhci, struct urb *urb) break; case FHCI_TF_INTR: urb->start_frame = get_frame_num(fhci) + 1; - td = fhci_td_fill(fhci, urb, urb_priv, ed, cnt++, + fhci_td_fill(fhci, urb, urb_priv, ed, cnt++, usb_pipeout(urb->pipe) ? FHCI_TA_OUT : FHCI_TA_IN, USB_TD_TOGGLE_DATA0, data, data_len, urb->interval, urb->start_frame, true); @@ -808,12 +807,12 @@ void fhci_queue_urb(struct fhci_hcd *fhci, struct urb *urb) ed->max_pkt_size = usb_endpoint_maxp(&urb->ep->desc); /* setup stage */ - td = fhci_td_fill(fhci, urb, urb_priv, ed, cnt++, FHCI_TA_SETUP, + fhci_td_fill(fhci, urb, urb_priv, ed, cnt++, FHCI_TA_SETUP, USB_TD_TOGGLE_DATA0, urb->setup_packet, 8, 0, 0, true); /* data stage */ if (data_len > 0) { - td = fhci_td_fill(fhci, urb, urb_priv, ed, cnt++, + fhci_td_fill(fhci, urb, urb_priv, ed, cnt++, usb_pipeout(urb->pipe) ? FHCI_TA_OUT : FHCI_TA_IN, USB_TD_TOGGLE_DATA1, data, data_len, 0, 0, @@ -822,12 +821,12 @@ void fhci_queue_urb(struct fhci_hcd *fhci, struct urb *urb) /* status stage */ if (data_len > 0) - td = fhci_td_fill(fhci, urb, urb_priv, ed, cnt++, + fhci_td_fill(fhci, urb, urb_priv, ed, cnt++, (usb_pipeout(urb->pipe) ? FHCI_TA_IN : FHCI_TA_OUT), USB_TD_TOGGLE_DATA1, data, 0, 0, 0, true); else - td = fhci_td_fill(fhci, urb, urb_priv, ed, cnt++, + fhci_td_fill(fhci, urb, urb_priv, ed, cnt++, FHCI_TA_IN, USB_TD_TOGGLE_DATA1, data, 0, 0, 0, true); @@ -844,7 +843,7 @@ void fhci_queue_urb(struct fhci_hcd *fhci, struct urb *urb) */ frame += cnt * urb->interval; frame &= 0x07ff; - td = fhci_td_fill(fhci, urb, urb_priv, ed, cnt, + fhci_td_fill(fhci, urb, urb_priv, ed, cnt, usb_pipeout(urb->pipe) ? FHCI_TA_OUT : FHCI_TA_IN, USB_TD_TOGGLE_DATA0, -- cgit v1.2.3-70-g09d2 From f535ad6c73c3306ec10311e4953c6df84d3b46ed Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Mon, 6 Jul 2020 14:33:41 +0100 Subject: usb: host: xhci-plat: Do not define 'struct acpi_device_id' when !CONFIG_ACPI MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since ACPI_PTR() is used to NULLify the value when !CONFIG_ACPI, struct usb_xhci_acpi_match becomes defined by unused. Fixes the following W=1 kernel build warning(s): drivers/usb/host/xhci-plat.c:457:36: warning: ‘usb_xhci_acpi_match’ defined but not used [-Wunused-const-variable=] 457 | static const struct acpi_device_id usb_xhci_acpi_match[] = { | ^~~~~~~~~~~~~~~~~~~ Cc: Mathias Nyman Cc: Andrzej Siewior Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20200706133341.476881-33-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/xhci-plat.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers/usb') diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c index f6b4089bfc4a..3e15b70a6fc9 100644 --- a/drivers/usb/host/xhci-plat.c +++ b/drivers/usb/host/xhci-plat.c @@ -454,12 +454,14 @@ static const struct dev_pm_ops xhci_plat_pm_ops = { NULL) }; +#ifdef CONFIG_ACPI static const struct acpi_device_id usb_xhci_acpi_match[] = { /* XHCI-compliant USB Controller */ { "PNP0D10", }, { } }; MODULE_DEVICE_TABLE(acpi, usb_xhci_acpi_match); +#endif static struct platform_driver usb_xhci_driver = { .probe = xhci_plat_probe, -- cgit v1.2.3-70-g09d2 From e46d8cb5f147955d77b0517f4bcb45e128d75525 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Wed, 8 Jul 2020 20:49:03 +0200 Subject: USB: storage: replace HTTP links with HTTPS ones Rationale: Reduces attack surface on kernel devs opening the links for MITM as HTTPS traffic is much harder to manipulate. Deterministic algorithm: For each file: If not .svg: For each line: If doesn't contain `\bxmlns\b`: For each link, `\bhttp://[^# \t\r\n]*(?:\w|/)`: If neither `\bgnu\.org/license`, nor `\bmozilla\.org/MPL\b`: If both the HTTP and HTTPS versions return 200 OK and serve the same content: Replace HTTP with HTTPS. Signed-off-by: Alexander A. Klimov Link: https://lore.kernel.org/r/20200708184903.17350-1-grandmaster@al2klimov.de Signed-off-by: Greg Kroah-Hartman --- drivers/usb/storage/Kconfig | 2 +- drivers/usb/storage/freecom.c | 2 +- drivers/usb/storage/unusual_devs.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/storage/Kconfig b/drivers/usb/storage/Kconfig index 5335a7ff5d14..d17b60a644ef 100644 --- a/drivers/usb/storage/Kconfig +++ b/drivers/usb/storage/Kconfig @@ -57,7 +57,7 @@ config USB_STORAGE_FREECOM tristate "Freecom USB/ATAPI Bridge support" help Support for the Freecom USB to IDE/ATAPI adaptor. - Freecom has a web page at . + Freecom has a web page at . If this driver is compiled as a module, it will be named ums-freecom. diff --git a/drivers/usb/storage/freecom.c b/drivers/usb/storage/freecom.c index 34e7eaff1174..3d5f7d0ff0f1 100644 --- a/drivers/usb/storage/freecom.c +++ b/drivers/usb/storage/freecom.c @@ -11,7 +11,7 @@ * * This driver was developed with information provided in FREECOM's USB * Programmers Reference Guide. For further information contact Freecom - * (http://www.freecom.de/) + * (https://www.freecom.de/) */ #include diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h index b6a9a7451620..220ae2c356ee 100644 --- a/drivers/usb/storage/unusual_devs.h +++ b/drivers/usb/storage/unusual_devs.h @@ -44,7 +44,7 @@ * mode. Existing userspace solutions are superior. * * New mode switching devices should instead be added to the database - * maintained at http://www.draisberghof.de/usb_modeswitch/ + * maintained at https://www.draisberghof.de/usb_modeswitch/ */ #if !defined(CONFIG_USB_STORAGE_SDDR09) && \ -- cgit v1.2.3-70-g09d2 From 2da3b53c78be8a11800a3d5053a8ca22b2455c8e Mon Sep 17 00:00:00 2001 From: "Gustavo A. R. Silva" Date: Tue, 7 Jul 2020 14:52:14 -0500 Subject: usbip: Use fallthrough pseudo-keyword Replace the existing /* fall through */ comments and its variants with the new pseudo-keyword macro fallthrough[1]. Also, remove unnecessary fall-through markings when it is the case. [1] https://www.kernel.org/doc/html/latest/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through Signed-off-by: Gustavo A. R. Silva Acked-by: Shuah Khan Link: https://lore.kernel.org/r/20200707195214.GA3932@embeddedor Signed-off-by: Greg Kroah-Hartman --- drivers/usb/usbip/stub_rx.c | 2 +- drivers/usb/usbip/vhci_hcd.c | 7 +++---- drivers/usb/usbip/vhci_rx.c | 2 +- drivers/usb/usbip/vudc_transfer.c | 4 ++-- 4 files changed, 7 insertions(+), 8 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/usbip/stub_rx.c b/drivers/usb/usbip/stub_rx.c index e2b019532234..325c22008e53 100644 --- a/drivers/usb/usbip/stub_rx.c +++ b/drivers/usb/usbip/stub_rx.c @@ -424,7 +424,7 @@ static void masking_bogus_flags(struct urb *urb) case USB_ENDPOINT_XFER_BULK: if (is_out) allowed |= URB_ZERO_PACKET; - /* FALLTHROUGH */ + fallthrough; default: /* all non-iso endpoints */ if (!is_out) allowed |= URB_SHORT_NOT_OK; diff --git a/drivers/usb/usbip/vhci_hcd.c b/drivers/usb/usbip/vhci_hcd.c index 65850e9c7190..1b598db5d8b9 100644 --- a/drivers/usb/usbip/vhci_hcd.c +++ b/drivers/usb/usbip/vhci_hcd.c @@ -508,7 +508,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, case USB_PORT_FEAT_U1_TIMEOUT: usbip_dbg_vhci_rh( " SetPortFeature: USB_PORT_FEAT_U1_TIMEOUT\n"); - /* Fall through */ + fallthrough; case USB_PORT_FEAT_U2_TIMEOUT: usbip_dbg_vhci_rh( " SetPortFeature: USB_PORT_FEAT_U2_TIMEOUT\n"); @@ -561,7 +561,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, "supported for USB 2.0 roothub\n"); goto error; } - /* FALLS THROUGH */ + fallthrough; case USB_PORT_FEAT_RESET: usbip_dbg_vhci_rh( " SetPortFeature: USB_PORT_FEAT_RESET\n"); @@ -584,8 +584,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, /* 50msec reset signaling */ vhci_hcd->re_timeout = jiffies + msecs_to_jiffies(50); - - /* FALLS THROUGH */ + fallthrough; default: usbip_dbg_vhci_rh(" SetPortFeature: default %d\n", wValue); diff --git a/drivers/usb/usbip/vhci_rx.c b/drivers/usb/usbip/vhci_rx.c index 00fc98741c5d..266024cbb64f 100644 --- a/drivers/usb/usbip/vhci_rx.c +++ b/drivers/usb/usbip/vhci_rx.c @@ -27,7 +27,7 @@ struct urb *pickup_urb_and_free_priv(struct vhci_device *vdev, __u32 seqnum) switch (status) { case -ENOENT: - /* fall through */ + fallthrough; case -ECONNRESET: dev_dbg(&urb->dev->dev, "urb seq# %u was unlinked %ssynchronously\n", diff --git a/drivers/usb/usbip/vudc_transfer.c b/drivers/usb/usbip/vudc_transfer.c index c9db846ee4f6..7e801fee33bf 100644 --- a/drivers/usb/usbip/vudc_transfer.c +++ b/drivers/usb/usbip/vudc_transfer.c @@ -404,7 +404,7 @@ restart: * for now, give unlimited bandwidth */ limit += urb->transfer_buffer_length; - /* fallthrough */ + fallthrough; default: treat_control_like_bulk: total -= transfer(udc, urb, ep, limit); @@ -479,7 +479,7 @@ void v_kick_timer(struct vudc *udc, unsigned long time) return; case VUDC_TR_IDLE: t->state = VUDC_TR_RUNNING; - /* fallthrough */ + fallthrough; case VUDC_TR_STOPPED: /* we may want to kick timer to unqueue urbs */ mod_timer(&t->timer, time); -- cgit v1.2.3-70-g09d2 From 4e71e079432e3e0c8572a405f5cedf957d4d422c Mon Sep 17 00:00:00 2001 From: "Gustavo A. R. Silva" Date: Tue, 7 Jul 2020 15:00:40 -0500 Subject: usb: phy: Use fallthrough pseudo-keyword Replace the existing /* fall through */ comments and its variants with the new pseudo-keyword macro fallthrough[1]. Also, remove unnecessary fall-through markings when it is the case. [1] https://www.kernel.org/doc/html/latest/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through Signed-off-by: Gustavo A. R. Silva Link: https://lore.kernel.org/r/20200707200040.GA4525@embeddedor Signed-off-by: Greg Kroah-Hartman --- drivers/usb/phy/phy-ab8500-usb.c | 12 ++++++------ drivers/usb/phy/phy-fsl-usb.c | 4 ++-- drivers/usb/phy/phy-isp1301-omap.c | 14 +++++++------- drivers/usb/phy/phy-mv-usb.c | 2 +- 4 files changed, 16 insertions(+), 16 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/phy/phy-ab8500-usb.c b/drivers/usb/phy/phy-ab8500-usb.c index 20c0f082bf9c..aa4a3140394b 100644 --- a/drivers/usb/phy/phy-ab8500-usb.c +++ b/drivers/usb/phy/phy-ab8500-usb.c @@ -331,7 +331,7 @@ static int ab8505_usb_link_status_update(struct ab8500_usb *ab, switch (lsts) { case USB_LINK_ACA_RID_B_8505: event = UX500_MUSB_RIDB; - /* Fall through */ + fallthrough; case USB_LINK_NOT_CONFIGURED_8505: case USB_LINK_RESERVED0_8505: case USB_LINK_RESERVED1_8505: @@ -352,7 +352,7 @@ static int ab8505_usb_link_status_update(struct ab8500_usb *ab, case USB_LINK_ACA_RID_C_NM_8505: event = UX500_MUSB_RIDC; - /* Fall through */ + fallthrough; case USB_LINK_STD_HOST_NC_8505: case USB_LINK_STD_HOST_C_NS_8505: case USB_LINK_STD_HOST_C_S_8505: @@ -371,7 +371,7 @@ static int ab8505_usb_link_status_update(struct ab8500_usb *ab, case USB_LINK_ACA_RID_A_8505: case USB_LINK_ACA_DOCK_CHGR_8505: event = UX500_MUSB_RIDA; - /* Fall through */ + fallthrough; case USB_LINK_HM_IDGND_8505: if (ab->mode == USB_IDLE) { ab->mode = USB_HOST; @@ -444,7 +444,7 @@ static int ab8500_usb_link_status_update(struct ab8500_usb *ab, switch (lsts) { case USB_LINK_ACA_RID_B_8500: event = UX500_MUSB_RIDB; - /* Fall through */ + fallthrough; case USB_LINK_NOT_CONFIGURED_8500: case USB_LINK_NOT_VALID_LINK_8500: ab->mode = USB_IDLE; @@ -461,7 +461,7 @@ static int ab8500_usb_link_status_update(struct ab8500_usb *ab, case USB_LINK_ACA_RID_C_HS_8500: case USB_LINK_ACA_RID_C_HS_CHIRP_8500: event = UX500_MUSB_RIDC; - /* Fall through */ + fallthrough; case USB_LINK_STD_HOST_NC_8500: case USB_LINK_STD_HOST_C_NS_8500: case USB_LINK_STD_HOST_C_S_8500: @@ -481,7 +481,7 @@ static int ab8500_usb_link_status_update(struct ab8500_usb *ab, case USB_LINK_ACA_RID_A_8500: event = UX500_MUSB_RIDA; - /* Fall through */ + fallthrough; case USB_LINK_HM_IDGND_8500: if (ab->mode == USB_IDLE) { ab->mode = USB_HOST; diff --git a/drivers/usb/phy/phy-fsl-usb.c b/drivers/usb/phy/phy-fsl-usb.c index 0c6d9f9f2994..f34c9437a182 100644 --- a/drivers/usb/phy/phy-fsl-usb.c +++ b/drivers/usb/phy/phy-fsl-usb.c @@ -911,10 +911,10 @@ int usb_otg_start(struct platform_device *pdev) break; case FSL_USB2_PHY_UTMI_WIDE: temp |= PORTSC_PTW_16BIT; - /* fall through */ + fallthrough; case FSL_USB2_PHY_UTMI: temp |= PORTSC_PTS_UTMI; - /* fall through */ + fallthrough; default: break; } diff --git a/drivers/usb/phy/phy-isp1301-omap.c b/drivers/usb/phy/phy-isp1301-omap.c index 7041ba030052..4a6462c92ef2 100644 --- a/drivers/usb/phy/phy-isp1301-omap.c +++ b/drivers/usb/phy/phy-isp1301-omap.c @@ -581,11 +581,11 @@ pulldown: /* HNP failed for some reason (A_AIDL_BDIS timeout) */ notresponding(isp); - /* FALLTHROUGH */ + fallthrough; case OTG_STATE_A_VBUS_ERR: isp->phy.otg->state = OTG_STATE_A_WAIT_VFALL; pr_debug(" --> a_wait_vfall\n"); - /* FALLTHROUGH */ + fallthrough; case OTG_STATE_A_WAIT_VFALL: /* FIXME usbcore thinks port power is still on ... */ clr |= OTG1_VBUS_DRV; @@ -595,7 +595,7 @@ pulldown: isp->phy.otg->state = OTG_STATE_A_WAIT_VRISE; pr_debug(" --> a_wait_vrise\n"); } - /* FALLTHROUGH */ + fallthrough; default: toggle(OTG_DRV_VBUS, OTG1_VBUS_DRV); } @@ -945,10 +945,10 @@ static void isp_update_otg(struct isp1301 *isp, u8 stat) switch (state) { case OTG_STATE_B_IDLE: a_idle(isp, "idle"); - /* FALLTHROUGH */ + fallthrough; case OTG_STATE_A_IDLE: enable_vbus_source(isp); - /* FALLTHROUGH */ + fallthrough; case OTG_STATE_A_WAIT_VRISE: /* we skip over OTG_STATE_A_WAIT_BCON, since * the HC will transition to A_HOST (or @@ -1032,12 +1032,12 @@ static void isp_update_otg(struct isp1301 *isp, u8 stat) OTG1_DP_PULLUP); dump_regs(isp, __func__); #endif - /* FALLTHROUGH */ + fallthrough; case OTG_STATE_B_SRP_INIT: b_idle(isp, __func__); l = omap_readl(OTG_CTRL) & OTG_XCEIV_OUTPUTS; omap_writel(l, OTG_CTRL); - /* FALLTHROUGH */ + fallthrough; case OTG_STATE_B_IDLE: if (otg->gadget && (isp_bstat & OTG_B_SESS_VLD)) { #ifdef CONFIG_USB_OTG diff --git a/drivers/usb/phy/phy-mv-usb.c b/drivers/usb/phy/phy-mv-usb.c index 06b47f1028b3..ce767ecc0636 100644 --- a/drivers/usb/phy/phy-mv-usb.c +++ b/drivers/usb/phy/phy-mv-usb.c @@ -334,7 +334,7 @@ static void mv_otg_update_state(struct mv_otg *mvotg) switch (old_state) { case OTG_STATE_UNDEFINED: mvotg->phy.otg->state = OTG_STATE_B_IDLE; - /* FALL THROUGH */ + fallthrough; case OTG_STATE_B_IDLE: if (otg_ctrl->id == 0) mvotg->phy.otg->state = OTG_STATE_A_IDLE; -- cgit v1.2.3-70-g09d2 From 0d9b6d49fe39bd397f1d5913b1bfb8c4fdef0255 Mon Sep 17 00:00:00 2001 From: "Gustavo A. R. Silva" Date: Tue, 7 Jul 2020 14:56:07 -0500 Subject: usb: Use fallthrough pseudo-keyword Replace the existing /* fall through */ comments and its variants with the new pseudo-keyword macro fallthrough[1]. Also, remove unnecessary fall-through markings when it is the case. [1] https://www.kernel.org/doc/html/latest/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through Signed-off-by: Gustavo A. R. Silva Link: https://lore.kernel.org/r/20200707195607.GA4198@embeddedor Signed-off-by: Greg Kroah-Hartman --- drivers/usb/atm/cxacru.c | 4 ++-- drivers/usb/cdns3/gadget.c | 4 ++-- drivers/usb/class/usbtmc.c | 2 +- drivers/usb/core/config.c | 2 +- drivers/usb/core/hcd.c | 8 ++++---- drivers/usb/core/hub.c | 2 +- drivers/usb/core/urb.c | 4 ++-- drivers/usb/host/fotg210-hcd.c | 8 ++++---- drivers/usb/host/isp1362-hcd.c | 2 +- drivers/usb/host/max3421-hcd.c | 6 +++--- drivers/usb/host/oxu210hp-hcd.c | 8 ++++---- drivers/usb/image/mdc800.c | 2 +- drivers/usb/isp1760/isp1760-hcd.c | 4 ++-- drivers/usb/misc/appledisplay.c | 2 +- drivers/usb/misc/usbtest.c | 8 ++++---- drivers/usb/misc/yurex.c | 2 +- drivers/usb/renesas_usbhs/mod_gadget.c | 2 +- drivers/usb/renesas_usbhs/pipe.c | 2 +- 18 files changed, 36 insertions(+), 36 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c index 5d41f85a7445..ea66f8f385ba 100644 --- a/drivers/usb/atm/cxacru.c +++ b/drivers/usb/atm/cxacru.c @@ -408,7 +408,7 @@ static ssize_t adsl_state_store(struct device *dev, case CXPOLL_STOPPING: /* abort stop request */ instance->poll_state = CXPOLL_POLLING; - /* fall through */ + fallthrough; case CXPOLL_POLLING: case CXPOLL_SHUTDOWN: /* don't start polling */ @@ -802,7 +802,7 @@ static int cxacru_atm_start(struct usbatm_data *usbatm_instance, case CXPOLL_STOPPING: /* abort stop request */ instance->poll_state = CXPOLL_POLLING; - /* fall through */ + fallthrough; case CXPOLL_POLLING: case CXPOLL_SHUTDOWN: /* don't start polling */ diff --git a/drivers/usb/cdns3/gadget.c b/drivers/usb/cdns3/gadget.c index 64a801c7a03c..d9dde624636b 100644 --- a/drivers/usb/cdns3/gadget.c +++ b/drivers/usb/cdns3/gadget.c @@ -2815,7 +2815,7 @@ static int cdns3_gadget_udc_start(struct usb_gadget *gadget, dev_err(priv_dev->dev, "invalid maximum_speed parameter %d\n", max_speed); - /* fall through */ + fallthrough; case USB_SPEED_UNKNOWN: /* default to superspeed */ max_speed = USB_SPEED_SUPER; @@ -3056,7 +3056,7 @@ static int cdns3_gadget_start(struct cdns3 *cdns) default: dev_err(cdns->dev, "invalid maximum_speed parameter %d\n", max_speed); - /* fall through */ + fallthrough; case USB_SPEED_UNKNOWN: /* default to superspeed */ max_speed = USB_SPEED_SUPER; diff --git a/drivers/usb/class/usbtmc.c b/drivers/usb/class/usbtmc.c index 4b52758d3a38..b222b777e6a4 100644 --- a/drivers/usb/class/usbtmc.c +++ b/drivers/usb/class/usbtmc.c @@ -2282,7 +2282,7 @@ static void usbtmc_interrupt(struct urb *urb) case -EOVERFLOW: dev_err(dev, "overflow with length %d, actual length is %d\n", data->iin_wMaxPacketSize, urb->actual_length); - /* fall through */ + fallthrough; case -ECONNRESET: case -ENOENT: case -ESHUTDOWN: diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c index 37442f423a41..562a730befda 100644 --- a/drivers/usb/core/config.c +++ b/drivers/usb/core/config.c @@ -427,7 +427,7 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno, i = maxp & (BIT(12) | BIT(11)); maxp &= ~i; } - /* fallthrough */ + fallthrough; default: maxpacket_maxes = high_speed_maxpacket_maxes; break; diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index de624c47e190..a33b849e8beb 100644 --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c @@ -564,7 +564,7 @@ static int rh_call_control (struct usb_hcd *hcd, struct urb *urb) case DeviceRequest | USB_REQ_GET_CONFIGURATION: tbuf[0] = 1; len = 1; - /* FALLTHROUGH */ + fallthrough; case DeviceOutRequest | USB_REQ_SET_CONFIGURATION: break; case DeviceRequest | USB_REQ_GET_DESCRIPTOR: @@ -633,7 +633,7 @@ static int rh_call_control (struct usb_hcd *hcd, struct urb *urb) case DeviceRequest | USB_REQ_GET_INTERFACE: tbuf[0] = 0; len = 1; - /* FALLTHROUGH */ + fallthrough; case DeviceOutRequest | USB_REQ_SET_INTERFACE: break; case DeviceOutRequest | USB_REQ_SET_ADDRESS: @@ -651,7 +651,7 @@ static int rh_call_control (struct usb_hcd *hcd, struct urb *urb) tbuf[0] = 0; tbuf[1] = 0; len = 2; - /* FALLTHROUGH */ + fallthrough; case EndpointOutRequest | USB_REQ_CLEAR_FEATURE: case EndpointOutRequest | USB_REQ_SET_FEATURE: dev_dbg (hcd->self.controller, "no endpoint features yet\n"); @@ -2726,7 +2726,7 @@ int usb_add_hcd(struct usb_hcd *hcd, case HCD_USB32: rhdev->rx_lanes = 2; rhdev->tx_lanes = 2; - /* fall through */ + fallthrough; case HCD_USB31: rhdev->speed = USB_SPEED_SUPER_PLUS; break; diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 71bbd2eed7c6..052d5accfe9b 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -4698,7 +4698,7 @@ hub_port_init(struct usb_hub *hub, struct usb_device *udev, int port1, r = 0; break; } - /* FALL THROUGH */ + fallthrough; default: if (r == 0) r = -EPROTO; diff --git a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c index da923ec17612..7bc23469f4e4 100644 --- a/drivers/usb/core/urb.c +++ b/drivers/usb/core/urb.c @@ -486,7 +486,7 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags) case USB_ENDPOINT_XFER_INT: if (is_out) allowed |= URB_ZERO_PACKET; - /* FALLTHROUGH */ + fallthrough; default: /* all non-iso endpoints */ if (!is_out) allowed |= URB_SHORT_NOT_OK; @@ -519,7 +519,7 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags) if ((urb->interval < 6) && (xfertype == USB_ENDPOINT_XFER_INT)) return -EINVAL; - /* fall through */ + fallthrough; default: if (urb->interval <= 0) return -EINVAL; diff --git a/drivers/usb/host/fotg210-hcd.c b/drivers/usb/host/fotg210-hcd.c index 633df2e927bb..194df8282471 100644 --- a/drivers/usb/host/fotg210-hcd.c +++ b/drivers/usb/host/fotg210-hcd.c @@ -2807,7 +2807,7 @@ static struct fotg210_qh *qh_make(struct fotg210_hcd *fotg210, struct urb *urb, switch (urb->dev->speed) { case USB_SPEED_LOW: info1 |= QH_LOW_SPEED; - /* FALL THROUGH */ + fallthrough; case USB_SPEED_FULL: /* EPS 0 means "full" */ @@ -4634,7 +4634,7 @@ static inline int scan_frame_queue(struct fotg210_hcd *fotg210, unsigned frame, default: fotg210_dbg(fotg210, "corrupt type %d frame %d shadow %p\n", type, frame, q.ptr); - /* FALL THROUGH */ + fallthrough; case Q_TYPE_QH: case Q_TYPE_FSTN: /* End of the iTDs and siTDs */ @@ -5411,7 +5411,7 @@ rescan: */ if (tmp) start_unlink_async(fotg210, qh); - /* FALL THROUGH */ + fallthrough; case QH_STATE_UNLINK: /* wait for hw to finish? */ case QH_STATE_UNLINK_WAIT: idle_timeout: @@ -5425,7 +5425,7 @@ idle_timeout: qh_destroy(fotg210, qh); break; } - /* fall through */ + fallthrough; default: /* caller was supposed to have unlinked any requests; * that's not our job. just leak this memory. diff --git a/drivers/usb/host/isp1362-hcd.c b/drivers/usb/host/isp1362-hcd.c index 4a3a2852523f..2cecb36d241b 100644 --- a/drivers/usb/host/isp1362-hcd.c +++ b/drivers/usb/host/isp1362-hcd.c @@ -1748,7 +1748,7 @@ static int isp1362_bus_suspend(struct usb_hcd *hcd) isp1362_hcd->hc_control &= ~OHCI_CTRL_HCFS; isp1362_hcd->hc_control |= OHCI_USB_RESET; isp1362_write_reg32(isp1362_hcd, HCCONTROL, isp1362_hcd->hc_control); - /* FALL THROUGH */ + fallthrough; case OHCI_USB_RESET: status = -EBUSY; pr_warn("%s: needs reinit!\n", __func__); diff --git a/drivers/usb/host/max3421-hcd.c b/drivers/usb/host/max3421-hcd.c index 8819f502b6a6..05828c0ab7de 100644 --- a/drivers/usb/host/max3421-hcd.c +++ b/drivers/usb/host/max3421-hcd.c @@ -925,7 +925,7 @@ max3421_handle_error(struct usb_hcd *hcd, u8 hrsl) spi_wr8(hcd, MAX3421_REG_HCTL, BIT(sndtog + MAX3421_HCTL_SNDTOG0_BIT)); } - /* FALL THROUGH */ + fallthrough; case MAX3421_HRSL_BADBC: /* bad byte count */ case MAX3421_HRSL_PIDERR: /* received PID is corrupted */ case MAX3421_HRSL_PKTERR: /* packet error (stuff, EOP) */ @@ -1715,7 +1715,7 @@ max3421_hub_control(struct usb_hcd *hcd, u16 type_req, u16 value, u16 index, dev_dbg(hcd->self.controller, "power-off\n"); max3421_gpout_set_value(hcd, pdata->vbus_gpout, !pdata->vbus_active_level); - /* FALLS THROUGH */ + fallthrough; default: max3421_hcd->port_status &= ~(1 << value); } @@ -1768,7 +1768,7 @@ max3421_hub_control(struct usb_hcd *hcd, u16 type_req, u16 value, u16 index, break; case USB_PORT_FEAT_RESET: max3421_reset_port(hcd); - /* FALLS THROUGH */ + fallthrough; default: if ((max3421_hcd->port_status & USB_PORT_STAT_POWER) != 0) diff --git a/drivers/usb/host/oxu210hp-hcd.c b/drivers/usb/host/oxu210hp-hcd.c index b00673295c9f..cfa7dd2cc7d3 100644 --- a/drivers/usb/host/oxu210hp-hcd.c +++ b/drivers/usb/host/oxu210hp-hcd.c @@ -1858,7 +1858,7 @@ static struct ehci_qh *qh_make(struct oxu_hcd *oxu, switch (urb->dev->speed) { case USB_SPEED_LOW: info1 |= (1 << 12); /* EPS "low" */ - /* FALL THROUGH */ + fallthrough; case USB_SPEED_FULL: /* EPS 0 means "full" */ @@ -3377,7 +3377,7 @@ static int oxu_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) switch (qh->qh_state) { case QH_STATE_LINKED: intr_deschedule(oxu, qh); - /* FALL THROUGH */ + fallthrough; case QH_STATE_IDLE: qh_completions(oxu, qh); break; @@ -3449,7 +3449,7 @@ rescan: if (!tmp) goto nogood; unlink_async(oxu, qh); - /* FALL THROUGH */ + fallthrough; case QH_STATE_UNLINK: /* wait for hw to finish? */ idle_timeout: spin_unlock_irqrestore(&oxu->lock, flags); @@ -3460,7 +3460,7 @@ idle_timeout: qh_put(qh); break; } - /* fall through */ + fallthrough; default: nogood: /* caller was supposed to have unlinked any requests; diff --git a/drivers/usb/image/mdc800.c b/drivers/usb/image/mdc800.c index 2388674042a9..fc0e22cc6fda 100644 --- a/drivers/usb/image/mdc800.c +++ b/drivers/usb/image/mdc800.c @@ -880,7 +880,7 @@ static ssize_t mdc800_device_write (struct file *file, const char __user *buf, s return -EIO; } mdc800->pic_len=-1; - /* fall through */ + fallthrough; case 0x09: /* Download Thumbnail */ mdc800->download_left=answersize+64; diff --git a/drivers/usb/isp1760/isp1760-hcd.c b/drivers/usb/isp1760/isp1760-hcd.c index 579a21bd70ad..dd74ab7a2f9c 100644 --- a/drivers/usb/isp1760/isp1760-hcd.c +++ b/drivers/usb/isp1760/isp1760-hcd.c @@ -788,11 +788,11 @@ static void collect_qtds(struct usb_hcd *hcd, struct isp1760_qh *qh, mem_reads8(hcd->regs, qtd->payload_addr, qtd->data_buffer, qtd->actual_length); - /* Fall through */ + fallthrough; case OUT_PID: qtd->urb->actual_length += qtd->actual_length; - /* Fall through */ + fallthrough; case SETUP_PID: break; } diff --git a/drivers/usb/misc/appledisplay.c b/drivers/usb/misc/appledisplay.c index ba1eaabc7796..91cfd917f6df 100644 --- a/drivers/usb/misc/appledisplay.c +++ b/drivers/usb/misc/appledisplay.c @@ -89,7 +89,7 @@ static void appledisplay_complete(struct urb *urb) dev_err(dev, "OVERFLOW with data length %d, actual length is %d\n", ACD_URB_BUFFER_LEN, pdata->urb->actual_length); - /* fall through */ + fallthrough; case -ECONNRESET: case -ENOENT: case -ESHUTDOWN: diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c index bae88893ee8e..8b220d56647b 100644 --- a/drivers/usb/misc/usbtest.c +++ b/drivers/usb/misc/usbtest.c @@ -182,7 +182,7 @@ get_endpoints(struct usbtest_dev *dev, struct usb_interface *intf) case USB_ENDPOINT_XFER_ISOC: if (dev->info->iso) endpoint_update(edi, &iso_in, &iso_out, e); - /* FALLTHROUGH */ + fallthrough; default: continue; } @@ -364,7 +364,7 @@ static void simple_fill_buf(struct urb *urb) switch (pattern) { default: - /* FALLTHROUGH */ + fallthrough; case 0: memset(buf, 0, len); break; @@ -681,7 +681,7 @@ static int get_altsetting(struct usbtest_dev *dev) return dev->buf[0]; case 0: retval = -ERANGE; - /* FALLTHROUGH */ + fallthrough; default: return retval; } @@ -1951,7 +1951,7 @@ static void complicated_callback(struct urb *urb) dev_err(&ctx->dev->intf->dev, "resubmit err %d\n", status); - /* FALLTHROUGH */ + fallthrough; case -ENODEV: /* disconnected */ case -ESHUTDOWN: /* endpoint disabled */ ctx->submit_error = 1; diff --git a/drivers/usb/misc/yurex.c b/drivers/usb/misc/yurex.c index be0505b8b5d4..6e7d34e7fec4 100644 --- a/drivers/usb/misc/yurex.c +++ b/drivers/usb/misc/yurex.c @@ -472,7 +472,7 @@ static ssize_t yurex_write(struct file *file, const char __user *user_buffer, break; case CMD_SET: data++; - /* FALL THROUGH */ + fallthrough; case '0' ... '9': set = 1; c = c2 = simple_strtoull(data, NULL, 0); diff --git a/drivers/usb/renesas_usbhs/mod_gadget.c b/drivers/usb/renesas_usbhs/mod_gadget.c index 53489cafecc1..105132ae87ac 100644 --- a/drivers/usb/renesas_usbhs/mod_gadget.c +++ b/drivers/usb/renesas_usbhs/mod_gadget.c @@ -509,7 +509,7 @@ static int usbhsg_irq_ctrl_stage(struct usbhs_priv *priv, case READ_STATUS_STAGE: case WRITE_STATUS_STAGE: usbhs_dcp_control_transfer_done(pipe); - /* fall through */ + fallthrough; default: return ret; } diff --git a/drivers/usb/renesas_usbhs/pipe.c b/drivers/usb/renesas_usbhs/pipe.c index 9e5afdde1adb..e7334b7fb3a6 100644 --- a/drivers/usb/renesas_usbhs/pipe.c +++ b/drivers/usb/renesas_usbhs/pipe.c @@ -308,7 +308,7 @@ static void __usbhsp_pid_try_nak_if_stall(struct usbhs_pipe *pipe) switch (pid) { case PID_STALL11: usbhsp_pipectrl_set(pipe, PID_MASK, PID_STALL10); - /* fall-through */ + fallthrough; case PID_STALL10: usbhsp_pipectrl_set(pipe, PID_MASK, PID_NAK); } -- cgit v1.2.3-70-g09d2 From e288fc982820e1bf397c873b0cf0cbf876829b7f Mon Sep 17 00:00:00 2001 From: "Gustavo A. R. Silva" Date: Tue, 7 Jul 2020 14:53:51 -0500 Subject: USB: OHCI: Use fallthrough pseudo-keyword Replace the existing /* fall through */ comments and its variants with the new pseudo-keyword macro fallthrough[1]. Also, remove unnecessary fall-through markings when it is the case. [1] https://www.kernel.org/doc/html/latest/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through Signed-off-by: Gustavo A. R. Silva Link: https://lore.kernel.org/r/20200707195351.GA4061@embeddedor Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/ohci-hcd.c | 4 ++-- drivers/usb/host/ohci-hub.c | 2 +- drivers/usb/host/ohci-q.c | 6 +++--- drivers/usb/host/ohci-tmio.c | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c index 4de91653a2c7..9b4121927d4a 100644 --- a/drivers/usb/host/ohci-hcd.c +++ b/drivers/usb/host/ohci-hcd.c @@ -385,7 +385,7 @@ sanitize: ed_free (ohci, ed); break; } - /* fall through */ + fallthrough; default: /* caller was supposed to have unlinked any requests; * that's not our job. can't recover; must leak ed. @@ -1051,7 +1051,7 @@ int ohci_restart(struct ohci_hcd *ohci) ed->ed_next = ohci->ed_rm_list; ed->ed_prev = NULL; ohci->ed_rm_list = ed; - /* FALLTHROUGH */ + fallthrough; case ED_UNLINK: break; default: diff --git a/drivers/usb/host/ohci-hub.c b/drivers/usb/host/ohci-hub.c index 634f3c7bf774..44504c1751e0 100644 --- a/drivers/usb/host/ohci-hub.c +++ b/drivers/usb/host/ohci-hub.c @@ -58,7 +58,7 @@ __acquires(ohci->lock) ohci->hc_control |= OHCI_USB_RESET; ohci_writel (ohci, ohci->hc_control, &ohci->regs->control); (void) ohci_readl (ohci, &ohci->regs->control); - /* FALL THROUGH */ + fallthrough; case OHCI_USB_RESET: status = -EBUSY; ohci_dbg (ohci, "needs reinit!\n"); diff --git a/drivers/usb/host/ohci-q.c b/drivers/usb/host/ohci-q.c index 4ccb85a67bb3..3b445312beea 100644 --- a/drivers/usb/host/ohci-q.c +++ b/drivers/usb/host/ohci-q.c @@ -647,7 +647,7 @@ static void td_submit_urb ( /* ... and periodic urbs have extra accounting */ periodic = ohci_to_hcd(ohci)->self.bandwidth_int_reqs++ == 0 && ohci_to_hcd(ohci)->self.bandwidth_isoc_reqs == 0; - /* FALLTHROUGH */ + fallthrough; case PIPE_BULK: info = is_out ? TD_T_TOGGLE | TD_CC | TD_DP_OUT @@ -879,11 +879,11 @@ static void ed_halted(struct ohci_hcd *ohci, struct td *td, int cc) case TD_DATAUNDERRUN: if ((urb->transfer_flags & URB_SHORT_NOT_OK) == 0) break; - /* fallthrough */ + fallthrough; case TD_CC_STALL: if (usb_pipecontrol (urb->pipe)) break; - /* fallthrough */ + fallthrough; default: ohci_dbg (ohci, "urb %p path %s ep%d%s %08x cc %d --> status %d\n", diff --git a/drivers/usb/host/ohci-tmio.c b/drivers/usb/host/ohci-tmio.c index fb6f5e9ae5c6..7f857bad9e95 100644 --- a/drivers/usb/host/ohci-tmio.c +++ b/drivers/usb/host/ohci-tmio.c @@ -97,13 +97,13 @@ static void tmio_stop_hc(struct platform_device *dev) switch (ohci->num_ports) { default: dev_err(&dev->dev, "Unsupported amount of ports: %d\n", ohci->num_ports); - /* fall through */ + fallthrough; case 3: pm |= CCR_PM_USBPW3; - /* fall through */ + fallthrough; case 2: pm |= CCR_PM_USBPW2; - /* fall through */ + fallthrough; case 1: pm |= CCR_PM_USBPW1; } -- cgit v1.2.3-70-g09d2 From 8b84724e9e8445f26fb2f7ccb86f8109ba2427c6 Mon Sep 17 00:00:00 2001 From: "Gustavo A. R. Silva" Date: Tue, 7 Jul 2020 14:50:23 -0500 Subject: usb: host: Use fallthrough pseudo-keyword Replace the existing /* fall through */ comments and its variants with the new pseudo-keyword macro fallthrough[1]. Also, remove unnecessary fall-through markings when it is the case. [1] https://www.kernel.org/doc/html/latest/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through Signed-off-by: Gustavo A. R. Silva Link: https://lore.kernel.org/r/20200707195023.GA3792@embeddedor Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/ehci-dbg.c | 2 +- drivers/usb/host/ehci-fsl.c | 4 ++-- drivers/usb/host/ehci-hcd.c | 4 ++-- drivers/usb/host/ehci-q.c | 2 +- drivers/usb/host/ehci-sched.c | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/host/ehci-dbg.c b/drivers/usb/host/ehci-dbg.c index 7619cfb06883..0b7f1edd9eec 100644 --- a/drivers/usb/host/ehci-dbg.c +++ b/drivers/usb/host/ehci-dbg.c @@ -823,7 +823,7 @@ static ssize_t fill_registers_buffer(struct debug_buffer *buf) break; case 0: /* illegal reserved capability */ cap = 0; - /* FALLTHROUGH */ + fallthrough; default: /* unknown */ break; } diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c index 1ebe4d425277..1e8b59ab2272 100644 --- a/drivers/usb/host/ehci-fsl.c +++ b/drivers/usb/host/ehci-fsl.c @@ -234,7 +234,7 @@ static int ehci_fsl_setup_phy(struct usb_hcd *hcd, break; case FSL_USB2_PHY_UTMI_WIDE: portsc |= PORT_PTS_PTW; - /* fall through */ + fallthrough; case FSL_USB2_PHY_UTMI: /* Presence of this node "has_fsl_erratum_a006918" * in device-tree is used to stop USB controller @@ -244,7 +244,7 @@ static int ehci_fsl_setup_phy(struct usb_hcd *hcd, dev_warn(dev, "USB PHY clock invalid\n"); return -EINVAL; } - /* fall through */ + fallthrough; case FSL_USB2_PHY_UTMI_DUAL: /* PHY_CLK_VALID bit is de-featured from all controller * versions below 2.4 and is to be checked only for diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index cf2b7ae93b7e..6257be4110ca 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c @@ -982,7 +982,7 @@ rescan: start_unlink_async(ehci, qh); else start_unlink_intr(ehci, qh); - /* FALL THROUGH */ + fallthrough; case QH_STATE_COMPLETING: /* already in unlinking */ case QH_STATE_UNLINK: /* wait for hw to finish? */ case QH_STATE_UNLINK_WAIT: @@ -999,7 +999,7 @@ idle_timeout: qh_destroy(ehci, qh); break; } - /* fall through */ + fallthrough; default: /* caller was supposed to have unlinked any requests; * that's not our job. just leak this memory. diff --git a/drivers/usb/host/ehci-q.c b/drivers/usb/host/ehci-q.c index 8a5c9b3ebe1e..a826715ae9bd 100644 --- a/drivers/usb/host/ehci-q.c +++ b/drivers/usb/host/ehci-q.c @@ -874,7 +874,7 @@ qh_make ( switch (urb->dev->speed) { case USB_SPEED_LOW: info1 |= QH_LOW_SPEED; - /* FALL THROUGH */ + fallthrough; case USB_SPEED_FULL: /* EPS 0 means "full" */ diff --git a/drivers/usb/host/ehci-sched.c b/drivers/usb/host/ehci-sched.c index da7b00a6110b..847979f265b1 100644 --- a/drivers/usb/host/ehci-sched.c +++ b/drivers/usb/host/ehci-sched.c @@ -2475,7 +2475,7 @@ restart: ehci_dbg(ehci, "corrupt type %d frame %d shadow %p\n", type, frame, q.ptr); /* BUG(); */ - /* FALL THROUGH */ + fallthrough; case Q_TYPE_QH: case Q_TYPE_FSTN: /* End of the iTDs and siTDs */ -- cgit v1.2.3-70-g09d2 From a74005ab91856276ca5e424a239ebe73347079d8 Mon Sep 17 00:00:00 2001 From: "Gustavo A. R. Silva" Date: Tue, 7 Jul 2020 12:15:00 -0500 Subject: usb: gadget: Use fallthrough pseudo-keyword Replace the existing /* fall through */ comments and its variants with the new pseudo-keyword macro fallthrough[1]. Also, remove unnecessary fall-through markings when it is the case. [1] https://www.kernel.org/doc/html/latest/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through Signed-off-by: Gustavo A. R. Silva Link: https://lore.kernel.org/r/20200707171500.GA13620@embeddedor Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/composite.c | 16 ++++++++-------- drivers/usb/gadget/function/f_fs.c | 2 +- drivers/usb/gadget/function/f_hid.c | 2 +- drivers/usb/gadget/function/f_mass_storage.c | 2 +- drivers/usb/gadget/function/f_phonet.c | 4 ++-- drivers/usb/gadget/function/f_printer.c | 6 +++--- drivers/usb/gadget/function/f_rndis.c | 2 +- drivers/usb/gadget/function/f_tcm.c | 2 +- drivers/usb/gadget/function/u_ether.c | 4 ++-- drivers/usb/gadget/function/u_serial.c | 6 +++--- drivers/usb/gadget/legacy/inode.c | 7 +++---- drivers/usb/gadget/udc/dummy_hcd.c | 12 ++++++------ drivers/usb/gadget/udc/goku_udc.c | 9 ++++++--- drivers/usb/gadget/udc/omap_udc.c | 4 ++-- drivers/usb/gadget/udc/s3c2410_udc.c | 4 ++-- drivers/usb/gadget/udc/tegra-xudc.c | 2 +- 16 files changed, 43 insertions(+), 41 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c index 8fbf73467fef..05b176c82cc5 100644 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c @@ -72,17 +72,17 @@ function_descriptors(struct usb_function *f, descriptors = f->ssp_descriptors; if (descriptors) break; - /* FALLTHROUGH */ + fallthrough; case USB_SPEED_SUPER: descriptors = f->ss_descriptors; if (descriptors) break; - /* FALLTHROUGH */ + fallthrough; case USB_SPEED_HIGH: descriptors = f->hs_descriptors; if (descriptors) break; - /* FALLTHROUGH */ + fallthrough; default: descriptors = f->fs_descriptors; } @@ -170,20 +170,20 @@ int config_ep_by_speed_and_alt(struct usb_gadget *g, want_comp_desc = 1; break; } - /* fall through */ + fallthrough; case USB_SPEED_SUPER: if (gadget_is_superspeed(g)) { speed_desc = f->ss_descriptors; want_comp_desc = 1; break; } - /* fall through */ + fallthrough; case USB_SPEED_HIGH: if (gadget_is_dualspeed(g)) { speed_desc = f->hs_descriptors; break; } - /* fall through */ + fallthrough; default: speed_desc = f->fs_descriptors; } @@ -237,7 +237,7 @@ ep_found: case USB_ENDPOINT_XFER_ISOC: /* mult: bits 1:0 of bmAttributes */ _ep->mult = (comp_desc->bmAttributes & 0x3) + 1; - /* fall through */ + fallthrough; case USB_ENDPOINT_XFER_BULK: case USB_ENDPOINT_XFER_INT: _ep->maxburst = comp_desc->bMaxBurst + 1; @@ -1697,7 +1697,7 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl) if (!gadget_is_dualspeed(gadget) || gadget->speed >= USB_SPEED_SUPER) break; - /* FALLTHROUGH */ + fallthrough; case USB_DT_CONFIG: value = config_desc(cdev, w_value); if (value >= 0) diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c index 2d00ba072645..046f770a76da 100644 --- a/drivers/usb/gadget/function/f_fs.c +++ b/drivers/usb/gadget/function/f_fs.c @@ -2726,7 +2726,7 @@ static void __ffs_event_add(struct ffs_data *ffs, switch (type) { case FUNCTIONFS_RESUME: rem_type2 = FUNCTIONFS_SUSPEND; - /* FALL THROUGH */ + fallthrough; case FUNCTIONFS_SUSPEND: case FUNCTIONFS_SETUP: rem_type1 = type; diff --git a/drivers/usb/gadget/function/f_hid.c b/drivers/usb/gadget/function/f_hid.c index df671acdd464..1125f4715830 100644 --- a/drivers/usb/gadget/function/f_hid.c +++ b/drivers/usb/gadget/function/f_hid.c @@ -477,7 +477,7 @@ static void hidg_set_report_complete(struct usb_ep *ep, struct usb_request *req) break; default: ERROR(cdev, "Set report failed %d\n", req->status); - /* FALLTHROUGH */ + fallthrough; case -ECONNABORTED: /* hardware forced ep reset */ case -ECONNRESET: /* request dequeued */ case -ESHUTDOWN: /* disconnect from host */ diff --git a/drivers/usb/gadget/function/f_mass_storage.c b/drivers/usb/gadget/function/f_mass_storage.c index 950d2a85f098..331c951d72dc 100644 --- a/drivers/usb/gadget/function/f_mass_storage.c +++ b/drivers/usb/gadget/function/f_mass_storage.c @@ -2039,7 +2039,7 @@ static int do_scsi_command(struct fsg_common *common) case RELEASE: case RESERVE: case SEND_DIAGNOSTIC: - /* Fall through */ + fallthrough; default: unknown_cmnd: diff --git a/drivers/usb/gadget/function/f_phonet.c b/drivers/usb/gadget/function/f_phonet.c index d7f6cc51b7ec..0b468f5d55bc 100644 --- a/drivers/usb/gadget/function/f_phonet.c +++ b/drivers/usb/gadget/function/f_phonet.c @@ -212,7 +212,7 @@ static void pn_tx_complete(struct usb_ep *ep, struct usb_request *req) case -ESHUTDOWN: /* disconnected */ case -ECONNRESET: /* disabled */ dev->stats.tx_aborted_errors++; - /* fall through */ + fallthrough; default: dev->stats.tx_errors++; } @@ -360,7 +360,7 @@ static void pn_rx_complete(struct usb_ep *ep, struct usb_request *req) /* Do resubmit in these cases: */ case -EOVERFLOW: /* request buffer overflow */ dev->stats.rx_over_errors++; - /* fall through */ + fallthrough; default: dev->stats.rx_errors++; break; diff --git a/drivers/usb/gadget/function/f_printer.c b/drivers/usb/gadget/function/f_printer.c index 9c7ed2539ff7..ec15f7637e40 100644 --- a/drivers/usb/gadget/function/f_printer.c +++ b/drivers/usb/gadget/function/f_printer.c @@ -285,7 +285,7 @@ static void rx_complete(struct usb_ep *ep, struct usb_request *req) /* data overrun */ case -EOVERFLOW: - /* FALLTHROUGH */ + fallthrough; default: DBG(dev, "rx status %d\n", status); @@ -304,7 +304,7 @@ static void tx_complete(struct usb_ep *ep, struct usb_request *req) switch (req->status) { default: VDBG(dev, "tx err %d\n", req->status); - /* FALLTHROUGH */ + fallthrough; case -ECONNRESET: /* unlink */ case -ESHUTDOWN: /* disconnect etc */ break; @@ -919,7 +919,7 @@ static bool gprinter_req_match(struct usb_function *f, if (!w_value && !w_length && !(USB_DIR_IN & ctrl->bRequestType)) break; - /* fall through */ + fallthrough; default: return false; } diff --git a/drivers/usb/gadget/function/f_rndis.c b/drivers/usb/gadget/function/f_rndis.c index 0d8e4a364ca6..9534c8ab62a8 100644 --- a/drivers/usb/gadget/function/f_rndis.c +++ b/drivers/usb/gadget/function/f_rndis.c @@ -426,7 +426,7 @@ static void rndis_response_complete(struct usb_ep *ep, struct usb_request *req) DBG(cdev, "RNDIS %s response error %d, %d/%d\n", ep->name, status, req->actual, req->length); - /* FALLTHROUGH */ + fallthrough; case 0: if (ep != rndis->notify) break; diff --git a/drivers/usb/gadget/function/f_tcm.c b/drivers/usb/gadget/function/f_tcm.c index eaf556ceac32..d94b814328c8 100644 --- a/drivers/usb/gadget/function/f_tcm.c +++ b/drivers/usb/gadget/function/f_tcm.c @@ -1150,7 +1150,7 @@ static int usbg_submit_command(struct f_uas *fu, default: pr_debug_once("Unsupported prio_attr: %02x.\n", cmd_iu->prio_attr); - /* fall through */ + fallthrough; case UAS_SIMPLE_TAG: cmd->prio_attr = TCM_SIMPLE_TAG; break; diff --git a/drivers/usb/gadget/function/u_ether.c b/drivers/usb/gadget/function/u_ether.c index f01e3e21ecf2..c3cc6bd14e61 100644 --- a/drivers/usb/gadget/function/u_ether.c +++ b/drivers/usb/gadget/function/u_ether.c @@ -321,7 +321,7 @@ quiesce: /* data overrun */ case -EOVERFLOW: dev->net->stats.rx_over_errors++; - /* FALLTHROUGH */ + fallthrough; default: dev->net->stats.rx_errors++; @@ -444,7 +444,7 @@ static void tx_complete(struct usb_ep *ep, struct usb_request *req) default: dev->net->stats.tx_errors++; VDBG(dev, "tx err %d\n", req->status); - /* FALLTHROUGH */ + fallthrough; case -ECONNRESET: /* unlink */ case -ESHUTDOWN: /* disconnect etc */ dev_kfree_skb_any(skb); diff --git a/drivers/usb/gadget/function/u_serial.c b/drivers/usb/gadget/function/u_serial.c index c295defe7ecd..127ecc2b4317 100644 --- a/drivers/usb/gadget/function/u_serial.c +++ b/drivers/usb/gadget/function/u_serial.c @@ -386,7 +386,7 @@ static void gs_rx_push(struct work_struct *work) /* presumably a transient fault */ pr_warn("ttyGS%d: unexpected RX status %d\n", port->port_num, req->status); - /* FALLTHROUGH */ + fallthrough; case 0: /* normal completion */ break; @@ -472,7 +472,7 @@ static void gs_write_complete(struct usb_ep *ep, struct usb_request *req) /* presumably a transient fault */ pr_warn("%s: unexpected %s status %d\n", __func__, ep->name, req->status); - /* FALL THROUGH */ + fallthrough; case 0: /* normal completion */ gs_start_tx(port); @@ -871,7 +871,7 @@ static void gs_console_complete_out(struct usb_ep *ep, struct usb_request *req) default: pr_warn("%s: unexpected %s status %d\n", __func__, ep->name, req->status); - /* fall through */ + fallthrough; case 0: /* normal completion */ spin_lock(&cons->lock); diff --git a/drivers/usb/gadget/legacy/inode.c b/drivers/usb/gadget/legacy/inode.c index 9ee0bfe7bcda..1b430b36d0a6 100644 --- a/drivers/usb/gadget/legacy/inode.c +++ b/drivers/usb/gadget/legacy/inode.c @@ -312,7 +312,7 @@ nonblock: case STATE_EP_READY: /* not configured yet */ if (is_write) return 0; - // FALLTHRU + fallthrough; case STATE_EP_UNBOUND: /* clean disconnect */ break; // case STATE_EP_DISABLED: /* "can't happen" */ @@ -1084,7 +1084,7 @@ next_event (struct dev_data *dev, enum usb_gadgetfs_event_type type) case GADGETFS_DISCONNECT: if (dev->state == STATE_DEV_SETUP) dev->setup_abort = 1; - // FALL THROUGH + fallthrough; case GADGETFS_CONNECT: dev->ev_next = 0; break; @@ -1381,7 +1381,6 @@ gadgetfs_setup (struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl) make_qualifier (dev); break; case USB_DT_OTHER_SPEED_CONFIG: - // FALLTHROUGH case USB_DT_CONFIG: value = config_buf (dev, w_value >> 8, @@ -1718,7 +1717,7 @@ gadgetfs_suspend (struct usb_gadget *gadget) case STATE_DEV_UNCONNECTED: next_event (dev, GADGETFS_SUSPEND); ep0_readable (dev); - /* FALLTHROUGH */ + fallthrough; default: break; } diff --git a/drivers/usb/gadget/udc/dummy_hcd.c b/drivers/usb/gadget/udc/dummy_hcd.c index de65d424fb65..53a227217f1c 100644 --- a/drivers/usb/gadget/udc/dummy_hcd.c +++ b/drivers/usb/gadget/udc/dummy_hcd.c @@ -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; @@ -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 & 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/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/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/tegra-xudc.c b/drivers/usb/gadget/udc/tegra-xudc.c index bbe1a04686da..404f77806c6a 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: -- cgit v1.2.3-70-g09d2 From 25051b55a2f6f05a15ba60f81e1f529b751aab5b Mon Sep 17 00:00:00 2001 From: Wei Yongjun Date: Tue, 7 Jul 2020 18:53:50 +0800 Subject: udc: lpc32xx: make symbol 'lpc32xx_usbddata' static The sparse tool complains as follows: drivers/usb/gadget/udc/lpc32xx_udc.c:2989:25: warning: symbol 'lpc32xx_usbddata' was not declared. Should it be static? This variable is not used outside of lpc32xx_udc.c, so this commit marks it static. Reported-by: Hulk Robot Signed-off-by: Wei Yongjun Link: https://lore.kernel.org/r/20200707105350.7064-1-weiyongjun1@huawei.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/udc/lpc32xx_udc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/usb') 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, -- cgit v1.2.3-70-g09d2 From bcbb9d812eead97e1fc01b223c0c5586a4ff08d9 Mon Sep 17 00:00:00 2001 From: Johan Hovold Date: Mon, 13 Jul 2020 12:55:13 +0200 Subject: USB: serial: cp210x: disable interface on errors in open Try to disable the serial interface in the unlikely event that generic open() fails. Link: https://lore.kernel.org/r/20200713105517.27796-2-johan@kernel.org Reviewed-by: Greg Kroah-Hartman Signed-off-by: Johan Hovold --- drivers/usb/serial/cp210x.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'drivers/usb') diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c index a90801ef0055..c01c7863dd1a 100644 --- a/drivers/usb/serial/cp210x.c +++ b/drivers/usb/serial/cp210x.c @@ -824,7 +824,16 @@ static int cp210x_open(struct tty_struct *tty, struct usb_serial_port *port) if (tty) cp210x_change_speed(tty, port, NULL); - return usb_serial_generic_open(tty, port); + result = usb_serial_generic_open(tty, port); + if (result) + goto err_disable; + + return 0; + +err_disable: + cp210x_write_u16_reg(port, CP210X_IFC_ENABLE, UART_DISABLE); + + return result; } static void cp210x_close(struct usb_serial_port *port) -- cgit v1.2.3-70-g09d2 From a7207e9835a4f245c8c693170906fda0980273f3 Mon Sep 17 00:00:00 2001 From: Johan Hovold Date: Mon, 13 Jul 2020 12:55:14 +0200 Subject: USB: serial: cp210x: add support for line-status events Add support for line-status events that specifically can be used to detect and report parity errors. Enable the device's event-insertion mode whenever input-parity checking is requested. This will insert line and modem status events into the data stream. Note that modem-status changes appear to be buffered until a character is received (at least on CP2102) and support is therefore left unimplemented. On at least one type of these chips (CP2102), line breaks are not reported as expected either (regardless of whether SERIAL_BREAK_CHAR is set) so do not enable event-mode when !IGNBRK is requested for now. Link: https://lore.kernel.org/r/20200713105517.27796-3-johan@kernel.org Reviewed-by: Greg Kroah-Hartman Signed-off-by: Johan Hovold --- drivers/usb/serial/cp210x.c | 189 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 186 insertions(+), 3 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c index c01c7863dd1a..02e4acb2823b 100644 --- a/drivers/usb/serial/cp210x.c +++ b/drivers/usb/serial/cp210x.c @@ -50,6 +50,9 @@ static void cp210x_release(struct usb_serial *); static int cp210x_port_probe(struct usb_serial_port *); static int cp210x_port_remove(struct usb_serial_port *); static void cp210x_dtr_rts(struct usb_serial_port *p, int on); +static void cp210x_process_read_urb(struct urb *urb); +static void cp210x_enable_event_mode(struct usb_serial_port *port); +static void cp210x_disable_event_mode(struct usb_serial_port *port); static const struct usb_device_id id_table[] = { { USB_DEVICE(0x045B, 0x0053) }, /* Renesas RX610 RX-Stick */ @@ -253,9 +256,21 @@ struct cp210x_serial_private { bool use_actual_rate; }; +enum cp210x_event_state { + ES_DATA, + ES_ESCAPE, + ES_LSR, + ES_LSR_DATA_0, + ES_LSR_DATA_1, + ES_MSR +}; + struct cp210x_port_private { __u8 bInterfaceNumber; bool has_swapped_line_ctl; + bool event_mode; + enum cp210x_event_state event_state; + u8 lsr; }; static struct usb_serial_driver cp210x_device = { @@ -281,7 +296,8 @@ static struct usb_serial_driver cp210x_device = { .release = cp210x_release, .port_probe = cp210x_port_probe, .port_remove = cp210x_port_remove, - .dtr_rts = cp210x_dtr_rts + .dtr_rts = cp210x_dtr_rts, + .process_read_urb = cp210x_process_read_urb, }; static struct usb_serial_driver * const serial_drivers[] = { @@ -403,6 +419,15 @@ struct cp210x_comm_status { */ #define PURGE_ALL 0x000f +/* CP210X_EMBED_EVENTS */ +#define CP210X_ESCCHAR 0xec + +#define CP210X_LSR_OVERRUN BIT(1) +#define CP210X_LSR_PARITY BIT(2) +#define CP210X_LSR_FRAME BIT(3) +#define CP210X_LSR_BREAK BIT(4) + + /* CP210X_GET_FLOW/CP210X_SET_FLOW read/write these 0x10 bytes */ struct cp210x_flow_ctl { __le32 ulControlHandshake; @@ -809,6 +834,7 @@ static int cp210x_get_line_ctl(struct usb_serial_port *port, u16 *ctl) static int cp210x_open(struct tty_struct *tty, struct usb_serial_port *port) { + struct cp210x_port_private *port_priv = usb_get_serial_port_data(port); int result; result = cp210x_write_u16_reg(port, CP210X_IFC_ENABLE, UART_ENABLE); @@ -820,10 +846,14 @@ static int cp210x_open(struct tty_struct *tty, struct usb_serial_port *port) /* Configure the termios structure */ cp210x_get_termios(tty, port); - /* The baud rate must be initialised on cp2104 */ - if (tty) + if (tty) { + /* The baud rate must be initialised on cp2104 */ cp210x_change_speed(tty, port, NULL); + if (I_INPCK(tty)) + cp210x_enable_event_mode(port); + } + result = usb_serial_generic_open(tty, port); if (result) goto err_disable; @@ -832,18 +862,128 @@ static int cp210x_open(struct tty_struct *tty, struct usb_serial_port *port) err_disable: cp210x_write_u16_reg(port, CP210X_IFC_ENABLE, UART_DISABLE); + port_priv->event_mode = false; return result; } static void cp210x_close(struct usb_serial_port *port) { + struct cp210x_port_private *port_priv = usb_get_serial_port_data(port); + usb_serial_generic_close(port); /* Clear both queues; cp2108 needs this to avoid an occasional hang */ cp210x_write_u16_reg(port, CP210X_PURGE, PURGE_ALL); cp210x_write_u16_reg(port, CP210X_IFC_ENABLE, UART_DISABLE); + + /* Disabling the interface disables event-insertion mode. */ + port_priv->event_mode = false; +} + +static void cp210x_process_lsr(struct usb_serial_port *port, unsigned char lsr, char *flag) +{ + if (lsr & CP210X_LSR_BREAK) { + port->icount.brk++; + *flag = TTY_BREAK; + } else if (lsr & CP210X_LSR_PARITY) { + port->icount.parity++; + *flag = TTY_PARITY; + } else if (lsr & CP210X_LSR_FRAME) { + port->icount.frame++; + *flag = TTY_FRAME; + } + + if (lsr & CP210X_LSR_OVERRUN) { + port->icount.overrun++; + tty_insert_flip_char(&port->port, 0, TTY_OVERRUN); + } +} + +static bool cp210x_process_char(struct usb_serial_port *port, unsigned char *ch, char *flag) +{ + struct cp210x_port_private *port_priv = usb_get_serial_port_data(port); + + switch (port_priv->event_state) { + case ES_DATA: + if (*ch == CP210X_ESCCHAR) { + port_priv->event_state = ES_ESCAPE; + break; + } + return false; + case ES_ESCAPE: + switch (*ch) { + case 0: + dev_dbg(&port->dev, "%s - escape char\n", __func__); + *ch = CP210X_ESCCHAR; + port_priv->event_state = ES_DATA; + return false; + case 1: + port_priv->event_state = ES_LSR_DATA_0; + break; + case 2: + port_priv->event_state = ES_LSR; + break; + case 3: + port_priv->event_state = ES_MSR; + break; + default: + dev_err(&port->dev, "malformed event 0x%02x\n", *ch); + port_priv->event_state = ES_DATA; + break; + } + break; + case ES_LSR_DATA_0: + port_priv->lsr = *ch; + port_priv->event_state = ES_LSR_DATA_1; + break; + case ES_LSR_DATA_1: + dev_dbg(&port->dev, "%s - lsr = 0x%02x, data = 0x%02x\n", + __func__, port_priv->lsr, *ch); + cp210x_process_lsr(port, port_priv->lsr, flag); + port_priv->event_state = ES_DATA; + return false; + case ES_LSR: + dev_dbg(&port->dev, "%s - lsr = 0x%02x\n", __func__, *ch); + port_priv->lsr = *ch; + cp210x_process_lsr(port, port_priv->lsr, flag); + port_priv->event_state = ES_DATA; + break; + case ES_MSR: + dev_dbg(&port->dev, "%s - msr = 0x%02x\n", __func__, *ch); + /* unimplemented */ + port_priv->event_state = ES_DATA; + break; + } + + return true; +} + +static void cp210x_process_read_urb(struct urb *urb) +{ + struct usb_serial_port *port = urb->context; + struct cp210x_port_private *port_priv = usb_get_serial_port_data(port); + unsigned char *ch = urb->transfer_buffer; + char flag; + int i; + + if (!urb->actual_length) + return; + + if (port_priv->event_mode) { + for (i = 0; i < urb->actual_length; i++, ch++) { + flag = TTY_NORMAL; + + if (cp210x_process_char(port, ch, &flag)) + continue; + + tty_insert_flip_char(&port->port, *ch, flag); + } + } else { + tty_insert_flip_string(&port->port, ch, urb->actual_length); + } + tty_flip_buffer_push(&port->port); } /* @@ -1176,6 +1316,41 @@ static void cp210x_change_speed(struct tty_struct *tty, tty_encode_baud_rate(tty, baud, baud); } +static void cp210x_enable_event_mode(struct usb_serial_port *port) +{ + struct cp210x_port_private *port_priv = usb_get_serial_port_data(port); + int ret; + + if (port_priv->event_mode) + return; + + port_priv->event_state = ES_DATA; + port_priv->event_mode = true; + + ret = cp210x_write_u16_reg(port, CP210X_EMBED_EVENTS, CP210X_ESCCHAR); + if (ret) { + dev_err(&port->dev, "failed to enable events: %d\n", ret); + port_priv->event_mode = false; + } +} + +static void cp210x_disable_event_mode(struct usb_serial_port *port) +{ + struct cp210x_port_private *port_priv = usb_get_serial_port_data(port); + int ret; + + if (!port_priv->event_mode) + return; + + ret = cp210x_write_u16_reg(port, CP210X_EMBED_EVENTS, 0); + if (ret) { + dev_err(&port->dev, "failed to disable events: %d\n", ret); + return; + } + + port_priv->event_mode = false; +} + static void cp210x_set_termios(struct tty_struct *tty, struct usb_serial_port *port, struct ktermios *old_termios) { @@ -1298,6 +1473,14 @@ static void cp210x_set_termios(struct tty_struct *tty, sizeof(flow_ctl)); } + /* + * Enable event-insertion mode only if input parity checking is + * enabled for now. + */ + if (I_INPCK(tty)) + cp210x_enable_event_mode(port); + else + cp210x_disable_event_mode(port); } static int cp210x_tiocmset(struct tty_struct *tty, -- cgit v1.2.3-70-g09d2 From de9c7e9f278492cee9f217ffc339a398536c7e51 Mon Sep 17 00:00:00 2001 From: Johan Hovold Date: Mon, 13 Jul 2020 12:55:15 +0200 Subject: USB: serial: cp210x: add support for TIOCGICOUNT Enable TIOCGICOUNT to allow reading out the (unused) interrupt counters and error statistics. Note that modem-status events are currently left unimplemented as they appear to be buffered on at least CP2102 and therefore cannot be used to implement TIOCMIWAIT. Link: https://lore.kernel.org/r/20200713105517.27796-4-johan@kernel.org Reviewed-by: Greg Kroah-Hartman Signed-off-by: Johan Hovold --- drivers/usb/serial/cp210x.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/usb') diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c index 02e4acb2823b..3a65be4a0ec0 100644 --- a/drivers/usb/serial/cp210x.c +++ b/drivers/usb/serial/cp210x.c @@ -291,6 +291,7 @@ static struct usb_serial_driver cp210x_device = { .unthrottle = usb_serial_generic_unthrottle, .tiocmget = cp210x_tiocmget, .tiocmset = cp210x_tiocmset, + .get_icount = usb_serial_generic_get_icount, .attach = cp210x_attach, .disconnect = cp210x_disconnect, .release = cp210x_release, -- cgit v1.2.3-70-g09d2 From ba84190eab5ba27c171b610ec1d8e0957638d8ec Mon Sep 17 00:00:00 2001 From: Johan Hovold Date: Mon, 13 Jul 2020 12:55:16 +0200 Subject: USB: serial: cp210x: drop unnecessary packed attributes Drop unnecessary packed attributes from structs without padding. Link: https://lore.kernel.org/r/20200713105517.27796-5-johan@kernel.org Reviewed-by: Greg Kroah-Hartman Signed-off-by: Johan Hovold --- drivers/usb/serial/cp210x.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c index 3a65be4a0ec0..09445b7a8f64 100644 --- a/drivers/usb/serial/cp210x.c +++ b/drivers/usb/serial/cp210x.c @@ -435,7 +435,7 @@ struct cp210x_flow_ctl { __le32 ulFlowReplace; __le32 ulXonLimit; __le32 ulXoffLimit; -} __packed; +}; /* cp210x_flow_ctl::ulControlHandshake */ #define CP210X_SERIAL_DTR_MASK GENMASK(1, 0) @@ -469,7 +469,7 @@ struct cp210x_flow_ctl { struct cp210x_pin_mode { u8 eci; u8 sci; -} __packed; +}; #define CP210X_PIN_MODE_MODEM 0 #define CP210X_PIN_MODE_GPIO BIT(0) @@ -532,7 +532,7 @@ struct cp210x_single_port_config { struct cp210x_gpio_write { u8 mask; u8 state; -} __packed; +}; /* * Helper to get interface number when we only have struct usb_serial. -- cgit v1.2.3-70-g09d2 From 16045babc7985cef48b355540d11bd942220931d Mon Sep 17 00:00:00 2001 From: Johan Hovold Date: Mon, 13 Jul 2020 12:55:17 +0200 Subject: USB: serial: cp210x: use in-kernel types in port data The port data is not exported to user space so use the in-kernel u8 type. Link: https://lore.kernel.org/r/20200713105517.27796-6-johan@kernel.org Reviewed-by: Greg Kroah-Hartman Signed-off-by: Johan Hovold --- drivers/usb/serial/cp210x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/usb') diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c index 09445b7a8f64..d0c05aa8a0d6 100644 --- a/drivers/usb/serial/cp210x.c +++ b/drivers/usb/serial/cp210x.c @@ -266,7 +266,7 @@ enum cp210x_event_state { }; struct cp210x_port_private { - __u8 bInterfaceNumber; + u8 bInterfaceNumber; bool has_swapped_line_ctl; bool event_mode; enum cp210x_event_state event_state; -- cgit v1.2.3-70-g09d2 From e0439cd97573f1c7c6bf98e7a6d63de34daeaf8a Mon Sep 17 00:00:00 2001 From: Johan Hovold Date: Mon, 13 Jul 2020 17:39:36 +0200 Subject: USB: serial: sierra: clean up special-interface handling Clean up the handling of special interfaces that either should be ignored or that need a larger number of URBs. Commit 66f092ed3b94 ("USB: serial: sierra: unify quirk handling logic") replaced the previous is_blacklisted() and is_highmemory() helpers with a single is_quirk() helper which made it even harder to understand what the interface lists were used for. Rename the interface-list struct, its members and the interface-lookup helper and restructure the code somewhat in order to make it more self-explanatory. Link: https://lore.kernel.org/r/20200713153936.18032-1-johan@kernel.org Reviewed-by: Greg Kroah-Hartman Signed-off-by: Johan Hovold --- drivers/usb/serial/sierra.c | 58 ++++++++++++++++++++++----------------------- 1 file changed, 29 insertions(+), 29 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/serial/sierra.c b/drivers/usb/serial/sierra.c index a862aa788a19..57fc3c31712e 100644 --- a/drivers/usb/serial/sierra.c +++ b/drivers/usb/serial/sierra.c @@ -45,10 +45,9 @@ static bool nmea; -/* Used in interface quirks */ -struct sierra_iface_quirk { - const u32 infolen; /* number of interface numbers on the list */ - const u8 *ifaceinfo; /* pointer to the array holding the numbers */ +struct sierra_iface_list { + const u8 *nums; /* array of interface numbers */ + size_t count; /* number of elements in array */ }; struct sierra_intf_private { @@ -101,20 +100,19 @@ static int sierra_calc_num_ports(struct usb_serial *serial, return num_ports; } -static int is_quirk(const u8 ifnum, const struct sierra_iface_quirk *quirk) +static bool is_listed(const u8 ifnum, const struct sierra_iface_list *list) { - const u8 *info; int i; - if (quirk) { - info = quirk->ifaceinfo; + if (!list) + return false; - for (i = 0; i < quirk->infolen; i++) { - if (info[i] == ifnum) - return 1; - } + for (i = 0; i < list->count; i++) { + if (list->nums[i] == ifnum) + return true; } - return 0; + + return false; } static u8 sierra_interface_num(struct usb_serial *serial) @@ -125,6 +123,7 @@ static u8 sierra_interface_num(struct usb_serial *serial) static int sierra_probe(struct usb_serial *serial, const struct usb_device_id *id) { + const struct sierra_iface_list *ignore_list; int result = 0; struct usb_device *udev; u8 ifnum; @@ -143,9 +142,10 @@ static int sierra_probe(struct usb_serial *serial, usb_set_interface(udev, ifnum, 1); } - if (is_quirk(ifnum, (struct sierra_iface_quirk *)id->driver_info)) { - dev_dbg(&serial->dev->dev, - "Ignoring interface #%d\n", ifnum); + ignore_list = (const struct sierra_iface_list *)id->driver_info; + + if (is_listed(ifnum, ignore_list)) { + dev_dbg(&serial->dev->dev, "Ignoring interface #%d\n", ifnum); return -ENODEV; } @@ -154,22 +154,22 @@ static int sierra_probe(struct usb_serial *serial, /* interfaces with higher memory requirements */ static const u8 hi_memory_typeA_ifaces[] = { 0, 2 }; -static const struct sierra_iface_quirk typeA_interface_list = { - .infolen = ARRAY_SIZE(hi_memory_typeA_ifaces), - .ifaceinfo = hi_memory_typeA_ifaces, +static const struct sierra_iface_list typeA_interface_list = { + .nums = hi_memory_typeA_ifaces, + .count = ARRAY_SIZE(hi_memory_typeA_ifaces), }; static const u8 hi_memory_typeB_ifaces[] = { 3, 4, 5, 6 }; -static const struct sierra_iface_quirk typeB_interface_list = { - .infolen = ARRAY_SIZE(hi_memory_typeB_ifaces), - .ifaceinfo = hi_memory_typeB_ifaces, +static const struct sierra_iface_list typeB_interface_list = { + .nums = hi_memory_typeB_ifaces, + .count = ARRAY_SIZE(hi_memory_typeB_ifaces), }; /* 'ignorelist' of interfaces not served by this driver */ static const u8 direct_ip_non_serial_ifaces[] = { 7, 8, 9, 10, 11, 19, 20 }; -static const struct sierra_iface_quirk direct_ip_interface_ignore = { - .infolen = ARRAY_SIZE(direct_ip_non_serial_ifaces), - .ifaceinfo = direct_ip_non_serial_ifaces, +static const struct sierra_iface_list direct_ip_interface_ignore = { + .nums = direct_ip_non_serial_ifaces, + .count = ARRAY_SIZE(direct_ip_non_serial_ifaces), }; static const struct usb_device_id id_table[] = { @@ -859,7 +859,7 @@ static int sierra_port_probe(struct usb_serial_port *port) { struct usb_serial *serial = port->serial; struct sierra_port_private *portdata; - const struct sierra_iface_quirk *himemoryp; + const struct sierra_iface_list *himemory_list; u8 ifnum; portdata = kzalloc(sizeof(*portdata), GFP_KERNEL); @@ -878,16 +878,16 @@ static int sierra_port_probe(struct usb_serial_port *port) if (serial->num_ports == 1) { /* Get interface number for composite device */ ifnum = sierra_interface_num(serial); - himemoryp = &typeB_interface_list; + himemory_list = &typeB_interface_list; } else { /* This is really the usb-serial port number of the interface * rather than the interface number. */ ifnum = port->port_number; - himemoryp = &typeA_interface_list; + himemory_list = &typeA_interface_list; } - if (is_quirk(ifnum, himemoryp)) { + if (is_listed(ifnum, himemory_list)) { portdata->num_out_urbs = N_OUT_URB_HM; portdata->num_in_urbs = N_IN_URB_HM; } -- cgit v1.2.3-70-g09d2 From 681aa3cf063c4338da9eab1496f5d2b718fac41d Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Mon, 13 Jul 2020 11:23:14 +0200 Subject: USB: ohci: Replace HTTP links with HTTPS ones Rationale: Reduces attack surface on kernel devs opening the links for MITM as HTTPS traffic is much harder to manipulate. Deterministic algorithm: For each file: If not .svg: For each line: If doesn't contain `\bxmlns\b`: For each link, `\bhttp://[^# \t\r\n]*(?:\w|/)`: If neither `\bgnu\.org/license`, nor `\bmozilla\.org/MPL\b`: If both the HTTP and HTTPS versions return 200 OK and serve the same content: Replace HTTP with HTTPS. Signed-off-by: Alexander A. Klimov Link: https://lore.kernel.org/r/20200713092314.32774-1-grandmaster@al2klimov.de Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/ohci-hcd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/usb') diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c index 9b4121927d4a..dd37e77dae00 100644 --- a/drivers/usb/host/ohci-hcd.c +++ b/drivers/usb/host/ohci-hcd.c @@ -16,7 +16,7 @@ * OHCI is the main "non-Intel/VIA" standard for USB 1.1 host controller * interfaces (though some non-x86 Intel chips use it). It supports * smarter hardware than UHCI. A download link for the spec available - * through the http://www.usb.org website. + * through the https://www.usb.org website. * * This file is licenced under the GPL. */ -- cgit v1.2.3-70-g09d2 From 952dd40e05ed170865a55bf52f152ce693cacac0 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Sat, 11 Jul 2020 15:58:25 +0200 Subject: usb: typec: Replace HTTP links with HTTPS ones Rationale: Reduces attack surface on kernel devs opening the links for MITM as HTTPS traffic is much harder to manipulate. Deterministic algorithm: For each file: If not .svg: For each line: If doesn't contain `\bxmlns\b`: For each link, `\bhttp://[^# \t\r\n]*(?:\w|/)`: If neither `\bgnu\.org/license`, nor `\bmozilla\.org/MPL\b`: If both the HTTP and HTTPS versions return 200 OK and serve the same content: Replace HTTP with HTTPS. Signed-off-by: Alexander A. Klimov Link: https://lore.kernel.org/r/20200711135825.19862-1-grandmaster@al2klimov.de Signed-off-by: Greg Kroah-Hartman --- drivers/usb/typec/tps6598x.c | 2 +- drivers/usb/typec/ucsi/Kconfig | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/typec/tps6598x.c b/drivers/usb/typec/tps6598x.c index b7c9fe5caabe..3db33bb622c3 100644 --- a/drivers/usb/typec/tps6598x.c +++ b/drivers/usb/typec/tps6598x.c @@ -100,7 +100,7 @@ struct tps6598x { /* * Max data bytes for Data1, Data2, and other registers. See ch 1.3.2: - * http://www.ti.com/lit/ug/slvuan1a/slvuan1a.pdf + * https://www.ti.com/lit/ug/slvuan1a/slvuan1a.pdf */ #define TPS_MAX_LEN 64 diff --git a/drivers/usb/typec/ucsi/Kconfig b/drivers/usb/typec/ucsi/Kconfig index 15c2ac7db02d..2192d7c4fec7 100644 --- a/drivers/usb/typec/ucsi/Kconfig +++ b/drivers/usb/typec/ucsi/Kconfig @@ -18,7 +18,7 @@ config TYPEC_UCSI for every supported interface method. The UCSI specification can be downloaded from: - http://www.intel.com/content/www/us/en/io/universal-serial-bus/usb-type-c-ucsi-spec.html + https://www.intel.com/content/www/us/en/io/universal-serial-bus/usb-type-c-ucsi-spec.html To compile the driver as a module, choose M here: the module will be called typec_ucsi. -- cgit v1.2.3-70-g09d2 From d6c3c6c09f5abb60a9f3c2d8f56abb529c967f35 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Sat, 11 Jul 2020 15:58:13 +0200 Subject: usb: host: xhci-plat: Replace HTTP links with HTTPS ones Rationale: Reduces attack surface on kernel devs opening the links for MITM as HTTPS traffic is much harder to manipulate. Deterministic algorithm: For each file: If not .svg: For each line: If doesn't contain `\bxmlns\b`: For each link, `\bhttp://[^# \t\r\n]*(?:\w|/)`: If neither `\bgnu\.org/license`, nor `\bmozilla\.org/MPL\b`: If both the HTTP and HTTPS versions return 200 OK and serve the same content: Replace HTTP with HTTPS. Signed-off-by: Alexander A. Klimov Link: https://lore.kernel.org/r/20200711135813.19798-1-grandmaster@al2klimov.de Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/xhci-plat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/usb') diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c index 3e15b70a6fc9..3057cfc76d6a 100644 --- a/drivers/usb/host/xhci-plat.c +++ b/drivers/usb/host/xhci-plat.c @@ -2,7 +2,7 @@ /* * xhci-plat.c - xHCI host controller driver platform Bus Glue. * - * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com + * Copyright (C) 2012 Texas Instruments Incorporated - https://www.ti.com * Author: Sebastian Andrzej Siewior * * A lot of code borrowed from the Linux xHCI driver. -- cgit v1.2.3-70-g09d2 From 10623b879da3932be313ba142d56b9f3d1216e96 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Sat, 11 Jul 2020 15:58:04 +0200 Subject: usb: dwc3: Replace HTTP links with HTTPS ones Rationale: Reduces attack surface on kernel devs opening the links for MITM as HTTPS traffic is much harder to manipulate. Deterministic algorithm: For each file: If not .svg: For each line: If doesn't contain `\bxmlns\b`: For each link, `\bhttp://[^# \t\r\n]*(?:\w|/)`: If neither `\bgnu\.org/license`, nor `\bmozilla\.org/MPL\b`: If both the HTTP and HTTPS versions return 200 OK and serve the same content: Replace HTTP with HTTPS. Signed-off-by: Alexander A. Klimov Link: https://lore.kernel.org/r/20200711135804.19735-1-grandmaster@al2klimov.de Signed-off-by: Greg Kroah-Hartman --- drivers/usb/dwc3/core.c | 2 +- drivers/usb/dwc3/core.h | 2 +- drivers/usb/dwc3/debug.h | 2 +- drivers/usb/dwc3/debugfs.c | 2 +- drivers/usb/dwc3/drd.c | 2 +- drivers/usb/dwc3/dwc3-keystone.c | 2 +- drivers/usb/dwc3/dwc3-of-simple.c | 2 +- drivers/usb/dwc3/dwc3-omap.c | 2 +- drivers/usb/dwc3/dwc3-pci.c | 2 +- drivers/usb/dwc3/ep0.c | 2 +- drivers/usb/dwc3/gadget.c | 2 +- drivers/usb/dwc3/gadget.h | 2 +- drivers/usb/dwc3/host.c | 2 +- drivers/usb/dwc3/io.h | 2 +- drivers/usb/dwc3/trace.c | 2 +- drivers/usb/dwc3/trace.h | 2 +- 16 files changed, 16 insertions(+), 16 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 25c686a752b0..422aea24afcd 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -2,7 +2,7 @@ /** * core.c - DesignWare USB3 DRD Controller Core file * - * Copyright (C) 2010-2011 Texas Instruments Incorporated - http://www.ti.com + * Copyright (C) 2010-2011 Texas Instruments Incorporated - https://www.ti.com * * Authors: Felipe Balbi , * Sebastian Andrzej Siewior diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h index 013f42a2b5dc..2f04b3e42bf1 100644 --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h @@ -2,7 +2,7 @@ /* * core.h - DesignWare USB3 DRD Core Header * - * Copyright (C) 2010-2011 Texas Instruments Incorporated - http://www.ti.com + * Copyright (C) 2010-2011 Texas Instruments Incorporated - https://www.ti.com * * Authors: Felipe Balbi , * Sebastian Andrzej Siewior diff --git a/drivers/usb/dwc3/debug.h b/drivers/usb/dwc3/debug.h index d8f600e0e88f..3d16dac4e5cc 100644 --- a/drivers/usb/dwc3/debug.h +++ b/drivers/usb/dwc3/debug.h @@ -2,7 +2,7 @@ /** * debug.h - DesignWare USB3 DRD Controller Debug Header * - * Copyright (C) 2010-2011 Texas Instruments Incorporated - http://www.ti.com + * Copyright (C) 2010-2011 Texas Instruments Incorporated - https://www.ti.com * * Authors: Felipe Balbi , * Sebastian Andrzej Siewior diff --git a/drivers/usb/dwc3/debugfs.c b/drivers/usb/dwc3/debugfs.c index 14dc6a37305d..2c7b6dd79cdf 100644 --- a/drivers/usb/dwc3/debugfs.c +++ b/drivers/usb/dwc3/debugfs.c @@ -2,7 +2,7 @@ /** * debugfs.c - DesignWare USB3 DRD Controller DebugFS file * - * Copyright (C) 2010-2011 Texas Instruments Incorporated - http://www.ti.com + * Copyright (C) 2010-2011 Texas Instruments Incorporated - https://www.ti.com * * Authors: Felipe Balbi , * Sebastian Andrzej Siewior diff --git a/drivers/usb/dwc3/drd.c b/drivers/usb/dwc3/drd.c index fd7f9a9f67dc..3e1c1aacf002 100644 --- a/drivers/usb/dwc3/drd.c +++ b/drivers/usb/dwc3/drd.c @@ -2,7 +2,7 @@ /* * drd.c - DesignWare USB3 DRD Controller Dual-role support * - * Copyright (C) 2017 Texas Instruments Incorporated - http://www.ti.com + * Copyright (C) 2017 Texas Instruments Incorporated - https://www.ti.com * * Authors: Roger Quadros */ diff --git a/drivers/usb/dwc3/dwc3-keystone.c b/drivers/usb/dwc3/dwc3-keystone.c index 6505f7bd69e2..9a99253d5ba3 100644 --- a/drivers/usb/dwc3/dwc3-keystone.c +++ b/drivers/usb/dwc3/dwc3-keystone.c @@ -2,7 +2,7 @@ /** * dwc3-keystone.c - Keystone Specific Glue layer * - * Copyright (C) 2010-2013 Texas Instruments Incorporated - http://www.ti.com + * Copyright (C) 2010-2013 Texas Instruments Incorporated - https://www.ti.com * * Author: WingMan Kwok */ diff --git a/drivers/usb/dwc3/dwc3-of-simple.c b/drivers/usb/dwc3/dwc3-of-simple.c index 34c828c22197..7df115012935 100644 --- a/drivers/usb/dwc3/dwc3-of-simple.c +++ b/drivers/usb/dwc3/dwc3-of-simple.c @@ -2,7 +2,7 @@ /* * dwc3-of-simple.c - OF glue layer for simple integrations * - * Copyright (c) 2015 Texas Instruments Incorporated - http://www.ti.com + * Copyright (c) 2015 Texas Instruments Incorporated - https://www.ti.com * * Author: Felipe Balbi * diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c index 11288a370828..3db17806e92e 100644 --- a/drivers/usb/dwc3/dwc3-omap.c +++ b/drivers/usb/dwc3/dwc3-omap.c @@ -2,7 +2,7 @@ /* * dwc3-omap.c - OMAP Specific Glue layer * - * Copyright (C) 2010-2011 Texas Instruments Incorporated - http://www.ti.com + * Copyright (C) 2010-2011 Texas Instruments Incorporated - https://www.ti.com * * Authors: Felipe Balbi , * Sebastian Andrzej Siewior diff --git a/drivers/usb/dwc3/dwc3-pci.c b/drivers/usb/dwc3/dwc3-pci.c index 96c05b121fac..519302b34154 100644 --- a/drivers/usb/dwc3/dwc3-pci.c +++ b/drivers/usb/dwc3/dwc3-pci.c @@ -2,7 +2,7 @@ /** * dwc3-pci.c - PCI Specific glue layer * - * Copyright (C) 2010-2011 Texas Instruments Incorporated - http://www.ti.com + * Copyright (C) 2010-2011 Texas Instruments Incorporated - https://www.ti.com * * Authors: Felipe Balbi , * Sebastian Andrzej Siewior diff --git a/drivers/usb/dwc3/ep0.c b/drivers/usb/dwc3/ep0.c index 8dd69728add3..59f2e8c31bd1 100644 --- a/drivers/usb/dwc3/ep0.c +++ b/drivers/usb/dwc3/ep0.c @@ -2,7 +2,7 @@ /* * ep0.c - DesignWare USB3 DRD Controller Endpoint 0 Handling * - * Copyright (C) 2010-2011 Texas Instruments Incorporated - http://www.ti.com + * Copyright (C) 2010-2011 Texas Instruments Incorporated - https://www.ti.com * * Authors: Felipe Balbi , * Sebastian Andrzej Siewior diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index 0b59b2f1cf26..3ab6f118c508 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -2,7 +2,7 @@ /* * gadget.c - DesignWare USB3 DRD Controller Gadget Framework Link * - * Copyright (C) 2010-2011 Texas Instruments Incorporated - http://www.ti.com + * Copyright (C) 2010-2011 Texas Instruments Incorporated - https://www.ti.com * * Authors: Felipe Balbi , * Sebastian Andrzej Siewior diff --git a/drivers/usb/dwc3/gadget.h b/drivers/usb/dwc3/gadget.h index 24dca3872022..42907dd89212 100644 --- a/drivers/usb/dwc3/gadget.h +++ b/drivers/usb/dwc3/gadget.h @@ -2,7 +2,7 @@ /* * gadget.h - DesignWare USB3 DRD Gadget Header * - * Copyright (C) 2010-2011 Texas Instruments Incorporated - http://www.ti.com + * Copyright (C) 2010-2011 Texas Instruments Incorporated - https://www.ti.com * * Authors: Felipe Balbi , * Sebastian Andrzej Siewior diff --git a/drivers/usb/dwc3/host.c b/drivers/usb/dwc3/host.c index bef1c1ac2067..e195176580de 100644 --- a/drivers/usb/dwc3/host.c +++ b/drivers/usb/dwc3/host.c @@ -2,7 +2,7 @@ /* * host.c - DesignWare USB3 DRD Controller Host Glue * - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com + * Copyright (C) 2011 Texas Instruments Incorporated - https://www.ti.com * * Authors: Felipe Balbi , */ diff --git a/drivers/usb/dwc3/io.h b/drivers/usb/dwc3/io.h index 9bbe5d4bf076..76b73b116862 100644 --- a/drivers/usb/dwc3/io.h +++ b/drivers/usb/dwc3/io.h @@ -2,7 +2,7 @@ /** * io.h - DesignWare USB3 DRD IO Header * - * Copyright (C) 2010-2011 Texas Instruments Incorporated - http://www.ti.com + * Copyright (C) 2010-2011 Texas Instruments Incorporated - https://www.ti.com * * Authors: Felipe Balbi , * Sebastian Andrzej Siewior diff --git a/drivers/usb/dwc3/trace.c b/drivers/usb/dwc3/trace.c index f8886f3f3c9e..1b45a9723eeb 100644 --- a/drivers/usb/dwc3/trace.c +++ b/drivers/usb/dwc3/trace.c @@ -2,7 +2,7 @@ /** * trace.c - DesignWare USB3 DRD Controller Trace Support * - * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com + * Copyright (C) 2014 Texas Instruments Incorporated - https://www.ti.com * * Author: Felipe Balbi */ diff --git a/drivers/usb/dwc3/trace.h b/drivers/usb/dwc3/trace.h index 4c4fc6c41d9b..da1be01637c8 100644 --- a/drivers/usb/dwc3/trace.h +++ b/drivers/usb/dwc3/trace.h @@ -2,7 +2,7 @@ /** * trace.h - DesignWare USB3 DRD Controller Trace Support * - * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com + * Copyright (C) 2014 Texas Instruments Incorporated - https://www.ti.com * * Author: Felipe Balbi */ -- cgit v1.2.3-70-g09d2 From 36774c5ac8a2f4a2340af3d793c9e322b4f68abf Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Fri, 10 Jul 2020 21:18:42 +0200 Subject: usb: phy: Replace HTTP links with HTTPS ones Rationale: Reduces attack surface on kernel devs opening the links for MITM as HTTPS traffic is much harder to manipulate. Deterministic algorithm: For each file: If not .svg: For each line: If doesn't contain `\bxmlns\b`: For each link, `\bhttp://[^# \t\r\n]*(?:\w|/)`: If neither `\bgnu\.org/license`, nor `\bmozilla\.org/MPL\b`: If both the HTTP and HTTPS versions return 200 OK and serve the same content: Replace HTTP with HTTPS. Signed-off-by: Alexander A. Klimov Link: https://lore.kernel.org/r/20200710191842.32561-1-grandmaster@al2klimov.de Signed-off-by: Greg Kroah-Hartman --- drivers/usb/phy/phy-keystone.c | 2 +- drivers/usb/phy/phy-twl6030-usb.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/phy/phy-keystone.c b/drivers/usb/phy/phy-keystone.c index 9c226b57153b..358d05cb643d 100644 --- a/drivers/usb/phy/phy-keystone.c +++ b/drivers/usb/phy/phy-keystone.c @@ -2,7 +2,7 @@ /* * phy-keystone - USB PHY, talking to dwc3 controller in Keystone. * - * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com + * Copyright (C) 2013 Texas Instruments Incorporated - https://www.ti.com * * Author: WingMan Kwok */ diff --git a/drivers/usb/phy/phy-twl6030-usb.c b/drivers/usb/phy/phy-twl6030-usb.c index 9a7e655d5280..8ba6c5a91557 100644 --- a/drivers/usb/phy/phy-twl6030-usb.c +++ b/drivers/usb/phy/phy-twl6030-usb.c @@ -2,7 +2,7 @@ /* * twl6030_usb - TWL6030 USB transceiver, talking to OMAP OTG driver. * - * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com + * Copyright (C) 2010 Texas Instruments Incorporated - https://www.ti.com * * Author: Hema HK */ -- cgit v1.2.3-70-g09d2 From 10fadd5e811715d68a3c73b31e009f120a5b7d27 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Fri, 10 Jul 2020 21:09:19 +0200 Subject: usb: gadget: Replace HTTP links with HTTPS ones Rationale: Reduces attack surface on kernel devs opening the links for MITM as HTTPS traffic is much harder to manipulate. Deterministic algorithm: For each file: If not .svg: For each line: If doesn't contain `\bxmlns\b`: For each link, `\bhttp://[^# \t\r\n]*(?:\w|/)`: If neither `\bgnu\.org/license`, nor `\bmozilla\.org/MPL\b`: If both the HTTP and HTTPS versions return 200 OK and serve the same content: Replace HTTP with HTTPS. Signed-off-by: Alexander A. Klimov Link: https://lore.kernel.org/r/20200710190919.31464-1-grandmaster@al2klimov.de Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/udc/amd5536udc.h | 2 +- drivers/usb/gadget/udc/amd5536udc_pci.c | 2 +- drivers/usb/gadget/udc/gr_udc.c | 2 +- drivers/usb/gadget/udc/gr_udc.h | 2 +- drivers/usb/gadget/udc/max3420_udc.c | 2 +- drivers/usb/gadget/udc/snps_udc_core.c | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) (limited to 'drivers/usb') 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 56258d076abc..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 */ diff --git a/drivers/usb/gadget/udc/gr_udc.c b/drivers/usb/gadget/udc/gr_udc.c index 345e28d76709..8c84a559a868 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 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 diff --git a/drivers/usb/gadget/udc/max3420_udc.c b/drivers/usb/gadget/udc/max3420_udc.c index 52884bae4af1..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 diff --git a/drivers/usb/gadget/udc/snps_udc_core.c b/drivers/usb/gadget/udc/snps_udc_core.c index 3fcded31405a..1102077facdc 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 */ -- cgit v1.2.3-70-g09d2 From 48025b4f3fa4a599921c1dc231983f41f9eecbc5 Mon Sep 17 00:00:00 2001 From: Suraj Upadhyay Date: Tue, 14 Jul 2020 17:22:49 +0530 Subject: USB: Remove pci-dma-compat wrapper APIs. The legacy API wrappers in include/linux/pci-dma-compat.h should go away as it creates unnecessary midlayering for include/linux/dma-mapping.h APIs, instead use dma-mapping.h APIs directly. The patch has been generated with the coccinelle script below and compile-tested. @@@@ - PCI_DMA_BIDIRECTIONAL + DMA_BIDIRECTIONAL @@@@ - PCI_DMA_TODEVICE + DMA_TO_DEVICE @@@@ - PCI_DMA_FROMDEVICE + DMA_FROM_DEVICE @@@@ - PCI_DMA_NONE + DMA_NONE @@ expression E1, E2, E3; @@ - pci_alloc_consistent(E1, E2, E3) + dma_alloc_coherent(&E1->dev, E2, E3, GFP_) @@ expression E1, E2, E3; @@ - pci_zalloc_consistent(E1, E2, E3) + dma_alloc_coherent(&E1->dev, E2, E3, GFP_) @@ expression E1, E2, E3, E4; @@ - pci_free_consistent(E1, E2, E3, E4) + dma_free_coherent(&E1->dev, E2, E3, E4) @@ expression E1, E2, E3, E4; @@ - pci_map_single(E1, E2, E3, E4) + dma_map_single(&E1->dev, E2, E3, E4) @@ expression E1, E2, E3, E4; @@ - pci_unmap_single(E1, E2, E3, E4) + dma_unmap_single(&E1->dev, E2, E3, E4) @@ expression E1, E2, E3, E4, E5; @@ - pci_map_page(E1, E2, E3, E4, E5) + dma_map_page(&E1->dev, E2, E3, E4, E5) @@ expression E1, E2, E3, E4; @@ - pci_unmap_page(E1, E2, E3, E4) + dma_unmap_page(&E1->dev, E2, E3, E4) @@ expression E1, E2, E3, E4; @@ - pci_map_sg(E1, E2, E3, E4) + dma_map_sg(&E1->dev, E2, E3, E4) @@ expression E1, E2, E3, E4; @@ - pci_unmap_sg(E1, E2, E3, E4) + dma_unmap_sg(&E1->dev, E2, E3, E4) @@ expression E1, E2, E3, E4; @@ - pci_dma_sync_single_for_cpu(E1, E2, E3, E4) + dma_sync_single_for_cpu(&E1->dev, E2, E3, E4) @@ expression E1, E2, E3, E4; @@ - pci_dma_sync_single_for_device(E1, E2, E3, E4) + dma_sync_single_for_device(&E1->dev, E2, E3, E4) @@ expression E1, E2, E3, E4; @@ - pci_dma_sync_sg_for_cpu(E1, E2, E3, E4) + dma_sync_sg_for_cpu(&E1->dev, E2, E3, E4) @@ expression E1, E2, E3, E4; @@ - pci_dma_sync_sg_for_device(E1, E2, E3, E4) + dma_sync_sg_for_device(&E1->dev, E2, E3, E4) @@ expression E1, E2; @@ - pci_dma_mapping_error(E1, E2) + dma_mapping_error(&E1->dev, E2) @@ expression E1, E2; @@ - pci_set_consistent_dma_mask(E1, E2) + dma_set_coherent_mask(&E1->dev, E2) @@ expression E1, E2; @@ - pci_set_dma_mask(E1, E2) + dma_set_mask(&E1->dev, E2) Signed-off-by: Suraj Upadhyay Link: https://lore.kernel.org/r/20200714115249.GA8563@blackclown Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/ehci-pci.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c index af3c1b9b38b2..71ec3025686f 100644 --- a/drivers/usb/host/ehci-pci.c +++ b/drivers/usb/host/ehci-pci.c @@ -124,8 +124,7 @@ static int ehci_pci_setup(struct usb_hcd *hcd) case 0x005b: /* CK804 */ case 0x00d8: /* CK8 */ case 0x00e8: /* CK8S */ - if (pci_set_consistent_dma_mask(pdev, - DMA_BIT_MASK(31)) < 0) + if (dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(31)) < 0) ehci_warn(ehci, "can't enable NVidia " "workaround for >2GB RAM\n"); break; -- cgit v1.2.3-70-g09d2 From 2b53a19284f537168fb506f2f40d7fda40a01162 Mon Sep 17 00:00:00 2001 From: Changming Liu Date: Sat, 11 Jul 2020 00:30:18 -0400 Subject: USB: sisusbvga: Fix a potential UB casued by left shifting a negative value The char buffer buf, receives data directly from user space, so its content might be negative and its elements are left shifted to form an unsigned integer. Since left shifting a negative value is undefined behavior, thus change the char to u8 to elimintate this UB. Signed-off-by: Changming Liu Link: https://lore.kernel.org/r/20200711043018.928-1-charley.ashbringer@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/misc/sisusbvga/sisusb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/usb') diff --git a/drivers/usb/misc/sisusbvga/sisusb.c b/drivers/usb/misc/sisusbvga/sisusb.c index 88c4975e303d..f08de33d9ff3 100644 --- a/drivers/usb/misc/sisusbvga/sisusb.c +++ b/drivers/usb/misc/sisusbvga/sisusb.c @@ -761,7 +761,7 @@ static int sisusb_write_mem_bulk(struct sisusb_usb_data *sisusb, u32 addr, u8 swap8, fromkern = kernbuffer ? 1 : 0; u16 swap16; u32 swap32, flag = (length >> 28) & 1; - char buf[4]; + u8 buf[4]; /* if neither kernbuffer not userbuffer are given, assume * data in obuf -- cgit v1.2.3-70-g09d2 From 258e858802cefbc59c5315f8893e99f8ffe117e6 Mon Sep 17 00:00:00 2001 From: YueHaibing Date: Wed, 15 Jul 2020 11:12:04 +0800 Subject: USB: musb: Remove unused inline function It is never used, so can remove it. Signed-off-by: YueHaibing Link: https://lore.kernel.org/r/20200715031204.17308-1-yuehaibing@huawei.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/musb/musb_host.h | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers/usb') diff --git a/drivers/usb/musb/musb_host.h b/drivers/usb/musb/musb_host.h index 32336571f05c..4804d4d85c15 100644 --- a/drivers/usb/musb/musb_host.h +++ b/drivers/usb/musb/musb_host.h @@ -97,7 +97,6 @@ static inline void musb_host_tx(struct musb *musb, u8 epnum) {} static inline void musb_host_rx(struct musb *musb, u8 epnum) {} static inline void musb_root_disconnect(struct musb *musb) {} static inline void musb_host_resume_root_hub(struct musb *musb) {} -static inline void musb_host_poll_rh_status(struct musb *musb) {} static inline void musb_host_poke_root_hub(struct musb *musb) {} static inline int musb_port_suspend(struct musb *musb, bool do_suspend) { -- cgit v1.2.3-70-g09d2 From 9607f3cd8b6633cae5a9c43d8a537add1af801da Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Wed, 15 Jul 2020 10:32:02 +0100 Subject: usb: dwc2: gadget: Make use of GINTMSK2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The value obtained from GINTSTS2 should be masked with the GINTMSK2 value. Looks like this has been broken since dwc2_gadget_wkup_alert_handler() was added back in 2018. Also fixes the following W=1 warning: drivers/usb/dwc2/gadget.c: In function ‘dwc2_gadget_wkup_alert_handler’: drivers/usb/dwc2/gadget.c:259:6: warning: variable ‘gintmsk2’ set but not used [-Wunused-but-set-variable] 259 | u32 gintmsk2; | ^~~~~~~~ Cc: Ben Dooks Fixes: 187c5298a1229 ("usb: dwc2: gadget: Add handler for WkupAlert interrupt") Signed-off-by: Lee Jones Acked-by: Minas Harutyunyan Link: https://lore.kernel.org/r/20200715093209.3165641-2-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/dwc2/gadget.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/usb') diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index df5fedaca60a..03cf1fa85621 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -260,6 +260,7 @@ static void dwc2_gadget_wkup_alert_handler(struct dwc2_hsotg *hsotg) gintsts2 = dwc2_readl(hsotg, GINTSTS2); gintmsk2 = dwc2_readl(hsotg, GINTMSK2); + gintsts2 &= gintmsk2; if (gintsts2 & GINTSTS2_WKUP_ALERT_INT) { dev_dbg(hsotg->dev, "%s: Wkup_Alert_Int\n", __func__); -- cgit v1.2.3-70-g09d2 From eeed948c1d0b7dfcc58e17fd72370cdba0dfdf95 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Wed, 15 Jul 2020 10:32:03 +0100 Subject: usb: dwc2: gadget: Avoid pointless read of EP control register MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Commit ec1f9d9f01384 ("usb: dwc2: gadget: parity fix in isochronous mode") moved these checks to dwc2_hsotg_change_ep_iso_parity() back in 2015. The assigned value hasn't been read back since. Let's remove the unnecessary H/W read. Fixes the following W=1 warning: drivers/usb/dwc2/gadget.c: In function ‘dwc2_hsotg_epint’: drivers/usb/dwc2/gadget.c:2981:6: warning: variable ‘ctrl’ set but not used [-Wunused-but-set-variable] 2981 | u32 ctrl; | ^~~~ Cc: Ben Dooks Signed-off-by: Lee Jones Acked-by: Minas Harutyunyan Link: https://lore.kernel.org/r/20200715093209.3165641-3-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/dwc2/gadget.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index 03cf1fa85621..5b9d23991c99 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -2978,10 +2978,8 @@ static void dwc2_hsotg_epint(struct dwc2_hsotg *hsotg, unsigned int idx, u32 epctl_reg = dir_in ? DIEPCTL(idx) : DOEPCTL(idx); u32 epsiz_reg = dir_in ? DIEPTSIZ(idx) : DOEPTSIZ(idx); u32 ints; - u32 ctrl; ints = dwc2_gadget_read_ep_interrupts(hsotg, idx, dir_in); - ctrl = dwc2_readl(hsotg, epctl_reg); /* Clear endpoint interrupts */ dwc2_writel(hsotg, ints, epint_reg); -- cgit v1.2.3-70-g09d2 From 680b512726545e07c8d42b8023c430bf80e6c22c Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Wed, 15 Jul 2020 10:32:04 +0100 Subject: usb: mtu3: mtu3_trace: Function headers are not suitable for kerneldoc Kerneldoc headers should only be used to document functions and data structures. Cc: Chunfeng Yun Cc: linux-mediatek@lists.infradead.org Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20200715093209.3165641-4-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/mtu3/mtu3_trace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/usb') diff --git a/drivers/usb/mtu3/mtu3_trace.c b/drivers/usb/mtu3/mtu3_trace.c index 4f5e7857ec31..155eae126e5e 100644 --- a/drivers/usb/mtu3/mtu3_trace.c +++ b/drivers/usb/mtu3/mtu3_trace.c @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 -/** +/* * mtu3_trace.c - trace support * * Copyright (C) 2019 MediaTek Inc. -- cgit v1.2.3-70-g09d2 From 56976249bd885fff2f1b77c994d38dada0027240 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Wed, 15 Jul 2020 10:32:05 +0100 Subject: usb: mtu3: mtu3_trace: Supply missing mtu3_debug.h include file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If the header file containing a function's prototype isn't included by the sourcefile containing the associated function, the build system complains of missing prototypes. Fixes the following W=1 kernel build warning(s): drivers/usb/mtu3/mtu3_trace.c:13:6: warning: no previous prototype for ‘mtu3_dbg_trace’ [-Wmissing-prototypes] 13 | void mtu3_dbg_trace(struct device *dev, const char *fmt, ...) | ^~~~~~~~~~~~~~ Cc: Chunfeng Yun Cc: linux-arm-kernel@lists.infradead.org Cc: linux-mediatek@lists.infradead.org Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20200715093209.3165641-5-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/mtu3/mtu3_trace.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/usb') diff --git a/drivers/usb/mtu3/mtu3_trace.c b/drivers/usb/mtu3/mtu3_trace.c index 155eae126e5e..d17ddb87cdcf 100644 --- a/drivers/usb/mtu3/mtu3_trace.c +++ b/drivers/usb/mtu3/mtu3_trace.c @@ -8,6 +8,7 @@ */ #define CREATE_TRACE_POINTS +#include "mtu3_debug.h" #include "mtu3_trace.h" void mtu3_dbg_trace(struct device *dev, const char *fmt, ...) -- cgit v1.2.3-70-g09d2 From ddcb6c6ad75760fcea6a0f64331fc00c552d16d0 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Wed, 15 Jul 2020 10:32:06 +0100 Subject: usb: class: cdc-wdm: Provide description for usb_cdc_wdm_register()'s manage_power arg A good attempt was made to document everything else. Fixes the following W=1 kernel build warning(s): drivers/usb/class/cdc-wdm.c:961: warning: Function parameter or member 'manage_power' not described in 'usb_cdc_wdm_register' Cc: Oliver Neukum Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20200715093209.3165641-6-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/class/cdc-wdm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'drivers/usb') diff --git a/drivers/usb/class/cdc-wdm.c b/drivers/usb/class/cdc-wdm.c index e3db6fbeadef..7f5de956a2fc 100644 --- a/drivers/usb/class/cdc-wdm.c +++ b/drivers/usb/class/cdc-wdm.c @@ -940,7 +940,8 @@ err: * @intf: usb interface the subdriver will associate with * @ep: interrupt endpoint to monitor for notifications * @bufsize: maximum message size to support for read/write - * + * @manage_power: call-back invoked during open and release to + * manage the device's power * Create WDM usb class character device and associate it with intf * without binding, allowing another driver to manage the interface. * -- cgit v1.2.3-70-g09d2 From e606c759f43b18de768253c70290cb023245faee Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Wed, 15 Jul 2020 10:32:07 +0100 Subject: usb: c67x00: c67x00-hcd: Demote obvious misuse of kerneldoc to standard comment blocks No attempt has been made to document any of the functions here. Fixes the following W=1 kernel build warning(s): drivers/usb/c67x00/c67x00-hcd.c:237: warning: Function parameter or member 'sie' not described in 'c67x00_hcd_irq' drivers/usb/c67x00/c67x00-hcd.c:237: warning: Function parameter or member 'int_status' not described in 'c67x00_hcd_irq' drivers/usb/c67x00/c67x00-hcd.c:237: warning: Function parameter or member 'msg' not described in 'c67x00_hcd_irq' drivers/usb/c67x00/c67x00-hcd.c:267: warning: Function parameter or member 'hcd' not described in 'c67x00_hcd_start' drivers/usb/c67x00/c67x00-hcd.c:279: warning: Function parameter or member 'hcd' not described in 'c67x00_hcd_stop' Cc: Peter Korsgaard Cc: Oliver Neukum Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20200715093209.3165641-7-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/c67x00/c67x00-hcd.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/c67x00/c67x00-hcd.c b/drivers/usb/c67x00/c67x00-hcd.c index c39eee17c0e4..39f237666331 100644 --- a/drivers/usb/c67x00/c67x00-hcd.c +++ b/drivers/usb/c67x00/c67x00-hcd.c @@ -228,7 +228,7 @@ static int c67x00_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, * Main part of host controller driver */ -/** +/* * c67x00_hcd_irq * * This function is called from the interrupt handler in c67x00-drv.c @@ -260,7 +260,7 @@ static void c67x00_hcd_irq(struct c67x00_sie *sie, u16 int_status, u16 msg) } } -/** +/* * c67x00_hcd_start: Host controller start hook */ static int c67x00_hcd_start(struct usb_hcd *hcd) @@ -272,7 +272,7 @@ static int c67x00_hcd_start(struct usb_hcd *hcd) return 0; } -/** +/* * c67x00_hcd_stop: Host controller stop hook */ static void c67x00_hcd_stop(struct usb_hcd *hcd) -- cgit v1.2.3-70-g09d2 From 4805ad24886a611fffb307c87f12d7e9504b7d25 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Wed, 15 Jul 2020 10:32:08 +0100 Subject: usb: misc: sisusbvga: sisusb_init: Remove genunine unused static const arrays MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit These are not referenced anywhere in the kernel. Fixes the following W=1 kernel build warning(s): drivers/usb/misc/sisusbvga/sisusb_init.h:171:29: warning: ‘ModeIndex_1280x1024’ defined but not used [-Wunused-const-variable=] drivers/usb/misc/sisusbvga/sisusb_init.h:170:29: warning: ‘ModeIndex_1280x768’ defined but not used [-Wunused-const-variable=] drivers/usb/misc/sisusbvga/sisusb_init.h:169:29: warning: ‘ModeIndex_1280x720’ defined but not used [-Wunused-const-variable=] drivers/usb/misc/sisusbvga/sisusb_init.h:168:29: warning: ‘ModeIndex_1152x864’ defined but not used [-Wunused-const-variable=] drivers/usb/misc/sisusbvga/sisusb_init.h:167:29: warning: ‘ModeIndex_1024x576’ defined but not used [-Wunused-const-variable=] drivers/usb/misc/sisusbvga/sisusb_init.h:166:29: warning: ‘ModeIndex_1024x768’ defined but not used [-Wunused-const-variable=] drivers/usb/misc/sisusbvga/sisusb_init.h:165:29: warning: ‘ModeIndex_960x600’ defined but not used [-Wunused-const-variable=] drivers/usb/misc/sisusbvga/sisusb_init.h:164:29: warning: ‘ModeIndex_960x540’ defined but not used [-Wunused-const-variable=] drivers/usb/misc/sisusbvga/sisusb_init.h:163:29: warning: ‘ModeIndex_856x480’ defined but not used [-Wunused-const-variable=] drivers/usb/misc/sisusbvga/sisusb_init.h:162:29: warning: ‘ModeIndex_848x480’ defined but not used [-Wunused-const-variable=] drivers/usb/misc/sisusbvga/sisusb_init.h:161:29: warning: ‘ModeIndex_800x600’ defined but not used [-Wunused-const-variable=] drivers/usb/misc/sisusbvga/sisusb_init.h:160:29: warning: ‘ModeIndex_800x480’ defined but not used [-Wunused-const-variable=] drivers/usb/misc/sisusbvga/sisusb_init.h:159:29: warning: ‘ModeIndex_768x576’ defined but not used [-Wunused-const-variable=] drivers/usb/misc/sisusbvga/sisusb_init.h:158:29: warning: ‘ModeIndex_720x576’ defined but not used [-Wunused-const-variable=] drivers/usb/misc/sisusbvga/sisusb_init.h:157:29: warning: ‘ModeIndex_720x480’ defined but not used [-Wunused-const-variable=] drivers/usb/misc/sisusbvga/sisusb_init.h:156:29: warning: ‘ModeIndex_640x480’ defined but not used [-Wunused-const-variable=] drivers/usb/misc/sisusbvga/sisusb_init.h:155:29: warning: ‘ModeIndex_640x400’ defined but not used [-Wunused-const-variable=] drivers/usb/misc/sisusbvga/sisusb_init.h:154:29: warning: ‘ModeIndex_512x384’ defined but not used [-Wunused-const-variable=] drivers/usb/misc/sisusbvga/sisusb_init.h:153:29: warning: ‘ModeIndex_400x300’ defined but not used [-Wunused-const-variable=] drivers/usb/misc/sisusbvga/sisusb_init.h:152:29: warning: ‘ModeIndex_320x240’ defined but not used [-Wunused-const-variable=] drivers/usb/misc/sisusbvga/sisusb_init.h:151:29: warning: ‘ModeIndex_320x200’ defined but not used [-Wunused-const-variable=] drivers/usb/misc/sisusbvga/sisusb_init.h:232:37: warning: ‘SiSUSB_ModeResInfo’ defined but not used [-Wunused-const-variable=] Cc: Thomas Winischhofer Cc: Joe Perches Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20200715093209.3165641-8-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/misc/sisusbvga/sisusb_init.h | 31 ------------------------------- 1 file changed, 31 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/misc/sisusbvga/sisusb_init.h b/drivers/usb/misc/sisusbvga/sisusb_init.h index b79bdf989933..80ba458f28cb 100644 --- a/drivers/usb/misc/sisusbvga/sisusb_init.h +++ b/drivers/usb/misc/sisusbvga/sisusb_init.h @@ -147,29 +147,6 @@ #define SIS_VIDEO_PLAYBACK 0x02 - 0x30 #define SIS_CRT2_PORT_04 0x04 - 0x30 -/* Mode numbers */ -static const unsigned short ModeIndex_320x200[] = { 0x59, 0x41, 0x00, 0x4f }; -static const unsigned short ModeIndex_320x240[] = { 0x50, 0x56, 0x00, 0x53 }; -static const unsigned short ModeIndex_400x300[] = { 0x51, 0x57, 0x00, 0x54 }; -static const unsigned short ModeIndex_512x384[] = { 0x52, 0x58, 0x00, 0x5c }; -static const unsigned short ModeIndex_640x400[] = { 0x2f, 0x5d, 0x00, 0x5e }; -static const unsigned short ModeIndex_640x480[] = { 0x2e, 0x44, 0x00, 0x62 }; -static const unsigned short ModeIndex_720x480[] = { 0x31, 0x33, 0x00, 0x35 }; -static const unsigned short ModeIndex_720x576[] = { 0x32, 0x34, 0x00, 0x36 }; -static const unsigned short ModeIndex_768x576[] = { 0x5f, 0x60, 0x00, 0x61 }; -static const unsigned short ModeIndex_800x480[] = { 0x70, 0x7a, 0x00, 0x76 }; -static const unsigned short ModeIndex_800x600[] = { 0x30, 0x47, 0x00, 0x63 }; -static const unsigned short ModeIndex_848x480[] = { 0x39, 0x3b, 0x00, 0x3e }; -static const unsigned short ModeIndex_856x480[] = { 0x3f, 0x42, 0x00, 0x45 }; -static const unsigned short ModeIndex_960x540[] = { 0x1d, 0x1e, 0x00, 0x1f }; -static const unsigned short ModeIndex_960x600[] = { 0x20, 0x21, 0x00, 0x22 }; -static const unsigned short ModeIndex_1024x768[] = { 0x38, 0x4a, 0x00, 0x64 }; -static const unsigned short ModeIndex_1024x576[] = { 0x71, 0x74, 0x00, 0x77 }; -static const unsigned short ModeIndex_1152x864[] = { 0x29, 0x2a, 0x00, 0x2b }; -static const unsigned short ModeIndex_1280x720[] = { 0x79, 0x75, 0x00, 0x78 }; -static const unsigned short ModeIndex_1280x768[] = { 0x23, 0x24, 0x00, 0x25 }; -static const unsigned short ModeIndex_1280x1024[] = { 0x3a, 0x4d, 0x00, 0x65 }; - static const unsigned char SiS_MDA_DAC[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, @@ -221,14 +198,6 @@ static const struct SiS_St SiSUSB_SModeIDTable[] = { {0xff, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} }; -static const struct SiS_StResInfo_S SiSUSB_StResInfo[] = { - {640, 400}, - {640, 350}, - {720, 400}, - {720, 350}, - {640, 480} -}; - static const struct SiS_ModeResInfo SiSUSB_ModeResInfo[] = { {320, 200, 8, 8}, /* 0x00 */ {320, 240, 8, 8}, /* 0x01 */ -- cgit v1.2.3-70-g09d2 From 313da01ad524771046beddb18faffc5b3caf930f Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Wed, 15 Jul 2020 10:32:09 +0100 Subject: usb: misc: sisusbvga: Move static const tables out to different include file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit sisusb_init.h is included by multiple source files, but the big data tables contained are only referenced by one of them, leaving the tables 'defined but not used' by the remainder. We have a choice to either place them inside the source file, taking up may lines and potentially overwhelming the source file OR tuck them away neatly inside their own headerfile. The latter was chosen. Fixes the following W=1 kernel build warning(s): In file included from drivers/usb/misc/sisusbvga/sisusb.c:54: drivers/usb/misc/sisusbvga/sisusb_init.h:664:34: warning: ‘SiSUSB_VCLKData’ defined but not used [-Wunused-const-variable=] 664 | static const struct SiS_VCLKData SiSUSB_VCLKData[] = { | ^~~~~~~~~~~~~~~ drivers/usb/misc/sisusbvga/sisusb_init.h:406:35: warning: ‘SiSUSB_CRT1Table’ defined but not used [-Wunused-const-variable=] 406 | static const struct SiS_CRT1Table SiSUSB_CRT1Table[] = { | ^~~~~~~~~~~~~~~~ drivers/usb/misc/sisusbvga/sisusb_init.h:348:30: warning: ‘SiSUSB_RefIndex’ defined but not used [-Wunused-const-variable=] 348 | static const struct SiS_Ext2 SiSUSB_RefIndex[] = { | ^~~~~~~~~~~~~~~ drivers/usb/misc/sisusbvga/sisusb_init.h:269:29: warning: ‘SiSUSB_EModeIDTable’ defined but not used [-Wunused-const-variable=] 269 | static const struct SiS_Ext SiSUSB_EModeIDTable[] = { | ^~~~~~~~~~~~~~~~~~~ drivers/usb/misc/sisusbvga/sisusb_init.h:238:36: warning: ‘SiSUSB_StandTable’ defined but not used [-Wunused-const-variable=] 238 | static const struct SiS_StandTable SiSUSB_StandTable[] = { | ^~~~~~~~~~~~~~~~~ drivers/usb/misc/sisusbvga/sisusb_init.h:201:37: warning: ‘SiSUSB_ModeResInfo’ defined but not used [-Wunused-const-variable=] 201 | static const struct SiS_ModeResInfo SiSUSB_ModeResInfo[] = { | ^~~~~~~~~~~~~~~~~~ drivers/usb/misc/sisusbvga/sisusb_init.h:196:28: warning: ‘SiSUSB_SModeIDTable’ defined but not used [-Wunused-const-variable=] 196 | static const struct SiS_St SiSUSB_SModeIDTable[] = { | ^~~~~~~~~~~~~~~~~~~ drivers/usb/misc/sisusbvga/sisusb_init.h:183:28: warning: ‘SiS_VGA_DAC’ defined but not used [-Wunused-const-variable=] 183 | static const unsigned char SiS_VGA_DAC[] = { | ^~~~~~~~~~~ drivers/usb/misc/sisusbvga/sisusb_init.h:172:28: warning: ‘SiS_EGA_DAC’ defined but not used [-Wunused-const-variable=] 172 | static const unsigned char SiS_EGA_DAC[] = { | ^~~~~~~~~~~ drivers/usb/misc/sisusbvga/sisusb_init.h:161:28: warning: ‘SiS_CGA_DAC’ defined but not used [-Wunused-const-variable=] 161 | static const unsigned char SiS_CGA_DAC[] = { | ^~~~~~~~~~~ drivers/usb/misc/sisusbvga/sisusb_init.h:150:28: warning: ‘SiS_MDA_DAC’ defined but not used [-Wunused-const-variable=] 150 | static const unsigned char SiS_MDA_DAC[] = { | ^~~~~~~~~~~ Cc: Thomas Winischhofer Cc: Joe Perches Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20200715093209.3165641-9-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/misc/sisusbvga/sisusb_init.c | 1 + drivers/usb/misc/sisusbvga/sisusb_init.h | 631 -------------------------- drivers/usb/misc/sisusbvga/sisusb_tables.h | 688 +++++++++++++++++++++++++++++ 3 files changed, 689 insertions(+), 631 deletions(-) create mode 100644 drivers/usb/misc/sisusbvga/sisusb_tables.h (limited to 'drivers/usb') diff --git a/drivers/usb/misc/sisusbvga/sisusb_init.c b/drivers/usb/misc/sisusbvga/sisusb_init.c index 66f6ab5acd97..7c11198d5dda 100644 --- a/drivers/usb/misc/sisusbvga/sisusb_init.c +++ b/drivers/usb/misc/sisusbvga/sisusb_init.c @@ -45,6 +45,7 @@ #include "sisusb.h" #include "sisusb_init.h" +#include "sisusb_tables.h" /*********************************************/ /* POINTER INITIALIZATION */ diff --git a/drivers/usb/misc/sisusbvga/sisusb_init.h b/drivers/usb/misc/sisusbvga/sisusb_init.h index 80ba458f28cb..b5cd77ae941d 100644 --- a/drivers/usb/misc/sisusbvga/sisusb_init.h +++ b/drivers/usb/misc/sisusbvga/sisusb_init.h @@ -147,637 +147,6 @@ #define SIS_VIDEO_PLAYBACK 0x02 - 0x30 #define SIS_CRT2_PORT_04 0x04 - 0x30 -static const unsigned char SiS_MDA_DAC[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, - 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, - 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, - 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, - 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F -}; - -static const unsigned char SiS_CGA_DAC[] = { - 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15, - 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15, - 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F, - 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F, - 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15, - 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15, - 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F, - 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F -}; - -static const unsigned char SiS_EGA_DAC[] = { - 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x05, 0x15, - 0x20, 0x30, 0x24, 0x34, 0x21, 0x31, 0x25, 0x35, - 0x08, 0x18, 0x0C, 0x1C, 0x09, 0x19, 0x0D, 0x1D, - 0x28, 0x38, 0x2C, 0x3C, 0x29, 0x39, 0x2D, 0x3D, - 0x02, 0x12, 0x06, 0x16, 0x03, 0x13, 0x07, 0x17, - 0x22, 0x32, 0x26, 0x36, 0x23, 0x33, 0x27, 0x37, - 0x0A, 0x1A, 0x0E, 0x1E, 0x0B, 0x1B, 0x0F, 0x1F, - 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F -}; - -static const unsigned char SiS_VGA_DAC[] = { - 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15, - 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F, - 0x00, 0x05, 0x08, 0x0B, 0x0E, 0x11, 0x14, 0x18, - 0x1C, 0x20, 0x24, 0x28, 0x2D, 0x32, 0x38, 0x3F, - 0x00, 0x10, 0x1F, 0x2F, 0x3F, 0x1F, 0x27, 0x2F, - 0x37, 0x3F, 0x2D, 0x31, 0x36, 0x3A, 0x3F, 0x00, - 0x07, 0x0E, 0x15, 0x1C, 0x0E, 0x11, 0x15, 0x18, - 0x1C, 0x14, 0x16, 0x18, 0x1A, 0x1C, 0x00, 0x04, - 0x08, 0x0C, 0x10, 0x08, 0x0A, 0x0C, 0x0E, 0x10, - 0x0B, 0x0C, 0x0D, 0x0F, 0x10 -}; - -static const struct SiS_St SiSUSB_SModeIDTable[] = { - {0x03, 0x0010, 0x18, 0x02, 0x02, 0x00, 0x01, 0x03, 0x40}, - {0xff, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} -}; - -static const struct SiS_ModeResInfo SiSUSB_ModeResInfo[] = { - {320, 200, 8, 8}, /* 0x00 */ - {320, 240, 8, 8}, /* 0x01 */ - {320, 400, 8, 8}, /* 0x02 */ - {400, 300, 8, 8}, /* 0x03 */ - {512, 384, 8, 8}, /* 0x04 */ - {640, 400, 8, 16}, /* 0x05 */ - {640, 480, 8, 16}, /* 0x06 */ - {800, 600, 8, 16}, /* 0x07 */ - {1024, 768, 8, 16}, /* 0x08 */ - {1280, 1024, 8, 16}, /* 0x09 */ - {1600, 1200, 8, 16}, /* 0x0a */ - {1920, 1440, 8, 16}, /* 0x0b */ - {2048, 1536, 8, 16}, /* 0x0c */ - {720, 480, 8, 16}, /* 0x0d */ - {720, 576, 8, 16}, /* 0x0e */ - {1280, 960, 8, 16}, /* 0x0f */ - {800, 480, 8, 16}, /* 0x10 */ - {1024, 576, 8, 16}, /* 0x11 */ - {1280, 720, 8, 16}, /* 0x12 */ - {856, 480, 8, 16}, /* 0x13 */ - {1280, 768, 8, 16}, /* 0x14 */ - {1400, 1050, 8, 16}, /* 0x15 */ - {1152, 864, 8, 16}, /* 0x16 */ - {848, 480, 8, 16}, /* 0x17 */ - {1360, 768, 8, 16}, /* 0x18 */ - {1024, 600, 8, 16}, /* 0x19 */ - {1152, 768, 8, 16}, /* 0x1a */ - {768, 576, 8, 16}, /* 0x1b */ - {1360, 1024, 8, 16}, /* 0x1c */ - {1680, 1050, 8, 16}, /* 0x1d */ - {1280, 800, 8, 16}, /* 0x1e */ - {1920, 1080, 8, 16}, /* 0x1f */ - {960, 540, 8, 16}, /* 0x20 */ - {960, 600, 8, 16} /* 0x21 */ -}; - -static const struct SiS_StandTable SiSUSB_StandTable[] = { - /* MD_3_400 - mode 0x03 - 400 */ - { - 0x50, 0x18, 0x10, 0x1000, - {0x00, 0x03, 0x00, 0x02}, - 0x67, - {0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x9c, 0x8e, 0x8f, 0x28, 0x1f, 0x96, 0xb9, 0xa3, - 0xff}, - {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x0c, 0x00, 0x0f, 0x08}, - {0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x00, 0xff} - }, - /* Generic for VGA and higher */ - { - 0x00, 0x00, 0x00, 0x0000, - {0x01, 0x0f, 0x00, 0x0e}, - 0x23, - {0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0x0b, 0x3e, - 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xea, 0x8c, 0xdf, 0x28, 0x40, 0xe7, 0x04, 0xa3, - 0xff}, - {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, - 0x01, 0x00, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0f, 0xff} - } -}; - -static const struct SiS_Ext SiSUSB_EModeIDTable[] = { - {0x2e, 0x0a1b, 0x0101, SIS_RI_640x480, 0x00, 0x00, 0x05, 0x05, 0x08, 2}, /* 640x480x8 */ - {0x2f, 0x0a1b, 0x0100, SIS_RI_640x400, 0x00, 0x00, 0x05, 0x05, 0x10, 0}, /* 640x400x8 */ - {0x30, 0x2a1b, 0x0103, SIS_RI_800x600, 0x00, 0x00, 0x07, 0x06, 0x00, 3}, /* 800x600x8 */ - {0x31, 0x4a1b, 0x0000, SIS_RI_720x480, 0x00, 0x00, 0x06, 0x06, 0x11, -1}, /* 720x480x8 */ - {0x32, 0x4a1b, 0x0000, SIS_RI_720x576, 0x00, 0x00, 0x06, 0x06, 0x12, -1}, /* 720x576x8 */ - {0x33, 0x4a1d, 0x0000, SIS_RI_720x480, 0x00, 0x00, 0x06, 0x06, 0x11, -1}, /* 720x480x16 */ - {0x34, 0x6a1d, 0x0000, SIS_RI_720x576, 0x00, 0x00, 0x06, 0x06, 0x12, -1}, /* 720x576x16 */ - {0x35, 0x4a1f, 0x0000, SIS_RI_720x480, 0x00, 0x00, 0x06, 0x06, 0x11, -1}, /* 720x480x32 */ - {0x36, 0x6a1f, 0x0000, SIS_RI_720x576, 0x00, 0x00, 0x06, 0x06, 0x12, -1}, /* 720x576x32 */ - {0x38, 0x0a1b, 0x0105, SIS_RI_1024x768, 0x00, 0x00, 0x08, 0x07, 0x13, 4}, /* 1024x768x8 */ - {0x3a, 0x0e3b, 0x0107, SIS_RI_1280x1024, 0x00, 0x00, 0x00, 0x00, 0x2f, 8}, /* 1280x1024x8 */ - {0x41, 0x9a1d, 0x010e, SIS_RI_320x200, 0x00, 0x00, 0x04, 0x04, 0x1a, 0}, /* 320x200x16 */ - {0x44, 0x0a1d, 0x0111, SIS_RI_640x480, 0x00, 0x00, 0x05, 0x05, 0x08, 2}, /* 640x480x16 */ - {0x47, 0x2a1d, 0x0114, SIS_RI_800x600, 0x00, 0x00, 0x07, 0x06, 0x00, 3}, /* 800x600x16 */ - {0x4a, 0x0a3d, 0x0117, SIS_RI_1024x768, 0x00, 0x00, 0x08, 0x07, 0x13, 4}, /* 1024x768x16 */ - {0x4d, 0x0e7d, 0x011a, SIS_RI_1280x1024, 0x00, 0x00, 0x00, 0x00, 0x2f, 8}, /* 1280x1024x16 */ - {0x50, 0x9a1b, 0x0132, SIS_RI_320x240, 0x00, 0x00, 0x04, 0x04, 0x1b, 2}, /* 320x240x8 */ - {0x51, 0xba1b, 0x0133, SIS_RI_400x300, 0x00, 0x00, 0x07, 0x07, 0x1c, 3}, /* 400x300x8 */ - {0x52, 0xba1b, 0x0134, SIS_RI_512x384, 0x00, 0x00, 0x00, 0x00, 0x1d, 4}, /* 512x384x8 */ - {0x56, 0x9a1d, 0x0135, SIS_RI_320x240, 0x00, 0x00, 0x04, 0x04, 0x1b, 2}, /* 320x240x16 */ - {0x57, 0xba1d, 0x0136, SIS_RI_400x300, 0x00, 0x00, 0x07, 0x07, 0x1c, 3}, /* 400x300x16 */ - {0x58, 0xba1d, 0x0137, SIS_RI_512x384, 0x00, 0x00, 0x00, 0x00, 0x1d, 4}, /* 512x384x16 */ - {0x59, 0x9a1b, 0x0138, SIS_RI_320x200, 0x00, 0x00, 0x04, 0x04, 0x1a, 0}, /* 320x200x8 */ - {0x5c, 0xba1f, 0x0000, SIS_RI_512x384, 0x00, 0x00, 0x00, 0x00, 0x1d, 4}, /* 512x384x32 */ - {0x5d, 0x0a1d, 0x0139, SIS_RI_640x400, 0x00, 0x00, 0x05, 0x07, 0x10, 0}, /* 640x400x16 */ - {0x5e, 0x0a1f, 0x0000, SIS_RI_640x400, 0x00, 0x00, 0x05, 0x07, 0x10, 0}, /* 640x400x32 */ - {0x62, 0x0a3f, 0x013a, SIS_RI_640x480, 0x00, 0x00, 0x05, 0x05, 0x08, 2}, /* 640x480x32 */ - {0x63, 0x2a3f, 0x013b, SIS_RI_800x600, 0x00, 0x00, 0x07, 0x06, 0x00, 3}, /* 800x600x32 */ - {0x64, 0x0a7f, 0x013c, SIS_RI_1024x768, 0x00, 0x00, 0x08, 0x07, 0x13, 4}, /* 1024x768x32 */ - {0x65, 0x0eff, 0x013d, SIS_RI_1280x1024, 0x00, 0x00, 0x00, 0x00, 0x2f, 8}, /* 1280x1024x32 */ - {0x70, 0x6a1b, 0x0000, SIS_RI_800x480, 0x00, 0x00, 0x07, 0x07, 0x1e, -1}, /* 800x480x8 */ - {0x71, 0x4a1b, 0x0000, SIS_RI_1024x576, 0x00, 0x00, 0x00, 0x00, 0x21, -1}, /* 1024x576x8 */ - {0x74, 0x4a1d, 0x0000, SIS_RI_1024x576, 0x00, 0x00, 0x00, 0x00, 0x21, -1}, /* 1024x576x16 */ - {0x75, 0x0a3d, 0x0000, SIS_RI_1280x720, 0x00, 0x00, 0x00, 0x00, 0x24, 5}, /* 1280x720x16 */ - {0x76, 0x6a1f, 0x0000, SIS_RI_800x480, 0x00, 0x00, 0x07, 0x07, 0x1e, -1}, /* 800x480x32 */ - {0x77, 0x4a1f, 0x0000, SIS_RI_1024x576, 0x00, 0x00, 0x00, 0x00, 0x21, -1}, /* 1024x576x32 */ - {0x78, 0x0a3f, 0x0000, SIS_RI_1280x720, 0x00, 0x00, 0x00, 0x00, 0x24, 5}, /* 1280x720x32 */ - {0x79, 0x0a3b, 0x0000, SIS_RI_1280x720, 0x00, 0x00, 0x00, 0x00, 0x24, 5}, /* 1280x720x8 */ - {0x7a, 0x6a1d, 0x0000, SIS_RI_800x480, 0x00, 0x00, 0x07, 0x07, 0x1e, -1}, /* 800x480x16 */ - {0x23, 0x0e3b, 0x0000, SIS_RI_1280x768, 0x00, 0x00, 0x00, 0x00, 0x27, 6}, /* 1280x768x8 */ - {0x24, 0x0e7d, 0x0000, SIS_RI_1280x768, 0x00, 0x00, 0x00, 0x00, 0x27, 6}, /* 1280x768x16 */ - {0x25, 0x0eff, 0x0000, SIS_RI_1280x768, 0x00, 0x00, 0x00, 0x00, 0x27, 6}, /* 1280x768x32 */ - {0x39, 0x6a1b, 0x0000, SIS_RI_848x480, 0x00, 0x00, 0x00, 0x00, 0x28, -1}, /* 848x480 */ - {0x3b, 0x6a3d, 0x0000, SIS_RI_848x480, 0x00, 0x00, 0x00, 0x00, 0x28, - -1}, - {0x3e, 0x6a7f, 0x0000, SIS_RI_848x480, 0x00, 0x00, 0x00, 0x00, 0x28, - -1}, - {0x3f, 0x6a1b, 0x0000, SIS_RI_856x480, 0x00, 0x00, 0x00, 0x00, 0x2a, -1}, /* 856x480 */ - {0x42, 0x6a3d, 0x0000, SIS_RI_856x480, 0x00, 0x00, 0x00, 0x00, 0x2a, - -1}, - {0x45, 0x6a7f, 0x0000, SIS_RI_856x480, 0x00, 0x00, 0x00, 0x00, 0x2a, - -1}, - {0x4f, 0x9a1f, 0x0000, SIS_RI_320x200, 0x00, 0x00, 0x04, 0x04, 0x1a, 0}, /* 320x200x32 */ - {0x53, 0x9a1f, 0x0000, SIS_RI_320x240, 0x00, 0x00, 0x04, 0x04, 0x1b, 2}, /* 320x240x32 */ - {0x54, 0xba1f, 0x0000, SIS_RI_400x300, 0x00, 0x00, 0x07, 0x07, 0x1c, 3}, /* 400x300x32 */ - {0x5f, 0x6a1b, 0x0000, SIS_RI_768x576, 0x00, 0x00, 0x06, 0x06, 0x2c, -1}, /* 768x576 */ - {0x60, 0x6a1d, 0x0000, SIS_RI_768x576, 0x00, 0x00, 0x06, 0x06, 0x2c, - -1}, - {0x61, 0x6a3f, 0x0000, SIS_RI_768x576, 0x00, 0x00, 0x06, 0x06, 0x2c, - -1}, - {0x1d, 0x6a1b, 0x0000, SIS_RI_960x540, 0x00, 0x00, 0x00, 0x00, 0x2d, -1}, /* 960x540 */ - {0x1e, 0x6a3d, 0x0000, SIS_RI_960x540, 0x00, 0x00, 0x00, 0x00, 0x2d, - -1}, - {0x1f, 0x6a7f, 0x0000, SIS_RI_960x540, 0x00, 0x00, 0x00, 0x00, 0x2d, - -1}, - {0x20, 0x6a1b, 0x0000, SIS_RI_960x600, 0x00, 0x00, 0x00, 0x00, 0x2e, -1}, /* 960x600 */ - {0x21, 0x6a3d, 0x0000, SIS_RI_960x600, 0x00, 0x00, 0x00, 0x00, 0x2e, - -1}, - {0x22, 0x6a7f, 0x0000, SIS_RI_960x600, 0x00, 0x00, 0x00, 0x00, 0x2e, - -1}, - {0x29, 0x4e1b, 0x0000, SIS_RI_1152x864, 0x00, 0x00, 0x00, 0x00, 0x33, -1}, /* 1152x864 */ - {0x2a, 0x4e3d, 0x0000, SIS_RI_1152x864, 0x00, 0x00, 0x00, 0x00, 0x33, - -1}, - {0x2b, 0x4e7f, 0x0000, SIS_RI_1152x864, 0x00, 0x00, 0x00, 0x00, 0x33, - -1}, - {0xff, 0x0000, 0x0000, 0, 0x00, 0x00, 0x00, 0x00, 0x00, -1} -}; - -static const struct SiS_Ext2 SiSUSB_RefIndex[] = { - {0x085f, 0x0d, 0x03, 0x05, 0x05, 0x30, 800, 600, 0x40, 0x00, 0x00}, /* 0x0 */ - {0x0067, 0x0e, 0x04, 0x05, 0x05, 0x30, 800, 600, 0x40, 0x00, 0x00}, /* 0x1 */ - {0x0067, 0x0f, 0x08, 0x48, 0x05, 0x30, 800, 600, 0x40, 0x00, 0x00}, /* 0x2 */ - {0x0067, 0x10, 0x07, 0x8b, 0x05, 0x30, 800, 600, 0x40, 0x00, 0x00}, /* 0x3 */ - {0x0047, 0x11, 0x0a, 0x00, 0x05, 0x30, 800, 600, 0x40, 0x00, 0x00}, /* 0x4 */ - {0x0047, 0x12, 0x0d, 0x00, 0x05, 0x30, 800, 600, 0x40, 0x00, 0x00}, /* 0x5 */ - {0x0047, 0x13, 0x13, 0x00, 0x05, 0x30, 800, 600, 0x20, 0x00, 0x00}, /* 0x6 */ - {0x0107, 0x14, 0x1c, 0x00, 0x05, 0x30, 800, 600, 0x20, 0x00, 0x00}, /* 0x7 */ - {0xc85f, 0x05, 0x00, 0x04, 0x04, 0x2e, 640, 480, 0x40, 0x00, 0x00}, /* 0x8 */ - {0xc067, 0x06, 0x02, 0x04, 0x04, 0x2e, 640, 480, 0x40, 0x00, 0x00}, /* 0x9 */ - {0xc067, 0x07, 0x02, 0x47, 0x04, 0x2e, 640, 480, 0x40, 0x00, 0x00}, /* 0xa */ - {0xc067, 0x08, 0x03, 0x8a, 0x04, 0x2e, 640, 480, 0x40, 0x00, 0x00}, /* 0xb */ - {0xc047, 0x09, 0x05, 0x00, 0x04, 0x2e, 640, 480, 0x40, 0x00, 0x00}, /* 0xc */ - {0xc047, 0x0a, 0x09, 0x00, 0x04, 0x2e, 640, 480, 0x40, 0x00, 0x00}, /* 0xd */ - {0xc047, 0x0b, 0x0e, 0x00, 0x04, 0x2e, 640, 480, 0x40, 0x00, 0x00}, /* 0xe */ - {0xc047, 0x0c, 0x15, 0x00, 0x04, 0x2e, 640, 480, 0x40, 0x00, 0x00}, /* 0xf */ - {0x487f, 0x04, 0x00, 0x00, 0x00, 0x2f, 640, 400, 0x30, 0x55, 0x6e}, /* 0x10 */ - {0xc06f, 0x3c, 0x01, 0x06, 0x13, 0x31, 720, 480, 0x30, 0x00, 0x00}, /* 0x11 */ - {0x006f, 0x3d, 0x6f, 0x06, 0x14, 0x32, 720, 576, 0x30, 0x00, 0x00}, /* 0x12 (6f was 03) */ - {0x0087, 0x15, 0x06, 0x00, 0x06, 0x38, 1024, 768, 0x30, 0x00, 0x00}, /* 0x13 */ - {0xc877, 0x16, 0x0b, 0x06, 0x06, 0x38, 1024, 768, 0x20, 0x00, 0x00}, /* 0x14 */ - {0xc067, 0x17, 0x0f, 0x49, 0x06, 0x38, 1024, 768, 0x20, 0x00, 0x00}, /* 0x15 */ - {0x0067, 0x18, 0x11, 0x00, 0x06, 0x38, 1024, 768, 0x20, 0x00, 0x00}, /* 0x16 */ - {0x0047, 0x19, 0x16, 0x8c, 0x06, 0x38, 1024, 768, 0x20, 0x00, 0x00}, /* 0x17 */ - {0x0107, 0x1a, 0x1b, 0x00, 0x06, 0x38, 1024, 768, 0x10, 0x00, 0x00}, /* 0x18 */ - {0x0107, 0x1b, 0x1f, 0x00, 0x06, 0x38, 1024, 768, 0x10, 0x00, 0x00}, /* 0x19 */ - {0x407f, 0x00, 0x00, 0x00, 0x00, 0x41, 320, 200, 0x30, 0x56, 0x4e}, /* 0x1a */ - {0xc07f, 0x01, 0x00, 0x04, 0x04, 0x50, 320, 240, 0x30, 0x00, 0x00}, /* 0x1b */ - {0x007f, 0x02, 0x04, 0x05, 0x05, 0x51, 400, 300, 0x30, 0x00, 0x00}, /* 0x1c */ - {0xc077, 0x03, 0x0b, 0x06, 0x06, 0x52, 512, 384, 0x30, 0x00, 0x00}, /* 0x1d */ - {0x0077, 0x32, 0x40, 0x08, 0x18, 0x70, 800, 480, 0x30, 0x00, 0x00}, /* 0x1e */ - {0x0047, 0x33, 0x07, 0x08, 0x18, 0x70, 800, 480, 0x30, 0x00, 0x00}, /* 0x1f */ - {0x0047, 0x34, 0x0a, 0x08, 0x18, 0x70, 800, 480, 0x30, 0x00, 0x00}, /* 0x20 */ - {0x0077, 0x35, 0x0b, 0x09, 0x19, 0x71, 1024, 576, 0x30, 0x00, 0x00}, /* 0x21 */ - {0x0047, 0x36, 0x11, 0x09, 0x19, 0x71, 1024, 576, 0x30, 0x00, 0x00}, /* 0x22 */ - {0x0047, 0x37, 0x16, 0x09, 0x19, 0x71, 1024, 576, 0x30, 0x00, 0x00}, /* 0x23 */ - {0x1137, 0x38, 0x19, 0x0a, 0x0c, 0x75, 1280, 720, 0x30, 0x00, 0x00}, /* 0x24 */ - {0x1107, 0x39, 0x1e, 0x0a, 0x0c, 0x75, 1280, 720, 0x30, 0x00, 0x00}, /* 0x25 */ - {0x1307, 0x3a, 0x20, 0x0a, 0x0c, 0x75, 1280, 720, 0x30, 0x00, 0x00}, /* 0x26 */ - {0x0077, 0x42, 0x5b, 0x08, 0x11, 0x23, 1280, 768, 0x30, 0x00, 0x00}, /* 0x27 */ - {0x0087, 0x45, 0x57, 0x00, 0x16, 0x39, 848, 480, 0x30, 0x00, 0x00}, /* 0x28 38Hzi */ - {0xc067, 0x46, 0x55, 0x0b, 0x16, 0x39, 848, 480, 0x30, 0x00, 0x00}, /* 0x29 848x480-60Hz */ - {0x0087, 0x47, 0x57, 0x00, 0x17, 0x3f, 856, 480, 0x30, 0x00, 0x00}, /* 0x2a 856x480-38Hzi */ - {0xc067, 0x48, 0x57, 0x00, 0x17, 0x3f, 856, 480, 0x30, 0x00, 0x00}, /* 0x2b 856x480-60Hz */ - {0x006f, 0x4d, 0x71, 0x06, 0x15, 0x5f, 768, 576, 0x30, 0x00, 0x00}, /* 0x2c 768x576-56Hz */ - {0x0067, 0x52, 0x6a, 0x00, 0x1c, 0x1d, 960, 540, 0x30, 0x00, 0x00}, /* 0x2d 960x540 60Hz */ - {0x0077, 0x53, 0x6b, 0x0b, 0x1d, 0x20, 960, 600, 0x30, 0x00, 0x00}, /* 0x2e 960x600 60Hz */ - {0x0087, 0x1c, 0x11, 0x00, 0x07, 0x3a, 1280, 1024, 0x30, 0x00, 0x00}, /* 0x2f */ - {0x0137, 0x1d, 0x19, 0x07, 0x07, 0x3a, 1280, 1024, 0x00, 0x00, 0x00}, /* 0x30 */ - {0x0107, 0x1e, 0x1e, 0x00, 0x07, 0x3a, 1280, 1024, 0x00, 0x00, 0x00}, /* 0x31 */ - {0x0207, 0x1f, 0x20, 0x00, 0x07, 0x3a, 1280, 1024, 0x00, 0x00, 0x00}, /* 0x32 */ - {0x0127, 0x54, 0x6d, 0x00, 0x1a, 0x29, 1152, 864, 0x30, 0x00, 0x00}, /* 0x33 1152x864-60Hz */ - {0x0127, 0x44, 0x19, 0x00, 0x1a, 0x29, 1152, 864, 0x30, 0x00, 0x00}, /* 0x34 1152x864-75Hz */ - {0x0127, 0x4a, 0x1e, 0x00, 0x1a, 0x29, 1152, 864, 0x30, 0x00, 0x00}, /* 0x35 1152x864-85Hz */ - {0xffff, 0x00, 0x00, 0x00, 0x00, 0x00, 0, 0, 0, 0x00, 0x00} -}; - -static const struct SiS_CRT1Table SiSUSB_CRT1Table[] = { - {{0x2d, 0x27, 0x28, 0x90, 0x2c, 0x80, 0xbf, 0x1f, - 0x9c, 0x8e, 0x8f, 0x96, 0xb9, 0x30, 0x00, 0x00, - 0x00}}, /* 0x0 */ - {{0x2d, 0x27, 0x28, 0x90, 0x2c, 0x80, 0x0b, 0x3e, - 0xe9, 0x8b, 0xdf, 0xe7, 0x04, 0x00, 0x00, 0x00, - 0x00}}, /* 0x1 */ - {{0x3d, 0x31, 0x31, 0x81, 0x37, 0x1f, 0x72, 0xf0, - 0x58, 0x8c, 0x57, 0x57, 0x73, 0x20, 0x00, 0x05, - 0x01}}, /* 0x2 */ - {{0x4f, 0x3f, 0x3f, 0x93, 0x45, 0x0d, 0x24, 0xf5, - 0x02, 0x88, 0xff, 0xff, 0x25, 0x10, 0x00, 0x01, - 0x01}}, /* 0x3 */ - {{0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, - 0x9c, 0x8e, 0x8f, 0x96, 0xb9, 0x30, 0x00, 0x05, - 0x00}}, /* 0x4 */ - {{0x5f, 0x4f, 0x4f, 0x83, 0x55, 0x81, 0x0b, 0x3e, - 0xe9, 0x8b, 0xdf, 0xe8, 0x0c, 0x00, 0x00, 0x05, - 0x00}}, /* 0x5 */ - {{0x63, 0x4f, 0x4f, 0x87, 0x56, 0x9b, 0x06, 0x3e, - 0xe8, 0x8a, 0xdf, 0xe7, 0x07, 0x00, 0x00, 0x01, - 0x00}}, /* 0x6 */ - {{0x64, 0x4f, 0x4f, 0x88, 0x55, 0x9d, 0xf2, 0x1f, - 0xe0, 0x83, 0xdf, 0xdf, 0xf3, 0x10, 0x00, 0x01, - 0x00}}, /* 0x7 */ - {{0x63, 0x4f, 0x4f, 0x87, 0x5a, 0x81, 0xfb, 0x1f, - 0xe0, 0x83, 0xdf, 0xdf, 0xfc, 0x10, 0x00, 0x05, - 0x00}}, /* 0x8 */ - {{0x65, 0x4f, 0x4f, 0x89, 0x58, 0x80, 0xfb, 0x1f, - 0xe0, 0x83, 0xdf, 0xdf, 0xfc, 0x10, 0x00, 0x05, - 0x61}}, /* 0x9 */ - {{0x65, 0x4f, 0x4f, 0x89, 0x58, 0x80, 0x01, 0x3e, - 0xe0, 0x83, 0xdf, 0xdf, 0x02, 0x00, 0x00, 0x05, - 0x61}}, /* 0xa */ - {{0x67, 0x4f, 0x4f, 0x8b, 0x58, 0x81, 0x0d, 0x3e, - 0xe0, 0x83, 0xdf, 0xdf, 0x0e, 0x00, 0x00, 0x05, - 0x61}}, /* 0xb */ - {{0x65, 0x4f, 0x4f, 0x89, 0x57, 0x9f, 0xfb, 0x1f, - 0xe6, 0x8a, 0xdf, 0xdf, 0xfc, 0x10, 0x00, 0x01, - 0x00}}, /* 0xc */ - {{0x7b, 0x63, 0x63, 0x9f, 0x6a, 0x93, 0x6f, 0xf0, - 0x58, 0x8a, 0x57, 0x57, 0x70, 0x20, 0x00, 0x05, - 0x01}}, /* 0xd */ - {{0x7f, 0x63, 0x63, 0x83, 0x6c, 0x1c, 0x72, 0xf0, - 0x58, 0x8c, 0x57, 0x57, 0x73, 0x20, 0x00, 0x06, - 0x01}}, /* 0xe */ - {{0x7d, 0x63, 0x63, 0x81, 0x6e, 0x1d, 0x98, 0xf0, - 0x7c, 0x82, 0x57, 0x57, 0x99, 0x00, 0x00, 0x06, - 0x01}}, /* 0xf */ - {{0x7f, 0x63, 0x63, 0x83, 0x69, 0x13, 0x6f, 0xf0, - 0x58, 0x8b, 0x57, 0x57, 0x70, 0x20, 0x00, 0x06, - 0x01}}, /* 0x10 */ - {{0x7e, 0x63, 0x63, 0x82, 0x6b, 0x13, 0x75, 0xf0, - 0x58, 0x8b, 0x57, 0x57, 0x76, 0x20, 0x00, 0x06, - 0x01}}, /* 0x11 */ - {{0x81, 0x63, 0x63, 0x85, 0x6d, 0x18, 0x7a, 0xf0, - 0x58, 0x8b, 0x57, 0x57, 0x7b, 0x20, 0x00, 0x06, - 0x61}}, /* 0x12 */ - {{0x83, 0x63, 0x63, 0x87, 0x6e, 0x19, 0x81, 0xf0, - 0x58, 0x8b, 0x57, 0x57, 0x82, 0x20, 0x00, 0x06, - 0x61}}, /* 0x13 */ - {{0x85, 0x63, 0x63, 0x89, 0x6f, 0x1a, 0x91, 0xf0, - 0x58, 0x8b, 0x57, 0x57, 0x92, 0x20, 0x00, 0x06, - 0x61}}, /* 0x14 */ - {{0x99, 0x7f, 0x7f, 0x9d, 0x84, 0x1a, 0x96, 0x1f, - 0x7f, 0x83, 0x7f, 0x7f, 0x97, 0x10, 0x00, 0x02, - 0x00}}, /* 0x15 */ - {{0xa3, 0x7f, 0x7f, 0x87, 0x86, 0x97, 0x24, 0xf5, - 0x02, 0x88, 0xff, 0xff, 0x25, 0x10, 0x00, 0x02, - 0x01}}, /* 0x16 */ - {{0xa1, 0x7f, 0x7f, 0x85, 0x86, 0x97, 0x24, 0xf5, - 0x02, 0x88, 0xff, 0xff, 0x25, 0x10, 0x00, 0x02, - 0x01}}, /* 0x17 */ - {{0x9f, 0x7f, 0x7f, 0x83, 0x85, 0x91, 0x1e, 0xf5, - 0x00, 0x83, 0xff, 0xff, 0x1f, 0x10, 0x00, 0x02, - 0x01}}, /* 0x18 */ - {{0xa7, 0x7f, 0x7f, 0x8b, 0x89, 0x95, 0x26, 0xf5, - 0x00, 0x83, 0xff, 0xff, 0x27, 0x10, 0x00, 0x02, - 0x01}}, /* 0x19 */ - {{0xa9, 0x7f, 0x7f, 0x8d, 0x8c, 0x9a, 0x2c, 0xf5, - 0x00, 0x83, 0xff, 0xff, 0x2d, 0x14, 0x00, 0x02, - 0x62}}, /* 0x1a */ - {{0xab, 0x7f, 0x7f, 0x8f, 0x8d, 0x9b, 0x35, 0xf5, - 0x00, 0x83, 0xff, 0xff, 0x36, 0x14, 0x00, 0x02, - 0x62}}, /* 0x1b */ - {{0xcf, 0x9f, 0x9f, 0x93, 0xb2, 0x01, 0x14, 0xba, - 0x00, 0x83, 0xff, 0xff, 0x15, 0x00, 0x00, 0x03, - 0x00}}, /* 0x1c */ - {{0xce, 0x9f, 0x9f, 0x92, 0xa9, 0x17, 0x28, 0x5a, - 0x00, 0x83, 0xff, 0xff, 0x29, 0x09, 0x00, 0x07, - 0x01}}, /* 0x1d */ - {{0xce, 0x9f, 0x9f, 0x92, 0xa5, 0x17, 0x28, 0x5a, - 0x00, 0x83, 0xff, 0xff, 0x29, 0x09, 0x00, 0x07, - 0x01}}, /* 0x1e */ - {{0xd3, 0x9f, 0x9f, 0x97, 0xab, 0x1f, 0x2e, 0x5a, - 0x00, 0x83, 0xff, 0xff, 0x2f, 0x09, 0x00, 0x07, - 0x01}}, /* 0x1f */ - {{0x09, 0xc7, 0xc7, 0x8d, 0xd3, 0x0b, 0xe0, 0x10, - 0xb0, 0x83, 0xaf, 0xaf, 0xe1, 0x2f, 0x01, 0x04, - 0x00}}, /* 0x20 */ - {{0x09, 0xc7, 0xc7, 0x8d, 0xd3, 0x0b, 0xe0, 0x10, - 0xb0, 0x83, 0xaf, 0xaf, 0xe1, 0x2f, 0x01, 0x04, - 0x00}}, /* 0x21 */ - {{0x09, 0xc7, 0xc7, 0x8d, 0xd3, 0x0b, 0xe0, 0x10, - 0xb0, 0x83, 0xaf, 0xaf, 0xe1, 0x2f, 0x01, 0x04, - 0x00}}, /* 0x22 */ - {{0x09, 0xc7, 0xc7, 0x8d, 0xd3, 0x0b, 0xe0, 0x10, - 0xb0, 0x83, 0xaf, 0xaf, 0xe1, 0x2f, 0x01, 0x04, - 0x00}}, /* 0x23 */ - {{0x09, 0xc7, 0xc7, 0x8d, 0xd3, 0x0b, 0xe0, 0x10, - 0xb0, 0x83, 0xaf, 0xaf, 0xe1, 0x2f, 0x01, 0x04, - 0x00}}, /* 0x24 */ - {{0x09, 0xc7, 0xc7, 0x8d, 0xd3, 0x0b, 0xe0, 0x10, - 0xb0, 0x83, 0xaf, 0xaf, 0xe1, 0x2f, 0x01, 0x04, - 0x00}}, /* 0x25 */ - {{0x09, 0xc7, 0xc7, 0x8d, 0xd3, 0x0b, 0xe0, 0x10, - 0xb0, 0x83, 0xaf, 0xaf, 0xe1, 0x2f, 0x01, 0x04, - 0x00}}, /* 0x26 */ - {{0x40, 0xef, 0xef, 0x84, 0x03, 0x1d, 0xda, 0x1f, - 0xa0, 0x83, 0x9f, 0x9f, 0xdb, 0x1f, 0x41, 0x01, - 0x00}}, /* 0x27 */ - {{0x43, 0xef, 0xef, 0x87, 0x06, 0x00, 0xd4, 0x1f, - 0xa0, 0x83, 0x9f, 0x9f, 0xd5, 0x1f, 0x41, 0x05, - 0x63}}, /* 0x28 */ - {{0x45, 0xef, 0xef, 0x89, 0x07, 0x01, 0xd9, 0x1f, - 0xa0, 0x83, 0x9f, 0x9f, 0xda, 0x1f, 0x41, 0x05, - 0x63}}, /* 0x29 */ - {{0x40, 0xef, 0xef, 0x84, 0x03, 0x1d, 0xda, 0x1f, - 0xa0, 0x83, 0x9f, 0x9f, 0xdb, 0x1f, 0x41, 0x01, - 0x00}}, /* 0x2a */ - {{0x40, 0xef, 0xef, 0x84, 0x03, 0x1d, 0xda, 0x1f, - 0xa0, 0x83, 0x9f, 0x9f, 0xdb, 0x1f, 0x41, 0x01, - 0x00}}, /* 0x2b */ - {{0x40, 0xef, 0xef, 0x84, 0x03, 0x1d, 0xda, 0x1f, - 0xa0, 0x83, 0x9f, 0x9f, 0xdb, 0x1f, 0x41, 0x01, - 0x00}}, /* 0x2c */ - {{0x59, 0xff, 0xff, 0x9d, 0x17, 0x13, 0x33, 0xba, - 0x00, 0x83, 0xff, 0xff, 0x34, 0x0f, 0x41, 0x05, - 0x44}}, /* 0x2d */ - {{0x5b, 0xff, 0xff, 0x9f, 0x18, 0x14, 0x38, 0xba, - 0x00, 0x83, 0xff, 0xff, 0x39, 0x0f, 0x41, 0x05, - 0x44}}, /* 0x2e */ - {{0x5b, 0xff, 0xff, 0x9f, 0x18, 0x14, 0x3d, 0xba, - 0x00, 0x83, 0xff, 0xff, 0x3e, 0x0f, 0x41, 0x05, - 0x44}}, /* 0x2f */ - {{0x5d, 0xff, 0xff, 0x81, 0x19, 0x95, 0x41, 0xba, - 0x00, 0x84, 0xff, 0xff, 0x42, 0x0f, 0x41, 0x05, - 0x44}}, /* 0x30 */ - {{0x55, 0xff, 0xff, 0x99, 0x0d, 0x0c, 0x3e, 0xba, - 0x00, 0x84, 0xff, 0xff, 0x3f, 0x0f, 0x41, 0x05, - 0x00}}, /* 0x31 */ - {{0x7f, 0x63, 0x63, 0x83, 0x6c, 0x1c, 0x72, 0xba, - 0x27, 0x8b, 0xdf, 0xdf, 0x73, 0x00, 0x00, 0x06, - 0x01}}, /* 0x32 */ - {{0x7f, 0x63, 0x63, 0x83, 0x69, 0x13, 0x6f, 0xba, - 0x26, 0x89, 0xdf, 0xdf, 0x6f, 0x00, 0x00, 0x06, - 0x01}}, /* 0x33 */ - {{0x7f, 0x63, 0x63, 0x82, 0x6b, 0x13, 0x75, 0xba, - 0x29, 0x8c, 0xdf, 0xdf, 0x75, 0x00, 0x00, 0x06, - 0x01}}, /* 0x34 */ - {{0xa3, 0x7f, 0x7f, 0x87, 0x86, 0x97, 0x24, 0xf1, - 0xaf, 0x85, 0x3f, 0x3f, 0x25, 0x30, 0x00, 0x02, - 0x01}}, /* 0x35 */ - {{0x9f, 0x7f, 0x7f, 0x83, 0x85, 0x91, 0x1e, 0xf1, - 0xad, 0x81, 0x3f, 0x3f, 0x1f, 0x30, 0x00, 0x02, - 0x01}}, /* 0x36 */ - {{0xa7, 0x7f, 0x7f, 0x88, 0x89, 0x95, 0x26, 0xf1, - 0xb1, 0x85, 0x3f, 0x3f, 0x27, 0x30, 0x00, 0x02, - 0x01}}, /* 0x37 */ - {{0xce, 0x9f, 0x9f, 0x92, 0xa9, 0x17, 0x28, 0xc4, - 0x7a, 0x8e, 0xcf, 0xcf, 0x29, 0x21, 0x00, 0x07, - 0x01}}, /* 0x38 */ - {{0xce, 0x9f, 0x9f, 0x92, 0xa5, 0x17, 0x28, 0xd4, - 0x7a, 0x8e, 0xcf, 0xcf, 0x29, 0x21, 0x00, 0x07, - 0x01}}, /* 0x39 */ - {{0xd3, 0x9f, 0x9f, 0x97, 0xab, 0x1f, 0x2e, 0xd4, - 0x7d, 0x81, 0xcf, 0xcf, 0x2f, 0x21, 0x00, 0x07, - 0x01}}, /* 0x3a */ - {{0xdc, 0x9f, 0x9f, 0x80, 0xaf, 0x9d, 0xe6, 0xff, - 0xc0, 0x83, 0xbf, 0xbf, 0xe7, 0x10, 0x00, 0x07, - 0x01}}, /* 0x3b */ - {{0x6b, 0x59, 0x59, 0x8f, 0x5e, 0x8c, 0x0b, 0x3e, - 0xe9, 0x8b, 0xdf, 0xe7, 0x04, 0x00, 0x00, 0x05, - 0x00}}, /* 0x3c */ - {{0x6d, 0x59, 0x59, 0x91, 0x60, 0x89, 0x53, 0xf0, - 0x41, 0x84, 0x3f, 0x3f, 0x54, 0x00, 0x00, 0x05, - 0x41}}, /* 0x3d */ - {{0x86, 0x6a, 0x6a, 0x8a, 0x74, 0x06, 0x8c, 0x15, - 0x4f, 0x83, 0xef, 0xef, 0x8d, 0x30, 0x00, 0x02, - 0x00}}, /* 0x3e */ - {{0x81, 0x6a, 0x6a, 0x85, 0x70, 0x00, 0x0f, 0x3e, - 0xeb, 0x8e, 0xdf, 0xdf, 0x10, 0x00, 0x00, 0x02, - 0x00}}, /* 0x3f */ - {{0xa3, 0x7f, 0x7f, 0x87, 0x86, 0x97, 0x1e, 0xf1, - 0xae, 0x85, 0x57, 0x57, 0x1f, 0x30, 0x00, 0x02, - 0x01}}, /* 0x40 */ - {{0xa3, 0x7f, 0x7f, 0x87, 0x86, 0x97, 0x24, 0xf5, - 0x02, 0x88, 0xff, 0xff, 0x25, 0x10, 0x00, 0x02, - 0x01}}, /* 0x41 */ - {{0xce, 0x9f, 0x9f, 0x92, 0xa9, 0x17, 0x20, 0xf5, - 0x03, 0x88, 0xff, 0xff, 0x21, 0x10, 0x00, 0x07, - 0x01}}, /* 0x42 */ - {{0xe6, 0xae, 0xae, 0x8a, 0xbd, 0x90, 0x3d, 0x10, - 0x1a, 0x8d, 0x19, 0x19, 0x3e, 0x2f, 0x00, 0x03, - 0x00}}, /* 0x43 */ - {{0xc3, 0x8f, 0x8f, 0x87, 0x9b, 0x0b, 0x82, 0xef, - 0x60, 0x83, 0x5f, 0x5f, 0x83, 0x10, 0x00, 0x07, - 0x01}}, /* 0x44 */ - {{0x86, 0x69, 0x69, 0x8A, 0x74, 0x06, 0x8C, 0x15, - 0x4F, 0x83, 0xEF, 0xEF, 0x8D, 0x30, 0x00, 0x02, - 0x00}}, /* 0x45 */ - {{0x83, 0x69, 0x69, 0x87, 0x6f, 0x1d, 0x03, 0x3E, - 0xE5, 0x8d, 0xDF, 0xe4, 0x04, 0x00, 0x00, 0x06, - 0x00}}, /* 0x46 */ - {{0x86, 0x6A, 0x6A, 0x8A, 0x74, 0x06, 0x8C, 0x15, - 0x4F, 0x83, 0xEF, 0xEF, 0x8D, 0x30, 0x00, 0x02, - 0x00}}, /* 0x47 */ - {{0x81, 0x6A, 0x6A, 0x85, 0x70, 0x00, 0x0F, 0x3E, - 0xEB, 0x8E, 0xDF, 0xDF, 0x10, 0x00, 0x00, 0x02, - 0x00}}, /* 0x48 */ - {{0xdd, 0xa9, 0xa9, 0x81, 0xb4, 0x97, 0x26, 0xfd, - 0x01, 0x8d, 0xff, 0x00, 0x27, 0x10, 0x00, 0x03, - 0x01}}, /* 0x49 */ - {{0xd9, 0x8f, 0x8f, 0x9d, 0xba, 0x0a, 0x8a, 0xff, - 0x60, 0x8b, 0x5f, 0x5f, 0x8b, 0x10, 0x00, 0x03, - 0x01}}, /* 0x4a */ - {{0xea, 0xae, 0xae, 0x8e, 0xba, 0x82, 0x40, 0x10, - 0x1b, 0x87, 0x19, 0x1a, 0x41, 0x0f, 0x00, 0x03, - 0x00}}, /* 0x4b */ - {{0xd3, 0x9f, 0x9f, 0x97, 0xab, 0x1f, 0xf1, 0xff, - 0xc0, 0x83, 0xbf, 0xbf, 0xf2, 0x10, 0x00, 0x07, - 0x01}}, /* 0x4c */ - {{0x75, 0x5f, 0x5f, 0x99, 0x66, 0x90, 0x53, 0xf0, - 0x41, 0x84, 0x3f, 0x3f, 0x54, 0x00, 0x00, 0x05, - 0x41}}, - {{0x2d, 0x27, 0x28, 0x90, 0x2c, 0x80, 0x0b, 0x3e, - 0xe9, 0x8b, 0xdf, 0xe7, 0x04, 0x00, 0x00, 0x00, - 0x00}}, /* 0x4e */ - {{0xcd, 0x9f, 0x9f, 0x91, 0xab, 0x1c, 0x3a, 0xff, - 0x20, 0x83, 0x1f, 0x1f, 0x3b, 0x10, 0x00, 0x07, - 0x21}}, /* 0x4f */ - {{0x15, 0xd1, 0xd1, 0x99, 0xe2, 0x19, 0x3d, 0x10, - 0x1a, 0x8d, 0x19, 0x19, 0x3e, 0x2f, 0x01, 0x0c, - 0x20}}, /* 0x50 */ - {{0x0e, 0xef, 0xef, 0x92, 0xfe, 0x03, 0x30, 0xf0, - 0x1e, 0x83, 0x1b, 0x1c, 0x31, 0x00, 0x01, 0x00, - 0x61}}, /* 0x51 */ - {{0x85, 0x77, 0x77, 0x89, 0x7d, 0x01, 0x31, 0xf0, - 0x1e, 0x84, 0x1b, 0x1c, 0x32, 0x00, 0x00, 0x02, - 0x41}}, /* 0x52 */ - {{0x87, 0x77, 0x77, 0x8b, 0x81, 0x0b, 0x68, 0xf0, - 0x5a, 0x80, 0x57, 0x57, 0x69, 0x00, 0x00, 0x02, - 0x01}}, /* 0x53 */ - {{0xcd, 0x8f, 0x8f, 0x91, 0x9b, 0x1b, 0x7a, 0xff, - 0x64, 0x8c, 0x5f, 0x62, 0x7b, 0x10, 0x00, 0x07, - 0x41}} /* 0x54 */ -}; - -static const struct SiS_VCLKData SiSUSB_VCLKData[] = { - {0x1b, 0xe1, 25}, /* 0x00 */ - {0x4e, 0xe4, 28}, /* 0x01 */ - {0x57, 0xe4, 31}, /* 0x02 */ - {0xc3, 0xc8, 36}, /* 0x03 */ - {0x42, 0xe2, 40}, /* 0x04 */ - {0xfe, 0xcd, 43}, /* 0x05 */ - {0x5d, 0xc4, 44}, /* 0x06 */ - {0x52, 0xe2, 49}, /* 0x07 */ - {0x53, 0xe2, 50}, /* 0x08 */ - {0x74, 0x67, 52}, /* 0x09 */ - {0x6d, 0x66, 56}, /* 0x0a */ - {0x5a, 0x64, 65}, /* 0x0b */ - {0x46, 0x44, 67}, /* 0x0c */ - {0xb1, 0x46, 68}, /* 0x0d */ - {0xd3, 0x4a, 72}, /* 0x0e */ - {0x29, 0x61, 75}, /* 0x0f */ - {0x6e, 0x46, 76}, /* 0x10 */ - {0x2b, 0x61, 78}, /* 0x11 */ - {0x31, 0x42, 79}, /* 0x12 */ - {0xab, 0x44, 83}, /* 0x13 */ - {0x46, 0x25, 84}, /* 0x14 */ - {0x78, 0x29, 86}, /* 0x15 */ - {0x62, 0x44, 94}, /* 0x16 */ - {0x2b, 0x41, 104}, /* 0x17 */ - {0x3a, 0x23, 105}, /* 0x18 */ - {0x70, 0x44, 108}, /* 0x19 */ - {0x3c, 0x23, 109}, /* 0x1a */ - {0x5e, 0x43, 113}, /* 0x1b */ - {0xbc, 0x44, 116}, /* 0x1c */ - {0xe0, 0x46, 132}, /* 0x1d */ - {0x54, 0x42, 135}, /* 0x1e */ - {0xea, 0x2a, 139}, /* 0x1f */ - {0x41, 0x22, 157}, /* 0x20 */ - {0x70, 0x24, 162}, /* 0x21 */ - {0x30, 0x21, 175}, /* 0x22 */ - {0x4e, 0x22, 189}, /* 0x23 */ - {0xde, 0x26, 194}, /* 0x24 */ - {0x62, 0x06, 202}, /* 0x25 */ - {0x3f, 0x03, 229}, /* 0x26 */ - {0xb8, 0x06, 234}, /* 0x27 */ - {0x34, 0x02, 253}, /* 0x28 */ - {0x58, 0x04, 255}, /* 0x29 */ - {0x24, 0x01, 265}, /* 0x2a */ - {0x9b, 0x02, 267}, /* 0x2b */ - {0x70, 0x05, 270}, /* 0x2c */ - {0x25, 0x01, 272}, /* 0x2d */ - {0x9c, 0x02, 277}, /* 0x2e */ - {0x27, 0x01, 286}, /* 0x2f */ - {0x3c, 0x02, 291}, /* 0x30 */ - {0xef, 0x0a, 292}, /* 0x31 */ - {0xf6, 0x0a, 310}, /* 0x32 */ - {0x95, 0x01, 315}, /* 0x33 */ - {0xf0, 0x09, 324}, /* 0x34 */ - {0xfe, 0x0a, 331}, /* 0x35 */ - {0xf3, 0x09, 332}, /* 0x36 */ - {0xea, 0x08, 340}, /* 0x37 */ - {0xe8, 0x07, 376}, /* 0x38 */ - {0xde, 0x06, 389}, /* 0x39 */ - {0x52, 0x2a, 54}, /* 0x3a 301 TV */ - {0x52, 0x6a, 27}, /* 0x3b 301 TV */ - {0x62, 0x24, 70}, /* 0x3c 301 TV */ - {0x62, 0x64, 70}, /* 0x3d 301 TV */ - {0xa8, 0x4c, 30}, /* 0x3e 301 TV */ - {0x20, 0x26, 33}, /* 0x3f 301 TV */ - {0x31, 0xc2, 39}, /* 0x40 */ - {0x60, 0x36, 30}, /* 0x41 Chrontel */ - {0x40, 0x4a, 28}, /* 0x42 Chrontel */ - {0x9f, 0x46, 44}, /* 0x43 Chrontel */ - {0x97, 0x2c, 26}, /* 0x44 */ - {0x44, 0xe4, 25}, /* 0x45 Chrontel */ - {0x7e, 0x32, 47}, /* 0x46 Chrontel */ - {0x8a, 0x24, 31}, /* 0x47 Chrontel */ - {0x97, 0x2c, 26}, /* 0x48 Chrontel */ - {0xce, 0x3c, 39}, /* 0x49 */ - {0x52, 0x4a, 36}, /* 0x4a Chrontel */ - {0x34, 0x61, 95}, /* 0x4b */ - {0x78, 0x27, 108}, /* 0x4c - was 102 */ - {0x66, 0x43, 123}, /* 0x4d Modes 0x26-0x28 (1400x1050) */ - {0x41, 0x4e, 21}, /* 0x4e */ - {0xa1, 0x4a, 29}, /* 0x4f Chrontel */ - {0x19, 0x42, 42}, /* 0x50 */ - {0x54, 0x46, 58}, /* 0x51 Chrontel */ - {0x25, 0x42, 61}, /* 0x52 */ - {0x44, 0x44, 66}, /* 0x53 Chrontel */ - {0x3a, 0x62, 70}, /* 0x54 Chrontel */ - {0x62, 0xc6, 34}, /* 0x55 848x480-60 */ - {0x6a, 0xc6, 37}, /* 0x56 848x480-75 - TEMP */ - {0xbf, 0xc8, 35}, /* 0x57 856x480-38i,60 */ - {0x30, 0x23, 88}, /* 0x58 1360x768-62 (is 60Hz!) */ - {0x52, 0x07, 149}, /* 0x59 1280x960-85 */ - {0x56, 0x07, 156}, /* 0x5a 1400x1050-75 */ - {0x70, 0x29, 81}, /* 0x5b 1280x768 LCD */ - {0x45, 0x25, 83}, /* 0x5c 1280x800 */ - {0x70, 0x0a, 147}, /* 0x5d 1680x1050 */ - {0x70, 0x24, 162}, /* 0x5e 1600x1200 */ - {0x5a, 0x64, 65}, /* 0x5f 1280x720 - temp */ - {0x63, 0x46, 68}, /* 0x60 1280x768_2 */ - {0x31, 0x42, 79}, /* 0x61 1280x768_3 - temp */ - {0, 0, 0}, /* 0x62 - custom (will be filled out at run-time) */ - {0x5a, 0x64, 65}, /* 0x63 1280x720 (LCD LVDS) */ - {0x70, 0x28, 90}, /* 0x64 1152x864@60 */ - {0x41, 0xc4, 32}, /* 0x65 848x480@60 */ - {0x5c, 0xc6, 32}, /* 0x66 856x480@60 */ - {0x76, 0xe7, 27}, /* 0x67 720x480@60 */ - {0x5f, 0xc6, 33}, /* 0x68 720/768x576@60 */ - {0x52, 0x27, 75}, /* 0x69 1920x1080i 60Hz interlaced */ - {0x7c, 0x6b, 38}, /* 0x6a 960x540@60 */ - {0xe3, 0x56, 41}, /* 0x6b 960x600@60 */ - {0x45, 0x25, 83}, /* 0x6c 1280x800 */ - {0x70, 0x28, 90}, /* 0x6d 1152x864@60 */ - {0x15, 0xe1, 20}, /* 0x6e 640x400@60 (fake, not actually used) */ - {0x5f, 0xc6, 33}, /* 0x6f 720x576@60 */ - {0x37, 0x5a, 10}, /* 0x70 320x200@60 (fake, not actually used) */ - {0x2b, 0xc2, 35} /* 0x71 768@576@60 */ -}; - int SiSUSBSetMode(struct SiS_Private *SiS_Pr, unsigned short ModeNo); int SiSUSBSetVESAMode(struct SiS_Private *SiS_Pr, unsigned short VModeNo); diff --git a/drivers/usb/misc/sisusbvga/sisusb_tables.h b/drivers/usb/misc/sisusbvga/sisusb_tables.h new file mode 100644 index 000000000000..56972f1ec280 --- /dev/null +++ b/drivers/usb/misc/sisusbvga/sisusb_tables.h @@ -0,0 +1,688 @@ +/* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */ +/* $XFree86$ */ +/* $XdotOrg$ */ +/* + * Data tables for init.c + * + * Copyright (C) 2001-2005 by Thomas Winischhofer, Vienna, Austria + * + * If distributed as part of the Linux kernel, the following license terms + * apply: + * + * * This program is free software; you can redistribute it and/or modify + * * it under the terms of the GNU General Public License as published by + * * the Free Software Foundation; either version 2 of the named License, + * * or any later version. + * * + * * This program is distributed in the hope that it will be useful, + * * but WITHOUT ANY WARRANTY; without even the implied warranty of + * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * * GNU General Public License for more details. + * * + * * You should have received a copy of the GNU General Public License + * * along with this program; if not, write to the Free Software + * * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA + * + * Otherwise, the following license terms apply: + * + * * Redistribution and use in source and binary forms, with or without + * * modification, are permitted provided that the following conditions + * * are met: + * * 1) Redistributions of source code must retain the above copyright + * * notice, this list of conditions and the following disclaimer. + * * 2) Redistributions in binary form must reproduce the above copyright + * * notice, this list of conditions and the following disclaimer in the + * * documentation and/or other materials provided with the distribution. + * * 3) The name of the author may not be used to endorse or promote products + * * derived from this software without specific prior written permission. + * * + * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Author: Thomas Winischhofer + * + */ + +#ifndef _SISUSB_TABLES_H_ +#define _SISUSB_TABLES_H_ + +static const unsigned char SiS_MDA_DAC[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, + 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, + 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, + 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, + 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F +}; + +static const unsigned char SiS_CGA_DAC[] = { + 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15, + 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15, + 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F, + 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F, + 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15, + 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15, + 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F, + 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F +}; + +static const unsigned char SiS_EGA_DAC[] = { + 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x05, 0x15, + 0x20, 0x30, 0x24, 0x34, 0x21, 0x31, 0x25, 0x35, + 0x08, 0x18, 0x0C, 0x1C, 0x09, 0x19, 0x0D, 0x1D, + 0x28, 0x38, 0x2C, 0x3C, 0x29, 0x39, 0x2D, 0x3D, + 0x02, 0x12, 0x06, 0x16, 0x03, 0x13, 0x07, 0x17, + 0x22, 0x32, 0x26, 0x36, 0x23, 0x33, 0x27, 0x37, + 0x0A, 0x1A, 0x0E, 0x1E, 0x0B, 0x1B, 0x0F, 0x1F, + 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F +}; + +static const unsigned char SiS_VGA_DAC[] = { + 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15, + 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F, + 0x00, 0x05, 0x08, 0x0B, 0x0E, 0x11, 0x14, 0x18, + 0x1C, 0x20, 0x24, 0x28, 0x2D, 0x32, 0x38, 0x3F, + 0x00, 0x10, 0x1F, 0x2F, 0x3F, 0x1F, 0x27, 0x2F, + 0x37, 0x3F, 0x2D, 0x31, 0x36, 0x3A, 0x3F, 0x00, + 0x07, 0x0E, 0x15, 0x1C, 0x0E, 0x11, 0x15, 0x18, + 0x1C, 0x14, 0x16, 0x18, 0x1A, 0x1C, 0x00, 0x04, + 0x08, 0x0C, 0x10, 0x08, 0x0A, 0x0C, 0x0E, 0x10, + 0x0B, 0x0C, 0x0D, 0x0F, 0x10 +}; + +static const struct SiS_St SiSUSB_SModeIDTable[] = { + {0x03, 0x0010, 0x18, 0x02, 0x02, 0x00, 0x01, 0x03, 0x40}, + {0xff, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} +}; + +static const struct SiS_ModeResInfo SiSUSB_ModeResInfo[] = { + {320, 200, 8, 8}, /* 0x00 */ + {320, 240, 8, 8}, /* 0x01 */ + {320, 400, 8, 8}, /* 0x02 */ + {400, 300, 8, 8}, /* 0x03 */ + {512, 384, 8, 8}, /* 0x04 */ + {640, 400, 8, 16}, /* 0x05 */ + {640, 480, 8, 16}, /* 0x06 */ + {800, 600, 8, 16}, /* 0x07 */ + {1024, 768, 8, 16}, /* 0x08 */ + {1280, 1024, 8, 16}, /* 0x09 */ + {1600, 1200, 8, 16}, /* 0x0a */ + {1920, 1440, 8, 16}, /* 0x0b */ + {2048, 1536, 8, 16}, /* 0x0c */ + {720, 480, 8, 16}, /* 0x0d */ + {720, 576, 8, 16}, /* 0x0e */ + {1280, 960, 8, 16}, /* 0x0f */ + {800, 480, 8, 16}, /* 0x10 */ + {1024, 576, 8, 16}, /* 0x11 */ + {1280, 720, 8, 16}, /* 0x12 */ + {856, 480, 8, 16}, /* 0x13 */ + {1280, 768, 8, 16}, /* 0x14 */ + {1400, 1050, 8, 16}, /* 0x15 */ + {1152, 864, 8, 16}, /* 0x16 */ + {848, 480, 8, 16}, /* 0x17 */ + {1360, 768, 8, 16}, /* 0x18 */ + {1024, 600, 8, 16}, /* 0x19 */ + {1152, 768, 8, 16}, /* 0x1a */ + {768, 576, 8, 16}, /* 0x1b */ + {1360, 1024, 8, 16}, /* 0x1c */ + {1680, 1050, 8, 16}, /* 0x1d */ + {1280, 800, 8, 16}, /* 0x1e */ + {1920, 1080, 8, 16}, /* 0x1f */ + {960, 540, 8, 16}, /* 0x20 */ + {960, 600, 8, 16} /* 0x21 */ +}; + +static const struct SiS_StandTable SiSUSB_StandTable[] = { + /* MD_3_400 - mode 0x03 - 400 */ + { + 0x50, 0x18, 0x10, 0x1000, + {0x00, 0x03, 0x00, 0x02}, + 0x67, + {0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, + 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, + 0x9c, 0x8e, 0x8f, 0x28, 0x1f, 0x96, 0xb9, 0xa3, + 0xff}, + {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, + 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, + 0x0c, 0x00, 0x0f, 0x08}, + {0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x00, 0xff} + }, + /* Generic for VGA and higher */ + { + 0x00, 0x00, 0x00, 0x0000, + {0x01, 0x0f, 0x00, 0x0e}, + 0x23, + {0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0x0b, 0x3e, + 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xea, 0x8c, 0xdf, 0x28, 0x40, 0xe7, 0x04, 0xa3, + 0xff}, + {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x01, 0x00, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0f, 0xff} + } +}; + +static const struct SiS_Ext SiSUSB_EModeIDTable[] = { + {0x2e, 0x0a1b, 0x0101, SIS_RI_640x480, 0x00, 0x00, 0x05, 0x05, 0x08, 2}, /* 640x480x8 */ + {0x2f, 0x0a1b, 0x0100, SIS_RI_640x400, 0x00, 0x00, 0x05, 0x05, 0x10, 0}, /* 640x400x8 */ + {0x30, 0x2a1b, 0x0103, SIS_RI_800x600, 0x00, 0x00, 0x07, 0x06, 0x00, 3}, /* 800x600x8 */ + {0x31, 0x4a1b, 0x0000, SIS_RI_720x480, 0x00, 0x00, 0x06, 0x06, 0x11, -1}, /* 720x480x8 */ + {0x32, 0x4a1b, 0x0000, SIS_RI_720x576, 0x00, 0x00, 0x06, 0x06, 0x12, -1}, /* 720x576x8 */ + {0x33, 0x4a1d, 0x0000, SIS_RI_720x480, 0x00, 0x00, 0x06, 0x06, 0x11, -1}, /* 720x480x16 */ + {0x34, 0x6a1d, 0x0000, SIS_RI_720x576, 0x00, 0x00, 0x06, 0x06, 0x12, -1}, /* 720x576x16 */ + {0x35, 0x4a1f, 0x0000, SIS_RI_720x480, 0x00, 0x00, 0x06, 0x06, 0x11, -1}, /* 720x480x32 */ + {0x36, 0x6a1f, 0x0000, SIS_RI_720x576, 0x00, 0x00, 0x06, 0x06, 0x12, -1}, /* 720x576x32 */ + {0x38, 0x0a1b, 0x0105, SIS_RI_1024x768, 0x00, 0x00, 0x08, 0x07, 0x13, 4}, /* 1024x768x8 */ + {0x3a, 0x0e3b, 0x0107, SIS_RI_1280x1024, 0x00, 0x00, 0x00, 0x00, 0x2f, 8}, /* 1280x1024x8 */ + {0x41, 0x9a1d, 0x010e, SIS_RI_320x200, 0x00, 0x00, 0x04, 0x04, 0x1a, 0}, /* 320x200x16 */ + {0x44, 0x0a1d, 0x0111, SIS_RI_640x480, 0x00, 0x00, 0x05, 0x05, 0x08, 2}, /* 640x480x16 */ + {0x47, 0x2a1d, 0x0114, SIS_RI_800x600, 0x00, 0x00, 0x07, 0x06, 0x00, 3}, /* 800x600x16 */ + {0x4a, 0x0a3d, 0x0117, SIS_RI_1024x768, 0x00, 0x00, 0x08, 0x07, 0x13, 4}, /* 1024x768x16 */ + {0x4d, 0x0e7d, 0x011a, SIS_RI_1280x1024, 0x00, 0x00, 0x00, 0x00, 0x2f, 8}, /* 1280x1024x16 */ + {0x50, 0x9a1b, 0x0132, SIS_RI_320x240, 0x00, 0x00, 0x04, 0x04, 0x1b, 2}, /* 320x240x8 */ + {0x51, 0xba1b, 0x0133, SIS_RI_400x300, 0x00, 0x00, 0x07, 0x07, 0x1c, 3}, /* 400x300x8 */ + {0x52, 0xba1b, 0x0134, SIS_RI_512x384, 0x00, 0x00, 0x00, 0x00, 0x1d, 4}, /* 512x384x8 */ + {0x56, 0x9a1d, 0x0135, SIS_RI_320x240, 0x00, 0x00, 0x04, 0x04, 0x1b, 2}, /* 320x240x16 */ + {0x57, 0xba1d, 0x0136, SIS_RI_400x300, 0x00, 0x00, 0x07, 0x07, 0x1c, 3}, /* 400x300x16 */ + {0x58, 0xba1d, 0x0137, SIS_RI_512x384, 0x00, 0x00, 0x00, 0x00, 0x1d, 4}, /* 512x384x16 */ + {0x59, 0x9a1b, 0x0138, SIS_RI_320x200, 0x00, 0x00, 0x04, 0x04, 0x1a, 0}, /* 320x200x8 */ + {0x5c, 0xba1f, 0x0000, SIS_RI_512x384, 0x00, 0x00, 0x00, 0x00, 0x1d, 4}, /* 512x384x32 */ + {0x5d, 0x0a1d, 0x0139, SIS_RI_640x400, 0x00, 0x00, 0x05, 0x07, 0x10, 0}, /* 640x400x16 */ + {0x5e, 0x0a1f, 0x0000, SIS_RI_640x400, 0x00, 0x00, 0x05, 0x07, 0x10, 0}, /* 640x400x32 */ + {0x62, 0x0a3f, 0x013a, SIS_RI_640x480, 0x00, 0x00, 0x05, 0x05, 0x08, 2}, /* 640x480x32 */ + {0x63, 0x2a3f, 0x013b, SIS_RI_800x600, 0x00, 0x00, 0x07, 0x06, 0x00, 3}, /* 800x600x32 */ + {0x64, 0x0a7f, 0x013c, SIS_RI_1024x768, 0x00, 0x00, 0x08, 0x07, 0x13, 4}, /* 1024x768x32 */ + {0x65, 0x0eff, 0x013d, SIS_RI_1280x1024, 0x00, 0x00, 0x00, 0x00, 0x2f, 8}, /* 1280x1024x32 */ + {0x70, 0x6a1b, 0x0000, SIS_RI_800x480, 0x00, 0x00, 0x07, 0x07, 0x1e, -1}, /* 800x480x8 */ + {0x71, 0x4a1b, 0x0000, SIS_RI_1024x576, 0x00, 0x00, 0x00, 0x00, 0x21, -1}, /* 1024x576x8 */ + {0x74, 0x4a1d, 0x0000, SIS_RI_1024x576, 0x00, 0x00, 0x00, 0x00, 0x21, -1}, /* 1024x576x16 */ + {0x75, 0x0a3d, 0x0000, SIS_RI_1280x720, 0x00, 0x00, 0x00, 0x00, 0x24, 5}, /* 1280x720x16 */ + {0x76, 0x6a1f, 0x0000, SIS_RI_800x480, 0x00, 0x00, 0x07, 0x07, 0x1e, -1}, /* 800x480x32 */ + {0x77, 0x4a1f, 0x0000, SIS_RI_1024x576, 0x00, 0x00, 0x00, 0x00, 0x21, -1}, /* 1024x576x32 */ + {0x78, 0x0a3f, 0x0000, SIS_RI_1280x720, 0x00, 0x00, 0x00, 0x00, 0x24, 5}, /* 1280x720x32 */ + {0x79, 0x0a3b, 0x0000, SIS_RI_1280x720, 0x00, 0x00, 0x00, 0x00, 0x24, 5}, /* 1280x720x8 */ + {0x7a, 0x6a1d, 0x0000, SIS_RI_800x480, 0x00, 0x00, 0x07, 0x07, 0x1e, -1}, /* 800x480x16 */ + {0x23, 0x0e3b, 0x0000, SIS_RI_1280x768, 0x00, 0x00, 0x00, 0x00, 0x27, 6}, /* 1280x768x8 */ + {0x24, 0x0e7d, 0x0000, SIS_RI_1280x768, 0x00, 0x00, 0x00, 0x00, 0x27, 6}, /* 1280x768x16 */ + {0x25, 0x0eff, 0x0000, SIS_RI_1280x768, 0x00, 0x00, 0x00, 0x00, 0x27, 6}, /* 1280x768x32 */ + {0x39, 0x6a1b, 0x0000, SIS_RI_848x480, 0x00, 0x00, 0x00, 0x00, 0x28, -1}, /* 848x480 */ + {0x3b, 0x6a3d, 0x0000, SIS_RI_848x480, 0x00, 0x00, 0x00, 0x00, 0x28, + -1}, + {0x3e, 0x6a7f, 0x0000, SIS_RI_848x480, 0x00, 0x00, 0x00, 0x00, 0x28, + -1}, + {0x3f, 0x6a1b, 0x0000, SIS_RI_856x480, 0x00, 0x00, 0x00, 0x00, 0x2a, -1}, /* 856x480 */ + {0x42, 0x6a3d, 0x0000, SIS_RI_856x480, 0x00, 0x00, 0x00, 0x00, 0x2a, + -1}, + {0x45, 0x6a7f, 0x0000, SIS_RI_856x480, 0x00, 0x00, 0x00, 0x00, 0x2a, + -1}, + {0x4f, 0x9a1f, 0x0000, SIS_RI_320x200, 0x00, 0x00, 0x04, 0x04, 0x1a, 0}, /* 320x200x32 */ + {0x53, 0x9a1f, 0x0000, SIS_RI_320x240, 0x00, 0x00, 0x04, 0x04, 0x1b, 2}, /* 320x240x32 */ + {0x54, 0xba1f, 0x0000, SIS_RI_400x300, 0x00, 0x00, 0x07, 0x07, 0x1c, 3}, /* 400x300x32 */ + {0x5f, 0x6a1b, 0x0000, SIS_RI_768x576, 0x00, 0x00, 0x06, 0x06, 0x2c, -1}, /* 768x576 */ + {0x60, 0x6a1d, 0x0000, SIS_RI_768x576, 0x00, 0x00, 0x06, 0x06, 0x2c, + -1}, + {0x61, 0x6a3f, 0x0000, SIS_RI_768x576, 0x00, 0x00, 0x06, 0x06, 0x2c, + -1}, + {0x1d, 0x6a1b, 0x0000, SIS_RI_960x540, 0x00, 0x00, 0x00, 0x00, 0x2d, -1}, /* 960x540 */ + {0x1e, 0x6a3d, 0x0000, SIS_RI_960x540, 0x00, 0x00, 0x00, 0x00, 0x2d, + -1}, + {0x1f, 0x6a7f, 0x0000, SIS_RI_960x540, 0x00, 0x00, 0x00, 0x00, 0x2d, + -1}, + {0x20, 0x6a1b, 0x0000, SIS_RI_960x600, 0x00, 0x00, 0x00, 0x00, 0x2e, -1}, /* 960x600 */ + {0x21, 0x6a3d, 0x0000, SIS_RI_960x600, 0x00, 0x00, 0x00, 0x00, 0x2e, + -1}, + {0x22, 0x6a7f, 0x0000, SIS_RI_960x600, 0x00, 0x00, 0x00, 0x00, 0x2e, + -1}, + {0x29, 0x4e1b, 0x0000, SIS_RI_1152x864, 0x00, 0x00, 0x00, 0x00, 0x33, -1}, /* 1152x864 */ + {0x2a, 0x4e3d, 0x0000, SIS_RI_1152x864, 0x00, 0x00, 0x00, 0x00, 0x33, + -1}, + {0x2b, 0x4e7f, 0x0000, SIS_RI_1152x864, 0x00, 0x00, 0x00, 0x00, 0x33, + -1}, + {0xff, 0x0000, 0x0000, 0, 0x00, 0x00, 0x00, 0x00, 0x00, -1} +}; + +static const struct SiS_Ext2 SiSUSB_RefIndex[] = { + {0x085f, 0x0d, 0x03, 0x05, 0x05, 0x30, 800, 600, 0x40, 0x00, 0x00}, /* 0x0 */ + {0x0067, 0x0e, 0x04, 0x05, 0x05, 0x30, 800, 600, 0x40, 0x00, 0x00}, /* 0x1 */ + {0x0067, 0x0f, 0x08, 0x48, 0x05, 0x30, 800, 600, 0x40, 0x00, 0x00}, /* 0x2 */ + {0x0067, 0x10, 0x07, 0x8b, 0x05, 0x30, 800, 600, 0x40, 0x00, 0x00}, /* 0x3 */ + {0x0047, 0x11, 0x0a, 0x00, 0x05, 0x30, 800, 600, 0x40, 0x00, 0x00}, /* 0x4 */ + {0x0047, 0x12, 0x0d, 0x00, 0x05, 0x30, 800, 600, 0x40, 0x00, 0x00}, /* 0x5 */ + {0x0047, 0x13, 0x13, 0x00, 0x05, 0x30, 800, 600, 0x20, 0x00, 0x00}, /* 0x6 */ + {0x0107, 0x14, 0x1c, 0x00, 0x05, 0x30, 800, 600, 0x20, 0x00, 0x00}, /* 0x7 */ + {0xc85f, 0x05, 0x00, 0x04, 0x04, 0x2e, 640, 480, 0x40, 0x00, 0x00}, /* 0x8 */ + {0xc067, 0x06, 0x02, 0x04, 0x04, 0x2e, 640, 480, 0x40, 0x00, 0x00}, /* 0x9 */ + {0xc067, 0x07, 0x02, 0x47, 0x04, 0x2e, 640, 480, 0x40, 0x00, 0x00}, /* 0xa */ + {0xc067, 0x08, 0x03, 0x8a, 0x04, 0x2e, 640, 480, 0x40, 0x00, 0x00}, /* 0xb */ + {0xc047, 0x09, 0x05, 0x00, 0x04, 0x2e, 640, 480, 0x40, 0x00, 0x00}, /* 0xc */ + {0xc047, 0x0a, 0x09, 0x00, 0x04, 0x2e, 640, 480, 0x40, 0x00, 0x00}, /* 0xd */ + {0xc047, 0x0b, 0x0e, 0x00, 0x04, 0x2e, 640, 480, 0x40, 0x00, 0x00}, /* 0xe */ + {0xc047, 0x0c, 0x15, 0x00, 0x04, 0x2e, 640, 480, 0x40, 0x00, 0x00}, /* 0xf */ + {0x487f, 0x04, 0x00, 0x00, 0x00, 0x2f, 640, 400, 0x30, 0x55, 0x6e}, /* 0x10 */ + {0xc06f, 0x3c, 0x01, 0x06, 0x13, 0x31, 720, 480, 0x30, 0x00, 0x00}, /* 0x11 */ + {0x006f, 0x3d, 0x6f, 0x06, 0x14, 0x32, 720, 576, 0x30, 0x00, 0x00}, /* 0x12 (6f was 03) */ + {0x0087, 0x15, 0x06, 0x00, 0x06, 0x38, 1024, 768, 0x30, 0x00, 0x00}, /* 0x13 */ + {0xc877, 0x16, 0x0b, 0x06, 0x06, 0x38, 1024, 768, 0x20, 0x00, 0x00}, /* 0x14 */ + {0xc067, 0x17, 0x0f, 0x49, 0x06, 0x38, 1024, 768, 0x20, 0x00, 0x00}, /* 0x15 */ + {0x0067, 0x18, 0x11, 0x00, 0x06, 0x38, 1024, 768, 0x20, 0x00, 0x00}, /* 0x16 */ + {0x0047, 0x19, 0x16, 0x8c, 0x06, 0x38, 1024, 768, 0x20, 0x00, 0x00}, /* 0x17 */ + {0x0107, 0x1a, 0x1b, 0x00, 0x06, 0x38, 1024, 768, 0x10, 0x00, 0x00}, /* 0x18 */ + {0x0107, 0x1b, 0x1f, 0x00, 0x06, 0x38, 1024, 768, 0x10, 0x00, 0x00}, /* 0x19 */ + {0x407f, 0x00, 0x00, 0x00, 0x00, 0x41, 320, 200, 0x30, 0x56, 0x4e}, /* 0x1a */ + {0xc07f, 0x01, 0x00, 0x04, 0x04, 0x50, 320, 240, 0x30, 0x00, 0x00}, /* 0x1b */ + {0x007f, 0x02, 0x04, 0x05, 0x05, 0x51, 400, 300, 0x30, 0x00, 0x00}, /* 0x1c */ + {0xc077, 0x03, 0x0b, 0x06, 0x06, 0x52, 512, 384, 0x30, 0x00, 0x00}, /* 0x1d */ + {0x0077, 0x32, 0x40, 0x08, 0x18, 0x70, 800, 480, 0x30, 0x00, 0x00}, /* 0x1e */ + {0x0047, 0x33, 0x07, 0x08, 0x18, 0x70, 800, 480, 0x30, 0x00, 0x00}, /* 0x1f */ + {0x0047, 0x34, 0x0a, 0x08, 0x18, 0x70, 800, 480, 0x30, 0x00, 0x00}, /* 0x20 */ + {0x0077, 0x35, 0x0b, 0x09, 0x19, 0x71, 1024, 576, 0x30, 0x00, 0x00}, /* 0x21 */ + {0x0047, 0x36, 0x11, 0x09, 0x19, 0x71, 1024, 576, 0x30, 0x00, 0x00}, /* 0x22 */ + {0x0047, 0x37, 0x16, 0x09, 0x19, 0x71, 1024, 576, 0x30, 0x00, 0x00}, /* 0x23 */ + {0x1137, 0x38, 0x19, 0x0a, 0x0c, 0x75, 1280, 720, 0x30, 0x00, 0x00}, /* 0x24 */ + {0x1107, 0x39, 0x1e, 0x0a, 0x0c, 0x75, 1280, 720, 0x30, 0x00, 0x00}, /* 0x25 */ + {0x1307, 0x3a, 0x20, 0x0a, 0x0c, 0x75, 1280, 720, 0x30, 0x00, 0x00}, /* 0x26 */ + {0x0077, 0x42, 0x5b, 0x08, 0x11, 0x23, 1280, 768, 0x30, 0x00, 0x00}, /* 0x27 */ + {0x0087, 0x45, 0x57, 0x00, 0x16, 0x39, 848, 480, 0x30, 0x00, 0x00}, /* 0x28 38Hzi */ + {0xc067, 0x46, 0x55, 0x0b, 0x16, 0x39, 848, 480, 0x30, 0x00, 0x00}, /* 0x29 848x480-60Hz */ + {0x0087, 0x47, 0x57, 0x00, 0x17, 0x3f, 856, 480, 0x30, 0x00, 0x00}, /* 0x2a 856x480-38Hzi */ + {0xc067, 0x48, 0x57, 0x00, 0x17, 0x3f, 856, 480, 0x30, 0x00, 0x00}, /* 0x2b 856x480-60Hz */ + {0x006f, 0x4d, 0x71, 0x06, 0x15, 0x5f, 768, 576, 0x30, 0x00, 0x00}, /* 0x2c 768x576-56Hz */ + {0x0067, 0x52, 0x6a, 0x00, 0x1c, 0x1d, 960, 540, 0x30, 0x00, 0x00}, /* 0x2d 960x540 60Hz */ + {0x0077, 0x53, 0x6b, 0x0b, 0x1d, 0x20, 960, 600, 0x30, 0x00, 0x00}, /* 0x2e 960x600 60Hz */ + {0x0087, 0x1c, 0x11, 0x00, 0x07, 0x3a, 1280, 1024, 0x30, 0x00, 0x00}, /* 0x2f */ + {0x0137, 0x1d, 0x19, 0x07, 0x07, 0x3a, 1280, 1024, 0x00, 0x00, 0x00}, /* 0x30 */ + {0x0107, 0x1e, 0x1e, 0x00, 0x07, 0x3a, 1280, 1024, 0x00, 0x00, 0x00}, /* 0x31 */ + {0x0207, 0x1f, 0x20, 0x00, 0x07, 0x3a, 1280, 1024, 0x00, 0x00, 0x00}, /* 0x32 */ + {0x0127, 0x54, 0x6d, 0x00, 0x1a, 0x29, 1152, 864, 0x30, 0x00, 0x00}, /* 0x33 1152x864-60Hz */ + {0x0127, 0x44, 0x19, 0x00, 0x1a, 0x29, 1152, 864, 0x30, 0x00, 0x00}, /* 0x34 1152x864-75Hz */ + {0x0127, 0x4a, 0x1e, 0x00, 0x1a, 0x29, 1152, 864, 0x30, 0x00, 0x00}, /* 0x35 1152x864-85Hz */ + {0xffff, 0x00, 0x00, 0x00, 0x00, 0x00, 0, 0, 0, 0x00, 0x00} +}; + +static const struct SiS_CRT1Table SiSUSB_CRT1Table[] = { + {{0x2d, 0x27, 0x28, 0x90, 0x2c, 0x80, 0xbf, 0x1f, + 0x9c, 0x8e, 0x8f, 0x96, 0xb9, 0x30, 0x00, 0x00, + 0x00}}, /* 0x0 */ + {{0x2d, 0x27, 0x28, 0x90, 0x2c, 0x80, 0x0b, 0x3e, + 0xe9, 0x8b, 0xdf, 0xe7, 0x04, 0x00, 0x00, 0x00, + 0x00}}, /* 0x1 */ + {{0x3d, 0x31, 0x31, 0x81, 0x37, 0x1f, 0x72, 0xf0, + 0x58, 0x8c, 0x57, 0x57, 0x73, 0x20, 0x00, 0x05, + 0x01}}, /* 0x2 */ + {{0x4f, 0x3f, 0x3f, 0x93, 0x45, 0x0d, 0x24, 0xf5, + 0x02, 0x88, 0xff, 0xff, 0x25, 0x10, 0x00, 0x01, + 0x01}}, /* 0x3 */ + {{0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, + 0x9c, 0x8e, 0x8f, 0x96, 0xb9, 0x30, 0x00, 0x05, + 0x00}}, /* 0x4 */ + {{0x5f, 0x4f, 0x4f, 0x83, 0x55, 0x81, 0x0b, 0x3e, + 0xe9, 0x8b, 0xdf, 0xe8, 0x0c, 0x00, 0x00, 0x05, + 0x00}}, /* 0x5 */ + {{0x63, 0x4f, 0x4f, 0x87, 0x56, 0x9b, 0x06, 0x3e, + 0xe8, 0x8a, 0xdf, 0xe7, 0x07, 0x00, 0x00, 0x01, + 0x00}}, /* 0x6 */ + {{0x64, 0x4f, 0x4f, 0x88, 0x55, 0x9d, 0xf2, 0x1f, + 0xe0, 0x83, 0xdf, 0xdf, 0xf3, 0x10, 0x00, 0x01, + 0x00}}, /* 0x7 */ + {{0x63, 0x4f, 0x4f, 0x87, 0x5a, 0x81, 0xfb, 0x1f, + 0xe0, 0x83, 0xdf, 0xdf, 0xfc, 0x10, 0x00, 0x05, + 0x00}}, /* 0x8 */ + {{0x65, 0x4f, 0x4f, 0x89, 0x58, 0x80, 0xfb, 0x1f, + 0xe0, 0x83, 0xdf, 0xdf, 0xfc, 0x10, 0x00, 0x05, + 0x61}}, /* 0x9 */ + {{0x65, 0x4f, 0x4f, 0x89, 0x58, 0x80, 0x01, 0x3e, + 0xe0, 0x83, 0xdf, 0xdf, 0x02, 0x00, 0x00, 0x05, + 0x61}}, /* 0xa */ + {{0x67, 0x4f, 0x4f, 0x8b, 0x58, 0x81, 0x0d, 0x3e, + 0xe0, 0x83, 0xdf, 0xdf, 0x0e, 0x00, 0x00, 0x05, + 0x61}}, /* 0xb */ + {{0x65, 0x4f, 0x4f, 0x89, 0x57, 0x9f, 0xfb, 0x1f, + 0xe6, 0x8a, 0xdf, 0xdf, 0xfc, 0x10, 0x00, 0x01, + 0x00}}, /* 0xc */ + {{0x7b, 0x63, 0x63, 0x9f, 0x6a, 0x93, 0x6f, 0xf0, + 0x58, 0x8a, 0x57, 0x57, 0x70, 0x20, 0x00, 0x05, + 0x01}}, /* 0xd */ + {{0x7f, 0x63, 0x63, 0x83, 0x6c, 0x1c, 0x72, 0xf0, + 0x58, 0x8c, 0x57, 0x57, 0x73, 0x20, 0x00, 0x06, + 0x01}}, /* 0xe */ + {{0x7d, 0x63, 0x63, 0x81, 0x6e, 0x1d, 0x98, 0xf0, + 0x7c, 0x82, 0x57, 0x57, 0x99, 0x00, 0x00, 0x06, + 0x01}}, /* 0xf */ + {{0x7f, 0x63, 0x63, 0x83, 0x69, 0x13, 0x6f, 0xf0, + 0x58, 0x8b, 0x57, 0x57, 0x70, 0x20, 0x00, 0x06, + 0x01}}, /* 0x10 */ + {{0x7e, 0x63, 0x63, 0x82, 0x6b, 0x13, 0x75, 0xf0, + 0x58, 0x8b, 0x57, 0x57, 0x76, 0x20, 0x00, 0x06, + 0x01}}, /* 0x11 */ + {{0x81, 0x63, 0x63, 0x85, 0x6d, 0x18, 0x7a, 0xf0, + 0x58, 0x8b, 0x57, 0x57, 0x7b, 0x20, 0x00, 0x06, + 0x61}}, /* 0x12 */ + {{0x83, 0x63, 0x63, 0x87, 0x6e, 0x19, 0x81, 0xf0, + 0x58, 0x8b, 0x57, 0x57, 0x82, 0x20, 0x00, 0x06, + 0x61}}, /* 0x13 */ + {{0x85, 0x63, 0x63, 0x89, 0x6f, 0x1a, 0x91, 0xf0, + 0x58, 0x8b, 0x57, 0x57, 0x92, 0x20, 0x00, 0x06, + 0x61}}, /* 0x14 */ + {{0x99, 0x7f, 0x7f, 0x9d, 0x84, 0x1a, 0x96, 0x1f, + 0x7f, 0x83, 0x7f, 0x7f, 0x97, 0x10, 0x00, 0x02, + 0x00}}, /* 0x15 */ + {{0xa3, 0x7f, 0x7f, 0x87, 0x86, 0x97, 0x24, 0xf5, + 0x02, 0x88, 0xff, 0xff, 0x25, 0x10, 0x00, 0x02, + 0x01}}, /* 0x16 */ + {{0xa1, 0x7f, 0x7f, 0x85, 0x86, 0x97, 0x24, 0xf5, + 0x02, 0x88, 0xff, 0xff, 0x25, 0x10, 0x00, 0x02, + 0x01}}, /* 0x17 */ + {{0x9f, 0x7f, 0x7f, 0x83, 0x85, 0x91, 0x1e, 0xf5, + 0x00, 0x83, 0xff, 0xff, 0x1f, 0x10, 0x00, 0x02, + 0x01}}, /* 0x18 */ + {{0xa7, 0x7f, 0x7f, 0x8b, 0x89, 0x95, 0x26, 0xf5, + 0x00, 0x83, 0xff, 0xff, 0x27, 0x10, 0x00, 0x02, + 0x01}}, /* 0x19 */ + {{0xa9, 0x7f, 0x7f, 0x8d, 0x8c, 0x9a, 0x2c, 0xf5, + 0x00, 0x83, 0xff, 0xff, 0x2d, 0x14, 0x00, 0x02, + 0x62}}, /* 0x1a */ + {{0xab, 0x7f, 0x7f, 0x8f, 0x8d, 0x9b, 0x35, 0xf5, + 0x00, 0x83, 0xff, 0xff, 0x36, 0x14, 0x00, 0x02, + 0x62}}, /* 0x1b */ + {{0xcf, 0x9f, 0x9f, 0x93, 0xb2, 0x01, 0x14, 0xba, + 0x00, 0x83, 0xff, 0xff, 0x15, 0x00, 0x00, 0x03, + 0x00}}, /* 0x1c */ + {{0xce, 0x9f, 0x9f, 0x92, 0xa9, 0x17, 0x28, 0x5a, + 0x00, 0x83, 0xff, 0xff, 0x29, 0x09, 0x00, 0x07, + 0x01}}, /* 0x1d */ + {{0xce, 0x9f, 0x9f, 0x92, 0xa5, 0x17, 0x28, 0x5a, + 0x00, 0x83, 0xff, 0xff, 0x29, 0x09, 0x00, 0x07, + 0x01}}, /* 0x1e */ + {{0xd3, 0x9f, 0x9f, 0x97, 0xab, 0x1f, 0x2e, 0x5a, + 0x00, 0x83, 0xff, 0xff, 0x2f, 0x09, 0x00, 0x07, + 0x01}}, /* 0x1f */ + {{0x09, 0xc7, 0xc7, 0x8d, 0xd3, 0x0b, 0xe0, 0x10, + 0xb0, 0x83, 0xaf, 0xaf, 0xe1, 0x2f, 0x01, 0x04, + 0x00}}, /* 0x20 */ + {{0x09, 0xc7, 0xc7, 0x8d, 0xd3, 0x0b, 0xe0, 0x10, + 0xb0, 0x83, 0xaf, 0xaf, 0xe1, 0x2f, 0x01, 0x04, + 0x00}}, /* 0x21 */ + {{0x09, 0xc7, 0xc7, 0x8d, 0xd3, 0x0b, 0xe0, 0x10, + 0xb0, 0x83, 0xaf, 0xaf, 0xe1, 0x2f, 0x01, 0x04, + 0x00}}, /* 0x22 */ + {{0x09, 0xc7, 0xc7, 0x8d, 0xd3, 0x0b, 0xe0, 0x10, + 0xb0, 0x83, 0xaf, 0xaf, 0xe1, 0x2f, 0x01, 0x04, + 0x00}}, /* 0x23 */ + {{0x09, 0xc7, 0xc7, 0x8d, 0xd3, 0x0b, 0xe0, 0x10, + 0xb0, 0x83, 0xaf, 0xaf, 0xe1, 0x2f, 0x01, 0x04, + 0x00}}, /* 0x24 */ + {{0x09, 0xc7, 0xc7, 0x8d, 0xd3, 0x0b, 0xe0, 0x10, + 0xb0, 0x83, 0xaf, 0xaf, 0xe1, 0x2f, 0x01, 0x04, + 0x00}}, /* 0x25 */ + {{0x09, 0xc7, 0xc7, 0x8d, 0xd3, 0x0b, 0xe0, 0x10, + 0xb0, 0x83, 0xaf, 0xaf, 0xe1, 0x2f, 0x01, 0x04, + 0x00}}, /* 0x26 */ + {{0x40, 0xef, 0xef, 0x84, 0x03, 0x1d, 0xda, 0x1f, + 0xa0, 0x83, 0x9f, 0x9f, 0xdb, 0x1f, 0x41, 0x01, + 0x00}}, /* 0x27 */ + {{0x43, 0xef, 0xef, 0x87, 0x06, 0x00, 0xd4, 0x1f, + 0xa0, 0x83, 0x9f, 0x9f, 0xd5, 0x1f, 0x41, 0x05, + 0x63}}, /* 0x28 */ + {{0x45, 0xef, 0xef, 0x89, 0x07, 0x01, 0xd9, 0x1f, + 0xa0, 0x83, 0x9f, 0x9f, 0xda, 0x1f, 0x41, 0x05, + 0x63}}, /* 0x29 */ + {{0x40, 0xef, 0xef, 0x84, 0x03, 0x1d, 0xda, 0x1f, + 0xa0, 0x83, 0x9f, 0x9f, 0xdb, 0x1f, 0x41, 0x01, + 0x00}}, /* 0x2a */ + {{0x40, 0xef, 0xef, 0x84, 0x03, 0x1d, 0xda, 0x1f, + 0xa0, 0x83, 0x9f, 0x9f, 0xdb, 0x1f, 0x41, 0x01, + 0x00}}, /* 0x2b */ + {{0x40, 0xef, 0xef, 0x84, 0x03, 0x1d, 0xda, 0x1f, + 0xa0, 0x83, 0x9f, 0x9f, 0xdb, 0x1f, 0x41, 0x01, + 0x00}}, /* 0x2c */ + {{0x59, 0xff, 0xff, 0x9d, 0x17, 0x13, 0x33, 0xba, + 0x00, 0x83, 0xff, 0xff, 0x34, 0x0f, 0x41, 0x05, + 0x44}}, /* 0x2d */ + {{0x5b, 0xff, 0xff, 0x9f, 0x18, 0x14, 0x38, 0xba, + 0x00, 0x83, 0xff, 0xff, 0x39, 0x0f, 0x41, 0x05, + 0x44}}, /* 0x2e */ + {{0x5b, 0xff, 0xff, 0x9f, 0x18, 0x14, 0x3d, 0xba, + 0x00, 0x83, 0xff, 0xff, 0x3e, 0x0f, 0x41, 0x05, + 0x44}}, /* 0x2f */ + {{0x5d, 0xff, 0xff, 0x81, 0x19, 0x95, 0x41, 0xba, + 0x00, 0x84, 0xff, 0xff, 0x42, 0x0f, 0x41, 0x05, + 0x44}}, /* 0x30 */ + {{0x55, 0xff, 0xff, 0x99, 0x0d, 0x0c, 0x3e, 0xba, + 0x00, 0x84, 0xff, 0xff, 0x3f, 0x0f, 0x41, 0x05, + 0x00}}, /* 0x31 */ + {{0x7f, 0x63, 0x63, 0x83, 0x6c, 0x1c, 0x72, 0xba, + 0x27, 0x8b, 0xdf, 0xdf, 0x73, 0x00, 0x00, 0x06, + 0x01}}, /* 0x32 */ + {{0x7f, 0x63, 0x63, 0x83, 0x69, 0x13, 0x6f, 0xba, + 0x26, 0x89, 0xdf, 0xdf, 0x6f, 0x00, 0x00, 0x06, + 0x01}}, /* 0x33 */ + {{0x7f, 0x63, 0x63, 0x82, 0x6b, 0x13, 0x75, 0xba, + 0x29, 0x8c, 0xdf, 0xdf, 0x75, 0x00, 0x00, 0x06, + 0x01}}, /* 0x34 */ + {{0xa3, 0x7f, 0x7f, 0x87, 0x86, 0x97, 0x24, 0xf1, + 0xaf, 0x85, 0x3f, 0x3f, 0x25, 0x30, 0x00, 0x02, + 0x01}}, /* 0x35 */ + {{0x9f, 0x7f, 0x7f, 0x83, 0x85, 0x91, 0x1e, 0xf1, + 0xad, 0x81, 0x3f, 0x3f, 0x1f, 0x30, 0x00, 0x02, + 0x01}}, /* 0x36 */ + {{0xa7, 0x7f, 0x7f, 0x88, 0x89, 0x95, 0x26, 0xf1, + 0xb1, 0x85, 0x3f, 0x3f, 0x27, 0x30, 0x00, 0x02, + 0x01}}, /* 0x37 */ + {{0xce, 0x9f, 0x9f, 0x92, 0xa9, 0x17, 0x28, 0xc4, + 0x7a, 0x8e, 0xcf, 0xcf, 0x29, 0x21, 0x00, 0x07, + 0x01}}, /* 0x38 */ + {{0xce, 0x9f, 0x9f, 0x92, 0xa5, 0x17, 0x28, 0xd4, + 0x7a, 0x8e, 0xcf, 0xcf, 0x29, 0x21, 0x00, 0x07, + 0x01}}, /* 0x39 */ + {{0xd3, 0x9f, 0x9f, 0x97, 0xab, 0x1f, 0x2e, 0xd4, + 0x7d, 0x81, 0xcf, 0xcf, 0x2f, 0x21, 0x00, 0x07, + 0x01}}, /* 0x3a */ + {{0xdc, 0x9f, 0x9f, 0x80, 0xaf, 0x9d, 0xe6, 0xff, + 0xc0, 0x83, 0xbf, 0xbf, 0xe7, 0x10, 0x00, 0x07, + 0x01}}, /* 0x3b */ + {{0x6b, 0x59, 0x59, 0x8f, 0x5e, 0x8c, 0x0b, 0x3e, + 0xe9, 0x8b, 0xdf, 0xe7, 0x04, 0x00, 0x00, 0x05, + 0x00}}, /* 0x3c */ + {{0x6d, 0x59, 0x59, 0x91, 0x60, 0x89, 0x53, 0xf0, + 0x41, 0x84, 0x3f, 0x3f, 0x54, 0x00, 0x00, 0x05, + 0x41}}, /* 0x3d */ + {{0x86, 0x6a, 0x6a, 0x8a, 0x74, 0x06, 0x8c, 0x15, + 0x4f, 0x83, 0xef, 0xef, 0x8d, 0x30, 0x00, 0x02, + 0x00}}, /* 0x3e */ + {{0x81, 0x6a, 0x6a, 0x85, 0x70, 0x00, 0x0f, 0x3e, + 0xeb, 0x8e, 0xdf, 0xdf, 0x10, 0x00, 0x00, 0x02, + 0x00}}, /* 0x3f */ + {{0xa3, 0x7f, 0x7f, 0x87, 0x86, 0x97, 0x1e, 0xf1, + 0xae, 0x85, 0x57, 0x57, 0x1f, 0x30, 0x00, 0x02, + 0x01}}, /* 0x40 */ + {{0xa3, 0x7f, 0x7f, 0x87, 0x86, 0x97, 0x24, 0xf5, + 0x02, 0x88, 0xff, 0xff, 0x25, 0x10, 0x00, 0x02, + 0x01}}, /* 0x41 */ + {{0xce, 0x9f, 0x9f, 0x92, 0xa9, 0x17, 0x20, 0xf5, + 0x03, 0x88, 0xff, 0xff, 0x21, 0x10, 0x00, 0x07, + 0x01}}, /* 0x42 */ + {{0xe6, 0xae, 0xae, 0x8a, 0xbd, 0x90, 0x3d, 0x10, + 0x1a, 0x8d, 0x19, 0x19, 0x3e, 0x2f, 0x00, 0x03, + 0x00}}, /* 0x43 */ + {{0xc3, 0x8f, 0x8f, 0x87, 0x9b, 0x0b, 0x82, 0xef, + 0x60, 0x83, 0x5f, 0x5f, 0x83, 0x10, 0x00, 0x07, + 0x01}}, /* 0x44 */ + {{0x86, 0x69, 0x69, 0x8A, 0x74, 0x06, 0x8C, 0x15, + 0x4F, 0x83, 0xEF, 0xEF, 0x8D, 0x30, 0x00, 0x02, + 0x00}}, /* 0x45 */ + {{0x83, 0x69, 0x69, 0x87, 0x6f, 0x1d, 0x03, 0x3E, + 0xE5, 0x8d, 0xDF, 0xe4, 0x04, 0x00, 0x00, 0x06, + 0x00}}, /* 0x46 */ + {{0x86, 0x6A, 0x6A, 0x8A, 0x74, 0x06, 0x8C, 0x15, + 0x4F, 0x83, 0xEF, 0xEF, 0x8D, 0x30, 0x00, 0x02, + 0x00}}, /* 0x47 */ + {{0x81, 0x6A, 0x6A, 0x85, 0x70, 0x00, 0x0F, 0x3E, + 0xEB, 0x8E, 0xDF, 0xDF, 0x10, 0x00, 0x00, 0x02, + 0x00}}, /* 0x48 */ + {{0xdd, 0xa9, 0xa9, 0x81, 0xb4, 0x97, 0x26, 0xfd, + 0x01, 0x8d, 0xff, 0x00, 0x27, 0x10, 0x00, 0x03, + 0x01}}, /* 0x49 */ + {{0xd9, 0x8f, 0x8f, 0x9d, 0xba, 0x0a, 0x8a, 0xff, + 0x60, 0x8b, 0x5f, 0x5f, 0x8b, 0x10, 0x00, 0x03, + 0x01}}, /* 0x4a */ + {{0xea, 0xae, 0xae, 0x8e, 0xba, 0x82, 0x40, 0x10, + 0x1b, 0x87, 0x19, 0x1a, 0x41, 0x0f, 0x00, 0x03, + 0x00}}, /* 0x4b */ + {{0xd3, 0x9f, 0x9f, 0x97, 0xab, 0x1f, 0xf1, 0xff, + 0xc0, 0x83, 0xbf, 0xbf, 0xf2, 0x10, 0x00, 0x07, + 0x01}}, /* 0x4c */ + {{0x75, 0x5f, 0x5f, 0x99, 0x66, 0x90, 0x53, 0xf0, + 0x41, 0x84, 0x3f, 0x3f, 0x54, 0x00, 0x00, 0x05, + 0x41}}, + {{0x2d, 0x27, 0x28, 0x90, 0x2c, 0x80, 0x0b, 0x3e, + 0xe9, 0x8b, 0xdf, 0xe7, 0x04, 0x00, 0x00, 0x00, + 0x00}}, /* 0x4e */ + {{0xcd, 0x9f, 0x9f, 0x91, 0xab, 0x1c, 0x3a, 0xff, + 0x20, 0x83, 0x1f, 0x1f, 0x3b, 0x10, 0x00, 0x07, + 0x21}}, /* 0x4f */ + {{0x15, 0xd1, 0xd1, 0x99, 0xe2, 0x19, 0x3d, 0x10, + 0x1a, 0x8d, 0x19, 0x19, 0x3e, 0x2f, 0x01, 0x0c, + 0x20}}, /* 0x50 */ + {{0x0e, 0xef, 0xef, 0x92, 0xfe, 0x03, 0x30, 0xf0, + 0x1e, 0x83, 0x1b, 0x1c, 0x31, 0x00, 0x01, 0x00, + 0x61}}, /* 0x51 */ + {{0x85, 0x77, 0x77, 0x89, 0x7d, 0x01, 0x31, 0xf0, + 0x1e, 0x84, 0x1b, 0x1c, 0x32, 0x00, 0x00, 0x02, + 0x41}}, /* 0x52 */ + {{0x87, 0x77, 0x77, 0x8b, 0x81, 0x0b, 0x68, 0xf0, + 0x5a, 0x80, 0x57, 0x57, 0x69, 0x00, 0x00, 0x02, + 0x01}}, /* 0x53 */ + {{0xcd, 0x8f, 0x8f, 0x91, 0x9b, 0x1b, 0x7a, 0xff, + 0x64, 0x8c, 0x5f, 0x62, 0x7b, 0x10, 0x00, 0x07, + 0x41}} /* 0x54 */ +}; + +static const struct SiS_VCLKData SiSUSB_VCLKData[] = { + {0x1b, 0xe1, 25}, /* 0x00 */ + {0x4e, 0xe4, 28}, /* 0x01 */ + {0x57, 0xe4, 31}, /* 0x02 */ + {0xc3, 0xc8, 36}, /* 0x03 */ + {0x42, 0xe2, 40}, /* 0x04 */ + {0xfe, 0xcd, 43}, /* 0x05 */ + {0x5d, 0xc4, 44}, /* 0x06 */ + {0x52, 0xe2, 49}, /* 0x07 */ + {0x53, 0xe2, 50}, /* 0x08 */ + {0x74, 0x67, 52}, /* 0x09 */ + {0x6d, 0x66, 56}, /* 0x0a */ + {0x5a, 0x64, 65}, /* 0x0b */ + {0x46, 0x44, 67}, /* 0x0c */ + {0xb1, 0x46, 68}, /* 0x0d */ + {0xd3, 0x4a, 72}, /* 0x0e */ + {0x29, 0x61, 75}, /* 0x0f */ + {0x6e, 0x46, 76}, /* 0x10 */ + {0x2b, 0x61, 78}, /* 0x11 */ + {0x31, 0x42, 79}, /* 0x12 */ + {0xab, 0x44, 83}, /* 0x13 */ + {0x46, 0x25, 84}, /* 0x14 */ + {0x78, 0x29, 86}, /* 0x15 */ + {0x62, 0x44, 94}, /* 0x16 */ + {0x2b, 0x41, 104}, /* 0x17 */ + {0x3a, 0x23, 105}, /* 0x18 */ + {0x70, 0x44, 108}, /* 0x19 */ + {0x3c, 0x23, 109}, /* 0x1a */ + {0x5e, 0x43, 113}, /* 0x1b */ + {0xbc, 0x44, 116}, /* 0x1c */ + {0xe0, 0x46, 132}, /* 0x1d */ + {0x54, 0x42, 135}, /* 0x1e */ + {0xea, 0x2a, 139}, /* 0x1f */ + {0x41, 0x22, 157}, /* 0x20 */ + {0x70, 0x24, 162}, /* 0x21 */ + {0x30, 0x21, 175}, /* 0x22 */ + {0x4e, 0x22, 189}, /* 0x23 */ + {0xde, 0x26, 194}, /* 0x24 */ + {0x62, 0x06, 202}, /* 0x25 */ + {0x3f, 0x03, 229}, /* 0x26 */ + {0xb8, 0x06, 234}, /* 0x27 */ + {0x34, 0x02, 253}, /* 0x28 */ + {0x58, 0x04, 255}, /* 0x29 */ + {0x24, 0x01, 265}, /* 0x2a */ + {0x9b, 0x02, 267}, /* 0x2b */ + {0x70, 0x05, 270}, /* 0x2c */ + {0x25, 0x01, 272}, /* 0x2d */ + {0x9c, 0x02, 277}, /* 0x2e */ + {0x27, 0x01, 286}, /* 0x2f */ + {0x3c, 0x02, 291}, /* 0x30 */ + {0xef, 0x0a, 292}, /* 0x31 */ + {0xf6, 0x0a, 310}, /* 0x32 */ + {0x95, 0x01, 315}, /* 0x33 */ + {0xf0, 0x09, 324}, /* 0x34 */ + {0xfe, 0x0a, 331}, /* 0x35 */ + {0xf3, 0x09, 332}, /* 0x36 */ + {0xea, 0x08, 340}, /* 0x37 */ + {0xe8, 0x07, 376}, /* 0x38 */ + {0xde, 0x06, 389}, /* 0x39 */ + {0x52, 0x2a, 54}, /* 0x3a 301 TV */ + {0x52, 0x6a, 27}, /* 0x3b 301 TV */ + {0x62, 0x24, 70}, /* 0x3c 301 TV */ + {0x62, 0x64, 70}, /* 0x3d 301 TV */ + {0xa8, 0x4c, 30}, /* 0x3e 301 TV */ + {0x20, 0x26, 33}, /* 0x3f 301 TV */ + {0x31, 0xc2, 39}, /* 0x40 */ + {0x60, 0x36, 30}, /* 0x41 Chrontel */ + {0x40, 0x4a, 28}, /* 0x42 Chrontel */ + {0x9f, 0x46, 44}, /* 0x43 Chrontel */ + {0x97, 0x2c, 26}, /* 0x44 */ + {0x44, 0xe4, 25}, /* 0x45 Chrontel */ + {0x7e, 0x32, 47}, /* 0x46 Chrontel */ + {0x8a, 0x24, 31}, /* 0x47 Chrontel */ + {0x97, 0x2c, 26}, /* 0x48 Chrontel */ + {0xce, 0x3c, 39}, /* 0x49 */ + {0x52, 0x4a, 36}, /* 0x4a Chrontel */ + {0x34, 0x61, 95}, /* 0x4b */ + {0x78, 0x27, 108}, /* 0x4c - was 102 */ + {0x66, 0x43, 123}, /* 0x4d Modes 0x26-0x28 (1400x1050) */ + {0x41, 0x4e, 21}, /* 0x4e */ + {0xa1, 0x4a, 29}, /* 0x4f Chrontel */ + {0x19, 0x42, 42}, /* 0x50 */ + {0x54, 0x46, 58}, /* 0x51 Chrontel */ + {0x25, 0x42, 61}, /* 0x52 */ + {0x44, 0x44, 66}, /* 0x53 Chrontel */ + {0x3a, 0x62, 70}, /* 0x54 Chrontel */ + {0x62, 0xc6, 34}, /* 0x55 848x480-60 */ + {0x6a, 0xc6, 37}, /* 0x56 848x480-75 - TEMP */ + {0xbf, 0xc8, 35}, /* 0x57 856x480-38i,60 */ + {0x30, 0x23, 88}, /* 0x58 1360x768-62 (is 60Hz!) */ + {0x52, 0x07, 149}, /* 0x59 1280x960-85 */ + {0x56, 0x07, 156}, /* 0x5a 1400x1050-75 */ + {0x70, 0x29, 81}, /* 0x5b 1280x768 LCD */ + {0x45, 0x25, 83}, /* 0x5c 1280x800 */ + {0x70, 0x0a, 147}, /* 0x5d 1680x1050 */ + {0x70, 0x24, 162}, /* 0x5e 1600x1200 */ + {0x5a, 0x64, 65}, /* 0x5f 1280x720 - temp */ + {0x63, 0x46, 68}, /* 0x60 1280x768_2 */ + {0x31, 0x42, 79}, /* 0x61 1280x768_3 - temp */ + {0, 0, 0}, /* 0x62 - custom (will be filled out at run-time) */ + {0x5a, 0x64, 65}, /* 0x63 1280x720 (LCD LVDS) */ + {0x70, 0x28, 90}, /* 0x64 1152x864@60 */ + {0x41, 0xc4, 32}, /* 0x65 848x480@60 */ + {0x5c, 0xc6, 32}, /* 0x66 856x480@60 */ + {0x76, 0xe7, 27}, /* 0x67 720x480@60 */ + {0x5f, 0xc6, 33}, /* 0x68 720/768x576@60 */ + {0x52, 0x27, 75}, /* 0x69 1920x1080i 60Hz interlaced */ + {0x7c, 0x6b, 38}, /* 0x6a 960x540@60 */ + {0xe3, 0x56, 41}, /* 0x6b 960x600@60 */ + {0x45, 0x25, 83}, /* 0x6c 1280x800 */ + {0x70, 0x28, 90}, /* 0x6d 1152x864@60 */ + {0x15, 0xe1, 20}, /* 0x6e 640x400@60 (fake, not actually used) */ + {0x5f, 0xc6, 33}, /* 0x6f 720x576@60 */ + {0x37, 0x5a, 10}, /* 0x70 320x200@60 (fake, not actually used) */ + {0x2b, 0xc2, 35} /* 0x71 768@576@60 */ +}; + +#endif -- cgit v1.2.3-70-g09d2 From de37458f8c2bfc465500a1dd0d15dbe96d2a698c Mon Sep 17 00:00:00 2001 From: Johan Hovold Date: Thu, 16 Jul 2020 10:50:55 +0200 Subject: USB: serial: iuu_phoenix: fix led-activity helpers The set-led command is eight bytes long and starts with a command byte followed by six bytes of RGB data and ends with a byte encoding a frequency (see iuu_led() and iuu_rgbf_fill_buffer()). The led activity helpers had a few long-standing bugs which corrupted the command packets by inserting a second command byte and thereby offsetting the RGB data and dropping the frequency in non-xmas mode. In xmas mode, a related off-by-one error left the frequency field uninitialised. Fixes: 60a8fc017103 ("USB: add iuu_phoenix driver") Reported-by: George Spelvin Link: https://lore.kernel.org/r/20200716085056.31471-1-johan@kernel.org Reviewed-by: Greg Kroah-Hartman Signed-off-by: Johan Hovold --- drivers/usb/serial/iuu_phoenix.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/serial/iuu_phoenix.c b/drivers/usb/serial/iuu_phoenix.c index 6336616fee49..9da0e25bb0ea 100644 --- a/drivers/usb/serial/iuu_phoenix.c +++ b/drivers/usb/serial/iuu_phoenix.c @@ -350,10 +350,11 @@ static void iuu_led_activity_on(struct urb *urb) { struct usb_serial_port *port = urb->context; char *buf_ptr = port->write_urb->transfer_buffer; - *buf_ptr++ = IUU_SET_LED; + if (xmas) { - get_random_bytes(buf_ptr, 6); - *(buf_ptr+7) = 1; + buf_ptr[0] = IUU_SET_LED; + get_random_bytes(buf_ptr + 1, 6); + buf_ptr[7] = 1; } else { iuu_rgbf_fill_buffer(buf_ptr, 255, 255, 0, 0, 0, 0, 255); } @@ -370,13 +371,14 @@ static void iuu_led_activity_off(struct urb *urb) { struct usb_serial_port *port = urb->context; char *buf_ptr = port->write_urb->transfer_buffer; + if (xmas) { iuu_rxcmd(urb); return; - } else { - *buf_ptr++ = IUU_SET_LED; - iuu_rgbf_fill_buffer(buf_ptr, 0, 0, 255, 255, 0, 0, 255); } + + iuu_rgbf_fill_buffer(buf_ptr, 0, 0, 255, 255, 0, 0, 255); + usb_fill_bulk_urb(port->write_urb, port->serial->dev, usb_sndbulkpipe(port->serial->dev, port->bulk_out_endpointAddress), -- cgit v1.2.3-70-g09d2 From d2a4309c1ab6df424b2239fe2920d6f26f808d17 Mon Sep 17 00:00:00 2001 From: Erik Ekman Date: Fri, 17 Jul 2020 20:51:18 +0200 Subject: USB: serial: qcserial: add EM7305 QDL product ID When running qmi-firmware-update on the Sierra Wireless EM7305 in a Toshiba laptop, it changed product ID to 0x9062 when entering QDL mode: usb 2-4: new high-speed USB device number 78 using xhci_hcd usb 2-4: New USB device found, idVendor=1199, idProduct=9062, bcdDevice= 0.00 usb 2-4: New USB device strings: Mfr=1, Product=2, SerialNumber=0 usb 2-4: Product: EM7305 usb 2-4: Manufacturer: Sierra Wireless, Incorporated The upgrade could complete after running # echo 1199 9062 > /sys/bus/usb-serial/drivers/qcserial/new_id qcserial 2-4:1.0: Qualcomm USB modem converter detected usb 2-4: Qualcomm USB modem converter now attached to ttyUSB0 Signed-off-by: Erik Ekman Link: https://lore.kernel.org/r/20200717185118.3640219-1-erik@kryo.se Cc: stable@vger.kernel.org Signed-off-by: Johan Hovold --- drivers/usb/serial/qcserial.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/usb') diff --git a/drivers/usb/serial/qcserial.c b/drivers/usb/serial/qcserial.c index 5dfbbaef38bb..c8d1ea0e6e6f 100644 --- a/drivers/usb/serial/qcserial.c +++ b/drivers/usb/serial/qcserial.c @@ -155,6 +155,7 @@ static const struct usb_device_id id_table[] = { {DEVICE_SWI(0x1199, 0x9056)}, /* Sierra Wireless Modem */ {DEVICE_SWI(0x1199, 0x9060)}, /* Sierra Wireless Modem */ {DEVICE_SWI(0x1199, 0x9061)}, /* Sierra Wireless Modem */ + {DEVICE_SWI(0x1199, 0x9062)}, /* Sierra Wireless EM7305 QDL */ {DEVICE_SWI(0x1199, 0x9063)}, /* Sierra Wireless EM7305 */ {DEVICE_SWI(0x1199, 0x9070)}, /* Sierra Wireless MC74xx */ {DEVICE_SWI(0x1199, 0x9071)}, /* Sierra Wireless MC74xx */ -- cgit v1.2.3-70-g09d2 From 306c54d0edb6ba94d39877524dddebaad7770cf2 Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Thu, 2 Jul 2020 17:30:45 +0300 Subject: usb: hcd: Try MSI interrupts on PCI devices It appears that some platforms share same IRQ line between several devices, some of which are EHCI and OHCI controllers. This is neither practical nor performance-wise, especially in the case when they are supporting MSI. In order to improve the situation try to allocate MSI and fallback to legacy IRQ if no MSI available. Signed-off-by: Andy Shevchenko Link: https://lore.kernel.org/r/20200702143045.23429-1-andriy.shevchenko@linux.intel.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/core/hcd-pci.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/core/hcd-pci.c b/drivers/usb/core/hcd-pci.c index 1547aa6e5314..4dc443aaef5c 100644 --- a/drivers/usb/core/hcd-pci.c +++ b/drivers/usb/core/hcd-pci.c @@ -194,20 +194,21 @@ int usb_hcd_pci_probe(struct pci_dev *dev, const struct pci_device_id *id, * make sure irq setup is not touched for xhci in generic hcd code */ if ((driver->flags & HCD_MASK) < HCD_USB3) { - if (!dev->irq) { + retval = pci_alloc_irq_vectors(dev, 1, 1, PCI_IRQ_LEGACY | PCI_IRQ_MSI); + if (retval < 0) { dev_err(&dev->dev, "Found HC with no IRQ. Check BIOS/PCI %s setup!\n", pci_name(dev)); retval = -ENODEV; goto disable_pci; } - hcd_irq = dev->irq; + hcd_irq = pci_irq_vector(dev, 0); } hcd = usb_create_hcd(driver, &dev->dev, pci_name(dev)); if (!hcd) { retval = -ENOMEM; - goto disable_pci; + goto free_irq_vectors; } hcd->amd_resume_bug = (usb_hcd_amd_remote_wakeup_quirk(dev) && @@ -286,6 +287,9 @@ int usb_hcd_pci_probe(struct pci_dev *dev, const struct pci_device_id *id, put_hcd: usb_put_hcd(hcd); +free_irq_vectors: + if ((driver->flags & HCD_MASK) < HCD_USB3) + pci_free_irq_vectors(dev); disable_pci: pci_disable_device(dev); dev_err(&dev->dev, "init %s fail, %d\n", pci_name(dev), retval); @@ -343,6 +347,8 @@ void usb_hcd_pci_remove(struct pci_dev *dev) up_read(&companions_rwsem); } usb_put_hcd(hcd); + if ((hcd->driver->flags & HCD_MASK) < HCD_USB3) + pci_free_irq_vectors(dev); pci_disable_device(dev); } EXPORT_SYMBOL_GPL(usb_hcd_pci_remove); @@ -454,7 +460,7 @@ static int suspend_common(struct device *dev, bool do_wakeup) * synchronized here. */ if (!hcd->msix_enabled) - synchronize_irq(pci_dev->irq); + synchronize_irq(pci_irq_vector(pci_dev, 0)); /* Downstream ports from this root hub should already be quiesced, so * there will be no DMA activity. Now we can shut down the upstream -- cgit v1.2.3-70-g09d2 From b1b6bed3b5036509b449b5965285d5057ba42527 Mon Sep 17 00:00:00 2001 From: Kars Mulder Date: Tue, 7 Jul 2020 16:43:50 +0200 Subject: usb: core: fix quirks_param_set() writing to a const pointer The function quirks_param_set() takes as argument a const char* pointer to the new value of the usbcore.quirks parameter. It then casts this pointer to a non-const char* pointer and passes it to the strsep() function, which overwrites the value. Fix this by creating a copy of the value using kstrdup() and letting that copy be written to by strsep(). Fixes: 027bd6cafd9a ("usb: core: Add "quirks" parameter for usbcore") Signed-off-by: Kars Mulder Link: https://lore.kernel.org/r/5ee2-5f048a00-21-618c5c00@230659773 Signed-off-by: Greg Kroah-Hartman --- drivers/usb/core/quirks.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c index 870df71d1827..7c1198f80c23 100644 --- a/drivers/usb/core/quirks.c +++ b/drivers/usb/core/quirks.c @@ -25,17 +25,23 @@ static unsigned int quirk_count; static char quirks_param[128]; -static int quirks_param_set(const char *val, const struct kernel_param *kp) +static int quirks_param_set(const char *value, const struct kernel_param *kp) { - char *p, *field; + char *val, *p, *field; u16 vid, pid; u32 flags; size_t i; int err; + val = kstrdup(value, GFP_KERNEL); + if (!val) + return -ENOMEM; + err = param_set_copystring(val, kp); - if (err) + if (err) { + kfree(val); return err; + } mutex_lock(&quirk_mutex); @@ -60,10 +66,11 @@ static int quirks_param_set(const char *val, const struct kernel_param *kp) if (!quirk_list) { quirk_count = 0; mutex_unlock(&quirk_mutex); + kfree(val); return -ENOMEM; } - for (i = 0, p = (char *)val; p && *p;) { + for (i = 0, p = val; p && *p;) { /* Each entry consists of VID:PID:flags */ field = strsep(&p, ":"); if (!field) @@ -144,6 +151,7 @@ static int quirks_param_set(const char *val, const struct kernel_param *kp) unlock: mutex_unlock(&quirk_mutex); + kfree(val); return 0; } -- cgit v1.2.3-70-g09d2 From 658027afeab3070681bda5152eb9681c7731bcc8 Mon Sep 17 00:00:00 2001 From: Prashant Malani Date: Wed, 8 Jul 2020 17:24:41 -0700 Subject: usb: typec: intel_pmc_mux: Avoid connect request on disconnect When pmc_usb_mux_set() is invoked when a device is disconnected, a valid scenario is for state->alt == NULL and state->mode == TYPEC_STATE_USB. In such cases, if a pmc_usb_disconnect() has already been issued (from either pmc_usb_set_orientation() when orientation == TYPEC_ORIENTATION_NONE, or pmc_usb_set_role() when role == USB_ROLE_NONE), a pmc_usb_connect() will be issued despite no peripheral being present. This confuses the PMC and leads to all subsequent PMC IPC requests returning errors due to timeout. To prevent this, return early if the port orientation or role is already set to none. Cc: Benson Leung Cc: Heikki Krogerus Cc: Rajmohan Mani Fixes: f3c1c41ebc67 ("usb: typec: intel_pmc_mux: Add support for USB4") Signed-off-by: Prashant Malani Link: https://lore.kernel.org/r/20200709002441.1309189-1-pmalani@chromium.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/typec/mux/intel_pmc_mux.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'drivers/usb') diff --git a/drivers/usb/typec/mux/intel_pmc_mux.c b/drivers/usb/typec/mux/intel_pmc_mux.c index 2aba07c7b221..e4021e13af40 100644 --- a/drivers/usb/typec/mux/intel_pmc_mux.c +++ b/drivers/usb/typec/mux/intel_pmc_mux.c @@ -310,6 +310,9 @@ pmc_usb_mux_set(struct typec_mux *mux, struct typec_mux_state *state) { struct pmc_usb_port *port = typec_mux_get_drvdata(mux); + if (port->orientation == TYPEC_ORIENTATION_NONE || port->role == USB_ROLE_NONE) + return 0; + if (state->mode == TYPEC_STATE_SAFE) return pmc_usb_mux_safe_state(port); if (state->mode == TYPEC_STATE_USB) -- cgit v1.2.3-70-g09d2 From 1401bfe058d3ccf8867e9faf77744900c305e74e Mon Sep 17 00:00:00 2001 From: Kyle Tso Date: Tue, 14 Jul 2020 11:34:52 +0800 Subject: usb: typec: Comment correction for typec_partner_register_altmode typec_register_altmode returns ERR_PTR on failure. Signed-off-by: Kyle Tso Reviewed-by: Guenter Roeck Link: https://lore.kernel.org/r/20200714033453.4044482-2-kyletso@google.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/typec/class.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/usb') diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c index c9234748537a..02655694f200 100644 --- a/drivers/usb/typec/class.c +++ b/drivers/usb/typec/class.c @@ -580,7 +580,7 @@ EXPORT_SYMBOL_GPL(typec_partner_set_identity); * SVID listed in response to Discover Modes command need to be listed in an * array in @desc. * - * Returns handle to the alternate mode on success or NULL on failure. + * Returns handle to the alternate mode on success or ERR_PTR on failure. */ struct typec_altmode * typec_partner_register_altmode(struct typec_partner *partner, -- cgit v1.2.3-70-g09d2 From d25d61be6bed44d3a5b7050836e6df602bf3d6ba Mon Sep 17 00:00:00 2001 From: Kyle Tso Date: Tue, 14 Jul 2020 11:34:53 +0800 Subject: usb: typec: tcpm: Error handling for tcpm_register_partner_altmodes typec_partner_register_altmode returns ERR_PTR. Reset the pointer altmode to NULL on failure. Signed-off-by: Kyle Tso Reviewed-by: Guenter Roeck Link: https://lore.kernel.org/r/20200714033453.4044482-3-kyletso@google.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/typec/tcpm/tcpm.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'drivers/usb') diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c index 82b19ebd7838..a6d4b03ec250 100644 --- a/drivers/usb/typec/tcpm/tcpm.c +++ b/drivers/usb/typec/tcpm/tcpm.c @@ -1061,9 +1061,11 @@ static void tcpm_register_partner_altmodes(struct tcpm_port *port) for (i = 0; i < modep->altmodes; i++) { altmode = typec_partner_register_altmode(port->partner, &modep->altmode_desc[i]); - if (!altmode) + if (IS_ERR(altmode)) { tcpm_log(port, "Failed to register partner SVID 0x%04x", modep->altmode_desc[i].svid); + altmode = NULL; + } port->partner_altmode[i] = altmode; } } -- cgit v1.2.3-70-g09d2 From b2dcfefc43f783c4462f30507f78b7bb093ee8df Mon Sep 17 00:00:00 2001 From: Badhri Jagan Sridharan Date: Wed, 15 Jul 2020 20:41:26 -0700 Subject: usb: typec: tcpm: Support bist test data mode for compliance TCPM supports BIST carried mode. PD compliance tests require BIST Test Data to be supported as well. Introducing set_bist_data callback to signal tcpc driver for configuring the port controller hardware to enable/disable BIST Test Data mode. Signed-off-by: Badhri Jagan Sridharan Reviewed-by: Guenter Roeck Link: https://lore.kernel.org/r/20200716034128.1251728-1-badhri@google.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/typec/tcpm/tcpm.c | 11 +++++++++++ include/linux/usb/tcpm.h | 2 ++ 2 files changed, 13 insertions(+) (limited to 'drivers/usb') diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c index a6d4b03ec250..a04f6c18b11a 100644 --- a/drivers/usb/typec/tcpm/tcpm.c +++ b/drivers/usb/typec/tcpm/tcpm.c @@ -2748,6 +2748,11 @@ static void tcpm_detach(struct tcpm_port *port) if (!port->attached) return; + if (port->tcpc->set_bist_data) { + tcpm_log(port, "disable BIST MODE TESTDATA"); + port->tcpc->set_bist_data(port->tcpc, false); + } + if (tcpm_port_is_disconnected(port)) port->hard_reset_count = 0; @@ -3557,6 +3562,12 @@ static void run_state_machine(struct tcpm_port *port) case BDO_MODE_CARRIER2: tcpm_pd_transmit(port, TCPC_TX_BIST_MODE_2, NULL); break; + case BDO_MODE_TESTDATA: + if (port->tcpc->set_bist_data) { + tcpm_log(port, "Enable BIST MODE TESTDATA"); + port->tcpc->set_bist_data(port->tcpc, true); + } + break; default: break; } diff --git a/include/linux/usb/tcpm.h b/include/linux/usb/tcpm.h index e7979c01c351..89f58760cf48 100644 --- a/include/linux/usb/tcpm.h +++ b/include/linux/usb/tcpm.h @@ -79,6 +79,7 @@ enum tcpm_transmit_type { * @try_role: Optional; called to set a preferred role * @pd_transmit:Called to transmit PD message * @mux: Pointer to multiplexer data + * @set_bist_data: Turn on/off bist data mode for compliance testing */ struct tcpc_dev { struct fwnode_handle *fwnode; @@ -103,6 +104,7 @@ struct tcpc_dev { int (*try_role)(struct tcpc_dev *dev, int role); int (*pd_transmit)(struct tcpc_dev *dev, enum tcpm_transmit_type type, const struct pd_message *msg); + int (*set_bist_data)(struct tcpc_dev *dev, bool on); }; struct tcpm_port; -- cgit v1.2.3-70-g09d2 From c081ac42fefcf459fc546627ecb78d27235b23fe Mon Sep 17 00:00:00 2001 From: Badhri Jagan Sridharan Date: Wed, 15 Jul 2020 20:41:27 -0700 Subject: usb: typec: tcpci: Support BIST test data mode for compliance. Quoting from TCPCI spec: "Setting this bit to 1 is intended to be used only when a USB compliance tester is using USB BIST Test Data to test the PHY layer of the TCPC. The TCPM should clear this bit when a disconnect is detected. 0: Normal Operation. Incoming messages enabled by RECEIVE_DETECT passed to TCPM via Alert. 1: BIST Test Mode. Incoming messages enabled by RECEIVE_DETECT result in GoodCRC response but may not be passed to the TCPM via Alert." Signed-off-by: Badhri Jagan Sridharan Reviewed-by: Guenter Roeck Link: https://lore.kernel.org/r/20200716034128.1251728-2-badhri@google.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/typec/tcpm/tcpci.c | 9 +++++++++ drivers/usb/typec/tcpm/tcpci.h | 1 + 2 files changed, 10 insertions(+) (limited to 'drivers/usb') diff --git a/drivers/usb/typec/tcpm/tcpci.c b/drivers/usb/typec/tcpm/tcpci.c index 753645bb2527..f57d91fd0e09 100644 --- a/drivers/usb/typec/tcpm/tcpci.c +++ b/drivers/usb/typec/tcpm/tcpci.c @@ -227,6 +227,14 @@ static int tcpci_set_vconn(struct tcpc_dev *tcpc, bool enable) enable ? TCPC_POWER_CTRL_VCONN_ENABLE : 0); } +static int tcpci_set_bist_data(struct tcpc_dev *tcpc, bool enable) +{ + struct tcpci *tcpci = tcpc_to_tcpci(tcpc); + + return regmap_update_bits(tcpci->regmap, TCPC_TCPC_CTRL, TCPC_TCPC_CTRL_BIST_TM, + enable ? TCPC_TCPC_CTRL_BIST_TM : 0); +} + static int tcpci_set_roles(struct tcpc_dev *tcpc, bool attached, enum typec_role role, enum typec_data_role data) { @@ -530,6 +538,7 @@ struct tcpci *tcpci_register_port(struct device *dev, struct tcpci_data *data) tcpci->tcpc.set_pd_rx = tcpci_set_pd_rx; tcpci->tcpc.set_roles = tcpci_set_roles; tcpci->tcpc.pd_transmit = tcpci_pd_transmit; + tcpci->tcpc.set_bist_data = tcpci_set_bist_data; err = tcpci_parse_config(tcpci); if (err < 0) diff --git a/drivers/usb/typec/tcpm/tcpci.h b/drivers/usb/typec/tcpm/tcpci.h index 303ebde26546..11c36d086c86 100644 --- a/drivers/usb/typec/tcpm/tcpci.h +++ b/drivers/usb/typec/tcpm/tcpci.h @@ -36,6 +36,7 @@ #define TCPC_TCPC_CTRL 0x19 #define TCPC_TCPC_CTRL_ORIENTATION BIT(0) +#define TCPC_TCPC_CTRL_BIST_TM BIT(1) #define TCPC_ROLE_CTRL 0x1a #define TCPC_ROLE_CTRL_DRP BIT(6) -- cgit v1.2.3-70-g09d2 From 6e1c2241f4cecfc21f26f44179d04217c8390338 Mon Sep 17 00:00:00 2001 From: Badhri Jagan Sridharan Date: Wed, 15 Jul 2020 20:41:28 -0700 Subject: usb: typec: tcpm: Stay in BIST mode till hardreset or unattached MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Port starts to toggle when transitioning to unattached state. This is incorrect while in BIST mode. 6.4.3.1 BIST Carrier Mode Upon receipt of a BIST Message, with a BIST Carrier Mode BIST Data Object, the UUT Shall send out a continuous string of BMC encoded alternating "1"s and “0”s. The UUT Shall exit the Continuous BIST Mode within tBISTContMode of this Continuous BIST Mode being enabled(see Section 6.6.7.2). 6.4.3.2 BIST Test Data Upon receipt of a BIST Message, with a BIST Test Data BIST Data Object, the UUT Shall return a GoodCRC Message and Shall enter a test mode in which it sends no further Messages except for GoodCRC Messages in response to received Messages. See Section 5.9.2 for the definition of the Test Data Frame. The test Shall be ended by sending Hard Reset Signaling to reset the UUT. Signed-off-by: Badhri Jagan Sridharan Reviewed-by: Guenter Roeck Link: https://lore.kernel.org/r/20200716034128.1251728-3-badhri@google.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/typec/tcpm/tcpm.c | 7 +++++-- include/linux/usb/pd.h | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c index a04f6c18b11a..ff1cbd2147ca 100644 --- a/drivers/usb/typec/tcpm/tcpm.c +++ b/drivers/usb/typec/tcpm/tcpm.c @@ -3561,6 +3561,8 @@ static void run_state_machine(struct tcpm_port *port) switch (BDO_MODE_MASK(port->bist_request)) { case BDO_MODE_CARRIER2: tcpm_pd_transmit(port, TCPC_TX_BIST_MODE_2, NULL); + tcpm_set_state(port, unattached_state(port), + PD_T_BIST_CONT_MODE); break; case BDO_MODE_TESTDATA: if (port->tcpc->set_bist_data) { @@ -3571,8 +3573,6 @@ static void run_state_machine(struct tcpm_port *port) default: break; } - /* Always switch to unattached state */ - tcpm_set_state(port, unattached_state(port), 0); break; case GET_STATUS_SEND: tcpm_pd_send_control(port, PD_CTRL_GET_STATUS); @@ -3962,6 +3962,9 @@ static void _tcpm_pd_vbus_off(struct tcpm_port *port) static void _tcpm_pd_hard_reset(struct tcpm_port *port) { tcpm_log_force(port, "Received hard reset"); + if (port->bist_request == BDO_MODE_TESTDATA && port->tcpc->set_bist_data) + port->tcpc->set_bist_data(port->tcpc, false); + /* * If we keep receiving hard reset requests, executing the hard reset * must have failed. Revert to error recovery if that happens. diff --git a/include/linux/usb/pd.h b/include/linux/usb/pd.h index a665d7f21142..b6c233e79bd4 100644 --- a/include/linux/usb/pd.h +++ b/include/linux/usb/pd.h @@ -483,4 +483,5 @@ static inline unsigned int rdo_max_power(u32 rdo) #define PD_N_CAPS_COUNT (PD_T_NO_RESPONSE / PD_T_SEND_SOURCE_CAP) #define PD_N_HARD_RESET_COUNT 2 +#define PD_T_BIST_CONT_MODE 50 /* 30 - 60 ms */ #endif /* __LINUX_USB_PD_H */ -- cgit v1.2.3-70-g09d2 From a482766d008556c2f4976cf6096a4887da070f27 Mon Sep 17 00:00:00 2001 From: Bixuan Cui Date: Fri, 17 Jul 2020 08:22:53 +0800 Subject: usb: usbtest: reduce stack usage in test_queue Fix the warning: [-Werror=-Wframe-larger-than=] drivers/usb/misc/usbtest.c: In function 'test_queue': drivers/usb/misc/usbtest.c:2148:1: warning: the frame size of 1232 bytes is larger than 1024 bytes Reported-by: kbuild test robot Acked-by: Alan Stern Signed-off-by: Bixuan Cui Link: https://lore.kernel.org/r/ffa85702-86ab-48d7-4da2-2efcc94b05d3@huawei.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/misc/usbtest.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'drivers/usb') diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c index 8b220d56647b..150090ee4ec1 100644 --- a/drivers/usb/misc/usbtest.c +++ b/drivers/usb/misc/usbtest.c @@ -2043,7 +2043,7 @@ test_queue(struct usbtest_dev *dev, struct usbtest_param_32 *param, unsigned i; unsigned long packets = 0; int status = 0; - struct urb *urbs[MAX_SGLEN]; + struct urb **urbs; if (!param->sglen || param->iterations > UINT_MAX / param->sglen) return -EINVAL; @@ -2051,6 +2051,10 @@ test_queue(struct usbtest_dev *dev, struct usbtest_param_32 *param, if (param->sglen > MAX_SGLEN) return -EINVAL; + urbs = kcalloc(param->sglen, sizeof(*urbs), GFP_KERNEL); + if (!urbs) + return -ENOMEM; + memset(&context, 0, sizeof(context)); context.count = param->iterations * param->sglen; context.dev = dev; @@ -2137,6 +2141,8 @@ test_queue(struct usbtest_dev *dev, struct usbtest_param_32 *param, else if (context.errors > (context.is_iso ? context.packet_count / 10 : 0)) status = -EIO; + + kfree(urbs); return status; fail: @@ -2144,6 +2150,8 @@ fail: if (urbs[i]) simple_free_urb(urbs[i]); } + + kfree(urbs); return status; } -- cgit v1.2.3-70-g09d2 From ffeb1e9e897b8d36b197275592d121c96d3bdb95 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Sun, 19 Jul 2020 18:09:10 +0200 Subject: USB: Replace HTTP links with HTTPS ones Rationale: Reduces attack surface on kernel devs opening the links for MITM as HTTPS traffic is much harder to manipulate. Deterministic algorithm: For each file: If not .svg: For each line: If doesn't contain `\bxmlns\b`: For each link, `\bhttp://[^# \t\r\n]*(?:\w|/)`: If neither `\bgnu\.org/license`, nor `\bmozilla\.org/MPL\b`: If both the HTTP and HTTPS versions return 200 OK and serve the same content: Replace HTTP with HTTPS. Signed-off-by: Alexander A. Klimov Link: https://lore.kernel.org/r/20200719160910.60018-1-grandmaster@al2klimov.de Signed-off-by: Greg Kroah-Hartman --- Documentation/usb/gadget_hid.rst | 2 +- Documentation/usb/gadget_multi.rst | 10 +++++----- Documentation/usb/linux.inf | 2 +- drivers/usb/cdns3/cdns3-ti.c | 2 +- drivers/usb/common/debug.c | 2 +- drivers/usb/host/max3421-hcd.c | 6 +++--- drivers/usb/misc/Kconfig | 4 ++-- include/linux/usb/phy_companion.h | 2 +- 8 files changed, 15 insertions(+), 15 deletions(-) (limited to 'drivers/usb') diff --git a/Documentation/usb/gadget_hid.rst b/Documentation/usb/gadget_hid.rst index 098d563040cc..e623416de4f1 100644 --- a/Documentation/usb/gadget_hid.rst +++ b/Documentation/usb/gadget_hid.rst @@ -11,7 +11,7 @@ and HID reports can be sent/received through I/O on the /dev/hidgX character devices. For more details about HID, see the developer page on -http://www.usb.org/developers/hidpage/ +https://www.usb.org/developers/hidpage/ Configuration ============= diff --git a/Documentation/usb/gadget_multi.rst b/Documentation/usb/gadget_multi.rst index 9806b55af301..3a22c1b2f39e 100644 --- a/Documentation/usb/gadget_multi.rst +++ b/Documentation/usb/gadget_multi.rst @@ -142,7 +142,7 @@ Footnotes ========= [1] Remote Network Driver Interface Specification, -[[http://msdn.microsoft.com/en-us/library/ee484414.aspx]]. +[[https://msdn.microsoft.com/en-us/library/ee484414.aspx]]. [2] Communications Device Class Abstract Control Model, spec for this and other USB classes can be found at @@ -150,9 +150,9 @@ and other USB classes can be found at [3] CDC Ethernet Control Model. -[4] [[http://msdn.microsoft.com/en-us/library/ff537109(v=VS.85).aspx]] +[4] [[https://msdn.microsoft.com/en-us/library/ff537109(v=VS.85).aspx]] -[5] [[http://msdn.microsoft.com/en-us/library/ff539234(v=VS.85).aspx]] +[5] [[https://msdn.microsoft.com/en-us/library/ff539234(v=VS.85).aspx]] [6] To put it in some other nice words, Windows failed to respond to any user input. @@ -160,6 +160,6 @@ any user input. [7] You may find [[http://www.cygnal.org/ubb/Forum9/HTML/001050.html]] useful. -[8] http://www.nirsoft.net/utils/usb_devices_view.html +[8] https://www.nirsoft.net/utils/usb_devices_view.html -[9] [[http://msdn.microsoft.com/en-us/library/ff570620.aspx]] +[9] [[https://msdn.microsoft.com/en-us/library/ff570620.aspx]] diff --git a/Documentation/usb/linux.inf b/Documentation/usb/linux.inf index 4ffa715b0ae8..c569ac6bec58 100644 --- a/Documentation/usb/linux.inf +++ b/Documentation/usb/linux.inf @@ -1,5 +1,5 @@ ; Based on template INF file found at -; +; ; which was: ; Copyright (c) Microsoft Corporation ; and released under the MLPL as found at: diff --git a/drivers/usb/cdns3/cdns3-ti.c b/drivers/usb/cdns3/cdns3-ti.c index e701ab56b0a7..90e246601537 100644 --- a/drivers/usb/cdns3/cdns3-ti.c +++ b/drivers/usb/cdns3/cdns3-ti.c @@ -2,7 +2,7 @@ /** * cdns3-ti.c - TI specific Glue layer for Cadence USB Controller * - * Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com + * Copyright (C) 2019 Texas Instruments Incorporated - https://www.ti.com */ #include diff --git a/drivers/usb/common/debug.c b/drivers/usb/common/debug.c index 54c8f984c7b4..ba849c7bc5c7 100644 --- a/drivers/usb/common/debug.c +++ b/drivers/usb/common/debug.c @@ -2,7 +2,7 @@ /* * Common USB debugging functions * - * Copyright (C) 2010-2011 Texas Instruments Incorporated - http://www.ti.com + * Copyright (C) 2010-2011 Texas Instruments Incorporated - https://www.ti.com * * Authors: Felipe Balbi , * Sebastian Andrzej Siewior diff --git a/drivers/usb/host/max3421-hcd.c b/drivers/usb/host/max3421-hcd.c index 05828c0ab7de..0894f6caccb2 100644 --- a/drivers/usb/host/max3421-hcd.c +++ b/drivers/usb/host/max3421-hcd.c @@ -11,9 +11,9 @@ * * Based on: * o MAX3421E datasheet - * http://datasheets.maximintegrated.com/en/ds/MAX3421E.pdf + * https://datasheets.maximintegrated.com/en/ds/MAX3421E.pdf * o MAX3421E Programming Guide - * http://www.hdl.co.jp/ftpdata/utl-001/AN3785.pdf + * https://www.hdl.co.jp/ftpdata/utl-001/AN3785.pdf * o gadget/dummy_hcd.c * For USB HCD implementation. * o Arduino MAX3421 driver @@ -317,7 +317,7 @@ static const int hrsl_to_error[] = { }; /* - * See http://www.beyondlogic.org/usbnutshell/usb4.shtml#Control for a + * See https://www.beyondlogic.org/usbnutshell/usb4.shtml#Control for a * reasonable overview of how control transfers use the the IN/OUT * tokens. */ diff --git a/drivers/usb/misc/Kconfig b/drivers/usb/misc/Kconfig index 4e48f8eed168..6818ea689cd9 100644 --- a/drivers/usb/misc/Kconfig +++ b/drivers/usb/misc/Kconfig @@ -78,7 +78,7 @@ config USB_CYPRESS_CY7C63 driver supports the pre-programmed devices (incl. firmware) by AK Modul-Bus Computer GmbH. - Please see: http://www.ak-modul-bus.de/stat/mikrocontroller.html + Please see: https://www.ak-modul-bus.de/stat/mikrocontroller.html To compile this driver as a module, choose M here: the module will be called cypress_cy7c63. @@ -106,7 +106,7 @@ config USB_IDMOUSE This driver creates an entry "/dev/idmouseX" or "/dev/usb/idmouseX", which can be used by, e.g.,"cat /dev/idmouse0 > fingerprint.pnm". - See also . + See also . config USB_FTDI_ELAN tristate "Elan PCMCIA CardBus Adapter USB Client" diff --git a/include/linux/usb/phy_companion.h b/include/linux/usb/phy_companion.h index 407f530061cd..263196f05015 100644 --- a/include/linux/usb/phy_companion.h +++ b/include/linux/usb/phy_companion.h @@ -2,7 +2,7 @@ /* * phy-companion.h -- phy companion to indicate the comparator part of PHY * - * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com + * Copyright (C) 2012 Texas Instruments Incorporated - https://www.ti.com * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or -- cgit v1.2.3-70-g09d2 From d8a849353c9c7710faa260a1fd11918d1f533e86 Mon Sep 17 00:00:00 2001 From: Xu Wang Date: Mon, 20 Jul 2020 05:24:56 +0000 Subject: usb: appledisplay: remove needless check before usb_free_coherent() usb_free_coherent() is safe with NULL addr and this check is not required. Signed-off-by: Xu Wang Link: https://lore.kernel.org/r/20200720052456.7610-1-vulab@iscas.ac.cn Signed-off-by: Greg Kroah-Hartman --- drivers/usb/misc/appledisplay.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/misc/appledisplay.c b/drivers/usb/misc/appledisplay.c index 91cfd917f6df..36fed1a09666 100644 --- a/drivers/usb/misc/appledisplay.c +++ b/drivers/usb/misc/appledisplay.c @@ -305,8 +305,7 @@ error: if (pdata->urb) { usb_kill_urb(pdata->urb); cancel_delayed_work_sync(&pdata->work); - if (pdata->urbdata) - usb_free_coherent(pdata->udev, ACD_URB_BUFFER_LEN, + usb_free_coherent(pdata->udev, ACD_URB_BUFFER_LEN, pdata->urbdata, pdata->urb->transfer_dma); usb_free_urb(pdata->urb); } -- cgit v1.2.3-70-g09d2 From 233418634345b414595dc12afd07021169fc6d8e Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 20 Jul 2020 15:55:23 +0200 Subject: usb: ohci-omap: Create private state container The OMAP1 was using static locals to hold the clock handles which is uncommon and does not scale. Create a private data struct and use that to hold the clocks. Cc: Janusz Krzysztofik Cc: Tony Lindgren Acked-by: Alan Stern Signed-off-by: Linus Walleij Link: https://lore.kernel.org/r/20200720135524.100374-1-linus.walleij@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/ohci-omap.c | 85 +++++++++++++++++++++++++------------------- 1 file changed, 49 insertions(+), 36 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/host/ohci-omap.c b/drivers/usb/host/ohci-omap.c index d8d35d456456..a4bdd2b7af83 100644 --- a/drivers/usb/host/ohci-omap.c +++ b/drivers/usb/host/ohci-omap.c @@ -69,22 +69,27 @@ static inline int tps65010_set_gpio_out_value(unsigned gpio, unsigned value) #endif -static struct clk *usb_host_ck; -static struct clk *usb_dc_ck; +struct ohci_omap_priv { + struct clk *usb_host_ck; + struct clk *usb_dc_ck; +}; static const char hcd_name[] = "ohci-omap"; static struct hc_driver __read_mostly ohci_omap_hc_driver; -static void omap_ohci_clock_power(int on) +#define hcd_to_ohci_omap_priv(h) \ + ((struct ohci_omap_priv *)hcd_to_ohci(h)->priv) + +static void omap_ohci_clock_power(struct ohci_omap_priv *priv, int on) { if (on) { - clk_enable(usb_dc_ck); - clk_enable(usb_host_ck); + clk_enable(priv->usb_dc_ck); + clk_enable(priv->usb_host_ck); /* guesstimate for T5 == 1x 32K clock + APLL lock time */ udelay(100); } else { - clk_disable(usb_host_ck); - clk_disable(usb_dc_ck); + clk_disable(priv->usb_host_ck); + clk_disable(priv->usb_dc_ck); } } @@ -196,6 +201,7 @@ static int ohci_omap_reset(struct usb_hcd *hcd) { struct ohci_hcd *ohci = hcd_to_ohci(hcd); struct omap_usb_config *config = dev_get_platdata(hcd->self.controller); + struct ohci_omap_priv *priv = hcd_to_ohci_omap_priv(hcd); int need_transceiver = (config->otg != 0); int ret; @@ -235,7 +241,7 @@ static int ohci_omap_reset(struct usb_hcd *hcd) } #endif - omap_ohci_clock_power(1); + omap_ohci_clock_power(priv, 1); if (cpu_is_omap15xx()) { omap_1510_local_bus_power(1); @@ -305,6 +311,7 @@ static int ohci_hcd_omap_probe(struct platform_device *pdev) { int retval, irq; struct usb_hcd *hcd = 0; + struct ohci_omap_priv *priv; if (pdev->num_resources != 2) { dev_err(&pdev->dev, "invalid num_resources: %i\n", @@ -318,34 +325,35 @@ static int ohci_hcd_omap_probe(struct platform_device *pdev) return -ENODEV; } - usb_host_ck = clk_get(&pdev->dev, "usb_hhc_ck"); - if (IS_ERR(usb_host_ck)) - return PTR_ERR(usb_host_ck); + hcd = usb_create_hcd(&ohci_omap_hc_driver, &pdev->dev, + dev_name(&pdev->dev)); + if (!hcd) + return -ENOMEM; - if (!cpu_is_omap15xx()) - usb_dc_ck = clk_get(&pdev->dev, "usb_dc_ck"); - else - usb_dc_ck = clk_get(&pdev->dev, "lb_ck"); + hcd->rsrc_start = pdev->resource[0].start; + hcd->rsrc_len = pdev->resource[0].end - pdev->resource[0].start + 1; + priv = hcd_to_ohci_omap_priv(hcd); - if (IS_ERR(usb_dc_ck)) { - clk_put(usb_host_ck); - return PTR_ERR(usb_dc_ck); + priv->usb_host_ck = clk_get(&pdev->dev, "usb_hhc_ck"); + if (IS_ERR(priv->usb_host_ck)) { + retval = PTR_ERR(priv->usb_host_ck); + goto err_put_hcd; } + if (!cpu_is_omap15xx()) + priv->usb_dc_ck = clk_get(&pdev->dev, "usb_dc_ck"); + else + priv->usb_dc_ck = clk_get(&pdev->dev, "lb_ck"); - hcd = usb_create_hcd(&ohci_omap_hc_driver, &pdev->dev, - dev_name(&pdev->dev)); - if (!hcd) { - retval = -ENOMEM; - goto err0; + if (IS_ERR(priv->usb_dc_ck)) { + retval = PTR_ERR(priv->usb_dc_ck); + goto err_put_host_ck; } - hcd->rsrc_start = pdev->resource[0].start; - hcd->rsrc_len = pdev->resource[0].end - pdev->resource[0].start + 1; if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { dev_dbg(&pdev->dev, "request_mem_region failed\n"); retval = -EBUSY; - goto err1; + goto err_put_dc_ck; } hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); @@ -370,11 +378,12 @@ err3: iounmap(hcd->regs); err2: release_mem_region(hcd->rsrc_start, hcd->rsrc_len); -err1: +err_put_dc_ck: + clk_put(priv->usb_dc_ck); +err_put_host_ck: + clk_put(priv->usb_host_ck); +err_put_hcd: usb_put_hcd(hcd); -err0: - clk_put(usb_dc_ck); - clk_put(usb_host_ck); return retval; } @@ -393,10 +402,11 @@ err0: static int ohci_hcd_omap_remove(struct platform_device *pdev) { struct usb_hcd *hcd = platform_get_drvdata(pdev); + struct ohci_omap_priv *priv = hcd_to_ohci_omap_priv(hcd); dev_dbg(hcd->self.controller, "stopping USB Controller\n"); usb_remove_hcd(hcd); - omap_ohci_clock_power(0); + omap_ohci_clock_power(priv, 0); if (!IS_ERR_OR_NULL(hcd->usb_phy)) { (void) otg_set_host(hcd->usb_phy->otg, 0); usb_put_phy(hcd->usb_phy); @@ -405,9 +415,9 @@ static int ohci_hcd_omap_remove(struct platform_device *pdev) gpio_free(9); iounmap(hcd->regs); release_mem_region(hcd->rsrc_start, hcd->rsrc_len); + clk_put(priv->usb_dc_ck); + clk_put(priv->usb_host_ck); usb_put_hcd(hcd); - clk_put(usb_dc_ck); - clk_put(usb_host_ck); return 0; } @@ -419,6 +429,7 @@ static int ohci_omap_suspend(struct platform_device *pdev, pm_message_t message) { struct usb_hcd *hcd = platform_get_drvdata(pdev); struct ohci_hcd *ohci = hcd_to_ohci(hcd); + struct ohci_omap_priv *priv = hcd_to_ohci_omap_priv(hcd); bool do_wakeup = device_may_wakeup(&pdev->dev); int ret; @@ -430,7 +441,7 @@ static int ohci_omap_suspend(struct platform_device *pdev, pm_message_t message) if (ret) return ret; - omap_ohci_clock_power(0); + omap_ohci_clock_power(priv, 0); return ret; } @@ -438,12 +449,13 @@ static int ohci_omap_resume(struct platform_device *dev) { struct usb_hcd *hcd = platform_get_drvdata(dev); struct ohci_hcd *ohci = hcd_to_ohci(hcd); + struct ohci_omap_priv *priv = hcd_to_ohci_omap_priv(hcd); if (time_before(jiffies, ohci->next_statechange)) msleep(5); ohci->next_statechange = jiffies; - omap_ohci_clock_power(1); + omap_ohci_clock_power(priv, 1); ohci_resume(hcd, false); return 0; } @@ -470,7 +482,8 @@ static struct platform_driver ohci_hcd_omap_driver = { static const struct ohci_driver_overrides omap_overrides __initconst = { .product_desc = "OMAP OHCI", - .reset = ohci_omap_reset + .reset = ohci_omap_reset, + .extra_priv_size = sizeof(struct ohci_omap_priv), }; static int __init ohci_omap_init(void) -- cgit v1.2.3-70-g09d2 From 15d157e874437e381643c37a10922388d6e55b29 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 20 Jul 2020 15:55:24 +0200 Subject: usb: ohci-omap: Convert to use GPIO descriptors The OMAP1 OHCI driver is using the legacy GPIO API to grab some random GPIO lines. One is from the TPS65010 chip and used for power, another one is for overcurrent and while the driver picks this line it doesn't watch it at all. Convert the driver and the OMAP1 OSK board file to pass these two GPIOs as machine described GPIO descriptors. I noticed the overcurrent GPIO line is not really used in the code so dropped in a little comment for other developers. Cc: Janusz Krzysztofik Cc: Tony Lindgren Acked-by: Alan Stern Signed-off-by: Linus Walleij Link: https://lore.kernel.org/r/20200720135524.100374-2-linus.walleij@linaro.org Signed-off-by: Greg Kroah-Hartman --- arch/arm/mach-omap1/board-osk.c | 17 ++++++++++++ drivers/usb/host/ohci-omap.c | 59 ++++++++++++++++++++++------------------- 2 files changed, 49 insertions(+), 27 deletions(-) (limited to 'drivers/usb') diff --git a/arch/arm/mach-omap1/board-osk.c b/arch/arm/mach-omap1/board-osk.c index 4df15e693b6e..144b9caa935c 100644 --- a/arch/arm/mach-omap1/board-osk.c +++ b/arch/arm/mach-omap1/board-osk.c @@ -26,6 +26,7 @@ * 675 Mass Ave, Cambridge, MA 02139, USA. */ #include +#include #include #include #include @@ -55,6 +56,9 @@ #include "common.h" +/* Name of the GPIO chip used by the OMAP for GPIOs 0..15 */ +#define OMAP_GPIO_LABEL "gpio-0-15" + /* At OMAP5912 OSK the Ethernet is directly connected to CS1 */ #define OMAP_OSK_ETHR_START 0x04800300 @@ -240,7 +244,9 @@ static struct tps65010_board tps_board = { static struct i2c_board_info __initdata osk_i2c_board_info[] = { { + /* This device will get the name "i2c-tps65010" */ I2C_BOARD_INFO("tps65010", 0x48), + .dev_name = "tps65010", .platform_data = &tps_board, }, @@ -278,6 +284,16 @@ static void __init osk_init_cf(void) irq_set_irq_type(gpio_to_irq(62), IRQ_TYPE_EDGE_FALLING); } +static struct gpiod_lookup_table osk_usb_gpio_table = { + .dev_id = "ohci", + .table = { + /* Power GPIO on the I2C-attached TPS65010 */ + GPIO_LOOKUP("i2c-tps65010", 1, "power", GPIO_ACTIVE_HIGH), + GPIO_LOOKUP(OMAP_GPIO_LABEL, 9, "overcurrent", + GPIO_ACTIVE_HIGH), + }, +}; + static struct omap_usb_config osk_usb_config __initdata = { /* has usb host connector (A) ... for development it can also * be used, with a NONSTANDARD gender-bending cable/dongle, as @@ -581,6 +597,7 @@ static void __init osk_init(void) l |= (3 << 1); omap_writel(l, USB_TRANSCEIVER_CTRL); + gpiod_add_lookup_table(&osk_usb_gpio_table); omap1_usb_init(&osk_usb_config); /* irq for tps65010 chip */ diff --git a/drivers/usb/host/ohci-omap.c b/drivers/usb/host/ohci-omap.c index a4bdd2b7af83..9ccdf2c216b5 100644 --- a/drivers/usb/host/ohci-omap.c +++ b/drivers/usb/host/ohci-omap.c @@ -18,7 +18,7 @@ #include #include #include -#include +#include #include #include #include @@ -53,25 +53,11 @@ #define DRIVER_DESC "OHCI OMAP driver" -#ifdef CONFIG_TPS65010 -#include -#else - -#define LOW 0 -#define HIGH 1 - -#define GPIO1 1 - -static inline int tps65010_set_gpio_out_value(unsigned gpio, unsigned value) -{ - return 0; -} - -#endif - struct ohci_omap_priv { struct clk *usb_host_ck; struct clk *usb_dc_ck; + struct gpio_desc *power; + struct gpio_desc *overcurrent; }; static const char hcd_name[] = "ohci-omap"; @@ -97,22 +83,22 @@ static void omap_ohci_clock_power(struct ohci_omap_priv *priv, int on) * Board specific gang-switched transceiver power on/off. * NOTE: OSK supplies power from DC, not battery. */ -static int omap_ohci_transceiver_power(int on) +static int omap_ohci_transceiver_power(struct ohci_omap_priv *priv, int on) { if (on) { if (machine_is_omap_innovator() && cpu_is_omap1510()) __raw_writeb(__raw_readb(INNOVATOR_FPGA_CAM_USB_CONTROL) | ((1 << 5/*usb1*/) | (1 << 3/*usb2*/)), INNOVATOR_FPGA_CAM_USB_CONTROL); - else if (machine_is_omap_osk()) - tps65010_set_gpio_out_value(GPIO1, LOW); + else if (priv->power) + gpiod_set_value(priv->power, 0); } else { if (machine_is_omap_innovator() && cpu_is_omap1510()) __raw_writeb(__raw_readb(INNOVATOR_FPGA_CAM_USB_CONTROL) & ~((1 << 5/*usb1*/) | (1 << 3/*usb2*/)), INNOVATOR_FPGA_CAM_USB_CONTROL); - else if (machine_is_omap_osk()) - tps65010_set_gpio_out_value(GPIO1, HIGH); + else if (priv->power) + gpiod_set_value(priv->power, 1); } return 0; @@ -272,8 +258,6 @@ static int ohci_omap_reset(struct usb_hcd *hcd) /* gpio9 for overcurrent detction */ omap_cfg_reg(W8_1610_GPIO9); - gpio_request(9, "OHCI overcurrent"); - gpio_direction_input(9); /* for paranoia's sake: disable USB.PUEN */ omap_cfg_reg(W4_USB_HIGHZ); @@ -287,7 +271,7 @@ static int ohci_omap_reset(struct usb_hcd *hcd) } /* FIXME hub_wq hub requests should manage power switching */ - omap_ohci_transceiver_power(1); + omap_ohci_transceiver_power(priv, 1); /* board init will have already handled HMC and mux setup. * any external transceiver should already be initialized @@ -334,6 +318,29 @@ static int ohci_hcd_omap_probe(struct platform_device *pdev) hcd->rsrc_len = pdev->resource[0].end - pdev->resource[0].start + 1; priv = hcd_to_ohci_omap_priv(hcd); + /* Obtain two optional GPIO lines */ + priv->power = devm_gpiod_get_optional(&pdev->dev, "power", GPIOD_ASIS); + if (IS_ERR(priv->power)) { + retval = PTR_ERR(priv->power); + goto err_put_hcd; + } + if (priv->power) + gpiod_set_consumer_name(priv->power, "OHCI power"); + + /* + * This "overcurrent" GPIO line isn't really used in the code, + * but has a designated hardware function. + * TODO: implement proper overcurrent handling. + */ + priv->overcurrent = devm_gpiod_get_optional(&pdev->dev, "overcurrent", + GPIOD_IN); + if (IS_ERR(priv->overcurrent)) { + retval = PTR_ERR(priv->overcurrent); + goto err_put_hcd; + } + if (priv->overcurrent) + gpiod_set_consumer_name(priv->overcurrent, "OHCI overcurrent"); + priv->usb_host_ck = clk_get(&pdev->dev, "usb_hhc_ck"); if (IS_ERR(priv->usb_host_ck)) { retval = PTR_ERR(priv->usb_host_ck); @@ -411,8 +418,6 @@ static int ohci_hcd_omap_remove(struct platform_device *pdev) (void) otg_set_host(hcd->usb_phy->otg, 0); usb_put_phy(hcd->usb_phy); } - if (machine_is_omap_osk()) - gpio_free(9); iounmap(hcd->regs); release_mem_region(hcd->rsrc_start, hcd->rsrc_len); clk_put(priv->usb_dc_ck); -- cgit v1.2.3-70-g09d2 From c17536d0abde2fd24afca542e3bb73b45a299633 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Wed, 22 Jul 2020 09:36:55 +0200 Subject: usb: usbfs: stop using compat_alloc_user_space Just switch the low-level routines to take kernel structures, and do the conversion from the compat to the native structure on that. Signed-off-by: Christoph Hellwig Link: https://lore.kernel.org/r/20200722073655.220011-1-hch@lst.de Signed-off-by: Greg Kroah-Hartman --- drivers/usb/core/devio.c | 126 ++++++++++++++++++++++++++--------------------- 1 file changed, 69 insertions(+), 57 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c index 96d4507d988a..e96a858a1218 100644 --- a/drivers/usb/core/devio.c +++ b/drivers/usb/core/devio.c @@ -1102,22 +1102,20 @@ static int usbdev_release(struct inode *inode, struct file *file) return 0; } -static int proc_control(struct usb_dev_state *ps, void __user *arg) +static int do_proc_control(struct usb_dev_state *ps, + struct usbdevfs_ctrltransfer *ctrl) { struct usb_device *dev = ps->dev; - struct usbdevfs_ctrltransfer ctrl; unsigned int tmo; unsigned char *tbuf; unsigned wLength; int i, pipe, ret; - if (copy_from_user(&ctrl, arg, sizeof(ctrl))) - return -EFAULT; - ret = check_ctrlrecip(ps, ctrl.bRequestType, ctrl.bRequest, - ctrl.wIndex); + ret = check_ctrlrecip(ps, ctrl->bRequestType, ctrl->bRequest, + ctrl->wIndex); if (ret) return ret; - wLength = ctrl.wLength; /* To suppress 64k PAGE_SIZE warning */ + wLength = ctrl->wLength; /* To suppress 64k PAGE_SIZE warning */ if (wLength > PAGE_SIZE) return -EINVAL; ret = usbfs_increase_memory_usage(PAGE_SIZE + sizeof(struct urb) + @@ -1129,52 +1127,52 @@ static int proc_control(struct usb_dev_state *ps, void __user *arg) ret = -ENOMEM; goto done; } - tmo = ctrl.timeout; + tmo = ctrl->timeout; snoop(&dev->dev, "control urb: bRequestType=%02x " "bRequest=%02x wValue=%04x " "wIndex=%04x wLength=%04x\n", - ctrl.bRequestType, ctrl.bRequest, ctrl.wValue, - ctrl.wIndex, ctrl.wLength); - if (ctrl.bRequestType & 0x80) { + ctrl->bRequestType, ctrl->bRequest, ctrl->wValue, + ctrl->wIndex, ctrl->wLength); + if (ctrl->bRequestType & 0x80) { pipe = usb_rcvctrlpipe(dev, 0); - snoop_urb(dev, NULL, pipe, ctrl.wLength, tmo, SUBMIT, NULL, 0); + snoop_urb(dev, NULL, pipe, ctrl->wLength, tmo, SUBMIT, NULL, 0); usb_unlock_device(dev); - i = usb_control_msg(dev, pipe, ctrl.bRequest, - ctrl.bRequestType, ctrl.wValue, ctrl.wIndex, - tbuf, ctrl.wLength, tmo); + i = usb_control_msg(dev, pipe, ctrl->bRequest, + ctrl->bRequestType, ctrl->wValue, ctrl->wIndex, + tbuf, ctrl->wLength, tmo); usb_lock_device(dev); snoop_urb(dev, NULL, pipe, max(i, 0), min(i, 0), COMPLETE, tbuf, max(i, 0)); - if ((i > 0) && ctrl.wLength) { - if (copy_to_user(ctrl.data, tbuf, i)) { + if ((i > 0) && ctrl->wLength) { + if (copy_to_user(ctrl->data, tbuf, i)) { ret = -EFAULT; goto done; } } } else { - if (ctrl.wLength) { - if (copy_from_user(tbuf, ctrl.data, ctrl.wLength)) { + if (ctrl->wLength) { + if (copy_from_user(tbuf, ctrl->data, ctrl->wLength)) { ret = -EFAULT; goto done; } } pipe = usb_sndctrlpipe(dev, 0); - snoop_urb(dev, NULL, pipe, ctrl.wLength, tmo, SUBMIT, - tbuf, ctrl.wLength); + snoop_urb(dev, NULL, pipe, ctrl->wLength, tmo, SUBMIT, + tbuf, ctrl->wLength); usb_unlock_device(dev); - i = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), ctrl.bRequest, - ctrl.bRequestType, ctrl.wValue, ctrl.wIndex, - tbuf, ctrl.wLength, tmo); + i = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), ctrl->bRequest, + ctrl->bRequestType, ctrl->wValue, ctrl->wIndex, + tbuf, ctrl->wLength, tmo); usb_lock_device(dev); snoop_urb(dev, NULL, pipe, max(i, 0), min(i, 0), COMPLETE, NULL, 0); } if (i < 0 && i != -EPIPE) { dev_printk(KERN_DEBUG, &dev->dev, "usbfs: USBDEVFS_CONTROL " "failed cmd %s rqt %u rq %u len %u ret %d\n", - current->comm, ctrl.bRequestType, ctrl.bRequest, - ctrl.wLength, i); + current->comm, ctrl->bRequestType, ctrl->bRequest, + ctrl->wLength, i); } ret = i; done: @@ -1184,30 +1182,37 @@ static int proc_control(struct usb_dev_state *ps, void __user *arg) return ret; } -static int proc_bulk(struct usb_dev_state *ps, void __user *arg) +static int proc_control(struct usb_dev_state *ps, void __user *arg) +{ + struct usbdevfs_ctrltransfer ctrl; + + if (copy_from_user(&ctrl, arg, sizeof(ctrl))) + return -EFAULT; + return do_proc_control(ps, &ctrl); +} + +static int do_proc_bulk(struct usb_dev_state *ps, + struct usbdevfs_bulktransfer *bulk) { struct usb_device *dev = ps->dev; - struct usbdevfs_bulktransfer bulk; unsigned int tmo, len1, pipe; int len2; unsigned char *tbuf; int i, ret; - if (copy_from_user(&bulk, arg, sizeof(bulk))) - return -EFAULT; - ret = findintfep(ps->dev, bulk.ep); + ret = findintfep(ps->dev, bulk->ep); if (ret < 0) return ret; ret = checkintf(ps, ret); if (ret) return ret; - if (bulk.ep & USB_DIR_IN) - pipe = usb_rcvbulkpipe(dev, bulk.ep & 0x7f); + if (bulk->ep & USB_DIR_IN) + pipe = usb_rcvbulkpipe(dev, bulk->ep & 0x7f); else - pipe = usb_sndbulkpipe(dev, bulk.ep & 0x7f); - if (!usb_maxpacket(dev, pipe, !(bulk.ep & USB_DIR_IN))) + pipe = usb_sndbulkpipe(dev, bulk->ep & 0x7f); + if (!usb_maxpacket(dev, pipe, !(bulk->ep & USB_DIR_IN))) return -EINVAL; - len1 = bulk.len; + len1 = bulk->len; if (len1 >= (INT_MAX - sizeof(struct urb))) return -EINVAL; ret = usbfs_increase_memory_usage(len1 + sizeof(struct urb)); @@ -1218,8 +1223,8 @@ static int proc_bulk(struct usb_dev_state *ps, void __user *arg) ret = -ENOMEM; goto done; } - tmo = bulk.timeout; - if (bulk.ep & 0x80) { + tmo = bulk->timeout; + if (bulk->ep & 0x80) { snoop_urb(dev, NULL, pipe, len1, tmo, SUBMIT, NULL, 0); usb_unlock_device(dev); @@ -1228,14 +1233,14 @@ static int proc_bulk(struct usb_dev_state *ps, void __user *arg) snoop_urb(dev, NULL, pipe, len2, i, COMPLETE, tbuf, len2); if (!i && len2) { - if (copy_to_user(bulk.data, tbuf, len2)) { + if (copy_to_user(bulk->data, tbuf, len2)) { ret = -EFAULT; goto done; } } } else { if (len1) { - if (copy_from_user(tbuf, bulk.data, len1)) { + if (copy_from_user(tbuf, bulk->data, len1)) { ret = -EFAULT; goto done; } @@ -1254,6 +1259,15 @@ static int proc_bulk(struct usb_dev_state *ps, void __user *arg) return ret; } +static int proc_bulk(struct usb_dev_state *ps, void __user *arg) +{ + struct usbdevfs_bulktransfer bulk; + + if (copy_from_user(&bulk, arg, sizeof(bulk))) + return -EFAULT; + return do_proc_bulk(ps, &bulk); +} + static void check_reset_of_active_ep(struct usb_device *udev, unsigned int epnum, char *ioctl_name) { @@ -2013,33 +2027,31 @@ static int proc_reapurbnonblock(struct usb_dev_state *ps, void __user *arg) static int proc_control_compat(struct usb_dev_state *ps, struct usbdevfs_ctrltransfer32 __user *p32) { - struct usbdevfs_ctrltransfer __user *p; - __u32 udata; - p = compat_alloc_user_space(sizeof(*p)); - if (copy_in_user(p, p32, (sizeof(*p32) - sizeof(compat_caddr_t))) || - get_user(udata, &p32->data) || - put_user(compat_ptr(udata), &p->data)) + struct usbdevfs_ctrltransfer ctrl; + u32 udata; + + if (copy_from_user(&ctrl, p32, sizeof(*p32) - sizeof(compat_caddr_t)) || + get_user(udata, &p32->data)) return -EFAULT; - return proc_control(ps, p); + ctrl.data = compat_ptr(udata); + return do_proc_control(ps, &ctrl); } static int proc_bulk_compat(struct usb_dev_state *ps, struct usbdevfs_bulktransfer32 __user *p32) { - struct usbdevfs_bulktransfer __user *p; - compat_uint_t n; + struct usbdevfs_bulktransfer bulk; compat_caddr_t addr; - p = compat_alloc_user_space(sizeof(*p)); - - if (get_user(n, &p32->ep) || put_user(n, &p->ep) || - get_user(n, &p32->len) || put_user(n, &p->len) || - get_user(n, &p32->timeout) || put_user(n, &p->timeout) || - get_user(addr, &p32->data) || put_user(compat_ptr(addr), &p->data)) + if (get_user(bulk.ep, &p32->ep) || + get_user(bulk.len, &p32->len) || + get_user(bulk.timeout, &p32->timeout) || + get_user(addr, &p32->data)) return -EFAULT; - - return proc_bulk(ps, p); + bulk.data = compat_ptr(addr); + return do_proc_bulk(ps, &bulk); } + static int proc_disconnectsignal_compat(struct usb_dev_state *ps, void __user *arg) { struct usbdevfs_disconnectsignal32 ds; -- cgit v1.2.3-70-g09d2 From bc0f0d4a5853e32ba97a0318f774570428fc5634 Mon Sep 17 00:00:00 2001 From: Amelie Delaunay Date: Tue, 16 Jun 2020 16:07:15 +0200 Subject: usb: dwc2: override PHY input signals with usb role switch support This patch adds support for usb role switch to dwc2, by using overriding control of the PHY voltage valid and ID input signals. iddig signal (ID) can be overridden: - when setting GUSBCFG_FORCEHOSTMODE, iddig input pin is overridden with 1; - when setting GUSBCFG_FORCEDEVMODE, iddig input pin is overridden with 0. avalid/bvalid/vbusvalid signals can be overridden respectively with: - GOTGCTL_AVALOEN + GOTGCTL_AVALOVAL - GOTGCTL_BVALOEN + GOTGCTL_BVALOVAL - GOTGCTL_VBVALEN + GOTGCTL_VBVALOVAL It is possible to determine valid sessions thanks to usb role switch: - if USB_ROLE_NONE then !avalid && !bvalid && !vbusvalid - if USB_ROLE_DEVICE then !avalid && bvalid && vbusvalid - if USB_ROLE_HOST then avalid && !bvalid && vbusvalid Acked-by: Minas Harutyunyan Signed-off-by: Amelie Delaunay Signed-off-by: Felipe Balbi --- drivers/usb/dwc2/Kconfig | 1 + drivers/usb/dwc2/Makefile | 2 +- drivers/usb/dwc2/core.h | 8 ++ drivers/usb/dwc2/drd.c | 190 ++++++++++++++++++++++++++++++++++++++++++++ drivers/usb/dwc2/gadget.c | 2 +- drivers/usb/dwc2/platform.c | 13 +++ 6 files changed, 214 insertions(+), 2 deletions(-) create mode 100644 drivers/usb/dwc2/drd.c (limited to 'drivers/usb') diff --git a/drivers/usb/dwc2/Kconfig b/drivers/usb/dwc2/Kconfig index 16e1aa304edc..dceb8f32414e 100644 --- a/drivers/usb/dwc2/Kconfig +++ b/drivers/usb/dwc2/Kconfig @@ -47,6 +47,7 @@ config USB_DWC2_PERIPHERAL config USB_DWC2_DUAL_ROLE bool "Dual Role mode" depends on (USB=y && USB_GADGET=y) || (USB_DWC2=m && USB && USB_GADGET) + select USB_ROLE_SWITCH help Select this option if you want the driver to work in a dual-role mode. In this mode both host and gadget features are enabled, and diff --git a/drivers/usb/dwc2/Makefile b/drivers/usb/dwc2/Makefile index 440320cc20a4..2bcd6945df46 100644 --- a/drivers/usb/dwc2/Makefile +++ b/drivers/usb/dwc2/Makefile @@ -3,7 +3,7 @@ ccflags-$(CONFIG_USB_DWC2_DEBUG) += -DDEBUG ccflags-$(CONFIG_USB_DWC2_VERBOSE) += -DVERBOSE_DEBUG obj-$(CONFIG_USB_DWC2) += dwc2.o -dwc2-y := core.o core_intr.o platform.o +dwc2-y := core.o core_intr.o platform.o drd.o dwc2-y += params.o ifneq ($(filter y,$(CONFIG_USB_DWC2_HOST) $(CONFIG_USB_DWC2_DUAL_ROLE)),) diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h index 9deff0400a92..33e790ccefb3 100644 --- a/drivers/usb/dwc2/core.h +++ b/drivers/usb/dwc2/core.h @@ -860,6 +860,7 @@ struct dwc2_hregs_backup { * - USB_DR_MODE_PERIPHERAL * - USB_DR_MODE_HOST * - USB_DR_MODE_OTG + * @role_sw: usb_role_switch handle * @hcd_enabled: Host mode sub-driver initialization indicator. * @gadget_enabled: Peripheral mode sub-driver initialization indicator. * @ll_hw_enabled: Status of low-level hardware resources. @@ -1054,6 +1055,7 @@ struct dwc2_hsotg { struct dwc2_core_params params; enum usb_otg_state op_state; enum usb_dr_mode dr_mode; + struct usb_role_switch *role_sw; unsigned int hcd_enabled:1; unsigned int gadget_enabled:1; unsigned int ll_hw_enabled:1; @@ -1376,6 +1378,11 @@ static inline int dwc2_is_device_mode(struct dwc2_hsotg *hsotg) return (dwc2_readl(hsotg, GINTSTS) & GINTSTS_CURMODE_HOST) == 0; } +int dwc2_drd_init(struct dwc2_hsotg *hsotg); +void dwc2_drd_suspend(struct dwc2_hsotg *hsotg); +void dwc2_drd_resume(struct dwc2_hsotg *hsotg); +void dwc2_drd_exit(struct dwc2_hsotg *hsotg); + /* * Dump core registers and SPRAM */ @@ -1392,6 +1399,7 @@ int dwc2_hsotg_resume(struct dwc2_hsotg *dwc2); int dwc2_gadget_init(struct dwc2_hsotg *hsotg); void dwc2_hsotg_core_init_disconnected(struct dwc2_hsotg *dwc2, bool reset); +void dwc2_hsotg_core_disconnect(struct dwc2_hsotg *hsotg); void dwc2_hsotg_core_connect(struct dwc2_hsotg *hsotg); void dwc2_hsotg_disconnect(struct dwc2_hsotg *dwc2); int dwc2_hsotg_set_test_mode(struct dwc2_hsotg *hsotg, int testmode); diff --git a/drivers/usb/dwc2/drd.c b/drivers/usb/dwc2/drd.c new file mode 100644 index 000000000000..032efffa37ab --- /dev/null +++ b/drivers/usb/dwc2/drd.c @@ -0,0 +1,190 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * drd.c - DesignWare USB2 DRD Controller Dual-role support + * + * Copyright (C) 2020 STMicroelectronics + * + * Author(s): Amelie Delaunay + */ + +#include +#include +#include +#include "core.h" + +static void dwc2_ovr_init(struct dwc2_hsotg *hsotg) +{ + unsigned long flags; + u32 gotgctl; + + spin_lock_irqsave(&hsotg->lock, flags); + + gotgctl = dwc2_readl(hsotg, GOTGCTL); + gotgctl |= GOTGCTL_BVALOEN | GOTGCTL_AVALOEN | GOTGCTL_VBVALOEN; + gotgctl |= GOTGCTL_DBNCE_FLTR_BYPASS; + gotgctl &= ~(GOTGCTL_BVALOVAL | GOTGCTL_AVALOVAL | GOTGCTL_VBVALOVAL); + dwc2_writel(hsotg, gotgctl, GOTGCTL); + + dwc2_force_mode(hsotg, false); + + spin_unlock_irqrestore(&hsotg->lock, flags); +} + +static int dwc2_ovr_avalid(struct dwc2_hsotg *hsotg, bool valid) +{ + u32 gotgctl = dwc2_readl(hsotg, GOTGCTL); + + /* Check if A-Session is already in the right state */ + if ((valid && (gotgctl & GOTGCTL_ASESVLD)) || + (!valid && !(gotgctl & GOTGCTL_ASESVLD))) + return -EALREADY; + + if (valid) + gotgctl |= GOTGCTL_AVALOVAL | GOTGCTL_VBVALOVAL; + else + gotgctl &= ~(GOTGCTL_AVALOVAL | GOTGCTL_VBVALOVAL); + dwc2_writel(hsotg, gotgctl, GOTGCTL); + + return 0; +} + +static int dwc2_ovr_bvalid(struct dwc2_hsotg *hsotg, bool valid) +{ + u32 gotgctl = dwc2_readl(hsotg, GOTGCTL); + + /* Check if B-Session is already in the right state */ + if ((valid && (gotgctl & GOTGCTL_BSESVLD)) || + (!valid && !(gotgctl & GOTGCTL_BSESVLD))) + return -EALREADY; + + if (valid) + gotgctl |= GOTGCTL_BVALOVAL | GOTGCTL_VBVALOVAL; + else + gotgctl &= ~(GOTGCTL_BVALOVAL | GOTGCTL_VBVALOVAL); + dwc2_writel(hsotg, gotgctl, GOTGCTL); + + return 0; +} + +static int dwc2_drd_role_sw_set(struct usb_role_switch *sw, enum usb_role role) +{ + struct dwc2_hsotg *hsotg = usb_role_switch_get_drvdata(sw); + unsigned long flags; + + /* Skip session not in line with dr_mode */ + if ((role == USB_ROLE_DEVICE && hsotg->dr_mode == USB_DR_MODE_HOST) || + (role == USB_ROLE_HOST && hsotg->dr_mode == USB_DR_MODE_PERIPHERAL)) + return -EINVAL; + + /* Skip session if core is in test mode */ + if (role == USB_ROLE_NONE && hsotg->test_mode) { + dev_dbg(hsotg->dev, "Core is in test mode\n"); + return -EBUSY; + } + + spin_lock_irqsave(&hsotg->lock, flags); + + if (role == USB_ROLE_HOST) { + if (dwc2_ovr_avalid(hsotg, true)) + goto unlock; + + if (hsotg->dr_mode == USB_DR_MODE_OTG) + /* + * This will raise a Connector ID Status Change + * Interrupt - connID A + */ + dwc2_force_mode(hsotg, true); + } else if (role == USB_ROLE_DEVICE) { + if (dwc2_ovr_bvalid(hsotg, true)) + goto unlock; + + if (hsotg->dr_mode == USB_DR_MODE_OTG) + /* + * This will raise a Connector ID Status Change + * Interrupt - connID B + */ + dwc2_force_mode(hsotg, false); + + /* This clear DCTL.SFTDISCON bit */ + dwc2_hsotg_core_connect(hsotg); + } else { + if (dwc2_is_device_mode(hsotg)) { + if (!dwc2_ovr_bvalid(hsotg, false)) + /* This set DCTL.SFTDISCON bit */ + dwc2_hsotg_core_disconnect(hsotg); + } else { + dwc2_ovr_avalid(hsotg, false); + } + } + +unlock: + spin_unlock_irqrestore(&hsotg->lock, flags); + + dev_dbg(hsotg->dev, "%s-session valid\n", + role == USB_ROLE_NONE ? "No" : + role == USB_ROLE_HOST ? "A" : "B"); + + return 0; +} + +int dwc2_drd_init(struct dwc2_hsotg *hsotg) +{ + struct usb_role_switch_desc role_sw_desc = {0}; + struct usb_role_switch *role_sw; + int ret; + + if (!device_property_read_bool(hsotg->dev, "usb-role-switch")) + return 0; + + role_sw_desc.driver_data = hsotg; + role_sw_desc.fwnode = dev_fwnode(hsotg->dev); + role_sw_desc.set = dwc2_drd_role_sw_set; + role_sw_desc.allow_userspace_control = true; + + role_sw = usb_role_switch_register(hsotg->dev, &role_sw_desc); + if (IS_ERR(role_sw)) { + ret = PTR_ERR(role_sw); + dev_err(hsotg->dev, + "failed to register role switch: %d\n", ret); + return ret; + } + + hsotg->role_sw = role_sw; + + /* Enable override and initialize values */ + dwc2_ovr_init(hsotg); + + return 0; +} + +void dwc2_drd_suspend(struct dwc2_hsotg *hsotg) +{ + u32 gintsts, gintmsk; + + if (hsotg->role_sw && !hsotg->params.external_id_pin_ctl) { + gintmsk = dwc2_readl(hsotg, GINTMSK); + gintmsk &= ~GINTSTS_CONIDSTSCHNG; + dwc2_writel(hsotg, gintmsk, GINTMSK); + gintsts = dwc2_readl(hsotg, GINTSTS); + dwc2_writel(hsotg, gintsts | GINTSTS_CONIDSTSCHNG, GINTSTS); + } +} + +void dwc2_drd_resume(struct dwc2_hsotg *hsotg) +{ + u32 gintsts, gintmsk; + + if (hsotg->role_sw && !hsotg->params.external_id_pin_ctl) { + gintsts = dwc2_readl(hsotg, GINTSTS); + dwc2_writel(hsotg, gintsts | GINTSTS_CONIDSTSCHNG, GINTSTS); + gintmsk = dwc2_readl(hsotg, GINTMSK); + gintmsk |= GINTSTS_CONIDSTSCHNG; + dwc2_writel(hsotg, gintmsk, GINTMSK); + } +} + +void dwc2_drd_exit(struct dwc2_hsotg *hsotg) +{ + if (hsotg->role_sw) + usb_role_switch_unregister(hsotg->role_sw); +} diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index 5b9d23991c99..16c5f976f141 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -3530,7 +3530,7 @@ void dwc2_hsotg_core_init_disconnected(struct dwc2_hsotg *hsotg, dwc2_readl(hsotg, DOEPCTL0)); } -static void dwc2_hsotg_core_disconnect(struct dwc2_hsotg *hsotg) +void dwc2_hsotg_core_disconnect(struct dwc2_hsotg *hsotg) { /* set the soft-disconnect bit */ dwc2_set_bit(hsotg, DCTL, DCTL_SFTDISCON); diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c index cb8ddbd53718..8fea5f1f60ab 100644 --- a/drivers/usb/dwc2/platform.c +++ b/drivers/usb/dwc2/platform.c @@ -317,6 +317,8 @@ static int dwc2_driver_remove(struct platform_device *dev) if (hsotg->params.activate_stm_id_vb_detection) regulator_disable(hsotg->usb33d); + dwc2_drd_exit(hsotg); + if (hsotg->ll_hw_enabled) dwc2_lowlevel_hw_disable(hsotg); @@ -533,6 +535,13 @@ static int dwc2_driver_probe(struct platform_device *dev) dwc2_writel(hsotg, ggpio, GGPIO); } + retval = dwc2_drd_init(hsotg); + if (retval) { + if (retval != -EPROBE_DEFER) + dev_err(hsotg->dev, "failed to initialize dual-role\n"); + goto error_init; + } + if (hsotg->dr_mode != USB_DR_MODE_HOST) { retval = dwc2_gadget_init(hsotg); if (retval) @@ -606,6 +615,8 @@ static int __maybe_unused dwc2_suspend(struct device *dev) if (is_device_mode) dwc2_hsotg_suspend(dwc2); + dwc2_drd_suspend(dwc2); + if (dwc2->params.activate_stm_id_vb_detection) { unsigned long flags; u32 ggpio, gotgctl; @@ -686,6 +697,8 @@ static int __maybe_unused dwc2_resume(struct device *dev) /* Need to restore FORCEDEVMODE/FORCEHOSTMODE */ dwc2_force_dr_mode(dwc2); + dwc2_drd_resume(dwc2); + if (dwc2_is_device_mode(dwc2)) ret = dwc2_hsotg_resume(dwc2); -- cgit v1.2.3-70-g09d2 From 916f8b627288039d9e771a9b2ab1b3c79b303039 Mon Sep 17 00:00:00 2001 From: Amelie Delaunay Date: Tue, 16 Jun 2020 16:07:16 +0200 Subject: usb: dwc2: don't use ID/Vbus detection if usb-role-switch on STM32MP15 SoCs If usb-role-switch is present in the device tree, it means that ID and Vbus signals are not connected to the OTG controller but to an external component (GPIOs, Type-C controller). In this configuration, usb role switch is used to force valid sessions on STM32MP15 SoCs. Acked-by: Minas Harutyunyan Signed-off-by: Amelie Delaunay Signed-off-by: Felipe Balbi --- drivers/usb/dwc2/params.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'drivers/usb') diff --git a/drivers/usb/dwc2/params.c b/drivers/usb/dwc2/params.c index 8f9d061c4d5f..bd792c9cdef9 100644 --- a/drivers/usb/dwc2/params.c +++ b/drivers/usb/dwc2/params.c @@ -183,9 +183,11 @@ static void dwc2_set_stm32mp15_fsotg_params(struct dwc2_hsotg *hsotg) static void dwc2_set_stm32mp15_hsotg_params(struct dwc2_hsotg *hsotg) { struct dwc2_core_params *p = &hsotg->params; + struct device_node *np = hsotg->dev->of_node; p->otg_cap = DWC2_CAP_PARAM_NO_HNP_SRP_CAPABLE; - p->activate_stm_id_vb_detection = true; + p->activate_stm_id_vb_detection = + !of_property_read_bool(np, "usb-role-switch"); p->host_rx_fifo_size = 440; p->host_nperio_tx_fifo_size = 256; p->host_perio_tx_fifo_size = 256; -- cgit v1.2.3-70-g09d2 From 8aaf19b8ec78748b80c73319d48413dd26fecb3d Mon Sep 17 00:00:00 2001 From: Kai-Heng Feng Date: Thu, 23 Jul 2020 17:45:04 +0300 Subject: xhci: Make debug message consistent with bus and port number Current xhci debug message doesn't always output bus number, so it's hard to figure out it's from USB2 or USB3 root hub. In addition to that, some port numbers are offset to 0 and others are offset to 1. Use the latter to match the USB core. So use "bus number - port index + 1" to make debug message consistent. Signed-off-by: Kai-Heng Feng Signed-off-by: Mathias Nyman Link: https://lore.kernel.org/r/20200723144530.9992-2-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/xhci-hub.c | 41 +++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c index 073c54e42223..c3554e37e09f 100644 --- a/drivers/usb/host/xhci-hub.c +++ b/drivers/usb/host/xhci-hub.c @@ -1241,7 +1241,8 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, temp = readl(ports[wIndex]->addr); /* Disable port */ if (link_state == USB_SS_PORT_LS_SS_DISABLED) { - xhci_dbg(xhci, "Disable port %d\n", wIndex); + xhci_dbg(xhci, "Disable port %d-%d\n", + hcd->self.busnum, wIndex + 1); temp = xhci_port_state_to_neutral(temp); /* * Clear all change bits, so that we get a new @@ -1257,7 +1258,8 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, /* Put link in RxDetect (enable port) */ if (link_state == USB_SS_PORT_LS_RX_DETECT) { - xhci_dbg(xhci, "Enable port %d\n", wIndex); + xhci_dbg(xhci, "Enable port %d-%d\n", + hcd->self.busnum, wIndex + 1); xhci_set_link_state(xhci, ports[wIndex], link_state); temp = readl(ports[wIndex]->addr); @@ -1289,8 +1291,8 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, goto error; } - xhci_dbg(xhci, "Enable compliance mode transition for port %d\n", - wIndex); + xhci_dbg(xhci, "Enable compliance mode transition for port %d-%d\n", + hcd->self.busnum, wIndex + 1); xhci_set_link_state(xhci, ports[wIndex], link_state); @@ -1304,8 +1306,9 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, } /* Can't set port link state above '3' (U3) */ if (link_state > USB_SS_PORT_LS_U3) { - xhci_warn(xhci, "Cannot set port %d link state %d\n", - wIndex, link_state); + xhci_warn(xhci, "Cannot set port %d-%d link state %d\n", + hcd->self.busnum, wIndex + 1, + link_state); goto error; } @@ -1340,8 +1343,8 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, spin_unlock_irqrestore(&xhci->lock, flags); if (!wait_for_completion_timeout(&bus_state->u3exit_done[wIndex], msecs_to_jiffies(100))) - xhci_dbg(xhci, "missing U0 port change event for port %d\n", - wIndex); + xhci_dbg(xhci, "missing U0 port change event for port %d-%d\n", + hcd->self.busnum, wIndex + 1); spin_lock_irqsave(&xhci->lock, flags); temp = readl(ports[wIndex]->addr); break; @@ -1386,15 +1389,15 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, writel(temp, ports[wIndex]->addr); temp = readl(ports[wIndex]->addr); - xhci_dbg(xhci, "set port reset, actual port %d status = 0x%x\n", wIndex, temp); + xhci_dbg(xhci, "set port reset, actual port %d-%d status = 0x%x\n", + hcd->self.busnum, wIndex + 1, temp); break; case USB_PORT_FEAT_REMOTE_WAKE_MASK: xhci_set_remote_wake_mask(xhci, ports[wIndex], wake_mask); temp = readl(ports[wIndex]->addr); - xhci_dbg(xhci, "set port remote wake mask, " - "actual port %d status = 0x%x\n", - wIndex, temp); + xhci_dbg(xhci, "set port remote wake mask, actual port %d-%d status = 0x%x\n", + hcd->self.busnum, wIndex + 1, temp); break; case USB_PORT_FEAT_BH_PORT_RESET: temp |= PORT_WR; @@ -1635,8 +1638,8 @@ retry: spin_unlock_irqrestore(&xhci->lock, flags); msleep(XHCI_PORT_POLLING_LFPS_TIME); spin_lock_irqsave(&xhci->lock, flags); - xhci_dbg(xhci, "port %d polling in bus suspend, waiting\n", - port_index); + xhci_dbg(xhci, "port %d-%d polling in bus suspend, waiting\n", + hcd->self.busnum, port_index + 1); goto retry; } /* bail out if port detected a over-current condition */ @@ -1654,7 +1657,8 @@ retry: xhci_dbg(xhci, "Bus suspend bailout, port connect change\n"); return -EBUSY; } - xhci_dbg(xhci, "port %d not suspended\n", port_index); + xhci_dbg(xhci, "port %d-%d not suspended\n", + hcd->self.busnum, port_index + 1); t2 &= ~PORT_PLS_MASK; t2 |= PORT_LINK_STROBE | XDEV_U3; set_bit(port_index, &bus_state->bus_suspended); @@ -1784,7 +1788,8 @@ int xhci_bus_resume(struct usb_hcd *hcd) if ((xhci->quirks & XHCI_MISSING_CAS) && (hcd->speed >= HCD_USB3) && xhci_port_missing_cas_quirk(ports[port_index])) { - xhci_dbg(xhci, "reset stuck port %d\n", port_index); + xhci_dbg(xhci, "reset stuck port %d-%d\n", + hcd->self.busnum, port_index + 1); clear_bit(port_index, &bus_state->bus_suspended); continue; } @@ -1831,8 +1836,8 @@ int xhci_bus_resume(struct usb_hcd *hcd) sret = xhci_handshake(ports[port_index]->addr, PORT_PLC, PORT_PLC, 10 * 1000); if (sret) { - xhci_warn(xhci, "port %d resume PLC timeout\n", - port_index); + xhci_warn(xhci, "port %d-%d resume PLC timeout\n", + hcd->self.busnum, port_index + 1); continue; } xhci_test_and_clear_bit(xhci, ports[port_index], PORT_PLC); -- cgit v1.2.3-70-g09d2 From 5b43a2a84bac79fe8814949f5e173f83a5436c71 Mon Sep 17 00:00:00 2001 From: Mathias Nyman Date: Thu, 23 Jul 2020 17:45:05 +0300 Subject: xhci: dbc: Don't use generic xhci inc_deq() function for dbc The generic inc_deq() helper takes struct xhci_hcd pointer as a parameter, and is a lot more complex than needed for the DbC usecase. In order to decouple xhci and DbC we have to create our own small inc_evt_deq() helper, not relying on xhci. Signed-off-by: Mathias Nyman Link: https://lore.kernel.org/r/20200723144530.9992-3-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/xhci-dbgcap.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'drivers/usb') diff --git a/drivers/usb/host/xhci-dbgcap.c b/drivers/usb/host/xhci-dbgcap.c index 987f893e941c..424b571d6ca9 100644 --- a/drivers/usb/host/xhci-dbgcap.c +++ b/drivers/usb/host/xhci-dbgcap.c @@ -644,6 +644,17 @@ static void dbc_handle_xfer_event(struct xhci_hcd *xhci, union xhci_trb *event) xhci_dbc_giveback(req, status); } +static void inc_evt_deq(struct xhci_ring *ring) +{ + /* If on the last TRB of the segment go back to the beginning */ + if (ring->dequeue == &ring->deq_seg->trbs[TRBS_PER_SEGMENT - 1]) { + ring->cycle_state ^= 1; + ring->dequeue = ring->deq_seg->trbs; + return; + } + ring->dequeue++; +} + static enum evtreturn xhci_dbc_do_handle_events(struct xhci_dbc *dbc) { dma_addr_t deq; @@ -765,7 +776,8 @@ static enum evtreturn xhci_dbc_do_handle_events(struct xhci_dbc *dbc) break; } - inc_deq(xhci, dbc->ring_evt); + inc_evt_deq(dbc->ring_evt); + evt = dbc->ring_evt->dequeue; update_erdp = true; } -- cgit v1.2.3-70-g09d2 From e3bc8004bde77e899e8d19487440f27b55e216b2 Mon Sep 17 00:00:00 2001 From: Mathias Nyman Date: Thu, 23 Jul 2020 17:45:06 +0300 Subject: xhci: Don't pass struct xhci_hcd pointer to xhci_link_seg() It's only used to dig out if we need to set a chain flag for specific hosts. Pass the flag directly as a parameter instead. No functional changes. xhci_link_seg() is also used by DbC code, this change helps decoupling xhci and DbC. Signed-off-by: Mathias Nyman Link: https://lore.kernel.org/r/20200723144530.9992-4-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/xhci-mem.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index fb221c091478..d38779e2fc84 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c @@ -96,8 +96,9 @@ static void xhci_free_segments_for_ring(struct xhci_hcd *xhci, * DMA address of the next segment. The caller needs to set any Link TRB * related flags, such as End TRB, Toggle Cycle, and no snoop. */ -static void xhci_link_segments(struct xhci_hcd *xhci, struct xhci_segment *prev, - struct xhci_segment *next, enum xhci_ring_type type) +static void xhci_link_segments(struct xhci_segment *prev, + struct xhci_segment *next, + enum xhci_ring_type type, bool chain_links) { u32 val; @@ -112,11 +113,7 @@ static void xhci_link_segments(struct xhci_hcd *xhci, struct xhci_segment *prev, val = le32_to_cpu(prev->trbs[TRBS_PER_SEGMENT-1].link.control); val &= ~TRB_TYPE_BITMASK; val |= TRB_TYPE(TRB_LINK); - /* Always set the chain bit with 0.95 hardware */ - /* Set chain bit for isoc rings on AMD 0.96 host */ - if (xhci_link_trb_quirk(xhci) || - (type == TYPE_ISOC && - (xhci->quirks & XHCI_AMD_0x96_HOST))) + if (chain_links) val |= TRB_CHAIN; prev->trbs[TRBS_PER_SEGMENT-1].link.control = cpu_to_le32(val); } @@ -131,13 +128,19 @@ static void xhci_link_rings(struct xhci_hcd *xhci, struct xhci_ring *ring, unsigned int num_segs) { struct xhci_segment *next; + bool chain_links; if (!ring || !first || !last) return; + /* Set chain bit for 0.95 hosts, and for isoc rings on AMD 0.96 host */ + chain_links = !!(xhci_link_trb_quirk(xhci) || + (ring->type == TYPE_ISOC && + (xhci->quirks & XHCI_AMD_0x96_HOST))); + next = ring->enq_seg->next; - xhci_link_segments(xhci, ring->enq_seg, first, ring->type); - xhci_link_segments(xhci, last, next, ring->type); + xhci_link_segments(ring->enq_seg, first, ring->type, chain_links); + xhci_link_segments(last, next, ring->type, chain_links); ring->num_segs += num_segs; ring->num_trbs_free += (TRBS_PER_SEGMENT - 1) * num_segs; @@ -321,6 +324,12 @@ static int xhci_alloc_segments_for_ring(struct xhci_hcd *xhci, enum xhci_ring_type type, unsigned int max_packet, gfp_t flags) { struct xhci_segment *prev; + bool chain_links; + + /* Set chain bit for 0.95 hosts, and for isoc rings on AMD 0.96 host */ + chain_links = !!(xhci_link_trb_quirk(xhci) || + (type == TYPE_ISOC && + (xhci->quirks & XHCI_AMD_0x96_HOST))); prev = xhci_segment_alloc(xhci, cycle_state, max_packet, flags); if (!prev) @@ -341,12 +350,12 @@ static int xhci_alloc_segments_for_ring(struct xhci_hcd *xhci, } return -ENOMEM; } - xhci_link_segments(xhci, prev, next, type); + xhci_link_segments(prev, next, type, chain_links); prev = next; num_segs--; } - xhci_link_segments(xhci, prev, *first, type); + xhci_link_segments(prev, *first, type, chain_links); *last = prev; return 0; -- cgit v1.2.3-70-g09d2 From 0b832e997436d0336257cdc1bf2e265234239094 Mon Sep 17 00:00:00 2001 From: Mathias Nyman Date: Thu, 23 Jul 2020 17:45:07 +0300 Subject: xhci: dbc: Don't use generic xhci erst allocation and free functions The generic erst allocation and free functions take struct xhci_hcd pointer as a parameter. Create own erst helpers for DbC in order to decouple xhci and DbC Signed-off-by: Mathias Nyman Link: https://lore.kernel.org/r/20200723144530.9992-5-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/xhci-dbgcap.c | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/host/xhci-dbgcap.c b/drivers/usb/host/xhci-dbgcap.c index 424b571d6ca9..138b0c994ad2 100644 --- a/drivers/usb/host/xhci-dbgcap.c +++ b/drivers/usb/host/xhci-dbgcap.c @@ -370,12 +370,36 @@ static void xhci_dbc_eps_exit(struct xhci_hcd *xhci) memset(dbc->eps, 0, sizeof(struct dbc_ep) * ARRAY_SIZE(dbc->eps)); } +static int dbc_erst_alloc(struct device *dev, struct xhci_ring *evt_ring, + struct xhci_erst *erst, gfp_t flags) +{ + erst->entries = dma_alloc_coherent(dev, sizeof(struct xhci_erst_entry), + &erst->erst_dma_addr, flags); + if (!erst->entries) + return -ENOMEM; + + erst->num_entries = 1; + erst->entries[0].seg_addr = cpu_to_le64(evt_ring->first_seg->dma); + erst->entries[0].seg_size = cpu_to_le32(TRBS_PER_SEGMENT); + erst->entries[0].rsvd = 0; + return 0; +} + +static void dbc_erst_free(struct device *dev, struct xhci_erst *erst) +{ + if (erst->entries) + dma_free_coherent(dev, sizeof(struct xhci_erst_entry), + erst->entries, erst->erst_dma_addr); + erst->entries = NULL; +} + static int xhci_dbc_mem_init(struct xhci_hcd *xhci, gfp_t flags) { int ret; dma_addr_t deq; u32 string_length; struct xhci_dbc *dbc = xhci->dbc; + struct device *dev = xhci_to_hcd(xhci)->self.controller; /* Allocate various rings for events and transfers: */ dbc->ring_evt = xhci_ring_alloc(xhci, 1, 1, TYPE_EVENT, 0, flags); @@ -391,7 +415,7 @@ static int xhci_dbc_mem_init(struct xhci_hcd *xhci, gfp_t flags) goto out_fail; /* Allocate and populate ERST: */ - ret = xhci_alloc_erst(xhci, dbc->ring_evt, &dbc->erst, flags); + ret = dbc_erst_alloc(dev, dbc->ring_evt, &dbc->erst, flags); if (ret) goto erst_fail; @@ -429,7 +453,7 @@ string_fail: xhci_free_container_ctx(xhci, dbc->ctx); dbc->ctx = NULL; ctx_fail: - xhci_free_erst(xhci, &dbc->erst); + dbc_erst_free(dev, &dbc->erst); erst_fail: xhci_ring_free(xhci, dbc->ring_out); dbc->ring_out = NULL; @@ -446,6 +470,7 @@ evt_fail: static void xhci_dbc_mem_cleanup(struct xhci_hcd *xhci) { struct xhci_dbc *dbc = xhci->dbc; + struct device *dev = xhci_to_hcd(xhci)->self.controller; if (!dbc) return; @@ -462,7 +487,7 @@ static void xhci_dbc_mem_cleanup(struct xhci_hcd *xhci) xhci_free_container_ctx(xhci, dbc->ctx); dbc->ctx = NULL; - xhci_free_erst(xhci, &dbc->erst); + dbc_erst_free(dev, &dbc->erst); xhci_ring_free(xhci, dbc->ring_out); xhci_ring_free(xhci, dbc->ring_in); xhci_ring_free(xhci, dbc->ring_evt); -- cgit v1.2.3-70-g09d2 From c9dd94385d48529da7a2eb88963883b8080e83d9 Mon Sep 17 00:00:00 2001 From: Mathias Nyman Date: Thu, 23 Jul 2020 17:45:08 +0300 Subject: xhci: dbc: Remove dbc_dma_alloc_coherent() wrapper dbc_dma_alloc_coherent() takes struct xhci_hcd pointer as an parameter, but does nothing more than calls dma_alloc_coherent(). Remove it and call dma_alloc_coherent() directly instead. No functional changes This change helps decoupling xhci and DbC Signed-off-by: Mathias Nyman Link: https://lore.kernel.org/r/20200723144530.9992-6-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/xhci-dbgcap.c | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/host/xhci-dbgcap.c b/drivers/usb/host/xhci-dbgcap.c index 138b0c994ad2..e8a2cbda135c 100644 --- a/drivers/usb/host/xhci-dbgcap.c +++ b/drivers/usb/host/xhci-dbgcap.c @@ -14,17 +14,6 @@ #include "xhci-trace.h" #include "xhci-dbgcap.h" -static inline void * -dbc_dma_alloc_coherent(struct xhci_hcd *xhci, size_t size, - dma_addr_t *dma_handle, gfp_t flags) -{ - void *vaddr; - - vaddr = dma_alloc_coherent(xhci_to_hcd(xhci)->self.sysdev, - size, dma_handle, flags); - return vaddr; -} - static inline void dbc_dma_free_coherent(struct xhci_hcd *xhci, size_t size, void *cpu_addr, dma_addr_t dma_handle) @@ -426,10 +415,8 @@ static int xhci_dbc_mem_init(struct xhci_hcd *xhci, gfp_t flags) /* Allocate the string table: */ dbc->string_size = sizeof(struct dbc_str_descs); - dbc->string = dbc_dma_alloc_coherent(xhci, - dbc->string_size, - &dbc->string_dma, - flags); + dbc->string = dma_alloc_coherent(dev, dbc->string_size, + &dbc->string_dma, flags); if (!dbc->string) goto string_fail; -- cgit v1.2.3-70-g09d2 From bcf87ea6e2d08eab75ba2aa53336a630421becfb Mon Sep 17 00:00:00 2001 From: Mathias Nyman Date: Thu, 23 Jul 2020 17:45:09 +0300 Subject: xhci: dbc: Remove dbc_dma_free_coherent() wrapper dbc_dma_free_coherent() takes struct xhci_hcd pointer as a parameter, but does nothing more than calls dma_free_coherent(). Remove it and call dma_free_coherent() directly instead. No functional changes This change helps decoupling xhci and DbC Signed-off-by: Mathias Nyman Link: https://lore.kernel.org/r/20200723144530.9992-7-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/xhci-dbgcap.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/host/xhci-dbgcap.c b/drivers/usb/host/xhci-dbgcap.c index e8a2cbda135c..5bec36ed97c6 100644 --- a/drivers/usb/host/xhci-dbgcap.c +++ b/drivers/usb/host/xhci-dbgcap.c @@ -14,15 +14,6 @@ #include "xhci-trace.h" #include "xhci-dbgcap.h" -static inline void -dbc_dma_free_coherent(struct xhci_hcd *xhci, size_t size, - void *cpu_addr, dma_addr_t dma_handle) -{ - if (cpu_addr) - dma_free_coherent(xhci_to_hcd(xhci)->self.sysdev, - size, cpu_addr, dma_handle); -} - static u32 xhci_dbc_populate_strings(struct dbc_str_descs *strings) { struct usb_string_descriptor *s_desc; @@ -465,9 +456,8 @@ static void xhci_dbc_mem_cleanup(struct xhci_hcd *xhci) xhci_dbc_eps_exit(xhci); if (dbc->string) { - dbc_dma_free_coherent(xhci, - dbc->string_size, - dbc->string, dbc->string_dma); + dma_free_coherent(dbc->dev, dbc->string_size, + dbc->string, dbc->string_dma); dbc->string = NULL; } -- cgit v1.2.3-70-g09d2 From be33f4809351e722689539a21f0373982de46637 Mon Sep 17 00:00:00 2001 From: Mathias Nyman Date: Thu, 23 Jul 2020 17:45:10 +0300 Subject: xhci: dbc: Add device pointer to dbc structure Currently the dbc structure contains a pointer to struct xhci_hcd, and dbc functions use that to dig up the underlying device pointer. We are trying to decouple xhci and dbc code, and prepare for code that use dbc such as dbctty into into real device drivers. This is one step along the way. Keep functionality the same and keep the xhci pointer, and let the new device pointer point to the xhci device for now. Signed-off-by: Mathias Nyman Link: https://lore.kernel.org/r/20200723144530.9992-8-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/xhci-dbgcap.c | 1 + drivers/usb/host/xhci-dbgcap.h | 1 + 2 files changed, 2 insertions(+) (limited to 'drivers/usb') diff --git a/drivers/usb/host/xhci-dbgcap.c b/drivers/usb/host/xhci-dbgcap.c index 5bec36ed97c6..ae584d6ae10c 100644 --- a/drivers/usb/host/xhci-dbgcap.c +++ b/drivers/usb/host/xhci-dbgcap.c @@ -878,6 +878,7 @@ static int xhci_do_dbc_init(struct xhci_hcd *xhci) spin_unlock_irqrestore(&xhci->lock, flags); dbc->xhci = xhci; + dbc->dev = xhci_to_hcd(xhci)->self.sysdev; INIT_DELAYED_WORK(&dbc->event_work, xhci_dbc_handle_events); spin_lock_init(&dbc->lock); diff --git a/drivers/usb/host/xhci-dbgcap.h b/drivers/usb/host/xhci-dbgcap.h index ce0c6072bd48..7ca2f4ccc537 100644 --- a/drivers/usb/host/xhci-dbgcap.h +++ b/drivers/usb/host/xhci-dbgcap.h @@ -133,6 +133,7 @@ struct dbc_port { struct xhci_dbc { spinlock_t lock; /* device access */ + struct device *dev; struct xhci_hcd *xhci; struct dbc_regs __iomem *regs; struct xhci_ring *ring_evt; -- cgit v1.2.3-70-g09d2 From 985247fe4c524eeffd94e7af486ffa6cc9a2fc53 Mon Sep 17 00:00:00 2001 From: Mathias Nyman Date: Thu, 23 Jul 2020 17:45:11 +0300 Subject: xhci: dbc: Use dev_info() and similar instead of xhci_info() To make this change possible we also need to change dbc_handle_port_status() to take dbc pointer as parameter instead of xhci_hcd pointer. Note that xhci_info() used xhci_to_hcd(xhci)->self.controller as the device while for dev_info we use xhci_to_hcd(xhci)->self.sysdev. In many cases those are the same, but not for some device where a dwc3 controller creates a xhci platform device. In th this case self.controller may be the platform device while self.sysdev is the actual device known to firmware (dwc3). This change helps decoupling xhci and DbC Signed-off-by: Mathias Nyman Link: https://lore.kernel.org/r/20200723144530.9992-9-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/xhci-dbgcap.c | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/host/xhci-dbgcap.c b/drivers/usb/host/xhci-dbgcap.c index ae584d6ae10c..3375be7ea642 100644 --- a/drivers/usb/host/xhci-dbgcap.c +++ b/drivers/usb/host/xhci-dbgcap.c @@ -286,13 +286,13 @@ dbc_ep_do_queue(struct dbc_ep *dep, struct dbc_request *req) req->length, dbc_ep_dma_direction(dep)); if (dma_mapping_error(dev, req->dma)) { - xhci_err(xhci, "failed to map buffer\n"); + dev_err(dbc->dev, "failed to map buffer\n"); return -EFAULT; } ret = xhci_dbc_queue_bulk_tx(dep, req); if (ret) { - xhci_err(xhci, "failed to queue trbs\n"); + dev_err(dbc->dev, "failed to queue trbs\n"); dma_unmap_single(dev, req->dma, req->length, @@ -567,23 +567,22 @@ static void xhci_dbc_stop(struct xhci_hcd *xhci) } static void -dbc_handle_port_status(struct xhci_hcd *xhci, union xhci_trb *event) +dbc_handle_port_status(struct xhci_dbc *dbc, union xhci_trb *event) { u32 portsc; - struct xhci_dbc *dbc = xhci->dbc; portsc = readl(&dbc->regs->portsc); if (portsc & DBC_PORTSC_CONN_CHANGE) - xhci_info(xhci, "DbC port connect change\n"); + dev_info(dbc->dev, "DbC port connect change\n"); if (portsc & DBC_PORTSC_RESET_CHANGE) - xhci_info(xhci, "DbC port reset change\n"); + dev_info(dbc->dev, "DbC port reset change\n"); if (portsc & DBC_PORTSC_LINK_CHANGE) - xhci_info(xhci, "DbC port link status change\n"); + dev_info(dbc->dev, "DbC port link status change\n"); if (portsc & DBC_PORTSC_CONFIG_CHANGE) - xhci_info(xhci, "DbC config error change\n"); + dev_info(dbc->dev, "DbC config error change\n"); /* Port reset change bit will be cleared in other place: */ writel(portsc & ~DBC_PORTSC_RESET_CHANGE, &dbc->regs->portsc); @@ -598,6 +597,7 @@ static void dbc_handle_xfer_event(struct xhci_hcd *xhci, union xhci_trb *event) u32 comp_code; size_t remain_length; struct dbc_request *req = NULL, *r; + struct xhci_dbc *dbc = xhci->dbc; comp_code = GET_COMP_CODE(le32_to_cpu(event->generic.field[2])); remain_length = EVENT_TRB_LEN(le32_to_cpu(event->generic.field[2])); @@ -617,11 +617,11 @@ static void dbc_handle_xfer_event(struct xhci_hcd *xhci, union xhci_trb *event) case COMP_BABBLE_DETECTED_ERROR: case COMP_USB_TRANSACTION_ERROR: case COMP_STALL_ERROR: - xhci_warn(xhci, "tx error %d detected\n", comp_code); + dev_warn(dbc->dev, "tx error %d detected\n", comp_code); status = -comp_code; break; default: - xhci_err(xhci, "unknown tx error %d\n", comp_code); + dev_err(dbc->dev, "unknown tx error %d\n", comp_code); status = -comp_code; break; } @@ -635,7 +635,7 @@ static void dbc_handle_xfer_event(struct xhci_hcd *xhci, union xhci_trb *event) } if (!req) { - xhci_warn(xhci, "no matched request\n"); + dev_warn(dbc->dev, "no matched request\n"); return; } @@ -676,7 +676,7 @@ static enum evtreturn xhci_dbc_do_handle_events(struct xhci_dbc *dbc) portsc = readl(&dbc->regs->portsc); if (portsc & DBC_PORTSC_CONN_STATUS) { dbc->state = DS_CONNECTED; - xhci_info(xhci, "DbC connected\n"); + dev_info(dbc->dev, "DbC connected\n"); } return EVT_DONE; @@ -684,7 +684,7 @@ static enum evtreturn xhci_dbc_do_handle_events(struct xhci_dbc *dbc) ctrl = readl(&dbc->regs->control); if (ctrl & DBC_CTRL_DBC_RUN) { dbc->state = DS_CONFIGURED; - xhci_info(xhci, "DbC configured\n"); + dev_info(dbc->dev, "DbC configured\n"); portsc = readl(&dbc->regs->portsc); writel(portsc, &dbc->regs->portsc); return EVT_GSER; @@ -696,7 +696,7 @@ static enum evtreturn xhci_dbc_do_handle_events(struct xhci_dbc *dbc) portsc = readl(&dbc->regs->portsc); if (!(portsc & DBC_PORTSC_PORT_ENABLED) && !(portsc & DBC_PORTSC_CONN_STATUS)) { - xhci_info(xhci, "DbC cable unplugged\n"); + dev_info(dbc->dev, "DbC cable unplugged\n"); dbc->state = DS_ENABLED; xhci_dbc_flush_requests(dbc); @@ -705,7 +705,7 @@ static enum evtreturn xhci_dbc_do_handle_events(struct xhci_dbc *dbc) /* Handle debug port reset event: */ if (portsc & DBC_PORTSC_RESET_CHANGE) { - xhci_info(xhci, "DbC port reset\n"); + dev_info(dbc->dev, "DbC port reset\n"); writel(portsc, &dbc->regs->portsc); dbc->state = DS_ENABLED; xhci_dbc_flush_requests(dbc); @@ -717,7 +717,7 @@ static enum evtreturn xhci_dbc_do_handle_events(struct xhci_dbc *dbc) ctrl = readl(&dbc->regs->control); if ((ctrl & DBC_CTRL_HALT_IN_TR) || (ctrl & DBC_CTRL_HALT_OUT_TR)) { - xhci_info(xhci, "DbC Endpoint stall\n"); + dev_info(dbc->dev, "DbC Endpoint stall\n"); dbc->state = DS_STALLED; if (ctrl & DBC_CTRL_HALT_IN_TR) { @@ -751,7 +751,7 @@ static enum evtreturn xhci_dbc_do_handle_events(struct xhci_dbc *dbc) return EVT_DONE; default: - xhci_err(xhci, "Unknown DbC state %d\n", dbc->state); + dev_err(dbc->dev, "Unknown DbC state %d\n", dbc->state); break; } @@ -769,7 +769,7 @@ static enum evtreturn xhci_dbc_do_handle_events(struct xhci_dbc *dbc) switch (le32_to_cpu(evt->event_cmd.flags) & TRB_TYPE_BITMASK) { case TRB_TYPE(TRB_PORT_STATUS): - dbc_handle_port_status(xhci, evt); + dbc_handle_port_status(dbc, evt); break; case TRB_TYPE(TRB_TRANSFER): dbc_handle_xfer_event(xhci, evt); @@ -813,11 +813,11 @@ static void xhci_dbc_handle_events(struct work_struct *work) case EVT_GSER: ret = xhci_dbc_tty_register_device(xhci); if (ret) { - xhci_err(xhci, "failed to alloc tty device\n"); + dev_err(dbc->dev, "failed to alloc tty device\n"); break; } - xhci_info(xhci, "DbC now attached to /dev/ttyDBC0\n"); + dev_info(dbc->dev, "DbC now attached to /dev/ttyDBC0\n"); break; case EVT_DISC: xhci_dbc_tty_unregister_device(xhci); @@ -825,7 +825,7 @@ static void xhci_dbc_handle_events(struct work_struct *work) case EVT_DONE: break; default: - xhci_info(xhci, "stop handling dbc events\n"); + dev_info(dbc->dev, "stop handling dbc events\n"); return; } -- cgit v1.2.3-70-g09d2 From 7cd6312e09be4f271885be9e89d092058e536539 Mon Sep 17 00:00:00 2001 From: Mathias Nyman Date: Thu, 23 Jul 2020 17:45:12 +0300 Subject: xhci: dbc: Don't use xhci_write_64() as it takes xhci as a parameter xhci_write_64() is essentially a wrapper for lo_hi_writeq(), but it requires struct xhci_hcd * as a parameter. Use lo_hi_writeq() directly instead No functional changes This change helps decoupling xhci and DbC Signed-off-by: Mathias Nyman Link: https://lore.kernel.org/r/20200723144530.9992-10-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/xhci-dbgcap.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/host/xhci-dbgcap.c b/drivers/usb/host/xhci-dbgcap.c index 3375be7ea642..3541fbbfc28b 100644 --- a/drivers/usb/host/xhci-dbgcap.c +++ b/drivers/usb/host/xhci-dbgcap.c @@ -101,7 +101,7 @@ static void xhci_dbc_init_contexts(struct xhci_hcd *xhci, u32 string_length) ep_ctx->deq = cpu_to_le64(deq | dbc->ring_in->cycle_state); /* Set DbC context and info registers: */ - xhci_write_64(xhci, dbc->ctx->dma, &dbc->regs->dccp); + lo_hi_writeq(dbc->ctx->dma, &dbc->regs->dccp); dev_info = cpu_to_le32((DBC_VENDOR_ID << 16) | DBC_PROTOCOL); writel(dev_info, &dbc->regs->devinfo1); @@ -413,10 +413,11 @@ static int xhci_dbc_mem_init(struct xhci_hcd *xhci, gfp_t flags) /* Setup ERST register: */ writel(dbc->erst.erst_size, &dbc->regs->ersts); - xhci_write_64(xhci, dbc->erst.erst_dma_addr, &dbc->regs->erstba); + + lo_hi_writeq(dbc->erst.erst_dma_addr, &dbc->regs->erstba); deq = xhci_trb_virt_to_dma(dbc->ring_evt->deq_seg, dbc->ring_evt->dequeue); - xhci_write_64(xhci, deq, &dbc->regs->erdp); + lo_hi_writeq(deq, &dbc->regs->erdp); /* Setup strings and contexts: */ string_length = xhci_dbc_populate_strings(dbc->string); @@ -788,7 +789,7 @@ static enum evtreturn xhci_dbc_do_handle_events(struct xhci_dbc *dbc) if (update_erdp) { deq = xhci_trb_virt_to_dma(dbc->ring_evt->deq_seg, dbc->ring_evt->dequeue); - xhci_write_64(xhci, deq, &dbc->regs->erdp); + lo_hi_writeq(deq, &dbc->regs->erdp); } return EVT_DONE; -- cgit v1.2.3-70-g09d2 From 1da49a26af6cce364f3608b36ccf6612d80eddbc Mon Sep 17 00:00:00 2001 From: Mathias Nyman Date: Thu, 23 Jul 2020 17:45:13 +0300 Subject: xhci: dbc: Don't pass the xhci pointer as a parameter to xhci_dbc_init_context() xhci_dbc_init_context() no longer needs the struct xhci_hcd pointer. Pass the dbc pointer directly instead. No functional changes This change helps decoupling xhci and DbC Signed-off-by: Mathias Nyman Link: https://lore.kernel.org/r/20200723144530.9992-11-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/xhci-dbgcap.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/host/xhci-dbgcap.c b/drivers/usb/host/xhci-dbgcap.c index 3541fbbfc28b..a5281f95fd72 100644 --- a/drivers/usb/host/xhci-dbgcap.c +++ b/drivers/usb/host/xhci-dbgcap.c @@ -63,16 +63,14 @@ static u32 xhci_dbc_populate_strings(struct dbc_str_descs *strings) return string_length; } -static void xhci_dbc_init_contexts(struct xhci_hcd *xhci, u32 string_length) +static void xhci_dbc_init_contexts(struct xhci_dbc *dbc, u32 string_length) { - struct xhci_dbc *dbc; struct dbc_info_context *info; struct xhci_ep_ctx *ep_ctx; u32 dev_info; dma_addr_t deq, dma; unsigned int max_burst; - dbc = xhci->dbc; if (!dbc) return; @@ -421,7 +419,7 @@ static int xhci_dbc_mem_init(struct xhci_hcd *xhci, gfp_t flags) /* Setup strings and contexts: */ string_length = xhci_dbc_populate_strings(dbc->string); - xhci_dbc_init_contexts(xhci, string_length); + xhci_dbc_init_contexts(dbc, string_length); xhci_dbc_eps_init(xhci); dbc->state = DS_INITIALIZED; -- cgit v1.2.3-70-g09d2 From ed7bffee0216b7ffeecfd5736b167118c8ddd2de Mon Sep 17 00:00:00 2001 From: Mathias Nyman Date: Thu, 23 Jul 2020 17:45:14 +0300 Subject: xhci: dbc: Get the device pointer from dbc structure in dbc_ep_do_queue() dbc_ep_do_queue() can now get the device pointer directly from dbc structure instead of going through the xhci_hcd structure. No functional changes This change helps decoupling xhci and DbC Signed-off-by: Mathias Nyman Link: https://lore.kernel.org/r/20200723144530.9992-12-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/xhci-dbgcap.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/host/xhci-dbgcap.c b/drivers/usb/host/xhci-dbgcap.c index a5281f95fd72..44fe93632901 100644 --- a/drivers/usb/host/xhci-dbgcap.c +++ b/drivers/usb/host/xhci-dbgcap.c @@ -267,11 +267,8 @@ static int dbc_ep_do_queue(struct dbc_ep *dep, struct dbc_request *req) { int ret; - struct device *dev; struct xhci_dbc *dbc = dep->dbc; - struct xhci_hcd *xhci = dbc->xhci; - - dev = xhci_to_hcd(xhci)->self.sysdev; + struct device *dev = dbc->dev; if (!req->length || !req->buf) return -EINVAL; -- cgit v1.2.3-70-g09d2 From d3249fa9177f7f425ac4a48b0c8caf28f77b9d52 Mon Sep 17 00:00:00 2001 From: Mathias Nyman Date: Thu, 23 Jul 2020 17:45:15 +0300 Subject: xhci: dbc: Pass dbc pointer to endpoint init and exit functions. struct xhci_hcd pointer is not needed for dbc endpoint init and exit, it was only used to get to the dbc structure. Pass the dbc pointer as a parameter to these functions instead. No functional changes This change helps decoupling xhci and DbC Signed-off-by: Mathias Nyman Link: https://lore.kernel.org/r/20200723144530.9992-13-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/xhci-dbgcap.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/host/xhci-dbgcap.c b/drivers/usb/host/xhci-dbgcap.c index 44fe93632901..6114b334eb61 100644 --- a/drivers/usb/host/xhci-dbgcap.c +++ b/drivers/usb/host/xhci-dbgcap.c @@ -319,10 +319,9 @@ int dbc_ep_queue(struct dbc_ep *dep, struct dbc_request *req, return ret; } -static inline void xhci_dbc_do_eps_init(struct xhci_hcd *xhci, bool direction) +static inline void xhci_dbc_do_eps_init(struct xhci_dbc *dbc, bool direction) { struct dbc_ep *dep; - struct xhci_dbc *dbc = xhci->dbc; dep = &dbc->eps[direction]; dep->dbc = dbc; @@ -332,16 +331,14 @@ static inline void xhci_dbc_do_eps_init(struct xhci_hcd *xhci, bool direction) INIT_LIST_HEAD(&dep->list_pending); } -static void xhci_dbc_eps_init(struct xhci_hcd *xhci) +static void xhci_dbc_eps_init(struct xhci_dbc *dbc) { - xhci_dbc_do_eps_init(xhci, BULK_OUT); - xhci_dbc_do_eps_init(xhci, BULK_IN); + xhci_dbc_do_eps_init(dbc, BULK_OUT); + xhci_dbc_do_eps_init(dbc, BULK_IN); } -static void xhci_dbc_eps_exit(struct xhci_hcd *xhci) +static void xhci_dbc_eps_exit(struct xhci_dbc *dbc) { - struct xhci_dbc *dbc = xhci->dbc; - memset(dbc->eps, 0, sizeof(struct dbc_ep) * ARRAY_SIZE(dbc->eps)); } @@ -418,7 +415,7 @@ static int xhci_dbc_mem_init(struct xhci_hcd *xhci, gfp_t flags) string_length = xhci_dbc_populate_strings(dbc->string); xhci_dbc_init_contexts(dbc, string_length); - xhci_dbc_eps_init(xhci); + xhci_dbc_eps_init(dbc); dbc->state = DS_INITIALIZED; return 0; @@ -449,7 +446,7 @@ static void xhci_dbc_mem_cleanup(struct xhci_hcd *xhci) if (!dbc) return; - xhci_dbc_eps_exit(xhci); + xhci_dbc_eps_exit(dbc); if (dbc->string) { dma_free_coherent(dbc->dev, dbc->string_size, -- cgit v1.2.3-70-g09d2 From 903089b7b9d85096f06bee3ee5715fe85b4e8651 Mon Sep 17 00:00:00 2001 From: Mathias Nyman Date: Thu, 23 Jul 2020 17:45:16 +0300 Subject: xhci: dbc: Change to pass dbc pointer to xhci_do_dbc_stop() Pass the dbc pointer instead of xhci_hcd pointer in order to decouple xhci and dbc. xhci_do_dbc_stop() only used xhci to get the dbc pointer. Pass the dbc pointer instead as a parameter No functional changes This change helps decoupling xhci and DbC Signed-off-by: Mathias Nyman Link: https://lore.kernel.org/r/20200723144530.9992-14-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/xhci-dbgcap.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/host/xhci-dbgcap.c b/drivers/usb/host/xhci-dbgcap.c index 6114b334eb61..7dce1e094364 100644 --- a/drivers/usb/host/xhci-dbgcap.c +++ b/drivers/usb/host/xhci-dbgcap.c @@ -500,10 +500,8 @@ static int xhci_do_dbc_start(struct xhci_hcd *xhci) return 0; } -static int xhci_do_dbc_stop(struct xhci_hcd *xhci) +static int xhci_do_dbc_stop(struct xhci_dbc *dbc) { - struct xhci_dbc *dbc = xhci->dbc; - if (dbc->state == DS_DISABLED) return -1; @@ -550,7 +548,7 @@ static void xhci_dbc_stop(struct xhci_hcd *xhci) xhci_dbc_tty_unregister_device(xhci); spin_lock_irqsave(&dbc->lock, flags); - ret = xhci_do_dbc_stop(xhci); + ret = xhci_do_dbc_stop(dbc); spin_unlock_irqrestore(&dbc->lock, flags); if (!ret) { -- cgit v1.2.3-70-g09d2 From a1f6376df494c2f96530c8f294b7a31053425cff Mon Sep 17 00:00:00 2001 From: Mathias Nyman Date: Thu, 23 Jul 2020 17:45:17 +0300 Subject: xhci: dbc: Pass dbc pointer to dbc_handle_xfer_event() instead of xhci_hcd pointer The event handling function only used xhci pointer to get the dbc pointer. Pass the dbc pointer instead as a parameter No functional changes This change helps decoupling xhci and DbC Signed-off-by: Mathias Nyman Link: https://lore.kernel.org/r/20200723144530.9992-15-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/xhci-dbgcap.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/host/xhci-dbgcap.c b/drivers/usb/host/xhci-dbgcap.c index 7dce1e094364..1c53fdc791a4 100644 --- a/drivers/usb/host/xhci-dbgcap.c +++ b/drivers/usb/host/xhci-dbgcap.c @@ -579,7 +579,7 @@ dbc_handle_port_status(struct xhci_dbc *dbc, union xhci_trb *event) writel(portsc & ~DBC_PORTSC_RESET_CHANGE, &dbc->regs->portsc); } -static void dbc_handle_xfer_event(struct xhci_hcd *xhci, union xhci_trb *event) +static void dbc_handle_xfer_event(struct xhci_dbc *dbc, union xhci_trb *event) { struct dbc_ep *dep; struct xhci_ring *ring; @@ -588,7 +588,6 @@ static void dbc_handle_xfer_event(struct xhci_hcd *xhci, union xhci_trb *event) u32 comp_code; size_t remain_length; struct dbc_request *req = NULL, *r; - struct xhci_dbc *dbc = xhci->dbc; comp_code = GET_COMP_CODE(le32_to_cpu(event->generic.field[2])); remain_length = EVENT_TRB_LEN(le32_to_cpu(event->generic.field[2])); @@ -654,7 +653,6 @@ static enum evtreturn xhci_dbc_do_handle_events(struct xhci_dbc *dbc) struct dbc_ep *dep; union xhci_trb *evt; u32 ctrl, portsc; - struct xhci_hcd *xhci = dbc->xhci; bool update_erdp = false; /* DbC state machine: */ @@ -763,7 +761,7 @@ static enum evtreturn xhci_dbc_do_handle_events(struct xhci_dbc *dbc) dbc_handle_port_status(dbc, evt); break; case TRB_TYPE(TRB_TRANSFER): - dbc_handle_xfer_event(xhci, evt); + dbc_handle_xfer_event(dbc, evt); break; default: break; -- cgit v1.2.3-70-g09d2 From b396fa39de9b47ce3368f65d7d069c7176f26371 Mon Sep 17 00:00:00 2001 From: Mathias Nyman Date: Thu, 23 Jul 2020 17:45:18 +0300 Subject: xhci: dbgtty: Pass dbc pointer when registering a dbctty device Pass dbc pointer to the xhci_dbc_tty_register_device() and xhci_dbc_tty_unregister_device() functions instead of xhci_hcd pointer These functions don't need a xhci_hcd pointer anymore, only use case was the xhci_err() function, which is now changed to a dev_err() instead. No functional changes This change helps decoupling xhci and DbC Signed-off-by: Mathias Nyman Link: https://lore.kernel.org/r/20200723144530.9992-16-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/xhci-dbgcap.c | 8 +++----- drivers/usb/host/xhci-dbgcap.h | 4 ++-- drivers/usb/host/xhci-dbgtty.c | 8 +++----- 3 files changed, 8 insertions(+), 12 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/host/xhci-dbgcap.c b/drivers/usb/host/xhci-dbgcap.c index 1c53fdc791a4..dd8ac5918ad8 100644 --- a/drivers/usb/host/xhci-dbgcap.c +++ b/drivers/usb/host/xhci-dbgcap.c @@ -545,7 +545,7 @@ static void xhci_dbc_stop(struct xhci_hcd *xhci) cancel_delayed_work_sync(&dbc->event_work); if (port->registered) - xhci_dbc_tty_unregister_device(xhci); + xhci_dbc_tty_unregister_device(dbc); spin_lock_irqsave(&dbc->lock, flags); ret = xhci_do_dbc_stop(dbc); @@ -789,10 +789,8 @@ static void xhci_dbc_handle_events(struct work_struct *work) enum evtreturn evtr; struct xhci_dbc *dbc; unsigned long flags; - struct xhci_hcd *xhci; dbc = container_of(to_delayed_work(work), struct xhci_dbc, event_work); - xhci = dbc->xhci; spin_lock_irqsave(&dbc->lock, flags); evtr = xhci_dbc_do_handle_events(dbc); @@ -800,7 +798,7 @@ static void xhci_dbc_handle_events(struct work_struct *work) switch (evtr) { case EVT_GSER: - ret = xhci_dbc_tty_register_device(xhci); + ret = xhci_dbc_tty_register_device(dbc); if (ret) { dev_err(dbc->dev, "failed to alloc tty device\n"); break; @@ -809,7 +807,7 @@ static void xhci_dbc_handle_events(struct work_struct *work) dev_info(dbc->dev, "DbC now attached to /dev/ttyDBC0\n"); break; case EVT_DISC: - xhci_dbc_tty_unregister_device(xhci); + xhci_dbc_tty_unregister_device(dbc); break; case EVT_DONE: break; diff --git a/drivers/usb/host/xhci-dbgcap.h b/drivers/usb/host/xhci-dbgcap.h index 7ca2f4ccc537..628f85f97dfe 100644 --- a/drivers/usb/host/xhci-dbgcap.h +++ b/drivers/usb/host/xhci-dbgcap.h @@ -198,8 +198,8 @@ int xhci_dbc_init(struct xhci_hcd *xhci); void xhci_dbc_exit(struct xhci_hcd *xhci); int xhci_dbc_tty_register_driver(struct xhci_hcd *xhci); void xhci_dbc_tty_unregister_driver(void); -int xhci_dbc_tty_register_device(struct xhci_hcd *xhci); -void xhci_dbc_tty_unregister_device(struct xhci_hcd *xhci); +int xhci_dbc_tty_register_device(struct xhci_dbc *dbc); +void xhci_dbc_tty_unregister_device(struct xhci_dbc *dbc); struct dbc_request *dbc_alloc_request(struct dbc_ep *dep, gfp_t gfp_flags); void dbc_free_request(struct dbc_ep *dep, struct dbc_request *req); int dbc_ep_queue(struct dbc_ep *dep, struct dbc_request *req, gfp_t gfp_flags); diff --git a/drivers/usb/host/xhci-dbgtty.c b/drivers/usb/host/xhci-dbgtty.c index 9a1d38442578..545e8cb0221a 100644 --- a/drivers/usb/host/xhci-dbgtty.c +++ b/drivers/usb/host/xhci-dbgtty.c @@ -440,11 +440,10 @@ xhci_dbc_tty_exit_port(struct dbc_port *port) tty_port_destroy(&port->port); } -int xhci_dbc_tty_register_device(struct xhci_hcd *xhci) +int xhci_dbc_tty_register_device(struct xhci_dbc *dbc) { int ret; struct device *tty_dev; - struct xhci_dbc *dbc = xhci->dbc; struct dbc_port *port = &dbc->port; xhci_dbc_tty_init_port(xhci, port); @@ -484,14 +483,13 @@ buf_alloc_fail: register_fail: xhci_dbc_tty_exit_port(port); - xhci_err(xhci, "can't register tty port, err %d\n", ret); + dev_err(dbc->dev, "can't register tty port, err %d\n", ret); return ret; } -void xhci_dbc_tty_unregister_device(struct xhci_hcd *xhci) +void xhci_dbc_tty_unregister_device(struct xhci_dbc *dbc) { - struct xhci_dbc *dbc = xhci->dbc; struct dbc_port *port = &dbc->port; tty_unregister_device(dbc_tty_driver, 0); -- cgit v1.2.3-70-g09d2 From 91aaf97471a047bec7c2ef6e59ed1c92359165a2 Mon Sep 17 00:00:00 2001 From: Mathias Nyman Date: Thu, 23 Jul 2020 17:45:19 +0300 Subject: xhci: dbc: Pass dbc pointer to get_in/out_ep() helper functions to get endpoints Pass dbc pointer instead of struct xhci_hcd pointer to the get_in_ep() and get_out_ep() helper functions. No functional changes This change helps decoupling xhci and DbC Signed-off-by: Mathias Nyman Link: https://lore.kernel.org/r/20200723144530.9992-17-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/xhci-dbgcap.c | 6 +++--- drivers/usb/host/xhci-dbgcap.h | 8 ++------ drivers/usb/host/xhci-dbgtty.c | 14 +++++++------- 3 files changed, 12 insertions(+), 16 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/host/xhci-dbgcap.c b/drivers/usb/host/xhci-dbgcap.c index dd8ac5918ad8..26e693dd7414 100644 --- a/drivers/usb/host/xhci-dbgcap.c +++ b/drivers/usb/host/xhci-dbgcap.c @@ -593,7 +593,7 @@ static void dbc_handle_xfer_event(struct xhci_dbc *dbc, union xhci_trb *event) remain_length = EVENT_TRB_LEN(le32_to_cpu(event->generic.field[2])); ep_id = TRB_TO_EP_ID(le32_to_cpu(event->generic.field[3])); dep = (ep_id == EPID_OUT) ? - get_out_ep(xhci) : get_in_ep(xhci); + get_out_ep(dbc) : get_in_ep(dbc); ring = dep->ring; switch (comp_code) { @@ -710,12 +710,12 @@ static enum evtreturn xhci_dbc_do_handle_events(struct xhci_dbc *dbc) dbc->state = DS_STALLED; if (ctrl & DBC_CTRL_HALT_IN_TR) { - dep = get_in_ep(xhci); + dep = get_in_ep(dbc); xhci_dbc_flush_endpoint_requests(dep); } if (ctrl & DBC_CTRL_HALT_OUT_TR) { - dep = get_out_ep(xhci); + dep = get_out_ep(dbc); xhci_dbc_flush_endpoint_requests(dep); } diff --git a/drivers/usb/host/xhci-dbgcap.h b/drivers/usb/host/xhci-dbgcap.h index 628f85f97dfe..dc7d2d157e7b 100644 --- a/drivers/usb/host/xhci-dbgcap.h +++ b/drivers/usb/host/xhci-dbgcap.h @@ -179,17 +179,13 @@ enum evtreturn { EVT_DISC, }; -static inline struct dbc_ep *get_in_ep(struct xhci_hcd *xhci) +static inline struct dbc_ep *get_in_ep(struct xhci_dbc *dbc) { - struct xhci_dbc *dbc = xhci->dbc; - return &dbc->eps[BULK_IN]; } -static inline struct dbc_ep *get_out_ep(struct xhci_hcd *xhci) +static inline struct dbc_ep *get_out_ep(struct xhci_dbc *dbc) { - struct xhci_dbc *dbc = xhci->dbc; - return &dbc->eps[BULK_OUT]; } diff --git a/drivers/usb/host/xhci-dbgtty.c b/drivers/usb/host/xhci-dbgtty.c index 545e8cb0221a..0ef48862f4a7 100644 --- a/drivers/usb/host/xhci-dbgtty.c +++ b/drivers/usb/host/xhci-dbgtty.c @@ -418,7 +418,7 @@ static const struct tty_port_operations dbc_port_ops = { }; static void -xhci_dbc_tty_init_port(struct xhci_hcd *xhci, struct dbc_port *port) +xhci_dbc_tty_init_port(struct xhci_dbc *dbc, struct dbc_port *port) { tty_port_init(&port->port); spin_lock_init(&port->port_lock); @@ -427,8 +427,8 @@ xhci_dbc_tty_init_port(struct xhci_hcd *xhci, struct dbc_port *port) INIT_LIST_HEAD(&port->read_queue); INIT_LIST_HEAD(&port->write_pool); - port->in = get_in_ep(xhci); - port->out = get_out_ep(xhci); + port->in = get_in_ep(dbc); + port->out = get_out_ep(dbc); port->port.ops = &dbc_port_ops; port->n_read = 0; } @@ -446,7 +446,7 @@ int xhci_dbc_tty_register_device(struct xhci_dbc *dbc) struct device *tty_dev; struct dbc_port *port = &dbc->port; - xhci_dbc_tty_init_port(xhci, port); + xhci_dbc_tty_init_port(dbc, port); tty_dev = tty_port_register_device(&port->port, dbc_tty_driver, 0, NULL); if (IS_ERR(tty_dev)) { @@ -497,7 +497,7 @@ void xhci_dbc_tty_unregister_device(struct xhci_dbc *dbc) port->registered = false; kfifo_free(&port->write_fifo); - xhci_dbc_free_requests(get_out_ep(xhci), &port->read_pool); - xhci_dbc_free_requests(get_out_ep(xhci), &port->read_queue); - xhci_dbc_free_requests(get_in_ep(xhci), &port->write_pool); + xhci_dbc_free_requests(get_out_ep(dbc), &port->read_pool); + xhci_dbc_free_requests(get_out_ep(dbc), &port->read_queue); + xhci_dbc_free_requests(get_in_ep(dbc), &port->write_pool); } -- cgit v1.2.3-70-g09d2 From f39f3afdf9b12cccc42c9db7a855821794bbd76c Mon Sep 17 00:00:00 2001 From: Mathias Nyman Date: Thu, 23 Jul 2020 17:45:20 +0300 Subject: xhci: dbc: Use dbc structure in the request completion instead of xhci_hcd The dbc request completion callback doesn't need a xhci_hcd pointer. The only user of the xhci_hcd pointer in dbgtty request callback was the xhci_warn() function. Change it to dev_warn() instead. While changing the callback function parameter to dbc in struct xhci_requeset, move the struct xhci_request declaraion down a bit in the header file to avoid compiler warinings No functional changes This change helps decoupling xhci and DbC Signed-off-by: Mathias Nyman Link: https://lore.kernel.org/r/20200723144530.9992-18-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/xhci-dbgcap.c | 5 ++--- drivers/usb/host/xhci-dbgcap.h | 34 +++++++++++++++++----------------- drivers/usb/host/xhci-dbgtty.c | 10 ++++------ 3 files changed, 23 insertions(+), 26 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/host/xhci-dbgcap.c b/drivers/usb/host/xhci-dbgcap.c index 26e693dd7414..2473100b955a 100644 --- a/drivers/usb/host/xhci-dbgcap.c +++ b/drivers/usb/host/xhci-dbgcap.c @@ -114,8 +114,7 @@ static void xhci_dbc_giveback(struct dbc_request *req, int status) { struct dbc_ep *dep = req->dep; struct xhci_dbc *dbc = dep->dbc; - struct xhci_hcd *xhci = dbc->xhci; - struct device *dev = xhci_to_hcd(dbc->xhci)->self.sysdev; + struct device *dev = dbc->dev; list_del_init(&req->list_pending); req->trb_dma = 0; @@ -133,7 +132,7 @@ static void xhci_dbc_giveback(struct dbc_request *req, int status) /* Give back the transfer request: */ spin_unlock(&dbc->lock); - req->complete(xhci, req); + req->complete(dbc, req); spin_lock(&dbc->lock); } diff --git a/drivers/usb/host/xhci-dbgcap.h b/drivers/usb/host/xhci-dbgcap.h index dc7d2d157e7b..9e3c5940f27b 100644 --- a/drivers/usb/host/xhci-dbgcap.h +++ b/drivers/usb/host/xhci-dbgcap.h @@ -84,23 +84,6 @@ enum dbc_state { DS_STALLED, }; -struct dbc_request { - void *buf; - unsigned int length; - dma_addr_t dma; - void (*complete)(struct xhci_hcd *xhci, - struct dbc_request *req); - struct list_head list_pool; - int status; - unsigned int actual; - - struct dbc_ep *dep; - struct list_head list_pending; - dma_addr_t trb_dma; - union xhci_trb *trb; - unsigned direction:1; -}; - struct dbc_ep { struct xhci_dbc *dbc; struct list_head list_pending; @@ -154,6 +137,23 @@ struct xhci_dbc { struct dbc_port port; }; +struct dbc_request { + void *buf; + unsigned int length; + dma_addr_t dma; + void (*complete)(struct xhci_dbc *dbc, + struct dbc_request *req); + struct list_head list_pool; + int status; + unsigned int actual; + + struct dbc_ep *dep; + struct list_head list_pending; + dma_addr_t trb_dma; + union xhci_trb *trb; + unsigned direction:1; +}; + #define dbc_bulkout_ctx(d) \ ((struct xhci_ep_ctx *)((d)->ctx->bytes + DBC_CONTEXT_SIZE)) #define dbc_bulkin_ctx(d) \ diff --git a/drivers/usb/host/xhci-dbgtty.c b/drivers/usb/host/xhci-dbgtty.c index 0ef48862f4a7..967f0419dad7 100644 --- a/drivers/usb/host/xhci-dbgtty.c +++ b/drivers/usb/host/xhci-dbgtty.c @@ -91,10 +91,9 @@ static void dbc_start_rx(struct dbc_port *port) } static void -dbc_read_complete(struct xhci_hcd *xhci, struct dbc_request *req) +dbc_read_complete(struct xhci_dbc *dbc, struct dbc_request *req) { unsigned long flags; - struct xhci_dbc *dbc = xhci->dbc; struct dbc_port *port = &dbc->port; spin_lock_irqsave(&port->port_lock, flags); @@ -103,10 +102,9 @@ dbc_read_complete(struct xhci_hcd *xhci, struct dbc_request *req) spin_unlock_irqrestore(&port->port_lock, flags); } -static void dbc_write_complete(struct xhci_hcd *xhci, struct dbc_request *req) +static void dbc_write_complete(struct xhci_dbc *dbc, struct dbc_request *req) { unsigned long flags; - struct xhci_dbc *dbc = xhci->dbc; struct dbc_port *port = &dbc->port; spin_lock_irqsave(&port->port_lock, flags); @@ -118,7 +116,7 @@ static void dbc_write_complete(struct xhci_hcd *xhci, struct dbc_request *req) case -ESHUTDOWN: break; default: - xhci_warn(xhci, "unexpected write complete status %d\n", + dev_warn(dbc->dev, "unexpected write complete status %d\n", req->status); break; } @@ -133,7 +131,7 @@ static void xhci_dbc_free_req(struct dbc_ep *dep, struct dbc_request *req) static int xhci_dbc_alloc_requests(struct dbc_ep *dep, struct list_head *head, - void (*fn)(struct xhci_hcd *, struct dbc_request *)) + void (*fn)(struct xhci_dbc *, struct dbc_request *)) { int i; struct dbc_request *req; -- cgit v1.2.3-70-g09d2 From cb66434e67cc30e2971879fe36e03c8ca7208101 Mon Sep 17 00:00:00 2001 From: Mathias Nyman Date: Thu, 23 Jul 2020 17:45:21 +0300 Subject: xhci: dbc: Don't use generic xhci context allocation for dbc The DbC context is different from the xhci device context. It's a lot smaller as it only contains three 64 bytes sub-contexts; the info, endpoint-out, and endpoint-in contexts. In total 192 bytes. The context size (CSZ) field in HCCPARAMS1 xhci register does not alter DbC context size like it does for xhci device contexts. So don't use the geneic xhci context memory allocation, or the dma pool that is intended for xhci device contexts. In addition to saving memory this also helps decoupleing xhci and dbc code. Signed-off-by: Mathias Nyman Link: https://lore.kernel.org/r/20200723144530.9992-19-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/xhci-dbgcap.c | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/host/xhci-dbgcap.c b/drivers/usb/host/xhci-dbgcap.c index 2473100b955a..fb56198d3aff 100644 --- a/drivers/usb/host/xhci-dbgcap.c +++ b/drivers/usb/host/xhci-dbgcap.c @@ -14,6 +14,14 @@ #include "xhci-trace.h" #include "xhci-dbgcap.h" +static void dbc_free_ctx(struct device *dev, struct xhci_container_ctx *ctx) +{ + if (!ctx) + return; + dma_free_coherent(dev, ctx->size, ctx->bytes, ctx->dma); + kfree(ctx); +} + static u32 xhci_dbc_populate_strings(struct dbc_str_descs *strings) { struct usb_string_descriptor *s_desc; @@ -364,6 +372,25 @@ static void dbc_erst_free(struct device *dev, struct xhci_erst *erst) erst->entries = NULL; } +static struct xhci_container_ctx * +dbc_alloc_ctx(struct device *dev, gfp_t flags) +{ + struct xhci_container_ctx *ctx; + + ctx = kzalloc(sizeof(*ctx), flags); + if (!ctx) + return NULL; + + /* xhci 7.6.9, all three contexts; info, ep-out and ep-in. Each 64 bytes*/ + ctx->size = 3 * DBC_CONTEXT_SIZE; + ctx->bytes = dma_alloc_coherent(dev, ctx->size, &ctx->dma, flags); + if (!ctx->bytes) { + kfree(ctx); + return NULL; + } + return ctx; +} + static int xhci_dbc_mem_init(struct xhci_hcd *xhci, gfp_t flags) { int ret; @@ -391,7 +418,7 @@ static int xhci_dbc_mem_init(struct xhci_hcd *xhci, gfp_t flags) goto erst_fail; /* Allocate context data structure: */ - dbc->ctx = xhci_alloc_container_ctx(xhci, XHCI_CTX_TYPE_DEVICE, flags); + dbc->ctx = dbc_alloc_ctx(dev, flags); /* was sysdev, and is still */ if (!dbc->ctx) goto ctx_fail; @@ -420,7 +447,7 @@ static int xhci_dbc_mem_init(struct xhci_hcd *xhci, gfp_t flags) return 0; string_fail: - xhci_free_container_ctx(xhci, dbc->ctx); + dbc_free_ctx(dev, dbc->ctx); dbc->ctx = NULL; ctx_fail: dbc_erst_free(dev, &dbc->erst); @@ -453,7 +480,7 @@ static void xhci_dbc_mem_cleanup(struct xhci_hcd *xhci) dbc->string = NULL; } - xhci_free_container_ctx(xhci, dbc->ctx); + dbc_free_ctx(dbc->dev, dbc->ctx); dbc->ctx = NULL; dbc_erst_free(dev, &dbc->erst); -- cgit v1.2.3-70-g09d2 From ac286428c69fb3dc2924ce0ad5a11b5577b2f5da Mon Sep 17 00:00:00 2001 From: Mathias Nyman Date: Thu, 23 Jul 2020 17:45:22 +0300 Subject: xhci: dbc: don't use generic xhci ring allocation functions for dbc. The generic xhci ring allocations code needs struct xhci_hcd pointer, and it allocates memory for the rings from dma pools created for the xhci device. In order to decouple xhci and DbC we have to create our own ring allocation and free routines for DbC Signed-off-by: Mathias Nyman Link: https://lore.kernel.org/r/20200723144530.9992-20-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/xhci-dbgcap.c | 80 ++++++++++++++++++++++++++++++++++++------ drivers/usb/host/xhci-mem.c | 4 +-- drivers/usb/host/xhci.h | 2 ++ 3 files changed, 74 insertions(+), 12 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/host/xhci-dbgcap.c b/drivers/usb/host/xhci-dbgcap.c index fb56198d3aff..b00cbff5e2ca 100644 --- a/drivers/usb/host/xhci-dbgcap.c +++ b/drivers/usb/host/xhci-dbgcap.c @@ -22,6 +22,21 @@ static void dbc_free_ctx(struct device *dev, struct xhci_container_ctx *ctx) kfree(ctx); } +/* we use only one segment for DbC rings */ +static void dbc_ring_free(struct device *dev, struct xhci_ring *ring) +{ + if (!ring) + return; + + if (ring->first_seg && ring->first_seg->trbs) { + dma_free_coherent(dev, TRB_SEGMENT_SIZE, + ring->first_seg->trbs, + ring->first_seg->dma); + kfree(ring->first_seg); + } + kfree(ring); +} + static u32 xhci_dbc_populate_strings(struct dbc_str_descs *strings) { struct usb_string_descriptor *s_desc; @@ -391,6 +406,51 @@ dbc_alloc_ctx(struct device *dev, gfp_t flags) return ctx; } +struct xhci_ring * +xhci_dbc_ring_alloc(struct device *dev, enum xhci_ring_type type, gfp_t flags) +{ + struct xhci_ring *ring; + struct xhci_segment *seg; + dma_addr_t dma; + + ring = kzalloc(sizeof(*ring), flags); + if (!ring) + return NULL; + + ring->num_segs = 1; + ring->type = type; + + seg = kzalloc(sizeof(*seg), flags); + if (!seg) + goto seg_fail; + + ring->first_seg = seg; + ring->last_seg = seg; + seg->next = seg; + + seg->trbs = dma_alloc_coherent(dev, TRB_SEGMENT_SIZE, &dma, flags); + if (!seg->trbs) + goto dma_fail; + + seg->dma = dma; + + /* Only event ring does not use link TRB */ + if (type != TYPE_EVENT) { + union xhci_trb *trb = &seg->trbs[TRBS_PER_SEGMENT - 1]; + + trb->link.segment_ptr = cpu_to_le64(dma); + trb->link.control = cpu_to_le32(LINK_TOGGLE | TRB_TYPE(TRB_LINK)); + } + INIT_LIST_HEAD(&ring->td_list); + xhci_initialize_ring_info(ring, 1); + return ring; +dma_fail: + kfree(seg); +seg_fail: + kfree(ring); + return NULL; +} + static int xhci_dbc_mem_init(struct xhci_hcd *xhci, gfp_t flags) { int ret; @@ -400,15 +460,15 @@ static int xhci_dbc_mem_init(struct xhci_hcd *xhci, gfp_t flags) struct device *dev = xhci_to_hcd(xhci)->self.controller; /* Allocate various rings for events and transfers: */ - dbc->ring_evt = xhci_ring_alloc(xhci, 1, 1, TYPE_EVENT, 0, flags); + dbc->ring_evt = xhci_dbc_ring_alloc(dev, TYPE_EVENT, flags); if (!dbc->ring_evt) goto evt_fail; - dbc->ring_in = xhci_ring_alloc(xhci, 1, 1, TYPE_BULK, 0, flags); + dbc->ring_in = xhci_dbc_ring_alloc(dev, TYPE_BULK, flags); if (!dbc->ring_in) goto in_fail; - dbc->ring_out = xhci_ring_alloc(xhci, 1, 1, TYPE_BULK, 0, flags); + dbc->ring_out = xhci_dbc_ring_alloc(dev, TYPE_BULK, flags); if (!dbc->ring_out) goto out_fail; @@ -452,13 +512,13 @@ string_fail: ctx_fail: dbc_erst_free(dev, &dbc->erst); erst_fail: - xhci_ring_free(xhci, dbc->ring_out); + dbc_ring_free(dev, dbc->ring_out); dbc->ring_out = NULL; out_fail: - xhci_ring_free(xhci, dbc->ring_in); + dbc_ring_free(dev, dbc->ring_in); dbc->ring_in = NULL; in_fail: - xhci_ring_free(xhci, dbc->ring_evt); + dbc_ring_free(dev, dbc->ring_evt); dbc->ring_evt = NULL; evt_fail: return -ENOMEM; @@ -483,10 +543,10 @@ static void xhci_dbc_mem_cleanup(struct xhci_hcd *xhci) dbc_free_ctx(dbc->dev, dbc->ctx); dbc->ctx = NULL; - dbc_erst_free(dev, &dbc->erst); - xhci_ring_free(xhci, dbc->ring_out); - xhci_ring_free(xhci, dbc->ring_in); - xhci_ring_free(xhci, dbc->ring_evt); + dbc_erst_free(dbc->dev, &dbc->erst); + dbc_ring_free(dbc->dev, dbc->ring_out); + dbc_ring_free(dbc->dev, dbc->ring_in); + dbc_ring_free(dbc->dev, dbc->ring_evt); dbc->ring_in = NULL; dbc->ring_out = NULL; dbc->ring_evt = NULL; diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index d38779e2fc84..696fad50b478 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c @@ -293,8 +293,8 @@ void xhci_ring_free(struct xhci_hcd *xhci, struct xhci_ring *ring) kfree(ring); } -static void xhci_initialize_ring_info(struct xhci_ring *ring, - unsigned int cycle_state) +void xhci_initialize_ring_info(struct xhci_ring *ring, + unsigned int cycle_state) { /* The ring is empty, so the enqueue pointer == dequeue pointer */ ring->enqueue = ring->first_seg->trbs; diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index c295e8a7f5ae..ea1754f185a2 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -2015,6 +2015,8 @@ int xhci_alloc_erst(struct xhci_hcd *xhci, struct xhci_ring *evt_ring, struct xhci_erst *erst, gfp_t flags); +void xhci_initialize_ring_info(struct xhci_ring *ring, + unsigned int cycle_state); void xhci_free_erst(struct xhci_hcd *xhci, struct xhci_erst *erst); void xhci_free_endpoint_ring(struct xhci_hcd *xhci, struct xhci_virt_device *virt_dev, -- cgit v1.2.3-70-g09d2 From dd98570be1fb3bec14c2347edf4a499aaf7870de Mon Sep 17 00:00:00 2001 From: Mathias Nyman Date: Thu, 23 Jul 2020 17:45:23 +0300 Subject: xhci: dbc: Pass dbc pointer to dbc memory init and cleanup functions Dbc mem_init and mem_cleanup functions used xhci_hcd to get to the device pointer. The device pointer can be accessed directly from dbc structure, so pass a pointer to dbc as a parameter instead. No functional changes This change helps decoupling xhci and DbC Signed-off-by: Mathias Nyman Link: https://lore.kernel.org/r/20200723144530.9992-21-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/xhci-dbgcap.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/host/xhci-dbgcap.c b/drivers/usb/host/xhci-dbgcap.c index b00cbff5e2ca..626635f26658 100644 --- a/drivers/usb/host/xhci-dbgcap.c +++ b/drivers/usb/host/xhci-dbgcap.c @@ -451,13 +451,12 @@ seg_fail: return NULL; } -static int xhci_dbc_mem_init(struct xhci_hcd *xhci, gfp_t flags) +static int xhci_dbc_mem_init(struct xhci_dbc *dbc, gfp_t flags) { int ret; dma_addr_t deq; u32 string_length; - struct xhci_dbc *dbc = xhci->dbc; - struct device *dev = xhci_to_hcd(xhci)->self.controller; + struct device *dev = dbc->dev; /* Allocate various rings for events and transfers: */ dbc->ring_evt = xhci_dbc_ring_alloc(dev, TYPE_EVENT, flags); @@ -524,11 +523,8 @@ evt_fail: return -ENOMEM; } -static void xhci_dbc_mem_cleanup(struct xhci_hcd *xhci) +static void xhci_dbc_mem_cleanup(struct xhci_dbc *dbc) { - struct xhci_dbc *dbc = xhci->dbc; - struct device *dev = xhci_to_hcd(xhci)->self.controller; - if (!dbc) return; @@ -568,7 +564,7 @@ static int xhci_do_dbc_start(struct xhci_hcd *xhci) if (ret) return ret; - ret = xhci_dbc_mem_init(xhci, GFP_ATOMIC); + ret = xhci_dbc_mem_init(dbc, GFP_ATOMIC); if (ret) return ret; @@ -638,7 +634,7 @@ static void xhci_dbc_stop(struct xhci_hcd *xhci) spin_unlock_irqrestore(&dbc->lock, flags); if (!ret) { - xhci_dbc_mem_cleanup(xhci); + xhci_dbc_mem_cleanup(dbc); pm_runtime_put_sync(xhci_to_hcd(xhci)->self.controller); } } -- cgit v1.2.3-70-g09d2 From 11e229a7585160c33228a9789405a504b8150525 Mon Sep 17 00:00:00 2001 From: Mathias Nyman Date: Thu, 23 Jul 2020 17:45:24 +0300 Subject: xhci: dbc: Pass dbc pointer to dbc start and stop functions. xhci_dbc_start() and xhci_dbc_stop() functions only used xhci_hcd pointer to get the dbc pointer. Pass the dbc pointer instead of the xhci_hcd pointer as a parameter No functional changes This change helps decoupling xhci and DbC Signed-off-by: Mathias Nyman Link: https://lore.kernel.org/r/20200723144530.9992-22-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/xhci-dbgcap.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/host/xhci-dbgcap.c b/drivers/usb/host/xhci-dbgcap.c index 626635f26658..af6e3622e53a 100644 --- a/drivers/usb/host/xhci-dbgcap.c +++ b/drivers/usb/host/xhci-dbgcap.c @@ -548,11 +548,10 @@ static void xhci_dbc_mem_cleanup(struct xhci_dbc *dbc) dbc->ring_evt = NULL; } -static int xhci_do_dbc_start(struct xhci_hcd *xhci) +static int xhci_do_dbc_start(struct xhci_dbc *dbc) { int ret; u32 ctrl; - struct xhci_dbc *dbc = xhci->dbc; if (dbc->state != DS_DISABLED) return -EINVAL; @@ -593,33 +592,31 @@ static int xhci_do_dbc_stop(struct xhci_dbc *dbc) return 0; } -static int xhci_dbc_start(struct xhci_hcd *xhci) +static int xhci_dbc_start(struct xhci_dbc *dbc) { int ret; unsigned long flags; - struct xhci_dbc *dbc = xhci->dbc; WARN_ON(!dbc); - pm_runtime_get_sync(xhci_to_hcd(xhci)->self.controller); + pm_runtime_get_sync(dbc->dev); /* note this was self.controller */ spin_lock_irqsave(&dbc->lock, flags); - ret = xhci_do_dbc_start(xhci); + ret = xhci_do_dbc_start(dbc); spin_unlock_irqrestore(&dbc->lock, flags); if (ret) { - pm_runtime_put(xhci_to_hcd(xhci)->self.controller); + pm_runtime_put(dbc->dev); /* note this was self.controller */ return ret; } return mod_delayed_work(system_wq, &dbc->event_work, 1); } -static void xhci_dbc_stop(struct xhci_hcd *xhci) +static void xhci_dbc_stop(struct xhci_dbc *dbc) { int ret; unsigned long flags; - struct xhci_dbc *dbc = xhci->dbc; struct dbc_port *port = &dbc->port; WARN_ON(!dbc); @@ -635,7 +632,7 @@ static void xhci_dbc_stop(struct xhci_hcd *xhci) if (!ret) { xhci_dbc_mem_cleanup(dbc); - pm_runtime_put_sync(xhci_to_hcd(xhci)->self.controller); + pm_runtime_put_sync(dbc->dev); /* note, was self.controller */ } } @@ -996,13 +993,15 @@ static ssize_t dbc_store(struct device *dev, const char *buf, size_t count) { struct xhci_hcd *xhci; + struct xhci_dbc *dbc; xhci = hcd_to_xhci(dev_get_drvdata(dev)); + dbc = xhci->dbc; if (!strncmp(buf, "enable", 6)) - xhci_dbc_start(xhci); + xhci_dbc_start(dbc); else if (!strncmp(buf, "disable", 7)) - xhci_dbc_stop(xhci); + xhci_dbc_stop(dbc); else return -EINVAL; @@ -1047,7 +1046,7 @@ void xhci_dbc_exit(struct xhci_hcd *xhci) device_remove_file(dev, &dev_attr_dbc); xhci_dbc_tty_unregister_driver(); - xhci_dbc_stop(xhci); + xhci_dbc_stop(xhci->dbc); xhci_do_dbc_exit(xhci); } @@ -1062,7 +1061,7 @@ int xhci_dbc_suspend(struct xhci_hcd *xhci) if (dbc->state == DS_CONFIGURED) dbc->resume_required = 1; - xhci_dbc_stop(xhci); + xhci_dbc_stop(dbc); return 0; } @@ -1077,7 +1076,7 @@ int xhci_dbc_resume(struct xhci_hcd *xhci) if (dbc->resume_required) { dbc->resume_required = 0; - xhci_dbc_start(xhci); + xhci_dbc_start(dbc); } return ret; -- cgit v1.2.3-70-g09d2 From e0aa56dc7b18c80b12a9afd23d90aa6d186f639a Mon Sep 17 00:00:00 2001 From: Mathias Nyman Date: Thu, 23 Jul 2020 17:45:25 +0300 Subject: xhci: dbc: simplify dbc requests allocation and queueing Don't pass endpoint pointer, dbctty should not be aware of struct dbc_ep, knowing the direction is enough. Signed-off-by: Mathias Nyman Link: https://lore.kernel.org/r/20200723144530.9992-23-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/xhci-dbgcap.c | 43 +++++++++++++++++++++++++++--------------- drivers/usb/host/xhci-dbgcap.h | 12 +++++++----- drivers/usb/host/xhci-dbgtty.c | 33 ++++++++++++++++---------------- 3 files changed, 52 insertions(+), 36 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/host/xhci-dbgcap.c b/drivers/usb/host/xhci-dbgcap.c index af6e3622e53a..e3eec628edb5 100644 --- a/drivers/usb/host/xhci-dbgcap.c +++ b/drivers/usb/host/xhci-dbgcap.c @@ -135,8 +135,7 @@ static void xhci_dbc_giveback(struct dbc_request *req, int status) __releases(&dbc->lock) __acquires(&dbc->lock) { - struct dbc_ep *dep = req->dep; - struct xhci_dbc *dbc = dep->dbc; + struct xhci_dbc *dbc = req->dbc; struct device *dev = dbc->dev; list_del_init(&req->list_pending); @@ -151,7 +150,7 @@ static void xhci_dbc_giveback(struct dbc_request *req, int status) dma_unmap_single(dev, req->dma, req->length, - dbc_ep_dma_direction(dep)); + dbc_ep_dma_direction(req)); /* Give back the transfer request: */ spin_unlock(&dbc->lock); @@ -187,18 +186,25 @@ static void xhci_dbc_flush_requests(struct xhci_dbc *dbc) } struct dbc_request * -dbc_alloc_request(struct dbc_ep *dep, gfp_t gfp_flags) +dbc_alloc_request(struct xhci_dbc *dbc, unsigned int direction, gfp_t flags) { struct dbc_request *req; - req = kzalloc(sizeof(*req), gfp_flags); + if (direction != BULK_IN && + direction != BULK_OUT) + return NULL; + + if (!dbc) + return NULL; + + req = kzalloc(sizeof(*req), flags); if (!req) return NULL; - req->dep = dep; + req->dbc = dbc; INIT_LIST_HEAD(&req->list_pending); INIT_LIST_HEAD(&req->list_pool); - req->direction = dep->direction; + req->direction = direction; trace_xhci_dbc_alloc_request(req); @@ -206,7 +212,7 @@ dbc_alloc_request(struct dbc_ep *dep, gfp_t gfp_flags) } void -dbc_free_request(struct dbc_ep *dep, struct dbc_request *req) +dbc_free_request(struct dbc_request *req) { trace_xhci_dbc_free_request(req); @@ -242,7 +248,7 @@ static int xhci_dbc_queue_bulk_tx(struct dbc_ep *dep, u64 addr; union xhci_trb *trb; unsigned int num_trbs; - struct xhci_dbc *dbc = dep->dbc; + struct xhci_dbc *dbc = req->dbc; struct xhci_ring *ring = dep->ring; u32 length, control, cycle; @@ -286,11 +292,12 @@ static int xhci_dbc_queue_bulk_tx(struct dbc_ep *dep, } static int -dbc_ep_do_queue(struct dbc_ep *dep, struct dbc_request *req) +dbc_ep_do_queue(struct dbc_request *req) { int ret; - struct xhci_dbc *dbc = dep->dbc; + struct xhci_dbc *dbc = req->dbc; struct device *dev = dbc->dev; + struct dbc_ep *dep = &dbc->eps[req->direction]; if (!req->length || !req->buf) return -EINVAL; @@ -322,16 +329,22 @@ dbc_ep_do_queue(struct dbc_ep *dep, struct dbc_request *req) return 0; } -int dbc_ep_queue(struct dbc_ep *dep, struct dbc_request *req, - gfp_t gfp_flags) +int dbc_ep_queue(struct dbc_request *req) { unsigned long flags; - struct xhci_dbc *dbc = dep->dbc; + struct xhci_dbc *dbc = req->dbc; int ret = -ESHUTDOWN; + if (!dbc) + return -ENODEV; + + if (req->direction != BULK_IN && + req->direction != BULK_OUT) + return -EINVAL; + spin_lock_irqsave(&dbc->lock, flags); if (dbc->state == DS_CONFIGURED) - ret = dbc_ep_do_queue(dep, req); + ret = dbc_ep_do_queue(req); spin_unlock_irqrestore(&dbc->lock, flags); mod_delayed_work(system_wq, &dbc->event_work, 0); diff --git a/drivers/usb/host/xhci-dbgcap.h b/drivers/usb/host/xhci-dbgcap.h index 9e3c5940f27b..fe360cf712c1 100644 --- a/drivers/usb/host/xhci-dbgcap.h +++ b/drivers/usb/host/xhci-dbgcap.h @@ -88,7 +88,7 @@ struct dbc_ep { struct xhci_dbc *dbc; struct list_head list_pending; struct xhci_ring *ring; - unsigned direction:1; + unsigned int direction:1; }; #define DBC_QUEUE_SIZE 16 @@ -147,7 +147,7 @@ struct dbc_request { int status; unsigned int actual; - struct dbc_ep *dep; + struct xhci_dbc *dbc; struct list_head list_pending; dma_addr_t trb_dma; union xhci_trb *trb; @@ -196,9 +196,11 @@ int xhci_dbc_tty_register_driver(struct xhci_hcd *xhci); void xhci_dbc_tty_unregister_driver(void); int xhci_dbc_tty_register_device(struct xhci_dbc *dbc); void xhci_dbc_tty_unregister_device(struct xhci_dbc *dbc); -struct dbc_request *dbc_alloc_request(struct dbc_ep *dep, gfp_t gfp_flags); -void dbc_free_request(struct dbc_ep *dep, struct dbc_request *req); -int dbc_ep_queue(struct dbc_ep *dep, struct dbc_request *req, gfp_t gfp_flags); +struct dbc_request *dbc_alloc_request(struct xhci_dbc *dbc, + unsigned int direction, + gfp_t flags); +void dbc_free_request(struct dbc_request *req); +int dbc_ep_queue(struct dbc_request *req); #ifdef CONFIG_PM int xhci_dbc_suspend(struct xhci_hcd *xhci); int xhci_dbc_resume(struct xhci_hcd *xhci); diff --git a/drivers/usb/host/xhci-dbgtty.c b/drivers/usb/host/xhci-dbgtty.c index 967f0419dad7..9886d42e1ff2 100644 --- a/drivers/usb/host/xhci-dbgtty.c +++ b/drivers/usb/host/xhci-dbgtty.c @@ -48,7 +48,7 @@ static int dbc_start_tx(struct dbc_port *port) list_del(&req->list_pool); spin_unlock(&port->port_lock); - status = dbc_ep_queue(port->out, req, GFP_ATOMIC); + status = dbc_ep_queue(req); spin_lock(&port->port_lock); if (status) { @@ -80,7 +80,7 @@ static void dbc_start_rx(struct dbc_port *port) req->length = DBC_MAX_PACKET; spin_unlock(&port->port_lock); - status = dbc_ep_queue(port->in, req, GFP_ATOMIC); + status = dbc_ep_queue(req); spin_lock(&port->port_lock); if (status) { @@ -123,28 +123,29 @@ static void dbc_write_complete(struct xhci_dbc *dbc, struct dbc_request *req) spin_unlock_irqrestore(&port->port_lock, flags); } -static void xhci_dbc_free_req(struct dbc_ep *dep, struct dbc_request *req) +static void xhci_dbc_free_req(struct dbc_request *req) { kfree(req->buf); - dbc_free_request(dep, req); + dbc_free_request(req); } static int -xhci_dbc_alloc_requests(struct dbc_ep *dep, struct list_head *head, +xhci_dbc_alloc_requests(struct xhci_dbc *dbc, unsigned int direction, + struct list_head *head, void (*fn)(struct xhci_dbc *, struct dbc_request *)) { int i; struct dbc_request *req; for (i = 0; i < DBC_QUEUE_SIZE; i++) { - req = dbc_alloc_request(dep, GFP_KERNEL); + req = dbc_alloc_request(dbc, direction, GFP_KERNEL); if (!req) break; req->length = DBC_MAX_PACKET; req->buf = kmalloc(req->length, GFP_KERNEL); if (!req->buf) { - dbc_free_request(dep, req); + dbc_free_request(req); break; } @@ -156,14 +157,14 @@ xhci_dbc_alloc_requests(struct dbc_ep *dep, struct list_head *head, } static void -xhci_dbc_free_requests(struct dbc_ep *dep, struct list_head *head) +xhci_dbc_free_requests(struct list_head *head) { struct dbc_request *req; while (!list_empty(head)) { req = list_entry(head->next, struct dbc_request, list_pool); list_del(&req->list_pool); - xhci_dbc_free_req(dep, req); + xhci_dbc_free_req(req); } } @@ -456,12 +457,12 @@ int xhci_dbc_tty_register_device(struct xhci_dbc *dbc) if (ret) goto buf_alloc_fail; - ret = xhci_dbc_alloc_requests(port->in, &port->read_pool, + ret = xhci_dbc_alloc_requests(dbc, BULK_IN, &port->read_pool, dbc_read_complete); if (ret) goto request_fail; - ret = xhci_dbc_alloc_requests(port->out, &port->write_pool, + ret = xhci_dbc_alloc_requests(dbc, BULK_OUT, &port->write_pool, dbc_write_complete); if (ret) goto request_fail; @@ -471,8 +472,8 @@ int xhci_dbc_tty_register_device(struct xhci_dbc *dbc) return 0; request_fail: - xhci_dbc_free_requests(port->in, &port->read_pool); - xhci_dbc_free_requests(port->out, &port->write_pool); + xhci_dbc_free_requests(&port->read_pool); + xhci_dbc_free_requests(&port->write_pool); kfifo_free(&port->write_fifo); buf_alloc_fail: @@ -495,7 +496,7 @@ void xhci_dbc_tty_unregister_device(struct xhci_dbc *dbc) port->registered = false; kfifo_free(&port->write_fifo); - xhci_dbc_free_requests(get_out_ep(dbc), &port->read_pool); - xhci_dbc_free_requests(get_out_ep(dbc), &port->read_queue); - xhci_dbc_free_requests(get_in_ep(dbc), &port->write_pool); + xhci_dbc_free_requests(&port->read_pool); + xhci_dbc_free_requests(&port->read_queue); + xhci_dbc_free_requests(&port->write_pool); } -- cgit v1.2.3-70-g09d2 From 4ee0e36643895e1b82d491e93acb5677d4d733de Mon Sep 17 00:00:00 2001 From: Mathias Nyman Date: Thu, 23 Jul 2020 17:45:26 +0300 Subject: xhci: dbc: remove endpoint pointers from dbc_port structure dbctty no longer needs references directly to dbc endpoints, so remove them Signed-off-by: Mathias Nyman Link: https://lore.kernel.org/r/20200723144530.9992-24-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/xhci-dbgcap.h | 2 -- drivers/usb/host/xhci-dbgtty.c | 2 -- 2 files changed, 4 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/host/xhci-dbgcap.h b/drivers/usb/host/xhci-dbgcap.h index fe360cf712c1..796cf2808be8 100644 --- a/drivers/usb/host/xhci-dbgcap.h +++ b/drivers/usb/host/xhci-dbgcap.h @@ -110,8 +110,6 @@ struct dbc_port { struct kfifo write_fifo; bool registered; - struct dbc_ep *in; - struct dbc_ep *out; }; struct xhci_dbc { diff --git a/drivers/usb/host/xhci-dbgtty.c b/drivers/usb/host/xhci-dbgtty.c index 9886d42e1ff2..ab2b82aa04be 100644 --- a/drivers/usb/host/xhci-dbgtty.c +++ b/drivers/usb/host/xhci-dbgtty.c @@ -426,8 +426,6 @@ xhci_dbc_tty_init_port(struct xhci_dbc *dbc, struct dbc_port *port) INIT_LIST_HEAD(&port->read_queue); INIT_LIST_HEAD(&port->write_pool); - port->in = get_in_ep(dbc); - port->out = get_out_ep(dbc); port->port.ops = &dbc_port_ops; port->n_read = 0; } -- cgit v1.2.3-70-g09d2 From 4521f16139409cdf9462c7325d43454462cff6c3 Mon Sep 17 00:00:00 2001 From: Mathias Nyman Date: Thu, 23 Jul 2020 17:45:27 +0300 Subject: xhci: dbctty: split dbc tty driver registration and unregistration functions. Split the dbc tty driver registrations function into separate init and probe parts. The init part will register the tty driver, and should in the future be called from module_init(). The probe part will become the normal probe function, but for now it is called from the init part. The unregister function is s likewise split into remove and exit parts. Signed-off-by: Mathias Nyman Link: https://lore.kernel.org/r/20200723144530.9992-25-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/xhci-dbgcap.c | 6 +- drivers/usb/host/xhci-dbgcap.h | 4 +- drivers/usb/host/xhci-dbgtty.c | 125 +++++++++++++++++++++++++---------------- 3 files changed, 81 insertions(+), 54 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/host/xhci-dbgcap.c b/drivers/usb/host/xhci-dbgcap.c index e3eec628edb5..99f0b425274a 100644 --- a/drivers/usb/host/xhci-dbgcap.c +++ b/drivers/usb/host/xhci-dbgcap.c @@ -1032,7 +1032,7 @@ int xhci_dbc_init(struct xhci_hcd *xhci) if (ret) goto init_err3; - ret = xhci_dbc_tty_register_driver(xhci); + ret = xhci_dbc_tty_probe(xhci); if (ret) goto init_err2; @@ -1043,7 +1043,7 @@ int xhci_dbc_init(struct xhci_hcd *xhci) return 0; init_err1: - xhci_dbc_tty_unregister_driver(); + xhci_dbc_tty_remove(xhci->dbc); init_err2: xhci_do_dbc_exit(xhci); init_err3: @@ -1058,7 +1058,7 @@ void xhci_dbc_exit(struct xhci_hcd *xhci) return; device_remove_file(dev, &dev_attr_dbc); - xhci_dbc_tty_unregister_driver(); + xhci_dbc_tty_remove(xhci->dbc); xhci_dbc_stop(xhci->dbc); xhci_do_dbc_exit(xhci); } diff --git a/drivers/usb/host/xhci-dbgcap.h b/drivers/usb/host/xhci-dbgcap.h index 796cf2808be8..e4c7c9279ea8 100644 --- a/drivers/usb/host/xhci-dbgcap.h +++ b/drivers/usb/host/xhci-dbgcap.h @@ -190,8 +190,8 @@ static inline struct dbc_ep *get_out_ep(struct xhci_dbc *dbc) #ifdef CONFIG_USB_XHCI_DBGCAP int xhci_dbc_init(struct xhci_hcd *xhci); void xhci_dbc_exit(struct xhci_hcd *xhci); -int xhci_dbc_tty_register_driver(struct xhci_hcd *xhci); -void xhci_dbc_tty_unregister_driver(void); +int xhci_dbc_tty_probe(struct xhci_hcd *xhci); +void xhci_dbc_tty_remove(struct xhci_dbc *dbc); int xhci_dbc_tty_register_device(struct xhci_dbc *dbc); void xhci_dbc_tty_unregister_device(struct xhci_dbc *dbc); struct dbc_request *dbc_alloc_request(struct xhci_dbc *dbc, diff --git a/drivers/usb/host/xhci-dbgtty.c b/drivers/usb/host/xhci-dbgtty.c index ab2b82aa04be..9acf1efba36c 100644 --- a/drivers/usb/host/xhci-dbgtty.c +++ b/drivers/usb/host/xhci-dbgtty.c @@ -14,6 +14,11 @@ #include "xhci.h" #include "xhci-dbgcap.h" +static int dbc_tty_init(void); +static void dbc_tty_exit(void); + +static struct tty_driver *dbc_tty_driver; + static unsigned int dbc_send_packet(struct dbc_port *port, char *packet, unsigned int size) { @@ -278,55 +283,6 @@ static const struct tty_operations dbc_tty_ops = { .unthrottle = dbc_tty_unthrottle, }; -static struct tty_driver *dbc_tty_driver; - -int xhci_dbc_tty_register_driver(struct xhci_hcd *xhci) -{ - int status; - struct xhci_dbc *dbc = xhci->dbc; - - dbc_tty_driver = tty_alloc_driver(1, TTY_DRIVER_REAL_RAW | - TTY_DRIVER_DYNAMIC_DEV); - if (IS_ERR(dbc_tty_driver)) { - status = PTR_ERR(dbc_tty_driver); - dbc_tty_driver = NULL; - return status; - } - - dbc_tty_driver->driver_name = "dbc_serial"; - dbc_tty_driver->name = "ttyDBC"; - - dbc_tty_driver->type = TTY_DRIVER_TYPE_SERIAL; - dbc_tty_driver->subtype = SERIAL_TYPE_NORMAL; - dbc_tty_driver->init_termios = tty_std_termios; - dbc_tty_driver->init_termios.c_cflag = - B9600 | CS8 | CREAD | HUPCL | CLOCAL; - dbc_tty_driver->init_termios.c_ispeed = 9600; - dbc_tty_driver->init_termios.c_ospeed = 9600; - dbc_tty_driver->driver_state = &dbc->port; - - tty_set_operations(dbc_tty_driver, &dbc_tty_ops); - - status = tty_register_driver(dbc_tty_driver); - if (status) { - xhci_err(xhci, - "can't register dbc tty driver, err %d\n", status); - put_tty_driver(dbc_tty_driver); - dbc_tty_driver = NULL; - } - - return status; -} - -void xhci_dbc_tty_unregister_driver(void) -{ - if (dbc_tty_driver) { - tty_unregister_driver(dbc_tty_driver); - put_tty_driver(dbc_tty_driver); - dbc_tty_driver = NULL; - } -} - static void dbc_rx_push(unsigned long _port) { struct dbc_request *req; @@ -498,3 +454,74 @@ void xhci_dbc_tty_unregister_device(struct xhci_dbc *dbc) xhci_dbc_free_requests(&port->read_queue); xhci_dbc_free_requests(&port->write_pool); } + +int xhci_dbc_tty_probe(struct xhci_hcd *xhci) +{ + struct xhci_dbc *dbc = xhci->dbc; + int status; + + /* dbc_tty_init will be called by module init() in the future */ + status = dbc_tty_init(); + if (status) + return status; + + dbc_tty_driver->driver_state = &dbc->port; + + return 0; +out: + + /* dbc_tty_exit will be called by module_exit() in the future */ + dbc_tty_exit(); + return status; +} + +/* + * undo what probe did, assume dbc is stopped already. + * we also assume tty_unregister_device() is called before this + */ +void xhci_dbc_tty_remove(struct xhci_dbc *dbc) +{ + /* dbc_tty_exit will be called by module_exit() in the future */ + dbc_tty_exit(); +} + +static int dbc_tty_init(void) +{ + int ret; + + dbc_tty_driver = tty_alloc_driver(1, TTY_DRIVER_REAL_RAW | + TTY_DRIVER_DYNAMIC_DEV); + if (IS_ERR(dbc_tty_driver)) + return PTR_ERR(dbc_tty_driver); + + dbc_tty_driver->driver_name = "dbc_serial"; + dbc_tty_driver->name = "ttyDBC"; + + dbc_tty_driver->type = TTY_DRIVER_TYPE_SERIAL; + dbc_tty_driver->subtype = SERIAL_TYPE_NORMAL; + dbc_tty_driver->init_termios = tty_std_termios; + dbc_tty_driver->init_termios.c_cflag = + B9600 | CS8 | CREAD | HUPCL | CLOCAL; + dbc_tty_driver->init_termios.c_ispeed = 9600; + dbc_tty_driver->init_termios.c_ospeed = 9600; + + tty_set_operations(dbc_tty_driver, &dbc_tty_ops); + + ret = tty_register_driver(dbc_tty_driver); + if (ret) { + pr_err("Can't register dbc tty driver\n"); + put_tty_driver(dbc_tty_driver); + } + return ret; +} + +static void dbc_tty_exit(void) +{ + if (dbc_tty_driver) { + tty_unregister_driver(dbc_tty_driver); + put_tty_driver(dbc_tty_driver); + dbc_tty_driver = NULL; + } +} + + -- cgit v1.2.3-70-g09d2 From 6ae6470bfa330d0b8892e02888bf5dac2272c28d Mon Sep 17 00:00:00 2001 From: Mathias Nyman Date: Thu, 23 Jul 2020 17:45:28 +0300 Subject: xhci: dbc: Add a operations structure to access driver functions Don't call dbctty driver functions directly from dbc core code. Introduce a new dbc_driver structure that contains function pointers for disconnect and configure operations. The driver (ttydbc) must provide these opeations when creating a dbc. Name the structure dbc_driver instead of dbc_ops as we plan to add more driver configureable values here, such as vid and pid. Decouples dbc and dbctty. Signed-off-by: Mathias Nyman Link: https://lore.kernel.org/r/20200723144530.9992-26-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/xhci-dbgcap.c | 17 ++++++----------- drivers/usb/host/xhci-dbgcap.h | 8 ++++++-- drivers/usb/host/xhci-dbgtty.c | 11 +++++++++-- 3 files changed, 21 insertions(+), 15 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/host/xhci-dbgcap.c b/drivers/usb/host/xhci-dbgcap.c index 99f0b425274a..47090bceae21 100644 --- a/drivers/usb/host/xhci-dbgcap.c +++ b/drivers/usb/host/xhci-dbgcap.c @@ -636,8 +636,8 @@ static void xhci_dbc_stop(struct xhci_dbc *dbc) cancel_delayed_work_sync(&dbc->event_work); - if (port->registered) - xhci_dbc_tty_unregister_device(dbc); + if (port->registered && dbc->driver->disconnect) + dbc->driver->disconnect(dbc); spin_lock_irqsave(&dbc->lock, flags); ret = xhci_do_dbc_stop(dbc); @@ -877,7 +877,6 @@ static enum evtreturn xhci_dbc_do_handle_events(struct xhci_dbc *dbc) static void xhci_dbc_handle_events(struct work_struct *work) { - int ret; enum evtreturn evtr; struct xhci_dbc *dbc; unsigned long flags; @@ -890,16 +889,12 @@ static void xhci_dbc_handle_events(struct work_struct *work) switch (evtr) { case EVT_GSER: - ret = xhci_dbc_tty_register_device(dbc); - if (ret) { - dev_err(dbc->dev, "failed to alloc tty device\n"); - break; - } - - dev_info(dbc->dev, "DbC now attached to /dev/ttyDBC0\n"); + if (dbc->driver->configure) + dbc->driver->configure(dbc); break; case EVT_DISC: - xhci_dbc_tty_unregister_device(dbc); + if (dbc->driver->disconnect) + dbc->driver->disconnect(dbc); break; case EVT_DONE: break; diff --git a/drivers/usb/host/xhci-dbgcap.h b/drivers/usb/host/xhci-dbgcap.h index e4c7c9279ea8..5018b32fc742 100644 --- a/drivers/usb/host/xhci-dbgcap.h +++ b/drivers/usb/host/xhci-dbgcap.h @@ -112,6 +112,11 @@ struct dbc_port { bool registered; }; +struct dbc_driver { + int (*configure)(struct xhci_dbc *dbc); + void (*disconnect)(struct xhci_dbc *dbc); +}; + struct xhci_dbc { spinlock_t lock; /* device access */ struct device *dev; @@ -133,6 +138,7 @@ struct xhci_dbc { struct dbc_ep eps[2]; struct dbc_port port; + const struct dbc_driver *driver; }; struct dbc_request { @@ -192,8 +198,6 @@ int xhci_dbc_init(struct xhci_hcd *xhci); void xhci_dbc_exit(struct xhci_hcd *xhci); int xhci_dbc_tty_probe(struct xhci_hcd *xhci); void xhci_dbc_tty_remove(struct xhci_dbc *dbc); -int xhci_dbc_tty_register_device(struct xhci_dbc *dbc); -void xhci_dbc_tty_unregister_device(struct xhci_dbc *dbc); struct dbc_request *dbc_alloc_request(struct xhci_dbc *dbc, unsigned int direction, gfp_t flags); diff --git a/drivers/usb/host/xhci-dbgtty.c b/drivers/usb/host/xhci-dbgtty.c index 9acf1efba36c..3231cec74a7a 100644 --- a/drivers/usb/host/xhci-dbgtty.c +++ b/drivers/usb/host/xhci-dbgtty.c @@ -455,6 +455,11 @@ void xhci_dbc_tty_unregister_device(struct xhci_dbc *dbc) xhci_dbc_free_requests(&port->write_pool); } +static const struct dbc_driver dbc_driver = { + .configure = xhci_dbc_tty_register_device, + .disconnect = xhci_dbc_tty_unregister_device, +}; + int xhci_dbc_tty_probe(struct xhci_hcd *xhci) { struct xhci_dbc *dbc = xhci->dbc; @@ -465,6 +470,8 @@ int xhci_dbc_tty_probe(struct xhci_hcd *xhci) if (status) return status; + dbc->driver = &dbc_driver; + dbc_tty_driver->driver_state = &dbc->port; return 0; @@ -481,6 +488,8 @@ out: */ void xhci_dbc_tty_remove(struct xhci_dbc *dbc) { + dbc->driver = NULL; + /* dbc_tty_exit will be called by module_exit() in the future */ dbc_tty_exit(); } @@ -523,5 +532,3 @@ static void dbc_tty_exit(void) dbc_tty_driver = NULL; } } - - -- cgit v1.2.3-70-g09d2 From 688915b11aa7f8b92d12a2e4672d71e3626a0e6a Mon Sep 17 00:00:00 2001 From: Mathias Nyman Date: Thu, 23 Jul 2020 17:45:29 +0300 Subject: xhci: dbgcap: remove dbc dependency on dbctty specific flag dbc should not be aware of, or use any dbctty specific variables. currenly dbc driver reads the port->registered flag to see if the callbacks should be called. Only makes these decisions based on dbc internal state instead. Signed-off-by: Mathias Nyman Link: https://lore.kernel.org/r/20200723144530.9992-27-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/xhci-dbgcap.c | 16 ++++++++++++---- drivers/usb/host/xhci-dbgtty.c | 5 +++++ 2 files changed, 17 insertions(+), 4 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/host/xhci-dbgcap.c b/drivers/usb/host/xhci-dbgcap.c index 47090bceae21..c57178db7994 100644 --- a/drivers/usb/host/xhci-dbgcap.c +++ b/drivers/usb/host/xhci-dbgcap.c @@ -630,14 +630,22 @@ static void xhci_dbc_stop(struct xhci_dbc *dbc) { int ret; unsigned long flags; - struct dbc_port *port = &dbc->port; WARN_ON(!dbc); - cancel_delayed_work_sync(&dbc->event_work); + switch (dbc->state) { + case DS_DISABLED: + return; + case DS_CONFIGURED: + case DS_STALLED: + if (dbc->driver->disconnect) + dbc->driver->disconnect(dbc); + break; + default: + break; + } - if (port->registered && dbc->driver->disconnect) - dbc->driver->disconnect(dbc); + cancel_delayed_work_sync(&dbc->event_work); spin_lock_irqsave(&dbc->lock, flags); ret = xhci_do_dbc_stop(dbc); diff --git a/drivers/usb/host/xhci-dbgtty.c b/drivers/usb/host/xhci-dbgtty.c index 3231cec74a7a..3b306a22da47 100644 --- a/drivers/usb/host/xhci-dbgtty.c +++ b/drivers/usb/host/xhci-dbgtty.c @@ -399,6 +399,9 @@ int xhci_dbc_tty_register_device(struct xhci_dbc *dbc) struct device *tty_dev; struct dbc_port *port = &dbc->port; + if (port->registered) + return -EBUSY; + xhci_dbc_tty_init_port(dbc, port); tty_dev = tty_port_register_device(&port->port, dbc_tty_driver, 0, NULL); @@ -445,6 +448,8 @@ void xhci_dbc_tty_unregister_device(struct xhci_dbc *dbc) { struct dbc_port *port = &dbc->port; + if (!port->registered) + return; tty_unregister_device(dbc_tty_driver, 0); xhci_dbc_tty_exit_port(port); port->registered = false; -- cgit v1.2.3-70-g09d2 From 9a360a7cae11461ccd933a9ea366b0dcb3afadb0 Mon Sep 17 00:00:00 2001 From: Mathias Nyman Date: Thu, 23 Jul 2020 17:45:30 +0300 Subject: xhci: dbc: remove tty specific port structure from struct xhci_dbc Use a void pointer that any function driver can use instead. Signed-off-by: Mathias Nyman Link: https://lore.kernel.org/r/20200723144530.9992-28-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/xhci-dbgcap.h | 2 +- drivers/usb/host/xhci-dbgtty.c | 29 +++++++++++++++++++++++------ 2 files changed, 24 insertions(+), 7 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/host/xhci-dbgcap.h b/drivers/usb/host/xhci-dbgcap.h index 5018b32fc742..c70b78d504eb 100644 --- a/drivers/usb/host/xhci-dbgcap.h +++ b/drivers/usb/host/xhci-dbgcap.h @@ -137,8 +137,8 @@ struct xhci_dbc { unsigned resume_required:1; struct dbc_ep eps[2]; - struct dbc_port port; const struct dbc_driver *driver; + void *priv; }; struct dbc_request { diff --git a/drivers/usb/host/xhci-dbgtty.c b/drivers/usb/host/xhci-dbgtty.c index 3b306a22da47..0b942112b6f8 100644 --- a/drivers/usb/host/xhci-dbgtty.c +++ b/drivers/usb/host/xhci-dbgtty.c @@ -19,6 +19,11 @@ static void dbc_tty_exit(void); static struct tty_driver *dbc_tty_driver; +static inline struct dbc_port *dbc_to_port(struct xhci_dbc *dbc) +{ + return dbc->priv; +} + static unsigned int dbc_send_packet(struct dbc_port *port, char *packet, unsigned int size) { @@ -99,7 +104,7 @@ static void dbc_read_complete(struct xhci_dbc *dbc, struct dbc_request *req) { unsigned long flags; - struct dbc_port *port = &dbc->port; + struct dbc_port *port = dbc_to_port(dbc); spin_lock_irqsave(&port->port_lock, flags); list_add_tail(&req->list_pool, &port->read_queue); @@ -110,7 +115,7 @@ dbc_read_complete(struct xhci_dbc *dbc, struct dbc_request *req) static void dbc_write_complete(struct xhci_dbc *dbc, struct dbc_request *req) { unsigned long flags; - struct dbc_port *port = &dbc->port; + struct dbc_port *port = dbc_to_port(dbc); spin_lock_irqsave(&port->port_lock, flags); list_add(&req->list_pool, &port->write_pool); @@ -397,7 +402,7 @@ int xhci_dbc_tty_register_device(struct xhci_dbc *dbc) { int ret; struct device *tty_dev; - struct dbc_port *port = &dbc->port; + struct dbc_port *port = dbc_to_port(dbc); if (port->registered) return -EBUSY; @@ -446,7 +451,7 @@ register_fail: void xhci_dbc_tty_unregister_device(struct xhci_dbc *dbc) { - struct dbc_port *port = &dbc->port; + struct dbc_port *port = dbc_to_port(dbc); if (!port->registered) return; @@ -468,6 +473,7 @@ static const struct dbc_driver dbc_driver = { int xhci_dbc_tty_probe(struct xhci_hcd *xhci) { struct xhci_dbc *dbc = xhci->dbc; + struct dbc_port *port; int status; /* dbc_tty_init will be called by module init() in the future */ @@ -475,13 +481,20 @@ int xhci_dbc_tty_probe(struct xhci_hcd *xhci) if (status) return status; + port = kzalloc(sizeof(*port), GFP_KERNEL); + if (!port) { + status = -ENOMEM; + goto out; + } + dbc->driver = &dbc_driver; + dbc->priv = port; + - dbc_tty_driver->driver_state = &dbc->port; + dbc_tty_driver->driver_state = port; return 0; out: - /* dbc_tty_exit will be called by module_exit() in the future */ dbc_tty_exit(); return status; @@ -493,7 +506,11 @@ out: */ void xhci_dbc_tty_remove(struct xhci_dbc *dbc) { + struct dbc_port *port = dbc_to_port(dbc); + dbc->driver = NULL; + dbc->priv = NULL; + kfree(port); /* dbc_tty_exit will be called by module_exit() in the future */ dbc_tty_exit(); -- cgit v1.2.3-70-g09d2 From 7a410953d1fb4dbe91ffcfdee9cbbf889d19b0d7 Mon Sep 17 00:00:00 2001 From: Dan Robertson Date: Mon, 13 Jul 2020 12:05:22 -0400 Subject: usb: dwc3: meson-g12a: fix shared reset control use The reset is a shared reset line, but reset_control_reset is still used and reset_control_deassert is not guaranteed to have been called before the first reset_control_assert call. When suspending the following warning may be seen: WARNING: CPU: 1 PID: 5530 at drivers/reset/core.c:355 reset_control_assert+0x184/0x19c Hardware name: Hardkernel ODROID-N2 (DT) [..] pc : reset_control_assert+0x184/0x19c lr : dwc3_meson_g12a_suspend+0x68/0x7c [..] Call trace: reset_control_assert+0x184/0x19c dwc3_meson_g12a_suspend+0x68/0x7c platform_pm_suspend+0x28/0x54 __device_suspend+0x590/0xabc dpm_suspend+0x104/0x404 dpm_suspend_start+0x84/0x1bc suspend_devices_and_enter+0xc4/0x4fc pm_suspend+0x198/0x2d4 Fixes: 6d9fa35a347a87 ("usb: dwc3: meson-g12a: get the reset as shared") Signed-off-by: Dan Robertson Signed-off-by: Felipe Balbi --- drivers/usb/dwc3/dwc3-meson-g12a.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/dwc3/dwc3-meson-g12a.c b/drivers/usb/dwc3/dwc3-meson-g12a.c index 1f7f4d88ed9d..88b75b5a039c 100644 --- a/drivers/usb/dwc3/dwc3-meson-g12a.c +++ b/drivers/usb/dwc3/dwc3-meson-g12a.c @@ -737,13 +737,13 @@ static int dwc3_meson_g12a_probe(struct platform_device *pdev) goto err_disable_clks; } - ret = reset_control_reset(priv->reset); + ret = reset_control_deassert(priv->reset); if (ret) - goto err_disable_clks; + goto err_assert_reset; ret = dwc3_meson_g12a_get_phys(priv); if (ret) - goto err_disable_clks; + goto err_assert_reset; ret = priv->drvdata->setup_regmaps(priv, base); if (ret) @@ -752,7 +752,7 @@ static int dwc3_meson_g12a_probe(struct platform_device *pdev) if (priv->vbus) { ret = regulator_enable(priv->vbus); if (ret) - goto err_disable_clks; + goto err_assert_reset; } /* Get dr_mode */ @@ -765,13 +765,13 @@ static int dwc3_meson_g12a_probe(struct platform_device *pdev) ret = priv->drvdata->usb_init(priv); if (ret) - goto err_disable_clks; + goto err_assert_reset; /* Init PHYs */ for (i = 0 ; i < PHY_COUNT ; ++i) { ret = phy_init(priv->phys[i]); if (ret) - goto err_disable_clks; + goto err_assert_reset; } /* Set PHY Power */ @@ -809,6 +809,9 @@ err_phys_exit: for (i = 0 ; i < PHY_COUNT ; ++i) phy_exit(priv->phys[i]); +err_assert_reset: + reset_control_assert(priv->reset); + err_disable_clks: clk_bulk_disable_unprepare(priv->drvdata->num_clks, priv->drvdata->clks); -- cgit v1.2.3-70-g09d2 From f4cfe5ce607dd87873956453a7775c102a18fc62 Mon Sep 17 00:00:00 2001 From: Peter Chen Date: Fri, 17 Jul 2020 18:13:17 +0800 Subject: usb: cdns3: gadget: improve the set_configuration handling - Delete the duplicated EP_CMD_ERDY and EP_CMD_REQ_CMPL setting - Prepare the next setup before setting EP_CMD_ERDY and EP_CMD_REQ_CMPL, it could avoid a bug that DMA hang at EP0 OUT for DEV_VER_NXP_V1 - Delete the duplicated cdns3_set_hw_configuration calling at cdns3_req_ep0_set_configuration, the composite.c will handle this request, and call .ep0_queue back, and at .ep_queue it will call cdns3_set_hw_configuration. - Move cdns3_allow_enable_l1 into cdns3_set_hw_configuration since it is part of this function. Signed-off-by: Peter Chen Signed-off-by: Felipe Balbi --- drivers/usb/cdns3/ep0.c | 15 +++------------ drivers/usb/cdns3/gadget.c | 3 ++- 2 files changed, 5 insertions(+), 13 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/cdns3/ep0.c b/drivers/usb/cdns3/ep0.c index 88af81bc10a3..1530edd5838c 100644 --- a/drivers/usb/cdns3/ep0.c +++ b/drivers/usb/cdns3/ep0.c @@ -161,13 +161,12 @@ static int cdns3_req_ep0_set_configuration(struct cdns3_device *priv_dev, if (result) return result; - if (config) { - cdns3_set_hw_configuration(priv_dev); - } else { + if (!config) { cdns3_hw_reset_eps_config(priv_dev); usb_gadget_set_state(&priv_dev->gadget, USB_STATE_ADDRESS); } + break; case USB_STATE_CONFIGURED: result = cdns3_ep0_delegate_req(priv_dev, ctrl_req); @@ -707,7 +706,6 @@ static int cdns3_gadget_ep0_queue(struct usb_ep *ep, struct cdns3_endpoint *priv_ep = ep_to_cdns3_ep(ep); struct cdns3_device *priv_dev = priv_ep->cdns3_dev; unsigned long flags; - int erdy_sent = 0; int ret = 0; u8 zlp = 0; @@ -723,15 +721,8 @@ static int cdns3_gadget_ep0_queue(struct usb_ep *ep, /* send STATUS stage. Should be called only for SET_CONFIGURATION */ if (priv_dev->ep0_stage == CDNS3_STATUS_STAGE) { cdns3_select_ep(priv_dev, 0x00); - - erdy_sent = !priv_dev->hw_configured_flag; cdns3_set_hw_configuration(priv_dev); - - if (!erdy_sent) - cdns3_ep0_complete_setup(priv_dev, 0, 1); - - cdns3_allow_enable_l1(priv_dev, 1); - + cdns3_ep0_complete_setup(priv_dev, 0, 1); request->actual = 0; priv_dev->status_completion_no_call = true; priv_dev->pending_status_request = request; diff --git a/drivers/usb/cdns3/gadget.c b/drivers/usb/cdns3/gadget.c index d9dde624636b..5b4b16bf4164 100644 --- a/drivers/usb/cdns3/gadget.c +++ b/drivers/usb/cdns3/gadget.c @@ -1315,7 +1315,6 @@ void cdns3_set_hw_configuration(struct cdns3_device *priv_dev) return; writel(USB_CONF_CFGSET, &priv_dev->regs->usb_conf); - writel(EP_CMD_ERDY | EP_CMD_REQ_CMPL, &priv_dev->regs->ep_cmd); cdns3_set_register_bit(&priv_dev->regs->usb_conf, USB_CONF_U1EN | USB_CONF_U2EN); @@ -1332,6 +1331,8 @@ void cdns3_set_hw_configuration(struct cdns3_device *priv_dev) cdns3_start_all_request(priv_dev, priv_ep); } } + + cdns3_allow_enable_l1(priv_dev, 1); } /** -- cgit v1.2.3-70-g09d2 From 37d9453b052dec46f6439658536ca8f301566559 Mon Sep 17 00:00:00 2001 From: Marek Szyprowski Date: Thu, 16 Jul 2020 13:55:25 +0200 Subject: usb: gadget: udc: Flush pending work also in error path When binding an UDC driver to the pending gadget fails in check_pending_gadget_drivers(), the usb_add_gadget_udc_release() function ends without waiting for the usb_gadget_state_work to finish, what in turn might cause the whole struct usb_gadget being freed by the caller before the usb_gadget_state_work being executed. This can be observed on some boards with USB Mass Storage gadget compiled-in and kernel booted without the needed module parameters: dwc2 12480000.hsotg: dwc2_check_params: Invalid parameter besl=1 dwc2 12480000.hsotg: dwc2_check_params: Invalid parameter g_np_tx_fifo_size=1024 dwc2 12480000.hsotg: EPs: 16, dedicated fifos, 7808 entries in SPRAM Mass Storage Function, version: 2009/09/11 LUN: removable file: (no medium) no file given for LUN0 g_mass_storage 12480000.hsotg: failed to start g_mass_storage: -22 dwc2: probe of 12480000.hsotg failed with error -22 8<--- cut here --- Unable to handle kernel NULL pointer dereference at virtual address 00000004 pgd = (ptrval) [00000004] *pgd=00000000 Internal error: Oops: 5 [#1] PREEMPT SMP ARM Modules linked in: CPU: 1 PID: 88 Comm: kworker/1:2 Not tainted 5.8.0-rc5-next-20200715-00062-gc5bb489ae825-dirty #8792 Hardware name: Samsung Exynos (Flattened Device Tree) Workqueue: 0x0 (rcu_gp) PC is at process_one_work+0x44/0x7dc ... Process kworker/1:2 (pid: 88, stack limit = 0x(ptrval)) Stack: (0xed9f1f00 to 0xed9f2000) ... [] (process_one_work) from [] (worker_thread+0x44/0x51c) [] (worker_thread) from [] (kthread+0x158/0x1a0) [] (kthread) from [] (ret_from_fork+0x14/0x20) Exception stack(0xed9f1fb0 to 0xed9f1ff8) ... ---[ end trace 5033c1326a62e5f3 ]--- note: kworker/1:2[88] exited with preempt_count 1 Fix this by flushing pending work in error path. Reviewed-by: Peter Chen Signed-off-by: Marek Szyprowski Signed-off-by: Felipe Balbi --- drivers/usb/gadget/udc/core.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/usb') diff --git a/drivers/usb/gadget/udc/core.c b/drivers/usb/gadget/udc/core.c index c33ad8a333ad..4f82bcd31fd3 100644 --- a/drivers/usb/gadget/udc/core.c +++ b/drivers/usb/gadget/udc/core.c @@ -1230,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: -- cgit v1.2.3-70-g09d2 From abac8a85c8196c2a098048ad78552c8b1a236c4d Mon Sep 17 00:00:00 2001 From: Michał Mirosław Date: Wed, 8 Jul 2020 20:04:10 +0200 Subject: usb: gadget: udc: atmel: implement .pullup callback MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Implement udc->pullup callback, so that udc_connect/disconnect work. This is needed for composite gadget, as it assumes udc_disconnect() actually works and calls its ->disconnect callback. Acked-by: Cristian Birsan Acked-by: Alexandre Belloni Signed-off-by: Michał Mirosław Signed-off-by: Felipe Balbi --- drivers/usb/gadget/udc/atmel_usba_udc.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'drivers/usb') diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c b/drivers/usb/gadget/udc/atmel_usba_udc.c index 5ca75e69e251..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) { -- cgit v1.2.3-70-g09d2 From 33a06f1300a79cfd461cea0268f05e969d4f34ec Mon Sep 17 00:00:00 2001 From: Marek Szyprowski Date: Thu, 16 Jul 2020 14:09:48 +0200 Subject: usb: dwc2: Fix error path in gadget registration When gadget registration fails, one should not call usb_del_gadget_udc(). Ensure this by setting gadget->udc to NULL. Also in case of a failure there is no need to disable low-level hardware, so return immiedetly instead of jumping to error_init label. This fixes the following kernel NULL ptr dereference on gadget failure (can be easily triggered with g_mass_storage without any module parameters): dwc2 12480000.hsotg: dwc2_check_params: Invalid parameter besl=1 dwc2 12480000.hsotg: dwc2_check_params: Invalid parameter g_np_tx_fifo_size=1024 dwc2 12480000.hsotg: EPs: 16, dedicated fifos, 7808 entries in SPRAM Mass Storage Function, version: 2009/09/11 LUN: removable file: (no medium) no file given for LUN0 g_mass_storage 12480000.hsotg: failed to start g_mass_storage: -22 8<--- cut here --- Unable to handle kernel NULL pointer dereference at virtual address 00000104 pgd = (ptrval) [00000104] *pgd=00000000 Internal error: Oops: 805 [#1] PREEMPT SMP ARM Modules linked in: CPU: 0 PID: 12 Comm: kworker/0:1 Not tainted 5.8.0-rc5 #3133 Hardware name: Samsung Exynos (Flattened Device Tree) Workqueue: events deferred_probe_work_func PC is at usb_del_gadget_udc+0x38/0xc4 LR is at __mutex_lock+0x31c/0xb18 ... Process kworker/0:1 (pid: 12, stack limit = 0x(ptrval)) Stack: (0xef121db0 to 0xef122000) ... [] (usb_del_gadget_udc) from [] (dwc2_hsotg_remove+0x10/0x20) [] (dwc2_hsotg_remove) from [] (dwc2_driver_probe+0x57c/0x69c) [] (dwc2_driver_probe) from [] (platform_drv_probe+0x6c/0xa4) [] (platform_drv_probe) from [] (really_probe+0x200/0x48c) [] (really_probe) from [] (driver_probe_device+0x78/0x1fc) [] (driver_probe_device) from [] (bus_for_each_drv+0x74/0xb8) [] (bus_for_each_drv) from [] (__device_attach+0xd4/0x16c) [] (__device_attach) from [] (bus_probe_device+0x88/0x90) [] (bus_probe_device) from [] (deferred_probe_work_func+0x3c/0xd0) [] (deferred_probe_work_func) from [] (process_one_work+0x234/0x7dc) [] (process_one_work) from [] (worker_thread+0x44/0x51c) [] (worker_thread) from [] (kthread+0x158/0x1a0) [] (kthread) from [] (ret_from_fork+0x14/0x20) Exception stack(0xef121fb0 to 0xef121ff8) ... ---[ end trace 9724c2fc7cc9c982 ]--- While fixing this also fix the double call to dwc2_lowlevel_hw_disable() if dr_mode is set to USB_DR_MODE_PERIPHERAL. In such case low-level hardware is already disabled before calling usb_add_gadget_udc(). That function correctly preserves low-level hardware state, there is no need for the second unconditional dwc2_lowlevel_hw_disable() call. Fixes: 207324a321a8 ("usb: dwc2: Postponed gadget registration to the udc class driver") Acked-by: Minas Harutyunyan Signed-off-by: Marek Szyprowski Signed-off-by: Felipe Balbi --- drivers/usb/dwc2/platform.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'drivers/usb') diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c index 8fea5f1f60ab..68b56b43a45e 100644 --- a/drivers/usb/dwc2/platform.c +++ b/drivers/usb/dwc2/platform.c @@ -591,6 +591,7 @@ static int dwc2_driver_probe(struct platform_device *dev) if (hsotg->gadget_enabled) { retval = usb_add_gadget_udc(hsotg->dev, &hsotg->gadget); if (retval) { + hsotg->gadget.udc = NULL; dwc2_hsotg_remove(hsotg); goto error_init; } @@ -602,7 +603,8 @@ error_init: if (hsotg->params.activate_stm_id_vb_detection) regulator_disable(hsotg->usb33d); error: - dwc2_lowlevel_hw_disable(hsotg); + if (hsotg->dr_mode != USB_DR_MODE_PERIPHERAL) + dwc2_lowlevel_hw_disable(hsotg); return retval; } -- cgit v1.2.3-70-g09d2 From 75ae051efc9b3cceaed525e7ecb9cf19780e0af5 Mon Sep 17 00:00:00 2001 From: Chunfeng Yun Date: Mon, 13 Jul 2020 14:48:01 +0800 Subject: usb: gadget: bdc: use readl_poll_timeout() to simplify code Use readl_poll_timeout() to poll register status Cc: Florian Fainelli Reviewed-by: Stephen Boyd Signed-off-by: Chunfeng Yun Reviewed-by: Florian Fainelli Signed-off-by: Felipe Balbi --- drivers/usb/gadget/udc/bdc/bdc_core.c | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/gadget/udc/bdc/bdc_core.c b/drivers/usb/gadget/udc/bdc/bdc_core.c index 02a3a774670b..d567e20234f0 100644 --- a/drivers/usb/gadget/udc/bdc/bdc_core.c +++ b/drivers/usb/gadget/udc/bdc/bdc_core.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -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 */ -- cgit v1.2.3-70-g09d2 From ae90cc8237bf4ee416a326c51052ddcc7918ee43 Mon Sep 17 00:00:00 2001 From: Evgeny Novikov Date: Wed, 15 Jul 2020 19:40:09 +0300 Subject: usb: gadget: net2272: skip BAR1 on error handling paths in probe net2272_rdk1_probe() skips "i == 1" (BAR1) during allocation of resources. The patch does this on error hanling paths as well. Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Evgeny Novikov Signed-off-by: Felipe Balbi --- drivers/usb/gadget/udc/net2272.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers/usb') diff --git a/drivers/usb/gadget/udc/net2272.c b/drivers/usb/gadget/udc/net2272.c index fbbe62513545..44d1ea2307bb 100644 --- a/drivers/usb/gadget/udc/net2272.c +++ b/drivers/usb/gadget/udc/net2272.c @@ -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)); -- cgit v1.2.3-70-g09d2 From 33c4b00b85a9855de47e498a15e21515320cc442 Mon Sep 17 00:00:00 2001 From: Peter Chen Date: Wed, 22 Jul 2020 12:29:52 +0800 Subject: usb: cdns3: ep0: delete the unnecessary operation It doesn't need to enable/disable L1 on the fly for EP0 transfer, we only need to enable L1 after SET_CONFIGURATION. This code may be introduced by careless. Cc: Pawel Laszczak Signed-off-by: Peter Chen Signed-off-by: Felipe Balbi --- drivers/usb/cdns3/ep0.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/cdns3/ep0.c b/drivers/usb/cdns3/ep0.c index 1530edd5838c..d9779abc65b2 100644 --- a/drivers/usb/cdns3/ep0.c +++ b/drivers/usb/cdns3/ep0.c @@ -123,8 +123,6 @@ static void cdns3_ep0_complete_setup(struct cdns3_device *priv_dev, priv_dev->ep0_stage = CDNS3_SETUP_STAGE; writel((send_erdy ? EP_CMD_ERDY : 0) | EP_CMD_REQ_CMPL, &priv_dev->regs->ep_cmd); - - cdns3_allow_enable_l1(priv_dev, 1); } /** @@ -639,7 +637,6 @@ void cdns3_check_ep0_interrupt_proceed(struct cdns3_device *priv_dev, int dir) if (priv_dev->wait_for_setup && ep_sts_reg & EP_STS_IOC) { priv_dev->wait_for_setup = 0; - cdns3_allow_enable_l1(priv_dev, 0); cdns3_ep0_setup_phase(priv_dev); } else if ((ep_sts_reg & EP_STS_IOC) || (ep_sts_reg & EP_STS_ISP)) { priv_dev->ep0_data_dir = dir; -- cgit v1.2.3-70-g09d2 From 95f5acfc4f58f01a22b66d8c9c0ffb72aa96271c Mon Sep 17 00:00:00 2001 From: Peter Chen Date: Wed, 22 Jul 2020 11:06:19 +0800 Subject: usb: cdns3: gadget: always zeroed TRB buffer when enable endpoint During the endpoint dequeue operation, it changes dequeued TRB as link TRB, when the endpoint is disabled and re-enabled, the DMA fetches the TRB before the link TRB, after it handles current TRB, the DMA pointer will advance to the TRB after link TRB, but enqueue and dequene variables don't know it due to no hardware interrupt at the time, when the next TRB is added to link TRB position, the DMA will not handle this TRB due to its pointer is already at the next TRB. See the trace log like below: file-storage-675 [001] d..1 86.585657: usb_ep_queue: ep0: req 00000000df9b3a4f length 0/0 sgs 0/0 stream 0 zsI status 0 --> 0 file-storage-675 [001] d..1 86.585663: cdns3_ep_queue: ep1out: req: 000000002ebce364, req buff 00000000f5bc96b4, length: 0/1024 zsi, status: -115, trb: [start:0, end:0: virt addr (null)], flags:0 SID: 0 file-storage-675 [001] d..1 86.585671: cdns3_prepare_trb: ep1out: trb 000000007f770303, dma buf: 0xbd195800, size: 1024, burst: 128 ctrl: 0x00000425 (C=1, T=0, ISP, IOC, Normal) SID:0 LAST_SID:0 file-storage-675 [001] d..1 86.585676: cdns3_ring: Ring contents for ep1out: Ring deq index: 0, trb: 000000007f770303 (virt), 0xc4003000 (dma) Ring enq index: 1, trb: 0000000049c1ba21 (virt), 0xc400300c (dma) free trbs: 38, CCS=1, PCS=1 @0x00000000c4003000 bd195800 80020400 00000425 @0x00000000c400300c c4003018 80020400 00001811 @0x00000000c4003018 bcfcc000 0000001f 00000426 @0x00000000c4003024 bcfce800 0000001f 00000426 ... irq/144-5b13000-698 [000] d... 87.619286: usb_gadget_giveback_request: ep1in: req 0000000031b832eb length 13/13 sgs 0/0 stream 0 zsI status 0 --> 0 file-storage-675 [001] d..1 87.619287: cdns3_ep_queue: ep1out: req: 000000002ebce364, req buff 00000000f5bc96b4, length: 0/1024 zsi, status: -115, trb: [start:0, end:0: virt addr 0x80020400c400300c], flags:0 SID: 0 file-storage-675 [001] d..1 87.619294: cdns3_prepare_trb: ep1out: trb 0000000049c1ba21, dma buf: 0xbd198000, size: 1024, burst: 128 ctrl: 0x00000425 (C=1, T=0, ISP, IOC, Normal) SID:0 LAST_SID:0 file-storage-675 [001] d..1 87.619297: cdns3_ring: Ring contents for ep1out: Ring deq index: 1, trb: 0000000049c1ba21 (virt), 0xc400300c (dma) Ring enq index: 2, trb: 0000000059b34b67 (virt), 0xc4003018 (dma) free trbs: 38, CCS=1, PCS=1 @0x00000000c4003000 bd195800 0000001f 00000427 @0x00000000c400300c bd198000 80020400 00000425 @0x00000000c4003018 bcfcc000 0000001f 00000426 @0x00000000c4003024 bcfce800 0000001f 00000426 ... file-storage-675 [001] d..1 87.619305: cdns3_doorbell_epx: ep1out, ep_trbaddr c4003018 file-storage-675 [001] .... 87.619308: usb_ep_queue: ep1out: req 000000002ebce364 length 0/1024 sgs 0/0 stream 0 zsI status -115 --> 0 irq/144-5b13000-698 [000] d..1 87.619315: cdns3_epx_irq: IRQ for ep1out: 01000c80 TRBERR , ep_traddr: c4003018 ep_last_sid: 00000000 use_streams: 0 irq/144-5b13000-698 [000] d..1 87.619395: cdns3_usb_irq: IRQ 00000008 = Hot Reset Fixes: f616c3bda47e ("usb: cdns3: Fix dequeue implementation") Cc: stable Signed-off-by: Peter Chen Signed-off-by: Felipe Balbi --- drivers/usb/cdns3/gadget.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'drivers/usb') diff --git a/drivers/usb/cdns3/gadget.c b/drivers/usb/cdns3/gadget.c index 5b4b16bf4164..65a154d47f8e 100644 --- a/drivers/usb/cdns3/gadget.c +++ b/drivers/usb/cdns3/gadget.c @@ -242,9 +242,10 @@ int cdns3_allocate_trb_pool(struct cdns3_endpoint *priv_ep) return -ENOMEM; priv_ep->alloc_ring_size = ring_size; - memset(priv_ep->trb_pool, 0, ring_size); } + memset(priv_ep->trb_pool, 0, ring_size); + priv_ep->num_trbs = num_trbs; if (!priv_ep->num) -- cgit v1.2.3-70-g09d2 From b20aecff99a2335731bb2ae69c8368dfc356aef7 Mon Sep 17 00:00:00 2001 From: Pawel Laszczak Date: Mon, 13 Jul 2020 12:05:46 +0200 Subject: usb: cdns3: core: removed cdns3_get_current_role_driver function Function is not used in driver so it can be removed. Signed-off-by: Pawel Laszczak Reviewed-by: Peter Chen Signed-off-by: Felipe Balbi --- drivers/usb/cdns3/core.c | 7 ------- 1 file changed, 7 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/cdns3/core.c b/drivers/usb/cdns3/core.c index 59e5e213a99b..1f77fb5aefbf 100644 --- a/drivers/usb/cdns3/core.c +++ b/drivers/usb/cdns3/core.c @@ -27,13 +27,6 @@ static int cdns3_idle_init(struct cdns3 *cdns); -static inline -struct cdns3_role_driver *cdns3_get_current_role_driver(struct cdns3 *cdns) -{ - WARN_ON(!cdns->roles[cdns->role]); - return cdns->roles[cdns->role]; -} - static int cdns3_role_start(struct cdns3 *cdns, enum usb_role role) { int ret; -- cgit v1.2.3-70-g09d2 From 27afe1661275213adee3f8dc08b3610abcbca678 Mon Sep 17 00:00:00 2001 From: Pawel Laszczak Date: Mon, 13 Jul 2020 12:05:47 +0200 Subject: usb: cdns3: drd: removed not needed variables initialization Patch remove some variables initialization from core.c and drd.c file. Reviewed-by: Peter Chen Signed-off-by: Pawel Laszczak Signed-off-by: Felipe Balbi --- drivers/usb/cdns3/core.c | 4 ++-- drivers/usb/cdns3/drd.c | 19 +++++++++---------- 2 files changed, 11 insertions(+), 12 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/cdns3/core.c b/drivers/usb/cdns3/core.c index 1f77fb5aefbf..c498b585eb13 100644 --- a/drivers/usb/cdns3/core.c +++ b/drivers/usb/cdns3/core.c @@ -86,7 +86,7 @@ static int cdns3_core_init_role(struct cdns3 *cdns) struct device *dev = cdns->dev; enum usb_dr_mode best_dr_mode; enum usb_dr_mode dr_mode; - int ret = 0; + int ret; dr_mode = usb_get_dr_mode(dev); cdns->role = USB_ROLE_NONE; @@ -177,7 +177,7 @@ static int cdns3_core_init_role(struct cdns3 *cdns) goto err; } - return ret; + return 0; err: cdns3_exit_roles(cdns); return ret; diff --git a/drivers/usb/cdns3/drd.c b/drivers/usb/cdns3/drd.c index 58089841ed52..4939a568d8a2 100644 --- a/drivers/usb/cdns3/drd.c +++ b/drivers/usb/cdns3/drd.c @@ -29,7 +29,6 @@ */ int cdns3_set_mode(struct cdns3 *cdns, enum usb_dr_mode mode) { - int ret = 0; u32 reg; switch (mode) { @@ -61,7 +60,7 @@ int cdns3_set_mode(struct cdns3 *cdns, enum usb_dr_mode mode) return -EINVAL; } - return ret; + return 0; } int cdns3_get_id(struct cdns3 *cdns) @@ -134,11 +133,11 @@ static void cdns3_otg_enable_irq(struct cdns3 *cdns) int cdns3_drd_switch_host(struct cdns3 *cdns, int on) { int ret, val; - u32 reg = OTGCMD_OTG_DIS; /* switch OTG core */ if (on) { - writel(OTGCMD_HOST_BUS_REQ | reg, &cdns->otg_regs->cmd); + writel(OTGCMD_HOST_BUS_REQ | OTGCMD_OTG_DIS, + &cdns->otg_regs->cmd); dev_dbg(cdns->dev, "Waiting till Host mode is turned on\n"); ret = readl_poll_timeout_atomic(&cdns->otg_regs->sts, val, @@ -212,7 +211,7 @@ int cdns3_drd_switch_gadget(struct cdns3 *cdns, int on) */ static int cdns3_init_otg_mode(struct cdns3 *cdns) { - int ret = 0; + int ret; cdns3_otg_disable_irq(cdns); /* clear all interrupts */ @@ -223,7 +222,8 @@ static int cdns3_init_otg_mode(struct cdns3 *cdns) return ret; cdns3_otg_enable_irq(cdns); - return ret; + + return 0; } /** @@ -234,7 +234,7 @@ static int cdns3_init_otg_mode(struct cdns3 *cdns) */ int cdns3_drd_update_mode(struct cdns3 *cdns) { - int ret = 0; + int ret; switch (cdns->dr_mode) { case USB_DR_MODE_PERIPHERAL: @@ -307,8 +307,8 @@ static irqreturn_t cdns3_drd_irq(int irq, void *data) int cdns3_drd_init(struct cdns3 *cdns) { void __iomem *regs; - int ret = 0; u32 state; + int ret; regs = devm_ioremap_resource(cdns->dev, &cdns->otg_res); if (IS_ERR(regs)) @@ -359,7 +359,6 @@ int cdns3_drd_init(struct cdns3 *cdns) cdns3_drd_thread_irq, IRQF_SHARED, dev_name(cdns->dev), cdns); - if (ret) { dev_err(cdns->dev, "couldn't get otg_irq\n"); return ret; @@ -371,7 +370,7 @@ int cdns3_drd_init(struct cdns3 *cdns) return -ENODEV; } - return ret; + return 0; } int cdns3_drd_exit(struct cdns3 *cdns) -- cgit v1.2.3-70-g09d2 From ecf4f823fb7050e4f450bb56cd403cbb6d41ca7c Mon Sep 17 00:00:00 2001 From: Pawel Laszczak Date: Mon, 13 Jul 2020 12:05:48 +0200 Subject: usb: cnds3: drd: deleted != Patch deletes unnecessary != from condition statement in cdns3_drd_init function. Reviewed-by: Peter Chen Signed-off-by: Pawel Laszczak Signed-off-by: Felipe Balbi --- drivers/usb/cdns3/drd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/usb') diff --git a/drivers/usb/cdns3/drd.c b/drivers/usb/cdns3/drd.c index 4939a568d8a2..6d2da504ad49 100644 --- a/drivers/usb/cdns3/drd.c +++ b/drivers/usb/cdns3/drd.c @@ -365,7 +365,7 @@ int cdns3_drd_init(struct cdns3 *cdns) } state = readl(&cdns->otg_regs->sts); - if (OTGSTS_OTG_NRDY(state) != 0) { + if (OTGSTS_OTG_NRDY(state)) { dev_err(cdns->dev, "Cadence USB3 OTG device not ready\n"); return -ENODEV; } -- cgit v1.2.3-70-g09d2 From 03cce68a828dba13b3715033e5133839820218c3 Mon Sep 17 00:00:00 2001 From: Pawel Laszczak Date: Mon, 13 Jul 2020 12:05:49 +0200 Subject: usb: cdns3: drd: return IRQ_NONE explicitly. IRQ_NONE can be returned indirect. Reviewed-by: Peter Chen Signed-off-by: Pawel Laszczak Signed-off-by: Felipe Balbi --- drivers/usb/cdns3/drd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/cdns3/drd.c b/drivers/usb/cdns3/drd.c index 6d2da504ad49..05a9f7d54c46 100644 --- a/drivers/usb/cdns3/drd.c +++ b/drivers/usb/cdns3/drd.c @@ -279,12 +279,12 @@ static irqreturn_t cdns3_drd_irq(int irq, void *data) u32 reg; if (cdns->dr_mode != USB_DR_MODE_OTG) - return ret; + return IRQ_NONE; reg = readl(&cdns->otg_regs->ivect); if (!reg) - return ret; + return IRQ_NONE; if (reg & OTGIEN_ID_CHANGE_INT) { dev_dbg(cdns->dev, "OTG IRQ: new ID: %d\n", -- cgit v1.2.3-70-g09d2 From 245258495a5157e4428bd944189e4062d852dcdd Mon Sep 17 00:00:00 2001 From: Pawel Laszczak Date: Mon, 13 Jul 2020 12:05:50 +0200 Subject: usb: cdns3: drd: changed return type from int to bool Patch changes return type from int to bool for cdns3_is_host and cdns3_is_device functions. Reviewed-by: Peter Chen Signed-off-by: Pawel Laszczak Signed-off-by: Felipe Balbi --- drivers/usb/cdns3/drd.c | 16 ++++++++-------- drivers/usb/cdns3/drd.h | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/cdns3/drd.c b/drivers/usb/cdns3/drd.c index 05a9f7d54c46..6fe092c828b3 100644 --- a/drivers/usb/cdns3/drd.c +++ b/drivers/usb/cdns3/drd.c @@ -83,25 +83,25 @@ int cdns3_get_vbus(struct cdns3 *cdns) return vbus; } -int cdns3_is_host(struct cdns3 *cdns) +bool cdns3_is_host(struct cdns3 *cdns) { if (cdns->dr_mode == USB_DR_MODE_HOST) - return 1; + return true; else if (!cdns3_get_id(cdns)) - return 1; + return true; - return 0; + return false; } -int cdns3_is_device(struct cdns3 *cdns) +bool cdns3_is_device(struct cdns3 *cdns) { if (cdns->dr_mode == USB_DR_MODE_PERIPHERAL) - return 1; + return true; else if (cdns->dr_mode == USB_DR_MODE_OTG) if (cdns3_get_id(cdns)) - return 1; + return true; - return 0; + return false; } /** diff --git a/drivers/usb/cdns3/drd.h b/drivers/usb/cdns3/drd.h index 04e01c4d2377..35b6d459ee58 100644 --- a/drivers/usb/cdns3/drd.h +++ b/drivers/usb/cdns3/drd.h @@ -153,8 +153,8 @@ struct cdns3_otg_common_regs { /* Only for CDNS3_CONTROLLER_V0 version */ #define OVERRIDE_IDPULLUP_V0 BIT(24) -int cdns3_is_host(struct cdns3 *cdns); -int cdns3_is_device(struct cdns3 *cdns); +bool cdns3_is_host(struct cdns3 *cdns); +bool cdns3_is_device(struct cdns3 *cdns); int cdns3_get_id(struct cdns3 *cdns); int cdns3_get_vbus(struct cdns3 *cdns); int cdns3_drd_init(struct cdns3 *cdns); -- cgit v1.2.3-70-g09d2 From 08c35dd3cc2184dcc952fc845329dcae1ee302d3 Mon Sep 17 00:00:00 2001 From: Pawel Laszczak Date: Mon, 13 Jul 2020 12:05:51 +0200 Subject: usb: cdns3: Added CDNS3_ID_PERIPHERAL and CDNS3_ID_HOST Patch adds 2 definitions that make it easier to understand the code. Reviewed-by: Peter Chen Signed-off-by: Pawel Laszczak Signed-off-by: Felipe Balbi --- drivers/usb/cdns3/drd.c | 4 ++-- drivers/usb/cdns3/drd.h | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/cdns3/drd.c b/drivers/usb/cdns3/drd.c index 6fe092c828b3..8e7673da905e 100644 --- a/drivers/usb/cdns3/drd.c +++ b/drivers/usb/cdns3/drd.c @@ -87,7 +87,7 @@ bool cdns3_is_host(struct cdns3 *cdns) { if (cdns->dr_mode == USB_DR_MODE_HOST) return true; - else if (!cdns3_get_id(cdns)) + else if (cdns3_get_id(cdns) == CDNS3_ID_HOST) return true; return false; @@ -98,7 +98,7 @@ bool cdns3_is_device(struct cdns3 *cdns) if (cdns->dr_mode == USB_DR_MODE_PERIPHERAL) return true; else if (cdns->dr_mode == USB_DR_MODE_OTG) - if (cdns3_get_id(cdns)) + if (cdns3_get_id(cdns) == CDNS3_ID_PERIPHERAL) return true; return false; diff --git a/drivers/usb/cdns3/drd.h b/drivers/usb/cdns3/drd.h index 35b6d459ee58..3889fead9df1 100644 --- a/drivers/usb/cdns3/drd.h +++ b/drivers/usb/cdns3/drd.h @@ -153,6 +153,9 @@ struct cdns3_otg_common_regs { /* Only for CDNS3_CONTROLLER_V0 version */ #define OVERRIDE_IDPULLUP_V0 BIT(24) +#define CDNS3_ID_PERIPHERAL 1 +#define CDNS3_ID_HOST 0 + bool cdns3_is_host(struct cdns3 *cdns); bool cdns3_is_device(struct cdns3 *cdns); int cdns3_get_id(struct cdns3 *cdns); -- cgit v1.2.3-70-g09d2 From 5c2cf30f14cc3973f2d288e33b0153f5d9a357fb Mon Sep 17 00:00:00 2001 From: Pawel Laszczak Date: Mon, 13 Jul 2020 12:05:52 +0200 Subject: usb: cdns3: core: removed 'goto not_otg' Patch removes 'goto not_otg' instruction from cdns3_hw_role_state_machine function. Signed-off-by: Pawel Laszczak Signed-off-by: Felipe Balbi --- drivers/usb/cdns3/core.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/cdns3/core.c b/drivers/usb/cdns3/core.c index c498b585eb13..8e3996f211a8 100644 --- a/drivers/usb/cdns3/core.c +++ b/drivers/usb/cdns3/core.c @@ -191,11 +191,17 @@ err: */ static enum usb_role cdns3_hw_role_state_machine(struct cdns3 *cdns) { - enum usb_role role; + enum usb_role role = USB_ROLE_NONE; int id, vbus; - if (cdns->dr_mode != USB_DR_MODE_OTG) - goto not_otg; + if (cdns->dr_mode != USB_DR_MODE_OTG) { + if (cdns3_is_host(cdns)) + role = USB_ROLE_HOST; + if (cdns3_is_device(cdns)) + role = USB_ROLE_DEVICE; + + return role; + } id = cdns3_get_id(cdns); vbus = cdns3_get_vbus(cdns); @@ -232,14 +238,6 @@ static enum usb_role cdns3_hw_role_state_machine(struct cdns3 *cdns) dev_dbg(cdns->dev, "role %d -> %d\n", cdns->role, role); return role; - -not_otg: - if (cdns3_is_host(cdns)) - role = USB_ROLE_HOST; - if (cdns3_is_device(cdns)) - role = USB_ROLE_DEVICE; - - return role; } static int cdns3_idle_role_start(struct cdns3 *cdns) -- cgit v1.2.3-70-g09d2 From f41ca26b8b178d0b7005c9bfeda88814179203b3 Mon Sep 17 00:00:00 2001 From: Pawel Laszczak Date: Mon, 13 Jul 2020 12:05:53 +0200 Subject: usb: cdns3: core: removed overwriting some error code Some error code can be preserved, so we can remove overwriting error code returned by some functions. Signed-off-by: Pawel Laszczak Reviewed-by: Peter Chen Signed-off-by: Felipe Balbi --- drivers/usb/cdns3/core.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/cdns3/core.c b/drivers/usb/cdns3/core.c index 8e3996f211a8..72885c5edb09 100644 --- a/drivers/usb/cdns3/core.c +++ b/drivers/usb/cdns3/core.c @@ -347,7 +347,6 @@ static int cdns3_role_set(struct usb_role_switch *sw, enum usb_role role) case USB_ROLE_HOST: break; default: - ret = -EPERM; goto pm_put; } } @@ -358,17 +357,14 @@ static int cdns3_role_set(struct usb_role_switch *sw, enum usb_role role) case USB_ROLE_DEVICE: break; default: - ret = -EPERM; goto pm_put; } } cdns3_role_stop(cdns); ret = cdns3_role_start(cdns, role); - if (ret) { + if (ret) dev_err(cdns->dev, "set role %d has failed\n", role); - ret = -EPERM; - } pm_put: pm_runtime_put_sync(cdns->dev); @@ -393,7 +389,7 @@ static int cdns3_probe(struct platform_device *pdev) ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32)); if (ret) { dev_err(dev, "error setting dma mask: %d\n", ret); - return -ENODEV; + return ret; } cdns = devm_kzalloc(dev, sizeof(*cdns), GFP_KERNEL); -- cgit v1.2.3-70-g09d2 From b2aeb6da3d6ee562e57ad3a7d73a7de0c36ce8eb Mon Sep 17 00:00:00 2001 From: Pawel Laszczak Date: Mon, 13 Jul 2020 12:05:54 +0200 Subject: usb: cdns3: drd: simplify *switch_gadet and *switch_host Patch split function cdns3_drd_switch_gadget and cdns3_drd_switch_host into: - cdns3_drd_host_on - cdns3_drd_host_off - cdns3_drd_gadget_on - cdns3_drd_gadgett_off These functions don't have any shared code so it's better to have smaller, faster and easier functions. Signed-off-by: Pawel Laszczak Reviewed-by: Peter Chen Signed-off-by: Felipe Balbi --- drivers/usb/cdns3/drd.c | 124 +++++++++++++++++++++++++-------------------- drivers/usb/cdns3/drd.h | 6 ++- drivers/usb/cdns3/gadget.c | 4 +- drivers/usb/cdns3/host.c | 4 +- 4 files changed, 76 insertions(+), 62 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/cdns3/drd.c b/drivers/usb/cdns3/drd.c index 8e7673da905e..6234bcd6158a 100644 --- a/drivers/usb/cdns3/drd.c +++ b/drivers/usb/cdns3/drd.c @@ -124,85 +124,97 @@ static void cdns3_otg_enable_irq(struct cdns3 *cdns) } /** - * cdns3_drd_switch_host - start/stop host - * @cdns: Pointer to controller context structure - * @on: 1 for start, 0 for stop + * cdns3_drd_host_on - start host. + * @cdns: Pointer to controller context structure. * - * Returns 0 on success otherwise negative errno + * Returns 0 on success otherwise negative errno. */ -int cdns3_drd_switch_host(struct cdns3 *cdns, int on) +int cdns3_drd_host_on(struct cdns3 *cdns) { - int ret, val; + u32 val; + int ret; - /* switch OTG core */ - if (on) { - writel(OTGCMD_HOST_BUS_REQ | OTGCMD_OTG_DIS, - &cdns->otg_regs->cmd); - - dev_dbg(cdns->dev, "Waiting till Host mode is turned on\n"); - ret = readl_poll_timeout_atomic(&cdns->otg_regs->sts, val, - val & OTGSTS_XHCI_READY, - 1, 100000); - if (ret) { - dev_err(cdns->dev, "timeout waiting for xhci_ready\n"); - return ret; - } - } else { - writel(OTGCMD_HOST_BUS_DROP | OTGCMD_DEV_BUS_DROP | - OTGCMD_DEV_POWER_OFF | OTGCMD_HOST_POWER_OFF, - &cdns->otg_regs->cmd); - /* Waiting till H_IDLE state.*/ - readl_poll_timeout_atomic(&cdns->otg_regs->state, val, - !(val & OTGSTATE_HOST_STATE_MASK), - 1, 2000000); - } + /* Enable host mode. */ + writel(OTGCMD_HOST_BUS_REQ | OTGCMD_OTG_DIS, + &cdns->otg_regs->cmd); - return 0; + dev_dbg(cdns->dev, "Waiting till Host mode is turned on\n"); + ret = readl_poll_timeout_atomic(&cdns->otg_regs->sts, val, + val & OTGSTS_XHCI_READY, 1, 100000); + + if (ret) + dev_err(cdns->dev, "timeout waiting for xhci_ready\n"); + + return ret; } /** - * cdns3_drd_switch_gadget - start/stop gadget - * @cdns: Pointer to controller context structure - * @on: 1 for start, 0 for stop + * cdns3_drd_host_off - stop host. + * @cdns: Pointer to controller context structure. + */ +void cdns3_drd_host_off(struct cdns3 *cdns) +{ + u32 val; + + writel(OTGCMD_HOST_BUS_DROP | OTGCMD_DEV_BUS_DROP | + OTGCMD_DEV_POWER_OFF | OTGCMD_HOST_POWER_OFF, + &cdns->otg_regs->cmd); + + /* Waiting till H_IDLE state.*/ + readl_poll_timeout_atomic(&cdns->otg_regs->state, val, + !(val & OTGSTATE_HOST_STATE_MASK), + 1, 2000000); +} + +/** + * cdns3_drd_gadget_on - start gadget. + * @cdns: Pointer to controller context structure. * * Returns 0 on success otherwise negative errno */ -int cdns3_drd_switch_gadget(struct cdns3 *cdns, int on) +int cdns3_drd_gadget_on(struct cdns3 *cdns) { int ret, val; u32 reg = OTGCMD_OTG_DIS; /* switch OTG core */ - if (on) { - writel(OTGCMD_DEV_BUS_REQ | reg, &cdns->otg_regs->cmd); + writel(OTGCMD_DEV_BUS_REQ | reg, &cdns->otg_regs->cmd); - dev_dbg(cdns->dev, "Waiting till Device mode is turned on\n"); + dev_dbg(cdns->dev, "Waiting till Device mode is turned on\n"); - ret = readl_poll_timeout_atomic(&cdns->otg_regs->sts, val, - val & OTGSTS_DEV_READY, - 1, 100000); - if (ret) { - dev_err(cdns->dev, "timeout waiting for dev_ready\n"); - return ret; - } - } else { - /* - * driver should wait at least 10us after disabling Device - * before turning-off Device (DEV_BUS_DROP) - */ - usleep_range(20, 30); - writel(OTGCMD_HOST_BUS_DROP | OTGCMD_DEV_BUS_DROP | - OTGCMD_DEV_POWER_OFF | OTGCMD_HOST_POWER_OFF, - &cdns->otg_regs->cmd); - /* Waiting till DEV_IDLE state.*/ - readl_poll_timeout_atomic(&cdns->otg_regs->state, val, - !(val & OTGSTATE_DEV_STATE_MASK), - 1, 2000000); + ret = readl_poll_timeout_atomic(&cdns->otg_regs->sts, val, + val & OTGSTS_DEV_READY, + 1, 100000); + if (ret) { + dev_err(cdns->dev, "timeout waiting for dev_ready\n"); + return ret; } return 0; } +/** + * cdns3_drd_gadget_off - stop gadget. + * @cdns: Pointer to controller context structure. + */ +void cdns3_drd_gadget_off(struct cdns3 *cdns) +{ + u32 val; + + /* + * Driver should wait at least 10us after disabling Device + * before turning-off Device (DEV_BUS_DROP). + */ + usleep_range(20, 30); + writel(OTGCMD_HOST_BUS_DROP | OTGCMD_DEV_BUS_DROP | + OTGCMD_DEV_POWER_OFF | OTGCMD_HOST_POWER_OFF, + &cdns->otg_regs->cmd); + /* Waiting till DEV_IDLE state.*/ + readl_poll_timeout_atomic(&cdns->otg_regs->state, val, + !(val & OTGSTATE_DEV_STATE_MASK), + 1, 2000000); +} + /** * cdns3_init_otg_mode - initialize drd controller * @cdns: Pointer to controller context structure diff --git a/drivers/usb/cdns3/drd.h b/drivers/usb/cdns3/drd.h index 3889fead9df1..7e7cf7fa2dd3 100644 --- a/drivers/usb/cdns3/drd.h +++ b/drivers/usb/cdns3/drd.h @@ -163,8 +163,10 @@ int cdns3_get_vbus(struct cdns3 *cdns); int cdns3_drd_init(struct cdns3 *cdns); int cdns3_drd_exit(struct cdns3 *cdns); int cdns3_drd_update_mode(struct cdns3 *cdns); -int cdns3_drd_switch_gadget(struct cdns3 *cdns, int on); -int cdns3_drd_switch_host(struct cdns3 *cdns, int on); +int cdns3_drd_gadget_on(struct cdns3 *cdns); +void cdns3_drd_gadget_off(struct cdns3 *cdns); +int cdns3_drd_host_on(struct cdns3 *cdns); +void cdns3_drd_host_off(struct cdns3 *cdns); int cdns3_set_mode(struct cdns3 *cdns, enum usb_dr_mode mode); #endif /* __LINUX_CDNS3_DRD */ diff --git a/drivers/usb/cdns3/gadget.c b/drivers/usb/cdns3/gadget.c index 65a154d47f8e..dea649ee173b 100644 --- a/drivers/usb/cdns3/gadget.c +++ b/drivers/usb/cdns3/gadget.c @@ -3017,7 +3017,7 @@ void cdns3_gadget_exit(struct cdns3 *cdns) kfree(priv_dev->zlp_buf); kfree(priv_dev); cdns->gadget_dev = NULL; - cdns3_drd_switch_gadget(cdns, 0); + cdns3_drd_gadget_off(cdns); } static int cdns3_gadget_start(struct cdns3 *cdns) @@ -3148,7 +3148,7 @@ static int __cdns3_gadget_init(struct cdns3 *cdns) return ret; } - cdns3_drd_switch_gadget(cdns, 1); + cdns3_drd_gadget_on(cdns); pm_runtime_get_sync(cdns->dev); ret = cdns3_gadget_start(cdns); diff --git a/drivers/usb/cdns3/host.c b/drivers/usb/cdns3/host.c index ad788bf3fe4f..36c63d9ecd37 100644 --- a/drivers/usb/cdns3/host.c +++ b/drivers/usb/cdns3/host.c @@ -19,7 +19,7 @@ static int __cdns3_host_init(struct cdns3 *cdns) struct platform_device *xhci; int ret; - cdns3_drd_switch_host(cdns, 1); + cdns3_drd_host_on(cdns); xhci = platform_device_alloc("xhci-hcd", PLATFORM_DEVID_AUTO); if (!xhci) { @@ -53,7 +53,7 @@ static void cdns3_host_exit(struct cdns3 *cdns) { platform_device_unregister(cdns->host_dev); cdns->host_dev = NULL; - cdns3_drd_switch_host(cdns, 0); + cdns3_drd_host_off(cdns); } int cdns3_host_init(struct cdns3 *cdns) -- cgit v1.2.3-70-g09d2 From 2468c877da428ebfd701142c4cdfefcfb7d4c00e Mon Sep 17 00:00:00 2001 From: Evgeny Novikov Date: Tue, 21 Jul 2020 23:15:58 +0300 Subject: usb: gadget: net2280: fix memory leak on probe error handling paths Driver does not release memory for device on error handling paths in net2280_probe() when gadget_release() is not registered yet. The patch fixes the bug like in other similar drivers. Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Evgeny Novikov Signed-off-by: Felipe Balbi --- drivers/usb/gadget/udc/net2280.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'drivers/usb') 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; } -- cgit v1.2.3-70-g09d2 From 6e5478aeb3184cb37035550f82527b27c064eef9 Mon Sep 17 00:00:00 2001 From: "周琰杰 (Zhou Yanjie)" Date: Thu, 23 Jul 2020 14:12:59 +0800 Subject: USB: PHY: JZ4770: Unify code style and simplify code. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1.Modify the macro definition to unify "#define USBPCR_XXXX n" into the "#define USBPCR_XXXX (n << USBPCR_XXXX_LSB)" style, so as to unify the code style in the "jz4770_phy_init()" and simplify the code. 2.Remove unused macro definitions to simplify the code. Tested-by: 周正 (Zhou Zheng) Suggested-by: Paul Cercueil Signed-off-by: 周琰杰 (Zhou Yanjie) Signed-off-by: Felipe Balbi --- drivers/usb/phy/phy-jz4770.c | 34 +++++++++++----------------------- 1 file changed, 11 insertions(+), 23 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/phy/phy-jz4770.c b/drivers/usb/phy/phy-jz4770.c index 8f62dc2a90ff..00209d5469d3 100644 --- a/drivers/usb/phy/phy-jz4770.c +++ b/drivers/usb/phy/phy-jz4770.c @@ -20,8 +20,6 @@ /* USBPCR */ #define USBPCR_USB_MODE BIT(31) #define USBPCR_AVLD_REG BIT(30) -#define USBPCR_INCRM BIT(27) -#define USBPCR_CLK12_EN BIT(26) #define USBPCR_COMMONONN BIT(25) #define USBPCR_VBUSVLDEXT BIT(24) #define USBPCR_VBUSVLDEXTSEL BIT(23) @@ -32,45 +30,39 @@ #define USBPCR_IDPULLUP_LSB 28 #define USBPCR_IDPULLUP_MASK GENMASK(29, USBPCR_IDPULLUP_LSB) -#define USBPCR_IDPULLUP_ALWAYS (3 << USBPCR_IDPULLUP_LSB) -#define USBPCR_IDPULLUP_SUSPEND (1 << USBPCR_IDPULLUP_LSB) -#define USBPCR_IDPULLUP_OTG (0 << USBPCR_IDPULLUP_LSB) +#define USBPCR_IDPULLUP_ALWAYS (0x2 << USBPCR_IDPULLUP_LSB) +#define USBPCR_IDPULLUP_SUSPEND (0x1 << USBPCR_IDPULLUP_LSB) +#define USBPCR_IDPULLUP_OTG (0x0 << USBPCR_IDPULLUP_LSB) #define USBPCR_COMPDISTUNE_LSB 17 #define USBPCR_COMPDISTUNE_MASK GENMASK(19, USBPCR_COMPDISTUNE_LSB) -#define USBPCR_COMPDISTUNE_DFT 4 +#define USBPCR_COMPDISTUNE_DFT (0x4 << USBPCR_COMPDISTUNE_LSB) #define USBPCR_OTGTUNE_LSB 14 #define USBPCR_OTGTUNE_MASK GENMASK(16, USBPCR_OTGTUNE_LSB) -#define USBPCR_OTGTUNE_DFT 4 +#define USBPCR_OTGTUNE_DFT (0x4 << USBPCR_OTGTUNE_LSB) #define USBPCR_SQRXTUNE_LSB 11 #define USBPCR_SQRXTUNE_MASK GENMASK(13, USBPCR_SQRXTUNE_LSB) -#define USBPCR_SQRXTUNE_DFT 3 +#define USBPCR_SQRXTUNE_DFT (0x3 << USBPCR_SQRXTUNE_LSB) #define USBPCR_TXFSLSTUNE_LSB 7 #define USBPCR_TXFSLSTUNE_MASK GENMASK(10, USBPCR_TXFSLSTUNE_LSB) -#define USBPCR_TXFSLSTUNE_DFT 3 +#define USBPCR_TXFSLSTUNE_DFT (0x3 << USBPCR_TXFSLSTUNE_LSB) #define USBPCR_TXRISETUNE_LSB 4 #define USBPCR_TXRISETUNE_MASK GENMASK(5, USBPCR_TXRISETUNE_LSB) -#define USBPCR_TXRISETUNE_DFT 3 +#define USBPCR_TXRISETUNE_DFT (0x3 << USBPCR_TXRISETUNE_LSB) #define USBPCR_TXVREFTUNE_LSB 0 #define USBPCR_TXVREFTUNE_MASK GENMASK(3, USBPCR_TXVREFTUNE_LSB) -#define USBPCR_TXVREFTUNE_DFT 5 +#define USBPCR_TXVREFTUNE_DFT (0x5 << USBPCR_TXVREFTUNE_LSB) /* USBRDT */ #define USBRDT_VBFIL_LD_EN BIT(25) #define USBRDT_IDDIG_EN BIT(24) #define USBRDT_IDDIG_REG BIT(23) -#define USBRDT_USBRDT_LSB 0 -#define USBRDT_USBRDT_MASK GENMASK(22, USBRDT_USBRDT_LSB) - -/* USBPCR1 */ -#define USBPCR1_UHC_POWON BIT(5) - struct jz4770_phy { struct usb_phy phy; struct usb_otg otg; @@ -136,12 +128,8 @@ static int jz4770_phy_init(struct usb_phy *phy) } reg = USBPCR_AVLD_REG | USBPCR_COMMONONN | USBPCR_IDPULLUP_ALWAYS | - (USBPCR_COMPDISTUNE_DFT << USBPCR_COMPDISTUNE_LSB) | - (USBPCR_OTGTUNE_DFT << USBPCR_OTGTUNE_LSB) | - (USBPCR_SQRXTUNE_DFT << USBPCR_SQRXTUNE_LSB) | - (USBPCR_TXFSLSTUNE_DFT << USBPCR_TXFSLSTUNE_LSB) | - (USBPCR_TXRISETUNE_DFT << USBPCR_TXRISETUNE_LSB) | - (USBPCR_TXVREFTUNE_DFT << USBPCR_TXVREFTUNE_LSB) | + USBPCR_COMPDISTUNE_DFT | USBPCR_OTGTUNE_DFT | USBPCR_SQRXTUNE_DFT | + USBPCR_TXFSLSTUNE_DFT | USBPCR_TXRISETUNE_DFT | USBPCR_TXVREFTUNE_DFT | USBPCR_POR; writel(reg, priv->base + REG_USBPCR_OFFSET); -- cgit v1.2.3-70-g09d2 From 2a6c0b82e65128c73b5102e00e031c5e58bb3504 Mon Sep 17 00:00:00 2001 From: "周琰杰 (Zhou Yanjie)" Date: Thu, 23 Jul 2020 14:13:00 +0800 Subject: USB: PHY: JZ4770: Add support for new Ingenic SoCs. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add support for probing the phy-jz4770 driver on the JZ4780 SoC, the X1000 SoC and the X1830 SoC from Ingenic. Tested-by: 周正 (Zhou Zheng) Co-developed-by: 漆鹏振 (Qi Pengzhen) Signed-off-by: 漆鹏振 (Qi Pengzhen) Signed-off-by: 周琰杰 (Zhou Yanjie) Signed-off-by: Felipe Balbi --- drivers/usb/phy/Kconfig | 4 +- drivers/usb/phy/phy-jz4770.c | 192 ++++++++++++++++++++++++++++++++++++------- 2 files changed, 163 insertions(+), 33 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig index 4b3fa78995cf..ef4787cd3d37 100644 --- a/drivers/usb/phy/Kconfig +++ b/drivers/usb/phy/Kconfig @@ -185,11 +185,11 @@ config USB_ULPI_VIEWPORT controllers with a viewport register (e.g. Chipidea/ARC controllers). config JZ4770_PHY - tristate "Ingenic JZ4770 Transceiver Driver" + tristate "Ingenic SoCs Transceiver Driver" depends on MIPS || COMPILE_TEST select USB_PHY help This driver provides PHY support for the USB controller found - on the JZ4770 SoC from Ingenic. + on the JZ-series and X-series SoCs from Ingenic. endmenu diff --git a/drivers/usb/phy/phy-jz4770.c b/drivers/usb/phy/phy-jz4770.c index 00209d5469d3..5ddf48f9085a 100644 --- a/drivers/usb/phy/phy-jz4770.c +++ b/drivers/usb/phy/phy-jz4770.c @@ -1,7 +1,9 @@ // SPDX-License-Identifier: GPL-2.0 /* - * Ingenic JZ4770 USB PHY driver + * Ingenic SoCs USB PHY driver * Copyright (c) Paul Cercueil + * Copyright (c) 漆鹏振 (Qi Pengzhen) + * Copyright (c) 周琰杰 (Zhou Yanjie) */ #include @@ -12,12 +14,13 @@ #include #include +/* OTGPHY register offsets */ #define REG_USBPCR_OFFSET 0x00 #define REG_USBRDT_OFFSET 0x04 #define REG_USBVBFIL_OFFSET 0x08 #define REG_USBPCR1_OFFSET 0x0c -/* USBPCR */ +/* bits within the USBPCR register */ #define USBPCR_USB_MODE BIT(31) #define USBPCR_AVLD_REG BIT(30) #define USBPCR_COMMONONN BIT(25) @@ -44,11 +47,21 @@ #define USBPCR_SQRXTUNE_LSB 11 #define USBPCR_SQRXTUNE_MASK GENMASK(13, USBPCR_SQRXTUNE_LSB) +#define USBPCR_SQRXTUNE_DCR_20PCT (0x7 << USBPCR_SQRXTUNE_LSB) #define USBPCR_SQRXTUNE_DFT (0x3 << USBPCR_SQRXTUNE_LSB) #define USBPCR_TXFSLSTUNE_LSB 7 #define USBPCR_TXFSLSTUNE_MASK GENMASK(10, USBPCR_TXFSLSTUNE_LSB) +#define USBPCR_TXFSLSTUNE_DCR_50PPT (0xf << USBPCR_TXFSLSTUNE_LSB) +#define USBPCR_TXFSLSTUNE_DCR_25PPT (0x7 << USBPCR_TXFSLSTUNE_LSB) #define USBPCR_TXFSLSTUNE_DFT (0x3 << USBPCR_TXFSLSTUNE_LSB) +#define USBPCR_TXFSLSTUNE_INC_25PPT (0x1 << USBPCR_TXFSLSTUNE_LSB) +#define USBPCR_TXFSLSTUNE_INC_50PPT (0x0 << USBPCR_TXFSLSTUNE_LSB) + +#define USBPCR_TXHSXVTUNE_LSB 4 +#define USBPCR_TXHSXVTUNE_MASK GENMASK(5, USBPCR_TXHSXVTUNE_LSB) +#define USBPCR_TXHSXVTUNE_DFT (0x3 << USBPCR_TXHSXVTUNE_LSB) +#define USBPCR_TXHSXVTUNE_DCR_15MV (0x1 << USBPCR_TXHSXVTUNE_LSB) #define USBPCR_TXRISETUNE_LSB 4 #define USBPCR_TXRISETUNE_MASK GENMASK(5, USBPCR_TXRISETUNE_LSB) @@ -56,14 +69,40 @@ #define USBPCR_TXVREFTUNE_LSB 0 #define USBPCR_TXVREFTUNE_MASK GENMASK(3, USBPCR_TXVREFTUNE_LSB) +#define USBPCR_TXVREFTUNE_INC_25PPT (0x7 << USBPCR_TXVREFTUNE_LSB) #define USBPCR_TXVREFTUNE_DFT (0x5 << USBPCR_TXVREFTUNE_LSB) -/* USBRDT */ +/* bits within the USBRDTR register */ +#define USBRDT_UTMI_RST BIT(27) +#define USBRDT_HB_MASK BIT(26) #define USBRDT_VBFIL_LD_EN BIT(25) #define USBRDT_IDDIG_EN BIT(24) #define USBRDT_IDDIG_REG BIT(23) +#define USBRDT_VBFIL_EN BIT(2) + +/* bits within the USBPCR1 register */ +#define USBPCR1_BVLD_REG BIT(31) +#define USBPCR1_DPPD BIT(29) +#define USBPCR1_DMPD BIT(28) +#define USBPCR1_USB_SEL BIT(28) +#define USBPCR1_WORD_IF_16BIT BIT(19) + +enum ingenic_usb_phy_version { + ID_JZ4770, + ID_JZ4780, + ID_X1000, + ID_X1830, +}; + +struct ingenic_soc_info { + enum ingenic_usb_phy_version version; + + void (*usb_phy_init)(struct usb_phy *phy); +}; struct jz4770_phy { + const struct ingenic_soc_info *soc_info; + struct usb_phy phy; struct usb_otg otg; struct device *dev; @@ -82,12 +121,18 @@ static inline struct jz4770_phy *phy_to_jz4770_phy(struct usb_phy *phy) return container_of(phy, struct jz4770_phy, phy); } -static int jz4770_phy_set_peripheral(struct usb_otg *otg, +static int ingenic_usb_phy_set_peripheral(struct usb_otg *otg, struct usb_gadget *gadget) { struct jz4770_phy *priv = otg_to_jz4770_phy(otg); u32 reg; + if (priv->soc_info->version >= ID_X1000) { + reg = readl(priv->base + REG_USBPCR1_OFFSET); + reg |= USBPCR1_BVLD_REG; + writel(reg, priv->base + REG_USBPCR1_OFFSET); + } + reg = readl(priv->base + REG_USBPCR_OFFSET); reg &= ~USBPCR_USB_MODE; reg |= USBPCR_VBUSVLDEXT | USBPCR_VBUSVLDEXTSEL | USBPCR_OTG_DISABLE; @@ -96,7 +141,7 @@ static int jz4770_phy_set_peripheral(struct usb_otg *otg, return 0; } -static int jz4770_phy_set_host(struct usb_otg *otg, struct usb_bus *host) +static int ingenic_usb_phy_set_host(struct usb_otg *otg, struct usb_bus *host) { struct jz4770_phy *priv = otg_to_jz4770_phy(otg); u32 reg; @@ -109,7 +154,7 @@ static int jz4770_phy_set_host(struct usb_otg *otg, struct usb_bus *host) return 0; } -static int jz4770_phy_init(struct usb_phy *phy) +static int ingenic_usb_phy_init(struct usb_phy *phy) { struct jz4770_phy *priv = phy_to_jz4770_phy(phy); int err; @@ -127,11 +172,7 @@ static int jz4770_phy_init(struct usb_phy *phy) return err; } - reg = USBPCR_AVLD_REG | USBPCR_COMMONONN | USBPCR_IDPULLUP_ALWAYS | - USBPCR_COMPDISTUNE_DFT | USBPCR_OTGTUNE_DFT | USBPCR_SQRXTUNE_DFT | - USBPCR_TXFSLSTUNE_DFT | USBPCR_TXRISETUNE_DFT | USBPCR_TXVREFTUNE_DFT | - USBPCR_POR; - writel(reg, priv->base + REG_USBPCR_OFFSET); + priv->soc_info->usb_phy_init(phy); /* Wait for PHY to reset */ usleep_range(30, 300); @@ -141,7 +182,7 @@ static int jz4770_phy_init(struct usb_phy *phy) return 0; } -static void jz4770_phy_shutdown(struct usb_phy *phy) +static void ingenic_usb_phy_shutdown(struct usb_phy *phy) { struct jz4770_phy *priv = phy_to_jz4770_phy(phy); @@ -149,11 +190,100 @@ static void jz4770_phy_shutdown(struct usb_phy *phy) regulator_disable(priv->vcc_supply); } -static void jz4770_phy_remove(void *phy) +static void ingenic_usb_phy_remove(void *phy) { usb_remove_phy(phy); } +static void jz4770_usb_phy_init(struct usb_phy *phy) +{ + struct jz4770_phy *priv = phy_to_jz4770_phy(phy); + u32 reg; + + reg = USBPCR_AVLD_REG | USBPCR_COMMONONN | USBPCR_IDPULLUP_ALWAYS | + USBPCR_COMPDISTUNE_DFT | USBPCR_OTGTUNE_DFT | USBPCR_SQRXTUNE_DFT | + USBPCR_TXFSLSTUNE_DFT | USBPCR_TXRISETUNE_DFT | USBPCR_TXVREFTUNE_DFT | + USBPCR_POR; + writel(reg, priv->base + REG_USBPCR_OFFSET); +} + +static void jz4780_usb_phy_init(struct usb_phy *phy) +{ + struct jz4770_phy *priv = phy_to_jz4770_phy(phy); + u32 reg; + + reg = readl(priv->base + REG_USBPCR1_OFFSET) | USBPCR1_USB_SEL | + USBPCR1_WORD_IF_16BIT; + writel(reg, priv->base + REG_USBPCR1_OFFSET); + + reg = USBPCR_TXPREEMPHTUNE | USBPCR_COMMONONN | USBPCR_POR; + writel(reg, priv->base + REG_USBPCR_OFFSET); +} + +static void x1000_usb_phy_init(struct usb_phy *phy) +{ + struct jz4770_phy *priv = phy_to_jz4770_phy(phy); + u32 reg; + + reg = readl(priv->base + REG_USBPCR1_OFFSET) | USBPCR1_WORD_IF_16BIT; + writel(reg, priv->base + REG_USBPCR1_OFFSET); + + reg = USBPCR_SQRXTUNE_DCR_20PCT | USBPCR_TXPREEMPHTUNE | + USBPCR_TXHSXVTUNE_DCR_15MV | USBPCR_TXVREFTUNE_INC_25PPT | + USBPCR_COMMONONN | USBPCR_POR; + writel(reg, priv->base + REG_USBPCR_OFFSET); +} + +static void x1830_usb_phy_init(struct usb_phy *phy) +{ + struct jz4770_phy *priv = phy_to_jz4770_phy(phy); + u32 reg; + + /* rdt */ + writel(USBRDT_VBFIL_EN | USBRDT_UTMI_RST, priv->base + REG_USBRDT_OFFSET); + + reg = readl(priv->base + REG_USBPCR1_OFFSET) | USBPCR1_WORD_IF_16BIT | + USBPCR1_DMPD | USBPCR1_DPPD; + writel(reg, priv->base + REG_USBPCR1_OFFSET); + + reg = USBPCR_IDPULLUP_OTG | USBPCR_VBUSVLDEXT | USBPCR_TXPREEMPHTUNE | + USBPCR_COMMONONN | USBPCR_POR; + writel(reg, priv->base + REG_USBPCR_OFFSET); +} + +static const struct ingenic_soc_info jz4770_soc_info = { + .version = ID_JZ4770, + + .usb_phy_init = jz4770_usb_phy_init, +}; + +static const struct ingenic_soc_info jz4780_soc_info = { + .version = ID_JZ4780, + + .usb_phy_init = jz4780_usb_phy_init, +}; + +static const struct ingenic_soc_info x1000_soc_info = { + .version = ID_X1000, + + .usb_phy_init = x1000_usb_phy_init, +}; + +static const struct ingenic_soc_info x1830_soc_info = { + .version = ID_X1830, + + .usb_phy_init = x1830_usb_phy_init, +}; + +static const struct of_device_id ingenic_usb_phy_of_matches[] = { + { .compatible = "ingenic,jz4770-phy", .data = &jz4770_soc_info }, + { .compatible = "ingenic,jz4780-phy", .data = &jz4780_soc_info }, + { .compatible = "ingenic,x1000-phy", .data = &x1000_soc_info }, + { .compatible = "ingenic,x1830-phy", .data = &x1830_soc_info }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(of, ingenic_usb_phy_of_matches); + static int jz4770_phy_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -164,18 +294,24 @@ static int jz4770_phy_probe(struct platform_device *pdev) if (!priv) return -ENOMEM; + priv->soc_info = device_get_match_data(&pdev->dev); + if (!priv->soc_info) { + dev_err(&pdev->dev, "Error: No device match found\n"); + return -ENODEV; + } + platform_set_drvdata(pdev, priv); priv->dev = dev; priv->phy.dev = dev; priv->phy.otg = &priv->otg; - priv->phy.label = "jz4770-phy"; - priv->phy.init = jz4770_phy_init; - priv->phy.shutdown = jz4770_phy_shutdown; + priv->phy.label = "ingenic-usb-phy"; + priv->phy.init = ingenic_usb_phy_init; + priv->phy.shutdown = ingenic_usb_phy_shutdown; priv->otg.state = OTG_STATE_UNDEFINED; priv->otg.usb_phy = &priv->phy; - priv->otg.set_host = jz4770_phy_set_host; - priv->otg.set_peripheral = jz4770_phy_set_peripheral; + priv->otg.set_host = ingenic_usb_phy_set_host; + priv->otg.set_peripheral = ingenic_usb_phy_set_peripheral; priv->base = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(priv->base)) { @@ -206,26 +342,20 @@ static int jz4770_phy_probe(struct platform_device *pdev) return err; } - return devm_add_action_or_reset(dev, jz4770_phy_remove, &priv->phy); + return devm_add_action_or_reset(dev, ingenic_usb_phy_remove, &priv->phy); } -#ifdef CONFIG_OF -static const struct of_device_id jz4770_phy_of_matches[] = { - { .compatible = "ingenic,jz4770-phy" }, - { } -}; -MODULE_DEVICE_TABLE(of, jz4770_phy_of_matches); -#endif - -static struct platform_driver jz4770_phy_driver = { +static struct platform_driver ingenic_phy_driver = { .probe = jz4770_phy_probe, .driver = { .name = "jz4770-phy", - .of_match_table = of_match_ptr(jz4770_phy_of_matches), + .of_match_table = of_match_ptr(ingenic_usb_phy_of_matches), }, }; -module_platform_driver(jz4770_phy_driver); +module_platform_driver(ingenic_phy_driver); +MODULE_AUTHOR("周琰杰 (Zhou Yanjie) "); +MODULE_AUTHOR("漆鹏振 (Qi Pengzhen) "); MODULE_AUTHOR("Paul Cercueil "); -MODULE_DESCRIPTION("Ingenic JZ4770 USB PHY driver"); +MODULE_DESCRIPTION("Ingenic SoCs USB PHY driver"); MODULE_LICENSE("GPL"); -- cgit v1.2.3-70-g09d2 From f7e764cba28e49fd22dbe106e819ae592780feb8 Mon Sep 17 00:00:00 2001 From: "周琰杰 (Zhou Yanjie)" Date: Thu, 23 Jul 2020 14:13:01 +0800 Subject: USB: PHY: JZ4770: Reformat the code to align it. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reformat the code (add one level of indentation before the values), to align the code in the macro definition section. Tested-by: 周正 (Zhou Zheng) Co-developed-by: 漆鹏振 (Qi Pengzhen) Signed-off-by: 漆鹏振 (Qi Pengzhen) Signed-off-by: 周琰杰 (Zhou Yanjie) Signed-off-by: Felipe Balbi --- drivers/usb/phy/phy-jz4770.c | 74 ++++++++++++++++++++++---------------------- 1 file changed, 37 insertions(+), 37 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/phy/phy-jz4770.c b/drivers/usb/phy/phy-jz4770.c index 5ddf48f9085a..d4ee3cb721ea 100644 --- a/drivers/usb/phy/phy-jz4770.c +++ b/drivers/usb/phy/phy-jz4770.c @@ -15,46 +15,46 @@ #include /* OTGPHY register offsets */ -#define REG_USBPCR_OFFSET 0x00 -#define REG_USBRDT_OFFSET 0x04 -#define REG_USBVBFIL_OFFSET 0x08 -#define REG_USBPCR1_OFFSET 0x0c +#define REG_USBPCR_OFFSET 0x00 +#define REG_USBRDT_OFFSET 0x04 +#define REG_USBVBFIL_OFFSET 0x08 +#define REG_USBPCR1_OFFSET 0x0c /* bits within the USBPCR register */ -#define USBPCR_USB_MODE BIT(31) -#define USBPCR_AVLD_REG BIT(30) -#define USBPCR_COMMONONN BIT(25) -#define USBPCR_VBUSVLDEXT BIT(24) -#define USBPCR_VBUSVLDEXTSEL BIT(23) -#define USBPCR_POR BIT(22) -#define USBPCR_SIDDQ BIT(21) -#define USBPCR_OTG_DISABLE BIT(20) -#define USBPCR_TXPREEMPHTUNE BIT(6) +#define USBPCR_USB_MODE BIT(31) +#define USBPCR_AVLD_REG BIT(30) +#define USBPCR_COMMONONN BIT(25) +#define USBPCR_VBUSVLDEXT BIT(24) +#define USBPCR_VBUSVLDEXTSEL BIT(23) +#define USBPCR_POR BIT(22) +#define USBPCR_SIDDQ BIT(21) +#define USBPCR_OTG_DISABLE BIT(20) +#define USBPCR_TXPREEMPHTUNE BIT(6) #define USBPCR_IDPULLUP_LSB 28 -#define USBPCR_IDPULLUP_MASK GENMASK(29, USBPCR_IDPULLUP_LSB) -#define USBPCR_IDPULLUP_ALWAYS (0x2 << USBPCR_IDPULLUP_LSB) -#define USBPCR_IDPULLUP_SUSPEND (0x1 << USBPCR_IDPULLUP_LSB) -#define USBPCR_IDPULLUP_OTG (0x0 << USBPCR_IDPULLUP_LSB) +#define USBPCR_IDPULLUP_MASK GENMASK(29, USBPCR_IDPULLUP_LSB) +#define USBPCR_IDPULLUP_ALWAYS (0x2 << USBPCR_IDPULLUP_LSB) +#define USBPCR_IDPULLUP_SUSPEND (0x1 << USBPCR_IDPULLUP_LSB) +#define USBPCR_IDPULLUP_OTG (0x0 << USBPCR_IDPULLUP_LSB) -#define USBPCR_COMPDISTUNE_LSB 17 -#define USBPCR_COMPDISTUNE_MASK GENMASK(19, USBPCR_COMPDISTUNE_LSB) -#define USBPCR_COMPDISTUNE_DFT (0x4 << USBPCR_COMPDISTUNE_LSB) +#define USBPCR_COMPDISTUNE_LSB 17 +#define USBPCR_COMPDISTUNE_MASK GENMASK(19, USBPCR_COMPDISTUNE_LSB) +#define USBPCR_COMPDISTUNE_DFT (0x4 << USBPCR_COMPDISTUNE_LSB) -#define USBPCR_OTGTUNE_LSB 14 -#define USBPCR_OTGTUNE_MASK GENMASK(16, USBPCR_OTGTUNE_LSB) -#define USBPCR_OTGTUNE_DFT (0x4 << USBPCR_OTGTUNE_LSB) +#define USBPCR_OTGTUNE_LSB 14 +#define USBPCR_OTGTUNE_MASK GENMASK(16, USBPCR_OTGTUNE_LSB) +#define USBPCR_OTGTUNE_DFT (0x4 << USBPCR_OTGTUNE_LSB) #define USBPCR_SQRXTUNE_LSB 11 -#define USBPCR_SQRXTUNE_MASK GENMASK(13, USBPCR_SQRXTUNE_LSB) +#define USBPCR_SQRXTUNE_MASK GENMASK(13, USBPCR_SQRXTUNE_LSB) #define USBPCR_SQRXTUNE_DCR_20PCT (0x7 << USBPCR_SQRXTUNE_LSB) -#define USBPCR_SQRXTUNE_DFT (0x3 << USBPCR_SQRXTUNE_LSB) +#define USBPCR_SQRXTUNE_DFT (0x3 << USBPCR_SQRXTUNE_LSB) -#define USBPCR_TXFSLSTUNE_LSB 7 -#define USBPCR_TXFSLSTUNE_MASK GENMASK(10, USBPCR_TXFSLSTUNE_LSB) +#define USBPCR_TXFSLSTUNE_LSB 7 +#define USBPCR_TXFSLSTUNE_MASK GENMASK(10, USBPCR_TXFSLSTUNE_LSB) #define USBPCR_TXFSLSTUNE_DCR_50PPT (0xf << USBPCR_TXFSLSTUNE_LSB) #define USBPCR_TXFSLSTUNE_DCR_25PPT (0x7 << USBPCR_TXFSLSTUNE_LSB) -#define USBPCR_TXFSLSTUNE_DFT (0x3 << USBPCR_TXFSLSTUNE_LSB) +#define USBPCR_TXFSLSTUNE_DFT (0x3 << USBPCR_TXFSLSTUNE_LSB) #define USBPCR_TXFSLSTUNE_INC_25PPT (0x1 << USBPCR_TXFSLSTUNE_LSB) #define USBPCR_TXFSLSTUNE_INC_50PPT (0x0 << USBPCR_TXFSLSTUNE_LSB) @@ -63,21 +63,21 @@ #define USBPCR_TXHSXVTUNE_DFT (0x3 << USBPCR_TXHSXVTUNE_LSB) #define USBPCR_TXHSXVTUNE_DCR_15MV (0x1 << USBPCR_TXHSXVTUNE_LSB) -#define USBPCR_TXRISETUNE_LSB 4 -#define USBPCR_TXRISETUNE_MASK GENMASK(5, USBPCR_TXRISETUNE_LSB) -#define USBPCR_TXRISETUNE_DFT (0x3 << USBPCR_TXRISETUNE_LSB) +#define USBPCR_TXRISETUNE_LSB 4 +#define USBPCR_TXRISETUNE_MASK GENMASK(5, USBPCR_TXRISETUNE_LSB) +#define USBPCR_TXRISETUNE_DFT (0x3 << USBPCR_TXRISETUNE_LSB) -#define USBPCR_TXVREFTUNE_LSB 0 -#define USBPCR_TXVREFTUNE_MASK GENMASK(3, USBPCR_TXVREFTUNE_LSB) +#define USBPCR_TXVREFTUNE_LSB 0 +#define USBPCR_TXVREFTUNE_MASK GENMASK(3, USBPCR_TXVREFTUNE_LSB) #define USBPCR_TXVREFTUNE_INC_25PPT (0x7 << USBPCR_TXVREFTUNE_LSB) -#define USBPCR_TXVREFTUNE_DFT (0x5 << USBPCR_TXVREFTUNE_LSB) +#define USBPCR_TXVREFTUNE_DFT (0x5 << USBPCR_TXVREFTUNE_LSB) /* bits within the USBRDTR register */ #define USBRDT_UTMI_RST BIT(27) #define USBRDT_HB_MASK BIT(26) -#define USBRDT_VBFIL_LD_EN BIT(25) -#define USBRDT_IDDIG_EN BIT(24) -#define USBRDT_IDDIG_REG BIT(23) +#define USBRDT_VBFIL_LD_EN BIT(25) +#define USBRDT_IDDIG_EN BIT(24) +#define USBRDT_IDDIG_REG BIT(23) #define USBRDT_VBFIL_EN BIT(2) /* bits within the USBPCR1 register */ -- cgit v1.2.3-70-g09d2 From 4e3a765ba03c065e5ee71ea309f1933102af7a33 Mon Sep 17 00:00:00 2001 From: Al Cooper Date: Wed, 22 Jul 2020 13:07:41 -0400 Subject: usb: bdc: Add compatible string for new style USB DT nodes Add compatible string for some newer boards that only have this as their match sting. Remove unused compatible string "brcm,bdc-v0.16". Signed-off-by: Al Cooper Acked-by: Florian Fainelli Signed-off-by: Felipe Balbi --- drivers/usb/gadget/udc/bdc/bdc_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/usb') diff --git a/drivers/usb/gadget/udc/bdc/bdc_core.c b/drivers/usb/gadget/udc/bdc/bdc_core.c index d567e20234f0..27e8f50974bb 100644 --- a/drivers/usb/gadget/udc/bdc/bdc_core.c +++ b/drivers/usb/gadget/udc/bdc/bdc_core.c @@ -625,7 +625,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 */ } }; -- cgit v1.2.3-70-g09d2 From a95bdfd22076497288868c028619bc5995f5cc7f Mon Sep 17 00:00:00 2001 From: Sasi Kumar Date: Wed, 22 Jul 2020 13:07:42 -0400 Subject: bdc: Fix bug causing crash after multiple disconnects Multiple connects/disconnects can cause a crash on the second disconnect. The driver had a problem where it would try to send endpoint commands after it was disconnected which is not allowed by the hardware. The fix is to only allow the endpoint commands when the endpoint is connected. This will also fix issues that showed up when using configfs to create gadgets. Signed-off-by: Sasi Kumar Signed-off-by: Al Cooper Acked-by: Florian Fainelli Signed-off-by: Felipe Balbi --- drivers/usb/gadget/udc/bdc/bdc_core.c | 4 ++++ drivers/usb/gadget/udc/bdc/bdc_ep.c | 16 ++++++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/gadget/udc/bdc/bdc_core.c b/drivers/usb/gadget/udc/bdc/bdc_core.c index 27e8f50974bb..28909d4b8190 100644 --- a/drivers/usb/gadget/udc/bdc/bdc_core.c +++ b/drivers/usb/gadget/udc/bdc/bdc_core.c @@ -278,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; @@ -287,6 +288,9 @@ 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 */ + 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 */ diff --git a/drivers/usb/gadget/udc/bdc/bdc_ep.c b/drivers/usb/gadget/udc/bdc/bdc_ep.c index ba250cf75bef..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; /* @@ -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); -- cgit v1.2.3-70-g09d2 From 33d1c71832b7b7e56ca82b2f19c5df31297657e6 Mon Sep 17 00:00:00 2001 From: Al Cooper Date: Wed, 22 Jul 2020 13:07:43 -0400 Subject: usb: bdc: Adb shows offline after resuming from S2 On Android systems, After temporarily putting device to S2 by short pressing the power button on the remote, the display turns off. Then press the power button to turn the display back up. Adb devices would show the devices is offline. It needs a physical disconnect of the usb cable or power cycle to bring the device back online. The device is operational otherwise. The problem is that during S2 resume, the ADB gadget driver could not link back with the BDC driver because the endpoint flags were cleared. The fix is to clear the endpoint flags for the disconnect case only and not for S2 exit. Signed-off-by: Al Cooper Acked-by: Florian Fainelli Signed-off-by: Felipe Balbi --- drivers/usb/gadget/udc/bdc/bdc_core.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/gadget/udc/bdc/bdc_core.c b/drivers/usb/gadget/udc/bdc/bdc_core.c index 28909d4b8190..d4ec1e37d50a 100644 --- a/drivers/usb/gadget/udc/bdc/bdc_core.c +++ b/drivers/usb/gadget/udc/bdc/bdc_core.c @@ -288,9 +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 */ - for (i = 1; i < bdc->num_eps; ++i) - bdc->bdc_ep_array[i]->flags = 0; + /* + * 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 */ -- cgit v1.2.3-70-g09d2 From b10d33c4f068ebb70a607d644b7ace259127aa18 Mon Sep 17 00:00:00 2001 From: Al Cooper Date: Wed, 22 Jul 2020 13:07:44 -0400 Subject: usb: bdc: driver runs out of buffer descriptors on large ADB transfers Version v1.0.40 of the Android host ADB software increased maximum transfer sizes from 256K to 1M. Since the STB ADB gadget driver requests only 16K at a time, the BDC driver ran out of buffer descriptors (BDs) if the queuing happens faster than the incoming 16K transfers. This issue is fixed by doubling the number of BDs that can be queued so that the entire 1M request can be queued without running out of buffers. Signed-off-by: Al Cooper Acked-by: Florian Fainelli Signed-off-by: Felipe Balbi --- drivers/usb/gadget/udc/bdc/bdc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/usb') 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 -- cgit v1.2.3-70-g09d2 From 5fc453d7de3d0c345812453823a3a56783c5f82c Mon Sep 17 00:00:00 2001 From: Danesh Petigara Date: Wed, 22 Jul 2020 13:07:45 -0400 Subject: usb: bdc: Halt controller on suspend GISB bus error kernel panics have been observed during S2 transition tests on the 7271t platform. The errors are a result of the BDC interrupt handler trying to access BDC register space after the system's suspend callbacks have completed. Adding a suspend hook to the BDC driver that halts the controller before S2 entry thus preventing unwanted access to the BDC register space during this transition. Signed-off-by: Danesh Petigara Signed-off-by: Al Cooper Acked-by: Florian Fainelli Signed-off-by: Felipe Balbi --- drivers/usb/gadget/udc/bdc/bdc_core.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/gadget/udc/bdc/bdc_core.c b/drivers/usb/gadget/udc/bdc/bdc_core.c index d4ec1e37d50a..0f1617e34f38 100644 --- a/drivers/usb/gadget/udc/bdc/bdc_core.c +++ b/drivers/usb/gadget/udc/bdc/bdc_core.c @@ -603,9 +603,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) -- cgit v1.2.3-70-g09d2 From 1fa645b1c92795b090ea8de314b5cecc22dbfb03 Mon Sep 17 00:00:00 2001 From: Florian Fainelli Date: Wed, 22 Jul 2020 13:07:46 -0400 Subject: usb: bdc: Use devm_clk_get_optional() The BDC clock is optional and we may get an -EPROBE_DEFER error code which would not be propagated correctly, fix this by using devm_clk_get_optional(). Signed-off-by: Florian Fainelli Signed-off-by: Al Cooper Signed-off-by: Felipe Balbi --- drivers/usb/gadget/udc/bdc/bdc_core.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/gadget/udc/bdc/bdc_core.c b/drivers/usb/gadget/udc/bdc/bdc_core.c index 0f1617e34f38..5ff36525044e 100644 --- a/drivers/usb/gadget/udc/bdc/bdc_core.c +++ b/drivers/usb/gadget/udc/bdc/bdc_core.c @@ -493,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) { -- cgit v1.2.3-70-g09d2 From a9cf8715180b18c62addbfe6f6267b8101903119 Mon Sep 17 00:00:00 2001 From: Ruslan Bilovol Date: Fri, 3 Jul 2020 16:49:03 +0300 Subject: usb: gadget: f_uac2: fix AC Interface Header Descriptor wTotalLength As per UAC2 spec (ch. 4.7.2), wTotalLength of AC Interface Header Descriptor "includes the combined length of this descriptor header and all Clock Source, Unit and Terminal descriptors." Thus add its size to its wTotalLength. Also after recent changes wTotalLength is calculated dynamically, update static definition of uac2_ac_header_descriptor accordingly Fixes: 132fcb460839 ("usb: gadget: Add Audio Class 2.0 Driver") Signed-off-by: Ruslan Bilovol Signed-off-by: Felipe Balbi --- drivers/usb/gadget/function/f_uac2.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/gadget/function/f_uac2.c b/drivers/usb/gadget/function/f_uac2.c index db2d4980cb35..3633df6d7610 100644 --- a/drivers/usb/gadget/function/f_uac2.c +++ b/drivers/usb/gadget/function/f_uac2.c @@ -215,10 +215,7 @@ static struct uac2_ac_header_descriptor ac_hdr_desc = { .bDescriptorSubtype = UAC_MS_HEADER, .bcdADC = cpu_to_le16(0x200), .bCategory = UAC2_FUNCTION_IO_BOX, - .wTotalLength = cpu_to_le16(sizeof in_clk_src_desc - + sizeof out_clk_src_desc + sizeof usb_out_it_desc - + sizeof io_in_it_desc + sizeof usb_in_ot_desc - + sizeof io_out_ot_desc), + /* .wTotalLength = DYNAMIC */ .bmControls = 0, }; @@ -501,7 +498,7 @@ static void setup_descriptor(struct f_uac2_opts *opts) as_in_hdr_desc.bTerminalLink = usb_in_ot_desc.bTerminalID; iad_desc.bInterfaceCount = 1; - ac_hdr_desc.wTotalLength = 0; + ac_hdr_desc.wTotalLength = cpu_to_le16(sizeof(ac_hdr_desc)); if (EPIN_EN(opts)) { u16 len = le16_to_cpu(ac_hdr_desc.wTotalLength); -- cgit v1.2.3-70-g09d2 From 7f2ca14d2f9b99e1579c8148dbabf92374ffc69a Mon Sep 17 00:00:00 2001 From: Zqiang Date: Tue, 30 Jun 2020 13:23:31 +0800 Subject: usb: gadget: function: printer: Interface is disabled and returns error After the device is disconnected from the host side, the interface of the device is reset. If the userspace operates the device again, an error code should be returned. Signed-off-by: Zqiang Signed-off-by: Felipe Balbi --- drivers/usb/gadget/function/f_printer.c | 36 +++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'drivers/usb') diff --git a/drivers/usb/gadget/function/f_printer.c b/drivers/usb/gadget/function/f_printer.c index ec15f7637e40..68697f596066 100644 --- a/drivers/usb/gadget/function/f_printer.c +++ b/drivers/usb/gadget/function/f_printer.c @@ -338,6 +338,11 @@ printer_open(struct inode *inode, struct file *fd) spin_lock_irqsave(&dev->lock, flags); + if (dev->interface < 0) { + spin_unlock_irqrestore(&dev->lock, flags); + return -ENODEV; + } + if (!dev->printer_cdev_open) { dev->printer_cdev_open = 1; fd->private_data = dev; @@ -430,6 +435,12 @@ printer_read(struct file *fd, char __user *buf, size_t len, loff_t *ptr) mutex_lock(&dev->lock_printer_io); spin_lock_irqsave(&dev->lock, flags); + if (dev->interface < 0) { + spin_unlock_irqrestore(&dev->lock, flags); + mutex_unlock(&dev->lock_printer_io); + return -ENODEV; + } + /* We will use this flag later to check if a printer reset happened * after we turn interrupts back on. */ @@ -561,6 +572,12 @@ printer_write(struct file *fd, const char __user *buf, size_t len, loff_t *ptr) mutex_lock(&dev->lock_printer_io); spin_lock_irqsave(&dev->lock, flags); + if (dev->interface < 0) { + spin_unlock_irqrestore(&dev->lock, flags); + mutex_unlock(&dev->lock_printer_io); + return -ENODEV; + } + /* Check if a printer reset happens while we have interrupts on */ dev->reset_printer = 0; @@ -667,6 +684,13 @@ printer_fsync(struct file *fd, loff_t start, loff_t end, int datasync) inode_lock(inode); spin_lock_irqsave(&dev->lock, flags); + + if (dev->interface < 0) { + spin_unlock_irqrestore(&dev->lock, flags); + inode_unlock(inode); + return -ENODEV; + } + tx_list_empty = (likely(list_empty(&dev->tx_reqs))); spin_unlock_irqrestore(&dev->lock, flags); @@ -689,6 +713,13 @@ printer_poll(struct file *fd, poll_table *wait) mutex_lock(&dev->lock_printer_io); spin_lock_irqsave(&dev->lock, flags); + + if (dev->interface < 0) { + spin_unlock_irqrestore(&dev->lock, flags); + mutex_unlock(&dev->lock_printer_io); + return EPOLLERR | EPOLLHUP; + } + setup_rx_reqs(dev); spin_unlock_irqrestore(&dev->lock, flags); mutex_unlock(&dev->lock_printer_io); @@ -722,6 +753,11 @@ printer_ioctl(struct file *fd, unsigned int code, unsigned long arg) spin_lock_irqsave(&dev->lock, flags); + if (dev->interface < 0) { + spin_unlock_irqrestore(&dev->lock, flags); + return -ENODEV; + } + switch (code) { case GADGET_GET_PRINTER_STATUS: status = (int)dev->printer_status; -- cgit v1.2.3-70-g09d2 From ca14378560db5440893404a639d69846f46eb70e Mon Sep 17 00:00:00 2001 From: Michael Grzeschik Date: Wed, 1 Jul 2020 20:24:51 +0200 Subject: usb: dwc3: gadget: add frame number mask This patch adds a define DWC3_FRNUMBER_MASK for the commonly used 0x3fff mask and uses it. Signed-off-by: Michael Grzeschik Signed-off-by: Felipe Balbi --- drivers/usb/dwc3/gadget.c | 4 ++-- drivers/usb/dwc3/gadget.h | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index 3ab6f118c508..ca27907667a3 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -1403,7 +1403,7 @@ static int dwc3_gadget_start_isoc_quirk(struct dwc3_ep *dep) * Check if we can start isoc transfer on the next interval or * 4 uframes in the future with BIT[15:14] as dep->combo_num */ - test_frame_number = dep->frame_number & 0x3fff; + test_frame_number = dep->frame_number & DWC3_FRNUMBER_MASK; test_frame_number |= dep->combo_num << 14; test_frame_number += max_t(u32, 4, dep->interval); @@ -1450,7 +1450,7 @@ static int dwc3_gadget_start_isoc_quirk(struct dwc3_ep *dep) else if (test0 && test1) dep->combo_num = 0; - dep->frame_number &= 0x3fff; + dep->frame_number &= DWC3_FRNUMBER_MASK; dep->frame_number |= dep->combo_num << 14; dep->frame_number += max_t(u32, 4, dep->interval); diff --git a/drivers/usb/dwc3/gadget.h b/drivers/usb/dwc3/gadget.h index 42907dd89212..bd85eb7fa9ef 100644 --- a/drivers/usb/dwc3/gadget.h +++ b/drivers/usb/dwc3/gadget.h @@ -54,6 +54,8 @@ struct dwc3; /* U2 Device exit Latency */ #define DWC3_DEFAULT_U2_DEV_EXIT_LAT 0x1FF /* Less then 511 microsec */ +/* Frame/Microframe Number Mask */ +#define DWC3_FRNUMBER_MASK 0x3fff /* -------------------------------------------------------------------------- */ #define to_dwc3_request(r) (container_of(r, struct dwc3_request, request)) -- cgit v1.2.3-70-g09d2 From c5a7092f401535d8a9159be963b0c318393c2a78 Mon Sep 17 00:00:00 2001 From: Michael Olbrich Date: Wed, 1 Jul 2020 20:24:52 +0200 Subject: usb: dwc3: gadget: make starting isoc transfers more robust Currently __dwc3_gadget_start_isoc must be called very shortly after XferNotReady. Otherwise the frame number is outdated and start transfer will fail, even with several retries. DSTS provides the lower 14 bit of the frame number. Use it in combination with the frame number provided by XferNotReady to guess the current frame number. This will succeed unless more than one 14 rollover has happened since XferNotReady. Start transfer might still fail if the frame number is increased immediately after DSTS is read. So retries are still needed. Don't drop the current request if this happens. This way it is not lost and can be used immediately to try again with the next frame number. With this change, __dwc3_gadget_start_isoc is still not successfully in all cases bit it increases the acceptable delay after XferNotReady significantly. Reviewed-by: Thinh Nguyen Signed-off-by: Michael Olbrich Signed-off-by: Michael Tretter Signed-off-by: Michael Grzeschik Signed-off-by: Felipe Balbi --- drivers/usb/dwc3/gadget.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'drivers/usb') diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index ca27907667a3..779b17373929 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -1463,6 +1463,7 @@ static int dwc3_gadget_start_isoc_quirk(struct dwc3_ep *dep) static int __dwc3_gadget_start_isoc(struct dwc3_ep *dep) { + const struct usb_endpoint_descriptor *desc = dep->endpoint.desc; struct dwc3 *dwc = dep->dwc; int ret; int i; @@ -1480,6 +1481,27 @@ static int __dwc3_gadget_start_isoc(struct dwc3_ep *dep) return dwc3_gadget_start_isoc_quirk(dep); } + if (desc->bInterval <= 14 && + dwc->gadget.speed >= USB_SPEED_HIGH) { + u32 frame = __dwc3_gadget_get_frame(dwc); + bool rollover = frame < + (dep->frame_number & DWC3_FRNUMBER_MASK); + + /* + * frame_number is set from XferNotReady and may be already + * out of date. DSTS only provides the lower 14 bit of the + * current frame number. So add the upper two bits of + * frame_number and handle a possible rollover. + * This will provide the correct frame_number unless more than + * rollover has happened since XferNotReady. + */ + + dep->frame_number = (dep->frame_number & ~DWC3_FRNUMBER_MASK) | + frame; + if (rollover) + dep->frame_number += BIT(14); + } + for (i = 0; i < DWC3_ISOC_MAX_RETRIES; i++) { dep->frame_number = DWC3_ALIGN_FRAME(dep, i + 1); -- cgit v1.2.3-70-g09d2 From f5e46aa4a124bfac34a770c4cfe5023de99380d4 Mon Sep 17 00:00:00 2001 From: Michael Grzeschik Date: Wed, 1 Jul 2020 20:24:53 +0200 Subject: usb: dwc3: gadget: when the started list is empty stop the active xfer When we have nothing left to be queued after handling the last trb we have to stop the current transfer. This way we can ensure that the next request will be queued with a new and valid timestamp and will not directly run into an missed xfer. Reviewed-by: Thinh Nguyen Signed-off-by: Michael Grzeschik Signed-off-by: Felipe Balbi --- drivers/usb/dwc3/gadget.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'drivers/usb') diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index 779b17373929..e44bfc3b5096 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -2738,7 +2738,9 @@ static bool dwc3_gadget_endpoint_trbs_complete(struct dwc3_ep *dep, if (dep->flags & DWC3_EP_END_TRANSFER_PENDING) goto out; - if (status == -EXDEV && list_empty(&dep->started_list)) + if (usb_endpoint_xfer_isoc(dep->endpoint.desc) && + list_empty(&dep->started_list) && + (list_empty(&dep->pending_list) || status == -EXDEV)) dwc3_stop_active_transfer(dep, true, true); else if (dwc3_gadget_ep_should_continue(dep)) if (__dwc3_gadget_kick_transfer(dep) == 0) -- cgit v1.2.3-70-g09d2 From 17a82716587e9d7c3b246a789add490b2b5dcab6 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Sun, 26 Jul 2020 11:49:39 +0200 Subject: USB: iowarrior: fix up report size handling for some devices In previous patches that added support for new iowarrior devices, the handling of the report size was not done correct. Fix that up and update the copyright date for the driver Reworked from an original patch written by Christoph Jung. Fixes: bab5417f5f01 ("USB: misc: iowarrior: add support for the 100 device") Fixes: 5f6f8da2d7b5 ("USB: misc: iowarrior: add support for the 28 and 28L devices") Fixes: 461d8deb26a7 ("USB: misc: iowarrior: add support for 2 OEMed devices") Cc: stable Reported-by: Christoph Jung Link: https://lore.kernel.org/r/20200726094939.1268978-1-gregkh@linuxfoundation.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/misc/iowarrior.c | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/misc/iowarrior.c b/drivers/usb/misc/iowarrior.c index 4afd1ace3d32..70ec29681526 100644 --- a/drivers/usb/misc/iowarrior.c +++ b/drivers/usb/misc/iowarrior.c @@ -2,8 +2,9 @@ /* * Native support for the I/O-Warrior USB devices * - * Copyright (c) 2003-2005 Code Mercenaries GmbH - * written by Christian Lucht + * Copyright (c) 2003-2005, 2020 Code Mercenaries GmbH + * written by Christian Lucht and + * Christoph Jung * * based on @@ -802,14 +803,28 @@ static int iowarrior_probe(struct usb_interface *interface, /* we have to check the report_size often, so remember it in the endianness suitable for our machine */ dev->report_size = usb_endpoint_maxp(dev->int_in_endpoint); - if ((dev->interface->cur_altsetting->desc.bInterfaceNumber == 0) && - ((dev->product_id == USB_DEVICE_ID_CODEMERCS_IOW56) || - (dev->product_id == USB_DEVICE_ID_CODEMERCS_IOW56AM) || - (dev->product_id == USB_DEVICE_ID_CODEMERCS_IOW28) || - (dev->product_id == USB_DEVICE_ID_CODEMERCS_IOW28L) || - (dev->product_id == USB_DEVICE_ID_CODEMERCS_IOW100))) - /* IOWarrior56 has wMaxPacketSize different from report size */ - dev->report_size = 7; + + /* + * Some devices need the report size to be different than the + * endpoint size. + */ + if (dev->interface->cur_altsetting->desc.bInterfaceNumber == 0) { + switch (dev->product_id) { + case USB_DEVICE_ID_CODEMERCS_IOW56: + case USB_DEVICE_ID_CODEMERCS_IOW56AM: + dev->report_size = 7; + break; + + case USB_DEVICE_ID_CODEMERCS_IOW28: + case USB_DEVICE_ID_CODEMERCS_IOW28L: + dev->report_size = 4; + break; + + case USB_DEVICE_ID_CODEMERCS_IOW100: + dev->report_size = 13; + break; + } + } /* create the urb and buffer for reading */ dev->int_in_urb = usb_alloc_urb(0, GFP_KERNEL); -- cgit v1.2.3-70-g09d2 From 09df709cb5aeb2b648576f4b089d3fb869311e28 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 27 Jul 2020 15:33:12 +0200 Subject: Revert "usb: dwc2: don't use ID/Vbus detection if usb-role-switch on STM32MP15 SoCs" This reverts commit 916f8b627288039d9e771a9b2ab1b3c79b303039. This was not meant to be applied as-is at the moment. Cc: Minas Harutyunyan Cc: Amelie Delaunay Cc: Felipe Balbi Signed-off-by: Greg Kroah-Hartman --- drivers/usb/dwc2/params.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/dwc2/params.c b/drivers/usb/dwc2/params.c index bd792c9cdef9..8f9d061c4d5f 100644 --- a/drivers/usb/dwc2/params.c +++ b/drivers/usb/dwc2/params.c @@ -183,11 +183,9 @@ static void dwc2_set_stm32mp15_fsotg_params(struct dwc2_hsotg *hsotg) static void dwc2_set_stm32mp15_hsotg_params(struct dwc2_hsotg *hsotg) { struct dwc2_core_params *p = &hsotg->params; - struct device_node *np = hsotg->dev->of_node; p->otg_cap = DWC2_CAP_PARAM_NO_HNP_SRP_CAPABLE; - p->activate_stm_id_vb_detection = - !of_property_read_bool(np, "usb-role-switch"); + p->activate_stm_id_vb_detection = true; p->host_rx_fifo_size = 440; p->host_nperio_tx_fifo_size = 256; p->host_perio_tx_fifo_size = 256; -- cgit v1.2.3-70-g09d2 From ca6377900974c3e22c379c48057aac51139d29fc Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 27 Jul 2020 15:34:15 +0200 Subject: Revert "usb: dwc2: override PHY input signals with usb role switch support" This reverts commit bc0f0d4a5853e32ba97a0318f774570428fc5634. It was not meant to be applied yet. Cc: Minas Harutyunyan Cc: Amelie Delaunay Cc: Felipe Balbi Signed-off-by: Greg Kroah-Hartman --- drivers/usb/dwc2/Kconfig | 1 - drivers/usb/dwc2/Makefile | 2 +- drivers/usb/dwc2/core.h | 8 -- drivers/usb/dwc2/drd.c | 190 -------------------------------------------- drivers/usb/dwc2/gadget.c | 2 +- drivers/usb/dwc2/platform.c | 13 --- 6 files changed, 2 insertions(+), 214 deletions(-) delete mode 100644 drivers/usb/dwc2/drd.c (limited to 'drivers/usb') diff --git a/drivers/usb/dwc2/Kconfig b/drivers/usb/dwc2/Kconfig index dceb8f32414e..16e1aa304edc 100644 --- a/drivers/usb/dwc2/Kconfig +++ b/drivers/usb/dwc2/Kconfig @@ -47,7 +47,6 @@ config USB_DWC2_PERIPHERAL config USB_DWC2_DUAL_ROLE bool "Dual Role mode" depends on (USB=y && USB_GADGET=y) || (USB_DWC2=m && USB && USB_GADGET) - select USB_ROLE_SWITCH help Select this option if you want the driver to work in a dual-role mode. In this mode both host and gadget features are enabled, and diff --git a/drivers/usb/dwc2/Makefile b/drivers/usb/dwc2/Makefile index 2bcd6945df46..440320cc20a4 100644 --- a/drivers/usb/dwc2/Makefile +++ b/drivers/usb/dwc2/Makefile @@ -3,7 +3,7 @@ ccflags-$(CONFIG_USB_DWC2_DEBUG) += -DDEBUG ccflags-$(CONFIG_USB_DWC2_VERBOSE) += -DVERBOSE_DEBUG obj-$(CONFIG_USB_DWC2) += dwc2.o -dwc2-y := core.o core_intr.o platform.o drd.o +dwc2-y := core.o core_intr.o platform.o dwc2-y += params.o ifneq ($(filter y,$(CONFIG_USB_DWC2_HOST) $(CONFIG_USB_DWC2_DUAL_ROLE)),) diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h index 33e790ccefb3..9deff0400a92 100644 --- a/drivers/usb/dwc2/core.h +++ b/drivers/usb/dwc2/core.h @@ -860,7 +860,6 @@ struct dwc2_hregs_backup { * - USB_DR_MODE_PERIPHERAL * - USB_DR_MODE_HOST * - USB_DR_MODE_OTG - * @role_sw: usb_role_switch handle * @hcd_enabled: Host mode sub-driver initialization indicator. * @gadget_enabled: Peripheral mode sub-driver initialization indicator. * @ll_hw_enabled: Status of low-level hardware resources. @@ -1055,7 +1054,6 @@ struct dwc2_hsotg { struct dwc2_core_params params; enum usb_otg_state op_state; enum usb_dr_mode dr_mode; - struct usb_role_switch *role_sw; unsigned int hcd_enabled:1; unsigned int gadget_enabled:1; unsigned int ll_hw_enabled:1; @@ -1378,11 +1376,6 @@ static inline int dwc2_is_device_mode(struct dwc2_hsotg *hsotg) return (dwc2_readl(hsotg, GINTSTS) & GINTSTS_CURMODE_HOST) == 0; } -int dwc2_drd_init(struct dwc2_hsotg *hsotg); -void dwc2_drd_suspend(struct dwc2_hsotg *hsotg); -void dwc2_drd_resume(struct dwc2_hsotg *hsotg); -void dwc2_drd_exit(struct dwc2_hsotg *hsotg); - /* * Dump core registers and SPRAM */ @@ -1399,7 +1392,6 @@ int dwc2_hsotg_resume(struct dwc2_hsotg *dwc2); int dwc2_gadget_init(struct dwc2_hsotg *hsotg); void dwc2_hsotg_core_init_disconnected(struct dwc2_hsotg *dwc2, bool reset); -void dwc2_hsotg_core_disconnect(struct dwc2_hsotg *hsotg); void dwc2_hsotg_core_connect(struct dwc2_hsotg *hsotg); void dwc2_hsotg_disconnect(struct dwc2_hsotg *dwc2); int dwc2_hsotg_set_test_mode(struct dwc2_hsotg *hsotg, int testmode); diff --git a/drivers/usb/dwc2/drd.c b/drivers/usb/dwc2/drd.c deleted file mode 100644 index 032efffa37ab..000000000000 --- a/drivers/usb/dwc2/drd.c +++ /dev/null @@ -1,190 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * drd.c - DesignWare USB2 DRD Controller Dual-role support - * - * Copyright (C) 2020 STMicroelectronics - * - * Author(s): Amelie Delaunay - */ - -#include -#include -#include -#include "core.h" - -static void dwc2_ovr_init(struct dwc2_hsotg *hsotg) -{ - unsigned long flags; - u32 gotgctl; - - spin_lock_irqsave(&hsotg->lock, flags); - - gotgctl = dwc2_readl(hsotg, GOTGCTL); - gotgctl |= GOTGCTL_BVALOEN | GOTGCTL_AVALOEN | GOTGCTL_VBVALOEN; - gotgctl |= GOTGCTL_DBNCE_FLTR_BYPASS; - gotgctl &= ~(GOTGCTL_BVALOVAL | GOTGCTL_AVALOVAL | GOTGCTL_VBVALOVAL); - dwc2_writel(hsotg, gotgctl, GOTGCTL); - - dwc2_force_mode(hsotg, false); - - spin_unlock_irqrestore(&hsotg->lock, flags); -} - -static int dwc2_ovr_avalid(struct dwc2_hsotg *hsotg, bool valid) -{ - u32 gotgctl = dwc2_readl(hsotg, GOTGCTL); - - /* Check if A-Session is already in the right state */ - if ((valid && (gotgctl & GOTGCTL_ASESVLD)) || - (!valid && !(gotgctl & GOTGCTL_ASESVLD))) - return -EALREADY; - - if (valid) - gotgctl |= GOTGCTL_AVALOVAL | GOTGCTL_VBVALOVAL; - else - gotgctl &= ~(GOTGCTL_AVALOVAL | GOTGCTL_VBVALOVAL); - dwc2_writel(hsotg, gotgctl, GOTGCTL); - - return 0; -} - -static int dwc2_ovr_bvalid(struct dwc2_hsotg *hsotg, bool valid) -{ - u32 gotgctl = dwc2_readl(hsotg, GOTGCTL); - - /* Check if B-Session is already in the right state */ - if ((valid && (gotgctl & GOTGCTL_BSESVLD)) || - (!valid && !(gotgctl & GOTGCTL_BSESVLD))) - return -EALREADY; - - if (valid) - gotgctl |= GOTGCTL_BVALOVAL | GOTGCTL_VBVALOVAL; - else - gotgctl &= ~(GOTGCTL_BVALOVAL | GOTGCTL_VBVALOVAL); - dwc2_writel(hsotg, gotgctl, GOTGCTL); - - return 0; -} - -static int dwc2_drd_role_sw_set(struct usb_role_switch *sw, enum usb_role role) -{ - struct dwc2_hsotg *hsotg = usb_role_switch_get_drvdata(sw); - unsigned long flags; - - /* Skip session not in line with dr_mode */ - if ((role == USB_ROLE_DEVICE && hsotg->dr_mode == USB_DR_MODE_HOST) || - (role == USB_ROLE_HOST && hsotg->dr_mode == USB_DR_MODE_PERIPHERAL)) - return -EINVAL; - - /* Skip session if core is in test mode */ - if (role == USB_ROLE_NONE && hsotg->test_mode) { - dev_dbg(hsotg->dev, "Core is in test mode\n"); - return -EBUSY; - } - - spin_lock_irqsave(&hsotg->lock, flags); - - if (role == USB_ROLE_HOST) { - if (dwc2_ovr_avalid(hsotg, true)) - goto unlock; - - if (hsotg->dr_mode == USB_DR_MODE_OTG) - /* - * This will raise a Connector ID Status Change - * Interrupt - connID A - */ - dwc2_force_mode(hsotg, true); - } else if (role == USB_ROLE_DEVICE) { - if (dwc2_ovr_bvalid(hsotg, true)) - goto unlock; - - if (hsotg->dr_mode == USB_DR_MODE_OTG) - /* - * This will raise a Connector ID Status Change - * Interrupt - connID B - */ - dwc2_force_mode(hsotg, false); - - /* This clear DCTL.SFTDISCON bit */ - dwc2_hsotg_core_connect(hsotg); - } else { - if (dwc2_is_device_mode(hsotg)) { - if (!dwc2_ovr_bvalid(hsotg, false)) - /* This set DCTL.SFTDISCON bit */ - dwc2_hsotg_core_disconnect(hsotg); - } else { - dwc2_ovr_avalid(hsotg, false); - } - } - -unlock: - spin_unlock_irqrestore(&hsotg->lock, flags); - - dev_dbg(hsotg->dev, "%s-session valid\n", - role == USB_ROLE_NONE ? "No" : - role == USB_ROLE_HOST ? "A" : "B"); - - return 0; -} - -int dwc2_drd_init(struct dwc2_hsotg *hsotg) -{ - struct usb_role_switch_desc role_sw_desc = {0}; - struct usb_role_switch *role_sw; - int ret; - - if (!device_property_read_bool(hsotg->dev, "usb-role-switch")) - return 0; - - role_sw_desc.driver_data = hsotg; - role_sw_desc.fwnode = dev_fwnode(hsotg->dev); - role_sw_desc.set = dwc2_drd_role_sw_set; - role_sw_desc.allow_userspace_control = true; - - role_sw = usb_role_switch_register(hsotg->dev, &role_sw_desc); - if (IS_ERR(role_sw)) { - ret = PTR_ERR(role_sw); - dev_err(hsotg->dev, - "failed to register role switch: %d\n", ret); - return ret; - } - - hsotg->role_sw = role_sw; - - /* Enable override and initialize values */ - dwc2_ovr_init(hsotg); - - return 0; -} - -void dwc2_drd_suspend(struct dwc2_hsotg *hsotg) -{ - u32 gintsts, gintmsk; - - if (hsotg->role_sw && !hsotg->params.external_id_pin_ctl) { - gintmsk = dwc2_readl(hsotg, GINTMSK); - gintmsk &= ~GINTSTS_CONIDSTSCHNG; - dwc2_writel(hsotg, gintmsk, GINTMSK); - gintsts = dwc2_readl(hsotg, GINTSTS); - dwc2_writel(hsotg, gintsts | GINTSTS_CONIDSTSCHNG, GINTSTS); - } -} - -void dwc2_drd_resume(struct dwc2_hsotg *hsotg) -{ - u32 gintsts, gintmsk; - - if (hsotg->role_sw && !hsotg->params.external_id_pin_ctl) { - gintsts = dwc2_readl(hsotg, GINTSTS); - dwc2_writel(hsotg, gintsts | GINTSTS_CONIDSTSCHNG, GINTSTS); - gintmsk = dwc2_readl(hsotg, GINTMSK); - gintmsk |= GINTSTS_CONIDSTSCHNG; - dwc2_writel(hsotg, gintmsk, GINTMSK); - } -} - -void dwc2_drd_exit(struct dwc2_hsotg *hsotg) -{ - if (hsotg->role_sw) - usb_role_switch_unregister(hsotg->role_sw); -} diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index 16c5f976f141..5b9d23991c99 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -3530,7 +3530,7 @@ void dwc2_hsotg_core_init_disconnected(struct dwc2_hsotg *hsotg, dwc2_readl(hsotg, DOEPCTL0)); } -void dwc2_hsotg_core_disconnect(struct dwc2_hsotg *hsotg) +static void dwc2_hsotg_core_disconnect(struct dwc2_hsotg *hsotg) { /* set the soft-disconnect bit */ dwc2_set_bit(hsotg, DCTL, DCTL_SFTDISCON); diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c index 68b56b43a45e..db9fd4bd1a38 100644 --- a/drivers/usb/dwc2/platform.c +++ b/drivers/usb/dwc2/platform.c @@ -317,8 +317,6 @@ static int dwc2_driver_remove(struct platform_device *dev) if (hsotg->params.activate_stm_id_vb_detection) regulator_disable(hsotg->usb33d); - dwc2_drd_exit(hsotg); - if (hsotg->ll_hw_enabled) dwc2_lowlevel_hw_disable(hsotg); @@ -535,13 +533,6 @@ static int dwc2_driver_probe(struct platform_device *dev) dwc2_writel(hsotg, ggpio, GGPIO); } - retval = dwc2_drd_init(hsotg); - if (retval) { - if (retval != -EPROBE_DEFER) - dev_err(hsotg->dev, "failed to initialize dual-role\n"); - goto error_init; - } - if (hsotg->dr_mode != USB_DR_MODE_HOST) { retval = dwc2_gadget_init(hsotg); if (retval) @@ -617,8 +608,6 @@ static int __maybe_unused dwc2_suspend(struct device *dev) if (is_device_mode) dwc2_hsotg_suspend(dwc2); - dwc2_drd_suspend(dwc2); - if (dwc2->params.activate_stm_id_vb_detection) { unsigned long flags; u32 ggpio, gotgctl; @@ -699,8 +688,6 @@ static int __maybe_unused dwc2_resume(struct device *dev) /* Need to restore FORCEDEVMODE/FORCEHOSTMODE */ dwc2_force_dr_mode(dwc2); - dwc2_drd_resume(dwc2); - if (dwc2_is_device_mode(dwc2)) ret = dwc2_hsotg_resume(dwc2); -- cgit v1.2.3-70-g09d2 From 62b9825827518843f0f93dec6730ddcde14eb5b2 Mon Sep 17 00:00:00 2001 From: Peter Chen Date: Mon, 17 Feb 2020 09:26:43 +0800 Subject: usb: chipidea: add query_available_role interface The glue layer may need to know current available role to do some setting, eg, the wakeup setting. So we add ci_hdrc_query_available_role for that. Signed-off-by: Peter Chen --- drivers/usb/chipidea/core.c | 27 +++++++++++++++++++++++++++ include/linux/usb/chipidea.h | 2 ++ 2 files changed, 29 insertions(+) (limited to 'drivers/usb') diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c index 9a7c53d09ab4..87ae3c8686a7 100644 --- a/drivers/usb/chipidea/core.c +++ b/drivers/usb/chipidea/core.c @@ -877,6 +877,33 @@ void ci_hdrc_remove_device(struct platform_device *pdev) } EXPORT_SYMBOL_GPL(ci_hdrc_remove_device); +/** + * ci_hdrc_query_available_role: get runtime available operation mode + * + * The glue layer can get current operation mode (host/peripheral/otg) + * This function should be called after ci core device has created. + * + * @pdev: the platform device of ci core. + * + * Return runtime usb_dr_mode. + */ +enum usb_dr_mode ci_hdrc_query_available_role(struct platform_device *pdev) +{ + struct ci_hdrc *ci = platform_get_drvdata(pdev); + + if (!ci) + return USB_DR_MODE_UNKNOWN; + if (ci->roles[CI_ROLE_HOST] && ci->roles[CI_ROLE_GADGET]) + return USB_DR_MODE_OTG; + else if (ci->roles[CI_ROLE_HOST]) + return USB_DR_MODE_HOST; + else if (ci->roles[CI_ROLE_GADGET]) + return USB_DR_MODE_PERIPHERAL; + else + return USB_DR_MODE_UNKNOWN; +} +EXPORT_SYMBOL_GPL(ci_hdrc_query_available_role); + static inline void ci_role_destroy(struct ci_hdrc *ci) { ci_hdrc_gadget_destroy(ci); diff --git a/include/linux/usb/chipidea.h b/include/linux/usb/chipidea.h index 54167a2d28ea..025b41687ce9 100644 --- a/include/linux/usb/chipidea.h +++ b/include/linux/usb/chipidea.h @@ -99,5 +99,7 @@ struct platform_device *ci_hdrc_add_device(struct device *dev, struct ci_hdrc_platform_data *platdata); /* Remove ci hdrc device */ void ci_hdrc_remove_device(struct platform_device *pdev); +/* Get current available role */ +enum usb_dr_mode ci_hdrc_query_available_role(struct platform_device *pdev); #endif -- cgit v1.2.3-70-g09d2 From d6f93d21001e4388a25b0b922e02e64bc6004d2f Mon Sep 17 00:00:00 2001 From: Peter Chen Date: Tue, 28 Jul 2020 14:12:11 +0800 Subject: usb: chipidea: imx: get available runtime dr mode for wakeup setting If runtime dr_mode is not dual-role, it doesn't need to enable ID wakeup interrupt. If runtime dr_mode is host, it doesn't need to enable VBUS wakeup interrupt. With these changes, the user will not get the unexpected wakeup for single role use case. For example, the host-only use case at Micro-AB port, the controller should not be waken up by only plug in Micro-AB cable or the Micro-B cable with host. Signed-off-by: Peter Chen --- drivers/usb/chipidea/ci_hdrc_imx.c | 4 ++++ drivers/usb/chipidea/ci_hdrc_imx.h | 1 + drivers/usb/chipidea/usbmisc_imx.c | 4 ++-- 3 files changed, 7 insertions(+), 2 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/chipidea/ci_hdrc_imx.c b/drivers/usb/chipidea/ci_hdrc_imx.c index 5ae16368a0c7..c39e2b615ac6 100644 --- a/drivers/usb/chipidea/ci_hdrc_imx.c +++ b/drivers/usb/chipidea/ci_hdrc_imx.c @@ -462,6 +462,10 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev) if (!IS_ERR(pdata.vbus_extcon.edev) || of_property_read_bool(np, "usb-role-switch")) data->usbmisc_data->ext_vbus = 1; + + /* usbmisc needs to know dr mode to choose wakeup setting */ + data->usbmisc_data->available_role = + ci_hdrc_query_available_role(data->ci_pdev); } ret = imx_usbmisc_init_post(data->usbmisc_data); diff --git a/drivers/usb/chipidea/ci_hdrc_imx.h b/drivers/usb/chipidea/ci_hdrc_imx.h index 727d02b6dbd3..99f846119c00 100644 --- a/drivers/usb/chipidea/ci_hdrc_imx.h +++ b/drivers/usb/chipidea/ci_hdrc_imx.h @@ -25,6 +25,7 @@ struct imx_usbmisc_data { unsigned int ext_id:1; /* ID from exteranl event */ unsigned int ext_vbus:1; /* Vbus from exteranl event */ struct usb_phy *usb_phy; + enum usb_dr_mode available_role; /* runtime usb dr mode */ }; int imx_usbmisc_init(struct imx_usbmisc_data *data); diff --git a/drivers/usb/chipidea/usbmisc_imx.c b/drivers/usb/chipidea/usbmisc_imx.c index f136876cb4a3..ae8f0f37e799 100644 --- a/drivers/usb/chipidea/usbmisc_imx.c +++ b/drivers/usb/chipidea/usbmisc_imx.c @@ -367,10 +367,10 @@ static u32 usbmisc_wakeup_setting(struct imx_usbmisc_data *data) { u32 wakeup_setting = MX6_USB_OTG_WAKEUP_BITS; - if (data->ext_id) + if (data->ext_id || data->available_role != USB_DR_MODE_OTG) wakeup_setting &= ~MX6_BM_ID_WAKEUP; - if (data->ext_vbus) + if (data->ext_vbus || data->available_role == USB_DR_MODE_HOST) wakeup_setting &= ~MX6_BM_VBUS_WAKEUP; return wakeup_setting; -- cgit v1.2.3-70-g09d2 From b0e02550346e676e104a47d1f050dc21d46cd35d Mon Sep 17 00:00:00 2001 From: Wei Yongjun Date: Tue, 28 Jul 2020 01:12:07 +0800 Subject: xhci: dbc: Make function xhci_dbc_ring_alloc() static The sparse tool complains as follows: drivers/usb/host/xhci-dbgcap.c:422:18: warning: symbol 'xhci_dbc_ring_alloc' was not declared. Should it be static? This function is not used outside ofxhci-dbgcap.c, so this commit marks it static. Fixes: ac286428c69f ("xhci: dbc: don't use generic xhci ring allocation functions for dbc.") Reported-by: Hulk Robot Signed-off-by: Wei Yongjun Link: https://lore.kernel.org/r/20200727171207.3101-1-weiyongjun1@huawei.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/xhci-dbgcap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/usb') diff --git a/drivers/usb/host/xhci-dbgcap.c b/drivers/usb/host/xhci-dbgcap.c index c57178db7994..fcc5ac5ce8b1 100644 --- a/drivers/usb/host/xhci-dbgcap.c +++ b/drivers/usb/host/xhci-dbgcap.c @@ -419,7 +419,7 @@ dbc_alloc_ctx(struct device *dev, gfp_t flags) return ctx; } -struct xhci_ring * +static struct xhci_ring * xhci_dbc_ring_alloc(struct device *dev, enum xhci_ring_type type, gfp_t flags) { struct xhci_ring *ring; -- cgit v1.2.3-70-g09d2 From 25252919a1050e4e013a40e4c5d2645e677157a0 Mon Sep 17 00:00:00 2001 From: Wei Yongjun Date: Tue, 28 Jul 2020 01:11:49 +0800 Subject: xhci: dbgtty: Make some functions static The sparse tool complains as follows: drivers/usb/host/xhci-dbgtty.c:401:5: warning: symbol 'xhci_dbc_tty_register_device' was not declared. Should it be static? drivers/usb/host/xhci-dbgtty.c:452:6: warning: symbol 'xhci_dbc_tty_unregister_device' was not declared. Should it be static? After commit 6ae6470bfa33 ("xhci: dbc: Add a operations structure to access driver functions"), those functions are not used outside of xhci-dbgtty.c, so this commit marks them static. Fixes: 6ae6470bfa33 ("xhci: dbc: Add a operations structure to access driver functions") Reported-by: Hulk Robot Signed-off-by: Wei Yongjun Link: https://lore.kernel.org/r/20200727171149.3011-1-weiyongjun1@huawei.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/xhci-dbgtty.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/host/xhci-dbgtty.c b/drivers/usb/host/xhci-dbgtty.c index 0b942112b6f8..b8918f73a432 100644 --- a/drivers/usb/host/xhci-dbgtty.c +++ b/drivers/usb/host/xhci-dbgtty.c @@ -398,7 +398,7 @@ xhci_dbc_tty_exit_port(struct dbc_port *port) tty_port_destroy(&port->port); } -int xhci_dbc_tty_register_device(struct xhci_dbc *dbc) +static int xhci_dbc_tty_register_device(struct xhci_dbc *dbc) { int ret; struct device *tty_dev; @@ -449,7 +449,7 @@ register_fail: return ret; } -void xhci_dbc_tty_unregister_device(struct xhci_dbc *dbc) +static void xhci_dbc_tty_unregister_device(struct xhci_dbc *dbc) { struct dbc_port *port = dbc_to_port(dbc); -- cgit v1.2.3-70-g09d2 From 5f2b8d87bca528616e04344d1fc4032dc5ec0f3d Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Fri, 24 Jul 2020 19:46:57 +0200 Subject: usb: typec: tcpm: Move mod_delayed_work(&port->vdm_state_machine) call into tcpm_queue_vdm() All callers of tcpm_queue_vdm() immediately follow the tcpm_queue_vdm() vdm call with a: mod_delayed_work(port->wq, &port->vdm_state_machine, 0); Call, fold this into tcpm_queue_vdm() itself. Reviewed-by: Guenter Roeck Reviewed-by: Heikki Krogerus Signed-off-by: Hans de Goede Link: https://lore.kernel.org/r/20200724174702.61754-1-hdegoede@redhat.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/typec/tcpm/tcpm.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c index ff1cbd2147ca..5fcbab1de40c 100644 --- a/drivers/usb/typec/tcpm/tcpm.c +++ b/drivers/usb/typec/tcpm/tcpm.c @@ -967,6 +967,8 @@ static void tcpm_queue_vdm(struct tcpm_port *port, const u32 header, /* Set ready, vdm state machine will actually send */ port->vdm_retries = 0; port->vdm_state = VDM_STATE_READY; + + mod_delayed_work(port->wq, &port->vdm_state_machine, 0); } static void svdm_consume_identity(struct tcpm_port *port, const __le32 *payload, @@ -1248,10 +1250,8 @@ static void tcpm_handle_vdm_request(struct tcpm_port *port, if (PD_VDO_SVDM(p0)) rlen = tcpm_pd_svdm(port, payload, cnt, response); - if (rlen > 0) { + if (rlen > 0) tcpm_queue_vdm(port, response[0], &response[1], rlen - 1); - mod_delayed_work(port->wq, &port->vdm_state_machine, 0); - } } static void tcpm_send_vdm(struct tcpm_port *port, u32 vid, int cmd, @@ -1266,8 +1266,6 @@ static void tcpm_send_vdm(struct tcpm_port *port, u32 vid, int cmd, header = VDO(vid, ((vid & USB_SID_PD) == USB_SID_PD) ? 1 : (PD_VDO_CMD(cmd) <= CMD_ATTENTION), cmd); tcpm_queue_vdm(port, header, data, count); - - mod_delayed_work(port->wq, &port->vdm_state_machine, 0); } static unsigned int vdm_ready_timeout(u32 vdm_hdr) @@ -1515,7 +1513,6 @@ static int tcpm_altmode_enter(struct typec_altmode *altmode, u32 *vdo) header |= VDO_OPOS(altmode->mode); tcpm_queue_vdm(port, header, vdo, vdo ? 1 : 0); - mod_delayed_work(port->wq, &port->vdm_state_machine, 0); mutex_unlock(&port->lock); return 0; @@ -1531,7 +1528,6 @@ static int tcpm_altmode_exit(struct typec_altmode *altmode) header |= VDO_OPOS(altmode->mode); tcpm_queue_vdm(port, header, NULL, 0); - mod_delayed_work(port->wq, &port->vdm_state_machine, 0); mutex_unlock(&port->lock); return 0; @@ -1544,7 +1540,6 @@ static int tcpm_altmode_vdm(struct typec_altmode *altmode, mutex_lock(&port->lock); tcpm_queue_vdm(port, header, data, count - 1); - mod_delayed_work(port->wq, &port->vdm_state_machine, 0); mutex_unlock(&port->lock); return 0; -- cgit v1.2.3-70-g09d2 From 03eafcfb60c0da4f08a638f0dd5926fc2fc1d64a Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Fri, 24 Jul 2020 19:46:58 +0200 Subject: usb: typec: tcpm: Add tcpm_queue_vdm_unlocked() helper Various callers (all the typec_altmode_ops) take the port-lock just for the tcpm_queue_vdm() call. Add a new tcpm_queue_vdm_unlocked() helper which takes the lock, so that its callers don't have to do this themselves. This is a preparation patch for fixing an AB BA lock inversion between the tcpm code and some altmode drivers. Reviewed-by: Heikki Krogerus Reviewed-by: Guenter Roeck Signed-off-by: Hans de Goede Link: https://lore.kernel.org/r/20200724174702.61754-2-hdegoede@redhat.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/typec/tcpm/tcpm.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c index 5fcbab1de40c..b72534393b15 100644 --- a/drivers/usb/typec/tcpm/tcpm.c +++ b/drivers/usb/typec/tcpm/tcpm.c @@ -961,6 +961,8 @@ static void tcpm_queue_message(struct tcpm_port *port, static void tcpm_queue_vdm(struct tcpm_port *port, const u32 header, const u32 *data, int cnt) { + WARN_ON(!mutex_is_locked(&port->lock)); + port->vdo_count = cnt + 1; port->vdo_data[0] = header; memcpy(&port->vdo_data[1], data, sizeof(u32) * cnt); @@ -971,6 +973,14 @@ static void tcpm_queue_vdm(struct tcpm_port *port, const u32 header, mod_delayed_work(port->wq, &port->vdm_state_machine, 0); } +static void tcpm_queue_vdm_unlocked(struct tcpm_port *port, const u32 header, + const u32 *data, int cnt) +{ + mutex_lock(&port->lock); + tcpm_queue_vdm(port, header, data, cnt); + mutex_unlock(&port->lock); +} + static void svdm_consume_identity(struct tcpm_port *port, const __le32 *payload, int cnt) { @@ -1508,13 +1518,10 @@ static int tcpm_altmode_enter(struct typec_altmode *altmode, u32 *vdo) struct tcpm_port *port = typec_altmode_get_drvdata(altmode); u32 header; - mutex_lock(&port->lock); header = VDO(altmode->svid, vdo ? 2 : 1, CMD_ENTER_MODE); header |= VDO_OPOS(altmode->mode); - tcpm_queue_vdm(port, header, vdo, vdo ? 1 : 0); - mutex_unlock(&port->lock); - + tcpm_queue_vdm_unlocked(port, header, vdo, vdo ? 1 : 0); return 0; } @@ -1523,13 +1530,10 @@ static int tcpm_altmode_exit(struct typec_altmode *altmode) struct tcpm_port *port = typec_altmode_get_drvdata(altmode); u32 header; - mutex_lock(&port->lock); header = VDO(altmode->svid, 1, CMD_EXIT_MODE); header |= VDO_OPOS(altmode->mode); - tcpm_queue_vdm(port, header, NULL, 0); - mutex_unlock(&port->lock); - + tcpm_queue_vdm_unlocked(port, header, NULL, 0); return 0; } @@ -1538,10 +1542,7 @@ static int tcpm_altmode_vdm(struct typec_altmode *altmode, { struct tcpm_port *port = typec_altmode_get_drvdata(altmode); - mutex_lock(&port->lock); - tcpm_queue_vdm(port, header, data, count - 1); - mutex_unlock(&port->lock); - + tcpm_queue_vdm_unlocked(port, header, data, count - 1); return 0; } -- cgit v1.2.3-70-g09d2 From 8afe9a3548f9d1805dcea6d97978f2179c8403a3 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Fri, 24 Jul 2020 19:46:59 +0200 Subject: usb: typec: tcpm: Refactor tcpm_handle_vdm_request payload handling Refactor the tcpm_handle_vdm_request payload handling by doing the endianness conversion only once directly inside tcpm_handle_vdm_request itself instead of doing it multiple times inside various helper functions called by tcpm_handle_vdm_request. This is a preparation patch for some further refactoring to fix an AB BA lock inversion between the tcpm code and some altmode drivers. Reviewed-by: Guenter Roeck Reviewed-by: Heikki Krogerus Signed-off-by: Hans de Goede Link: https://lore.kernel.org/r/20200724174702.61754-3-hdegoede@redhat.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/typec/tcpm/tcpm.c | 49 +++++++++++++++++++------------------------ 1 file changed, 22 insertions(+), 27 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c index b72534393b15..d65358a242f8 100644 --- a/drivers/usb/typec/tcpm/tcpm.c +++ b/drivers/usb/typec/tcpm/tcpm.c @@ -981,16 +981,15 @@ static void tcpm_queue_vdm_unlocked(struct tcpm_port *port, const u32 header, mutex_unlock(&port->lock); } -static void svdm_consume_identity(struct tcpm_port *port, const __le32 *payload, - int cnt) +static void svdm_consume_identity(struct tcpm_port *port, const u32 *p, int cnt) { - u32 vdo = le32_to_cpu(payload[VDO_INDEX_IDH]); - u32 product = le32_to_cpu(payload[VDO_INDEX_PRODUCT]); + u32 vdo = p[VDO_INDEX_IDH]; + u32 product = p[VDO_INDEX_PRODUCT]; memset(&port->mode_data, 0, sizeof(port->mode_data)); port->partner_ident.id_header = vdo; - port->partner_ident.cert_stat = le32_to_cpu(payload[VDO_INDEX_CSTAT]); + port->partner_ident.cert_stat = p[VDO_INDEX_CSTAT]; port->partner_ident.product = product; typec_partner_set_identity(port->partner); @@ -1000,17 +999,15 @@ static void svdm_consume_identity(struct tcpm_port *port, const __le32 *payload, PD_PRODUCT_PID(product), product & 0xffff); } -static bool svdm_consume_svids(struct tcpm_port *port, const __le32 *payload, - int cnt) +static bool svdm_consume_svids(struct tcpm_port *port, const u32 *p, int cnt) { struct pd_mode_data *pmdata = &port->mode_data; int i; for (i = 1; i < cnt; i++) { - u32 p = le32_to_cpu(payload[i]); u16 svid; - svid = (p >> 16) & 0xffff; + svid = (p[i] >> 16) & 0xffff; if (!svid) return false; @@ -1020,7 +1017,7 @@ static bool svdm_consume_svids(struct tcpm_port *port, const __le32 *payload, pmdata->svids[pmdata->nsvids++] = svid; tcpm_log(port, "SVID %d: 0x%x", pmdata->nsvids, svid); - svid = p & 0xffff; + svid = p[i] & 0xffff; if (!svid) return false; @@ -1036,8 +1033,7 @@ abort: return false; } -static void svdm_consume_modes(struct tcpm_port *port, const __le32 *payload, - int cnt) +static void svdm_consume_modes(struct tcpm_port *port, const u32 *p, int cnt) { struct pd_mode_data *pmdata = &port->mode_data; struct typec_altmode_desc *paltmode; @@ -1054,7 +1050,7 @@ static void svdm_consume_modes(struct tcpm_port *port, const __le32 *payload, paltmode->svid = pmdata->svids[pmdata->svid_index]; paltmode->mode = i; - paltmode->vdo = le32_to_cpu(payload[i]); + paltmode->vdo = p[i]; tcpm_log(port, " Alternate mode %d: SVID 0x%04x, VDO %d: 0x%08x", pmdata->altmodes, paltmode->svid, @@ -1084,21 +1080,17 @@ static void tcpm_register_partner_altmodes(struct tcpm_port *port) #define supports_modal(port) PD_IDH_MODAL_SUPP((port)->partner_ident.id_header) -static int tcpm_pd_svdm(struct tcpm_port *port, const __le32 *payload, int cnt, +static int tcpm_pd_svdm(struct tcpm_port *port, const u32 *p, int cnt, u32 *response) { struct typec_altmode *adev; struct typec_altmode *pdev; struct pd_mode_data *modep; - u32 p[PD_MAX_PAYLOAD]; int rlen = 0; int cmd_type; int cmd; int i; - for (i = 0; i < cnt; i++) - p[i] = le32_to_cpu(payload[i]); - cmd_type = PD_VDO_CMDT(p[0]); cmd = PD_VDO_CMD(p[0]); @@ -1159,13 +1151,13 @@ static int tcpm_pd_svdm(struct tcpm_port *port, const __le32 *payload, int cnt, switch (cmd) { case CMD_DISCOVER_IDENT: /* 6.4.4.3.1 */ - svdm_consume_identity(port, payload, cnt); + svdm_consume_identity(port, p, cnt); response[0] = VDO(USB_SID_PD, 1, CMD_DISCOVER_SVID); rlen = 1; break; case CMD_DISCOVER_SVID: /* 6.4.4.3.2 */ - if (svdm_consume_svids(port, payload, cnt)) { + if (svdm_consume_svids(port, p, cnt)) { response[0] = VDO(USB_SID_PD, 1, CMD_DISCOVER_SVID); rlen = 1; @@ -1177,7 +1169,7 @@ static int tcpm_pd_svdm(struct tcpm_port *port, const __le32 *payload, int cnt, break; case CMD_DISCOVER_MODES: /* 6.4.4.3.3 */ - svdm_consume_modes(port, payload, cnt); + svdm_consume_modes(port, p, cnt); modep->svid_index++; if (modep->svid_index < modep->nsvids) { u16 svid = modep->svids[modep->svid_index]; @@ -1240,15 +1232,18 @@ static int tcpm_pd_svdm(struct tcpm_port *port, const __le32 *payload, int cnt, static void tcpm_handle_vdm_request(struct tcpm_port *port, const __le32 *payload, int cnt) { - int rlen = 0; + u32 p[PD_MAX_PAYLOAD]; u32 response[8] = { }; - u32 p0 = le32_to_cpu(payload[0]); + int i, rlen = 0; + + for (i = 0; i < cnt; i++) + p[i] = le32_to_cpu(payload[i]); if (port->vdm_state == VDM_STATE_BUSY) { /* If UFP responded busy retry after timeout */ - if (PD_VDO_CMDT(p0) == CMDT_RSP_BUSY) { + if (PD_VDO_CMDT(p[0]) == CMDT_RSP_BUSY) { port->vdm_state = VDM_STATE_WAIT_RSP_BUSY; - port->vdo_retry = (p0 & ~VDO_CMDT_MASK) | + port->vdo_retry = (p[0] & ~VDO_CMDT_MASK) | CMDT_INIT; mod_delayed_work(port->wq, &port->vdm_state_machine, msecs_to_jiffies(PD_T_VDM_BUSY)); @@ -1257,8 +1252,8 @@ static void tcpm_handle_vdm_request(struct tcpm_port *port, port->vdm_state = VDM_STATE_DONE; } - if (PD_VDO_SVDM(p0)) - rlen = tcpm_pd_svdm(port, payload, cnt, response); + if (PD_VDO_SVDM(p[0])) + rlen = tcpm_pd_svdm(port, p, cnt, response); if (rlen > 0) tcpm_queue_vdm(port, response[0], &response[1], rlen - 1); -- cgit v1.2.3-70-g09d2 From 95b4d51c96a87cd760c2a4f27fb28a59a27b6368 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Fri, 24 Jul 2020 19:47:00 +0200 Subject: usb: typec: tcpm: Refactor tcpm_handle_vdm_request Refactor tcpm_handle_vdm_request and its tcpm_pd_svdm helper function so that reporting the results of the vdm to the altmode-driver is separated out into a clear separate step inside tcpm_handle_vdm_request, instead of being scattered over various places inside the tcpm_pd_svdm helper. This is a preparation patch for fixing an AB BA lock inversion between the tcpm code and some altmode drivers. Reviewed-by: Heikki Krogerus Reviewed-by: Guenter Roeck Signed-off-by: Hans de Goede Link: https://lore.kernel.org/r/20200724174702.61754-4-hdegoede@redhat.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/typec/tcpm/tcpm.c | 76 +++++++++++++++++++++++++++---------------- 1 file changed, 48 insertions(+), 28 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c index d65358a242f8..51400cce582e 100644 --- a/drivers/usb/typec/tcpm/tcpm.c +++ b/drivers/usb/typec/tcpm/tcpm.c @@ -159,6 +159,14 @@ enum pd_msg_request { PD_MSG_DATA_SOURCE_CAP, }; +enum adev_actions { + ADEV_NONE = 0, + ADEV_NOTIFY_USB_AND_QUEUE_VDM, + ADEV_QUEUE_VDM, + ADEV_QUEUE_VDM_SEND_EXIT_MODE_ON_FAIL, + ADEV_ATTENTION, +}; + /* Events from low level driver */ #define TCPM_CC_EVENT BIT(0) @@ -1080,10 +1088,10 @@ static void tcpm_register_partner_altmodes(struct tcpm_port *port) #define supports_modal(port) PD_IDH_MODAL_SUPP((port)->partner_ident.id_header) -static int tcpm_pd_svdm(struct tcpm_port *port, const u32 *p, int cnt, - u32 *response) +static int tcpm_pd_svdm(struct tcpm_port *port, struct typec_altmode *adev, + const u32 *p, int cnt, u32 *response, + enum adev_actions *adev_action) { - struct typec_altmode *adev; struct typec_altmode *pdev; struct pd_mode_data *modep; int rlen = 0; @@ -1099,9 +1107,6 @@ static int tcpm_pd_svdm(struct tcpm_port *port, const u32 *p, int cnt, modep = &port->mode_data; - adev = typec_match_altmode(port->port_altmode, ALTMODE_DISCOVERY_MAX, - PD_VDO_VID(p[0]), PD_VDO_OPOS(p[0])); - pdev = typec_match_altmode(port->partner_altmode, ALTMODE_DISCOVERY_MAX, PD_VDO_VID(p[0]), PD_VDO_OPOS(p[0])); @@ -1127,8 +1132,7 @@ static int tcpm_pd_svdm(struct tcpm_port *port, const u32 *p, int cnt, break; case CMD_ATTENTION: /* Attention command does not have response */ - if (adev) - typec_altmode_attention(adev, p[1]); + *adev_action = ADEV_ATTENTION; return 0; default: break; @@ -1182,23 +1186,15 @@ static int tcpm_pd_svdm(struct tcpm_port *port, const u32 *p, int cnt, case CMD_ENTER_MODE: if (adev && pdev) { typec_altmode_update_active(pdev, true); - - if (typec_altmode_vdm(adev, p[0], &p[1], cnt)) { - response[0] = VDO(adev->svid, 1, - CMD_EXIT_MODE); - response[0] |= VDO_OPOS(adev->mode); - return 1; - } + *adev_action = ADEV_QUEUE_VDM_SEND_EXIT_MODE_ON_FAIL; } return 0; case CMD_EXIT_MODE: if (adev && pdev) { typec_altmode_update_active(pdev, false); - /* Back to USB Operation */ - WARN_ON(typec_altmode_notify(adev, - TYPEC_STATE_USB, - NULL)); + *adev_action = ADEV_NOTIFY_USB_AND_QUEUE_VDM; + return 0; } break; default: @@ -1209,11 +1205,8 @@ static int tcpm_pd_svdm(struct tcpm_port *port, const u32 *p, int cnt, switch (cmd) { case CMD_ENTER_MODE: /* Back to USB Operation */ - if (adev) - WARN_ON(typec_altmode_notify(adev, - TYPEC_STATE_USB, - NULL)); - break; + *adev_action = ADEV_NOTIFY_USB_AND_QUEUE_VDM; + return 0; default: break; } @@ -1223,15 +1216,15 @@ static int tcpm_pd_svdm(struct tcpm_port *port, const u32 *p, int cnt, } /* Informing the alternate mode drivers about everything */ - if (adev) - typec_altmode_vdm(adev, p[0], &p[1], cnt); - + *adev_action = ADEV_QUEUE_VDM; return rlen; } static void tcpm_handle_vdm_request(struct tcpm_port *port, const __le32 *payload, int cnt) { + enum adev_actions adev_action = ADEV_NONE; + struct typec_altmode *adev; u32 p[PD_MAX_PAYLOAD]; u32 response[8] = { }; int i, rlen = 0; @@ -1239,6 +1232,9 @@ static void tcpm_handle_vdm_request(struct tcpm_port *port, for (i = 0; i < cnt; i++) p[i] = le32_to_cpu(payload[i]); + adev = typec_match_altmode(port->port_altmode, ALTMODE_DISCOVERY_MAX, + PD_VDO_VID(p[0]), PD_VDO_OPOS(p[0])); + if (port->vdm_state == VDM_STATE_BUSY) { /* If UFP responded busy retry after timeout */ if (PD_VDO_CMDT(p[0]) == CMDT_RSP_BUSY) { @@ -1253,7 +1249,31 @@ static void tcpm_handle_vdm_request(struct tcpm_port *port, } if (PD_VDO_SVDM(p[0])) - rlen = tcpm_pd_svdm(port, p, cnt, response); + rlen = tcpm_pd_svdm(port, adev, p, cnt, response, &adev_action); + + if (adev) { + switch (adev_action) { + case ADEV_NONE: + break; + case ADEV_NOTIFY_USB_AND_QUEUE_VDM: + WARN_ON(typec_altmode_notify(adev, TYPEC_STATE_USB, NULL)); + typec_altmode_vdm(adev, p[0], &p[1], cnt); + break; + case ADEV_QUEUE_VDM: + typec_altmode_vdm(adev, p[0], &p[1], cnt); + break; + case ADEV_QUEUE_VDM_SEND_EXIT_MODE_ON_FAIL: + if (typec_altmode_vdm(adev, p[0], &p[1], cnt)) { + response[0] = VDO(adev->svid, 1, CMD_EXIT_MODE); + response[0] |= VDO_OPOS(adev->mode); + rlen = 1; + } + break; + case ADEV_ATTENTION: + typec_altmode_attention(adev, p[1]); + break; + } + } if (rlen > 0) tcpm_queue_vdm(port, response[0], &response[1], rlen - 1); -- cgit v1.2.3-70-g09d2 From a37241d83465dbcb1981093e139701a0755156e3 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Fri, 24 Jul 2020 19:47:01 +0200 Subject: usb: typec: tcpm: Fix AB BA lock inversion between tcpm code and the alt-mode drivers When we receive a PD data packet which ends up being for the alt-mode driver we have the following lock order: 1. tcpm_pd_rx_handler take the tcpm-port lock 2. We call into the alt-mode driver which takes the alt-mode's lock And when the alt-mode driver initiates communication we have the following lock order: 3. alt-mode driver takes the alt-mode's lock 4. alt-mode driver calls tcpm_altmode_enter which takes the tcpm-port lock This is a classic AB BA lock inversion issue. With the refactoring of tcpm_handle_vdm_request() done before this patch, we don't rely on, or need to make changes to the tcpm-port data by the time we make call 2. from above. All data to be passed to the alt-mode driver sits on our stack at this point, and thus does not need locking. So after the refactoring we can simply fix this by releasing the tcpm-port lock before calling into the alt-mode driver. This fixes the following lockdep warning: [ 191.454238] ====================================================== [ 191.454240] WARNING: possible circular locking dependency detected [ 191.454244] 5.8.0-rc5+ #1 Not tainted [ 191.454246] ------------------------------------------------------ [ 191.454248] kworker/u8:5/794 is trying to acquire lock: [ 191.454251] ffff9bac8e30d4a8 (&dp->lock){+.+.}-{3:3}, at: dp_altmode_vdm+0x30/0xf0 [typec_displayport] [ 191.454263] but task is already holding lock: [ 191.454264] ffff9bac9dc240a0 (&port->lock#2){+.+.}-{3:3}, at: tcpm_pd_rx_handler+0x43/0x12c0 [tcpm] [ 191.454273] which lock already depends on the new lock. [ 191.454275] the existing dependency chain (in reverse order) is: [ 191.454277] -> #1 (&port->lock#2){+.+.}-{3:3}: [ 191.454286] __mutex_lock+0x7b/0x820 [ 191.454290] tcpm_altmode_enter+0x23/0x90 [tcpm] [ 191.454293] dp_altmode_work+0xca/0xe0 [typec_displayport] [ 191.454299] process_one_work+0x23f/0x570 [ 191.454302] worker_thread+0x55/0x3c0 [ 191.454305] kthread+0x138/0x160 [ 191.454309] ret_from_fork+0x22/0x30 [ 191.454311] -> #0 (&dp->lock){+.+.}-{3:3}: [ 191.454317] __lock_acquire+0x1241/0x2090 [ 191.454320] lock_acquire+0xa4/0x3d0 [ 191.454323] __mutex_lock+0x7b/0x820 [ 191.454326] dp_altmode_vdm+0x30/0xf0 [typec_displayport] [ 191.454330] tcpm_pd_rx_handler+0x11ae/0x12c0 [tcpm] [ 191.454333] process_one_work+0x23f/0x570 [ 191.454336] worker_thread+0x55/0x3c0 [ 191.454338] kthread+0x138/0x160 [ 191.454341] ret_from_fork+0x22/0x30 [ 191.454343] other info that might help us debug this: [ 191.454345] Possible unsafe locking scenario: [ 191.454347] CPU0 CPU1 [ 191.454348] ---- ---- [ 191.454350] lock(&port->lock#2); [ 191.454353] lock(&dp->lock); [ 191.454355] lock(&port->lock#2); [ 191.454357] lock(&dp->lock); [ 191.454360] *** DEADLOCK *** Reviewed-by: Heikki Krogerus Reviewed-by: Guenter Roeck Signed-off-by: Hans de Goede Link: https://lore.kernel.org/r/20200724174702.61754-5-hdegoede@redhat.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/typec/tcpm/tcpm.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'drivers/usb') diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c index 51400cce582e..87ed5e2f79ca 100644 --- a/drivers/usb/typec/tcpm/tcpm.c +++ b/drivers/usb/typec/tcpm/tcpm.c @@ -1251,6 +1251,27 @@ static void tcpm_handle_vdm_request(struct tcpm_port *port, if (PD_VDO_SVDM(p[0])) rlen = tcpm_pd_svdm(port, adev, p, cnt, response, &adev_action); + /* + * We are done with any state stored in the port struct now, except + * for any port struct changes done by the tcpm_queue_vdm() call + * below, which is a separate operation. + * + * So we can safely release the lock here; and we MUST release the + * lock here to avoid an AB BA lock inversion: + * + * If we keep the lock here then the lock ordering in this path is: + * 1. tcpm_pd_rx_handler take the tcpm port lock + * 2. One of the typec_altmode_* calls below takes the alt-mode's lock + * + * And we also have this ordering: + * 1. alt-mode driver takes the alt-mode's lock + * 2. alt-mode driver calls tcpm_altmode_enter which takes the + * tcpm port lock + * + * Dropping our lock here avoids this. + */ + mutex_unlock(&port->lock); + if (adev) { switch (adev_action) { case ADEV_NONE: @@ -1275,6 +1296,15 @@ static void tcpm_handle_vdm_request(struct tcpm_port *port, } } + /* + * We must re-take the lock here to balance the unlock in + * tcpm_pd_rx_handler, note that no changes, other then the + * tcpm_queue_vdm call, are made while the lock is held again. + * All that is done after the call is unwinding the call stack until + * we return to tcpm_pd_rx_handler and do the unlock there. + */ + mutex_lock(&port->lock); + if (rlen > 0) tcpm_queue_vdm(port, response[0], &response[1], rlen - 1); } -- cgit v1.2.3-70-g09d2 From 754498c1d6369d47b6433e9a05ba926255c2d699 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Fri, 24 Jul 2020 19:47:02 +0200 Subject: usb: typec: tcpm: Add WARN_ON ensure we are not trying to send 2 VDM packets at the same time The tcpm.c code for sending VDMs assumes that there will only be one VDM in flight at the time. The "queue" used by tcpm_queue_vdm is only 1 entry deep. This assumes that the higher layers (tcpm state-machine and alt-mode drivers) ensure that queuing a new VDM before the old one has been completely send (or it timed out) add a WARN_ON to check for this. Reviewed-by: Heikki Krogerus Reviewed-by: Guenter Roeck Signed-off-by: Hans de Goede Link: https://lore.kernel.org/r/20200724174702.61754-6-hdegoede@redhat.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/typec/tcpm/tcpm.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'drivers/usb') diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c index 87ed5e2f79ca..3ef37202ee37 100644 --- a/drivers/usb/typec/tcpm/tcpm.c +++ b/drivers/usb/typec/tcpm/tcpm.c @@ -971,6 +971,9 @@ static void tcpm_queue_vdm(struct tcpm_port *port, const u32 header, { WARN_ON(!mutex_is_locked(&port->lock)); + /* Make sure we are not still processing a previous VDM packet */ + WARN_ON(port->vdm_state > VDM_STATE_DONE); + port->vdo_count = cnt + 1; port->vdo_data[0] = header; memcpy(&port->vdo_data[1], data, sizeof(u32) * cnt); -- cgit v1.2.3-70-g09d2 From 0ed9498f9ecfde50c93f3f3dd64b4cd5414d9944 Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Mon, 27 Jul 2020 12:46:42 +0200 Subject: USB: Simplify USB ID table match usb_device_match_id() supports being passed NULL tables, so no need to check for it. Signed-off-by: Bastien Nocera Link: https://lore.kernel.org/r/20200727104644.149873-1-hadess@hadess.net Signed-off-by: Greg Kroah-Hartman --- drivers/usb/core/generic.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/core/generic.c b/drivers/usb/core/generic.c index 4626227a6dd2..b6f2d4b44754 100644 --- a/drivers/usb/core/generic.c +++ b/drivers/usb/core/generic.c @@ -205,8 +205,6 @@ static int __check_usb_generic(struct device_driver *drv, void *data) udrv = to_usb_device_driver(drv); if (udrv == &usb_generic_driver) return 0; - if (!udrv->id_table) - return 0; return usb_device_match_id(udev, udrv->id_table) != NULL; } -- cgit v1.2.3-70-g09d2 From 5ad91812ea4b86f8740cfa433465825fdefa554e Mon Sep 17 00:00:00 2001 From: Chunfeng Yun Date: Wed, 22 Jul 2020 15:51:09 +0800 Subject: usb: mtu3: convert to devm_platform_ioremap_resource_byname Use devm_platform_ioremap_resource_byname() to simplify code Signed-off-by: Chunfeng Yun Link: https://lore.kernel.org/r/1595404275-8449-1-git-send-email-chunfeng.yun@mediatek.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/mtu3/mtu3_core.c | 4 +--- drivers/usb/mtu3/mtu3_plat.c | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/mtu3/mtu3_core.c b/drivers/usb/mtu3/mtu3_core.c index 6d515eb67ea7..9c49160138f2 100644 --- a/drivers/usb/mtu3/mtu3_core.c +++ b/drivers/usb/mtu3/mtu3_core.c @@ -828,7 +828,6 @@ int ssusb_gadget_init(struct ssusb_mtk *ssusb) struct device *dev = ssusb->dev; struct platform_device *pdev = to_platform_device(dev); struct mtu3 *mtu = NULL; - struct resource *res; int ret = -ENOMEM; mtu = devm_kzalloc(dev, sizeof(struct mtu3), GFP_KERNEL); @@ -840,8 +839,7 @@ int ssusb_gadget_init(struct ssusb_mtk *ssusb) return mtu->irq; dev_info(dev, "irq %d\n", mtu->irq); - res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "mac"); - mtu->mac_base = devm_ioremap_resource(dev, res); + mtu->mac_base = devm_platform_ioremap_resource_byname(pdev, "mac"); if (IS_ERR(mtu->mac_base)) { dev_err(dev, "error mapping memory for dev mac\n"); return PTR_ERR(mtu->mac_base); diff --git a/drivers/usb/mtu3/mtu3_plat.c b/drivers/usb/mtu3/mtu3_plat.c index 9c256ea3cdf5..d44d5417438d 100644 --- a/drivers/usb/mtu3/mtu3_plat.c +++ b/drivers/usb/mtu3/mtu3_plat.c @@ -216,7 +216,6 @@ static int get_ssusb_rscs(struct platform_device *pdev, struct ssusb_mtk *ssusb) struct device_node *node = pdev->dev.of_node; struct otg_switch_mtk *otg_sx = &ssusb->otg_switch; struct device *dev = &pdev->dev; - struct resource *res; int i; int ret; @@ -263,8 +262,7 @@ static int get_ssusb_rscs(struct platform_device *pdev, struct ssusb_mtk *ssusb) } } - res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "ippc"); - ssusb->ippc_base = devm_ioremap_resource(dev, res); + ssusb->ippc_base = devm_platform_ioremap_resource_byname(pdev, "ippc"); if (IS_ERR(ssusb->ippc_base)) return PTR_ERR(ssusb->ippc_base); -- cgit v1.2.3-70-g09d2 From 6ce7b97cfae2264687b29ae84f63fa3b57282f29 Mon Sep 17 00:00:00 2001 From: Chunfeng Yun Date: Wed, 22 Jul 2020 15:51:10 +0800 Subject: usb: phy: am335x: convert to devm_platform_ioremap_resource_byname Use devm_platform_ioremap_resource_byname() to simplify code Signed-off-by: Chunfeng Yun Link: https://lore.kernel.org/r/1595404275-8449-2-git-send-email-chunfeng.yun@mediatek.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/phy/phy-am335x-control.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/phy/phy-am335x-control.c b/drivers/usb/phy/phy-am335x-control.c index d16dfc320faa..97e6603c7149 100644 --- a/drivers/usb/phy/phy-am335x-control.c +++ b/drivers/usb/phy/phy-am335x-control.c @@ -149,7 +149,6 @@ EXPORT_SYMBOL_GPL(am335x_get_phy_control); static int am335x_control_usb_probe(struct platform_device *pdev) { - struct resource *res; struct am335x_control_usb *ctrl_usb; const struct of_device_id *of_id; const struct phy_control *phy_ctrl; @@ -166,13 +165,11 @@ static int am335x_control_usb_probe(struct platform_device *pdev) ctrl_usb->dev = &pdev->dev; - res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "phy_ctrl"); - ctrl_usb->phy_reg = devm_ioremap_resource(&pdev->dev, res); + ctrl_usb->phy_reg = devm_platform_ioremap_resource_byname(pdev, "phy_ctrl"); if (IS_ERR(ctrl_usb->phy_reg)) return PTR_ERR(ctrl_usb->phy_reg); - res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "wakeup"); - ctrl_usb->wkup = devm_ioremap_resource(&pdev->dev, res); + ctrl_usb->wkup = devm_platform_ioremap_resource_byname(pdev, "wakeup"); if (IS_ERR(ctrl_usb->wkup)) return PTR_ERR(ctrl_usb->wkup); -- cgit v1.2.3-70-g09d2 From 7e8b59c1fc6bf78b8117efd8d354bcb99efed2ea Mon Sep 17 00:00:00 2001 From: Chunfeng Yun Date: Wed, 22 Jul 2020 15:51:11 +0800 Subject: usb: cdns3: convert to devm_platform_ioremap_resource_byname Use devm_platform_ioremap_resource_byname() to simplify code Cc: Peter Chen Reviewed-by: Peter Chen Signed-off-by: Chunfeng Yun Link: https://lore.kernel.org/r/1595404275-8449-3-git-send-email-chunfeng.yun@mediatek.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/cdns3/core.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/cdns3/core.c b/drivers/usb/cdns3/core.c index 72885c5edb09..5c1586ec7824 100644 --- a/drivers/usb/cdns3/core.c +++ b/drivers/usb/cdns3/core.c @@ -423,8 +423,7 @@ static int cdns3_probe(struct platform_device *pdev) if (cdns->dev_irq < 0) dev_err(dev, "couldn't get peripheral irq\n"); - res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dev"); - regs = devm_ioremap_resource(dev, res); + regs = devm_platform_ioremap_resource_byname(pdev, "dev"); if (IS_ERR(regs)) return PTR_ERR(regs); cdns->dev_regs = regs; -- cgit v1.2.3-70-g09d2 From db123bea96252d2f9eb0dc8e53f7b2e54856b31c Mon Sep 17 00:00:00 2001 From: Chunfeng Yun Date: Wed, 22 Jul 2020 15:51:12 +0800 Subject: usb: dwc3: convert to devm_platform_ioremap_resource_byname Use devm_platform_ioremap_resource_byname() to simplify code Cc: Patrice Chotard Reviewed-by: Patrice Chotard Signed-off-by: Chunfeng Yun Link: https://lore.kernel.org/r/1595404275-8449-4-git-send-email-chunfeng.yun@mediatek.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/dwc3/dwc3-st.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/dwc3/dwc3-st.c b/drivers/usb/dwc3/dwc3-st.c index c682420f25ca..e733be840545 100644 --- a/drivers/usb/dwc3/dwc3-st.c +++ b/drivers/usb/dwc3/dwc3-st.c @@ -206,8 +206,8 @@ static int st_dwc3_probe(struct platform_device *pdev) if (!dwc3_data) return -ENOMEM; - res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "reg-glue"); - dwc3_data->glue_base = devm_ioremap_resource(dev, res); + dwc3_data->glue_base = + devm_platform_ioremap_resource_byname(pdev, "reg-glue"); if (IS_ERR(dwc3_data->glue_base)) return PTR_ERR(dwc3_data->glue_base); -- cgit v1.2.3-70-g09d2 From c94622683443a8eab17df07b9124304f8c40c01c Mon Sep 17 00:00:00 2001 From: Chunfeng Yun Date: Wed, 22 Jul 2020 15:51:13 +0800 Subject: usb: gadget: r8a66597: convert to devm_platform_ioremap_resource_byname Use devm_platform_ioremap_resource_byname() to simplify code Signed-off-by: Chunfeng Yun Link: https://lore.kernel.org/r/1595404275-8449-5-git-send-email-chunfeng.yun@mediatek.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/udc/r8a66597-udc.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'drivers/usb') 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); } -- cgit v1.2.3-70-g09d2 From 9d4ee5bd8298a2a8c2487c4d4a105fe9ddef1d81 Mon Sep 17 00:00:00 2001 From: Chunfeng Yun Date: Wed, 22 Jul 2020 15:51:14 +0800 Subject: usb: gadget: tegra-xudc: convert to devm_platform_ioremap_resource_byname Use devm_platform_ioremap_resource_byname() to simplify code Cc: Nagarjuna Kristam Signed-off-by: Chunfeng Yun Link: https://lore.kernel.org/r/1595404275-8449-6-git-send-email-chunfeng.yun@mediatek.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/udc/tegra-xudc.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/gadget/udc/tegra-xudc.c b/drivers/usb/gadget/udc/tegra-xudc.c index 404f77806c6a..d6ff68c06911 100644 --- a/drivers/usb/gadget/udc/tegra-xudc.c +++ b/drivers/usb/gadget/udc/tegra-xudc.c @@ -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); } -- cgit v1.2.3-70-g09d2 From 2d30e408a2a6b3443d3232593e3d472584a3e9f8 Mon Sep 17 00:00:00 2001 From: Chunfeng Yun Date: Wed, 22 Jul 2020 15:51:15 +0800 Subject: usb: musb: convert to devm_platform_ioremap_resource_byname Use devm_platform_ioremap_resource_byname() to simplify code Cc: Bin Liu Signed-off-by: Chunfeng Yun Link: https://lore.kernel.org/r/1595404275-8449-7-git-send-email-chunfeng.yun@mediatek.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/musb/musb_dsps.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c index 71660491557f..19556c1a8ae8 100644 --- a/drivers/usb/musb/musb_dsps.c +++ b/drivers/usb/musb/musb_dsps.c @@ -429,12 +429,10 @@ static int dsps_musb_init(struct musb *musb) struct platform_device *parent = to_platform_device(dev->parent); const struct dsps_musb_wrapper *wrp = glue->wrp; void __iomem *reg_base; - struct resource *r; u32 rev, val; int ret; - r = platform_get_resource_byname(parent, IORESOURCE_MEM, "control"); - reg_base = devm_ioremap_resource(dev, r); + reg_base = devm_platform_ioremap_resource_byname(parent, "control"); if (IS_ERR(reg_base)) return PTR_ERR(reg_base); musb->ctrl_base = reg_base; -- cgit v1.2.3-70-g09d2 From 1841cb255da41e87bed9573915891d056f80e2e7 Mon Sep 17 00:00:00 2001 From: Forest Crossman Date: Mon, 27 Jul 2020 23:24:07 -0500 Subject: usb: xhci: define IDs for various ASMedia host controllers Not all ASMedia host controllers have a device ID that matches its part number. #define some of these IDs to make it clearer at a glance which chips require what quirks. Acked-by: Mathias Nyman Signed-off-by: Forest Crossman Link: https://lore.kernel.org/r/20200728042408.180529-2-cyrozap@gmail.com Cc: stable Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/xhci-pci.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c index 9234c82e70e4..baa5af88ca67 100644 --- a/drivers/usb/host/xhci-pci.c +++ b/drivers/usb/host/xhci-pci.c @@ -57,7 +57,9 @@ #define PCI_DEVICE_ID_AMD_PROMONTORYA_3 0x43ba #define PCI_DEVICE_ID_AMD_PROMONTORYA_2 0x43bb #define PCI_DEVICE_ID_AMD_PROMONTORYA_1 0x43bc +#define PCI_DEVICE_ID_ASMEDIA_1042_XHCI 0x1042 #define PCI_DEVICE_ID_ASMEDIA_1042A_XHCI 0x1142 +#define PCI_DEVICE_ID_ASMEDIA_2142_XHCI 0x2142 static const char hcd_name[] = "xhci_hcd"; @@ -260,13 +262,13 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci) xhci->quirks |= XHCI_LPM_SUPPORT; if (pdev->vendor == PCI_VENDOR_ID_ASMEDIA && - pdev->device == 0x1042) + pdev->device == PCI_DEVICE_ID_ASMEDIA_1042_XHCI) xhci->quirks |= XHCI_BROKEN_STREAMS; if (pdev->vendor == PCI_VENDOR_ID_ASMEDIA && - pdev->device == 0x1142) + pdev->device == PCI_DEVICE_ID_ASMEDIA_1042A_XHCI) xhci->quirks |= XHCI_TRUST_TX_LENGTH; if (pdev->vendor == PCI_VENDOR_ID_ASMEDIA && - pdev->device == 0x2142) + pdev->device == PCI_DEVICE_ID_ASMEDIA_2142_XHCI) xhci->quirks |= XHCI_NO_64BIT_SUPPORT; if (pdev->vendor == PCI_VENDOR_ID_ASMEDIA && -- cgit v1.2.3-70-g09d2 From ec37198acca7b4c17b96247697406e47aafe0605 Mon Sep 17 00:00:00 2001 From: Forest Crossman Date: Mon, 27 Jul 2020 23:24:08 -0500 Subject: usb: xhci: Fix ASMedia ASM1142 DMA addressing I've confirmed that the ASMedia ASM1142 has the same problem as the ASM2142/ASM3142, in that it too reports that it supports 64-bit DMA addresses when in fact it does not. As with the ASM2142/ASM3142, this can cause problems on systems where the upper bits matter, and adding the XHCI_NO_64BIT_SUPPORT quirk completely fixes the issue. Acked-by: Mathias Nyman Signed-off-by: Forest Crossman Cc: stable Link: https://lore.kernel.org/r/20200728042408.180529-3-cyrozap@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/xhci-pci.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'drivers/usb') diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c index baa5af88ca67..3feaafebfe58 100644 --- a/drivers/usb/host/xhci-pci.c +++ b/drivers/usb/host/xhci-pci.c @@ -59,6 +59,7 @@ #define PCI_DEVICE_ID_AMD_PROMONTORYA_1 0x43bc #define PCI_DEVICE_ID_ASMEDIA_1042_XHCI 0x1042 #define PCI_DEVICE_ID_ASMEDIA_1042A_XHCI 0x1142 +#define PCI_DEVICE_ID_ASMEDIA_1142_XHCI 0x1242 #define PCI_DEVICE_ID_ASMEDIA_2142_XHCI 0x2142 static const char hcd_name[] = "xhci_hcd"; @@ -268,7 +269,8 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci) pdev->device == PCI_DEVICE_ID_ASMEDIA_1042A_XHCI) xhci->quirks |= XHCI_TRUST_TX_LENGTH; if (pdev->vendor == PCI_VENDOR_ID_ASMEDIA && - pdev->device == PCI_DEVICE_ID_ASMEDIA_2142_XHCI) + (pdev->device == PCI_DEVICE_ID_ASMEDIA_1142_XHCI || + pdev->device == PCI_DEVICE_ID_ASMEDIA_2142_XHCI)) xhci->quirks |= XHCI_NO_64BIT_SUPPORT; if (pdev->vendor == PCI_VENDOR_ID_ASMEDIA && -- cgit v1.2.3-70-g09d2 From fde9156ad5f0db3be9acad4de52e35dc1a3243be Mon Sep 17 00:00:00 2001 From: Chunfeng Yun Date: Mon, 27 Jul 2020 15:14:50 +0800 Subject: usb: mtu3: remove unnecessary pointer checks The class driver will ensure the parameters are valid pointers before call the hook function of usb_ep_ops, so no need check them again. Signed-off-by: Chunfeng Yun Link: https://lore.kernel.org/r/1595834101-13094-1-git-send-email-chunfeng.yun@mediatek.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/mtu3/mtu3_gadget.c | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/mtu3/mtu3_gadget.c b/drivers/usb/mtu3/mtu3_gadget.c index f93732e53fd8..6b26cb8054cd 100644 --- a/drivers/usb/mtu3/mtu3_gadget.c +++ b/drivers/usb/mtu3/mtu3_gadget.c @@ -263,23 +263,15 @@ void mtu3_free_request(struct usb_ep *ep, struct usb_request *req) static int mtu3_gadget_queue(struct usb_ep *ep, struct usb_request *req, gfp_t gfp_flags) { - struct mtu3_ep *mep; - struct mtu3_request *mreq; - struct mtu3 *mtu; + struct mtu3_ep *mep = to_mtu3_ep(ep); + struct mtu3_request *mreq = to_mtu3_request(req); + struct mtu3 *mtu = mep->mtu; unsigned long flags; int ret = 0; - if (!ep || !req) - return -EINVAL; - if (!req->buf) return -ENODATA; - mep = to_mtu3_ep(ep); - mtu = mep->mtu; - mreq = to_mtu3_request(req); - mreq->mtu = mtu; - if (mreq->mep != mep) return -EINVAL; @@ -303,6 +295,7 @@ static int mtu3_gadget_queue(struct usb_ep *ep, return -ESHUTDOWN; } + mreq->mtu = mtu; mreq->request.actual = 0; mreq->request.status = -EINPROGRESS; @@ -335,11 +328,11 @@ static int mtu3_gadget_dequeue(struct usb_ep *ep, struct usb_request *req) struct mtu3_ep *mep = to_mtu3_ep(ep); struct mtu3_request *mreq = to_mtu3_request(req); struct mtu3_request *r; + struct mtu3 *mtu = mep->mtu; unsigned long flags; int ret = 0; - struct mtu3 *mtu = mep->mtu; - if (!ep || !req || mreq->mep != mep) + if (mreq->mep != mep) return -EINVAL; dev_dbg(mtu->dev, "%s : req=%p\n", __func__, req); @@ -379,9 +372,6 @@ static int mtu3_gadget_ep_set_halt(struct usb_ep *ep, int value) unsigned long flags; int ret = 0; - if (!ep) - return -EINVAL; - dev_dbg(mtu->dev, "%s : %s...", __func__, ep->name); spin_lock_irqsave(&mtu->lock, flags); @@ -424,9 +414,6 @@ static int mtu3_gadget_ep_set_wedge(struct usb_ep *ep) { struct mtu3_ep *mep = to_mtu3_ep(ep); - if (!ep) - return -EINVAL; - mep->wedged = 1; return usb_ep_set_halt(ep); -- cgit v1.2.3-70-g09d2 From c0a8d952cf0d26b01ff2929165eabd0b8707c307 Mon Sep 17 00:00:00 2001 From: Chunfeng Yun Date: Mon, 27 Jul 2020 15:14:51 +0800 Subject: usb: mtu3: fix macro for maximum number of packets The bits field for maximum number of packets is 8 bits. Signed-off-by: Chunfeng Yun Link: https://lore.kernel.org/r/1595834101-13094-2-git-send-email-chunfeng.yun@mediatek.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/mtu3/mtu3_hw_regs.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/mtu3/mtu3_hw_regs.h b/drivers/usb/mtu3/mtu3_hw_regs.h index bf34f784f84b..072db1f6470e 100644 --- a/drivers/usb/mtu3/mtu3_hw_regs.h +++ b/drivers/usb/mtu3/mtu3_hw_regs.h @@ -134,7 +134,7 @@ #define TX_W1C_BITS (~(TX_SENTSTALL)) /* U3D_TX1CSR1 */ -#define TX_MAX_PKT_G2(x) (((x) & 0x7f) << 24) +#define TX_MAX_PKT_G2(x) (((x) & 0xff) << 24) #define TX_MULT_G2(x) (((x) & 0x7) << 21) #define TX_MULT_OG(x) (((x) & 0x3) << 22) #define TX_MAX_PKT_OG(x) (((x) & 0x3f) << 16) @@ -173,7 +173,7 @@ #define RX_W1C_BITS (~(RX_SENTSTALL | RX_RXPKTRDY)) /* U3D_RX1CSR1 */ -#define RX_MAX_PKT_G2(x) (((x) & 0x7f) << 24) +#define RX_MAX_PKT_G2(x) (((x) & 0xff) << 24) #define RX_MULT_G2(x) (((x) & 0x7) << 21) #define RX_MULT_OG(x) (((x) & 0x3) << 22) #define RX_MAX_PKT_OG(x) (((x) & 0x3f) << 16) -- cgit v1.2.3-70-g09d2 From f55df11e3164e4aab1832bfe5a2f5997ee243f04 Mon Sep 17 00:00:00 2001 From: Chunfeng Yun Date: Mon, 27 Jul 2020 15:14:52 +0800 Subject: usb: mtu3: reinitialize CSR registers The CSR registers will be reset as default value if the ports are disabled, so reinitialize them when the ports are enabled again. Signed-off-by: Chunfeng Yun Link: https://lore.kernel.org/r/1595834101-13094-3-git-send-email-chunfeng.yun@mediatek.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/mtu3/mtu3_core.c | 61 +++++++++++++++++++++++--------------------- 1 file changed, 32 insertions(+), 29 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/mtu3/mtu3_core.c b/drivers/usb/mtu3/mtu3_core.c index 9c49160138f2..b4f07af7bb90 100644 --- a/drivers/usb/mtu3/mtu3_core.c +++ b/drivers/usb/mtu3/mtu3_core.c @@ -202,6 +202,36 @@ static void mtu3_intr_enable(struct mtu3 *mtu) mtu3_writel(mbase, U3D_DEV_LINK_INTR_ENABLE, SSUSB_DEV_SPEED_CHG_INTR); } +static void mtu3_set_speed(struct mtu3 *mtu); + +/* CSR registers will be reset to default value if port is disabled */ +static void mtu3_csr_init(struct mtu3 *mtu) +{ + void __iomem *mbase = mtu->mac_base; + + if (mtu->is_u3_ip) { + /* disable LGO_U1/U2 by default */ + mtu3_clrbits(mbase, U3D_LINK_POWER_CONTROL, + SW_U1_REQUEST_ENABLE | SW_U2_REQUEST_ENABLE); + /* enable accept LGO_U1/U2 link command from host */ + mtu3_setbits(mbase, U3D_LINK_POWER_CONTROL, + SW_U1_ACCEPT_ENABLE | SW_U2_ACCEPT_ENABLE); + /* device responses to u3_exit from host automatically */ + mtu3_clrbits(mbase, U3D_LTSSM_CTRL, SOFT_U3_EXIT_EN); + /* automatically build U2 link when U3 detect fail */ + mtu3_setbits(mbase, U3D_USB2_TEST_MODE, U2U3_AUTO_SWITCH); + /* auto clear SOFT_CONN when clear USB3_EN if work as HS */ + mtu3_setbits(mbase, U3D_U3U2_SWITCH_CTRL, SOFTCON_CLR_AUTO_EN); + } + + mtu3_set_speed(mtu); + + /* delay about 0.1us from detecting reset to send chirp-K */ + mtu3_clrbits(mbase, U3D_LINK_RESET_INFO, WTCHRP_MSK); + /* enable automatical HWRW from L1 */ + mtu3_setbits(mbase, U3D_POWER_MANAGEMENT, LPM_HRWE); +} + /* reset: u2 - data toggle, u3 - SeqN, flow control status etc */ static void mtu3_ep_reset(struct mtu3_ep *mep) { @@ -267,13 +297,7 @@ void mtu3_start(struct mtu3 *mtu) mtu3_clrbits(mtu->ippc_base, U3D_SSUSB_IP_PW_CTRL2, SSUSB_IP_DEV_PDN); - /* - * When disable U2 port, USB2_CSR's register will be reset to - * default value after re-enable it again(HS is enabled by default). - * So if force mac to work as FS, disable HS function. - */ - if (mtu->max_speed == USB_SPEED_FULL) - mtu3_clrbits(mbase, U3D_POWER_MANAGEMENT, HS_ENABLE); + mtu3_csr_init(mtu); /* Initialize the default interrupts */ mtu3_intr_enable(mtu); @@ -572,39 +596,18 @@ static void mtu3_set_speed(struct mtu3 *mtu) static void mtu3_regs_init(struct mtu3 *mtu) { - void __iomem *mbase = mtu->mac_base; /* be sure interrupts are disabled before registration of ISR */ mtu3_intr_disable(mtu); mtu3_intr_status_clear(mtu); - if (mtu->is_u3_ip) { - /* disable LGO_U1/U2 by default */ - mtu3_clrbits(mbase, U3D_LINK_POWER_CONTROL, - SW_U1_REQUEST_ENABLE | SW_U2_REQUEST_ENABLE); - /* enable accept LGO_U1/U2 link command from host */ - mtu3_setbits(mbase, U3D_LINK_POWER_CONTROL, - SW_U1_ACCEPT_ENABLE | SW_U2_ACCEPT_ENABLE); - /* device responses to u3_exit from host automatically */ - mtu3_clrbits(mbase, U3D_LTSSM_CTRL, SOFT_U3_EXIT_EN); - /* automatically build U2 link when U3 detect fail */ - mtu3_setbits(mbase, U3D_USB2_TEST_MODE, U2U3_AUTO_SWITCH); - /* auto clear SOFT_CONN when clear USB3_EN if work as HS */ - mtu3_setbits(mbase, U3D_U3U2_SWITCH_CTRL, SOFTCON_CLR_AUTO_EN); - } - - mtu3_set_speed(mtu); + mtu3_csr_init(mtu); - /* delay about 0.1us from detecting reset to send chirp-K */ - mtu3_clrbits(mbase, U3D_LINK_RESET_INFO, WTCHRP_MSK); /* U2/U3 detected by HW */ mtu3_writel(mbase, U3D_DEVICE_CONF, 0); /* vbus detected by HW */ mtu3_clrbits(mbase, U3D_MISC_CTRL, VBUS_FRC_EN | VBUS_ON); - /* enable automatical HWRW from L1 */ - mtu3_setbits(mbase, U3D_POWER_MANAGEMENT, LPM_HRWE); - /* use new QMU format when HW version >= 0x1003 */ if (mtu->gen2cp) mtu3_writel(mbase, U3D_QFCR, ~0x0); -- cgit v1.2.3-70-g09d2 From b7d5c3cabcec4191e22e962867904e661cb9bc84 Mon Sep 17 00:00:00 2001 From: Chunfeng Yun Date: Mon, 27 Jul 2020 15:14:53 +0800 Subject: usb: mtu3: clear interrupts status when disable interrupts When disable interrupts, will also want to clear their status, ensure it by calling mtu3_intr_status_clear() in mtu3_intr_disable(). Signed-off-by: Chunfeng Yun Link: https://lore.kernel.org/r/1595834101-13094-4-git-send-email-chunfeng.yun@mediatek.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/mtu3/mtu3_core.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/mtu3/mtu3_core.c b/drivers/usb/mtu3/mtu3_core.c index b4f07af7bb90..4958b04545da 100644 --- a/drivers/usb/mtu3/mtu3_core.c +++ b/drivers/usb/mtu3/mtu3_core.c @@ -147,17 +147,6 @@ static void mtu3_device_reset(struct mtu3 *mtu) mtu3_clrbits(ibase, U3D_SSUSB_DEV_RST_CTRL, SSUSB_DEV_SW_RST); } -/* disable all interrupts */ -static void mtu3_intr_disable(struct mtu3 *mtu) -{ - void __iomem *mbase = mtu->mac_base; - - /* Disable level 1 interrupts */ - mtu3_writel(mbase, U3D_LV1IECR, ~0x0); - /* Disable endpoint interrupts */ - mtu3_writel(mbase, U3D_EPIECR, ~0x0); -} - static void mtu3_intr_status_clear(struct mtu3 *mtu) { void __iomem *mbase = mtu->mac_base; @@ -170,6 +159,18 @@ static void mtu3_intr_status_clear(struct mtu3 *mtu) mtu3_writel(mbase, U3D_LTSSM_INTR, ~0x0); /* Clear speed change interrupt status */ mtu3_writel(mbase, U3D_DEV_LINK_INTR, ~0x0); + /* Clear QMU interrupt status */ + mtu3_writel(mbase, U3D_QISAR0, ~0x0); +} + +/* disable all interrupts */ +static void mtu3_intr_disable(struct mtu3 *mtu) +{ + /* Disable level 1 interrupts */ + mtu3_writel(mtu->mac_base, U3D_LV1IECR, ~0x0); + /* Disable endpoint interrupts */ + mtu3_writel(mtu->mac_base, U3D_EPIECR, ~0x0); + mtu3_intr_status_clear(mtu); } /* enable system global interrupt */ @@ -312,7 +313,6 @@ void mtu3_stop(struct mtu3 *mtu) dev_dbg(mtu->dev, "%s\n", __func__); mtu3_intr_disable(mtu); - mtu3_intr_status_clear(mtu); if (mtu->softconnect) mtu3_dev_on_off(mtu, 0); @@ -600,7 +600,6 @@ static void mtu3_regs_init(struct mtu3 *mtu) /* be sure interrupts are disabled before registration of ISR */ mtu3_intr_disable(mtu); - mtu3_intr_status_clear(mtu); mtu3_csr_init(mtu); -- cgit v1.2.3-70-g09d2 From 1258450ef38af7ea5b27a0a14195bb406f59cda8 Mon Sep 17 00:00:00 2001 From: Chunfeng Yun Date: Mon, 27 Jul 2020 15:14:54 +0800 Subject: usb: mtu3: introduce a funtion to check maximum speed The max_speed got from DTS may be not supported by the hardware, so need check it, and assign a proper default value. And make it clear by introducing a funtion. Signed-off-by: Chunfeng Yun Link: https://lore.kernel.org/r/1595834101-13094-5-git-send-email-chunfeng.yun@mediatek.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/mtu3/mtu3_core.c | 48 ++++++++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 20 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/mtu3/mtu3_core.c b/drivers/usb/mtu3/mtu3_core.c index 4958b04545da..c37842dbfb95 100644 --- a/drivers/usb/mtu3/mtu3_core.c +++ b/drivers/usb/mtu3/mtu3_core.c @@ -573,9 +573,6 @@ static void mtu3_set_speed(struct mtu3 *mtu) { void __iomem *mbase = mtu->mac_base; - if (!mtu->is_u3_ip && (mtu->max_speed > USB_SPEED_HIGH)) - mtu->max_speed = USB_SPEED_HIGH; - if (mtu->max_speed == USB_SPEED_FULL) { /* disable U3 SS function */ mtu3_clrbits(mbase, U3D_USB3_CONFIG, USB3_EN); @@ -761,6 +758,32 @@ static irqreturn_t mtu3_irq(int irq, void *data) return IRQ_HANDLED; } +static void mtu3_check_params(struct mtu3 *mtu) +{ + /* check the max_speed parameter */ + switch (mtu->max_speed) { + case USB_SPEED_FULL: + case USB_SPEED_HIGH: + case USB_SPEED_SUPER: + case USB_SPEED_SUPER_PLUS: + break; + default: + dev_err(mtu->dev, "invalid max_speed: %s\n", + usb_speed_string(mtu->max_speed)); + fallthrough; + case USB_SPEED_UNKNOWN: + /* default as SSP */ + mtu->max_speed = USB_SPEED_SUPER_PLUS; + break; + } + + if (!mtu->is_u3_ip && (mtu->max_speed > USB_SPEED_HIGH)) + mtu->max_speed = USB_SPEED_HIGH; + + dev_info(mtu->dev, "max_speed: %s\n", + usb_speed_string(mtu->max_speed)); +} + static int mtu3_hw_init(struct mtu3 *mtu) { u32 value; @@ -776,6 +799,8 @@ static int mtu3_hw_init(struct mtu3 *mtu) dev_info(mtu->dev, "IP version 0x%x(%s IP)\n", mtu->hw_version, mtu->is_u3_ip ? "U3" : "U2"); + mtu3_check_params(mtu); + mtu3_device_reset(mtu); ret = mtu3_device_enable(mtu); @@ -855,23 +880,6 @@ int ssusb_gadget_init(struct ssusb_mtk *ssusb) mtu->ssusb = ssusb; mtu->max_speed = usb_get_maximum_speed(dev); - /* check the max_speed parameter */ - switch (mtu->max_speed) { - case USB_SPEED_FULL: - case USB_SPEED_HIGH: - case USB_SPEED_SUPER: - case USB_SPEED_SUPER_PLUS: - break; - default: - dev_err(dev, "invalid max_speed: %s\n", - usb_speed_string(mtu->max_speed)); - /* fall through */ - case USB_SPEED_UNKNOWN: - /* default as SSP */ - mtu->max_speed = USB_SPEED_SUPER_PLUS; - break; - } - dev_dbg(dev, "mac_base=0x%p, ippc_base=0x%p\n", mtu->mac_base, mtu->ippc_base); -- cgit v1.2.3-70-g09d2 From dc4c1aa7eae99d7a69717247cc6bd1c071407104 Mon Sep 17 00:00:00 2001 From: Chunfeng Yun Date: Mon, 27 Jul 2020 15:14:55 +0800 Subject: usb: mtu3: add ->udc_set_speed() Make use of the method to make sure connect on speeds supported by the gadget driver. Signed-off-by: Chunfeng Yun Link: https://lore.kernel.org/r/1595834101-13094-6-git-send-email-chunfeng.yun@mediatek.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/mtu3/mtu3.h | 4 ++- drivers/usb/mtu3/mtu3_core.c | 68 +++++++++++++++++++++++++----------------- drivers/usb/mtu3/mtu3_gadget.c | 14 +++++++++ 3 files changed, 58 insertions(+), 28 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/mtu3/mtu3.h b/drivers/usb/mtu3/mtu3.h index d49db92ab26c..9d68f25e4c85 100644 --- a/drivers/usb/mtu3/mtu3.h +++ b/drivers/usb/mtu3/mtu3.h @@ -348,7 +348,8 @@ struct mtu3 { struct usb_gadget_driver *gadget_driver; struct mtu3_request ep0_req; u8 setup_buf[EP0_RESPONSE_BUF]; - u32 max_speed; + enum usb_device_speed max_speed; + enum usb_device_speed speed; unsigned is_active:1; unsigned may_wakeup:1; @@ -433,6 +434,7 @@ void mtu3_ep0_setup(struct mtu3 *mtu); void mtu3_start(struct mtu3 *mtu); void mtu3_stop(struct mtu3 *mtu); void mtu3_dev_on_off(struct mtu3 *mtu, int is_on); +void mtu3_set_speed(struct mtu3 *mtu, enum usb_device_speed speed); int mtu3_gadget_setup(struct mtu3 *mtu); void mtu3_gadget_cleanup(struct mtu3 *mtu); diff --git a/drivers/usb/mtu3/mtu3_core.c b/drivers/usb/mtu3/mtu3_core.c index c37842dbfb95..9e0b68b3920c 100644 --- a/drivers/usb/mtu3/mtu3_core.c +++ b/drivers/usb/mtu3/mtu3_core.c @@ -203,7 +203,42 @@ static void mtu3_intr_enable(struct mtu3 *mtu) mtu3_writel(mbase, U3D_DEV_LINK_INTR_ENABLE, SSUSB_DEV_SPEED_CHG_INTR); } -static void mtu3_set_speed(struct mtu3 *mtu); +void mtu3_set_speed(struct mtu3 *mtu, enum usb_device_speed speed) +{ + void __iomem *mbase = mtu->mac_base; + + if (speed > mtu->max_speed) + speed = mtu->max_speed; + + switch (speed) { + case USB_SPEED_FULL: + /* disable U3 SS function */ + mtu3_clrbits(mbase, U3D_USB3_CONFIG, USB3_EN); + /* disable HS function */ + mtu3_clrbits(mbase, U3D_POWER_MANAGEMENT, HS_ENABLE); + break; + case USB_SPEED_HIGH: + mtu3_clrbits(mbase, U3D_USB3_CONFIG, USB3_EN); + /* HS/FS detected by HW */ + mtu3_setbits(mbase, U3D_POWER_MANAGEMENT, HS_ENABLE); + break; + case USB_SPEED_SUPER: + mtu3_clrbits(mtu->ippc_base, SSUSB_U3_CTRL(0), + SSUSB_U3_PORT_SSP_SPEED); + break; + case USB_SPEED_SUPER_PLUS: + mtu3_setbits(mtu->ippc_base, SSUSB_U3_CTRL(0), + SSUSB_U3_PORT_SSP_SPEED); + break; + default: + dev_err(mtu->dev, "invalid speed: %s\n", + usb_speed_string(speed)); + return; + } + + mtu->speed = speed; + dev_dbg(mtu->dev, "set speed: %s\n", usb_speed_string(speed)); +} /* CSR registers will be reset to default value if port is disabled */ static void mtu3_csr_init(struct mtu3 *mtu) @@ -225,8 +260,6 @@ static void mtu3_csr_init(struct mtu3 *mtu) mtu3_setbits(mbase, U3D_U3U2_SWITCH_CTRL, SOFTCON_CLR_AUTO_EN); } - mtu3_set_speed(mtu); - /* delay about 0.1us from detecting reset to send chirp-K */ mtu3_clrbits(mbase, U3D_LINK_RESET_INFO, WTCHRP_MSK); /* enable automatical HWRW from L1 */ @@ -280,13 +313,13 @@ void mtu3_ep_stall_set(struct mtu3_ep *mep, bool set) void mtu3_dev_on_off(struct mtu3 *mtu, int is_on) { - if (mtu->is_u3_ip && mtu->max_speed >= USB_SPEED_SUPER) + if (mtu->is_u3_ip && mtu->speed >= USB_SPEED_SUPER) mtu3_ss_func_set(mtu, is_on); else mtu3_hs_softconn_set(mtu, is_on); dev_info(mtu->dev, "gadget (%s) pullup D%s\n", - usb_speed_string(mtu->max_speed), is_on ? "+" : "-"); + usb_speed_string(mtu->speed), is_on ? "+" : "-"); } void mtu3_start(struct mtu3 *mtu) @@ -299,6 +332,7 @@ void mtu3_start(struct mtu3 *mtu) mtu3_clrbits(mtu->ippc_base, U3D_SSUSB_IP_PW_CTRL2, SSUSB_IP_DEV_PDN); mtu3_csr_init(mtu); + mtu3_set_speed(mtu, mtu->speed); /* Initialize the default interrupts */ mtu3_intr_enable(mtu); @@ -569,28 +603,6 @@ static void mtu3_mem_free(struct mtu3 *mtu) kfree(mtu->ep_array); } -static void mtu3_set_speed(struct mtu3 *mtu) -{ - void __iomem *mbase = mtu->mac_base; - - if (mtu->max_speed == USB_SPEED_FULL) { - /* disable U3 SS function */ - mtu3_clrbits(mbase, U3D_USB3_CONFIG, USB3_EN); - /* disable HS function */ - mtu3_clrbits(mbase, U3D_POWER_MANAGEMENT, HS_ENABLE); - } else if (mtu->max_speed == USB_SPEED_HIGH) { - mtu3_clrbits(mbase, U3D_USB3_CONFIG, USB3_EN); - /* HS/FS detected by HW */ - mtu3_setbits(mbase, U3D_POWER_MANAGEMENT, HS_ENABLE); - } else if (mtu->max_speed == USB_SPEED_SUPER) { - mtu3_clrbits(mtu->ippc_base, SSUSB_U3_CTRL(0), - SSUSB_U3_PORT_SSP_SPEED); - } - - dev_info(mtu->dev, "max_speed: %s\n", - usb_speed_string(mtu->max_speed)); -} - static void mtu3_regs_init(struct mtu3 *mtu) { void __iomem *mbase = mtu->mac_base; @@ -780,6 +792,8 @@ static void mtu3_check_params(struct mtu3 *mtu) if (!mtu->is_u3_ip && (mtu->max_speed > USB_SPEED_HIGH)) mtu->max_speed = USB_SPEED_HIGH; + mtu->speed = mtu->max_speed; + dev_info(mtu->dev, "max_speed: %s\n", usb_speed_string(mtu->max_speed)); } diff --git a/drivers/usb/mtu3/mtu3_gadget.c b/drivers/usb/mtu3/mtu3_gadget.c index 6b26cb8054cd..3d1312972bfe 100644 --- a/drivers/usb/mtu3/mtu3_gadget.c +++ b/drivers/usb/mtu3/mtu3_gadget.c @@ -577,6 +577,19 @@ static int mtu3_gadget_stop(struct usb_gadget *g) return 0; } +static void +mtu3_gadget_set_speed(struct usb_gadget *g, enum usb_device_speed speed) +{ + struct mtu3 *mtu = gadget_to_mtu3(g); + unsigned long flags; + + dev_dbg(mtu->dev, "%s %s\n", __func__, usb_speed_string(speed)); + + spin_lock_irqsave(&mtu->lock, flags); + mtu3_set_speed(mtu, speed); + spin_unlock_irqrestore(&mtu->lock, flags); +} + static const struct usb_gadget_ops mtu3_gadget_ops = { .get_frame = mtu3_gadget_get_frame, .wakeup = mtu3_gadget_wakeup, @@ -584,6 +597,7 @@ static const struct usb_gadget_ops mtu3_gadget_ops = { .pullup = mtu3_gadget_pullup, .udc_start = mtu3_gadget_start, .udc_stop = mtu3_gadget_stop, + .udc_set_speed = mtu3_gadget_set_speed, }; static void mtu3_state_reset(struct mtu3 *mtu) -- cgit v1.2.3-70-g09d2 From ba428976a8827f596093ed1c55fc8cabac21249e Mon Sep 17 00:00:00 2001 From: Chunfeng Yun Date: Mon, 27 Jul 2020 15:14:56 +0800 Subject: usb: mtu3: remove repeated error log The caller already print error log. Signed-off-by: Chunfeng Yun Link: https://lore.kernel.org/r/1595834101-13094-7-git-send-email-chunfeng.yun@mediatek.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/mtu3/mtu3_gadget.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/mtu3/mtu3_gadget.c b/drivers/usb/mtu3/mtu3_gadget.c index 3d1312972bfe..2bc9a959d8fc 100644 --- a/drivers/usb/mtu3/mtu3_gadget.c +++ b/drivers/usb/mtu3/mtu3_gadget.c @@ -673,8 +673,6 @@ static void mtu3_gadget_init_eps(struct mtu3 *mtu) int mtu3_gadget_setup(struct mtu3 *mtu) { - int ret; - mtu->g.ops = &mtu3_gadget_ops; mtu->g.max_speed = mtu->max_speed; mtu->g.speed = USB_SPEED_UNKNOWN; @@ -685,11 +683,7 @@ int mtu3_gadget_setup(struct mtu3 *mtu) mtu3_gadget_init_eps(mtu); - ret = usb_add_gadget_udc(mtu->dev, &mtu->g); - if (ret) - dev_err(mtu->dev, "failed to register udc\n"); - - return ret; + return usb_add_gadget_udc(mtu->dev, &mtu->g); } void mtu3_gadget_cleanup(struct mtu3 *mtu) -- cgit v1.2.3-70-g09d2 From bf77804b1cbdeb78b89a0584b7e225ceba862183 Mon Sep 17 00:00:00 2001 From: Chunfeng Yun Date: Mon, 27 Jul 2020 15:14:57 +0800 Subject: usb: mtu3: remove useless member @busy in mtu3_ep struct The member @busy in mtu3_ep struct is unnecessary, so remove it. Signed-off-by: Chunfeng Yun Link: https://lore.kernel.org/r/1595834101-13094-8-git-send-email-chunfeng.yun@mediatek.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/mtu3/mtu3.h | 1 - drivers/usb/mtu3/mtu3_gadget.c | 6 ------ 2 files changed, 7 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/mtu3/mtu3.h b/drivers/usb/mtu3/mtu3.h index 9d68f25e4c85..8fd83bd13319 100644 --- a/drivers/usb/mtu3/mtu3.h +++ b/drivers/usb/mtu3/mtu3.h @@ -294,7 +294,6 @@ struct mtu3_ep { int flags; u8 wedged; - u8 busy; }; struct mtu3_request { diff --git a/drivers/usb/mtu3/mtu3_gadget.c b/drivers/usb/mtu3/mtu3_gadget.c index 2bc9a959d8fc..ef9fcd5dc869 100644 --- a/drivers/usb/mtu3/mtu3_gadget.c +++ b/drivers/usb/mtu3/mtu3_gadget.c @@ -17,7 +17,6 @@ __acquires(mep->mtu->lock) { struct mtu3_request *mreq; struct mtu3 *mtu; - int busy = mep->busy; mreq = to_mtu3_request(req); list_del(&mreq->list); @@ -25,8 +24,6 @@ __acquires(mep->mtu->lock) mreq->request.status = status; mtu = mreq->mtu; - mep->busy = 1; - trace_mtu3_req_complete(mreq); spin_unlock(&mtu->lock); @@ -40,14 +37,12 @@ __acquires(mep->mtu->lock) usb_gadget_giveback_request(&mep->ep, &mreq->request); spin_lock(&mtu->lock); - mep->busy = busy; } static void nuke(struct mtu3_ep *mep, const int status) { struct mtu3_request *mreq = NULL; - mep->busy = 1; if (list_empty(&mep->req_list)) return; @@ -195,7 +190,6 @@ static int mtu3_gadget_ep_enable(struct usb_ep *ep, if (ret) goto error; - mep->busy = 0; mep->wedged = 0; mep->flags |= MTU3_EP_ENABLED; mtu->active_ep++; -- cgit v1.2.3-70-g09d2 From 54402373c45e440f2e71f7a02cd5c8889abec085 Mon Sep 17 00:00:00 2001 From: Chunfeng Yun Date: Mon, 27 Jul 2020 15:14:58 +0800 Subject: usb: mtu3: use MTU3_EP_WEDGE flag Use MTU3_EP_WEDGE flag instead of the member @wedged in mtu3_ep struct, then @wedged can be removed. Signed-off-by: Chunfeng Yun Link: https://lore.kernel.org/r/1595834101-13094-9-git-send-email-chunfeng.yun@mediatek.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/mtu3/mtu3.h | 1 - drivers/usb/mtu3/mtu3_gadget.c | 9 ++++----- drivers/usb/mtu3/mtu3_gadget_ep0.c | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/mtu3/mtu3.h b/drivers/usb/mtu3/mtu3.h index 8fd83bd13319..71f4f02c05c6 100644 --- a/drivers/usb/mtu3/mtu3.h +++ b/drivers/usb/mtu3/mtu3.h @@ -293,7 +293,6 @@ struct mtu3_ep { const struct usb_endpoint_descriptor *desc; int flags; - u8 wedged; }; struct mtu3_request { diff --git a/drivers/usb/mtu3/mtu3_gadget.c b/drivers/usb/mtu3/mtu3_gadget.c index ef9fcd5dc869..73a85369eb95 100644 --- a/drivers/usb/mtu3/mtu3_gadget.c +++ b/drivers/usb/mtu3/mtu3_gadget.c @@ -190,8 +190,7 @@ static int mtu3_gadget_ep_enable(struct usb_ep *ep, if (ret) goto error; - mep->wedged = 0; - mep->flags |= MTU3_EP_ENABLED; + mep->flags = MTU3_EP_ENABLED; mtu->active_ep++; error: @@ -219,7 +218,7 @@ static int mtu3_gadget_ep_disable(struct usb_ep *ep) spin_lock_irqsave(&mtu->lock, flags); mtu3_ep_disable(mep); - mep->flags &= ~MTU3_EP_ENABLED; + mep->flags = 0; mtu->active_ep--; spin_unlock_irqrestore(&(mtu->lock), flags); @@ -389,7 +388,7 @@ static int mtu3_gadget_ep_set_halt(struct usb_ep *ep, int value) goto done; } } else { - mep->wedged = 0; + mep->flags &= ~MTU3_EP_WEDGE; } dev_dbg(mtu->dev, "%s %s stall\n", ep->name, value ? "set" : "clear"); @@ -408,7 +407,7 @@ static int mtu3_gadget_ep_set_wedge(struct usb_ep *ep) { struct mtu3_ep *mep = to_mtu3_ep(ep); - mep->wedged = 1; + mep->flags |= MTU3_EP_WEDGE; return usb_ep_set_halt(ep); } diff --git a/drivers/usb/mtu3/mtu3_gadget_ep0.c b/drivers/usb/mtu3/mtu3_gadget_ep0.c index 563a0a2e970d..0ca47212f1ec 100644 --- a/drivers/usb/mtu3/mtu3_gadget_ep0.c +++ b/drivers/usb/mtu3/mtu3_gadget_ep0.c @@ -417,7 +417,7 @@ static int ep0_handle_feature(struct mtu3 *mtu, handled = 1; /* ignore request if endpoint is wedged */ - if (mep->wedged) + if (mep->flags & MTU3_EP_WEDGE) break; mtu3_ep_stall_set(mep, set); -- cgit v1.2.3-70-g09d2 From f1e51e99ed498d4aa9ae5df28e43d558ea627781 Mon Sep 17 00:00:00 2001 From: Chunfeng Yun Date: Mon, 27 Jul 2020 15:14:59 +0800 Subject: usb: mtu3: clear dual mode of u3port when disable device If not clear u3port's dual mode when disable device, the IP will fail to enter sleep mode when suspend. Signed-off-by: Chunfeng Yun Link: https://lore.kernel.org/r/1595834101-13094-10-git-send-email-chunfeng.yun@mediatek.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/mtu3/mtu3_core.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'drivers/usb') diff --git a/drivers/usb/mtu3/mtu3_core.c b/drivers/usb/mtu3/mtu3_core.c index 9e0b68b3920c..b3b459937566 100644 --- a/drivers/usb/mtu3/mtu3_core.c +++ b/drivers/usb/mtu3/mtu3_core.c @@ -131,8 +131,12 @@ static void mtu3_device_disable(struct mtu3 *mtu) mtu3_setbits(ibase, SSUSB_U2_CTRL(0), SSUSB_U2_PORT_DIS | SSUSB_U2_PORT_PDN); - if (mtu->ssusb->dr_mode == USB_DR_MODE_OTG) + if (mtu->ssusb->dr_mode == USB_DR_MODE_OTG) { mtu3_clrbits(ibase, SSUSB_U2_CTRL(0), SSUSB_U2_PORT_OTG_SEL); + if (mtu->is_u3_ip) + mtu3_clrbits(ibase, SSUSB_U3_CTRL(0), + SSUSB_U3_PORT_DUAL_MODE); + } mtu3_setbits(ibase, U3D_SSUSB_IP_PW_CTRL2, SSUSB_IP_DEV_PDN); } -- cgit v1.2.3-70-g09d2 From ab4dc051d7b39ce31dd7a7c1d7c64fef69178050 Mon Sep 17 00:00:00 2001 From: Chunfeng Yun Date: Mon, 27 Jul 2020 15:15:00 +0800 Subject: usb: mtu3: simplify mtu3_req_complete() Use argument req directly instead of mreq->request, they are the same usb request. Signed-off-by: Chunfeng Yun Link: https://lore.kernel.org/r/1595834101-13094-11-git-send-email-chunfeng.yun@mediatek.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/mtu3/mtu3_gadget.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/mtu3/mtu3_gadget.c b/drivers/usb/mtu3/mtu3_gadget.c index 73a85369eb95..1de5c9a1d20a 100644 --- a/drivers/usb/mtu3/mtu3_gadget.c +++ b/drivers/usb/mtu3/mtu3_gadget.c @@ -15,15 +15,13 @@ void mtu3_req_complete(struct mtu3_ep *mep, __releases(mep->mtu->lock) __acquires(mep->mtu->lock) { - struct mtu3_request *mreq; - struct mtu3 *mtu; + struct mtu3_request *mreq = to_mtu3_request(req); + struct mtu3 *mtu = mreq->mtu; - mreq = to_mtu3_request(req); list_del(&mreq->list); - if (mreq->request.status == -EINPROGRESS) - mreq->request.status = status; + if (req->status == -EINPROGRESS) + req->status = status; - mtu = mreq->mtu; trace_mtu3_req_complete(mreq); spin_unlock(&mtu->lock); @@ -31,11 +29,10 @@ __acquires(mep->mtu->lock) if (mep->epnum) usb_gadget_unmap_request(&mtu->g, req, mep->is_in); - dev_dbg(mtu->dev, "%s complete req: %p, sts %d, %d/%d\n", mep->name, - req, req->status, mreq->request.actual, mreq->request.length); - - usb_gadget_giveback_request(&mep->ep, &mreq->request); + dev_dbg(mtu->dev, "%s complete req: %p, sts %d, %d/%d\n", + mep->name, req, req->status, req->actual, req->length); + usb_gadget_giveback_request(&mep->ep, req); spin_lock(&mtu->lock); } -- cgit v1.2.3-70-g09d2 From e3ee0e740c3887d2293e8d54a8707218d70d86ca Mon Sep 17 00:00:00 2001 From: Paul Cercueil Date: Mon, 27 Jul 2020 19:04:13 +0200 Subject: usb: common: usb-conn-gpio: Register charger Register a power supply charger, whose online state depends on whether the USB role is set to device or not. This is useful when the USB role is the only way to know if the device is charging from USB. The API is the standard power supply charger API, you get a /sys/class/power_supply/xxx/online node which tells you the state of the charger. The sole purpose of this is to give userspace applications a way to know whether or not the charger is plugged. Signed-off-by: Paul Cercueil Link: https://lore.kernel.org/r/20200727170413.23131-1-paul@crapouillou.net Signed-off-by: Greg Kroah-Hartman --- drivers/usb/common/Kconfig | 1 + drivers/usb/common/usb-conn-gpio.c | 45 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) (limited to 'drivers/usb') diff --git a/drivers/usb/common/Kconfig b/drivers/usb/common/Kconfig index d611477aae41..5e8a04e3dd3c 100644 --- a/drivers/usb/common/Kconfig +++ b/drivers/usb/common/Kconfig @@ -40,6 +40,7 @@ config USB_CONN_GPIO tristate "USB GPIO Based Connection Detection Driver" depends on GPIOLIB select USB_ROLE_SWITCH + select POWER_SUPPLY help The driver supports USB role switch between host and device via GPIO based USB cable detection, used typically if an input GPIO is used diff --git a/drivers/usb/common/usb-conn-gpio.c b/drivers/usb/common/usb-conn-gpio.c index b4051f042c79..7b3a21360d7c 100644 --- a/drivers/usb/common/usb-conn-gpio.c +++ b/drivers/usb/common/usb-conn-gpio.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -38,6 +39,9 @@ struct usb_conn_info { struct gpio_desc *vbus_gpiod; int id_irq; int vbus_irq; + + struct power_supply_desc desc; + struct power_supply *charger; }; /* @@ -104,6 +108,8 @@ static void usb_conn_detect_cable(struct work_struct *work) dev_dbg(info->dev, "vbus regulator is %s\n", regulator_is_enabled(info->vbus) ? "enabled" : "disabled"); + + power_supply_changed(info->charger); } static void usb_conn_queue_dwork(struct usb_conn_info *info, @@ -121,10 +127,35 @@ static irqreturn_t usb_conn_isr(int irq, void *dev_id) return IRQ_HANDLED; } +static enum power_supply_property usb_charger_properties[] = { + POWER_SUPPLY_PROP_ONLINE, +}; + +static int usb_charger_get_property(struct power_supply *psy, + enum power_supply_property psp, + union power_supply_propval *val) +{ + struct usb_conn_info *info = power_supply_get_drvdata(psy); + + switch (psp) { + case POWER_SUPPLY_PROP_ONLINE: + val->intval = info->last_role == USB_ROLE_DEVICE; + break; + default: + return -EINVAL; + } + + return 0; +} + static int usb_conn_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; + struct power_supply_desc *desc; struct usb_conn_info *info; + struct power_supply_config cfg = { + .of_node = dev->of_node, + }; int ret = 0; info = devm_kzalloc(dev, sizeof(*info), GFP_KERNEL); @@ -203,6 +234,20 @@ static int usb_conn_probe(struct platform_device *pdev) } } + desc = &info->desc; + desc->name = "usb-charger"; + desc->properties = usb_charger_properties; + desc->num_properties = ARRAY_SIZE(usb_charger_properties); + desc->get_property = usb_charger_get_property; + desc->type = POWER_SUPPLY_TYPE_USB; + cfg.drv_data = info; + + info->charger = devm_power_supply_register(dev, desc, &cfg); + if (IS_ERR(info->charger)) { + dev_err(dev, "Unable to register charger\n"); + return PTR_ERR(info->charger); + } + platform_set_drvdata(pdev, info); /* Perform initial detection */ -- cgit v1.2.3-70-g09d2