Change struct platform_driver::remove() to return void

This is step b) of the plan outlined in commit 5c5a7680e6 ("platform:
 Provide a remove callback that returns no value"), which completes the
 first major step of making the remove callback return no value. Up to
 now it returned an int which however was mostly ignored by the driver
 core and lured driver authors to believe there is some error handling.
 
 Note that the Linux driver model assumes that removing a device cannot
 fail, so this isn't about being lazy and not implementing error handling
 in the core and so making .remove return void is the right thing to do.
 -----BEGIN PGP SIGNATURE-----
 
 iQEzBAABCgAdFiEEP4GsaTp6HlmJrf7Tj4D7WH0S/k4FAmZgPUoACgkQj4D7WH0S
 /k5qgQgAt8+E9rZV65Ds24Exd7TNIGmtvCrlP3GB4WZs11AvPkDQfaBs7udI9UPX
 UDq5GY++5Sh8QYxphnJFM10rd8hSl8oP7cxWmSJEpunulVDtlgTL5JbqyJPOd0xK
 4WzQWd2bGWJbMmzhUaLq8FlxQGxVskrjKpZX4HMGX+44YgGQs0oSJ6OYBzasK0Iz
 mDJO9176QyjLwBzGX41d0jrgtMuxUOYXXzb2hgWOpNLlLSilFzXOJiI3ttLm90Bg
 Vr9jS4MAc19tCmybO5IhkUqyalV0nAagzO7UR4u5tMKvnRbqxm9EOqJg6xzOZk1/
 ZSyD3MjAPjBRMyKDj2jVelcidlfXjw==
 =/Ht2
 -----END PGP SIGNATURE-----

Merge tag 'platform-remove-void-step-b' of https://git.kernel.org/pub/scm/linux/kernel/git/ukleinek/linux into driver-core-next

Uwe writes:

Change struct platform_driver::remove() to return void

This is step b) of the plan outlined in commit 5c5a7680e6 ("platform:
Provide a remove callback that returns no value"), which completes the
first major step of making the remove callback return no value. Up to
now it returned an int which however was mostly ignored by the driver
core and lured driver authors to believe there is some error handling.

Note that the Linux driver model assumes that removing a device cannot
fail, so this isn't about being lazy and not implementing error handling
in the core and so making .remove return void is the right thing to do.

* tag 'platform-remove-void-step-b' of https://git.kernel.org/pub/scm/linux/kernel/git/ukleinek/linux:
  platform: Make platform_driver::remove() return void
  samples: qmi: Convert to platform remove callback returning void
  nvdimm/of_pmem: Convert to platform remove callback returning void
  nvdimm/e820: Convert to platform remove callback returning void
  gpu: ipu-v3: Convert to platform remove callback returning void
  gpu: host1x: Convert to platform remove callback returning void
  drm/mediatek: Convert to platform remove callback returning void
  drm/imagination: Convert to platform remove callback returning void
  gpu: host1x: mipi: Benefit from devm_clk_get_prepared()
  pps: clients: gpio: Convert to platform remove callback returning void
  fsi: occ: Convert to platform remove callback returning void
  fsi: master-gpio: Convert to platform remove callback returning void
  fsi: master-ast-cf: Convert to platform remove callback returning void
  fsi: master-aspeed: Convert to platform remove callback returning void
  reset: ti-sci: Convert to platform remove callback returning void
  reset: rzg2l-usbphy-ctrl: Convert to platform remove callback returning void
  reset: meson-audio-arb: Convert to platform remove callback returning void
This commit is contained in:
Greg Kroah-Hartman 2024-06-07 21:07:09 +02:00
commit bd7246a19e
20 changed files with 44 additions and 97 deletions

View File

@ -1420,14 +1420,8 @@ static void platform_remove(struct device *_dev)
struct platform_driver *drv = to_platform_driver(_dev->driver);
struct platform_device *dev = to_platform_device(_dev);
if (drv->remove_new) {
drv->remove_new(dev);
} else if (drv->remove) {
int ret = drv->remove(dev);
if (ret)
dev_warn(_dev, "remove callback returned a non-zero value. This will be ignored.\n");
}
if (drv->remove)
drv->remove(dev);
dev_pm_domain_detach(_dev, true);
}

View File

@ -646,14 +646,12 @@ err_free_aspeed:
return rc;
}
static int fsi_master_aspeed_remove(struct platform_device *pdev)
static void fsi_master_aspeed_remove(struct platform_device *pdev)
{
struct fsi_master_aspeed *aspeed = platform_get_drvdata(pdev);
fsi_master_unregister(&aspeed->master);
clk_disable_unprepare(aspeed->clk);
return 0;
}
static const struct of_device_id fsi_master_aspeed_match[] = {
@ -668,7 +666,7 @@ static struct platform_driver fsi_master_aspeed_driver = {
.of_match_table = fsi_master_aspeed_match,
},
.probe = fsi_master_aspeed_probe,
.remove = fsi_master_aspeed_remove,
.remove_new = fsi_master_aspeed_remove,
};
module_platform_driver(fsi_master_aspeed_driver);

View File

@ -1412,15 +1412,13 @@ static int fsi_master_acf_probe(struct platform_device *pdev)
}
static int fsi_master_acf_remove(struct platform_device *pdev)
static void fsi_master_acf_remove(struct platform_device *pdev)
{
struct fsi_master_acf *master = platform_get_drvdata(pdev);
device_remove_file(master->dev, &dev_attr_external_mode);
fsi_master_unregister(&master->master);
return 0;
}
static const struct of_device_id fsi_master_acf_match[] = {
@ -1436,7 +1434,7 @@ static struct platform_driver fsi_master_acf = {
.of_match_table = fsi_master_acf_match,
},
.probe = fsi_master_acf_probe,
.remove = fsi_master_acf_remove,
.remove_new = fsi_master_acf_remove,
};
module_platform_driver(fsi_master_acf);

View File

@ -867,15 +867,13 @@ static int fsi_master_gpio_probe(struct platform_device *pdev)
static int fsi_master_gpio_remove(struct platform_device *pdev)
static void fsi_master_gpio_remove(struct platform_device *pdev)
{
struct fsi_master_gpio *master = platform_get_drvdata(pdev);
device_remove_file(&pdev->dev, &dev_attr_external_mode);
fsi_master_unregister(&master->master);
return 0;
}
static const struct of_device_id fsi_master_gpio_match[] = {
@ -890,7 +888,7 @@ static struct platform_driver fsi_master_gpio_driver = {
.of_match_table = fsi_master_gpio_match,
},
.probe = fsi_master_gpio_probe,
.remove = fsi_master_gpio_remove,
.remove_new = fsi_master_gpio_remove,
};
module_platform_driver(fsi_master_gpio_driver);

View File

@ -703,7 +703,7 @@ static int occ_probe(struct platform_device *pdev)
return 0;
}
static int occ_remove(struct platform_device *pdev)
static void occ_remove(struct platform_device *pdev)
{
struct occ *occ = platform_get_drvdata(pdev);
@ -720,8 +720,6 @@ static int occ_remove(struct platform_device *pdev)
device_for_each_child(&pdev->dev, NULL, occ_unregister_of_child);
ida_simple_remove(&occ_ida, occ->idx);
return 0;
}
static const struct of_device_id occ_match[] = {
@ -743,7 +741,7 @@ static struct platform_driver occ_driver = {
.of_match_table = occ_match,
},
.probe = occ_probe,
.remove = occ_remove,
.remove_new = occ_remove,
};
static int occ_init(void)

View File

@ -1451,8 +1451,7 @@ err_context_fini:
return err;
}
static int
pvr_remove(struct platform_device *plat_dev)
static void pvr_remove(struct platform_device *plat_dev)
{
struct drm_device *drm_dev = platform_get_drvdata(plat_dev);
struct pvr_device *pvr_dev = to_pvr_device(drm_dev);
@ -1469,8 +1468,6 @@ pvr_remove(struct platform_device *plat_dev)
pvr_watchdog_fini(pvr_dev);
pvr_queue_device_fini(pvr_dev);
pvr_context_device_fini(pvr_dev);
return 0;
}
static const struct of_device_id dt_match[] = {
@ -1485,7 +1482,7 @@ static const struct dev_pm_ops pvr_pm_ops = {
static struct platform_driver pvr_driver = {
.probe = pvr_probe,
.remove = pvr_remove,
.remove_new = pvr_remove,
.driver = {
.name = PVR_DRIVER_NAME,
.pm = &pvr_pm_ops,

View File

@ -137,10 +137,9 @@ static int mtk_padding_probe(struct platform_device *pdev)
return 0;
}
static int mtk_padding_remove(struct platform_device *pdev)
static void mtk_padding_remove(struct platform_device *pdev)
{
component_del(&pdev->dev, &mtk_padding_component_ops);
return 0;
}
static const struct of_device_id mtk_padding_driver_dt_match[] = {
@ -151,7 +150,7 @@ MODULE_DEVICE_TABLE(of, mtk_padding_driver_dt_match);
struct platform_driver mtk_padding_driver = {
.probe = mtk_padding_probe,
.remove = mtk_padding_remove,
.remove_new = mtk_padding_remove,
.driver = {
.name = "mediatek-disp-padding",
.of_match_table = mtk_padding_driver_dt_match,

View File

@ -677,7 +677,7 @@ destroy_cache:
return err;
}
static int host1x_remove(struct platform_device *pdev)
static void host1x_remove(struct platform_device *pdev)
{
struct host1x *host = platform_get_drvdata(pdev);
@ -692,8 +692,6 @@ static int host1x_remove(struct platform_device *pdev)
host1x_channel_list_free(&host->channel_list);
host1x_iommu_exit(host);
host1x_bo_cache_destroy(&host->cache);
return 0;
}
static int __maybe_unused host1x_runtime_suspend(struct device *dev)
@ -778,7 +776,7 @@ static struct platform_driver tegra_host1x_driver = {
.pm = &host1x_pm_ops,
},
.probe = host1x_probe,
.remove = host1x_remove,
.remove_new = host1x_remove,
};
static struct platform_driver * const drivers[] = {

View File

@ -501,7 +501,6 @@ static int tegra_mipi_probe(struct platform_device *pdev)
{
const struct of_device_id *match;
struct tegra_mipi *mipi;
int err;
match = of_match_node(tegra_mipi_of_match, pdev->dev.of_node);
if (!match)
@ -520,35 +519,21 @@ static int tegra_mipi_probe(struct platform_device *pdev)
mutex_init(&mipi->lock);
mipi->clk = devm_clk_get(&pdev->dev, NULL);
mipi->clk = devm_clk_get_prepared(&pdev->dev, NULL);
if (IS_ERR(mipi->clk)) {
dev_err(&pdev->dev, "failed to get clock\n");
return PTR_ERR(mipi->clk);
}
err = clk_prepare(mipi->clk);
if (err < 0)
return err;
platform_set_drvdata(pdev, mipi);
return 0;
}
static int tegra_mipi_remove(struct platform_device *pdev)
{
struct tegra_mipi *mipi = platform_get_drvdata(pdev);
clk_unprepare(mipi->clk);
return 0;
}
struct platform_driver tegra_mipi_driver = {
.driver = {
.name = "tegra-mipi",
.of_match_table = tegra_mipi_of_match,
},
.probe = tegra_mipi_probe,
.remove = tegra_mipi_remove,
};

View File

@ -1450,7 +1450,7 @@ out_failed_reset:
return ret;
}
static int ipu_remove(struct platform_device *pdev)
static void ipu_remove(struct platform_device *pdev)
{
struct ipu_soc *ipu = platform_get_drvdata(pdev);
@ -1459,8 +1459,6 @@ static int ipu_remove(struct platform_device *pdev)
ipu_irq_exit(ipu);
clk_disable_unprepare(ipu->clk);
return 0;
}
static struct platform_driver imx_ipu_driver = {
@ -1469,7 +1467,7 @@ static struct platform_driver imx_ipu_driver = {
.of_match_table = imx_ipu_dt_ids,
},
.probe = ipu_probe,
.remove = ipu_remove,
.remove_new = ipu_remove,
};
static struct platform_driver * const drivers[] = {

View File

@ -312,7 +312,7 @@ static int ipu_pre_probe(struct platform_device *pdev)
return 0;
}
static int ipu_pre_remove(struct platform_device *pdev)
static void ipu_pre_remove(struct platform_device *pdev)
{
struct ipu_pre *pre = platform_get_drvdata(pdev);
@ -326,7 +326,6 @@ static int ipu_pre_remove(struct platform_device *pdev)
if (pre->buffer_virt)
gen_pool_free(pre->iram, (unsigned long)pre->buffer_virt,
IPU_PRE_MAX_WIDTH * IPU_PRE_NUM_SCANLINES * 4);
return 0;
}
static const struct of_device_id ipu_pre_dt_ids[] = {
@ -336,7 +335,7 @@ static const struct of_device_id ipu_pre_dt_ids[] = {
struct platform_driver ipu_pre_drv = {
.probe = ipu_pre_probe,
.remove = ipu_pre_remove,
.remove_new = ipu_pre_remove,
.driver = {
.name = "imx-ipu-pre",
.of_match_table = ipu_pre_dt_ids,

View File

@ -419,15 +419,13 @@ static int ipu_prg_probe(struct platform_device *pdev)
return 0;
}
static int ipu_prg_remove(struct platform_device *pdev)
static void ipu_prg_remove(struct platform_device *pdev)
{
struct ipu_prg *prg = platform_get_drvdata(pdev);
mutex_lock(&ipu_prg_list_mutex);
list_del(&prg->list);
mutex_unlock(&ipu_prg_list_mutex);
return 0;
}
#ifdef CONFIG_PM
@ -471,7 +469,7 @@ static const struct of_device_id ipu_prg_dt_ids[] = {
struct platform_driver ipu_prg_drv = {
.probe = ipu_prg_probe,
.remove = ipu_prg_remove,
.remove_new = ipu_prg_remove,
.driver = {
.name = "imx-ipu-prg",
.pm = &prg_pm_ops,

View File

@ -9,12 +9,11 @@
#include <linux/module.h>
#include <linux/numa.h>
static int e820_pmem_remove(struct platform_device *pdev)
static void e820_pmem_remove(struct platform_device *pdev)
{
struct nvdimm_bus *nvdimm_bus = platform_get_drvdata(pdev);
nvdimm_bus_unregister(nvdimm_bus);
return 0;
}
static int e820_register_one(struct resource *res, void *data)
@ -60,7 +59,7 @@ err:
static struct platform_driver e820_pmem_driver = {
.probe = e820_pmem_probe,
.remove = e820_pmem_remove,
.remove_new = e820_pmem_remove,
.driver = {
.name = "e820_pmem",
},

View File

@ -84,14 +84,12 @@ static int of_pmem_region_probe(struct platform_device *pdev)
return 0;
}
static int of_pmem_region_remove(struct platform_device *pdev)
static void of_pmem_region_remove(struct platform_device *pdev)
{
struct of_pmem_private *priv = platform_get_drvdata(pdev);
nvdimm_bus_unregister(priv->bus);
kfree(priv);
return 0;
}
static const struct of_device_id of_pmem_region_match[] = {
@ -102,7 +100,7 @@ static const struct of_device_id of_pmem_region_match[] = {
static struct platform_driver of_pmem_region_driver = {
.probe = of_pmem_region_probe,
.remove = of_pmem_region_remove,
.remove_new = of_pmem_region_remove,
.driver = {
.name = "of_pmem",
.of_match_table = of_pmem_region_match,

View File

@ -220,7 +220,7 @@ static int pps_gpio_probe(struct platform_device *pdev)
return 0;
}
static int pps_gpio_remove(struct platform_device *pdev)
static void pps_gpio_remove(struct platform_device *pdev)
{
struct pps_gpio_device_data *data = platform_get_drvdata(pdev);
@ -229,7 +229,6 @@ static int pps_gpio_remove(struct platform_device *pdev)
/* reset echo pin in any case */
gpiod_set_value(data->echo_pin, 0);
dev_info(&pdev->dev, "removed IRQ %d as PPS source\n", data->irq);
return 0;
}
static const struct of_device_id pps_gpio_dt_ids[] = {
@ -240,7 +239,7 @@ MODULE_DEVICE_TABLE(of, pps_gpio_dt_ids);
static struct platform_driver pps_gpio_driver = {
.probe = pps_gpio_probe,
.remove = pps_gpio_remove,
.remove_new = pps_gpio_remove,
.driver = {
.name = PPS_GPIO_NAME,
.of_match_table = pps_gpio_dt_ids,

View File

@ -120,7 +120,7 @@ static const struct of_device_id meson_audio_arb_of_match[] = {
};
MODULE_DEVICE_TABLE(of, meson_audio_arb_of_match);
static int meson_audio_arb_remove(struct platform_device *pdev)
static void meson_audio_arb_remove(struct platform_device *pdev)
{
struct meson_audio_arb_data *arb = platform_get_drvdata(pdev);
@ -130,8 +130,6 @@ static int meson_audio_arb_remove(struct platform_device *pdev)
spin_unlock(&arb->lock);
clk_disable_unprepare(arb->clk);
return 0;
}
static int meson_audio_arb_probe(struct platform_device *pdev)
@ -189,7 +187,7 @@ static int meson_audio_arb_probe(struct platform_device *pdev)
static struct platform_driver meson_audio_arb_pdrv = {
.probe = meson_audio_arb_probe,
.remove = meson_audio_arb_remove,
.remove_new = meson_audio_arb_remove,
.driver = {
.name = "meson-audio-arb-reset",
.of_match_table = meson_audio_arb_of_match,

View File

@ -156,15 +156,13 @@ static int rzg2l_usbphy_ctrl_probe(struct platform_device *pdev)
return 0;
}
static int rzg2l_usbphy_ctrl_remove(struct platform_device *pdev)
static void rzg2l_usbphy_ctrl_remove(struct platform_device *pdev)
{
struct rzg2l_usbphy_ctrl_priv *priv = dev_get_drvdata(&pdev->dev);
pm_runtime_put(&pdev->dev);
pm_runtime_disable(&pdev->dev);
reset_control_assert(priv->rstc);
return 0;
}
static struct platform_driver rzg2l_usbphy_ctrl_driver = {
@ -173,7 +171,7 @@ static struct platform_driver rzg2l_usbphy_ctrl_driver = {
.of_match_table = rzg2l_usbphy_ctrl_match_table,
},
.probe = rzg2l_usbphy_ctrl_probe,
.remove = rzg2l_usbphy_ctrl_remove,
.remove_new = rzg2l_usbphy_ctrl_remove,
};
module_platform_driver(rzg2l_usbphy_ctrl_driver);

View File

@ -235,20 +235,18 @@ static int ti_sci_reset_probe(struct platform_device *pdev)
return reset_controller_register(&data->rcdev);
}
static int ti_sci_reset_remove(struct platform_device *pdev)
static void ti_sci_reset_remove(struct platform_device *pdev)
{
struct ti_sci_reset_data *data = platform_get_drvdata(pdev);
reset_controller_unregister(&data->rcdev);
idr_destroy(&data->idr);
return 0;
}
static struct platform_driver ti_sci_reset_driver = {
.probe = ti_sci_reset_probe,
.remove = ti_sci_reset_remove,
.remove_new = ti_sci_reset_remove,
.driver = {
.name = "ti-sci-reset",
.of_match_table = ti_sci_reset_of_match,

View File

@ -237,15 +237,14 @@ struct platform_driver {
int (*probe)(struct platform_device *);
/*
* Traditionally the remove callback returned an int which however is
* ignored by the driver core. This led to wrong expectations by driver
* authors who thought returning an error code was a valid error
* handling strategy. To convert to a callback returning void, new
* drivers should implement .remove_new() until the conversion it done
* that eventually makes .remove() return void.
* .remove_new() is a relic from a prototype conversion of .remove().
* New drivers are supposed to implement .remove(). Once all drivers are
* converted to not use .remove_new any more, it will be dropped.
*/
int (*remove)(struct platform_device *);
void (*remove_new)(struct platform_device *);
union {
void (*remove)(struct platform_device *);
void (*remove_new)(struct platform_device *);
};
void (*shutdown)(struct platform_device *);
int (*suspend)(struct platform_device *, pm_message_t state);

View File

@ -511,7 +511,7 @@ err_release_qmi_handle:
return ret;
}
static int qmi_sample_remove(struct platform_device *pdev)
static void qmi_sample_remove(struct platform_device *pdev)
{
struct qmi_sample *sample = platform_get_drvdata(pdev);
@ -520,13 +520,11 @@ static int qmi_sample_remove(struct platform_device *pdev)
debugfs_remove(sample->de_dir);
qmi_handle_release(&sample->qmi);
return 0;
}
static struct platform_driver qmi_sample_driver = {
.probe = qmi_sample_probe,
.remove = qmi_sample_remove,
.remove_new = qmi_sample_remove,
.driver = {
.name = "qmi_sample_client",
},