Skip to contentSkip to conversation

dvb_usb_v2 Allow d->props.bInterfaceNumber to set the correct interface.

PATCH In review Malcolm Priestley 2 participants 2 messages Jun 13, 2012 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

PATCH 2/2 dvb_usb_v2 Allow d->props.bInterfaceNumber to set the correct interface.

Although the interface could be set in identify state, ideally it should be done in the probe.

Allow d->props.bInterfaceNumber try to set the correct interface rather than return error.

---
 drivers/media/dvb/dvb-usb/dvb_usb_init.c |   11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/media/dvb/dvb-usb/dvb_usb_init.c +9 -2
index c16a28a..b2eb8ac 100644
@@ -391,8 +391,15 @@ int dvb_usbv2_probe(struct usb_interface *intf,
 
 	if (d->intf->cur_altsetting->desc.bInterfaceNumber !=
 			d->props.bInterfaceNumber) {
-		ret = -ENODEV;
-		goto err_kfree;
+		usb_reset_configuration(d->udev);
+
+		ret = usb_set_interface(d->udev,
+			d->intf->cur_altsetting->desc.bInterfaceNumber,
+				d->props.bInterfaceNumber);
+		if (ret < 0) {
+			ret = -ENODEV;
+			goto err_kfree;
+		}
 	}
 
 	mutex_init(&d->usb_mutex);
Signature · 1 line
1.7.10
#1 lore raw
Quoted 16 lines · Malcolm Priestley

Although the interface could be set in identify state, ideally it should be done in the probe.

Allow d->props.bInterfaceNumber try to set the correct interface rather than return error.

---
  drivers/media/dvb/dvb-usb/dvb_usb_init.c |   11 +++++++++--
  1 file changed, 9 insertions(+), 2 deletions(-)
drivers/media/dvb/dvb-usb/dvb_usb_init.c +0 -0
index c16a28a..b2eb8ac 100644

drivers/media/dvb/dvb-usb/dvb_usb_init.c int dvb_usbv2_probe(struct usb_interface *intf, · line 398

Quoted 10 lines
drivers/media/dvb/dvb-usb/dvb_usb_init.c +5 -2
@@ -391,8 +391,15 @@ int dvb_usbv2_probe(struct usb_interface *intf,
 
  	if (d->intf->cur_altsetting->desc.bInterfaceNumber !=
  			d->props.bInterfaceNumber) {
-		ret = -ENODEV;
-		goto err_kfree;
+		usb_reset_configuration(d->udev);
+
+		ret = usb_set_interface(d->udev,
+			d->intf->cur_altsetting->desc.bInterfaceNumber,
+				d->props.bInterfaceNumber);

I suspect it is wrong, as is changes alternate setting (to the bInterfaceNumber given as a property) whilst interface seems to be same what I understand. You are confusing with alternate setting and interface, right?

http://ftp.au.debian.org/linux-mandocs/2.6.12.6/usb_set_interface.html

After my explanation, are you really sure that this is correct?

USB device could have multiple interfaces. And each interface could have multiple alternate settings.

For the DVB device point of view those means generally that if we have multiple interfaces those are one for remote and one for DVB. And if we have multiple alternate settings inside DVB interface it is selecting for USB stream settings (BULK vs. ISOC, different ISOC profiles). That kind of alternate setting change belongs to streaming control callback of driver.

But I like the idea of switching to correct interface. But I doubt it is not possible, as USB core claims interfaces. And my opinion is that interface should be added as a USB match flag, instead of that kind driver checks.

drivers/media/dvb/dvb-usb/dvb_usb_init.c int dvb_usbv2_probe(struct usb_interface *intf, · line 405

Quoted 7 lines
drivers/media/dvb/dvb-usb/dvb_usb_init.c +4 -0
+		if (ret<  0) {
+			ret = -ENODEV;
+			goto err_kfree;
+		}
  	}
 
  	mutex_init(&d->usb_mutex);

regards
Antti

Signature · 1 line
http://palosaari.fi/