Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 5c5a7680e67b ("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

+44 -97
+2 -8
drivers/base/platform.c
··· 1420 1420 struct platform_driver *drv = to_platform_driver(_dev->driver); 1421 1421 struct platform_device *dev = to_platform_device(_dev); 1422 1422 1423 - if (drv->remove_new) { 1424 - drv->remove_new(dev); 1425 - } else if (drv->remove) { 1426 - int ret = drv->remove(dev); 1427 - 1428 - if (ret) 1429 - dev_warn(_dev, "remove callback returned a non-zero value. This will be ignored.\n"); 1430 - } 1423 + if (drv->remove) 1424 + drv->remove(dev); 1431 1425 dev_pm_domain_detach(_dev, true); 1432 1426 } 1433 1427
+2 -4
drivers/fsi/fsi-master-aspeed.c
··· 646 646 return rc; 647 647 } 648 648 649 - static int fsi_master_aspeed_remove(struct platform_device *pdev) 649 + static void fsi_master_aspeed_remove(struct platform_device *pdev) 650 650 { 651 651 struct fsi_master_aspeed *aspeed = platform_get_drvdata(pdev); 652 652 653 653 fsi_master_unregister(&aspeed->master); 654 654 clk_disable_unprepare(aspeed->clk); 655 - 656 - return 0; 657 655 } 658 656 659 657 static const struct of_device_id fsi_master_aspeed_match[] = { ··· 666 668 .of_match_table = fsi_master_aspeed_match, 667 669 }, 668 670 .probe = fsi_master_aspeed_probe, 669 - .remove = fsi_master_aspeed_remove, 671 + .remove_new = fsi_master_aspeed_remove, 670 672 }; 671 673 672 674 module_platform_driver(fsi_master_aspeed_driver);
+2 -4
drivers/fsi/fsi-master-ast-cf.c
··· 1412 1412 } 1413 1413 1414 1414 1415 - static int fsi_master_acf_remove(struct platform_device *pdev) 1415 + static void fsi_master_acf_remove(struct platform_device *pdev) 1416 1416 { 1417 1417 struct fsi_master_acf *master = platform_get_drvdata(pdev); 1418 1418 1419 1419 device_remove_file(master->dev, &dev_attr_external_mode); 1420 1420 1421 1421 fsi_master_unregister(&master->master); 1422 - 1423 - return 0; 1424 1422 } 1425 1423 1426 1424 static const struct of_device_id fsi_master_acf_match[] = { ··· 1434 1436 .of_match_table = fsi_master_acf_match, 1435 1437 }, 1436 1438 .probe = fsi_master_acf_probe, 1437 - .remove = fsi_master_acf_remove, 1439 + .remove_new = fsi_master_acf_remove, 1438 1440 }; 1439 1441 1440 1442 module_platform_driver(fsi_master_acf);
+2 -4
drivers/fsi/fsi-master-gpio.c
··· 867 867 868 868 869 869 870 - static int fsi_master_gpio_remove(struct platform_device *pdev) 870 + static void fsi_master_gpio_remove(struct platform_device *pdev) 871 871 { 872 872 struct fsi_master_gpio *master = platform_get_drvdata(pdev); 873 873 874 874 device_remove_file(&pdev->dev, &dev_attr_external_mode); 875 875 876 876 fsi_master_unregister(&master->master); 877 - 878 - return 0; 879 877 } 880 878 881 879 static const struct of_device_id fsi_master_gpio_match[] = { ··· 888 890 .of_match_table = fsi_master_gpio_match, 889 891 }, 890 892 .probe = fsi_master_gpio_probe, 891 - .remove = fsi_master_gpio_remove, 893 + .remove_new = fsi_master_gpio_remove, 892 894 }; 893 895 894 896 module_platform_driver(fsi_master_gpio_driver);
+2 -4
drivers/fsi/fsi-occ.c
··· 703 703 return 0; 704 704 } 705 705 706 - static int occ_remove(struct platform_device *pdev) 706 + static void occ_remove(struct platform_device *pdev) 707 707 { 708 708 struct occ *occ = platform_get_drvdata(pdev); 709 709 ··· 720 720 device_for_each_child(&pdev->dev, NULL, occ_unregister_of_child); 721 721 722 722 ida_simple_remove(&occ_ida, occ->idx); 723 - 724 - return 0; 725 723 } 726 724 727 725 static const struct of_device_id occ_match[] = { ··· 741 743 .of_match_table = occ_match, 742 744 }, 743 745 .probe = occ_probe, 744 - .remove = occ_remove, 746 + .remove_new = occ_remove, 745 747 }; 746 748 747 749 static int occ_init(void)
+2 -5
drivers/gpu/drm/imagination/pvr_drv.c
··· 1451 1451 return err; 1452 1452 } 1453 1453 1454 - static int 1455 - pvr_remove(struct platform_device *plat_dev) 1454 + static void pvr_remove(struct platform_device *plat_dev) 1456 1455 { 1457 1456 struct drm_device *drm_dev = platform_get_drvdata(plat_dev); 1458 1457 struct pvr_device *pvr_dev = to_pvr_device(drm_dev); ··· 1468 1469 pvr_watchdog_fini(pvr_dev); 1469 1470 pvr_queue_device_fini(pvr_dev); 1470 1471 pvr_context_device_fini(pvr_dev); 1471 - 1472 - return 0; 1473 1472 } 1474 1473 1475 1474 static const struct of_device_id dt_match[] = { ··· 1482 1485 1483 1486 static struct platform_driver pvr_driver = { 1484 1487 .probe = pvr_probe, 1485 - .remove = pvr_remove, 1488 + .remove_new = pvr_remove, 1486 1489 .driver = { 1487 1490 .name = PVR_DRIVER_NAME, 1488 1491 .pm = &pvr_pm_ops,
+2 -3
drivers/gpu/drm/mediatek/mtk_padding.c
··· 137 137 return 0; 138 138 } 139 139 140 - static int mtk_padding_remove(struct platform_device *pdev) 140 + static void mtk_padding_remove(struct platform_device *pdev) 141 141 { 142 142 component_del(&pdev->dev, &mtk_padding_component_ops); 143 - return 0; 144 143 } 145 144 146 145 static const struct of_device_id mtk_padding_driver_dt_match[] = { ··· 150 151 151 152 struct platform_driver mtk_padding_driver = { 152 153 .probe = mtk_padding_probe, 153 - .remove = mtk_padding_remove, 154 + .remove_new = mtk_padding_remove, 154 155 .driver = { 155 156 .name = "mediatek-disp-padding", 156 157 .of_match_table = mtk_padding_driver_dt_match,
+2 -4
drivers/gpu/host1x/dev.c
··· 677 677 return err; 678 678 } 679 679 680 - static int host1x_remove(struct platform_device *pdev) 680 + static void host1x_remove(struct platform_device *pdev) 681 681 { 682 682 struct host1x *host = platform_get_drvdata(pdev); 683 683 ··· 692 692 host1x_channel_list_free(&host->channel_list); 693 693 host1x_iommu_exit(host); 694 694 host1x_bo_cache_destroy(&host->cache); 695 - 696 - return 0; 697 695 } 698 696 699 697 static int __maybe_unused host1x_runtime_suspend(struct device *dev) ··· 776 778 .pm = &host1x_pm_ops, 777 779 }, 778 780 .probe = host1x_probe, 779 - .remove = host1x_remove, 781 + .remove_new = host1x_remove, 780 782 }; 781 783 782 784 static struct platform_driver * const drivers[] = {
+1 -16
drivers/gpu/host1x/mipi.c
··· 501 501 { 502 502 const struct of_device_id *match; 503 503 struct tegra_mipi *mipi; 504 - int err; 505 504 506 505 match = of_match_node(tegra_mipi_of_match, pdev->dev.of_node); 507 506 if (!match) ··· 519 520 520 521 mutex_init(&mipi->lock); 521 522 522 - mipi->clk = devm_clk_get(&pdev->dev, NULL); 523 + mipi->clk = devm_clk_get_prepared(&pdev->dev, NULL); 523 524 if (IS_ERR(mipi->clk)) { 524 525 dev_err(&pdev->dev, "failed to get clock\n"); 525 526 return PTR_ERR(mipi->clk); 526 527 } 527 528 528 - err = clk_prepare(mipi->clk); 529 - if (err < 0) 530 - return err; 531 - 532 529 platform_set_drvdata(pdev, mipi); 533 - 534 - return 0; 535 - } 536 - 537 - static int tegra_mipi_remove(struct platform_device *pdev) 538 - { 539 - struct tegra_mipi *mipi = platform_get_drvdata(pdev); 540 - 541 - clk_unprepare(mipi->clk); 542 530 543 531 return 0; 544 532 } ··· 536 550 .of_match_table = tegra_mipi_of_match, 537 551 }, 538 552 .probe = tegra_mipi_probe, 539 - .remove = tegra_mipi_remove, 540 553 };
+2 -4
drivers/gpu/ipu-v3/ipu-common.c
··· 1450 1450 return ret; 1451 1451 } 1452 1452 1453 - static int ipu_remove(struct platform_device *pdev) 1453 + static void ipu_remove(struct platform_device *pdev) 1454 1454 { 1455 1455 struct ipu_soc *ipu = platform_get_drvdata(pdev); 1456 1456 ··· 1459 1459 ipu_irq_exit(ipu); 1460 1460 1461 1461 clk_disable_unprepare(ipu->clk); 1462 - 1463 - return 0; 1464 1462 } 1465 1463 1466 1464 static struct platform_driver imx_ipu_driver = { ··· 1467 1469 .of_match_table = imx_ipu_dt_ids, 1468 1470 }, 1469 1471 .probe = ipu_probe, 1470 - .remove = ipu_remove, 1472 + .remove_new = ipu_remove, 1471 1473 }; 1472 1474 1473 1475 static struct platform_driver * const drivers[] = {
+2 -3
drivers/gpu/ipu-v3/ipu-pre.c
··· 312 312 return 0; 313 313 } 314 314 315 - static int ipu_pre_remove(struct platform_device *pdev) 315 + static void ipu_pre_remove(struct platform_device *pdev) 316 316 { 317 317 struct ipu_pre *pre = platform_get_drvdata(pdev); 318 318 ··· 326 326 if (pre->buffer_virt) 327 327 gen_pool_free(pre->iram, (unsigned long)pre->buffer_virt, 328 328 IPU_PRE_MAX_WIDTH * IPU_PRE_NUM_SCANLINES * 4); 329 - return 0; 330 329 } 331 330 332 331 static const struct of_device_id ipu_pre_dt_ids[] = { ··· 335 336 336 337 struct platform_driver ipu_pre_drv = { 337 338 .probe = ipu_pre_probe, 338 - .remove = ipu_pre_remove, 339 + .remove_new = ipu_pre_remove, 339 340 .driver = { 340 341 .name = "imx-ipu-pre", 341 342 .of_match_table = ipu_pre_dt_ids,
+2 -4
drivers/gpu/ipu-v3/ipu-prg.c
··· 419 419 return 0; 420 420 } 421 421 422 - static int ipu_prg_remove(struct platform_device *pdev) 422 + static void ipu_prg_remove(struct platform_device *pdev) 423 423 { 424 424 struct ipu_prg *prg = platform_get_drvdata(pdev); 425 425 426 426 mutex_lock(&ipu_prg_list_mutex); 427 427 list_del(&prg->list); 428 428 mutex_unlock(&ipu_prg_list_mutex); 429 - 430 - return 0; 431 429 } 432 430 433 431 #ifdef CONFIG_PM ··· 469 471 470 472 struct platform_driver ipu_prg_drv = { 471 473 .probe = ipu_prg_probe, 472 - .remove = ipu_prg_remove, 474 + .remove_new = ipu_prg_remove, 473 475 .driver = { 474 476 .name = "imx-ipu-prg", 475 477 .pm = &prg_pm_ops,
+2 -3
drivers/nvdimm/e820.c
··· 9 9 #include <linux/module.h> 10 10 #include <linux/numa.h> 11 11 12 - static int e820_pmem_remove(struct platform_device *pdev) 12 + static void e820_pmem_remove(struct platform_device *pdev) 13 13 { 14 14 struct nvdimm_bus *nvdimm_bus = platform_get_drvdata(pdev); 15 15 16 16 nvdimm_bus_unregister(nvdimm_bus); 17 - return 0; 18 17 } 19 18 20 19 static int e820_register_one(struct resource *res, void *data) ··· 59 60 60 61 static struct platform_driver e820_pmem_driver = { 61 62 .probe = e820_pmem_probe, 62 - .remove = e820_pmem_remove, 63 + .remove_new = e820_pmem_remove, 63 64 .driver = { 64 65 .name = "e820_pmem", 65 66 },
+2 -4
drivers/nvdimm/of_pmem.c
··· 84 84 return 0; 85 85 } 86 86 87 - static int of_pmem_region_remove(struct platform_device *pdev) 87 + static void of_pmem_region_remove(struct platform_device *pdev) 88 88 { 89 89 struct of_pmem_private *priv = platform_get_drvdata(pdev); 90 90 91 91 nvdimm_bus_unregister(priv->bus); 92 92 kfree(priv); 93 - 94 - return 0; 95 93 } 96 94 97 95 static const struct of_device_id of_pmem_region_match[] = { ··· 100 102 101 103 static struct platform_driver of_pmem_region_driver = { 102 104 .probe = of_pmem_region_probe, 103 - .remove = of_pmem_region_remove, 105 + .remove_new = of_pmem_region_remove, 104 106 .driver = { 105 107 .name = "of_pmem", 106 108 .of_match_table = of_pmem_region_match,
+2 -3
drivers/pps/clients/pps-gpio.c
··· 220 220 return 0; 221 221 } 222 222 223 - static int pps_gpio_remove(struct platform_device *pdev) 223 + static void pps_gpio_remove(struct platform_device *pdev) 224 224 { 225 225 struct pps_gpio_device_data *data = platform_get_drvdata(pdev); 226 226 ··· 229 229 /* reset echo pin in any case */ 230 230 gpiod_set_value(data->echo_pin, 0); 231 231 dev_info(&pdev->dev, "removed IRQ %d as PPS source\n", data->irq); 232 - return 0; 233 232 } 234 233 235 234 static const struct of_device_id pps_gpio_dt_ids[] = { ··· 239 240 240 241 static struct platform_driver pps_gpio_driver = { 241 242 .probe = pps_gpio_probe, 242 - .remove = pps_gpio_remove, 243 + .remove_new = pps_gpio_remove, 243 244 .driver = { 244 245 .name = PPS_GPIO_NAME, 245 246 .of_match_table = pps_gpio_dt_ids,
+2 -4
drivers/reset/reset-meson-audio-arb.c
··· 120 120 }; 121 121 MODULE_DEVICE_TABLE(of, meson_audio_arb_of_match); 122 122 123 - static int meson_audio_arb_remove(struct platform_device *pdev) 123 + static void meson_audio_arb_remove(struct platform_device *pdev) 124 124 { 125 125 struct meson_audio_arb_data *arb = platform_get_drvdata(pdev); 126 126 ··· 130 130 spin_unlock(&arb->lock); 131 131 132 132 clk_disable_unprepare(arb->clk); 133 - 134 - return 0; 135 133 } 136 134 137 135 static int meson_audio_arb_probe(struct platform_device *pdev) ··· 187 189 188 190 static struct platform_driver meson_audio_arb_pdrv = { 189 191 .probe = meson_audio_arb_probe, 190 - .remove = meson_audio_arb_remove, 192 + .remove_new = meson_audio_arb_remove, 191 193 .driver = { 192 194 .name = "meson-audio-arb-reset", 193 195 .of_match_table = meson_audio_arb_of_match,
+2 -4
drivers/reset/reset-rzg2l-usbphy-ctrl.c
··· 156 156 return 0; 157 157 } 158 158 159 - static int rzg2l_usbphy_ctrl_remove(struct platform_device *pdev) 159 + static void rzg2l_usbphy_ctrl_remove(struct platform_device *pdev) 160 160 { 161 161 struct rzg2l_usbphy_ctrl_priv *priv = dev_get_drvdata(&pdev->dev); 162 162 163 163 pm_runtime_put(&pdev->dev); 164 164 pm_runtime_disable(&pdev->dev); 165 165 reset_control_assert(priv->rstc); 166 - 167 - return 0; 168 166 } 169 167 170 168 static struct platform_driver rzg2l_usbphy_ctrl_driver = { ··· 171 173 .of_match_table = rzg2l_usbphy_ctrl_match_table, 172 174 }, 173 175 .probe = rzg2l_usbphy_ctrl_probe, 174 - .remove = rzg2l_usbphy_ctrl_remove, 176 + .remove_new = rzg2l_usbphy_ctrl_remove, 175 177 }; 176 178 module_platform_driver(rzg2l_usbphy_ctrl_driver); 177 179
+2 -4
drivers/reset/reset-ti-sci.c
··· 235 235 return reset_controller_register(&data->rcdev); 236 236 } 237 237 238 - static int ti_sci_reset_remove(struct platform_device *pdev) 238 + static void ti_sci_reset_remove(struct platform_device *pdev) 239 239 { 240 240 struct ti_sci_reset_data *data = platform_get_drvdata(pdev); 241 241 242 242 reset_controller_unregister(&data->rcdev); 243 243 244 244 idr_destroy(&data->idr); 245 - 246 - return 0; 247 245 } 248 246 249 247 static struct platform_driver ti_sci_reset_driver = { 250 248 .probe = ti_sci_reset_probe, 251 - .remove = ti_sci_reset_remove, 249 + .remove_new = ti_sci_reset_remove, 252 250 .driver = { 253 251 .name = "ti-sci-reset", 254 252 .of_match_table = ti_sci_reset_of_match,
+7 -8
include/linux/platform_device.h
··· 237 237 int (*probe)(struct platform_device *); 238 238 239 239 /* 240 - * Traditionally the remove callback returned an int which however is 241 - * ignored by the driver core. This led to wrong expectations by driver 242 - * authors who thought returning an error code was a valid error 243 - * handling strategy. To convert to a callback returning void, new 244 - * drivers should implement .remove_new() until the conversion it done 245 - * that eventually makes .remove() return void. 240 + * .remove_new() is a relic from a prototype conversion of .remove(). 241 + * New drivers are supposed to implement .remove(). Once all drivers are 242 + * converted to not use .remove_new any more, it will be dropped. 246 243 */ 247 - int (*remove)(struct platform_device *); 248 - void (*remove_new)(struct platform_device *); 244 + union { 245 + void (*remove)(struct platform_device *); 246 + void (*remove_new)(struct platform_device *); 247 + }; 249 248 250 249 void (*shutdown)(struct platform_device *); 251 250 int (*suspend)(struct platform_device *, pm_message_t state);
+2 -4
samples/qmi/qmi_sample_client.c
··· 511 511 return ret; 512 512 } 513 513 514 - static int qmi_sample_remove(struct platform_device *pdev) 514 + static void qmi_sample_remove(struct platform_device *pdev) 515 515 { 516 516 struct qmi_sample *sample = platform_get_drvdata(pdev); 517 517 ··· 520 520 debugfs_remove(sample->de_dir); 521 521 522 522 qmi_handle_release(&sample->qmi); 523 - 524 - return 0; 525 523 } 526 524 527 525 static struct platform_driver qmi_sample_driver = { 528 526 .probe = qmi_sample_probe, 529 - .remove = qmi_sample_remove, 527 + .remove_new = qmi_sample_remove, 530 528 .driver = { 531 529 .name = "qmi_sample_client", 532 530 },