[media] media: rc: nuvoton: remove usage of b_idx in nvt_get_rx_ir_data
authorHeiner Kallweit <hkallweit1@gmail.com>
Tue, 2 Aug 2016 05:44:44 +0000 (02:44 -0300)
committerMauro Carvalho Chehab <mchehab@s-opensource.com>
Thu, 22 Sep 2016 14:24:28 +0000 (11:24 -0300)
The call to nvt_get_rx_ir_data and nvt_process_rx_ir_data from
the ISR is protected with spinlock nvt->lock. Therefore it's
guaranteed that nvt->pkts is 0 when entering nvt_get_rx_ir_data
(as nvt->pkts is set to 0 at the end of nvt_process_rx_ir_data).
Having said that we can remove b_idx.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
drivers/media/rc/nuvoton-cir.c

index 0c69536..e4158a9 100644 (file)
@@ -802,7 +802,6 @@ static void nvt_handle_rx_fifo_overrun(struct nvt_dev *nvt)
 static void nvt_get_rx_ir_data(struct nvt_dev *nvt)
 {
        u8 fifocount, val;
-       unsigned int b_idx;
        int i;
 
        /* Get count of how many bytes to read from RX FIFO */
@@ -810,21 +809,13 @@ static void nvt_get_rx_ir_data(struct nvt_dev *nvt)
 
        nvt_dbg("attempting to fetch %u bytes from hw rx fifo", fifocount);
 
-       b_idx = nvt->pkts;
-
-       /* This should never happen, but lets check anyway... */
-       if (b_idx + fifocount > RX_BUF_LEN) {
-               nvt_process_rx_ir_data(nvt);
-               b_idx = 0;
-       }
-
        /* Read fifocount bytes from CIR Sample RX FIFO register */
        for (i = 0; i < fifocount; i++) {
                val = nvt_cir_reg_read(nvt, CIR_SRXFIFO);
-               nvt->buf[b_idx + i] = val;
+               nvt->buf[i] = val;
        }
 
-       nvt->pkts += fifocount;
+       nvt->pkts = fifocount;
        nvt_dbg("%s: pkts now %d", __func__, nvt->pkts);
 
        nvt_process_rx_ir_data(nvt);