This is the mail archive of the
ecos-patches@sourceware.org
mailing list for the eCos project.
Re: USB serial linux kernel module
- From: Frank Pagliughi <fpagliughi at mindspring dot com>
- To: Andrew Lunn <andrew at lunn dot ch>
- Cc: eCos Patches <ecos-patches at ecos dot sourceware dot org>
- Date: Sat, 09 Aug 2008 10:29:41 -0400
- Subject: Re: USB serial linux kernel module
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=dk20050327; d=mindspring.com; b=bUXy/AC55rCJZluwo0AoXVcrPQuwvJWNLBAnQGdhDQe0k/9pIPMqiiQgRsIP6cbE; h=Received:Message-ID:Date:From:User-Agent:MIME-Version:To:CC:Subject:References:In-Reply-To:Content-Type:X-ELNK-Trace:X-Originating-IP;
- References: <20080713130144.GL4167@lunn.ch>
Andrew Lunn wrote:
Hi Frank
I worked on the Linux kernel module for the USB serial interface.
Attached is a patch that allows it to compile with 2.6.26-rc9. The
patch also handles the device when it is in ACM mode. I found that
Linux attaches a device to the ACM interface which just has an
interrupt endpoint. This device is useless. By adding a probe function
i can detect this interface and tell the usb-serial layer to ignore
it.
Please could you test this patch and let me know if it works for
you. If so, i will commit it.
Thanks
Andrew
Andrew,
This should patch your version of the ecos_usbserial.c Linux driver. It
brings in endpoint check functions for older versions of the kernel. I
tried this on Fedora 6 (older) and Fedora 8 (newer) and it worked on both.
Thanks for the help with this. I'm relieved to have a single version
that works with both Windows and Linux hosts. I would have never thought
of doing it this way.
Frank
--- andrews_ecos_usbserial.c 2008-08-09 09:26:54.000000000 -0400
+++ ecos_usbserial.c 2008-08-09 09:39:28.000000000 -0400
@@ -58,6 +58,18 @@
static int debug;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
+static inline int usb_endpoint_xfer_bulk(
+ const struct usb_endpoint_descriptor *endpoint) {
+ return (endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
+ USB_ENDPOINT_XFER_BULK;
+}
+
+static inline int usb_endpoint_dir_in(const struct usb_endpoint_descriptor *epd) {
+ return (epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN;
+}
+#endif
+
/* Our probe function will detect if the interface has sufficient bulk
* in and out endpoints to be useful. The ACM interface only has an
* interrupt endpoint, so we don't want a serial device bound to it.
@@ -77,20 +89,21 @@
for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) {
endpoint = &iface_desc->endpoint[i].desc;
- if (usb_endpoint_is_bulk_in(endpoint)) {
- /* we found a bulk in endpoint */
- dbg("found bulk in on endpoint %d", i);
+ if (usb_endpoint_xfer_bulk(endpoint)) {
+ if (usb_endpoint_dir_in(endpoint)) {
+ /* we found a bulk in endpoint */
+ dbg("found bulk in on endpoint %d", i);
++num_bulk_in;
- }
-
- if (usb_endpoint_is_bulk_out(endpoint)) {
- /* we found a bulk out endpoint */
+ }
+ else {
+ /* we found a bulk out endpoint */
dbg("found bulk out on endpoint %d", i);
++num_bulk_out;
- }
+ }
+ }
}
- if (!num_bulk_out || !num_bulk_out) {
+ if (!num_bulk_in || !num_bulk_out) {
info("Ignoring interface, insufficient endpoints");
return -ENODEV;
}