hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/drivers/media/rc/ene_ir.c
....@@ -1,17 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * driver for ENE KB3926 B/C/D/E/F CIR (pnp id: ENE0XXX)
34 *
45 * Copyright (C) 2010 Maxim Levitsky <maximlevitsky@gmail.com>
5
- *
6
- * This program is free software; you can redistribute it and/or
7
- * modify it under the terms of the GNU General Public License as
8
- * published by the Free Software Foundation; either version 2 of the
9
- * License, or (at your option) any later version.
10
- *
11
- * This program is distributed in the hope that it will be useful, but
12
- * WITHOUT ANY WARRANTY; without even the implied warranty of
13
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
- * General Public License for more details.
156 *
167 * Special thanks to:
178 * Sami R. <maesesami@gmail.com> for lot of help in debugging and therefore
....@@ -22,7 +13,6 @@
2213 * on latest notebooks
2314 *
2415 * ENE for partial device documentation
25
- *
2616 */
2717
2818 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
....@@ -184,7 +174,7 @@
184174 return 0;
185175 }
186176
187
-/* Read properities of hw sample buffer */
177
+/* Read properties of hw sample buffer */
188178 static void ene_rx_setup_hw_buffer(struct ene_device *dev)
189179 {
190180 u16 tmp;
....@@ -326,8 +316,6 @@
326316 /* Sense current received carrier */
327317 static void ene_rx_sense_carrier(struct ene_device *dev)
328318 {
329
- DEFINE_IR_RAW_EVENT(ev);
330
-
331319 int carrier, duty_cycle;
332320 int period = ene_read_reg(dev, ENE_CIRCAR_PRD);
333321 int hperiod = ene_read_reg(dev, ENE_CIRCAR_HPRD);
....@@ -348,9 +336,11 @@
348336 dbg("RX: sensed carrier = %d Hz, duty cycle %d%%",
349337 carrier, duty_cycle);
350338 if (dev->carrier_detect_enabled) {
351
- ev.carrier_report = true;
352
- ev.carrier = carrier;
353
- ev.duty_cycle = duty_cycle;
339
+ struct ir_raw_event ev = {
340
+ .carrier_report = true,
341
+ .carrier = carrier,
342
+ .duty_cycle = duty_cycle
343
+ };
354344 ir_raw_event_store(dev->rdev, &ev);
355345 }
356346 }
....@@ -442,27 +432,27 @@
442432
443433 select_timeout:
444434 if (dev->rx_fan_input_inuse) {
445
- dev->rdev->rx_resolution = US_TO_NS(ENE_FW_SAMPLE_PERIOD_FAN);
435
+ dev->rdev->rx_resolution = ENE_FW_SAMPLE_PERIOD_FAN;
446436
447437 /* Fan input doesn't support timeouts, it just ends the
448438 input with a maximum sample */
449439 dev->rdev->min_timeout = dev->rdev->max_timeout =
450
- US_TO_NS(ENE_FW_SMPL_BUF_FAN_MSK *
451
- ENE_FW_SAMPLE_PERIOD_FAN);
440
+ ENE_FW_SMPL_BUF_FAN_MSK *
441
+ ENE_FW_SAMPLE_PERIOD_FAN;
452442 } else {
453
- dev->rdev->rx_resolution = US_TO_NS(sample_period);
443
+ dev->rdev->rx_resolution = sample_period;
454444
455445 /* Theoreticly timeout is unlimited, but we cap it
456446 * because it was seen that on one device, it
457447 * would stop sending spaces after around 250 msec.
458448 * Besides, this is close to 2^32 anyway and timeout is u32.
459449 */
460
- dev->rdev->min_timeout = US_TO_NS(127 * sample_period);
461
- dev->rdev->max_timeout = US_TO_NS(200000);
450
+ dev->rdev->min_timeout = 127 * sample_period;
451
+ dev->rdev->max_timeout = 200000;
462452 }
463453
464454 if (dev->hw_learning_and_tx_capable)
465
- dev->rdev->tx_resolution = US_TO_NS(sample_period);
455
+ dev->rdev->tx_resolution = sample_period;
466456
467457 if (dev->rdev->timeout > dev->rdev->max_timeout)
468458 dev->rdev->timeout = dev->rdev->max_timeout;
....@@ -733,7 +723,7 @@
733723 unsigned long flags;
734724 irqreturn_t retval = IRQ_NONE;
735725 struct ene_device *dev = (struct ene_device *)data;
736
- DEFINE_IR_RAW_EVENT(ev);
726
+ struct ir_raw_event ev = {};
737727
738728 spin_lock_irqsave(&dev->hw_lock, flags);
739729
....@@ -808,7 +798,7 @@
808798
809799 dbg("RX: %d (%s)", hw_sample, pulse ? "pulse" : "space");
810800
811
- ev.duration = US_TO_NS(hw_sample);
801
+ ev.duration = hw_sample;
812802 ev.pulse = pulse;
813803 ir_raw_event_store_with_filter(dev->rdev, &ev);
814804 }
....@@ -828,7 +818,7 @@
828818 dev->learning_mode_enabled = learning_mode_force;
829819
830820 /* Set reasonable default timeout */
831
- dev->rdev->timeout = US_TO_NS(150000);
821
+ dev->rdev->timeout = MS_TO_US(150);
832822 }
833823
834824 /* Upload all hardware settings at once. Used at load and resume time */
....@@ -1116,6 +1106,8 @@
11161106 struct ene_device *dev = pnp_get_drvdata(pnp_dev);
11171107 unsigned long flags;
11181108
1109
+ rc_unregister_device(dev->rdev);
1110
+ del_timer_sync(&dev->tx_sim_timer);
11191111 spin_lock_irqsave(&dev->hw_lock, flags);
11201112 ene_rx_disable(dev);
11211113 ene_rx_restore_hw_buffer(dev);
....@@ -1123,7 +1115,6 @@
11231115
11241116 free_irq(dev->irq, dev);
11251117 release_region(dev->hw_io, ENE_IO_SIZE);
1126
- rc_unregister_device(dev->rdev);
11271118 kfree(dev);
11281119 }
11291120