mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00:00
w1: ds2490 USB setup fixes
Calling usb_reset_configuration after usb_set_interface resets the interface that was just selected, so call reset first. Using alternative 3 greatly speeds the one wire search. alt 0 or 1, 10ms int, 23.16 seconds alt 2 or 3, 1ms int, 2.99 to 3.05 seconds Use usb_interrupt_msg not usb_bulk_msg as it is an interrupt pipe (bulk worked, it was just technically the wrong call). Signed-off-by: David Fries <David@Fries.net> Acked-by: Evgeniy Polyakov <zbr@ioremap.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
f28c4e1f31
commit
da78b7e74a
1 changed files with 17 additions and 11 deletions
|
@ -252,7 +252,8 @@ static int ds_recv_status_nodump(struct ds_device *dev, struct ds_status *st,
|
||||||
memset(st, 0, sizeof(*st));
|
memset(st, 0, sizeof(*st));
|
||||||
|
|
||||||
count = 0;
|
count = 0;
|
||||||
err = usb_bulk_msg(dev->udev, usb_rcvbulkpipe(dev->udev, dev->ep[EP_STATUS]), buf, size, &count, 100);
|
err = usb_interrupt_msg(dev->udev, usb_rcvintpipe(dev->udev,
|
||||||
|
dev->ep[EP_STATUS]), buf, size, &count, 100);
|
||||||
if (err < 0) {
|
if (err < 0) {
|
||||||
printk(KERN_ERR "Failed to read 1-wire data from 0x%x: err=%d.\n", dev->ep[EP_STATUS], err);
|
printk(KERN_ERR "Failed to read 1-wire data from 0x%x: err=%d.\n", dev->ep[EP_STATUS], err);
|
||||||
return err;
|
return err;
|
||||||
|
@ -917,7 +918,7 @@ static int ds_probe(struct usb_interface *intf,
|
||||||
struct usb_endpoint_descriptor *endpoint;
|
struct usb_endpoint_descriptor *endpoint;
|
||||||
struct usb_host_interface *iface_desc;
|
struct usb_host_interface *iface_desc;
|
||||||
struct ds_device *dev;
|
struct ds_device *dev;
|
||||||
int i, err;
|
int i, err, alt;
|
||||||
|
|
||||||
dev = kmalloc(sizeof(struct ds_device), GFP_KERNEL);
|
dev = kmalloc(sizeof(struct ds_device), GFP_KERNEL);
|
||||||
if (!dev) {
|
if (!dev) {
|
||||||
|
@ -935,20 +936,25 @@ static int ds_probe(struct usb_interface *intf,
|
||||||
|
|
||||||
usb_set_intfdata(intf, dev);
|
usb_set_intfdata(intf, dev);
|
||||||
|
|
||||||
err = usb_set_interface(dev->udev, intf->altsetting[0].desc.bInterfaceNumber, 3);
|
|
||||||
if (err) {
|
|
||||||
printk(KERN_ERR "Failed to set alternative setting 3 for %d interface: err=%d.\n",
|
|
||||||
intf->altsetting[0].desc.bInterfaceNumber, err);
|
|
||||||
goto err_out_clear;
|
|
||||||
}
|
|
||||||
|
|
||||||
err = usb_reset_configuration(dev->udev);
|
err = usb_reset_configuration(dev->udev);
|
||||||
if (err) {
|
if (err) {
|
||||||
printk(KERN_ERR "Failed to reset configuration: err=%d.\n", err);
|
dev_err(&dev->udev->dev,
|
||||||
|
"Failed to reset configuration: err=%d.\n", err);
|
||||||
goto err_out_clear;
|
goto err_out_clear;
|
||||||
}
|
}
|
||||||
|
|
||||||
iface_desc = &intf->altsetting[0];
|
/* alternative 3, 1ms interrupt (greatly speeds search), 64 byte bulk */
|
||||||
|
alt = 3;
|
||||||
|
err = usb_set_interface(dev->udev,
|
||||||
|
intf->altsetting[alt].desc.bInterfaceNumber, alt);
|
||||||
|
if (err) {
|
||||||
|
dev_err(&dev->udev->dev, "Failed to set alternative setting %d "
|
||||||
|
"for %d interface: err=%d.\n", alt,
|
||||||
|
intf->altsetting[alt].desc.bInterfaceNumber, err);
|
||||||
|
goto err_out_clear;
|
||||||
|
}
|
||||||
|
|
||||||
|
iface_desc = &intf->altsetting[alt];
|
||||||
if (iface_desc->desc.bNumEndpoints != NUM_EP-1) {
|
if (iface_desc->desc.bNumEndpoints != NUM_EP-1) {
|
||||||
printk(KERN_INFO "Num endpoints=%d. It is not DS9490R.\n", iface_desc->desc.bNumEndpoints);
|
printk(KERN_INFO "Num endpoints=%d. It is not DS9490R.\n", iface_desc->desc.bNumEndpoints);
|
||||||
err = -EINVAL;
|
err = -EINVAL;
|
||||||
|
|
Loading…
Add table
Reference in a new issue