From: David Fries <David@Fries.net>
To: linux-kernel@vger.kernel.org
Cc: Evgeniy Polyakov <zbr@ioremap.net>,
Marcin Jurkowski <marcin1j@gmail.com>,
Josh Boyer <jwboyer@gmail.com>,
Sven Geggus <lists@fuchsschwanzdomain.de>
Subject: [PATCH 11/14] w1: ds2490 USB setup fixes
Date: Sun, 29 Dec 2013 00:45:53 -0600 [thread overview]
Message-ID: <1388299556-12669-12-git-send-email-David@Fries.net> (raw)
In-Reply-To: <1388299556-12669-1-git-send-email-David@Fries.net>
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>
Cc: Evgeniy Polyakov <zbr@ioremap.net>
---
drivers/w1/masters/ds2490.c | 22 ++++++++++++++--------
1 file changed, 14 insertions(+), 8 deletions(-)
diff --git a/drivers/w1/masters/ds2490.c b/drivers/w1/masters/ds2490.c
index 6a3d0a1..cd59e12 100644
--- a/drivers/w1/masters/ds2490.c
+++ b/drivers/w1/masters/ds2490.c
@@ -252,7 +252,8 @@ static int ds_recv_status_nodump(struct ds_device *dev, struct ds_status *st,
memset(st, 0, sizeof(*st));
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) {
printk(KERN_ERR "Failed to read 1-wire data from 0x%x: err=%d.\n", dev->ep[EP_STATUS], err);
return err;
@@ -917,7 +918,7 @@ static int ds_probe(struct usb_interface *intf,
struct usb_endpoint_descriptor *endpoint;
struct usb_host_interface *iface_desc;
struct ds_device *dev;
- int i, err;
+ int i, err, alt;
dev = kmalloc(sizeof(struct ds_device), GFP_KERNEL);
if (!dev) {
@@ -935,20 +936,25 @@ static int ds_probe(struct usb_interface *intf,
usb_set_intfdata(intf, dev);
- err = usb_set_interface(dev->udev, intf->altsetting[0].desc.bInterfaceNumber, 3);
+ err = usb_reset_configuration(dev->udev);
if (err) {
- printk(KERN_ERR "Failed to set alternative setting 3 for %d interface: err=%d.\n",
- intf->altsetting[0].desc.bInterfaceNumber, err);
+ dev_err(&dev->udev->dev,
+ "Failed to reset configuration: err=%d.\n", err);
goto err_out_clear;
}
- err = usb_reset_configuration(dev->udev);
+ /* 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) {
- printk(KERN_ERR "Failed to reset configuration: err=%d.\n", 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[0];
+ iface_desc = &intf->altsetting[alt];
if (iface_desc->desc.bNumEndpoints != NUM_EP-1) {
printk(KERN_INFO "Num endpoints=%d. It is not DS9490R.\n", iface_desc->desc.bNumEndpoints);
err = -EINVAL;
--
1.7.10.4
next prev parent reply other threads:[~2013-12-29 6:53 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-29 6:45 [PATCH 00/14] w1: async netlink, search, fixes, and improvements David Fries
2013-12-29 6:45 ` [PATCH 01/14] w1: fix w1_send_slave dropping a slave id David Fries
2013-12-29 6:45 ` [PATCH 02/14] w1: fixup search to support abort from netlink David Fries
2013-12-29 6:45 ` [PATCH 03/14] w1: Only wake up the search process if it is going to be searching David Fries
2013-12-29 6:45 ` [PATCH 04/14] w1: increase w1_max_slave_count, allow write access David Fries
2013-12-29 6:45 ` [PATCH 05/14] w1: continue slave search where previous left off David Fries
2013-12-29 6:45 ` [PATCH 06/14] w1: new netlink commands, add/remove/list slaves David Fries
2013-12-29 6:45 ` [PATCH 07/14] w1: process w1 netlink commands in w1_process thread David Fries
2013-12-29 6:45 ` [PATCH 08/14] connector: add portid to unicast in addition to broadcasting David Fries
2013-12-29 6:45 ` [PATCH 09/14] w1: reply only to the requester portid David Fries
2013-12-29 6:45 ` [PATCH 10/14] w1: ds2490 reduce magic numbers David Fries
2013-12-29 6:45 ` David Fries [this message]
2013-12-29 6:45 ` [PATCH 12/14] w1: ds2490 fix and enable hardware search David Fries
2013-12-29 6:45 ` [PATCH 13/14] w1: use family_data instead of rom in w1_slave David Fries
2013-12-29 6:45 ` [PATCH 14/14] w1: format for DocBook and fixes David Fries
2013-12-29 21:26 ` [PATCH 00/14] w1: async netlink, search, fixes, and improvements Evgeniy Polyakov
2014-01-15 4:52 ` [PATCH 16/16] hold bus_mutex in netlink and search David Fries
2014-01-15 20:58 ` Evgeniy Polyakov
2014-01-15 21:10 ` David Fries
2014-01-16 2:33 ` GregKH
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1388299556-12669-12-git-send-email-David@Fries.net \
--to=david@fries.net \
--cc=jwboyer@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lists@fuchsschwanzdomain.de \
--cc=marcin1j@gmail.com \
--cc=zbr@ioremap.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.