From patchwork Sun Sep 22 01:21:04 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 20514 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qe0-f71.google.com (mail-qe0-f71.google.com [209.85.128.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 12AAA25E85 for ; Sun, 22 Sep 2013 01:22:42 +0000 (UTC) Received: by mail-qe0-f71.google.com with SMTP id a11sf1934163qen.10 for ; Sat, 21 Sep 2013 18:22:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:in-reply-to:references :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=pjVhkXqaJIxFkhNE4TU5QNitUICyUS/vWS7sayhxafk=; b=F6oOKb+T+EUopRSTlsUKJrJ+tDAjPx1WnZsUQHnEfogKvQ5mRgmDBTvecwWNvO11eB sqz9RNRmLS6X6rmseuVyjl/hCYjUStFtGvrbcVeJkdeBEuDiVNTHHyfK6Rpk4o8g/Qjd F2C2YM4N6p/XSlauJeEt52XKIhEwCAFafK3aTIq4gDTJpIoWBmaJ8VCPjv/mtr1JuOpo cWkiTHTRIUcyt5Fj3BUU/yJEakKFNReWpJwxJ5f7gRs5ObilMXTEdlrCFMy+b+iVquFk Je1xMYse0S01Xzxz6LsgwNcaoIFkIyYc378IUXVJutL++c/Ec6RVYCL/sAdU6LZVBFRX OP5g== X-Gm-Message-State: ALoCoQk6B9s4znPAhFlBtnl/vfN237GYGcXN5Cgxyqpm4EJXdulV+j8d5jdpLLTDJVbqwbJ49Q2v X-Received: by 10.224.112.133 with SMTP id w5mr6587577qap.5.1379812961934; Sat, 21 Sep 2013 18:22:41 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.49.196 with SMTP id w4ls712488qen.71.gmail; Sat, 21 Sep 2013 18:22:41 -0700 (PDT) X-Received: by 10.220.199.5 with SMTP id eq5mr14170314vcb.16.1379812961843; Sat, 21 Sep 2013 18:22:41 -0700 (PDT) Received: from mail-ve0-f181.google.com (mail-ve0-f181.google.com [209.85.128.181]) by mx.google.com with ESMTPS id is10si4536336veb.108.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 21 Sep 2013 18:22:41 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.181 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.181; Received: by mail-ve0-f181.google.com with SMTP id oy12so1474628veb.12 for ; Sat, 21 Sep 2013 18:22:41 -0700 (PDT) X-Received: by 10.220.237.208 with SMTP id kp16mr14146543vcb.4.1379812961762; Sat, 21 Sep 2013 18:22:41 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp91741vcz; Sat, 21 Sep 2013 18:22:41 -0700 (PDT) X-Received: by 10.68.179.98 with SMTP id df2mr16025248pbc.38.1379812960922; Sat, 21 Sep 2013 18:22:40 -0700 (PDT) Received: from mail-pd0-f179.google.com (mail-pd0-f179.google.com [209.85.192.179]) by mx.google.com with ESMTPS id gl2si15822789pbc.198.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 21 Sep 2013 18:22:40 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.192.179 is neither permitted nor denied by best guess record for domain of viresh.kumar@linaro.org) client-ip=209.85.192.179; Received: by mail-pd0-f179.google.com with SMTP id v10so1823147pde.38 for ; Sat, 21 Sep 2013 18:22:40 -0700 (PDT) X-Received: by 10.66.145.132 with SMTP id su4mr17050146pab.11.1379812960497; Sat, 21 Sep 2013 18:22:40 -0700 (PDT) Received: from localhost ([122.167.152.64]) by mx.google.com with ESMTPSA id py4sm24628876pbb.33.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sat, 21 Sep 2013 18:22:39 -0700 (PDT) From: Viresh Kumar To: rjw@sisk.pl, daniel.lezcano@linaro.org Cc: linaro-kernel@lists.linaro.org, patches@linaro.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Viresh Kumar Subject: [PATCH 12/21] cpuidle: call cpuidle_get_driver() from after taking cpuidle_driver_lock Date: Sun, 22 Sep 2013 06:51:04 +0530 Message-Id: <193825f6c2fb70462f6da2cc60e7c6c02682d6c5.1379779777.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 1.7.12.rc2.18.g61b472e In-Reply-To: References: In-Reply-To: References: X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: viresh.kumar@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.181 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , cpuidle_driver_lock is taken correctly at most of the places but at few places calls to cpuidle_get_driver() are done from outside of this lock. Fix them by calling cpuidle_get_driver() after taking cpuidle_driver_lock. Signed-off-by: Viresh Kumar Acked-by: Daniel Lezcano --- drivers/cpuidle/driver.c | 3 ++- drivers/cpuidle/sysfs.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/cpuidle/driver.c b/drivers/cpuidle/driver.c index 6279e1c..7b2510a 100644 --- a/drivers/cpuidle/driver.c +++ b/drivers/cpuidle/driver.c @@ -340,10 +340,11 @@ struct cpuidle_driver *cpuidle_driver_ref(void) */ void cpuidle_driver_unref(void) { - struct cpuidle_driver *drv = cpuidle_get_driver(); + struct cpuidle_driver *drv; spin_lock(&cpuidle_driver_lock); + drv = cpuidle_get_driver(); if (drv && !WARN_ON(drv->refcnt <= 0)) drv->refcnt--; diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c index 8739cc0..a022393 100644 --- a/drivers/cpuidle/sysfs.c +++ b/drivers/cpuidle/sysfs.c @@ -52,9 +52,10 @@ static ssize_t show_current_driver(struct device *dev, char *buf) { ssize_t ret; - struct cpuidle_driver *cpuidle_driver = cpuidle_get_driver(); + struct cpuidle_driver *cpuidle_driver; spin_lock(&cpuidle_driver_lock); + cpuidle_driver = cpuidle_get_driver(); if (cpuidle_driver) ret = sprintf(buf, "%s\n", cpuidle_driver->name); else