diff options
Diffstat (limited to 'arch/arm/mach-omap2/powerdomain.c')
-rw-r--r-- | arch/arm/mach-omap2/powerdomain.c | 39 |
1 files changed, 27 insertions, 12 deletions
diff --git a/arch/arm/mach-omap2/powerdomain.c b/arch/arm/mach-omap2/powerdomain.c index 2594cbff3947..f00289abd30f 100644 --- a/arch/arm/mach-omap2/powerdomain.c +++ b/arch/arm/mach-omap2/powerdomain.c | |||
@@ -273,35 +273,50 @@ struct powerdomain *pwrdm_lookup(const char *name) | |||
273 | } | 273 | } |
274 | 274 | ||
275 | /** | 275 | /** |
276 | * pwrdm_for_each - call function on each registered clockdomain | 276 | * pwrdm_for_each_nolock - call function on each registered clockdomain |
277 | * @fn: callback function * | 277 | * @fn: callback function * |
278 | * | 278 | * |
279 | * Call the supplied function for each registered powerdomain. The | 279 | * Call the supplied function for each registered powerdomain. The |
280 | * callback function can return anything but 0 to bail out early from | 280 | * callback function can return anything but 0 to bail out early from |
281 | * the iterator. The callback function is called with the pwrdm_rwlock | 281 | * the iterator. Returns the last return value of the callback function, which |
282 | * held for reading, so no powerdomain structure manipulation | 282 | * should be 0 for success or anything else to indicate failure; or -EINVAL if |
283 | * functions should be called from the callback, although hardware | 283 | * the function pointer is null. |
284 | * powerdomain control functions are fine. Returns the last return | ||
285 | * value of the callback function, which should be 0 for success or | ||
286 | * anything else to indicate failure; or -EINVAL if the function | ||
287 | * pointer is null. | ||
288 | */ | 284 | */ |
289 | int pwrdm_for_each(int (*fn)(struct powerdomain *pwrdm, void *user), | 285 | int pwrdm_for_each_nolock(int (*fn)(struct powerdomain *pwrdm, void *user), |
290 | void *user) | 286 | void *user) |
291 | { | 287 | { |
292 | struct powerdomain *temp_pwrdm; | 288 | struct powerdomain *temp_pwrdm; |
293 | unsigned long flags; | ||
294 | int ret = 0; | 289 | int ret = 0; |
295 | 290 | ||
296 | if (!fn) | 291 | if (!fn) |
297 | return -EINVAL; | 292 | return -EINVAL; |
298 | 293 | ||
299 | read_lock_irqsave(&pwrdm_rwlock, flags); | ||
300 | list_for_each_entry(temp_pwrdm, &pwrdm_list, node) { | 294 | list_for_each_entry(temp_pwrdm, &pwrdm_list, node) { |
301 | ret = (*fn)(temp_pwrdm, user); | 295 | ret = (*fn)(temp_pwrdm, user); |
302 | if (ret) | 296 | if (ret) |
303 | break; | 297 | break; |
304 | } | 298 | } |
299 | |||
300 | return ret; | ||
301 | } | ||
302 | |||
303 | /** | ||
304 | * pwrdm_for_each - call function on each registered clockdomain | ||
305 | * @fn: callback function * | ||
306 | * | ||
307 | * This function is the same as 'pwrdm_for_each_nolock()', but keeps the | ||
308 | * &pwrdm_rwlock locked for reading, so no powerdomain structure manipulation | ||
309 | * functions should be called from the callback, although hardware powerdomain | ||
310 | * control functions are fine. | ||
311 | */ | ||
312 | int pwrdm_for_each(int (*fn)(struct powerdomain *pwrdm, void *user), | ||
313 | void *user) | ||
314 | { | ||
315 | unsigned long flags; | ||
316 | int ret; | ||
317 | |||
318 | read_lock_irqsave(&pwrdm_rwlock, flags); | ||
319 | ret = pwrdm_for_each_nolock(fn, user); | ||
305 | read_unlock_irqrestore(&pwrdm_rwlock, flags); | 320 | read_unlock_irqrestore(&pwrdm_rwlock, flags); |
306 | 321 | ||
307 | return ret; | 322 | return ret; |