.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * driver for ENE KB3926 B/C/D/E/F CIR (pnp id: ENE0XXX) |
---|
3 | 4 | * |
---|
4 | 5 | * 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. |
---|
15 | 6 | * |
---|
16 | 7 | * Special thanks to: |
---|
17 | 8 | * Sami R. <maesesami@gmail.com> for lot of help in debugging and therefore |
---|
.. | .. |
---|
22 | 13 | * on latest notebooks |
---|
23 | 14 | * |
---|
24 | 15 | * ENE for partial device documentation |
---|
25 | | - * |
---|
26 | 16 | */ |
---|
27 | 17 | |
---|
28 | 18 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
---|
.. | .. |
---|
184 | 174 | return 0; |
---|
185 | 175 | } |
---|
186 | 176 | |
---|
187 | | -/* Read properities of hw sample buffer */ |
---|
| 177 | +/* Read properties of hw sample buffer */ |
---|
188 | 178 | static void ene_rx_setup_hw_buffer(struct ene_device *dev) |
---|
189 | 179 | { |
---|
190 | 180 | u16 tmp; |
---|
.. | .. |
---|
326 | 316 | /* Sense current received carrier */ |
---|
327 | 317 | static void ene_rx_sense_carrier(struct ene_device *dev) |
---|
328 | 318 | { |
---|
329 | | - DEFINE_IR_RAW_EVENT(ev); |
---|
330 | | - |
---|
331 | 319 | int carrier, duty_cycle; |
---|
332 | 320 | int period = ene_read_reg(dev, ENE_CIRCAR_PRD); |
---|
333 | 321 | int hperiod = ene_read_reg(dev, ENE_CIRCAR_HPRD); |
---|
.. | .. |
---|
348 | 336 | dbg("RX: sensed carrier = %d Hz, duty cycle %d%%", |
---|
349 | 337 | carrier, duty_cycle); |
---|
350 | 338 | 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 | + }; |
---|
354 | 344 | ir_raw_event_store(dev->rdev, &ev); |
---|
355 | 345 | } |
---|
356 | 346 | } |
---|
.. | .. |
---|
442 | 432 | |
---|
443 | 433 | select_timeout: |
---|
444 | 434 | 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; |
---|
446 | 436 | |
---|
447 | 437 | /* Fan input doesn't support timeouts, it just ends the |
---|
448 | 438 | input with a maximum sample */ |
---|
449 | 439 | 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; |
---|
452 | 442 | } else { |
---|
453 | | - dev->rdev->rx_resolution = US_TO_NS(sample_period); |
---|
| 443 | + dev->rdev->rx_resolution = sample_period; |
---|
454 | 444 | |
---|
455 | 445 | /* Theoreticly timeout is unlimited, but we cap it |
---|
456 | 446 | * because it was seen that on one device, it |
---|
457 | 447 | * would stop sending spaces after around 250 msec. |
---|
458 | 448 | * Besides, this is close to 2^32 anyway and timeout is u32. |
---|
459 | 449 | */ |
---|
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; |
---|
462 | 452 | } |
---|
463 | 453 | |
---|
464 | 454 | if (dev->hw_learning_and_tx_capable) |
---|
465 | | - dev->rdev->tx_resolution = US_TO_NS(sample_period); |
---|
| 455 | + dev->rdev->tx_resolution = sample_period; |
---|
466 | 456 | |
---|
467 | 457 | if (dev->rdev->timeout > dev->rdev->max_timeout) |
---|
468 | 458 | dev->rdev->timeout = dev->rdev->max_timeout; |
---|
.. | .. |
---|
733 | 723 | unsigned long flags; |
---|
734 | 724 | irqreturn_t retval = IRQ_NONE; |
---|
735 | 725 | struct ene_device *dev = (struct ene_device *)data; |
---|
736 | | - DEFINE_IR_RAW_EVENT(ev); |
---|
| 726 | + struct ir_raw_event ev = {}; |
---|
737 | 727 | |
---|
738 | 728 | spin_lock_irqsave(&dev->hw_lock, flags); |
---|
739 | 729 | |
---|
.. | .. |
---|
808 | 798 | |
---|
809 | 799 | dbg("RX: %d (%s)", hw_sample, pulse ? "pulse" : "space"); |
---|
810 | 800 | |
---|
811 | | - ev.duration = US_TO_NS(hw_sample); |
---|
| 801 | + ev.duration = hw_sample; |
---|
812 | 802 | ev.pulse = pulse; |
---|
813 | 803 | ir_raw_event_store_with_filter(dev->rdev, &ev); |
---|
814 | 804 | } |
---|
.. | .. |
---|
828 | 818 | dev->learning_mode_enabled = learning_mode_force; |
---|
829 | 819 | |
---|
830 | 820 | /* Set reasonable default timeout */ |
---|
831 | | - dev->rdev->timeout = US_TO_NS(150000); |
---|
| 821 | + dev->rdev->timeout = MS_TO_US(150); |
---|
832 | 822 | } |
---|
833 | 823 | |
---|
834 | 824 | /* Upload all hardware settings at once. Used at load and resume time */ |
---|
.. | .. |
---|
1116 | 1106 | struct ene_device *dev = pnp_get_drvdata(pnp_dev); |
---|
1117 | 1107 | unsigned long flags; |
---|
1118 | 1108 | |
---|
| 1109 | + rc_unregister_device(dev->rdev); |
---|
| 1110 | + del_timer_sync(&dev->tx_sim_timer); |
---|
1119 | 1111 | spin_lock_irqsave(&dev->hw_lock, flags); |
---|
1120 | 1112 | ene_rx_disable(dev); |
---|
1121 | 1113 | ene_rx_restore_hw_buffer(dev); |
---|
.. | .. |
---|
1123 | 1115 | |
---|
1124 | 1116 | free_irq(dev->irq, dev); |
---|
1125 | 1117 | release_region(dev->hw_io, ENE_IO_SIZE); |
---|
1126 | | - rc_unregister_device(dev->rdev); |
---|
1127 | 1118 | kfree(dev); |
---|
1128 | 1119 | } |
---|
1129 | 1120 | |
---|