Skip to content

Commit 9066e15

Browse files
committed
Merge tag 'usb-6.1-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb
Pull USB fixes from Greg KH: "Here are some small USB fixes for 6.1-rc7 that resolve some reported problems: - cdnsp driver fixes for reported problems - dwc3 fixes for some small reported problems - uvc gadget driver fix for reported regression All of these have been in linux-next with no reported problems" * tag 'usb-6.1-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: usb: cdnsp: fix issue with ZLP - added TD_SIZE = 1 usb: dwc3: gadget: Clear ep descriptor last usb: dwc3: exynos: Fix remove() function usb: cdnsp: Fix issue with Clear Feature Halt Endpoint usb: dwc3: gadget: Disable GUSB2PHYCFG.SUSPHY for End Transfer usb: gadget: uvc: also use try_format in set_format
2 parents db31824 + 7a21b27 commit 9066e15

File tree

5 files changed

+46
-81
lines changed

5 files changed

+46
-81
lines changed

drivers/usb/cdns3/cdnsp-gadget.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -600,11 +600,11 @@ int cdnsp_halt_endpoint(struct cdnsp_device *pdev,
600600

601601
trace_cdnsp_ep_halt(value ? "Set" : "Clear");
602602

603-
if (value) {
604-
ret = cdnsp_cmd_stop_ep(pdev, pep);
605-
if (ret)
606-
return ret;
603+
ret = cdnsp_cmd_stop_ep(pdev, pep);
604+
if (ret)
605+
return ret;
607606

607+
if (value) {
608608
if (GET_EP_CTX_STATE(pep->out_ctx) == EP_STATE_STOPPED) {
609609
cdnsp_queue_halt_endpoint(pdev, pep->idx);
610610
cdnsp_ring_cmd_db(pdev);
@@ -613,10 +613,6 @@ int cdnsp_halt_endpoint(struct cdnsp_device *pdev,
613613

614614
pep->ep_state |= EP_HALTED;
615615
} else {
616-
/*
617-
* In device mode driver can call reset endpoint command
618-
* from any endpoint state.
619-
*/
620616
cdnsp_queue_reset_ep(pdev, pep->idx);
621617
cdnsp_ring_cmd_db(pdev);
622618
ret = cdnsp_wait_for_cmd_compl(pdev);

drivers/usb/cdns3/cdnsp-ring.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1763,10 +1763,15 @@ static u32 cdnsp_td_remainder(struct cdnsp_device *pdev,
17631763
int trb_buff_len,
17641764
unsigned int td_total_len,
17651765
struct cdnsp_request *preq,
1766-
bool more_trbs_coming)
1766+
bool more_trbs_coming,
1767+
bool zlp)
17671768
{
17681769
u32 maxp, total_packet_count;
17691770

1771+
/* Before ZLP driver needs set TD_SIZE = 1. */
1772+
if (zlp)
1773+
return 1;
1774+
17701775
/* One TRB with a zero-length data packet. */
17711776
if (!more_trbs_coming || (transferred == 0 && trb_buff_len == 0) ||
17721777
trb_buff_len == td_total_len)
@@ -1960,7 +1965,8 @@ int cdnsp_queue_bulk_tx(struct cdnsp_device *pdev, struct cdnsp_request *preq)
19601965
/* Set the TRB length, TD size, and interrupter fields. */
19611966
remainder = cdnsp_td_remainder(pdev, enqd_len, trb_buff_len,
19621967
full_len, preq,
1963-
more_trbs_coming);
1968+
more_trbs_coming,
1969+
zero_len_trb);
19641970

19651971
length_field = TRB_LEN(trb_buff_len) | TRB_TD_SIZE(remainder) |
19661972
TRB_INTR_TARGET(0);
@@ -2025,7 +2031,7 @@ int cdnsp_queue_ctrl_tx(struct cdnsp_device *pdev, struct cdnsp_request *preq)
20252031

20262032
if (preq->request.length > 0) {
20272033
remainder = cdnsp_td_remainder(pdev, 0, preq->request.length,
2028-
preq->request.length, preq, 1);
2034+
preq->request.length, preq, 1, 0);
20292035

20302036
length_field = TRB_LEN(preq->request.length) |
20312037
TRB_TD_SIZE(remainder) | TRB_INTR_TARGET(0);
@@ -2076,7 +2082,8 @@ int cdnsp_cmd_stop_ep(struct cdnsp_device *pdev, struct cdnsp_ep *pep)
20762082
u32 ep_state = GET_EP_CTX_STATE(pep->out_ctx);
20772083
int ret = 0;
20782084

2079-
if (ep_state == EP_STATE_STOPPED || ep_state == EP_STATE_DISABLED) {
2085+
if (ep_state == EP_STATE_STOPPED || ep_state == EP_STATE_DISABLED ||
2086+
ep_state == EP_STATE_HALTED) {
20802087
trace_cdnsp_ep_stopped_or_disabled(pep->out_ctx);
20812088
goto ep_stopped;
20822089
}
@@ -2225,7 +2232,7 @@ static int cdnsp_queue_isoc_tx(struct cdnsp_device *pdev,
22252232
/* Set the TRB length, TD size, & interrupter fields. */
22262233
remainder = cdnsp_td_remainder(pdev, running_total,
22272234
trb_buff_len, td_len, preq,
2228-
more_trbs_coming);
2235+
more_trbs_coming, 0);
22292236

22302237
length_field = TRB_LEN(trb_buff_len) | TRB_INTR_TARGET(0);
22312238

drivers/usb/dwc3/dwc3-exynos.c

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,6 @@ struct dwc3_exynos {
3737
struct regulator *vdd10;
3838
};
3939

40-
static int dwc3_exynos_remove_child(struct device *dev, void *unused)
41-
{
42-
struct platform_device *pdev = to_platform_device(dev);
43-
44-
platform_device_unregister(pdev);
45-
46-
return 0;
47-
}
48-
4940
static int dwc3_exynos_probe(struct platform_device *pdev)
5041
{
5142
struct dwc3_exynos *exynos;
@@ -142,7 +133,7 @@ static int dwc3_exynos_remove(struct platform_device *pdev)
142133
struct dwc3_exynos *exynos = platform_get_drvdata(pdev);
143134
int i;
144135

145-
device_for_each_child(&pdev->dev, NULL, dwc3_exynos_remove_child);
136+
of_platform_depopulate(&pdev->dev);
146137

147138
for (i = exynos->num_clks - 1; i >= 0; i--)
148139
clk_disable_unprepare(exynos->clks[i]);

drivers/usb/dwc3/gadget.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,8 @@ int dwc3_send_gadget_ep_cmd(struct dwc3_ep *dep, unsigned int cmd,
291291
*
292292
* DWC_usb3 3.30a and DWC_usb31 1.90a programming guide section 3.2.2
293293
*/
294-
if (dwc->gadget->speed <= USB_SPEED_HIGH) {
294+
if (dwc->gadget->speed <= USB_SPEED_HIGH ||
295+
DWC3_DEPCMD_CMD(cmd) == DWC3_DEPCMD_ENDTRANSFER) {
295296
reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0));
296297
if (unlikely(reg & DWC3_GUSB2PHYCFG_SUSPHY)) {
297298
saved_config |= DWC3_GUSB2PHYCFG_SUSPHY;
@@ -1023,12 +1024,6 @@ static int __dwc3_gadget_ep_disable(struct dwc3_ep *dep)
10231024
reg &= ~DWC3_DALEPENA_EP(dep->number);
10241025
dwc3_writel(dwc->regs, DWC3_DALEPENA, reg);
10251026

1026-
/* Clear out the ep descriptors for non-ep0 */
1027-
if (dep->number > 1) {
1028-
dep->endpoint.comp_desc = NULL;
1029-
dep->endpoint.desc = NULL;
1030-
}
1031-
10321027
dwc3_remove_requests(dwc, dep, -ESHUTDOWN);
10331028

10341029
dep->stream_capable = false;
@@ -1043,6 +1038,12 @@ static int __dwc3_gadget_ep_disable(struct dwc3_ep *dep)
10431038
mask |= (DWC3_EP_DELAY_STOP | DWC3_EP_TRANSFER_STARTED);
10441039
dep->flags &= mask;
10451040

1041+
/* Clear out the ep descriptors for non-ep0 */
1042+
if (dep->number > 1) {
1043+
dep->endpoint.comp_desc = NULL;
1044+
dep->endpoint.desc = NULL;
1045+
}
1046+
10461047
return 0;
10471048
}
10481049

drivers/usb/gadget/function/uvc_v4l2.c

Lines changed: 21 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -199,16 +199,6 @@ uvc_send_response(struct uvc_device *uvc, struct uvc_request_data *data)
199199
* V4L2 ioctls
200200
*/
201201

202-
struct uvc_format {
203-
u8 bpp;
204-
u32 fcc;
205-
};
206-
207-
static struct uvc_format uvc_formats[] = {
208-
{ 16, V4L2_PIX_FMT_YUYV },
209-
{ 0, V4L2_PIX_FMT_MJPEG },
210-
};
211-
212202
static int
213203
uvc_v4l2_querycap(struct file *file, void *fh, struct v4l2_capability *cap)
214204
{
@@ -242,47 +232,6 @@ uvc_v4l2_get_format(struct file *file, void *fh, struct v4l2_format *fmt)
242232
return 0;
243233
}
244234

245-
static int
246-
uvc_v4l2_set_format(struct file *file, void *fh, struct v4l2_format *fmt)
247-
{
248-
struct video_device *vdev = video_devdata(file);
249-
struct uvc_device *uvc = video_get_drvdata(vdev);
250-
struct uvc_video *video = &uvc->video;
251-
struct uvc_format *format;
252-
unsigned int imagesize;
253-
unsigned int bpl;
254-
unsigned int i;
255-
256-
for (i = 0; i < ARRAY_SIZE(uvc_formats); ++i) {
257-
format = &uvc_formats[i];
258-
if (format->fcc == fmt->fmt.pix.pixelformat)
259-
break;
260-
}
261-
262-
if (i == ARRAY_SIZE(uvc_formats)) {
263-
uvcg_info(&uvc->func, "Unsupported format 0x%08x.\n",
264-
fmt->fmt.pix.pixelformat);
265-
return -EINVAL;
266-
}
267-
268-
bpl = format->bpp * fmt->fmt.pix.width / 8;
269-
imagesize = bpl ? bpl * fmt->fmt.pix.height : fmt->fmt.pix.sizeimage;
270-
271-
video->fcc = format->fcc;
272-
video->bpp = format->bpp;
273-
video->width = fmt->fmt.pix.width;
274-
video->height = fmt->fmt.pix.height;
275-
video->imagesize = imagesize;
276-
277-
fmt->fmt.pix.field = V4L2_FIELD_NONE;
278-
fmt->fmt.pix.bytesperline = bpl;
279-
fmt->fmt.pix.sizeimage = imagesize;
280-
fmt->fmt.pix.colorspace = V4L2_COLORSPACE_SRGB;
281-
fmt->fmt.pix.priv = 0;
282-
283-
return 0;
284-
}
285-
286235
static int
287236
uvc_v4l2_try_format(struct file *file, void *fh, struct v4l2_format *fmt)
288237
{
@@ -323,6 +272,27 @@ uvc_v4l2_try_format(struct file *file, void *fh, struct v4l2_format *fmt)
323272
return 0;
324273
}
325274

275+
static int
276+
uvc_v4l2_set_format(struct file *file, void *fh, struct v4l2_format *fmt)
277+
{
278+
struct video_device *vdev = video_devdata(file);
279+
struct uvc_device *uvc = video_get_drvdata(vdev);
280+
struct uvc_video *video = &uvc->video;
281+
int ret;
282+
283+
ret = uvc_v4l2_try_format(file, fh, fmt);
284+
if (ret)
285+
return ret;
286+
287+
video->fcc = fmt->fmt.pix.pixelformat;
288+
video->bpp = fmt->fmt.pix.bytesperline * 8 / video->width;
289+
video->width = fmt->fmt.pix.width;
290+
video->height = fmt->fmt.pix.height;
291+
video->imagesize = fmt->fmt.pix.sizeimage;
292+
293+
return ret;
294+
}
295+
326296
static int
327297
uvc_v4l2_enum_frameintervals(struct file *file, void *fh,
328298
struct v4l2_frmivalenum *fival)

0 commit comments

Comments
 (0)