Skip to content
Permalink
Browse files
drivers: make struct device_driver::remove return void
The driver core doesn't check the return value of the remove callback
because there is only little software can do when hardware disappears.

So change the callback to not return a value at all and adapt all users.
The motivation for this change is that some driver authors have a
misconception about failures in the remove callback. Making it void
makes it pretty obvious that there is no error handling to be expected.

Most drivers were easy to convert as they returned 0 unconditionally, I
added a warning to code paths that returned an error code (that was
ignored already before).

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
  • Loading branch information
ukleinek authored and intel-lab-lkp committed Nov 10, 2020
1 parent 407ab57 commit b836c14181cf5aab71cd870732f72437811ab228
Show file tree
Hide file tree
Showing 54 changed files with 129 additions and 172 deletions.
@@ -36,7 +36,7 @@ MODULE_DESCRIPTION("ACPI Processor Driver");
MODULE_LICENSE("GPL");

static int acpi_processor_start(struct device *dev);
static int acpi_processor_stop(struct device *dev);
static void acpi_processor_stop(struct device *dev);

static const struct acpi_device_id processor_device_ids[] = {
{ACPI_PROCESSOR_OBJECT_HID, 0},
@@ -261,27 +261,25 @@ static int acpi_processor_start(struct device *dev)
return ret;
}

static int acpi_processor_stop(struct device *dev)
static void acpi_processor_stop(struct device *dev)
{
struct acpi_device *device = ACPI_COMPANION(dev);
struct acpi_processor *pr;

if (!device)
return 0;
return;

acpi_remove_notify_handler(device->handle, ACPI_DEVICE_NOTIFY,
acpi_processor_notify);

pr = acpi_driver_data(device);
if (!pr)
return 0;
return;
acpi_processor_power_exit(pr);

acpi_pss_perf_exit(pr, device);

acpi_cppc_processor_exit(pr);

return 0;
}

bool acpi_processor_cpufreq_init;
@@ -295,14 +295,17 @@ static int amba_probe(struct device *dev)
return ret;
}

static int amba_remove(struct device *dev)
static void amba_remove(struct device *dev)
{
struct amba_device *pcdev = to_amba_device(dev);
struct amba_driver *drv = to_amba_driver(dev->driver);
int ret;

pm_runtime_get_sync(dev);
ret = drv->remove(pcdev);
if (ret)
dev_info(dev, "Failed to remove (%pe), ignoring\n",
ERR_PTR(ret));
pm_runtime_put_noidle(dev);

/* Undo the runtime PM settings in amba_probe() */
@@ -312,8 +315,6 @@ static int amba_remove(struct device *dev)

amba_put_disable_pclk(pcdev);
dev_pm_domain_detach(dev, true);

return ret;
}

static void amba_shutdown(struct device *dev)
@@ -777,17 +777,18 @@ static int platform_drv_probe_fail(struct device *_dev)
return -ENXIO;
}

static int platform_drv_remove(struct device *_dev)
static void platform_drv_remove(struct device *_dev)
{
struct platform_driver *drv = to_platform_driver(_dev->driver);
struct platform_device *dev = to_platform_device(_dev);
int ret = 0;

if (drv->remove)
ret = drv->remove(dev);
if (drv->remove) {
int ret = drv->remove(dev);
if (ret)
dev_warn(_dev, "Failed to remove driver (%pe), ignoring\n",
ERR_PTR(ret));
}
dev_pm_domain_detach(_dev, true);

return ret;
}

static void platform_drv_shutdown(struct device *_dev)
@@ -339,19 +339,16 @@ static int fsl_mc_driver_probe(struct device *dev)
return 0;
}

static int fsl_mc_driver_remove(struct device *dev)
static void fsl_mc_driver_remove(struct device *dev)
{
struct fsl_mc_driver *mc_drv = to_fsl_mc_driver(dev->driver);
struct fsl_mc_device *mc_dev = to_fsl_mc_device(dev);
int error;

error = mc_drv->remove(mc_dev);
if (error < 0) {
dev_err(dev, "%s failed: %d\n", __func__, error);
return error;
dev_err(dev, "%s failed: %d (ignoring)\n", __func__, error);
}

return 0;
}

static void fsl_mc_driver_shutdown(struct device *dev)
@@ -1213,7 +1213,7 @@ static int mhi_driver_probe(struct device *dev)
return ret;
}

static int mhi_driver_remove(struct device *dev)
static void mhi_driver_remove(struct device *dev)
{
struct mhi_device *mhi_dev = to_mhi_device(dev);
struct mhi_driver *mhi_drv = to_mhi_driver(dev->driver);
@@ -1227,7 +1227,7 @@ static int mhi_driver_remove(struct device *dev)

/* Skip if it is a controller device */
if (mhi_dev->dev_type == MHI_DEVICE_CONTROLLER)
return 0;
return;

/* Reset both channels */
for (dir = 0; dir < 2; dir++) {
@@ -1280,8 +1280,6 @@ static int mhi_driver_remove(struct device *dev)
while (mhi_dev->dev_wake)
mhi_device_put(mhi_dev);
read_unlock_bh(&mhi_cntrl->pm_lock);

return 0;
}

int __mhi_driver_register(struct mhi_driver *mhi_drv, struct module *owner)
@@ -261,13 +261,11 @@ static int optee_rng_probe(struct device *dev)
return err;
}

static int optee_rng_remove(struct device *dev)
static void optee_rng_remove(struct device *dev)
{
hwrng_unregister(&pvt_data.optee_rng);
tee_client_close_session(pvt_data.ctx, pvt_data.session_id);
tee_client_close_context(pvt_data.ctx);

return 0;
}

static const struct tee_client_device_id optee_rng_id_table[] = {
@@ -310,7 +310,7 @@ static int ftpm_plat_tee_probe(struct platform_device *pdev)
* Return:
* 0 always.
*/
static int ftpm_tee_remove(struct device *dev)
static void ftpm_tee_remove(struct device *dev)
{
struct ftpm_tee_private *pvt_data = dev_get_drvdata(dev);

@@ -330,15 +330,15 @@ static int ftpm_tee_remove(struct device *dev)
tee_client_close_context(pvt_data->ctx);

/* memory allocated with devm_kzalloc() is freed automatically */

return 0;
}

static int ftpm_plat_tee_remove(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;

return ftpm_tee_remove(dev);
ftpm_tee_remove(dev);

return 0;
}

/**
@@ -232,14 +232,12 @@ static int tee_bnxt_fw_probe(struct device *dev)
return err;
}

static int tee_bnxt_fw_remove(struct device *dev)
static void tee_bnxt_fw_remove(struct device *dev)
{
tee_shm_free(pvt_data.fw_shm_pool);
tee_client_close_session(pvt_data.ctx, pvt_data.session_id);
tee_client_close_context(pvt_data.ctx);
pvt_data.ctx = NULL;

return 0;
}

static const struct tee_client_device_id tee_bnxt_fw_id_table[] = {
@@ -259,7 +259,7 @@ static int hub_master_probe(struct device *dev)
return rc;
}

static int hub_master_remove(struct device *dev)
static void hub_master_remove(struct device *dev)
{
struct fsi_master_hub *hub = dev_get_drvdata(dev);

@@ -272,8 +272,6 @@ static int hub_master_remove(struct device *dev)
* the hub
*/
put_device(&hub->master.dev);

return 0;
}

static const struct fsi_device_id hub_master_ids[] = {
@@ -1010,7 +1010,7 @@ static int sbefifo_unregister_child(struct device *dev, void *data)
return 0;
}

static int sbefifo_remove(struct device *dev)
static void sbefifo_remove(struct device *dev)
{
struct sbefifo *sbefifo = dev_get_drvdata(dev);

@@ -1024,8 +1024,6 @@ static int sbefifo_remove(struct device *dev)
fsi_free_minor(sbefifo->dev.devt);
device_for_each_child(dev, NULL, sbefifo_unregister_child);
put_device(&sbefifo->dev);

return 0;
}

static const struct fsi_device_id sbefifo_ids[] = {
@@ -613,7 +613,7 @@ static int scom_probe(struct device *dev)
return rc;
}

static int scom_remove(struct device *dev)
static void scom_remove(struct device *dev)
{
struct scom_device *scom = dev_get_drvdata(dev);

@@ -623,8 +623,6 @@ static int scom_remove(struct device *dev)
cdev_device_del(&scom->cdev, &scom->dev);
fsi_free_minor(scom->dev.devt);
put_device(&scom->dev);

return 0;
}

static const struct fsi_device_id scom_ids[] = {
@@ -1150,12 +1150,15 @@ static int mipi_dsi_drv_probe(struct device *dev)
return drv->probe(dsi);
}

static int mipi_dsi_drv_remove(struct device *dev)
static void mipi_dsi_drv_remove(struct device *dev)
{
struct mipi_dsi_driver *drv = to_mipi_dsi_driver(dev->driver);
struct mipi_dsi_device *dsi = to_mipi_dsi_device(dev);

return drv->remove(dsi);
int ret = drv->remove(dsi);
if (ret)
dev_warn(dev, "Failed to unbind device (%pe), ignoring\n",
ERR_PTR(ret));
}

static void mipi_dsi_drv_shutdown(struct device *dev)
@@ -619,15 +619,18 @@ static int host1x_device_probe(struct device *dev)
return 0;
}

static int host1x_device_remove(struct device *dev)
static void host1x_device_remove(struct device *dev)
{
struct host1x_driver *driver = to_host1x_driver(dev->driver);
struct host1x_device *device = to_host1x_device(dev);

if (driver->remove)
return driver->remove(device);
if (driver->remove) {
int ret = driver->remove(device);
if (ret)
dev_warn(dev, "Failed to unbind driver (%pe), ignoring\n",
ERR_PTR(ret));

return 0;
}
}

static void host1x_device_shutdown(struct device *dev)
@@ -222,7 +222,7 @@ static int greybus_probe(struct device *dev)
return 0;
}

static int greybus_remove(struct device *dev)
static void greybus_remove(struct device *dev)
{
struct greybus_driver *driver = to_greybus_driver(dev->driver);
struct gb_bundle *bundle = to_gb_bundle(dev);
@@ -261,8 +261,6 @@ static int greybus_remove(struct device *dev)
pm_runtime_set_suspended(dev);
pm_runtime_dont_use_autosuspend(dev);
pm_runtime_put_noidle(dev);

return 0;
}

int greybus_register_driver(struct greybus_driver *driver, struct module *owner,
@@ -1402,7 +1402,7 @@ static int cs_hsi_client_probe(struct device *dev)
return err;
}

static int cs_hsi_client_remove(struct device *dev)
static void cs_hsi_client_remove(struct device *dev)
{
struct cs_hsi_iface *hi;

@@ -1414,8 +1414,6 @@ static int cs_hsi_client_remove(struct device *dev)
spin_unlock_bh(&cs_char_data.lock);
if (hi)
cs_hsi_stop(hi);

return 0;
}

static struct hsi_client_driver cs_hsi_driver = {
@@ -730,7 +730,7 @@ static int hsc_probe(struct device *dev)
return ret;
}

static int hsc_remove(struct device *dev)
static void hsc_remove(struct device *dev)
{
struct hsi_client *cl = to_hsi_client(dev);
struct hsc_client_data *cl_data = hsi_client_drvdata(cl);
@@ -740,8 +740,6 @@ static int hsc_remove(struct device *dev)
unregister_chrdev_region(hsc_dev, HSC_DEVS);
hsi_client_set_drvdata(cl, NULL);
kfree(cl_data);

return 0;
}

static struct hsi_client_driver hsc_driver = {
@@ -237,7 +237,7 @@ static int nokia_modem_probe(struct device *dev)
return err;
}

static int nokia_modem_remove(struct device *dev)
static void nokia_modem_remove(struct device *dev)
{
struct nokia_modem_device *modem = dev_get_drvdata(dev);

@@ -258,8 +258,6 @@ static int nokia_modem_remove(struct device *dev)
dev_set_drvdata(dev, NULL);
disable_irq_wake(modem->nokia_modem_rst_ind_irq);
tasklet_kill(&modem->nokia_modem_rst_ind_tasklet);

return 0;
}

#ifdef CONFIG_OF
@@ -1146,7 +1146,7 @@ static int ssi_protocol_probe(struct device *dev)
return err;
}

static int ssi_protocol_remove(struct device *dev)
static void ssi_protocol_remove(struct device *dev)
{
struct hsi_client *cl = to_hsi_client(dev);
struct ssi_protocol *ssi = hsi_client_drvdata(cl);
@@ -1156,8 +1156,6 @@ static int ssi_protocol_remove(struct device *dev)
ssip_free_cmds(ssi);
hsi_client_set_drvdata(cl, NULL);
kfree(ssi);

return 0;
}

static struct hsi_client_driver ssip_driver = {

0 comments on commit b836c14

Please sign in to comment.