linux/drivers/platform/x86/wireless-hotkey.c
Dawei Li 6c0eb5ba35 ACPI: make remove callback of ACPI driver void
For bus-based driver, device removal is implemented as:
1 device_remove()->
2   bus->remove()->
3     driver->remove()

Driver core needs no inform from callee(bus driver) about the
result of remove callback. In that case, commit fc7a6209d5
("bus: Make remove callback return void") forces bus_type::remove
be void-returned.

Now we have the situation that both 1 & 2 of calling chain are
void-returned, so it does not make much sense for 3(driver->remove)
to return non-void to its caller.

So the basic idea behind this change is making remove() callback of
any bus-based driver to be void-returned.

This change, for itself, is for device drivers based on acpi-bus.

Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Acked-by: Lee Jones <lee@kernel.org>
Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Dawei Li <set_pte_at@outlook.com>
Reviewed-by: Maximilian Luz <luzmaximilian@gmail.com>  # for drivers/platform/surface/*
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2022-11-23 19:11:22 +01:00

103 lines
2.0 KiB
C

// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Airplane mode button for AMD, HP & Xiaomi laptops
*
* Copyright (C) 2014-2017 Alex Hung <alex.hung@canonical.com>
* Copyright (C) 2021 Advanced Micro Devices
*/
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/input.h>
#include <linux/platform_device.h>
#include <linux/acpi.h>
#include <acpi/acpi_bus.h>
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Alex Hung");
MODULE_ALIAS("acpi*:HPQ6001:*");
MODULE_ALIAS("acpi*:WSTADEF:*");
MODULE_ALIAS("acpi*:AMDI0051:*");
static struct input_dev *wl_input_dev;
static const struct acpi_device_id wl_ids[] = {
{"HPQ6001", 0},
{"WSTADEF", 0},
{"AMDI0051", 0},
{"", 0},
};
static int wireless_input_setup(void)
{
int err;
wl_input_dev = input_allocate_device();
if (!wl_input_dev)
return -ENOMEM;
wl_input_dev->name = "Wireless hotkeys";
wl_input_dev->phys = "hpq6001/input0";
wl_input_dev->id.bustype = BUS_HOST;
wl_input_dev->evbit[0] = BIT(EV_KEY);
set_bit(KEY_RFKILL, wl_input_dev->keybit);
err = input_register_device(wl_input_dev);
if (err)
goto err_free_dev;
return 0;
err_free_dev:
input_free_device(wl_input_dev);
return err;
}
static void wireless_input_destroy(void)
{
input_unregister_device(wl_input_dev);
}
static void wl_notify(struct acpi_device *acpi_dev, u32 event)
{
if (event != 0x80) {
pr_info("Received unknown event (0x%x)\n", event);
return;
}
input_report_key(wl_input_dev, KEY_RFKILL, 1);
input_sync(wl_input_dev);
input_report_key(wl_input_dev, KEY_RFKILL, 0);
input_sync(wl_input_dev);
}
static int wl_add(struct acpi_device *device)
{
int err;
err = wireless_input_setup();
if (err)
pr_err("Failed to setup wireless hotkeys\n");
return err;
}
static void wl_remove(struct acpi_device *device)
{
wireless_input_destroy();
}
static struct acpi_driver wl_driver = {
.name = "wireless-hotkey",
.owner = THIS_MODULE,
.ids = wl_ids,
.ops = {
.add = wl_add,
.remove = wl_remove,
.notify = wl_notify,
},
};
module_acpi_driver(wl_driver);