diff options
Diffstat (limited to 'drivers/hid/hid-appleir.c')
| -rw-r--r-- | drivers/hid/hid-appleir.c | 33 |
1 files changed, 10 insertions, 23 deletions
diff --git a/drivers/hid/hid-appleir.c b/drivers/hid/hid-appleir.c index 07cbc70f00e7..5e8ced7bc05a 100644 --- a/drivers/hid/hid-appleir.c +++ b/drivers/hid/hid-appleir.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-only /* * HID driver for the apple ir device * @@ -12,15 +13,6 @@ * Copyright (C) 2010, 2012 Bastien Nocera <hadess@hadess.net> * Copyright (C) 2013 Benjamin Tissoires <benjamin.tissoires@gmail.com> * Copyright (C) 2013 Red Hat Inc. All Rights Reserved - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * 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. */ #include <linux/device.h> @@ -173,9 +165,9 @@ static void battery_flat(struct appleir *appleir) dev_err(&appleir->input_dev->dev, "possible flat battery?\n"); } -static void key_up_tick(unsigned long data) +static void key_up_tick(struct timer_list *t) { - struct appleir *appleir = (struct appleir *)data; + struct appleir *appleir = timer_container_of(appleir, t, key_up_timer); struct hid_device *hid = appleir->hid; unsigned long flags; @@ -196,7 +188,7 @@ static int appleir_raw_event(struct hid_device *hid, struct hid_report *report, static const u8 flatbattery[] = { 0x25, 0x87, 0xe0 }; unsigned long flags; - if (len != 5) + if (len != 5 || !(hid->claimed & HID_CLAIMED_INPUT)) goto out; if (!memcmp(data, keydown, sizeof(keydown))) { @@ -291,11 +283,9 @@ static int appleir_probe(struct hid_device *hid, const struct hid_device_id *id) int ret; struct appleir *appleir; - appleir = kzalloc(sizeof(struct appleir), GFP_KERNEL); - if (!appleir) { - ret = -ENOMEM; - goto allocfail; - } + appleir = devm_kzalloc(&hid->dev, sizeof(struct appleir), GFP_KERNEL); + if (!appleir) + return -ENOMEM; appleir->hid = hid; @@ -303,8 +293,7 @@ static int appleir_probe(struct hid_device *hid, const struct hid_device_id *id) hid->quirks |= HID_QUIRK_HIDINPUT_FORCE; spin_lock_init(&appleir->lock); - setup_timer(&appleir->key_up_timer, - key_up_tick, (unsigned long) appleir); + timer_setup(&appleir->key_up_timer, key_up_tick, 0); hid_set_drvdata(hid, appleir); @@ -322,8 +311,7 @@ static int appleir_probe(struct hid_device *hid, const struct hid_device_id *id) return 0; fail: - kfree(appleir); -allocfail: + devm_kfree(&hid->dev, appleir); return ret; } @@ -331,8 +319,7 @@ static void appleir_remove(struct hid_device *hid) { struct appleir *appleir = hid_get_drvdata(hid); hid_hw_stop(hid); - del_timer_sync(&appleir->key_up_timer); - kfree(appleir); + timer_delete_sync(&appleir->key_up_timer); } static const struct hid_device_id appleir_devices[] = { |
