From: Rainer Weikusat <rainer.weikusat@sncag.com>
To: Greg KH <greg@kroah.com>,
"linux-kernel@vger.kernel.orgRainer Weikusat"
<rweikusat@sncag.com>
Cc: linux-kernel@vger.kernel.org, Rainer Weikusat <rweikusat@sncag.com>
Subject: [PATCH 2.6.20-rc3] fix for bugzilla #7544 (keyspan USB-to-serial converter)
Date: Wed, 03 Jan 2007 15:36:25 +0100 [thread overview]
Message-ID: <87ejqcdvo6.fsf@semtex.sncag.com> (raw)
In-Reply-To: <87irfodwk0.fsf@semtex.sncag.com> (Rainer Weikusat's message of "Wed, 03 Jan 2007 15:17:19 +0100")
At least the Keyspan USA-19HS USB-to-serial converter supports
two different configurations, one where the input endpoints
have interrupt transfer type and one where they are bulk endpoints.
The default UHCI configuration uses the interrupt input endpoints.
The keyspan driver, OTOH, assumes that the device has only bulk
endpoints (all URBs are initialized by calling usb_fill_bulk_urb
in keyspan.c/ keyspan_setup_urb). This causes the interval field
of the input URBs to have a value of zero instead of one, which
'accidentally' worked with Linux at least up to 2.6.17.11 but
stopped to with 2.6.18, which changed the UHCI support code handling
URBs for interrupt endpoints. The patch below modifies to driver to
initialize its input URBs either as interrupt or as bulk URBs,
depending on the transfertype contained in the associated endpoint
descriptor (only tested with the default configuration) enabling
the driver to again receive data from the serial converter.
Signed-off-by: Rainer Weikusat <rweikusat@sncag.com>
---
Modified to no longer call panic, but return NULL after having
logged a KERN_WARNING message first.
diff -purN linux-2.6.20-rc3/drivers/usb/serial/keyspan.c linux-2.6.20-rc3-keyspan/drivers/usb/serial/keyspan.c
--- linux-2.6.20-rc3/drivers/usb/serial/keyspan.c 2007-01-02 11:10:22.000000000 +0100
+++ linux-2.6.20-rc3-keyspan/drivers/usb/serial/keyspan.c 2007-01-03 15:18:24.000000000 +0100
@@ -1275,11 +1275,32 @@ static int keyspan_fake_startup (struct
}
/* Helper functions used by keyspan_setup_urbs */
+static struct usb_endpoint_descriptor const *
+find_ep_desc_for(struct usb_serial const *serial, int endpoint)
+{
+ struct usb_host_endpoint const *p, *e;
+
+ p = serial->interface->cur_altsetting->endpoint;
+ e = p + serial->interface->cur_altsetting->desc.bNumEndpoints;
+ while (p < e && p->desc.bEndpointAddress != endpoint) ++p;
+
+ if (p == e) {
+ printk(KERN_WARNING "%s - found no endpoint descriptor for "
+ "endpoint %d\n", __func__, endpoint);
+ return NULL;
+ }
+
+ return &p->desc;
+}
+
static struct urb *keyspan_setup_urb (struct usb_serial *serial, int endpoint,
int dir, void *ctx, char *buf, int len,
void (*callback)(struct urb *))
{
struct urb *urb;
+ struct usb_endpoint_descriptor const *ep_desc;
+ char const *ep_type_name;
+ unsigned ep_type;
if (endpoint == -1)
return NULL; /* endpoint not needed */
@@ -1290,12 +1311,34 @@ static struct urb *keyspan_setup_urb (st
dbg ("%s - alloc for endpoint %d failed.", __FUNCTION__, endpoint);
return NULL;
}
+
+ ep_desc = find_ep_desc_for(serial, endpoint);
+ ep_type = ep_desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK;
+ switch (ep_type) {
+ case USB_ENDPOINT_XFER_INT:
+ ep_type_name = "INT";
+ usb_fill_int_urb(urb, serial->dev,
+ usb_sndintpipe(serial->dev, endpoint) | dir,
+ buf, len, callback, ctx,
+ ep_desc->bInterval);
+ break;
- /* Fill URB using supplied data. */
- usb_fill_bulk_urb(urb, serial->dev,
- usb_sndbulkpipe(serial->dev, endpoint) | dir,
- buf, len, callback, ctx);
+ case USB_ENDPOINT_XFER_BULK:
+ ep_type_name = "BULK";
+ usb_fill_bulk_urb(urb, serial->dev,
+ usb_sndbulkpipe(serial->dev, endpoint) | dir,
+ buf, len, callback, ctx);
+ break;
+
+ default:
+ printk(KERN_WARNING "%s - unsupported endpoint type %d\n",
+ __func__, ep_type);
+ usb_free_urb(urb);
+ return NULL;
+ }
+ dbg("%s - using urb %p for %s endpoint %d",
+ __func__, urb, ep_type_name, endpoint);
return urb;
}
prev parent reply other threads:[~2007-01-03 14:36 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-01-02 18:16 [PATCH 2.6.20-rc3] fix for bugzilla #7544 (keyspan USB-to-serial converter) Rainer Weikusat
2007-01-03 1:37 ` Greg KH
2007-01-03 11:00 ` Rainer Weikusat
2007-01-03 14:17 ` Rainer Weikusat
2007-01-03 14:36 ` Rainer Weikusat [this message]
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=87ejqcdvo6.fsf@semtex.sncag.com \
--to=rainer.weikusat@sncag.com \
--cc=greg@kroah.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rweikusat@sncag.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox