From: Alon Ziv <alon+git@nolaviz.org>
To: linux-usb@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, Alon Ziv <alon+git@nolaviz.org>
Subject: [PATCH 2/3] Add Opticon OPN2001 write support
Date: Sun, 10 Oct 2010 08:32:19 +0200 [thread overview]
Message-ID: <1286692340-18639-3-git-send-email-alon-git@nolaviz.org> (raw)
In-Reply-To: <1286692340-18639-1-git-send-email-alon-git@nolaviz.org>
OPN2001 expects write operations to arrive as a vendor-specific command
through the control pipe (instead of using a separate bulk-out pipe).
Signed-off-by: Alon Ziv <alon-git@nolaviz.org>
---
drivers/usb/serial/opticon.c | 30 ++++++++++++++++++++++++++----
1 files changed, 26 insertions(+), 4 deletions(-)
diff --git a/drivers/usb/serial/opticon.c b/drivers/usb/serial/opticon.c
index 9ff19c8..4fe7c3d 100644
--- a/drivers/usb/serial/opticon.c
+++ b/drivers/usb/serial/opticon.c
@@ -187,6 +187,9 @@ static void opticon_write_bulk_callback(struct urb *urb)
/* free up the transfer buffer, as usb_free_urb() does not do this */
kfree(urb->transfer_buffer);
+ /* setup packet may be set if we're using it for writing */
+ kfree(urb->setup_packet);
+
if (status)
dbg("%s - nonzero write bulk status received: %d",
__func__, status);
@@ -237,10 +240,29 @@ static int opticon_write(struct tty_struct *tty, struct usb_serial_port *port,
usb_serial_debug_data(debug, &port->dev, __func__, count, buffer);
- usb_fill_bulk_urb(urb, serial->dev,
- usb_sndbulkpipe(serial->dev,
- port->bulk_out_endpointAddress),
- buffer, count, opticon_write_bulk_callback, priv);
+ if (port->bulk_out_endpointAddress) {
+ usb_fill_bulk_urb(urb, serial->dev,
+ usb_sndbulkpipe(serial->dev,
+ port->bulk_out_endpointAddress),
+ buffer, count, opticon_write_bulk_callback, priv);
+ } else {
+ struct usb_ctrlrequest *dr;
+
+ dr = kmalloc(sizeof(struct usb_ctrlrequest), GFP_NOIO);
+ if (!dr)
+ return -ENOMEM;
+
+ dr->bRequestType = USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT;
+ dr->bRequest = 0x01;
+ dr->wValue = 0;
+ dr->wIndex = 0;
+ dr->wLength = cpu_to_le16(count);
+
+ usb_fill_control_urb(urb, serial->dev,
+ usb_sndctrlpipe(serial->dev, 0),
+ (unsigned char *)dr, buffer, count,
+ opticon_write_bulk_callback, priv);
+ }
/* send it down the pipe */
status = usb_submit_urb(urb, GFP_ATOMIC);
--
1.6.3.3
next prev parent reply other threads:[~2010-10-10 6:48 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-10 6:32 [PATCH 0/3] opticon driver fixes Alon Ziv
2010-10-10 6:32 ` [PATCH 1/3] Fix long-standing bugs in opticon driver Alon Ziv
2010-10-10 6:32 ` Alon Ziv [this message]
2010-10-10 10:53 ` [PATCH 2/3] Add Opticon OPN2001 write support Sergei Shtylyov
2010-10-10 12:34 ` Greg KH
2010-10-10 13:58 ` Sergei Shtylyov
2010-10-10 14:52 ` Greg KH
2010-10-10 6:32 ` [PATCH 3/3] Whitespace fixes in opticon driver Alon Ziv
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=1286692340-18639-3-git-send-email-alon-git@nolaviz.org \
--to=alon+git@nolaviz.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
/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
all inboxes | Powered by JetHome®