diff options
Diffstat (limited to 'drivers/media/rc/fintek-cir.c')
| -rw-r--r-- | drivers/media/rc/fintek-cir.c | 69 |
1 files changed, 14 insertions, 55 deletions
diff --git a/drivers/media/rc/fintek-cir.c b/drivers/media/rc/fintek-cir.c index d6fa441655d2..3fb0968efd57 100644 --- a/drivers/media/rc/fintek-cir.c +++ b/drivers/media/rc/fintek-cir.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * Driver for Feature Integration Technology Inc. (aka Fintek) LPC CIR * @@ -6,21 +7,6 @@ * Special thanks to Fintek for providing hardware and spec sheets. * This driver is based upon the nuvoton, ite and ene drivers for * similar hardware. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA */ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt @@ -33,7 +19,6 @@ #include <linux/sched.h> #include <linux/slab.h> #include <media/rc-core.h> -#include <linux/pci_ids.h> #include "fintek-cir.h" @@ -66,13 +51,6 @@ static inline void fintek_set_reg_bit(struct fintek_dev *fintek, u8 val, u8 reg) fintek_cr_write(fintek, tmp, reg); } -/* clear config register bit without changing other bits */ -static inline void fintek_clear_reg_bit(struct fintek_dev *fintek, u8 val, u8 reg) -{ - u8 tmp = fintek_cr_read(fintek, reg) & ~val; - fintek_cr_write(fintek, tmp, reg); -} - /* enter config mode */ static inline void fintek_config_mode_enable(struct fintek_dev *fintek) { @@ -105,11 +83,7 @@ static inline void fintek_cir_reg_write(struct fintek_dev *fintek, u8 val, u8 of /* read val from cir config register */ static u8 fintek_cir_reg_read(struct fintek_dev *fintek, u8 offset) { - u8 val; - - val = inb(fintek->cir_addr + offset); - - return val; + return inb(fintek->cir_addr + offset); } /* dump current cir register contents */ @@ -148,7 +122,6 @@ static int fintek_hw_detect(struct fintek_dev *fintek) u8 vendor_major, vendor_minor; u8 portsel, ir_class; u16 vendor, chip; - int ret = 0; fintek_config_mode_enable(fintek); @@ -208,7 +181,7 @@ static int fintek_hw_detect(struct fintek_dev *fintek) spin_unlock_irqrestore(&fintek->fintek_lock, flags); - return ret; + return 0; } static void fintek_cir_ldev_init(struct fintek_dev *fintek) @@ -293,7 +266,7 @@ static int fintek_cmdsize(u8 cmd, u8 subcmd) /* process ir data stored in driver buffer */ static void fintek_process_rx_ir_data(struct fintek_dev *fintek) { - DEFINE_IR_RAW_EVENT(rawir); + struct ir_raw_event rawir = {}; u8 sample; bool event = false; int i; @@ -314,7 +287,7 @@ static void fintek_process_rx_ir_data(struct fintek_dev *fintek) if (fintek->rem) fintek->parser_state = PARSE_IRDATA; else - ir_raw_event_reset(fintek->rdev); + ir_raw_event_overflow(fintek->rdev); break; case SUBCMD: fintek->rem = fintek_cmdsize(fintek->cmd, sample); @@ -325,10 +298,9 @@ static void fintek_process_rx_ir_data(struct fintek_dev *fintek) break; case PARSE_IRDATA: fintek->rem--; - init_ir_raw_event(&rawir); rawir.pulse = ((sample & BUF_PULSE_BIT) != 0); - rawir.duration = US_TO_NS((sample & BUF_SAMPLE_MASK) - * CIR_SAMPLE_PERIOD); + rawir.duration = (sample & BUF_SAMPLE_MASK) + * CIR_SAMPLE_PERIOD; fit_dbg("Storing %s with duration %d", rawir.pulse ? "pulse" : "space", @@ -498,7 +470,7 @@ static int fintek_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id return ret; /* input device for IR remote (and tx) */ - rdev = rc_allocate_device(); + rdev = rc_allocate_device(RC_DRIVER_IR_RAW); if (!rdev) goto exit_free_dev_rdev; @@ -540,11 +512,10 @@ static int fintek_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id /* Set up the rc device */ rdev->priv = fintek; - rdev->driver_type = RC_DRIVER_IR_RAW; - rdev->allowed_protos = RC_BIT_ALL; + rdev->allowed_protocols = RC_PROTO_BIT_ALL_IR_DECODER; rdev->open = fintek_open; rdev->close = fintek_close; - rdev->input_name = FINTEK_DESCRIPTION; + rdev->device_name = FINTEK_DESCRIPTION; rdev->input_phys = "fintek/cir0"; rdev->input_id.bustype = BUS_HOST; rdev->input_id.vendor = VENDOR_ID_FINTEK; @@ -553,9 +524,9 @@ static int fintek_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id rdev->dev.parent = &pdev->dev; rdev->driver_name = FINTEK_DRIVER_NAME; rdev->map_name = RC_MAP_RC6_MCE; - rdev->timeout = US_TO_NS(1000); + rdev->timeout = 1000; /* rx resolution is hardwired to 50us atm, 1, 25, 100 also possible */ - rdev->rx_resolution = US_TO_NS(CIR_SAMPLE_PERIOD); + rdev->rx_resolution = CIR_SAMPLE_PERIOD; fintek->rdev = rdev; @@ -644,7 +615,6 @@ static int fintek_suspend(struct pnp_dev *pdev, pm_message_t state) static int fintek_resume(struct pnp_dev *pdev) { - int ret = 0; struct fintek_dev *fintek = pnp_get_drvdata(pdev); fit_dbg("%s called", __func__); @@ -661,7 +631,7 @@ static int fintek_resume(struct pnp_dev *pdev) fintek_cir_regs_init(fintek); - return ret; + return 0; } static void fintek_shutdown(struct pnp_dev *pdev) @@ -686,16 +656,6 @@ static struct pnp_driver fintek_driver = { .shutdown = fintek_shutdown, }; -static int fintek_init(void) -{ - return pnp_register_driver(&fintek_driver); -} - -static void fintek_exit(void) -{ - pnp_unregister_driver(&fintek_driver); -} - module_param(debug, int, S_IRUGO | S_IWUSR); MODULE_PARM_DESC(debug, "Enable debugging output"); @@ -705,5 +665,4 @@ MODULE_DESCRIPTION(FINTEK_DESCRIPTION " driver"); MODULE_AUTHOR("Jarod Wilson <jarod@redhat.com>"); MODULE_LICENSE("GPL"); -module_init(fintek_init); -module_exit(fintek_exit); +module_pnp_driver(fintek_driver); |
