@@ -106,6 +106,7 @@ static int update_resource_level(struct shared_resource *resp)
unsigned long target_level;
int ret;
+ mutex_lock(&resp->resource_mutex);
/* Regenerate the target_value for the resource */
if (resp->flags & RES_TYPE_PERFORMANCE) {
target_level = RES_PERFORMANCE_DEFAULTLEVEL;
@@ -118,9 +119,11 @@ static int update_resource_level(struct shared_resource *resp)
if (user->level < target_level)
target_level = user->level;
} else {
+ mutex_unlock(&resp->resource_mutex);
pr_debug("SRF: Unknown resource type\n");
return -EINVAL;
}
+ mutex_unlock(&resp->resource_mutex);
pr_debug("SRF: Changing Level for resource %s to %ld\n",
resp->name, target_level);
@@ -439,10 +442,12 @@ int resource_release(const char *name, struct device *dev)
list_del(&user->node);
free_user(user);
- /* Recompute and set the current level for the resource */
- ret = update_resource_level(resp);
res_unlock:
mutex_unlock(&resp->resource_mutex);
+ /* Recompute and set the current level for the resource */
+ if (!ret)
+ ret = update_resource_level(resp);
+
return ret;
}
EXPORT_SYMBOL(resource_release);