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

Configure Feed

Select the types of activity you want to include in your feed.

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>

+4 -18
+4 -18
drivers/input/keyboard/samsung-keypad.c
··· 361 361 if (!keypad->base) 362 362 return -EBUSY; 363 363 364 - keypad->clk = devm_clk_get(&pdev->dev, "keypad"); 364 + keypad->clk = devm_clk_get_prepared(&pdev->dev, "keypad"); 365 365 if (IS_ERR(keypad->clk)) { 366 366 dev_err(&pdev->dev, "failed to get keypad clk\n"); 367 367 return PTR_ERR(keypad->clk); 368 - } 369 - 370 - error = clk_prepare(keypad->clk); 371 - if (error) { 372 - dev_err(&pdev->dev, "keypad clock prepare failed\n"); 373 - return error; 374 368 } 375 369 376 370 keypad->input_dev = input_dev; ··· 393 399 keypad->keycodes, input_dev); 394 400 if (error) { 395 401 dev_err(&pdev->dev, "failed to build keymap\n"); 396 - goto err_unprepare_clk; 402 + return error; 397 403 } 398 404 399 405 input_set_capability(input_dev, EV_MSC, MSC_SCAN); ··· 405 411 keypad->irq = platform_get_irq(pdev, 0); 406 412 if (keypad->irq < 0) { 407 413 error = keypad->irq; 408 - goto err_unprepare_clk; 414 + return error; 409 415 } 410 416 411 417 error = devm_request_threaded_irq(&pdev->dev, keypad->irq, NULL, ··· 413 419 dev_name(&pdev->dev), keypad); 414 420 if (error) { 415 421 dev_err(&pdev->dev, "failed to register keypad interrupt\n"); 416 - goto err_unprepare_clk; 422 + return error; 417 423 } 418 424 419 425 device_init_wakeup(&pdev->dev, pdata->wakeup); ··· 433 439 434 440 err_disable_runtime_pm: 435 441 pm_runtime_disable(&pdev->dev); 436 - err_unprepare_clk: 437 - clk_unprepare(keypad->clk); 438 442 return error; 439 443 } 440 444 441 445 static void samsung_keypad_remove(struct platform_device *pdev) 442 446 { 443 - struct samsung_keypad *keypad = platform_get_drvdata(pdev); 444 - 445 447 pm_runtime_disable(&pdev->dev); 446 - 447 - input_unregister_device(keypad->input_dev); 448 - 449 - clk_unprepare(keypad->clk); 450 448 } 451 449 452 450 static int samsung_keypad_runtime_suspend(struct device *dev)