aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/IR/mceusb.c
diff options
context:
space:
mode:
authorJarod Wilson <jarod@redhat.com>2010-07-03 21:42:14 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2010-08-02 14:34:49 -0400
commitb48592e496e55e4e3e6e7f27d5ba3a229a1db7a6 (patch)
treeb007fb6e65213c251e3d8d3250d2c430feabe435 /drivers/media/IR/mceusb.c
parent95c5d605ca6fd6ab5ab0f6d097ff97d5aa2f9235 (diff)
V4L/DVB: IR/mceusb: unify and simplify different gen device init
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> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/IR/mceusb.c')
-rw-r--r--drivers/media/IR/mceusb.c50
1 files changed, 7 insertions, 43 deletions
diff --git a/drivers/media/IR/mceusb.c b/drivers/media/IR/mceusb.c
index cc8e2ef28b66..3c056a8fba7f 100644
--- a/drivers/media/IR/mceusb.c
+++ b/drivers/media/IR/mceusb.c
@@ -768,47 +768,18 @@ static void mceusb_gen1_init(struct mceusb_dev *ir)
768 int i, ret; 768 int i, ret;
769 int partial = 0; 769 int partial = 0;
770 struct device *dev = ir->dev; 770 struct device *dev = ir->dev;
771 char *junk, *data; 771 char *data;
772
773 junk = kmalloc(2 * USB_BUFLEN, GFP_KERNEL);
774 if (!junk) {
775 dev_err(dev, "%s: memory allocation failed!\n", __func__);
776 return;
777 }
778 772
779 data = kzalloc(USB_CTRL_MSG_SZ, GFP_KERNEL); 773 data = kzalloc(USB_CTRL_MSG_SZ, GFP_KERNEL);
780 if (!data) { 774 if (!data) {
781 dev_err(dev, "%s: memory allocation failed!\n", __func__); 775 dev_err(dev, "%s: memory allocation failed!\n", __func__);
782 kfree(junk);
783 return; 776 return;
784 } 777 }
785 778
786 /* 779 /*
787 * Clear off the first few messages. These look like calibration 780 * This is a strange one. Windows issues a set address to the device
788 * or test data, I can't really tell. This also flushes in case
789 * we have random ir data queued up.
790 */
791 for (i = 0; i < MCE_G1_INIT_MSGS; i++)
792 usb_bulk_msg(ir->usbdev,
793 usb_rcvbulkpipe(ir->usbdev,
794 ir->usb_ep_in->bEndpointAddress),
795 junk, sizeof(junk), &partial, HZ * 10);
796
797 /* Get Status */
798 ret = usb_control_msg(ir->usbdev, usb_rcvctrlpipe(ir->usbdev, 0),
799 USB_REQ_GET_STATUS, USB_DIR_IN,
800 0, 0, data, USB_CTRL_MSG_SZ, HZ * 3);
801
802 /* ret = usb_get_status( ir->usbdev, 0, 0, data ); */
803 dev_dbg(dev, "%s - ret = %d status = 0x%x 0x%x\n", __func__,
804 ret, data[0], data[1]);
805
806 /*
807 * This is a strange one. They issue a set address to the device
808 * on the receive control pipe and expect a certain value pair back 781 * on the receive control pipe and expect a certain value pair back
809 */ 782 */
810 memset(data, 0, sizeof(data));
811
812 ret = usb_control_msg(ir->usbdev, usb_rcvctrlpipe(ir->usbdev, 0), 783 ret = usb_control_msg(ir->usbdev, usb_rcvctrlpipe(ir->usbdev, 0),
813 USB_REQ_SET_ADDRESS, USB_TYPE_VENDOR, 0, 0, 784 USB_REQ_SET_ADDRESS, USB_TYPE_VENDOR, 0, 0,
814 data, USB_CTRL_MSG_SZ, HZ * 3); 785 data, USB_CTRL_MSG_SZ, HZ * 3);
@@ -836,19 +807,12 @@ static void mceusb_gen1_init(struct mceusb_dev *ir)
836 dev_dbg(dev, "%s - retC = %d\n", __func__, ret); 807 dev_dbg(dev, "%s - retC = %d\n", __func__, ret);
837 808
838 kfree(data); 809 kfree(data);
839 kfree(junk);
840}; 810};
841 811
842static void mceusb_gen2_init(struct mceusb_dev *ir) 812static void mceusb_gen2_init(struct mceusb_dev *ir)
843{ 813{
844 int maxp = ir->len_in; 814 int maxp = ir->len_in;
845 815
846 mce_sync_in(ir, NULL, maxp);
847 mce_sync_in(ir, NULL, maxp);
848
849 set_current_state(TASK_INTERRUPTIBLE);
850 schedule_timeout(msecs_to_jiffies(100));
851
852 /* device reset */ 816 /* device reset */
853 mce_async_out(ir, DEVICE_RESET, sizeof(DEVICE_RESET)); 817 mce_async_out(ir, DEVICE_RESET, sizeof(DEVICE_RESET));
854 mce_sync_in(ir, NULL, maxp); 818 mce_sync_in(ir, NULL, maxp);
@@ -866,8 +830,6 @@ static void mceusb_gen3_init(struct mceusb_dev *ir)
866{ 830{
867 int maxp = ir->len_in; 831 int maxp = ir->len_in;
868 832
869 mce_sync_in(ir, NULL, maxp);
870
871 /* device reset */ 833 /* device reset */
872 mce_async_out(ir, DEVICE_RESET, sizeof(DEVICE_RESET)); 834 mce_async_out(ir, DEVICE_RESET, sizeof(DEVICE_RESET));
873 mce_sync_in(ir, NULL, maxp); 835 mce_sync_in(ir, NULL, maxp);
@@ -974,8 +936,6 @@ static int __devinit mceusb_dev_probe(struct usb_interface *intf,
974 936
975 dev_dbg(&intf->dev, ": %s called\n", __func__); 937 dev_dbg(&intf->dev, ": %s called\n", __func__);
976 938
977 usb_reset_device(dev);
978
979 config = dev->actconfig; 939 config = dev->actconfig;
980 idesc = intf->cur_altsetting; 940 idesc = intf->cur_altsetting;
981 941
@@ -1062,7 +1022,11 @@ static int __devinit mceusb_dev_probe(struct usb_interface *intf,
1062 if (!ir->idev) 1022 if (!ir->idev)
1063 goto input_dev_fail; 1023 goto input_dev_fail;
1064 1024
1065 /* inbound data */ 1025 /* flush buffers on the device */
1026 mce_sync_in(ir, NULL, maxp);
1027 mce_sync_in(ir, NULL, maxp);
1028
1029 /* wire up inbound data handler */
1066 usb_fill_int_urb(ir->urb_in, dev, pipe, ir->buf_in, 1030 usb_fill_int_urb(ir->urb_in, dev, pipe, ir->buf_in,
1067 maxp, (usb_complete_t) mceusb_dev_recv, ir, ep_in->bInterval); 1031 maxp, (usb_complete_t) mceusb_dev_recv, ir, ep_in->bInterval);
1068 ir->urb_in->transfer_dma = ir->dma_in; 1032 ir->urb_in->transfer_dma = ir->dma_in;