hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/media/rc/redrat3.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * USB RedRat3 IR Transceiver rc-core driver
34 *
....@@ -28,17 +29,6 @@
2829 * It uses its own little protocol to communicate, the required
2930 * parts of which are embedded within this driver.
3031 * --
31
- *
32
- * This program is free software; you can redistribute it and/or modify
33
- * it under the terms of the GNU General Public License as published by
34
- * the Free Software Foundation; either version 2 of the License, or
35
- * (at your option) any later version.
36
- *
37
- * This program is distributed in the hope that it will be useful,
38
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
39
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
40
- * GNU General Public License for more details.
41
- *
4232 */
4333
4434 #include <asm/unaligned.h>
....@@ -140,7 +130,7 @@
140130 * When receiving a continuous ir stream (for example when a user is
141131 * holding a button down on a remote), this specifies the minimum size
142132 * of a space when the redrat3 sends a irdata packet to the host. Specified
143
- * in miliseconds. Default value 18ms.
133
+ * in milliseconds. Default value 18ms.
144134 * The value can be between 2 and 30 inclusive.
145135 */
146136 static int minimum_pause = 18;
....@@ -348,9 +338,9 @@
348338
349339 static void redrat3_process_ir_data(struct redrat3_dev *rr3)
350340 {
351
- DEFINE_IR_RAW_EVENT(rawir);
341
+ struct ir_raw_event rawir = {};
352342 struct device *dev;
353
- unsigned int i, sig_size, single_len, offset, val;
343
+ unsigned int i, sig_size, offset, val;
354344 u32 mod_freq;
355345
356346 dev = rr3->dev;
....@@ -358,10 +348,10 @@
358348 mod_freq = redrat3_val_to_mod_freq(&rr3->irdata);
359349 dev_dbg(dev, "Got mod_freq of %u\n", mod_freq);
360350 if (mod_freq && rr3->wideband) {
361
- DEFINE_IR_RAW_EVENT(ev);
362
-
363
- ev.carrier_report = 1;
364
- ev.carrier = mod_freq;
351
+ struct ir_raw_event ev = {
352
+ .carrier_report = 1,
353
+ .carrier = mod_freq
354
+ };
365355
366356 ir_raw_event_store(rr3->rc, &ev);
367357 }
....@@ -371,7 +361,6 @@
371361 for (i = 0; i < sig_size; i++) {
372362 offset = rr3->irdata.sigdata[i];
373363 val = get_unaligned_be16(&rr3->irdata.lens[offset]);
374
- single_len = redrat3_len_to_us(val);
375364
376365 /* we should always get pulse/space/pulse/space samples */
377366 if (i % 2)
....@@ -379,7 +368,7 @@
379368 else
380369 rawir.pulse = true;
381370
382
- rawir.duration = US_TO_NS(single_len);
371
+ rawir.duration = redrat3_len_to_us(val);
383372 /* cap the value to IR_MAX_DURATION */
384373 rawir.duration = (rawir.duration > IR_MAX_DURATION) ?
385374 IR_MAX_DURATION : rawir.duration;
....@@ -505,7 +494,7 @@
505494 return timeout;
506495 }
507496
508
-static int redrat3_set_timeout(struct rc_dev *rc_dev, unsigned int timeoutns)
497
+static int redrat3_set_timeout(struct rc_dev *rc_dev, unsigned int timeoutus)
509498 {
510499 struct redrat3_dev *rr3 = rc_dev->priv;
511500 struct usb_device *udev = rr3->udev;
....@@ -517,7 +506,7 @@
517506 if (!timeout)
518507 return -ENOMEM;
519508
520
- *timeout = cpu_to_be32(redrat3_us_to_len(timeoutns / 1000));
509
+ *timeout = cpu_to_be32(redrat3_us_to_len(timeoutus));
521510 ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), RR3_SET_IR_PARAM,
522511 USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT,
523512 RR3_IR_IO_SIG_TIMEOUT, 0, timeout, sizeof(*timeout),
....@@ -957,15 +946,15 @@
957946 rc->dev.parent = dev;
958947 rc->priv = rr3;
959948 rc->allowed_protocols = RC_PROTO_BIT_ALL_IR_DECODER;
960
- rc->min_timeout = MS_TO_NS(RR3_RX_MIN_TIMEOUT);
961
- rc->max_timeout = MS_TO_NS(RR3_RX_MAX_TIMEOUT);
962
- rc->timeout = US_TO_NS(redrat3_get_timeout(rr3));
949
+ rc->min_timeout = MS_TO_US(RR3_RX_MIN_TIMEOUT);
950
+ rc->max_timeout = MS_TO_US(RR3_RX_MAX_TIMEOUT);
951
+ rc->timeout = redrat3_get_timeout(rr3);
963952 rc->s_timeout = redrat3_set_timeout;
964953 rc->tx_ir = redrat3_transmit_ir;
965954 rc->s_tx_carrier = redrat3_set_tx_carrier;
966955 rc->s_carrier_report = redrat3_wideband_receiver;
967956 rc->driver_name = DRIVER_NAME;
968
- rc->rx_resolution = US_TO_NS(2);
957
+ rc->rx_resolution = 2;
969958 rc->map_name = RC_MAP_HAUPPAUGE;
970959
971960 ret = rc_register_device(rc);