Skip to content

Commit 38be895

Browse files
Uwe Kleine-Königandersson
authored andcommitted
rpmsg: qcom_smd: Convert to platform remove callback returning void
The .remove() callback for a platform driver returns an int which makes many driver authors wrongly assume it's possible to do error handling by returning an error code. However the value returned is (mostly) ignored and this typically results in resource leaks. To improve here there is a quest to make the remove callback return void. In the first step of this quest all drivers are converted to .remove_new() which already returns void. qcom_smd_remove() always returned zero, though that isn't completely trivial to see. So explain that in a comment and convert to .remove_new(). Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Bjorn Andersson <andersson@kernel.org> Link: https://lore.kernel.org/r/20230321154039.355098-4-u.kleine-koenig@pengutronix.de
1 parent 49446e5 commit 38be895

1 file changed

Lines changed: 7 additions & 9 deletions

File tree

drivers/rpmsg/qcom_smd.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1579,15 +1579,13 @@ static int qcom_smd_remove_edge(struct device *dev, void *data)
15791579
* Shut down all smd clients by making sure that each edge stops processing
15801580
* events and scanning for new channels, then call destroy on the devices.
15811581
*/
1582-
static int qcom_smd_remove(struct platform_device *pdev)
1582+
static void qcom_smd_remove(struct platform_device *pdev)
15831583
{
1584-
int ret;
1585-
1586-
ret = device_for_each_child(&pdev->dev, NULL, qcom_smd_remove_edge);
1587-
if (ret)
1588-
dev_warn(&pdev->dev, "can't remove smd device: %d\n", ret);
1589-
1590-
return ret;
1584+
/*
1585+
* qcom_smd_remove_edge always returns zero, so there is no need to
1586+
* check the return value of device_for_each_child.
1587+
*/
1588+
device_for_each_child(&pdev->dev, NULL, qcom_smd_remove_edge);
15911589
}
15921590

15931591
static const struct of_device_id qcom_smd_of_match[] = {
@@ -1598,7 +1596,7 @@ MODULE_DEVICE_TABLE(of, qcom_smd_of_match);
15981596

15991597
static struct platform_driver qcom_smd_driver = {
16001598
.probe = qcom_smd_probe,
1601-
.remove = qcom_smd_remove,
1599+
.remove_new = qcom_smd_remove,
16021600
.driver = {
16031601
.name = "qcom-smd",
16041602
.of_match_table = qcom_smd_of_match,

0 commit comments

Comments
 (0)