gpu: nvgpu: Enable clocks only if defined

Enable clocks only if they are defined. This prevents panic in cases
where clock does not need to be enabled explicitly.

Bug 1567274

Change-Id: I7113c6d874b61acc2646effda9c02d3d1817c531
Signed-off-by: Terje Bergstrom <tbergstrom@nvidia.com>
This commit is contained in:
Terje Bergstrom
2014-10-24 14:49:06 +03:00
committed by Dan Willemsen
parent be48f4a451
commit b5bb4f53db
2 changed files with 11 additions and 3 deletions

View File

@@ -1146,7 +1146,9 @@ static int gk20a_pm_enable_clk(struct device *dev)
return -EINVAL; return -EINVAL;
for (index = 0; index < platform->num_clks; index++) { for (index = 0; index < platform->num_clks; index++) {
int err = clk_prepare_enable(platform->clk[index]); int err = 0;
if (platform->clk[index])
clk_prepare_enable(platform->clk[index]);
if (err) if (err)
return -EINVAL; return -EINVAL;
} }
@@ -1163,8 +1165,10 @@ static int gk20a_pm_disable_clk(struct device *dev)
if (!platform) if (!platform)
return -EINVAL; return -EINVAL;
for (index = 0; index < platform->num_clks; index++) for (index = 0; index < platform->num_clks; index++) {
if (platform->clk[index])
clk_disable_unprepare(platform->clk[index]); clk_disable_unprepare(platform->clk[index]);
}
return 0; return 0;
} }

View File

@@ -96,6 +96,10 @@ err_get_clock:
clk_put(platform->clk[1]); clk_put(platform->clk[1]);
if (!IS_ERR_OR_NULL(platform->clk[2])) if (!IS_ERR_OR_NULL(platform->clk[2]))
clk_put(platform->clk[2]); clk_put(platform->clk[2]);
platform->clk[0] = NULL;
platform->clk[1] = NULL;
platform->clk[2] = NULL;
return -ENODEV; return -ENODEV;
} }