Commit 3a918aa6 authored by Jarod Wilson's avatar Jarod Wilson Committed by Mauro Carvalho Chehab

[media] mceusb: mce_sync_in is brain-dead

Aside from the initial "hey, lets make sure we've flushed any
pre-existing data on the device" call to mce_sync_in, every other one of
the calls was entirely superfluous. Ergo, remove them all, and rename
the one and only (questionably) useful one to reflect what it really
does. Verified on both gen2 and gen3 hardware to make zero difference.
Well, except that you no longer get a bunch of urb submit failures from
the unneeded mce_sync_in calls. Oh. And move that flush to a point
*after* we've wired up the inbound urb, or it won't do squat. I have
half a mind to just remove it entirely, but someone thought it was
necessary at some point, and it doesn't seem to hurt, so lets leave it
for the time being.

This excercise took place due to insightful questions asked by Hans
Petter Selasky, about the possible reuse of the inbound urb before it
was actually availble by mce_sync_in, so thanks to him for motivating
this cleanup.
Reported-by: default avatarHans Petter Selasky <hselasky@c2i.net>
Signed-off-by: default avatarJarod Wilson <jarod@redhat.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent b825fe1b
...@@ -682,9 +682,9 @@ static void mce_async_out(struct mceusb_dev *ir, unsigned char *data, int size) ...@@ -682,9 +682,9 @@ static void mce_async_out(struct mceusb_dev *ir, unsigned char *data, int size)
mce_request_packet(ir, data, size, MCEUSB_TX); mce_request_packet(ir, data, size, MCEUSB_TX);
} }
static void mce_sync_in(struct mceusb_dev *ir, unsigned char *data, int size) static void mce_flush_rx_buffer(struct mceusb_dev *ir, int size)
{ {
mce_request_packet(ir, data, size, MCEUSB_RX); mce_request_packet(ir, NULL, size, MCEUSB_RX);
} }
/* Send data out the IR blaster port(s) */ /* Send data out the IR blaster port(s) */
...@@ -970,7 +970,6 @@ static void mceusb_dev_recv(struct urb *urb, struct pt_regs *regs) ...@@ -970,7 +970,6 @@ static void mceusb_dev_recv(struct urb *urb, struct pt_regs *regs)
static void mceusb_gen1_init(struct mceusb_dev *ir) static void mceusb_gen1_init(struct mceusb_dev *ir)
{ {
int ret; int ret;
int maxp = ir->len_in;
struct device *dev = ir->dev; struct device *dev = ir->dev;
char *data; char *data;
...@@ -1012,55 +1011,40 @@ static void mceusb_gen1_init(struct mceusb_dev *ir) ...@@ -1012,55 +1011,40 @@ static void mceusb_gen1_init(struct mceusb_dev *ir)
/* device reset */ /* device reset */
mce_async_out(ir, DEVICE_RESET, sizeof(DEVICE_RESET)); mce_async_out(ir, DEVICE_RESET, sizeof(DEVICE_RESET));
mce_sync_in(ir, NULL, maxp);
/* get hw/sw revision? */ /* get hw/sw revision? */
mce_async_out(ir, GET_REVISION, sizeof(GET_REVISION)); mce_async_out(ir, GET_REVISION, sizeof(GET_REVISION));
mce_sync_in(ir, NULL, maxp);
kfree(data); kfree(data);
}; };
static void mceusb_gen2_init(struct mceusb_dev *ir) static void mceusb_gen2_init(struct mceusb_dev *ir)
{ {
int maxp = ir->len_in;
/* device reset */ /* device reset */
mce_async_out(ir, DEVICE_RESET, sizeof(DEVICE_RESET)); mce_async_out(ir, DEVICE_RESET, sizeof(DEVICE_RESET));
mce_sync_in(ir, NULL, maxp);
/* get hw/sw revision? */ /* get hw/sw revision? */
mce_async_out(ir, GET_REVISION, sizeof(GET_REVISION)); mce_async_out(ir, GET_REVISION, sizeof(GET_REVISION));
mce_sync_in(ir, NULL, maxp);
/* unknown what the next two actually return... */ /* unknown what the next two actually return... */
mce_async_out(ir, GET_UNKNOWN, sizeof(GET_UNKNOWN)); mce_async_out(ir, GET_UNKNOWN, sizeof(GET_UNKNOWN));
mce_sync_in(ir, NULL, maxp);
mce_async_out(ir, GET_UNKNOWN2, sizeof(GET_UNKNOWN2)); mce_async_out(ir, GET_UNKNOWN2, sizeof(GET_UNKNOWN2));
mce_sync_in(ir, NULL, maxp);
} }
static void mceusb_get_parameters(struct mceusb_dev *ir) static void mceusb_get_parameters(struct mceusb_dev *ir)
{ {
int maxp = ir->len_in;
/* get the carrier and frequency */ /* get the carrier and frequency */
mce_async_out(ir, GET_CARRIER_FREQ, sizeof(GET_CARRIER_FREQ)); mce_async_out(ir, GET_CARRIER_FREQ, sizeof(GET_CARRIER_FREQ));
mce_sync_in(ir, NULL, maxp);
if (!ir->flags.no_tx) { if (!ir->flags.no_tx)
/* get the transmitter bitmask */ /* get the transmitter bitmask */
mce_async_out(ir, GET_TX_BITMASK, sizeof(GET_TX_BITMASK)); mce_async_out(ir, GET_TX_BITMASK, sizeof(GET_TX_BITMASK));
mce_sync_in(ir, NULL, maxp);
}
/* get receiver timeout value */ /* get receiver timeout value */
mce_async_out(ir, GET_RX_TIMEOUT, sizeof(GET_RX_TIMEOUT)); mce_async_out(ir, GET_RX_TIMEOUT, sizeof(GET_RX_TIMEOUT));
mce_sync_in(ir, NULL, maxp);
/* get receiver sensor setting */ /* get receiver sensor setting */
mce_async_out(ir, GET_RX_SENSOR, sizeof(GET_RX_SENSOR)); mce_async_out(ir, GET_RX_SENSOR, sizeof(GET_RX_SENSOR));
mce_sync_in(ir, NULL, maxp);
} }
static struct rc_dev *mceusb_init_rc_dev(struct mceusb_dev *ir) static struct rc_dev *mceusb_init_rc_dev(struct mceusb_dev *ir)
...@@ -1224,16 +1208,16 @@ static int __devinit mceusb_dev_probe(struct usb_interface *intf, ...@@ -1224,16 +1208,16 @@ static int __devinit mceusb_dev_probe(struct usb_interface *intf,
if (!ir->rc) if (!ir->rc)
goto rc_dev_fail; goto rc_dev_fail;
/* flush buffers on the device */
mce_sync_in(ir, NULL, maxp);
mce_sync_in(ir, NULL, maxp);
/* wire up inbound data handler */ /* wire up inbound data handler */
usb_fill_int_urb(ir->urb_in, dev, pipe, ir->buf_in, usb_fill_int_urb(ir->urb_in, dev, pipe, ir->buf_in,
maxp, (usb_complete_t) mceusb_dev_recv, ir, ep_in->bInterval); maxp, (usb_complete_t) mceusb_dev_recv, ir, ep_in->bInterval);
ir->urb_in->transfer_dma = ir->dma_in; ir->urb_in->transfer_dma = ir->dma_in;
ir->urb_in->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; ir->urb_in->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
/* flush buffers on the device */
mce_dbg(&intf->dev, "Flushing receive buffers\n");
mce_flush_rx_buffer(ir, maxp);
/* initialize device */ /* initialize device */
if (ir->flags.microsoft_gen1) if (ir->flags.microsoft_gen1)
mceusb_gen1_init(ir); mceusb_gen1_init(ir);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment