Commit b70f2c6cce3d14c9a2550f58ad2527152fbb13c6
1 parent
d456979731
Exists in
v3.2_SMARCT335xPSP_04.06.00.11
and in
2 other branches
Add 0010-hwrng-omap4-rng-Convert-to-use-pm_runtime-API.patch that wasn't part of…
… official PSP 04.06.00.11 release
Showing 1 changed file with 11 additions and 13 deletions Side-by-side Diff
drivers/char/hw_random/omap4-rng.c
... | ... | @@ -23,7 +23,7 @@ |
23 | 23 | #include <linux/module.h> |
24 | 24 | #include <linux/init.h> |
25 | 25 | #include <linux/random.h> |
26 | -#include <linux/clk.h> | |
26 | +#include <linux/pm_runtime.h> | |
27 | 27 | #include <linux/err.h> |
28 | 28 | #include <linux/platform_device.h> |
29 | 29 | #include <linux/hw_random.h> |
... | ... | @@ -111,7 +111,6 @@ |
111 | 111 | |
112 | 112 | |
113 | 113 | static void __iomem *rng_base; |
114 | -static struct clk *rng_fck; | |
115 | 114 | static struct platform_device *rng_dev; |
116 | 115 | |
117 | 116 | #define trng_read(reg) \ |
... | ... | @@ -172,13 +171,8 @@ |
172 | 171 | if (rng_dev) |
173 | 172 | return -EBUSY; |
174 | 173 | |
175 | - rng_fck = clk_get(&pdev->dev, "rng_fck"); | |
176 | - if (IS_ERR(rng_fck)) { | |
177 | - dev_err(&pdev->dev, "Could not get rng_fck\n"); | |
178 | - ret = PTR_ERR(rng_fck); | |
179 | - return ret; | |
180 | - } else | |
181 | - clk_enable(rng_fck); | |
174 | + pm_runtime_enable(&pdev->dev); | |
175 | + pm_runtime_get_sync(&pdev->dev); | |
182 | 176 | |
183 | 177 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
184 | 178 | if (!res) { |
... | ... | @@ -223,8 +217,8 @@ |
223 | 217 | err_ioremap: |
224 | 218 | release_mem_region(res->start, resource_size(res)); |
225 | 219 | err_region: |
226 | - clk_disable(rng_fck); | |
227 | - clk_put(rng_fck); | |
220 | + pm_runtime_put_sync(&pdev->dev); | |
221 | + pm_runtime_disable(&pdev->dev); | |
228 | 222 | return ret; |
229 | 223 | } |
230 | 224 | |
... | ... | @@ -238,8 +232,8 @@ |
238 | 232 | |
239 | 233 | iounmap(rng_base); |
240 | 234 | |
241 | - clk_disable(rng_fck); | |
242 | - clk_put(rng_fck); | |
235 | + pm_runtime_put_sync(&pdev->dev); | |
236 | + pm_runtime_disable(&pdev->dev); | |
243 | 237 | release_mem_region(res->start, resource_size(res)); |
244 | 238 | rng_base = NULL; |
245 | 239 | |
246 | 240 | |
... | ... | @@ -252,11 +246,15 @@ |
252 | 246 | { |
253 | 247 | trng_write(trng_read(CONTROL) & ~RNG_REG_CONTROL_ENABLE_TRNG, CONTROL); |
254 | 248 | |
249 | + pm_runtime_put_sync(&pdev->dev); | |
250 | + | |
255 | 251 | return 0; |
256 | 252 | } |
257 | 253 | |
258 | 254 | static int omap4_rng_resume(struct platform_device *pdev) |
259 | 255 | { |
256 | + pm_runtime_get_sync(&pdev->dev); | |
257 | + | |
260 | 258 | trng_write(trng_read(CONTROL) | RNG_REG_CONTROL_ENABLE_TRNG, CONTROL); |
261 | 259 | |
262 | 260 | return 0; |