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

can: m_can: 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() is
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>
Link: https://lore.kernel.org/r/20230512212725.143824-12-u.kleine-koenig@pengutronix.de
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>

authored by

Uwe Kleine-König and committed by
Marc Kleine-Budde
2d7c33d0 3ac96f45

+2 -4
+2 -4
drivers/net/can/m_can/m_can_platform.c
··· 164 164 return m_can_class_resume(dev); 165 165 } 166 166 167 - static int m_can_plat_remove(struct platform_device *pdev) 167 + static void m_can_plat_remove(struct platform_device *pdev) 168 168 { 169 169 struct m_can_plat_priv *priv = platform_get_drvdata(pdev); 170 170 struct m_can_classdev *mcan_class = &priv->cdev; ··· 172 172 m_can_class_unregister(mcan_class); 173 173 174 174 m_can_class_free_dev(mcan_class->net); 175 - 176 - return 0; 177 175 } 178 176 179 177 static int __maybe_unused m_can_runtime_suspend(struct device *dev) ··· 221 223 .pm = &m_can_pmops, 222 224 }, 223 225 .probe = m_can_plat_probe, 224 - .remove = m_can_plat_remove, 226 + .remove_new = m_can_plat_remove, 225 227 }; 226 228 227 229 module_platform_driver(m_can_plat_driver);