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

misc: sram: 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 ignored (apart
from emitting a warning) 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. Eventually after all drivers
are converted, .remove_new() will be renamed to .remove().

Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/r/946ebc33a01bf700171257cd219fbe8626bc0c99.1708508896.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Uwe Kleine-König and committed by
Greg Kroah-Hartman
74b32514 3aa42cb8

+2 -4
+2 -4
drivers/misc/sram.c
··· 435 435 return ret; 436 436 } 437 437 438 - static int sram_remove(struct platform_device *pdev) 438 + static void sram_remove(struct platform_device *pdev) 439 439 { 440 440 struct sram_dev *sram = platform_get_drvdata(pdev); 441 441 ··· 443 443 444 444 if (sram->pool && gen_pool_avail(sram->pool) < gen_pool_size(sram->pool)) 445 445 dev_err(sram->dev, "removed while SRAM allocated\n"); 446 - 447 - return 0; 448 446 } 449 447 450 448 static struct platform_driver sram_driver = { ··· 451 453 .of_match_table = sram_dt_ids, 452 454 }, 453 455 .probe = sram_probe, 454 - .remove = sram_remove, 456 + .remove_new = sram_remove, 455 457 }; 456 458 457 459 static int __init sram_init(void)