Skip to content

Commit

Permalink
Merge tag 'fixes-for-v5.7-rc5' of git://git.kernel.org/pub/scm/linux/…
Browse files Browse the repository at this point in the history
…kernel/git/balbi/usb into usb-linus

Felipe writes:

USB: fixes for v5.7-rc5

Fixing raw-gadget's IOCTL return value. Enabling EXTCON for Intel
Merrifield. Couple leaks have been plugged in net2272 and
twl6030-usb. Returning an error code when things fail in cdc and ncm
legacy gadgets. An old bug on dwc3 regarding HWO bit handling has been
fixed.

Apart from these, some minor fixes.

Signed-off-by: Felipe Balbi <balbi@kernel.org>

* tag 'fixes-for-v5.7-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb:
  usb: raw-gadget: fix return value of ep read ioctls
  usb: dwc3: select USB_ROLE_SWITCH
  usb: gadget: legacy: fix error return code in gncm_bind()
  usb: gadget: legacy: fix error return code in cdc_bind()
  usb: gadget: legacy: fix redundant initialization warnings
  usb: gadget: tegra-xudc: Fix idle suspend/resume
  usb: gadget: net2272: Fix a memory leak in an error handling path in 'net2272_plat_probe()'
  usb: phy: twl6030-usb: Fix a resource leak in an error handling path in 'twl6030_usb_probe()'
  usb: cdns3: gadget: prev_req->trb is NULL for ep0
  usb: gadget: audio: Fix a missing error return value in audio_bind()
  usb: dwc3: pci: Enable extcon driver for Intel Merrifield
  dwc3: Remove check for HWO flag in dwc3_gadget_ep_reclaim_trb_sg()
  • Loading branch information
Greg Kroah-Hartman committed May 13, 2020
2 parents 2ef96a5 + 6e50764 commit c34a4f9
Show file tree
Hide file tree
Showing 12 changed files with 34 additions and 18 deletions.
2 changes: 1 addition & 1 deletion drivers/usb/cdns3/gadget.c
Original file line number Diff line number Diff line change
Expand Up @@ -2548,7 +2548,7 @@ int cdns3_gadget_ep_dequeue(struct usb_ep *ep,
link_trb = priv_req->trb;

/* Update ring only if removed request is on pending_req_list list */
if (req_on_hw_ring) {
if (req_on_hw_ring && link_trb) {
link_trb->buffer = TRB_BUFFER(priv_ep->trb_pool_dma +
((priv_req->end_trb + 1) * TRB_SIZE));
link_trb->control = (link_trb->control & TRB_CYCLE) |
Expand Down
1 change: 1 addition & 0 deletions drivers/usb/dwc3/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ config USB_DWC3
tristate "DesignWare USB3 DRD Core Support"
depends on (USB || USB_GADGET) && HAS_DMA
select USB_XHCI_PLATFORM if USB_XHCI_HCD
select USB_ROLE_SWITCH if USB_DWC3_DUAL_ROLE
help
Say Y or M here if your system has a Dual Role SuperSpeed
USB controller based on the DesignWare USB3 IP Core.
Expand Down
1 change: 1 addition & 0 deletions drivers/usb/dwc3/dwc3-pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ static const struct property_entry dwc3_pci_intel_properties[] = {

static const struct property_entry dwc3_pci_mrfld_properties[] = {
PROPERTY_ENTRY_STRING("dr_mode", "otg"),
PROPERTY_ENTRY_STRING("linux,extcon-name", "mrfld_bcove_pwrsrc"),
PROPERTY_ENTRY_BOOL("linux,sysdev_is_parent"),
{}
};
Expand Down
3 changes: 0 additions & 3 deletions drivers/usb/dwc3/gadget.c
Original file line number Diff line number Diff line change
Expand Up @@ -2483,9 +2483,6 @@ static int dwc3_gadget_ep_reclaim_trb_sg(struct dwc3_ep *dep,
for_each_sg(sg, s, pending, i) {
trb = &dep->trb_pool[dep->trb_dequeue];

if (trb->ctrl & DWC3_TRB_CTRL_HWO)
break;

req->sg = sg_next(s);
req->num_pending_sgs--;

Expand Down
4 changes: 3 additions & 1 deletion drivers/usb/gadget/legacy/audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,10 @@ static int audio_bind(struct usb_composite_dev *cdev)
struct usb_descriptor_header *usb_desc;

usb_desc = usb_otg_descriptor_alloc(cdev->gadget);
if (!usb_desc)
if (!usb_desc) {
status = -ENOMEM;
goto fail;
}
usb_otg_descriptor_init(cdev->gadget, usb_desc);
otg_desc[0] = usb_desc;
otg_desc[1] = NULL;
Expand Down
4 changes: 3 additions & 1 deletion drivers/usb/gadget/legacy/cdc2.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,10 @@ static int cdc_bind(struct usb_composite_dev *cdev)
struct usb_descriptor_header *usb_desc;

usb_desc = usb_otg_descriptor_alloc(gadget);
if (!usb_desc)
if (!usb_desc) {
status = -ENOMEM;
goto fail1;
}
usb_otg_descriptor_init(gadget, usb_desc);
otg_desc[0] = usb_desc;
otg_desc[1] = NULL;
Expand Down
3 changes: 1 addition & 2 deletions drivers/usb/gadget/legacy/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -1361,7 +1361,6 @@ gadgetfs_setup (struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)

req->buf = dev->rbuf;
req->context = NULL;
value = -EOPNOTSUPP;
switch (ctrl->bRequest) {

case USB_REQ_GET_DESCRIPTOR:
Expand Down Expand Up @@ -1784,7 +1783,7 @@ static ssize_t
dev_config (struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
{
struct dev_data *dev = fd->private_data;
ssize_t value = len, length = len;
ssize_t value, length = len;
unsigned total;
u32 tag;
char *kbuf;
Expand Down
4 changes: 3 additions & 1 deletion drivers/usb/gadget/legacy/ncm.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,10 @@ static int gncm_bind(struct usb_composite_dev *cdev)
struct usb_descriptor_header *usb_desc;

usb_desc = usb_otg_descriptor_alloc(gadget);
if (!usb_desc)
if (!usb_desc) {
status = -ENOMEM;
goto fail;
}
usb_otg_descriptor_init(gadget, usb_desc);
otg_desc[0] = usb_desc;
otg_desc[1] = NULL;
Expand Down
8 changes: 6 additions & 2 deletions drivers/usb/gadget/legacy/raw_gadget.c
Original file line number Diff line number Diff line change
Expand Up @@ -669,12 +669,14 @@ static int raw_ioctl_ep0_read(struct raw_dev *dev, unsigned long value)
if (IS_ERR(data))
return PTR_ERR(data);
ret = raw_process_ep0_io(dev, &io, data, false);
if (ret)
if (ret < 0)
goto free;

length = min(io.length, (unsigned int)ret);
if (copy_to_user((void __user *)(value + sizeof(io)), data, length))
ret = -EFAULT;
else
ret = length;
free:
kfree(data);
return ret;
Expand Down Expand Up @@ -964,12 +966,14 @@ static int raw_ioctl_ep_read(struct raw_dev *dev, unsigned long value)
if (IS_ERR(data))
return PTR_ERR(data);
ret = raw_process_ep_io(dev, &io, data, false);
if (ret)
if (ret < 0)
goto free;

length = min(io.length, (unsigned int)ret);
if (copy_to_user((void __user *)(value + sizeof(io)), data, length))
ret = -EFAULT;
else
ret = length;
free:
kfree(data);
return ret;
Expand Down
2 changes: 2 additions & 0 deletions drivers/usb/gadget/udc/net2272.c
Original file line number Diff line number Diff line change
Expand Up @@ -2647,6 +2647,8 @@ net2272_plat_probe(struct platform_device *pdev)
err_req:
release_mem_region(base, len);
err:
kfree(dev);

return ret;
}

Expand Down
8 changes: 4 additions & 4 deletions drivers/usb/gadget/udc/tegra-xudc.c
Original file line number Diff line number Diff line change
Expand Up @@ -3840,11 +3840,11 @@ static int __maybe_unused tegra_xudc_suspend(struct device *dev)

flush_work(&xudc->usb_role_sw_work);

/* Forcibly disconnect before powergating. */
tegra_xudc_device_mode_off(xudc);

if (!pm_runtime_status_suspended(dev))
if (!pm_runtime_status_suspended(dev)) {
/* Forcibly disconnect before powergating. */
tegra_xudc_device_mode_off(xudc);
tegra_xudc_powergate(xudc);
}

pm_runtime_disable(dev);

Expand Down
12 changes: 9 additions & 3 deletions drivers/usb/phy/phy-twl6030-usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ static int twl6030_usb_probe(struct platform_device *pdev)
if (status < 0) {
dev_err(&pdev->dev, "can't get IRQ %d, err %d\n",
twl->irq1, status);
return status;
goto err_put_regulator;
}

status = request_threaded_irq(twl->irq2, NULL, twl6030_usb_irq,
Expand All @@ -386,8 +386,7 @@ static int twl6030_usb_probe(struct platform_device *pdev)
if (status < 0) {
dev_err(&pdev->dev, "can't get IRQ %d, err %d\n",
twl->irq2, status);
free_irq(twl->irq1, twl);
return status;
goto err_free_irq1;
}

twl->asleep = 0;
Expand All @@ -396,6 +395,13 @@ static int twl6030_usb_probe(struct platform_device *pdev)
dev_info(&pdev->dev, "Initialized TWL6030 USB module\n");

return 0;

err_free_irq1:
free_irq(twl->irq1, twl);
err_put_regulator:
regulator_put(twl->usb3v3);

return status;
}

static int twl6030_usb_remove(struct platform_device *pdev)
Expand Down

0 comments on commit c34a4f9

Please sign in to comment.