diff options
author | Wei Ni <wni@nvidia.com> | 2016-03-29 06:29:20 -0400 |
---|---|---|
committer | Eduardo Valentin <edubezval@gmail.com> | 2016-05-17 10:28:29 -0400 |
commit | 8de2ab023598bcb874e2182ab6ea7355bbf33af6 (patch) | |
tree | 950ea59022246572006ff47f4e8f71c3caadb8a3 | |
parent | 2a895871f27fdc82ac7b365d3f94e2c7b3467898 (diff) |
thermal: tegra: handle clocks in one function
Handle clock enable/disable codes in one function
soctherm_clk_enable(), so that the codes are more clear.
Signed-off-by: Wei Ni <wni@nvidia.com>
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
-rw-r--r-- | drivers/thermal/tegra/soctherm.c | 51 |
1 files changed, 36 insertions, 15 deletions
diff --git a/drivers/thermal/tegra/soctherm.c b/drivers/thermal/tegra/soctherm.c index 365b45213327..deeb3b7e4dac 100644 --- a/drivers/thermal/tegra/soctherm.c +++ b/drivers/thermal/tegra/soctherm.c | |||
@@ -428,6 +428,39 @@ static void soctherm_debug_init(struct platform_device *pdev) | |||
428 | static inline void soctherm_debug_init(struct platform_device *pdev) {} | 428 | static inline void soctherm_debug_init(struct platform_device *pdev) {} |
429 | #endif | 429 | #endif |
430 | 430 | ||
431 | static int soctherm_clk_enable(struct platform_device *pdev, bool enable) | ||
432 | { | ||
433 | struct tegra_soctherm *tegra = platform_get_drvdata(pdev); | ||
434 | int err; | ||
435 | |||
436 | if (!tegra->clock_soctherm || !tegra->clock_tsensor) | ||
437 | return -EINVAL; | ||
438 | |||
439 | reset_control_assert(tegra->reset); | ||
440 | |||
441 | if (enable) { | ||
442 | err = clk_prepare_enable(tegra->clock_soctherm); | ||
443 | if (err) { | ||
444 | reset_control_deassert(tegra->reset); | ||
445 | return err; | ||
446 | } | ||
447 | |||
448 | err = clk_prepare_enable(tegra->clock_tsensor); | ||
449 | if (err) { | ||
450 | clk_disable_unprepare(tegra->clock_soctherm); | ||
451 | reset_control_deassert(tegra->reset); | ||
452 | return err; | ||
453 | } | ||
454 | } else { | ||
455 | clk_disable_unprepare(tegra->clock_tsensor); | ||
456 | clk_disable_unprepare(tegra->clock_soctherm); | ||
457 | } | ||
458 | |||
459 | reset_control_deassert(tegra->reset); | ||
460 | |||
461 | return 0; | ||
462 | } | ||
463 | |||
431 | static const struct of_device_id tegra_soctherm_of_match[] = { | 464 | static const struct of_device_id tegra_soctherm_of_match[] = { |
432 | #ifdef CONFIG_ARCH_TEGRA_124_SOC | 465 | #ifdef CONFIG_ARCH_TEGRA_124_SOC |
433 | { | 466 | { |
@@ -496,20 +529,10 @@ static int tegra_soctherm_probe(struct platform_device *pdev) | |||
496 | return PTR_ERR(tegra->clock_soctherm); | 529 | return PTR_ERR(tegra->clock_soctherm); |
497 | } | 530 | } |
498 | 531 | ||
499 | reset_control_assert(tegra->reset); | 532 | err = soctherm_clk_enable(pdev, true); |
500 | |||
501 | err = clk_prepare_enable(tegra->clock_soctherm); | ||
502 | if (err) | 533 | if (err) |
503 | return err; | 534 | return err; |
504 | 535 | ||
505 | err = clk_prepare_enable(tegra->clock_tsensor); | ||
506 | if (err) { | ||
507 | clk_disable_unprepare(tegra->clock_soctherm); | ||
508 | return err; | ||
509 | } | ||
510 | |||
511 | reset_control_deassert(tegra->reset); | ||
512 | |||
513 | /* Initialize raw sensors */ | 536 | /* Initialize raw sensors */ |
514 | 537 | ||
515 | tegra->calib = devm_kzalloc(&pdev->dev, | 538 | tegra->calib = devm_kzalloc(&pdev->dev, |
@@ -579,8 +602,7 @@ static int tegra_soctherm_probe(struct platform_device *pdev) | |||
579 | return 0; | 602 | return 0; |
580 | 603 | ||
581 | disable_clocks: | 604 | disable_clocks: |
582 | clk_disable_unprepare(tegra->clock_tsensor); | 605 | soctherm_clk_enable(pdev, false); |
583 | clk_disable_unprepare(tegra->clock_soctherm); | ||
584 | 606 | ||
585 | return err; | 607 | return err; |
586 | } | 608 | } |
@@ -591,8 +613,7 @@ static int tegra_soctherm_remove(struct platform_device *pdev) | |||
591 | 613 | ||
592 | debugfs_remove_recursive(tegra->debugfs_dir); | 614 | debugfs_remove_recursive(tegra->debugfs_dir); |
593 | 615 | ||
594 | clk_disable_unprepare(tegra->clock_tsensor); | 616 | soctherm_clk_enable(pdev, false); |
595 | clk_disable_unprepare(tegra->clock_soctherm); | ||
596 | 617 | ||
597 | return 0; | 618 | return 0; |
598 | } | 619 | } |