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

Input: tps65219-pwrbutton - convert to .remove_new()

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).

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().

Before this driver might have returned an error. In this case emit a
warning that tells more about the problem than the generic warning by
the core, and instead of making the remove callback return zero
unconditionally, convert to .remove_new() which is equivalent.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Reviewed-by: Markus Schneider-Pargmann <msp@baylibre.com>
Link: https://lore.kernel.org/r/20230605161458.117361-1-u.kleine-koenig@pengutronix.de
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

authored by

Uwe Kleine-König and committed by
Dmitry Torokhov
ab892b7f b0031562

+8 -5
+8 -5
drivers/input/misc/tps65219-pwrbutton.c
··· 117 117 return 0; 118 118 } 119 119 120 - static int tps65219_pb_remove(struct platform_device *pdev) 120 + static void tps65219_pb_remove(struct platform_device *pdev) 121 121 { 122 122 struct tps65219 *tps = dev_get_drvdata(pdev->dev.parent); 123 + int ret; 123 124 124 125 /* Disable interrupt for the pushbutton */ 125 - return regmap_update_bits(tps->regmap, TPS65219_REG_MASK_CONFIG, 126 - TPS65219_REG_MASK_INT_FOR_PB_MASK, 127 - TPS65219_REG_MASK_INT_FOR_PB_MASK); 126 + ret = regmap_update_bits(tps->regmap, TPS65219_REG_MASK_CONFIG, 127 + TPS65219_REG_MASK_INT_FOR_PB_MASK, 128 + TPS65219_REG_MASK_INT_FOR_PB_MASK); 129 + if (ret) 130 + dev_warn(&pdev->dev, "Failed to disable irq (%pe)\n", ERR_PTR(ret)); 128 131 } 129 132 130 133 static const struct platform_device_id tps65219_pwrbtn_id_table[] = { ··· 138 135 139 136 static struct platform_driver tps65219_pb_driver = { 140 137 .probe = tps65219_pb_probe, 141 - .remove = tps65219_pb_remove, 138 + .remove_new = tps65219_pb_remove, 142 139 .driver = { 143 140 .name = "tps65219_pwrbutton", 144 141 },