Skip to content

Commit

Permalink
ACPI: make remove callback of ACPI driver void
Browse files Browse the repository at this point in the history
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 fc7a620
("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>
  • Loading branch information
Dawei Li authored and Rafael J. Wysocki committed Nov 23, 2022
1 parent d7d4332 commit 6c0eb5b
Show file tree
Hide file tree
Showing 48 changed files with 88 additions and 149 deletions.
4 changes: 2 additions & 2 deletions arch/ia64/hp/common/aml_nfw.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,9 @@ static int aml_nfw_add(struct acpi_device *device)
return aml_nfw_add_global_handler();
}

static int aml_nfw_remove(struct acpi_device *device)
static void aml_nfw_remove(struct acpi_device *device)
{
return aml_nfw_remove_global_handler();
aml_nfw_remove_global_handler();
}

static const struct acpi_device_id aml_nfw_ids[] = {
Expand Down
3 changes: 1 addition & 2 deletions arch/x86/platform/olpc/olpc-xo15-sci.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,13 +183,12 @@ static int xo15_sci_add(struct acpi_device *device)
return r;
}

static int xo15_sci_remove(struct acpi_device *device)
static void xo15_sci_remove(struct acpi_device *device)
{
acpi_disable_gpe(NULL, xo15_sci_gpe);
acpi_remove_gpe_handler(NULL, xo15_sci_gpe, xo15_sci_gpe_handler);
cancel_work_sync(&sci_work);
sysfs_remove_file(&device->dev.kobj, &lid_wake_on_close_attr.attr);
return 0;
}

#ifdef CONFIG_PM_SLEEP
Expand Down
8 changes: 3 additions & 5 deletions drivers/acpi/ac.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ MODULE_DESCRIPTION("ACPI AC Adapter Driver");
MODULE_LICENSE("GPL");

static int acpi_ac_add(struct acpi_device *device);
static int acpi_ac_remove(struct acpi_device *device);
static void acpi_ac_remove(struct acpi_device *device);
static void acpi_ac_notify(struct acpi_device *device, u32 event);

static const struct acpi_device_id ac_device_ids[] = {
Expand Down Expand Up @@ -288,21 +288,19 @@ static int acpi_ac_resume(struct device *dev)
#define acpi_ac_resume NULL
#endif

static int acpi_ac_remove(struct acpi_device *device)
static void acpi_ac_remove(struct acpi_device *device)
{
struct acpi_ac *ac = NULL;

if (!device || !acpi_driver_data(device))
return -EINVAL;
return;

ac = acpi_driver_data(device);

power_supply_unregister(ac->charger);
unregister_acpi_notifier(&ac->battery_nb);

kfree(ac);

return 0;
}

static int __init acpi_ac_init(void)
Expand Down
3 changes: 1 addition & 2 deletions drivers/acpi/acpi_pad.c
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ static int acpi_pad_add(struct acpi_device *device)
return 0;
}

static int acpi_pad_remove(struct acpi_device *device)
static void acpi_pad_remove(struct acpi_device *device)
{
mutex_lock(&isolated_cpus_lock);
acpi_pad_idle_cpus(0);
Expand All @@ -458,7 +458,6 @@ static int acpi_pad_remove(struct acpi_device *device)
acpi_remove_notify_handler(device->handle,
ACPI_DEVICE_NOTIFY, acpi_pad_notify);
acpi_pad_remove_sysfs(device);
return 0;
}

static const struct acpi_device_id pad_device_ids[] = {
Expand Down
8 changes: 3 additions & 5 deletions drivers/acpi/acpi_video.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ static DEFINE_MUTEX(register_count_mutex);
static DEFINE_MUTEX(video_list_lock);
static LIST_HEAD(video_bus_head);
static int acpi_video_bus_add(struct acpi_device *device);
static int acpi_video_bus_remove(struct acpi_device *device);
static void acpi_video_bus_remove(struct acpi_device *device);
static void acpi_video_bus_notify(struct acpi_device *device, u32 event);
static void acpi_video_bus_register_backlight_work(struct work_struct *ignored);
static DECLARE_DELAYED_WORK(video_bus_register_backlight_work,
Expand Down Expand Up @@ -2067,13 +2067,13 @@ static int acpi_video_bus_add(struct acpi_device *device)
return error;
}

static int acpi_video_bus_remove(struct acpi_device *device)
static void acpi_video_bus_remove(struct acpi_device *device)
{
struct acpi_video_bus *video = NULL;


if (!device || !acpi_driver_data(device))
return -EINVAL;
return;

video = acpi_driver_data(device);

Expand All @@ -2087,8 +2087,6 @@ static int acpi_video_bus_remove(struct acpi_device *device)

kfree(video->attached_array);
kfree(video);

return 0;
}

static void acpi_video_bus_register_backlight_work(struct work_struct *ignored)
Expand Down
5 changes: 2 additions & 3 deletions drivers/acpi/battery.c
Original file line number Diff line number Diff line change
Expand Up @@ -1208,20 +1208,19 @@ static int acpi_battery_add(struct acpi_device *device)
return result;
}

static int acpi_battery_remove(struct acpi_device *device)
static void acpi_battery_remove(struct acpi_device *device)
{
struct acpi_battery *battery = NULL;

if (!device || !acpi_driver_data(device))
return -EINVAL;
return;
device_init_wakeup(&device->dev, 0);
battery = acpi_driver_data(device);
unregister_pm_notifier(&battery->pm_nb);
sysfs_remove_battery(battery);
mutex_destroy(&battery->lock);
mutex_destroy(&battery->sysfs_lock);
kfree(battery);
return 0;
}

#ifdef CONFIG_PM_SLEEP
Expand Down
5 changes: 2 additions & 3 deletions drivers/acpi/button.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ static const struct dmi_system_id dmi_lid_quirks[] = {
};

static int acpi_button_add(struct acpi_device *device);
static int acpi_button_remove(struct acpi_device *device);
static void acpi_button_remove(struct acpi_device *device);
static void acpi_button_notify(struct acpi_device *device, u32 event);

#ifdef CONFIG_PM_SLEEP
Expand Down Expand Up @@ -580,14 +580,13 @@ static int acpi_button_add(struct acpi_device *device)
return error;
}

static int acpi_button_remove(struct acpi_device *device)
static void acpi_button_remove(struct acpi_device *device)
{
struct acpi_button *button = acpi_driver_data(device);

acpi_button_remove_fs(device);
input_unregister_device(button->input);
kfree(button);
return 0;
}

static int param_set_lid_init_state(const char *val,
Expand Down
5 changes: 2 additions & 3 deletions drivers/acpi/ec.c
Original file line number Diff line number Diff line change
Expand Up @@ -1663,12 +1663,12 @@ static int acpi_ec_add(struct acpi_device *device)
return ret;
}

static int acpi_ec_remove(struct acpi_device *device)
static void acpi_ec_remove(struct acpi_device *device)
{
struct acpi_ec *ec;

if (!device)
return -EINVAL;
return;

ec = acpi_driver_data(device);
release_region(ec->data_addr, 1);
Expand All @@ -1678,7 +1678,6 @@ static int acpi_ec_remove(struct acpi_device *device)
ec_remove_handlers(ec);
acpi_ec_free(ec);
}
return 0;
}

static acpi_status
Expand Down
3 changes: 1 addition & 2 deletions drivers/acpi/hed.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,9 @@ static int acpi_hed_add(struct acpi_device *device)
return 0;
}

static int acpi_hed_remove(struct acpi_device *device)
static void acpi_hed_remove(struct acpi_device *device)
{
hed_handle = NULL;
return 0;
}

static struct acpi_driver acpi_hed_driver = {
Expand Down
3 changes: 1 addition & 2 deletions drivers/acpi/nfit/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -3371,10 +3371,9 @@ static int acpi_nfit_add(struct acpi_device *adev)
return devm_add_action_or_reset(dev, acpi_nfit_shutdown, acpi_desc);
}

static int acpi_nfit_remove(struct acpi_device *adev)
static void acpi_nfit_remove(struct acpi_device *adev)
{
/* see acpi_nfit_unregister */
return 0;
}

static void acpi_nfit_update_notify(struct device *dev, acpi_handle handle)
Expand Down
9 changes: 4 additions & 5 deletions drivers/acpi/sbs.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ struct acpi_sbs {

#define to_acpi_sbs(x) power_supply_get_drvdata(x)

static int acpi_sbs_remove(struct acpi_device *device);
static void acpi_sbs_remove(struct acpi_device *device);
static int acpi_battery_get_state(struct acpi_battery *battery);

static inline int battery_scale(int log)
Expand Down Expand Up @@ -664,16 +664,16 @@ static int acpi_sbs_add(struct acpi_device *device)
return result;
}

static int acpi_sbs_remove(struct acpi_device *device)
static void acpi_sbs_remove(struct acpi_device *device)
{
struct acpi_sbs *sbs;
int id;

if (!device)
return -EINVAL;
return;
sbs = acpi_driver_data(device);
if (!sbs)
return -EINVAL;
return;
mutex_lock(&sbs->lock);
acpi_smbus_unregister_callback(sbs->hc);
for (id = 0; id < MAX_SBS_BAT; ++id)
Expand All @@ -682,7 +682,6 @@ static int acpi_sbs_remove(struct acpi_device *device)
mutex_unlock(&sbs->lock);
mutex_destroy(&sbs->lock);
kfree(sbs);
return 0;
}

#ifdef CONFIG_PM_SLEEP
Expand Down
7 changes: 3 additions & 4 deletions drivers/acpi/sbshc.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ struct acpi_smb_hc {
};

static int acpi_smbus_hc_add(struct acpi_device *device);
static int acpi_smbus_hc_remove(struct acpi_device *device);
static void acpi_smbus_hc_remove(struct acpi_device *device);

static const struct acpi_device_id sbs_device_ids[] = {
{"ACPI0001", 0},
Expand Down Expand Up @@ -280,19 +280,18 @@ static int acpi_smbus_hc_add(struct acpi_device *device)

extern void acpi_ec_remove_query_handler(struct acpi_ec *ec, u8 query_bit);

static int acpi_smbus_hc_remove(struct acpi_device *device)
static void acpi_smbus_hc_remove(struct acpi_device *device)
{
struct acpi_smb_hc *hc;

if (!device)
return -EINVAL;
return;

hc = acpi_driver_data(device);
acpi_ec_remove_query_handler(hc->ec, hc->query_bit);
acpi_os_wait_events_complete();
kfree(hc);
device->driver_data = NULL;
return 0;
}

module_acpi_driver(acpi_smb_hc_driver);
Expand Down
7 changes: 3 additions & 4 deletions drivers/acpi/thermal.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ MODULE_PARM_DESC(psv, "Disable or override all passive trip points.");
static struct workqueue_struct *acpi_thermal_pm_queue;

static int acpi_thermal_add(struct acpi_device *device);
static int acpi_thermal_remove(struct acpi_device *device);
static void acpi_thermal_remove(struct acpi_device *device);
static void acpi_thermal_notify(struct acpi_device *device, u32 event);

static const struct acpi_device_id thermal_device_ids[] = {
Expand Down Expand Up @@ -1059,19 +1059,18 @@ static int acpi_thermal_add(struct acpi_device *device)
return result;
}

static int acpi_thermal_remove(struct acpi_device *device)
static void acpi_thermal_remove(struct acpi_device *device)
{
struct acpi_thermal *tz;

if (!device || !acpi_driver_data(device))
return -EINVAL;
return;

flush_workqueue(acpi_thermal_pm_queue);
tz = acpi_driver_data(device);

acpi_thermal_unregister_thermal_zone(tz);
kfree(tz);
return 0;
}

#ifdef CONFIG_PM_SLEEP
Expand Down
10 changes: 7 additions & 3 deletions drivers/acpi/tiny-power-button.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,15 @@ static const struct acpi_device_id tiny_power_button_device_ids[] = {
};
MODULE_DEVICE_TABLE(acpi, tiny_power_button_device_ids);

static int acpi_noop_add_remove(struct acpi_device *device)
static int acpi_noop_add(struct acpi_device *device)
{
return 0;
}

static void acpi_noop_remove(struct acpi_device *device)
{
}

static void acpi_tiny_power_button_notify(struct acpi_device *device, u32 event)
{
kill_cad_pid(power_signal, 1);
Expand All @@ -34,8 +38,8 @@ static struct acpi_driver acpi_tiny_power_button_driver = {
.class = "tiny-power-button",
.ids = tiny_power_button_device_ids,
.ops = {
.add = acpi_noop_add_remove,
.remove = acpi_noop_add_remove,
.add = acpi_noop_add,
.remove = acpi_noop_remove,
.notify = acpi_tiny_power_button_notify,
},
};
Expand Down
3 changes: 1 addition & 2 deletions drivers/char/sonypi.c
Original file line number Diff line number Diff line change
Expand Up @@ -1123,10 +1123,9 @@ static int sonypi_acpi_add(struct acpi_device *device)
return 0;
}

static int sonypi_acpi_remove(struct acpi_device *device)
static void sonypi_acpi_remove(struct acpi_device *device)
{
sonypi_acpi_device = NULL;
return 0;
}

static const struct acpi_device_id sonypi_device_ids[] = {
Expand Down
4 changes: 1 addition & 3 deletions drivers/char/tpm/tpm_crb.c
Original file line number Diff line number Diff line change
Expand Up @@ -713,14 +713,12 @@ static int crb_acpi_add(struct acpi_device *device)
return tpm_chip_register(chip);
}

static int crb_acpi_remove(struct acpi_device *device)
static void crb_acpi_remove(struct acpi_device *device)
{
struct device *dev = &device->dev;
struct tpm_chip *chip = dev_get_drvdata(dev);

tpm_chip_unregister(chip);

return 0;
}

static const struct dev_pm_ops crb_pm = {
Expand Down
4 changes: 1 addition & 3 deletions drivers/hv/vmbus_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -2239,7 +2239,7 @@ static acpi_status vmbus_walk_resources(struct acpi_resource *res, void *ctx)
return AE_OK;
}

static int vmbus_acpi_remove(struct acpi_device *device)
static void vmbus_acpi_remove(struct acpi_device *device)
{
struct resource *cur_res;
struct resource *next_res;
Expand All @@ -2256,8 +2256,6 @@ static int vmbus_acpi_remove(struct acpi_device *device)
kfree(cur_res);
}
}

return 0;
}

static void vmbus_reserve_fb(void)
Expand Down
Loading

0 comments on commit 6c0eb5b

Please sign in to comment.