From: Jarod Wilson <jarod@redhat.com>
To: Mauro Carvalho Chehab <mchehab@redhat.com>
Cc: "linux-media@vger.kernel.org" <linux-media@vger.kernel.org>
Subject: [PATCH] IR/mceusb: unify and simplify different gen device init
Date: Sat, 3 Jul 2010 21:42:14 -0400 [thread overview]
Message-ID: <20100704014214.GD17081@redhat.com> (raw)
In-Reply-To: <AANLkTimbfm9nGxtNyCnpNFz3WhP1g6CzMQvRP0lJe9Dc@mail.gmail.com>
Started out as an effort to try to tackle the last remaining issue I'm
having with this damned pinnacle device getting wedged the first time
its plugged in after an indeterminate length of not being plugged in.
Didn't get that solved yet, but did streamline the init code a bit more
and remove some superfluous gunk. Nukes a completely unneeded call to
usb_device_init() and several lines of overly complex crap in the gen1
device init path.
Signed-off-by: Jarod Wilson <jarod@redhat.com>
---
drivers/media/IR/mceusb.c | 47 ++++++--------------------------------------
1 files changed, 7 insertions(+), 40 deletions(-)
diff --git a/drivers/media/IR/mceusb.c b/drivers/media/IR/mceusb.c
index aaa40d8..46de9bc 100644
--- a/drivers/media/IR/mceusb.c
+++ b/drivers/media/IR/mceusb.c
@@ -766,47 +766,18 @@ static void mceusb_gen1_init(struct mceusb_dev *ir)
int i, ret;
int partial = 0;
struct device *dev = ir->dev;
- char *junk, *data;
-
- junk = kmalloc(2 * USB_BUFLEN, GFP_KERNEL);
- if (!junk) {
- dev_err(dev, "%s: memory allocation failed!\n", __func__);
- return;
- }
+ char *data;
data = kzalloc(USB_CTRL_MSG_SZ, GFP_KERNEL);
if (!data) {
dev_err(dev, "%s: memory allocation failed!\n", __func__);
- kfree(junk);
return;
}
/*
- * Clear off the first few messages. These look like calibration
- * or test data, I can't really tell. This also flushes in case
- * we have random ir data queued up.
- */
- for (i = 0; i < MCE_G1_INIT_MSGS; i++)
- usb_bulk_msg(ir->usbdev,
- usb_rcvbulkpipe(ir->usbdev,
- ir->usb_ep_in->bEndpointAddress),
- junk, sizeof(junk), &partial, HZ * 10);
-
- /* Get Status */
- ret = usb_control_msg(ir->usbdev, usb_rcvctrlpipe(ir->usbdev, 0),
- USB_REQ_GET_STATUS, USB_DIR_IN,
- 0, 0, data, USB_CTRL_MSG_SZ, HZ * 3);
-
- /* ret = usb_get_status( ir->usbdev, 0, 0, data ); */
- dev_dbg(dev, "%s - ret = %d status = 0x%x 0x%x\n", __func__,
- ret, data[0], data[1]);
-
- /*
- * This is a strange one. They issue a set address to the device
+ * This is a strange one. Windows issues a set address to the device
* on the receive control pipe and expect a certain value pair back
*/
- memset(data, 0, sizeof(data));
-
ret = usb_control_msg(ir->usbdev, usb_rcvctrlpipe(ir->usbdev, 0),
USB_REQ_SET_ADDRESS, USB_TYPE_VENDOR, 0, 0,
data, USB_CTRL_MSG_SZ, HZ * 3);
@@ -834,16 +805,12 @@ static void mceusb_gen1_init(struct mceusb_dev *ir)
dev_dbg(dev, "%s - retC = %d\n", __func__, ret);
kfree(data);
- kfree(junk);
};
static void mceusb_gen2_init(struct mceusb_dev *ir)
{
int maxp = ir->len_in;
- mce_sync_in(ir, NULL, maxp);
- mce_sync_in(ir, NULL, maxp);
-
/* device reset */
mce_async_out(ir, DEVICE_RESET, sizeof(DEVICE_RESET));
mce_sync_in(ir, NULL, maxp);
@@ -861,8 +828,6 @@ static void mceusb_gen3_init(struct mceusb_dev *ir)
{
int maxp = ir->len_in;
- mce_sync_in(ir, NULL, maxp);
-
/* device reset */
mce_async_out(ir, DEVICE_RESET, sizeof(DEVICE_RESET));
mce_sync_in(ir, NULL, maxp);
@@ -969,8 +934,6 @@ static int __devinit mceusb_dev_probe(struct usb_interface *intf,
dev_dbg(&intf->dev, ": %s called\n", __func__);
- usb_reset_device(dev);
-
config = dev->actconfig;
idesc = intf->cur_altsetting;
@@ -1057,7 +1020,11 @@ static int __devinit mceusb_dev_probe(struct usb_interface *intf,
if (!ir->idev)
goto input_dev_fail;
- /* inbound data */
+ /* flush buffers on the device */
+ mce_sync_in(ir, NULL, maxp);
+ mce_sync_in(ir, NULL, maxp);
+
+ /* wire up inbound data handler */
usb_fill_int_urb(ir->urb_in, dev, pipe, ir->buf_in,
maxp, (usb_complete_t) mceusb_dev_recv, ir, ep_in->bInterval);
ir->urb_in->transfer_dma = ir->dma_in;
--
1.7.1
--
Jarod Wilson
jarod@redhat.com
prev parent reply other threads:[~2010-07-04 1:42 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-16 20:10 [PATCH] IR/mceusb: kill pinnacle-device-specific nonsense Jarod Wilson
2010-07-03 4:02 ` [PATCH v3] " Jarod Wilson
2010-07-03 22:17 ` Mauro Carvalho Chehab
2010-07-04 0:41 ` [PATCH] " Jarod Wilson
2010-07-04 1:42 ` Jarod Wilson [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=20100704014214.GD17081@redhat.com \
--to=jarod@redhat.com \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@redhat.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;
as well as URLs for NNTP newsgroup(s).