diff mbox series

[2/2] Input: spear-keyboard - Switch to devm_clk_get_prepared()

Message ID ea855328eb4396cd1c44d2b6acc1fc394fcb1508.1721939824.git.christophe.jaillet@wanadoo.fr (mailing list archive)
State New
Headers show
Series Input: spear-keyboard - Fix an issue and clean-up code | expand

Commit Message

Christophe JAILLET July 25, 2024, 8:46 p.m. UTC
Use devm_clk_get_prepared() in order to remove a clk_unprepare() in an
error handling path of the probe and completely remove the .remove()
function.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
Compile tested only.
---
 drivers/input/keyboard/spear-keyboard.c | 15 +--------------
 1 file changed, 1 insertion(+), 14 deletions(-)

Comments

Dmitry Torokhov July 25, 2024, 8:55 p.m. UTC | #1
On Thu, Jul 25, 2024 at 10:46:50PM +0200, Christophe JAILLET wrote:
> Use devm_clk_get_prepared() in order to remove a clk_unprepare() in an
> error handling path of the probe and completely remove the .remove()
> function.
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

Please refresh after dropping the 1st patch and resend. You may remove
the call to input_unregister_device() in the context of this change as
without explicit call to clk_unprepare() on removal we can fully rely on
devm for cleaning up.

Thanks.
diff mbox series

Patch

diff --git a/drivers/input/keyboard/spear-keyboard.c b/drivers/input/keyboard/spear-keyboard.c
index 5d9fc8dc9433..1df4feb8ba01 100644
--- a/drivers/input/keyboard/spear-keyboard.c
+++ b/drivers/input/keyboard/spear-keyboard.c
@@ -222,7 +222,7 @@  static int spear_kbd_probe(struct platform_device *pdev)
 	if (IS_ERR(kbd->io_base))
 		return PTR_ERR(kbd->io_base);
 
-	kbd->clk = devm_clk_get(&pdev->dev, NULL);
+	kbd->clk = devm_clk_get_prepared(&pdev->dev, NULL);
 	if (IS_ERR(kbd->clk))
 		return PTR_ERR(kbd->clk);
 
@@ -255,14 +255,9 @@  static int spear_kbd_probe(struct platform_device *pdev)
 		return error;
 	}
 
-	error = clk_prepare(kbd->clk);
-	if (error)
-		return error;
-
 	error = input_register_device(input_dev);
 	if (error) {
 		dev_err(&pdev->dev, "Unable to register keyboard device\n");
-		clk_unprepare(kbd->clk);
 		return error;
 	}
 
@@ -272,13 +267,6 @@  static int spear_kbd_probe(struct platform_device *pdev)
 	return 0;
 }
 
-static void spear_kbd_remove(struct platform_device *pdev)
-{
-	struct spear_kbd *kbd = platform_get_drvdata(pdev);
-
-	clk_unprepare(kbd->clk);
-}
-
 static int spear_kbd_suspend(struct device *dev)
 {
 	struct platform_device *pdev = to_platform_device(dev);
@@ -372,7 +360,6 @@  MODULE_DEVICE_TABLE(of, spear_kbd_id_table);
 
 static struct platform_driver spear_kbd_driver = {
 	.probe		= spear_kbd_probe,
-	.remove_new	= spear_kbd_remove,
 	.driver		= {
 		.name	= "keyboard",
 		.pm	= pm_sleep_ptr(&spear_kbd_pm_ops),