aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJarod Wilson <jarod@redhat.com>2011-05-26 13:23:18 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2011-06-11 08:02:07 -0400
commit3a918aa69daf001910640cc910ea4053ba840a6e (patch)
tree614c95836ee77cf58b1b24b46d55889774461468
parentb825fe1b1bb5927402c3d3084641355946ef05f8 (diff)
[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: Hans Petter Selasky <hselasky@c2i.net> Signed-off-by: Jarod Wilson <jarod@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r--drivers/media/rc/mceusb.c30
1 files changed, 7 insertions, 23 deletions
diff --git a/drivers/media/rc/mceusb.c b/drivers/media/rc/mceusb.c
index 650b2f47951..6cf22012079 100644
--- a/drivers/media/rc/mceusb.c
+++ b/drivers/media/rc/mceusb.c
@@ -682,9 +682,9 @@ static void mce_async_out(struct mceusb_dev *ir, unsigned char *data, int size)
682 mce_request_packet(ir, data, size, MCEUSB_TX); 682 mce_request_packet(ir, data, size, MCEUSB_TX);
683} 683}
684 684
685static void mce_sync_in(struct mceusb_dev *ir, unsigned char *data, int size) 685static void mce_flush_rx_buffer(struct mceusb_dev *ir, int size)
686{ 686{
687 mce_request_packet(ir, data, size, MCEUSB_RX); 687 mce_request_packet(ir, NULL, size, MCEUSB_RX);
688} 688}
689 689
690/* Send data out the IR blaster port(s) */ 690/* Send data out the IR blaster port(s) */
@@ -970,7 +970,6 @@ static void mceusb_dev_recv(struct urb *urb, struct pt_regs *regs)
970static void mceusb_gen1_init(struct mceusb_dev *ir) 970static void mceusb_gen1_init(struct mceusb_dev *ir)
971{ 971{
972 int ret; 972 int ret;
973 int maxp = ir->len_in;
974 struct device *dev = ir->dev; 973 struct device *dev = ir->dev;
975 char *data; 974 char *data;
976 975
@@ -1012,55 +1011,40 @@ static void mceusb_gen1_init(struct mceusb_dev *ir)
1012 1011
1013 /* device reset */ 1012 /* device reset */
1014 mce_async_out(ir, DEVICE_RESET, sizeof(DEVICE_RESET)); 1013 mce_async_out(ir, DEVICE_RESET, sizeof(DEVICE_RESET));
1015 mce_sync_in(ir, NULL, maxp);
1016 1014
1017 /* get hw/sw revision? */ 1015 /* get hw/sw revision? */
1018 mce_async_out(ir, GET_REVISION, sizeof(GET_REVISION)); 1016 mce_async_out(ir, GET_REVISION, sizeof(GET_REVISION));
1019 mce_sync_in(ir, NULL, maxp);
1020 1017
1021 kfree(data); 1018 kfree(data);
1022}; 1019};
1023 1020
1024static void mceusb_gen2_init(struct mceusb_dev *ir) 1021static void mceusb_gen2_init(struct mceusb_dev *ir)
1025{ 1022{
1026 int maxp = ir->len_in;
1027
1028 /* device reset */ 1023 /* device reset */
1029 mce_async_out(ir, DEVICE_RESET, sizeof(DEVICE_RESET)); 1024 mce_async_out(ir, DEVICE_RESET, sizeof(DEVICE_RESET));
1030 mce_sync_in(ir, NULL, maxp);
1031 1025
1032 /* get hw/sw revision? */ 1026 /* get hw/sw revision? */
1033 mce_async_out(ir, GET_REVISION, sizeof(GET_REVISION)); 1027 mce_async_out(ir, GET_REVISION, sizeof(GET_REVISION));
1034 mce_sync_in(ir, NULL, maxp);
1035 1028
1036 /* unknown what the next two actually return... */ 1029 /* unknown what the next two actually return... */
1037 mce_async_out(ir, GET_UNKNOWN, sizeof(GET_UNKNOWN)); 1030 mce_async_out(ir, GET_UNKNOWN, sizeof(GET_UNKNOWN));
1038 mce_sync_in(ir, NULL, maxp);
1039 mce_async_out(ir, GET_UNKNOWN2, sizeof(GET_UNKNOWN2)); 1031 mce_async_out(ir, GET_UNKNOWN2, sizeof(GET_UNKNOWN2));
1040 mce_sync_in(ir, NULL, maxp);
1041} 1032}
1042 1033
1043static void mceusb_get_parameters(struct mceusb_dev *ir) 1034static void mceusb_get_parameters(struct mceusb_dev *ir)
1044{ 1035{
1045 int maxp = ir->len_in;
1046
1047 /* get the carrier and frequency */ 1036 /* get the carrier and frequency */
1048 mce_async_out(ir, GET_CARRIER_FREQ, sizeof(GET_CARRIER_FREQ)); 1037 mce_async_out(ir, GET_CARRIER_FREQ, sizeof(GET_CARRIER_FREQ));
1049 mce_sync_in(ir, NULL, maxp);
1050 1038
1051 if (!ir->flags.no_tx) { 1039 if (!ir->flags.no_tx)
1052 /* get the transmitter bitmask */ 1040 /* get the transmitter bitmask */
1053 mce_async_out(ir, GET_TX_BITMASK, sizeof(GET_TX_BITMASK)); 1041 mce_async_out(ir, GET_TX_BITMASK, sizeof(GET_TX_BITMASK));
1054 mce_sync_in(ir, NULL, maxp);
1055 }
1056 1042
1057 /* get receiver timeout value */ 1043 /* get receiver timeout value */
1058 mce_async_out(ir, GET_RX_TIMEOUT, sizeof(GET_RX_TIMEOUT)); 1044 mce_async_out(ir, GET_RX_TIMEOUT, sizeof(GET_RX_TIMEOUT));
1059 mce_sync_in(ir, NULL, maxp);
1060 1045
1061 /* get receiver sensor setting */ 1046 /* get receiver sensor setting */
1062 mce_async_out(ir, GET_RX_SENSOR, sizeof(GET_RX_SENSOR)); 1047 mce_async_out(ir, GET_RX_SENSOR, sizeof(GET_RX_SENSOR));
1063 mce_sync_in(ir, NULL, maxp);
1064} 1048}
1065 1049
1066static struct rc_dev *mceusb_init_rc_dev(struct mceusb_dev *ir) 1050static 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 if (!ir->rc) 1208 if (!ir->rc)
1225 goto rc_dev_fail; 1209 goto rc_dev_fail;
1226 1210
1227 /* flush buffers on the device */
1228 mce_sync_in(ir, NULL, maxp);
1229 mce_sync_in(ir, NULL, maxp);
1230
1231 /* wire up inbound data handler */ 1211 /* wire up inbound data handler */
1232 usb_fill_int_urb(ir->urb_in, dev, pipe, ir->buf_in, 1212 usb_fill_int_urb(ir->urb_in, dev, pipe, ir->buf_in,
1233 maxp, (usb_complete_t) mceusb_dev_recv, ir, ep_in->bInterval); 1213 maxp, (usb_complete_t) mceusb_dev_recv, ir, ep_in->bInterval);
1234 ir->urb_in->transfer_dma = ir->dma_in; 1214 ir->urb_in->transfer_dma = ir->dma_in;
1235 ir->urb_in->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; 1215 ir->urb_in->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
1236 1216
1217 /* flush buffers on the device */
1218 mce_dbg(&intf->dev, "Flushing receive buffers\n");
1219 mce_flush_rx_buffer(ir, maxp);
1220
1237 /* initialize device */ 1221 /* initialize device */
1238 if (ir->flags.microsoft_gen1) 1222 if (ir->flags.microsoft_gen1)
1239 mceusb_gen1_init(ir); 1223 mceusb_gen1_init(ir);