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

Input: spear-keyboard - switch to devm_clk_get_prepared()

Use devm_clk_get_prepared() in order to remove a clk_unprepare() in an
error handling path of the probe and from the .remove() function.

This done, the whole .remove() function can also be axed because
'input_dev' is a managed resource allocated with
devm_input_allocate_device() and we can fully rely on devm for cleaning up.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://lore.kernel.org/r/062986b0a5105cbc61330da0e55b22c00e2c1c4f.1722062145.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

authored by

Christophe JAILLET and committed by
Dmitry Torokhov
3fe81a56 740ff03d

+1 -15
+1 -15
drivers/input/keyboard/spear-keyboard.c
··· 222 222 if (IS_ERR(kbd->io_base)) 223 223 return PTR_ERR(kbd->io_base); 224 224 225 - kbd->clk = devm_clk_get(&pdev->dev, NULL); 225 + kbd->clk = devm_clk_get_prepared(&pdev->dev, NULL); 226 226 if (IS_ERR(kbd->clk)) 227 227 return PTR_ERR(kbd->clk); 228 228 ··· 255 255 return error; 256 256 } 257 257 258 - error = clk_prepare(kbd->clk); 259 - if (error) 260 - return error; 261 - 262 258 error = input_register_device(input_dev); 263 259 if (error) { 264 260 dev_err(&pdev->dev, "Unable to register keyboard device\n"); 265 - clk_unprepare(kbd->clk); 266 261 return error; 267 262 } 268 263 ··· 265 270 platform_set_drvdata(pdev, kbd); 266 271 267 272 return 0; 268 - } 269 - 270 - static void spear_kbd_remove(struct platform_device *pdev) 271 - { 272 - struct spear_kbd *kbd = platform_get_drvdata(pdev); 273 - 274 - input_unregister_device(kbd->input); 275 - clk_unprepare(kbd->clk); 276 273 } 277 274 278 275 static int spear_kbd_suspend(struct device *dev) ··· 360 373 361 374 static struct platform_driver spear_kbd_driver = { 362 375 .probe = spear_kbd_probe, 363 - .remove_new = spear_kbd_remove, 364 376 .driver = { 365 377 .name = "keyboard", 366 378 .pm = pm_sleep_ptr(&spear_kbd_pm_ops),