diff options
author | Marek Szyprowski <m.szyprowski@samsung.com> | 2016-06-30 10:29:46 +0200 |
---|---|---|
committer | Seung-Woo Kim <sw0312.kim@samsung.com> | 2016-08-04 13:31:37 +0900 |
commit | 8e703435cec63e3c5faa6e78d279fd1144f815ab (patch) | |
tree | 7264a41b09aec3a6c1d6f45332caded7a3e260c2 | |
parent | ac8742636dc4925feba49aa74863454e7e99532d (diff) | |
download | linux-exynos-8e703435cec63e3c5faa6e78d279fd1144f815ab.tar.gz linux-exynos-8e703435cec63e3c5faa6e78d279fd1144f815ab.tar.bz2 linux-exynos-8e703435cec63e3c5faa6e78d279fd1144f815ab.zip |
media: s5p-mfc: don't keep clocks prepared all the time
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Change-Id: I2b3a109eb9ac28e282083adf444baaef75431376
-rw-r--r-- | drivers/media/platform/s5p-mfc/s5p_mfc_pm.c | 50 |
1 files changed, 28 insertions, 22 deletions
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_pm.c b/drivers/media/platform/s5p-mfc/s5p_mfc_pm.c index 837889c26e8e..d21055e19a71 100644 --- a/drivers/media/platform/s5p-mfc/s5p_mfc_pm.c +++ b/drivers/media/platform/s5p-mfc/s5p_mfc_pm.c @@ -29,7 +29,7 @@ static atomic_t clk_ref; int s5p_mfc_init_pm(struct s5p_mfc_dev *dev) { - int i, ret = 0; + int i; struct device *kdev = &dev->plat_dev->dev; pm = &dev->pm; @@ -44,16 +44,7 @@ int s5p_mfc_init_pm(struct s5p_mfc_dev *dev) if (IS_ERR(pm->clocks[i])) { mfc_err("Failed to get clock: %s\n", pm->clk_names[i]); - ret = PTR_ERR(pm->clocks[i]); - goto err; - } - - ret = clk_prepare(pm->clocks[i]); - if (ret < 0) { - mfc_err("clock prepare failed for clock: %s\n", - pm->clk_names[i]); - i++; - goto err; + return PTR_ERR(pm->clocks[i]); } } @@ -66,19 +57,10 @@ int s5p_mfc_init_pm(struct s5p_mfc_dev *dev) atomic_set(&clk_ref, 0); #endif return 0; -err: - while (--i > 0) - clk_unprepare(pm->clocks[i]); - - return ret; } void s5p_mfc_final_pm(struct s5p_mfc_dev *dev) { - int i; - for (i = 0; i < pm->num_clocks; i++) - clk_unprepare(pm->clocks[i]); - #ifdef CONFIG_PM pm_runtime_disable(pm->device); #endif @@ -116,16 +98,40 @@ void s5p_mfc_clock_off(void) int s5p_mfc_power_on(void) { + int i, ret = 0; + #ifdef CONFIG_PM - return pm_runtime_get_sync(pm->device); + ret = pm_runtime_get_sync(pm->device); + if (ret < 0) + return ret; #else atomic_set(&pm->power, 1); - return 0; #endif + /* clock control */ + for (i = 0; i < pm->num_clocks; i++) { + ret = clk_prepare(pm->clocks[i]); + if (ret < 0) { + mfc_err("clock prepare failed for clock: %s\n", + pm->clk_names[i]); + i++; + goto err; + } + } + + return 0; +err: + while (--i > 0) + clk_unprepare(pm->clocks[i]); + pm_runtime_put(pm->device); + return ret; } int s5p_mfc_power_off(void) { + int i; + for (i = 0; i < pm->num_clocks; i++) + clk_unprepare(pm->clocks[i]); + #ifdef CONFIG_PM return pm_runtime_put_sync(pm->device); #else |