From patchwork Tue May 4 00:34:30 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Chan X-Patchwork-Id: 96642 X-Patchwork-Delegate: khilman@deeprootsystems.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o440YcP7018570 for ; Tue, 4 May 2010 00:34:39 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754411Ab0EDAeh (ORCPT ); Mon, 3 May 2010 20:34:37 -0400 Received: from smtp-out.google.com ([216.239.44.51]:40755 "EHLO smtp-out.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752875Ab0EDAeg (ORCPT ); Mon, 3 May 2010 20:34:36 -0400 Received: from kpbe15.cbf.corp.google.com (kpbe15.cbf.corp.google.com [172.25.105.79]) by smtp-out.google.com with ESMTP id o440YYwN002666; Mon, 3 May 2010 17:34:34 -0700 Received: from mikechan.mtv.corp.google.com (mikechan.mtv.corp.google.com [172.18.102.252]) by kpbe15.cbf.corp.google.com with ESMTP id o440YWkw031973; Mon, 3 May 2010 17:34:32 -0700 Received: by mikechan.mtv.corp.google.com (Postfix, from userid 18922) id 8253222020; Mon, 3 May 2010 17:34:32 -0700 (PDT) From: Mike Chan Cc: khilman@deeprootsystems.com, linux-omap@vger.kernel.org, Mike Chan Subject: [PATCH 1/2] [ARM] omap-pm: resource: Lock resource list in update_resource_level Date: Mon, 3 May 2010 17:34:30 -0700 Message-Id: <1272933271-12937-1-git-send-email-mike@android.com> X-Mailer: git-send-email 1.7.0.1 X-System-Of-Record: true To: unlisted-recipients:; (no To-header on input) Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Tue, 04 May 2010 00:34:39 +0000 (UTC) diff --git a/arch/arm/plat-omap/resource.c b/arch/arm/plat-omap/resource.c index f769f7c..6d3bba6 100644 --- a/arch/arm/plat-omap/resource.c +++ b/arch/arm/plat-omap/resource.c @@ -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);