Skip to content

Commit

Permalink
platform/x86: wmi: Make remove callback return void
Browse files Browse the repository at this point in the history
The driver core ignores the return value of struct bus_type::remove()
(and so wmi_dev_remove()) because there is only little that can be done.

To simplify the quest to make this function return void, let struct
wmi_driver::remove() return void, too. All implementers of this callback
return 0 already and this way it should be obvious to driver authors
that returning an error code is a bad idea.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Reviewed-by: Pali Rohár <pali@kernel.org>
Link: https://lore.kernel.org/r/20210301160404.1677064-1-u.kleine-koenig@pengutronix.de
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
  • Loading branch information
Uwe Kleine-König authored and Hans de Goede committed Mar 8, 2021
1 parent 2478907 commit 2b329f5
Show file tree
Hide file tree
Showing 10 changed files with 11 additions and 20 deletions.
3 changes: 1 addition & 2 deletions drivers/platform/x86/dell/dell-smbios-wmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ static int dell_smbios_wmi_probe(struct wmi_device *wdev, const void *context)
return ret;
}

static int dell_smbios_wmi_remove(struct wmi_device *wdev)
static void dell_smbios_wmi_remove(struct wmi_device *wdev)
{
struct wmi_smbios_priv *priv = dev_get_drvdata(&wdev->dev);
int count;
Expand All @@ -218,7 +218,6 @@ static int dell_smbios_wmi_remove(struct wmi_device *wdev)
count = get_order(priv->req_buf_size);
free_pages((unsigned long)priv->buf, count);
mutex_unlock(&call_mutex);
return 0;
}

static const struct wmi_device_id dell_smbios_wmi_id_table[] = {
Expand Down
3 changes: 1 addition & 2 deletions drivers/platform/x86/dell/dell-wmi-descriptor.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,14 +174,13 @@ static int dell_wmi_descriptor_probe(struct wmi_device *wdev,
return ret;
}

static int dell_wmi_descriptor_remove(struct wmi_device *wdev)
static void dell_wmi_descriptor_remove(struct wmi_device *wdev)
{
struct descriptor_priv *priv = dev_get_drvdata(&wdev->dev);

mutex_lock(&list_mutex);
list_del(&priv->list);
mutex_unlock(&list_mutex);
return 0;
}

static const struct wmi_device_id dell_wmi_descriptor_id_table[] = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,11 @@ static int bios_attr_set_interface_probe(struct wmi_device *wdev, const void *co
return 0;
}

static int bios_attr_set_interface_remove(struct wmi_device *wdev)
static void bios_attr_set_interface_remove(struct wmi_device *wdev)
{
mutex_lock(&wmi_priv.mutex);
wmi_priv.bios_attr_wdev = NULL;
mutex_unlock(&wmi_priv.mutex);
return 0;
}

static const struct wmi_device_id bios_attr_set_interface_id_table[] = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,11 @@ static int bios_attr_pass_interface_probe(struct wmi_device *wdev, const void *c
return 0;
}

static int bios_attr_pass_interface_remove(struct wmi_device *wdev)
static void bios_attr_pass_interface_remove(struct wmi_device *wdev)
{
mutex_lock(&wmi_priv.mutex);
wmi_priv.password_attr_wdev = NULL;
mutex_unlock(&wmi_priv.mutex);
return 0;
}

static const struct wmi_device_id bios_attr_pass_interface_id_table[] = {
Expand Down
3 changes: 1 addition & 2 deletions drivers/platform/x86/dell/dell-wmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -714,10 +714,9 @@ static int dell_wmi_probe(struct wmi_device *wdev, const void *context)
return dell_wmi_input_setup(wdev);
}

static int dell_wmi_remove(struct wmi_device *wdev)
static void dell_wmi_remove(struct wmi_device *wdev)
{
dell_wmi_input_destroy(wdev);
return 0;
}
static const struct wmi_device_id dell_wmi_id_table[] = {
{ .guid_string = DELL_EVENT_GUID },
Expand Down
3 changes: 1 addition & 2 deletions drivers/platform/x86/intel-wmi-sbl-fw-update.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,9 @@ static int intel_wmi_sbl_fw_update_probe(struct wmi_device *wdev,
return 0;
}

static int intel_wmi_sbl_fw_update_remove(struct wmi_device *wdev)
static void intel_wmi_sbl_fw_update_remove(struct wmi_device *wdev)
{
dev_info(&wdev->dev, "Slim Bootloader signaling driver removed\n");
return 0;
}

static const struct wmi_device_id intel_wmi_sbl_id_table[] = {
Expand Down
3 changes: 1 addition & 2 deletions drivers/platform/x86/intel-wmi-thunderbolt.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,10 @@ static int intel_wmi_thunderbolt_probe(struct wmi_device *wdev,
return ret;
}

static int intel_wmi_thunderbolt_remove(struct wmi_device *wdev)
static void intel_wmi_thunderbolt_remove(struct wmi_device *wdev)
{
sysfs_remove_group(&wdev->dev.kobj, &tbt_attribute_group);
kobject_uevent(&wdev->dev.kobj, KOBJ_CHANGE);
return 0;
}

static const struct wmi_device_id intel_wmi_thunderbolt_id_table[] = {
Expand Down
3 changes: 1 addition & 2 deletions drivers/platform/x86/wmi-bmof.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,12 @@ static int wmi_bmof_probe(struct wmi_device *wdev, const void *context)
return ret;
}

static int wmi_bmof_remove(struct wmi_device *wdev)
static void wmi_bmof_remove(struct wmi_device *wdev)
{
struct bmof_priv *priv = dev_get_drvdata(&wdev->dev);

sysfs_remove_bin_file(&wdev->dev.kobj, &priv->bmof_bin_attr);
kfree(priv->bmofdata);
return 0;
}

static const struct wmi_device_id wmi_bmof_id_table[] = {
Expand Down
5 changes: 2 additions & 3 deletions drivers/platform/x86/wmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -985,7 +985,6 @@ static int wmi_dev_remove(struct device *dev)
struct wmi_block *wblock = dev_to_wblock(dev);
struct wmi_driver *wdriver =
container_of(dev->driver, struct wmi_driver, driver);
int ret = 0;

if (wdriver->filter_callback) {
misc_deregister(&wblock->char_dev);
Expand All @@ -994,12 +993,12 @@ static int wmi_dev_remove(struct device *dev)
}

if (wdriver->remove)
ret = wdriver->remove(dev_to_wdev(dev));
wdriver->remove(dev_to_wdev(dev));

if (ACPI_FAILURE(wmi_method_enable(wblock, 0)))
dev_warn(dev, "failed to disable device\n");

return ret;
return 0;
}

static struct class wmi_bus_class = {
Expand Down
2 changes: 1 addition & 1 deletion include/linux/wmi.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ struct wmi_driver {
const struct wmi_device_id *id_table;

int (*probe)(struct wmi_device *wdev, const void *context);
int (*remove)(struct wmi_device *wdev);
void (*remove)(struct wmi_device *wdev);
void (*notify)(struct wmi_device *device, union acpi_object *data);
long (*filter_callback)(struct wmi_device *wdev, unsigned int cmd,
struct wmi_ioctl_buffer *arg);
Expand Down

0 comments on commit 2b329f5

Please sign in to comment.