Skip to content

Commit e65efc6

Browse files
committed
Input: samsung-keypad - switch to using devm_clk_get_prepared()
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>
1 parent c6f908f commit e65efc6

1 file changed

Lines changed: 4 additions & 18 deletions

File tree

drivers/input/keyboard/samsung-keypad.c

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -361,18 +361,12 @@ static int samsung_keypad_probe(struct platform_device *pdev)
361361
if (!keypad->base)
362362
return -EBUSY;
363363

364-
keypad->clk = devm_clk_get(&pdev->dev, "keypad");
364+
keypad->clk = devm_clk_get_prepared(&pdev->dev, "keypad");
365365
if (IS_ERR(keypad->clk)) {
366366
dev_err(&pdev->dev, "failed to get keypad clk\n");
367367
return PTR_ERR(keypad->clk);
368368
}
369369

370-
error = clk_prepare(keypad->clk);
371-
if (error) {
372-
dev_err(&pdev->dev, "keypad clock prepare failed\n");
373-
return error;
374-
}
375-
376370
keypad->input_dev = input_dev;
377371
keypad->pdev = pdev;
378372
keypad->row_shift = row_shift;
@@ -399,7 +393,7 @@ static int samsung_keypad_probe(struct platform_device *pdev)
399393
keypad->keycodes, input_dev);
400394
if (error) {
401395
dev_err(&pdev->dev, "failed to build keymap\n");
402-
goto err_unprepare_clk;
396+
return error;
403397
}
404398

405399
input_set_capability(input_dev, EV_MSC, MSC_SCAN);
@@ -411,15 +405,15 @@ static int samsung_keypad_probe(struct platform_device *pdev)
411405
keypad->irq = platform_get_irq(pdev, 0);
412406
if (keypad->irq < 0) {
413407
error = keypad->irq;
414-
goto err_unprepare_clk;
408+
return error;
415409
}
416410

417411
error = devm_request_threaded_irq(&pdev->dev, keypad->irq, NULL,
418412
samsung_keypad_irq, IRQF_ONESHOT,
419413
dev_name(&pdev->dev), keypad);
420414
if (error) {
421415
dev_err(&pdev->dev, "failed to register keypad interrupt\n");
422-
goto err_unprepare_clk;
416+
return error;
423417
}
424418

425419
device_init_wakeup(&pdev->dev, pdata->wakeup);
@@ -439,20 +433,12 @@ static int samsung_keypad_probe(struct platform_device *pdev)
439433

440434
err_disable_runtime_pm:
441435
pm_runtime_disable(&pdev->dev);
442-
err_unprepare_clk:
443-
clk_unprepare(keypad->clk);
444436
return error;
445437
}
446438

447439
static void samsung_keypad_remove(struct platform_device *pdev)
448440
{
449-
struct samsung_keypad *keypad = platform_get_drvdata(pdev);
450-
451441
pm_runtime_disable(&pdev->dev);
452-
453-
input_unregister_device(keypad->input_dev);
454-
455-
clk_unprepare(keypad->clk);
456442
}
457443

458444
static int samsung_keypad_runtime_suspend(struct device *dev)

0 commit comments

Comments
 (0)