Commit f933d160 authored by Jia-Ju Bai's avatar Jia-Ju Bai Committed by Mauro Carvalho Chehab

media: usb: ttusb-dec: reduce the number of memory reads in ttusb_dec_handle_irq()

In ttusb_dec_handle_irq(), buffer[4] is continuously read from memory
three times, without being modified.
To reduce the number of memory reads, buffer[4] is first assigned to a
local variable index, and then index is used to replace buffer[4].
Signed-off-by: default avatarJia-Ju Bai <baijiaju1990@gmail.com>
Reviewed-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarSean Young <sean@mess.org>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent 4e054aab
...@@ -250,6 +250,7 @@ static void ttusb_dec_handle_irq( struct urb *urb) ...@@ -250,6 +250,7 @@ static void ttusb_dec_handle_irq( struct urb *urb)
struct ttusb_dec *dec = urb->context; struct ttusb_dec *dec = urb->context;
char *buffer = dec->irq_buffer; char *buffer = dec->irq_buffer;
int retval; int retval;
int index = buffer[4];
switch(urb->status) { switch(urb->status) {
case 0: /*success*/ case 0: /*success*/
...@@ -281,11 +282,11 @@ static void ttusb_dec_handle_irq( struct urb *urb) ...@@ -281,11 +282,11 @@ static void ttusb_dec_handle_irq( struct urb *urb)
* this should/could be added later ... * this should/could be added later ...
* for now lets report each signal as a key down and up * for now lets report each signal as a key down and up
*/ */
if (buffer[4] - 1 < ARRAY_SIZE(rc_keys)) { if (index - 1 < ARRAY_SIZE(rc_keys)) {
dprintk("%s:rc signal:%d\n", __func__, buffer[4]); dprintk("%s:rc signal:%d\n", __func__, index);
input_report_key(dec->rc_input_dev, rc_keys[buffer[4] - 1], 1); input_report_key(dec->rc_input_dev, rc_keys[index - 1], 1);
input_sync(dec->rc_input_dev); input_sync(dec->rc_input_dev);
input_report_key(dec->rc_input_dev, rc_keys[buffer[4] - 1], 0); input_report_key(dec->rc_input_dev, rc_keys[index - 1], 0);
input_sync(dec->rc_input_dev); input_sync(dec->rc_input_dev);
} }
} }
......
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