History

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.

Dmitry Torokhov committed 2 years ago

Commit e65efc61 parent c6f908f1 file · +4 −18Browse files

Unified · Split

drivers/input/keyboard/samsung-keypad.c+4−18
@@ -361,18 +361,12 @@ static int samsung_keypad_probe(struct platform_device *pdev) · 360 unmodified lines
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) · 20 unmodified lines
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,7 +405,7 @@ static int samsung_keypad_probe(struct platform_device *pdev) · 5 unmodified lines
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,
@@ -419,7 +413,7 @@ static int samsung_keypad_probe(struct platform_device *pdev) · 1 unmodified line
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) · 13 unmodified lines
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)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t