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