Skip to contentSkip to conversation

media: go7007: Fix URB type for interrupt handling

PATCH In review Takashi Iwai 2 participants 3 messages Feb 6, 2020 – Feb 7, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 media: go7007: Fix URB type for interrupt handling

Josef reported that his old-and-good Plextor ConvertX M402U video converter spews lots of WARNINGs on the recent kernels, and it turned out that the device uses a bulk endpoint for interrupt handling just like 2250 board.

For fixing it, generalize the check with the proper verification of the endpoint instead of hard-coded board type check.

---
 drivers/media/usb/go7007/go7007-usb.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/media/usb/go7007/go7007-usb.c +3 -1
index ff2aa057c1fb..f889c9d740cd 100644
@@ -1044,6 +1044,7 @@ static int go7007_usb_probe(struct usb_interface *intf,
 	struct go7007_usb *usb;
 	const struct go7007_usb_board *board;
 	struct usb_device *usbdev = interface_to_usbdev(intf);
+	struct usb_host_endpoint *ep;
 	unsigned num_i2c_devs;
 	char *name;
 	int video_pipe, i, v_urb_len;
@@ -1140,7 +1141,8 @@ static int go7007_usb_probe(struct usb_interface *intf,
 	if (usb->intr_urb->transfer_buffer == NULL)
 		goto allocfail;
 
-	if (go->board_id == GO7007_BOARDID_SENSORAY_2250)
+	ep = usb->usbdev->ep_in[4];
+	if (usb_endpoint_type(&ep->desc) == USB_ENDPOINT_XFER_BULK)
 		usb_fill_bulk_urb(usb->intr_urb, usb->usbdev,
 			usb_rcvbulkpipe(usb->usbdev, 4),
 			usb->intr_urb->transfer_buffer, 2*sizeof(u16),
Signature · 1 line
2.16.4
#1 lore raw

Em Thu, 6 Feb 2020 16:45:27 +0100
Takashi Iwai <[email protected]> escreveu:

Quoted 31 lines

Josef reported that his old-and-good Plextor ConvertX M402U video converter spews lots of WARNINGs on the recent kernels, and it turned out that the device uses a bulk endpoint for interrupt handling just like 2250 board.

For fixing it, generalize the check with the proper verification of the endpoint instead of hard-coded board type check.

---
 drivers/media/usb/go7007/go7007-usb.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/media/usb/go7007/go7007-usb.c +1 -0
index ff2aa057c1fb..f889c9d740cd 100644
@@ -1044,6 +1044,7 @@ static int go7007_usb_probe(struct usb_interface *intf,
 	struct go7007_usb *usb;
 	const struct go7007_usb_board *board;
 	struct usb_device *usbdev = interface_to_usbdev(intf);
+	struct usb_host_endpoint *ep;
 	unsigned num_i2c_devs;
 	char *name;
 	int video_pipe, i, v_urb_len;

drivers/media/usb/go7007/go7007-usb.c static int go7007_usb_probe(struct usb_interface *intf, · line 1144

Quoted 5 lines
drivers/media/usb/go7007/go7007-usb.c +1 -1
@@ -1140,7 +1141,8 @@ static int go7007_usb_probe(struct usb_interface *intf,
 	if (usb->intr_urb->transfer_buffer == NULL)
 		goto allocfail;
 
-	if (go->board_id == GO7007_BOARDID_SENSORAY_2250)
+	ep = usb->usbdev->ep_in[4];

Hmm... why [4] above?

I mean, what other drivers do is something like:

	for (i = 0; i < intf->num_altsetting; i++) {
	   for (j = 0; j < intf->altsetting[i].desc.bNumEndpoints; j++) {
		ep = &intf->altsetting[i].endpoint[j].desc;
		/* some logic to check ep and change alt if needed */
	   }
        }

drivers/media/usb/go7007/go7007-usb.c static int go7007_usb_probe(struct usb_interface *intf, · line 1148

Quoted 4 lines
drivers/media/usb/go7007/go7007-usb.c +1 -0
+	if (usb_endpoint_type(&ep->desc) == USB_ENDPOINT_XFER_BULK)
 		usb_fill_bulk_urb(usb->intr_urb, usb->usbdev,
 			usb_rcvbulkpipe(usb->usbdev, 4),
 			usb->intr_urb->transfer_buffer, 2*sizeof(u16),

Cheers,
Mauro

#2 lore raw
Quoted 43 lines · Mauro Carvalho Chehab

Em Thu, 6 Feb 2020 16:45:27 +0100
Takashi Iwai <[email protected]> escreveu:

Quoted 31 lines

Josef reported that his old-and-good Plextor ConvertX M402U video converter spews lots of WARNINGs on the recent kernels, and it turned out that the device uses a bulk endpoint for interrupt handling just like 2250 board.

For fixing it, generalize the check with the proper verification of the endpoint instead of hard-coded board type check.

---
 drivers/media/usb/go7007/go7007-usb.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/media/usb/go7007/go7007-usb.c +1 -0
index ff2aa057c1fb..f889c9d740cd 100644
@@ -1044,6 +1044,7 @@ static int go7007_usb_probe(struct usb_interface *intf,
 	struct go7007_usb *usb;
 	const struct go7007_usb_board *board;
 	struct usb_device *usbdev = interface_to_usbdev(intf);
+	struct usb_host_endpoint *ep;
 	unsigned num_i2c_devs;
 	char *name;
 	int video_pipe, i, v_urb_len;

drivers/media/usb/go7007/go7007-usb.c static int go7007_usb_probe(struct usb_interface *intf, · line 1144

Quoted 5 lines
drivers/media/usb/go7007/go7007-usb.c +1 -1
@@ -1140,7 +1141,8 @@ static int go7007_usb_probe(struct usb_interface *intf,
 	if (usb->intr_urb->transfer_buffer == NULL)
 		goto allocfail;
 
-	if (go->board_id == GO7007_BOARDID_SENSORAY_2250)
+	ep = usb->usbdev->ep_in[4];

Hmm... why [4] above?

Quoted 9 lines

I mean, what other drivers do is something like:

	for (i = 0; i < intf->num_altsetting; i++) {
	   for (j = 0; j < intf->altsetting[i].desc.bNumEndpoints; j++) {
		ep = &intf->altsetting[i].endpoint[j].desc;
		/* some logic to check ep and change alt if needed */
	   }
        }

It corresponds to the endpoint for the created URB will be associated with; i.e.

Quoted 3 lines

drivers/media/usb/go7007/go7007-usb.c static int go7007_usb_probe(struct usb_interface *intf, · line 1147

Quoted 3 lines
drivers/media/usb/go7007/go7007-usb.c +1 -0
+	if (usb_endpoint_type(&ep->desc) == USB_ENDPOINT_XFER_BULK)
 		usb_fill_bulk_urb(usb->intr_urb, usb->usbdev,
 			usb_rcvbulkpipe(usb->usbdev, 4),

here it's usb_rcvbulkpipe(dev, 4) or usb_rcvintpipe(dev, 4) indicating the endpoint 4.

If it matters, it can be changed to
usb_pipe_endpoint(usb->usbdev, usb_rcvbulkpipe(usb->usbdev, 4))
too.

thanks,

Takashi