From patchwork Sun Jul 4 01:42:14 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jarod Wilson X-Patchwork-Id: 110078 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.4/8.14.3) with ESMTP id o641gRe0028275 for ; Sun, 4 Jul 2010 01:42:30 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756528Ab0GDBmQ (ORCPT ); Sat, 3 Jul 2010 21:42:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52999 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756522Ab0GDBmQ (ORCPT ); Sat, 3 Jul 2010 21:42:16 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o641gF4D022784 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sat, 3 Jul 2010 21:42:16 -0400 Received: from ihatethathostname.lab.bos.redhat.com (ihatethathostname.lab.bos.redhat.com [10.16.43.238]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o641gEOM029977 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 3 Jul 2010 21:42:15 -0400 Received: from ihatethathostname.lab.bos.redhat.com (ihatethathostname.lab.bos.redhat.com [127.0.0.1]) by ihatethathostname.lab.bos.redhat.com (8.14.4/8.14.3) with ESMTP id o641gECi017275; Sat, 3 Jul 2010 21:42:14 -0400 Received: (from jarod@localhost) by ihatethathostname.lab.bos.redhat.com (8.14.4/8.14.4/Submit) id o641gEIW017273; Sat, 3 Jul 2010 21:42:14 -0400 X-Authentication-Warning: ihatethathostname.lab.bos.redhat.com: jarod set sender to jarod@redhat.com using -f Date: Sat, 3 Jul 2010 21:42:14 -0400 From: Jarod Wilson To: Mauro Carvalho Chehab Cc: "linux-media@vger.kernel.org" Subject: [PATCH] IR/mceusb: unify and simplify different gen device init Message-ID: <20100704014214.GD17081@redhat.com> References: <20100616201046.GA10000@redhat.com> <20100703040227.GA31255@redhat.com> <4C2FB6E8.5090001@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.20 (2009-12-10) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Sun, 04 Jul 2010 01:42:30 +0000 (UTC) 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;