hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/media/rc/ttusbir.c
....@@ -1,17 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * TechnoTrend USB IR Receiver
34 *
45 * Copyright (C) 2012 Sean Young <sean@mess.org>
5
- *
6
- * This program is free software; you can redistribute it and/or modify
7
- * it under the terms of the GNU General Public License as published by
8
- * the Free Software Foundation; either version 2 of the License, or
9
- * (at your option) any later version.
10
- *
11
- * This program is distributed in the hope that it will be useful,
12
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- * GNU General Public License for more details.
156 */
167
178 #include <linux/module.h>
....@@ -29,8 +20,8 @@
2920 * messages per second (!), whether IR is idle or not.
3021 */
3122 #define NUM_URBS 4
32
-#define NS_PER_BYTE 62500
33
-#define NS_PER_BIT (NS_PER_BYTE/8)
23
+#define US_PER_BYTE 62
24
+#define US_PER_BIT (US_PER_BYTE / 8)
3425
3526 struct ttusbir {
3627 struct rc_dev *rc;
....@@ -117,24 +108,22 @@
117108 */
118109 static void ttusbir_process_ir_data(struct ttusbir *tt, uint8_t *buf)
119110 {
120
- struct ir_raw_event rawir;
111
+ struct ir_raw_event rawir = {};
121112 unsigned i, v, b;
122113 bool event = false;
123
-
124
- init_ir_raw_event(&rawir);
125114
126115 for (i = 0; i < 128; i++) {
127116 v = buf[i] & 0xfe;
128117 switch (v) {
129118 case 0xfe:
130119 rawir.pulse = false;
131
- rawir.duration = NS_PER_BYTE;
120
+ rawir.duration = US_PER_BYTE;
132121 if (ir_raw_event_store_with_filter(tt->rc, &rawir))
133122 event = true;
134123 break;
135124 case 0:
136125 rawir.pulse = true;
137
- rawir.duration = NS_PER_BYTE;
126
+ rawir.duration = US_PER_BYTE;
138127 if (ir_raw_event_store_with_filter(tt->rc, &rawir))
139128 event = true;
140129 break;
....@@ -148,12 +137,12 @@
148137 rawir.pulse = false;
149138 }
150139
151
- rawir.duration = NS_PER_BIT * (8 - b);
140
+ rawir.duration = US_PER_BIT * (8 - b);
152141 if (ir_raw_event_store_with_filter(tt->rc, &rawir))
153142 event = true;
154143
155144 rawir.pulse = !rawir.pulse;
156
- rawir.duration = NS_PER_BIT * b;
145
+ rawir.duration = US_PER_BIT * b;
157146 if (ir_raw_event_store_with_filter(tt->rc, &rawir))
158147 event = true;
159148 break;
....@@ -322,10 +311,10 @@
322311 rc->max_timeout = 10 * IR_DEFAULT_TIMEOUT;
323312
324313 /*
325
- * The precision is NS_PER_BIT, but since every 8th bit can be
326
- * overwritten with garbage the accuracy is at best 2 * NS_PER_BIT.
314
+ * The precision is US_PER_BIT, but since every 8th bit can be
315
+ * overwritten with garbage the accuracy is at best 2 * US_PER_BIT.
327316 */
328
- rc->rx_resolution = NS_PER_BIT;
317
+ rc->rx_resolution = 2 * US_PER_BIT;
329318
330319 ret = rc_register_device(rc);
331320 if (ret) {