From patchwork Wed May 29 17:43:34 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 17277 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vb0-f72.google.com (mail-vb0-f72.google.com [209.85.212.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 4EA3D25D81 for ; Wed, 29 May 2013 17:43:52 +0000 (UTC) Received: by mail-vb0-f72.google.com with SMTP id w15sf9670623vbf.11 for ; Wed, 29 May 2013 10:43:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-beenthere:x-forwarded-to:x-forwarded-for :delivered-to:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-gm-message-state:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-google-group-id:list-post:list-help:list-archive:list-unsubscribe; bh=iCldTirzzgmXge/rPzCWDTW2Q1vzrdMZYDfxDsiLFc4=; b=I1tNWCgdrZybzcQzsR+TeQvHxkSyO4Zp0J/bxWh7EkZt+AM03U1ULa7If28Xu7IzLX FztGL95hfXWjOPx8UCBjDJ6wSpRdAL0CQH8ft5UwjjdoxSpromeYflmFDdm5o9Vbr4MS s+6T1fNodn3eYk5UXBBk5jYC1Xwi96LdWOA0ajMUnwQ/Mvo1IfhdPyDXPMww5jQu0WTH fg3EhdYth6kQ9n2FBzRzuHVbdiprn7/UnXFRIdHmFtwEZxAIgG2YSK8SxyOeiCh0QH4A ObhVF7uJ3w/6g0NFlQsKGoSUNobsR6N0qof5q5zqTvzgC/xttHJgUjFN656T91tvJOiS rzNg== X-Received: by 10.236.143.101 with SMTP id k65mr1846423yhj.45.1369849432012; Wed, 29 May 2013 10:43:52 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.118.234 with SMTP id kp10ls3899251qeb.47.gmail; Wed, 29 May 2013 10:43:51 -0700 (PDT) X-Received: by 10.58.69.101 with SMTP id d5mr2261065veu.52.1369849431847; Wed, 29 May 2013 10:43:51 -0700 (PDT) Received: from mail-ve0-x22e.google.com (mail-ve0-x22e.google.com [2607:f8b0:400c:c01::22e]) by mx.google.com with ESMTPS id ha8si22235148vdb.87.2013.05.29.10.43.51 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 29 May 2013 10:43:51 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400c:c01::22e is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=2607:f8b0:400c:c01::22e; Received: by mail-ve0-f174.google.com with SMTP id oz10so3461912veb.19 for ; Wed, 29 May 2013 10:43:51 -0700 (PDT) X-Received: by 10.58.187.164 with SMTP id ft4mr2332213vec.5.1369849431770; Wed, 29 May 2013 10:43:51 -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.229.199 with SMTP id jj7csp22136vcb; Wed, 29 May 2013 10:43:51 -0700 (PDT) X-Received: by 10.15.108.141 with SMTP id cd13mr5170132eeb.46.1369849430751; Wed, 29 May 2013 10:43:50 -0700 (PDT) Received: from mail-we0-x22d.google.com (mail-we0-x22d.google.com [2a00:1450:400c:c03::22d]) by mx.google.com with ESMTPS id b45si21533123eef.301.2013.05.29.10.43.50 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 29 May 2013 10:43:50 -0700 (PDT) Received-SPF: neutral (google.com: 2a00:1450:400c:c03::22d is neither permitted nor denied by best guess record for domain of daniel.lezcano@linaro.org) client-ip=2a00:1450:400c:c03::22d; Received: by mail-we0-f173.google.com with SMTP id p57so6545687wes.18 for ; Wed, 29 May 2013 10:43:50 -0700 (PDT) X-Received: by 10.180.198.140 with SMTP id jc12mr1970620wic.53.1369849430110; Wed, 29 May 2013 10:43:50 -0700 (PDT) Received: from mai.home (AToulouse-654-1-324-164.w86-199.abo.wanadoo.fr. [86.199.211.164]) by mx.google.com with ESMTPSA id cw8sm32657116wib.7.2013.05.29.10.43.48 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 29 May 2013 10:43:49 -0700 (PDT) From: Daniel Lezcano To: rjw@sisk.pl Cc: linux-pm@lists.linux-foundation.org, patches@linaro.org, linaro-kernel@lists.linaro.org Subject: [PATCH 7/7] cpuidle: check the device not already registered Date: Wed, 29 May 2013 19:43:34 +0200 Message-Id: <1369849414-7761-7-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1369849414-7761-1-git-send-email-daniel.lezcano@linaro.org> References: <1369849414-7761-1-git-send-email-daniel.lezcano@linaro.org> X-Gm-Message-State: ALoCoQmmkZBrzA5sz8JAETQ7br02oeqnQD/8+S2oEYMNaORKvAyTvakdSpz2C6kVZ2gIblI3yu+N X-Original-Sender: daniel.lezcano@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:400c:c01::22e 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: , Add a sanity check for cpuidle_register_device by testing if the device was already registered or not. Signed-off-by: Daniel Lezcano --- drivers/cpuidle/cpuidle.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c index a4f5ae6..167f2ae 100644 --- a/drivers/cpuidle/cpuidle.c +++ b/drivers/cpuidle/cpuidle.c @@ -400,13 +400,16 @@ static int __cpuidle_register_device(struct cpuidle_device *dev) */ int cpuidle_register_device(struct cpuidle_device *dev) { - int ret; + int ret = -EBUSY; if (!dev) return -EINVAL; mutex_lock(&cpuidle_lock); + if (dev->registered) + goto out_unlock; + ret = __cpuidle_device_init(dev); if (ret) goto out_unlock;