[media] redrat3: cap duration in the right place
[firefly-linux-kernel-4.4.55.git] / drivers / media / rc / redrat3.c
index 5147767ccb78045523bbd7f37dd732063a86c388..ea5039b88c50363809c5db7d8b92f64e3cbcfe56 100644 (file)
@@ -414,20 +414,10 @@ static u32 redrat3_us_to_len(u32 microsec)
 
 }
 
-/* timer callback to send long trailing space on receive timeout */
+/* timer callback to send reset event */
 static void redrat3_rx_timeout(unsigned long data)
 {
        struct redrat3_dev *rr3 = (struct redrat3_dev *)data;
-       DEFINE_IR_RAW_EVENT(rawir);
-
-       rawir.pulse = false;
-       rawir.duration = rr3->rc->timeout;
-       rr3_dbg(rr3->dev, "storing trailing space with duration %d\n",
-               rawir.duration);
-       ir_raw_event_store_with_filter(rr3->rc, &rawir);
-
-       rr3_dbg(rr3->dev, "calling ir_raw_event_handle\n");
-       ir_raw_event_handle(rr3->rc);
 
        rr3_dbg(rr3->dev, "calling ir_raw_event_reset\n");
        ir_raw_event_reset(rr3->rc);
@@ -506,9 +496,6 @@ static void redrat3_process_ir_data(struct redrat3_dev *rr3)
                u16 val = len_vals[data_vals[i]];
                single_len = redrat3_len_to_us((u32)be16_to_cpu(val));
 
-               /* cap the value to IR_MAX_DURATION */
-               single_len &= IR_MAX_DURATION;
-
                /* we should always get pulse/space/pulse/space samples */
                if (i % 2)
                        rawir.pulse = false;
@@ -516,6 +503,9 @@ static void redrat3_process_ir_data(struct redrat3_dev *rr3)
                        rawir.pulse = true;
 
                rawir.duration = US_TO_NS(single_len);
+               /* cap the value to IR_MAX_DURATION */
+               rawir.duration &= IR_MAX_DURATION;
+
                rr3_dbg(dev, "storing %s with duration %d (i: %d)\n",
                        rawir.pulse ? "pulse" : "space", rawir.duration, i);
                ir_raw_event_store_with_filter(rr3->rc, &rawir);
@@ -1186,7 +1176,7 @@ static int __devinit redrat3_dev_probe(struct usb_interface *intf,
        rr3 = kzalloc(sizeof(*rr3), GFP_KERNEL);
        if (rr3 == NULL) {
                dev_err(dev, "Memory allocation failure\n");
-               goto error;
+               goto no_endpoints;
        }
 
        rr3->dev = &intf->dev;