]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
Input: samsung-keypad - switch to using devm_clk_get_prepared()
authorDmitry Torokhov <dmitry.torokhov@gmail.com>
Mon, 19 Aug 2024 04:57:58 +0000 (21:57 -0700)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Tue, 1 Jul 2025 21:15:33 +0000 (14:15 -0700)
Switch to using devm_clk_get_prepared() instead of combining
devm_clk_get() with clk_prepare(), which simplifies the code and
ensures that the clock is unprepared at the right time relative to
releasing other managed resources.

Link: https://lore.kernel.org/r/20240819045813.2154642-2-dmitry.torokhov@gmail.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
drivers/input/keyboard/samsung-keypad.c

index 9f1049aa3048c865f1e60b1a7b1419e587bfbcf4..edd085f86df0dc2d86d08dc2ea9ea9fc899b9be9 100644 (file)
@@ -361,18 +361,12 @@ static int samsung_keypad_probe(struct platform_device *pdev)
        if (!keypad->base)
                return -EBUSY;
 
-       keypad->clk = devm_clk_get(&pdev->dev, "keypad");
+       keypad->clk = devm_clk_get_prepared(&pdev->dev, "keypad");
        if (IS_ERR(keypad->clk)) {
                dev_err(&pdev->dev, "failed to get keypad clk\n");
                return PTR_ERR(keypad->clk);
        }
 
-       error = clk_prepare(keypad->clk);
-       if (error) {
-               dev_err(&pdev->dev, "keypad clock prepare failed\n");
-               return error;
-       }
-
        keypad->input_dev = input_dev;
        keypad->pdev = pdev;
        keypad->row_shift = row_shift;
@@ -399,7 +393,7 @@ static int samsung_keypad_probe(struct platform_device *pdev)
                                           keypad->keycodes, input_dev);
        if (error) {
                dev_err(&pdev->dev, "failed to build keymap\n");
-               goto err_unprepare_clk;
+               return error;
        }
 
        input_set_capability(input_dev, EV_MSC, MSC_SCAN);
@@ -411,7 +405,7 @@ static int samsung_keypad_probe(struct platform_device *pdev)
        keypad->irq = platform_get_irq(pdev, 0);
        if (keypad->irq < 0) {
                error = keypad->irq;
-               goto err_unprepare_clk;
+               return error;
        }
 
        error = devm_request_threaded_irq(&pdev->dev, keypad->irq, NULL,
@@ -419,7 +413,7 @@ static int samsung_keypad_probe(struct platform_device *pdev)
                                          dev_name(&pdev->dev), keypad);
        if (error) {
                dev_err(&pdev->dev, "failed to register keypad interrupt\n");
-               goto err_unprepare_clk;
+               return error;
        }
 
        device_init_wakeup(&pdev->dev, pdata->wakeup);
@@ -439,20 +433,12 @@ static int samsung_keypad_probe(struct platform_device *pdev)
 
 err_disable_runtime_pm:
        pm_runtime_disable(&pdev->dev);
-err_unprepare_clk:
-       clk_unprepare(keypad->clk);
        return error;
 }
 
 static void samsung_keypad_remove(struct platform_device *pdev)
 {
-       struct samsung_keypad *keypad = platform_get_drvdata(pdev);
-
        pm_runtime_disable(&pdev->dev);
-
-       input_unregister_device(keypad->input_dev);
-
-       clk_unprepare(keypad->clk);
 }
 
 static int samsung_keypad_runtime_suspend(struct device *dev)