Skip to content

Commit c0655fe

Browse files
committed
Merge tag 'usb-4.1-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb
Pull USB fixes from Greg KH: "Here are some USB fixes and new device ids for 4.1-rc4. All are pretty minor, and have been in linux-next successfully" * tag 'usb-4.1-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: usb-storage: Add NO_WP_DETECT quirk for Lacie 059f:0651 devices Added another USB product ID for ELAN touchscreen quirks. xhci: gracefully handle xhci_irq dead device xhci: Solve full event ring by increasing TRBS_PER_SEGMENT to 256 xhci: fix isoc endpoint dequeue from advancing too far on transaction error usb: chipidea: debug: avoid out of bound read USB: visor: Match I330 phone more precisely USB: pl2303: Remove support for Samsung I330 USB: cp210x: add ID for KCF Technologies PRN device usb: gadget: remove incorrect __init/__exit annotations usb: phy: isp1301: work around tps65010 dependency usb: gadget: serial: fix re-ordering of tx data usb: gadget: hid: Fix static variable usage usb: gadget: configfs: Fix interfaces array NULL-termination usb: gadget: xilinx: fix devm_ioremap_resource() check usb: dwc3: dwc3-omap: correct the register macros
2 parents dd8edd7 + 5691926 commit c0655fe

38 files changed

+171
-140
lines changed

drivers/usb/chipidea/debug.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,13 @@ static ssize_t ci_port_test_write(struct file *file, const char __user *ubuf,
8888
char buf[32];
8989
int ret;
9090

91-
if (copy_from_user(buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
91+
count = min_t(size_t, sizeof(buf) - 1, count);
92+
if (copy_from_user(buf, ubuf, count))
9293
return -EFAULT;
9394

95+
/* sscanf requires a zero terminated string */
96+
buf[count] = '\0';
97+
9498
if (sscanf(buf, "%u", &mode) != 1)
9599
return -EINVAL;
96100

drivers/usb/core/quirks.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ static const struct usb_device_id usb_quirk_list[] = {
106106
{ USB_DEVICE(0x04f3, 0x010c), .driver_info =
107107
USB_QUIRK_DEVICE_QUALIFIER },
108108

109+
{ USB_DEVICE(0x04f3, 0x0125), .driver_info =
110+
USB_QUIRK_DEVICE_QUALIFIER },
111+
109112
{ USB_DEVICE(0x04f3, 0x016f), .driver_info =
110113
USB_QUIRK_DEVICE_QUALIFIER },
111114

drivers/usb/dwc3/dwc3-omap.c

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@
6565
#define USBOTGSS_IRQENABLE_SET_MISC 0x003c
6666
#define USBOTGSS_IRQENABLE_CLR_MISC 0x0040
6767
#define USBOTGSS_IRQMISC_OFFSET 0x03fc
68-
#define USBOTGSS_UTMI_OTG_CTRL 0x0080
69-
#define USBOTGSS_UTMI_OTG_STATUS 0x0084
68+
#define USBOTGSS_UTMI_OTG_STATUS 0x0080
69+
#define USBOTGSS_UTMI_OTG_CTRL 0x0084
7070
#define USBOTGSS_UTMI_OTG_OFFSET 0x0480
7171
#define USBOTGSS_TXFIFO_DEPTH 0x0508
7272
#define USBOTGSS_RXFIFO_DEPTH 0x050c
@@ -98,28 +98,28 @@
9898
#define USBOTGSS_IRQMISC_DISCHRGVBUS_FALL (1 << 3)
9999
#define USBOTGSS_IRQMISC_IDPULLUP_FALL (1 << 0)
100100

101-
/* UTMI_OTG_CTRL REGISTER */
102-
#define USBOTGSS_UTMI_OTG_CTRL_DRVVBUS (1 << 5)
103-
#define USBOTGSS_UTMI_OTG_CTRL_CHRGVBUS (1 << 4)
104-
#define USBOTGSS_UTMI_OTG_CTRL_DISCHRGVBUS (1 << 3)
105-
#define USBOTGSS_UTMI_OTG_CTRL_IDPULLUP (1 << 0)
106-
107101
/* UTMI_OTG_STATUS REGISTER */
108-
#define USBOTGSS_UTMI_OTG_STATUS_SW_MODE (1 << 31)
109-
#define USBOTGSS_UTMI_OTG_STATUS_POWERPRESENT (1 << 9)
110-
#define USBOTGSS_UTMI_OTG_STATUS_TXBITSTUFFENABLE (1 << 8)
111-
#define USBOTGSS_UTMI_OTG_STATUS_IDDIG (1 << 4)
112-
#define USBOTGSS_UTMI_OTG_STATUS_SESSEND (1 << 3)
113-
#define USBOTGSS_UTMI_OTG_STATUS_SESSVALID (1 << 2)
114-
#define USBOTGSS_UTMI_OTG_STATUS_VBUSVALID (1 << 1)
102+
#define USBOTGSS_UTMI_OTG_STATUS_DRVVBUS (1 << 5)
103+
#define USBOTGSS_UTMI_OTG_STATUS_CHRGVBUS (1 << 4)
104+
#define USBOTGSS_UTMI_OTG_STATUS_DISCHRGVBUS (1 << 3)
105+
#define USBOTGSS_UTMI_OTG_STATUS_IDPULLUP (1 << 0)
106+
107+
/* UTMI_OTG_CTRL REGISTER */
108+
#define USBOTGSS_UTMI_OTG_CTRL_SW_MODE (1 << 31)
109+
#define USBOTGSS_UTMI_OTG_CTRL_POWERPRESENT (1 << 9)
110+
#define USBOTGSS_UTMI_OTG_CTRL_TXBITSTUFFENABLE (1 << 8)
111+
#define USBOTGSS_UTMI_OTG_CTRL_IDDIG (1 << 4)
112+
#define USBOTGSS_UTMI_OTG_CTRL_SESSEND (1 << 3)
113+
#define USBOTGSS_UTMI_OTG_CTRL_SESSVALID (1 << 2)
114+
#define USBOTGSS_UTMI_OTG_CTRL_VBUSVALID (1 << 1)
115115

116116
struct dwc3_omap {
117117
struct device *dev;
118118

119119
int irq;
120120
void __iomem *base;
121121

122-
u32 utmi_otg_status;
122+
u32 utmi_otg_ctrl;
123123
u32 utmi_otg_offset;
124124
u32 irqmisc_offset;
125125
u32 irq_eoi_offset;
@@ -153,15 +153,15 @@ static inline void dwc3_omap_writel(void __iomem *base, u32 offset, u32 value)
153153
writel(value, base + offset);
154154
}
155155

156-
static u32 dwc3_omap_read_utmi_status(struct dwc3_omap *omap)
156+
static u32 dwc3_omap_read_utmi_ctrl(struct dwc3_omap *omap)
157157
{
158-
return dwc3_omap_readl(omap->base, USBOTGSS_UTMI_OTG_STATUS +
158+
return dwc3_omap_readl(omap->base, USBOTGSS_UTMI_OTG_CTRL +
159159
omap->utmi_otg_offset);
160160
}
161161

162-
static void dwc3_omap_write_utmi_status(struct dwc3_omap *omap, u32 value)
162+
static void dwc3_omap_write_utmi_ctrl(struct dwc3_omap *omap, u32 value)
163163
{
164-
dwc3_omap_writel(omap->base, USBOTGSS_UTMI_OTG_STATUS +
164+
dwc3_omap_writel(omap->base, USBOTGSS_UTMI_OTG_CTRL +
165165
omap->utmi_otg_offset, value);
166166

167167
}
@@ -235,25 +235,25 @@ static void dwc3_omap_set_mailbox(struct dwc3_omap *omap,
235235
}
236236
}
237237

238-
val = dwc3_omap_read_utmi_status(omap);
239-
val &= ~(USBOTGSS_UTMI_OTG_STATUS_IDDIG
240-
| USBOTGSS_UTMI_OTG_STATUS_VBUSVALID
241-
| USBOTGSS_UTMI_OTG_STATUS_SESSEND);
242-
val |= USBOTGSS_UTMI_OTG_STATUS_SESSVALID
243-
| USBOTGSS_UTMI_OTG_STATUS_POWERPRESENT;
244-
dwc3_omap_write_utmi_status(omap, val);
238+
val = dwc3_omap_read_utmi_ctrl(omap);
239+
val &= ~(USBOTGSS_UTMI_OTG_CTRL_IDDIG
240+
| USBOTGSS_UTMI_OTG_CTRL_VBUSVALID
241+
| USBOTGSS_UTMI_OTG_CTRL_SESSEND);
242+
val |= USBOTGSS_UTMI_OTG_CTRL_SESSVALID
243+
| USBOTGSS_UTMI_OTG_CTRL_POWERPRESENT;
244+
dwc3_omap_write_utmi_ctrl(omap, val);
245245
break;
246246

247247
case OMAP_DWC3_VBUS_VALID:
248248
dev_dbg(omap->dev, "VBUS Connect\n");
249249

250-
val = dwc3_omap_read_utmi_status(omap);
251-
val &= ~USBOTGSS_UTMI_OTG_STATUS_SESSEND;
252-
val |= USBOTGSS_UTMI_OTG_STATUS_IDDIG
253-
| USBOTGSS_UTMI_OTG_STATUS_VBUSVALID
254-
| USBOTGSS_UTMI_OTG_STATUS_SESSVALID
255-
| USBOTGSS_UTMI_OTG_STATUS_POWERPRESENT;
256-
dwc3_omap_write_utmi_status(omap, val);
250+
val = dwc3_omap_read_utmi_ctrl(omap);
251+
val &= ~USBOTGSS_UTMI_OTG_CTRL_SESSEND;
252+
val |= USBOTGSS_UTMI_OTG_CTRL_IDDIG
253+
| USBOTGSS_UTMI_OTG_CTRL_VBUSVALID
254+
| USBOTGSS_UTMI_OTG_CTRL_SESSVALID
255+
| USBOTGSS_UTMI_OTG_CTRL_POWERPRESENT;
256+
dwc3_omap_write_utmi_ctrl(omap, val);
257257
break;
258258

259259
case OMAP_DWC3_ID_FLOAT:
@@ -263,13 +263,13 @@ static void dwc3_omap_set_mailbox(struct dwc3_omap *omap,
263263
case OMAP_DWC3_VBUS_OFF:
264264
dev_dbg(omap->dev, "VBUS Disconnect\n");
265265

266-
val = dwc3_omap_read_utmi_status(omap);
267-
val &= ~(USBOTGSS_UTMI_OTG_STATUS_SESSVALID
268-
| USBOTGSS_UTMI_OTG_STATUS_VBUSVALID
269-
| USBOTGSS_UTMI_OTG_STATUS_POWERPRESENT);
270-
val |= USBOTGSS_UTMI_OTG_STATUS_SESSEND
271-
| USBOTGSS_UTMI_OTG_STATUS_IDDIG;
272-
dwc3_omap_write_utmi_status(omap, val);
266+
val = dwc3_omap_read_utmi_ctrl(omap);
267+
val &= ~(USBOTGSS_UTMI_OTG_CTRL_SESSVALID
268+
| USBOTGSS_UTMI_OTG_CTRL_VBUSVALID
269+
| USBOTGSS_UTMI_OTG_CTRL_POWERPRESENT);
270+
val |= USBOTGSS_UTMI_OTG_CTRL_SESSEND
271+
| USBOTGSS_UTMI_OTG_CTRL_IDDIG;
272+
dwc3_omap_write_utmi_ctrl(omap, val);
273273
break;
274274

275275
default:
@@ -422,22 +422,22 @@ static void dwc3_omap_set_utmi_mode(struct dwc3_omap *omap)
422422
struct device_node *node = omap->dev->of_node;
423423
int utmi_mode = 0;
424424

425-
reg = dwc3_omap_read_utmi_status(omap);
425+
reg = dwc3_omap_read_utmi_ctrl(omap);
426426

427427
of_property_read_u32(node, "utmi-mode", &utmi_mode);
428428

429429
switch (utmi_mode) {
430430
case DWC3_OMAP_UTMI_MODE_SW:
431-
reg |= USBOTGSS_UTMI_OTG_STATUS_SW_MODE;
431+
reg |= USBOTGSS_UTMI_OTG_CTRL_SW_MODE;
432432
break;
433433
case DWC3_OMAP_UTMI_MODE_HW:
434-
reg &= ~USBOTGSS_UTMI_OTG_STATUS_SW_MODE;
434+
reg &= ~USBOTGSS_UTMI_OTG_CTRL_SW_MODE;
435435
break;
436436
default:
437437
dev_dbg(omap->dev, "UNKNOWN utmi mode %d\n", utmi_mode);
438438
}
439439

440-
dwc3_omap_write_utmi_status(omap, reg);
440+
dwc3_omap_write_utmi_ctrl(omap, reg);
441441
}
442442

443443
static int dwc3_omap_extcon_register(struct dwc3_omap *omap)
@@ -614,7 +614,7 @@ static int dwc3_omap_suspend(struct device *dev)
614614
{
615615
struct dwc3_omap *omap = dev_get_drvdata(dev);
616616

617-
omap->utmi_otg_status = dwc3_omap_read_utmi_status(omap);
617+
omap->utmi_otg_ctrl = dwc3_omap_read_utmi_ctrl(omap);
618618
dwc3_omap_disable_irqs(omap);
619619

620620
return 0;
@@ -624,7 +624,7 @@ static int dwc3_omap_resume(struct device *dev)
624624
{
625625
struct dwc3_omap *omap = dev_get_drvdata(dev);
626626

627-
dwc3_omap_write_utmi_status(omap, omap->utmi_otg_status);
627+
dwc3_omap_write_utmi_ctrl(omap, omap->utmi_otg_ctrl);
628628
dwc3_omap_enable_irqs(omap);
629629

630630
pm_runtime_disable(dev);

drivers/usb/gadget/configfs.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1295,6 +1295,7 @@ static void purge_configs_funcs(struct gadget_info *gi)
12951295
}
12961296
}
12971297
c->next_interface_id = 0;
1298+
memset(c->interface, 0, sizeof(c->interface));
12981299
c->superspeed = 0;
12991300
c->highspeed = 0;
13001301
c->fullspeed = 0;

drivers/usb/gadget/function/f_hid.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -437,12 +437,20 @@ static int hidg_setup(struct usb_function *f,
437437
| USB_REQ_GET_DESCRIPTOR):
438438
switch (value >> 8) {
439439
case HID_DT_HID:
440+
{
441+
struct hid_descriptor hidg_desc_copy = hidg_desc;
442+
440443
VDBG(cdev, "USB_REQ_GET_DESCRIPTOR: HID\n");
444+
hidg_desc_copy.desc[0].bDescriptorType = HID_DT_REPORT;
445+
hidg_desc_copy.desc[0].wDescriptorLength =
446+
cpu_to_le16(hidg->report_desc_length);
447+
441448
length = min_t(unsigned short, length,
442-
hidg_desc.bLength);
443-
memcpy(req->buf, &hidg_desc, length);
449+
hidg_desc_copy.bLength);
450+
memcpy(req->buf, &hidg_desc_copy, length);
444451
goto respond;
445452
break;
453+
}
446454
case HID_DT_REPORT:
447455
VDBG(cdev, "USB_REQ_GET_DESCRIPTOR: REPORT\n");
448456
length = min_t(unsigned short, length,
@@ -632,6 +640,10 @@ static int hidg_bind(struct usb_configuration *c, struct usb_function *f)
632640
hidg_fs_in_ep_desc.wMaxPacketSize = cpu_to_le16(hidg->report_length);
633641
hidg_hs_out_ep_desc.wMaxPacketSize = cpu_to_le16(hidg->report_length);
634642
hidg_fs_out_ep_desc.wMaxPacketSize = cpu_to_le16(hidg->report_length);
643+
/*
644+
* We can use hidg_desc struct here but we should not relay
645+
* that its content won't change after returning from this function.
646+
*/
635647
hidg_desc.desc[0].bDescriptorType = HID_DT_REPORT;
636648
hidg_desc.desc[0].wDescriptorLength =
637649
cpu_to_le16(hidg->report_desc_length);

drivers/usb/gadget/function/u_serial.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ struct gs_port {
113113
int write_allocated;
114114
struct gs_buf port_write_buf;
115115
wait_queue_head_t drain_wait; /* wait while writes drain */
116+
bool write_busy;
116117

117118
/* REVISIT this state ... */
118119
struct usb_cdc_line_coding port_line_coding; /* 8-N-1 etc */
@@ -363,7 +364,7 @@ __acquires(&port->port_lock)
363364
int status = 0;
364365
bool do_tty_wake = false;
365366

366-
while (!list_empty(pool)) {
367+
while (!port->write_busy && !list_empty(pool)) {
367368
struct usb_request *req;
368369
int len;
369370

@@ -393,9 +394,11 @@ __acquires(&port->port_lock)
393394
* NOTE that we may keep sending data for a while after
394395
* the TTY closed (dev->ioport->port_tty is NULL).
395396
*/
397+
port->write_busy = true;
396398
spin_unlock(&port->port_lock);
397399
status = usb_ep_queue(in, req, GFP_ATOMIC);
398400
spin_lock(&port->port_lock);
401+
port->write_busy = false;
399402

400403
if (status) {
401404
pr_debug("%s: %s %s err %d\n",

drivers/usb/gadget/legacy/acm_ms.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ static struct usb_function *f_msg;
121121
/*
122122
* We _always_ have both ACM and mass storage functions.
123123
*/
124-
static int __init acm_ms_do_config(struct usb_configuration *c)
124+
static int acm_ms_do_config(struct usb_configuration *c)
125125
{
126126
struct fsg_opts *opts;
127127
int status;
@@ -174,7 +174,7 @@ static struct usb_configuration acm_ms_config_driver = {
174174

175175
/*-------------------------------------------------------------------------*/
176176

177-
static int __init acm_ms_bind(struct usb_composite_dev *cdev)
177+
static int acm_ms_bind(struct usb_composite_dev *cdev)
178178
{
179179
struct usb_gadget *gadget = cdev->gadget;
180180
struct fsg_opts *opts;
@@ -249,7 +249,7 @@ static int __init acm_ms_bind(struct usb_composite_dev *cdev)
249249
return status;
250250
}
251251

252-
static int __exit acm_ms_unbind(struct usb_composite_dev *cdev)
252+
static int acm_ms_unbind(struct usb_composite_dev *cdev)
253253
{
254254
usb_put_function(f_msg);
255255
usb_put_function_instance(fi_msg);
@@ -258,13 +258,13 @@ static int __exit acm_ms_unbind(struct usb_composite_dev *cdev)
258258
return 0;
259259
}
260260

261-
static __refdata struct usb_composite_driver acm_ms_driver = {
261+
static struct usb_composite_driver acm_ms_driver = {
262262
.name = "g_acm_ms",
263263
.dev = &device_desc,
264264
.max_speed = USB_SPEED_SUPER,
265265
.strings = dev_strings,
266266
.bind = acm_ms_bind,
267-
.unbind = __exit_p(acm_ms_unbind),
267+
.unbind = acm_ms_unbind,
268268
};
269269

270270
module_usb_composite_driver(acm_ms_driver);

drivers/usb/gadget/legacy/audio.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ static const struct usb_descriptor_header *otg_desc[] = {
167167

168168
/*-------------------------------------------------------------------------*/
169169

170-
static int __init audio_do_config(struct usb_configuration *c)
170+
static int audio_do_config(struct usb_configuration *c)
171171
{
172172
int status;
173173

@@ -216,7 +216,7 @@ static struct usb_configuration audio_config_driver = {
216216

217217
/*-------------------------------------------------------------------------*/
218218

219-
static int __init audio_bind(struct usb_composite_dev *cdev)
219+
static int audio_bind(struct usb_composite_dev *cdev)
220220
{
221221
#ifndef CONFIG_GADGET_UAC1
222222
struct f_uac2_opts *uac2_opts;
@@ -276,7 +276,7 @@ static int __init audio_bind(struct usb_composite_dev *cdev)
276276
return status;
277277
}
278278

279-
static int __exit audio_unbind(struct usb_composite_dev *cdev)
279+
static int audio_unbind(struct usb_composite_dev *cdev)
280280
{
281281
#ifdef CONFIG_GADGET_UAC1
282282
if (!IS_ERR_OR_NULL(f_uac1))
@@ -292,13 +292,13 @@ static int __exit audio_unbind(struct usb_composite_dev *cdev)
292292
return 0;
293293
}
294294

295-
static __refdata struct usb_composite_driver audio_driver = {
295+
static struct usb_composite_driver audio_driver = {
296296
.name = "g_audio",
297297
.dev = &device_desc,
298298
.strings = audio_strings,
299299
.max_speed = USB_SPEED_HIGH,
300300
.bind = audio_bind,
301-
.unbind = __exit_p(audio_unbind),
301+
.unbind = audio_unbind,
302302
};
303303

304304
module_usb_composite_driver(audio_driver);

0 commit comments

Comments
 (0)