From patchwork Wed Jun 12 13:08:55 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 17833 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qe0-f69.google.com (mail-qe0-f69.google.com [209.85.128.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 5E83B23903 for ; Wed, 12 Jun 2013 13:09:09 +0000 (UTC) Received: by mail-qe0-f69.google.com with SMTP id a11sf6166961qen.4 for ; Wed, 12 Jun 2013 06:09:09 -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=saO3cuwGPrYA2sfKucti0+ZuZju6+6CUDxWuB6FII74=; b=b9OLvbRx80fbsKMOVgelqkz9+/EkWvO2SUefa99kkl/FtVDrJYeZcW4e4ZdblLDB3/ ur1pSF/jwvedets0IYqJRQ9CVYKznyBZB8w+W0tqrEnOe0EFzxpkWqn9ZYYd3tBfUuiX 2CJHJz3cPKZ4aXHQXDpt0wnKLlfnUhMbY+f6CqIJYEsOgm957PHicKPqvkS3an3uNJdj +f6T+GhwIKSXd51lxnuQqw4OZas5QRZO16NZsUYcSiZ+gsXTiyWmLUsfRkP/uj5cQBAx KyFKxHvQuosZ0WMf5XOQQLmskmW1draTvRdt1k3t9paUCV3Bgzgd53E1ge6WuMsQ761B KKew== X-Received: by 10.236.223.162 with SMTP id v32mr1060789yhp.25.1371042549071; Wed, 12 Jun 2013 06:09:09 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.108.201 with SMTP id hm9ls3741188qeb.65.gmail; Wed, 12 Jun 2013 06:09:08 -0700 (PDT) X-Received: by 10.52.232.69 with SMTP id tm5mr8136062vdc.117.1371042548886; Wed, 12 Jun 2013 06:09:08 -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 zt2si8546256vdb.154.2013.06.12.06.09.08 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 12 Jun 2013 06:09:08 -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 oz10so6620189veb.5 for ; Wed, 12 Jun 2013 06:09:08 -0700 (PDT) X-Received: by 10.220.144.67 with SMTP id y3mr8517472vcu.17.1371042548759; Wed, 12 Jun 2013 06:09:08 -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.58.191.99 with SMTP id gx3csp143398vec; Wed, 12 Jun 2013 06:09:07 -0700 (PDT) X-Received: by 10.180.210.225 with SMTP id mx1mr4430579wic.15.1371042546974; Wed, 12 Jun 2013 06:09:06 -0700 (PDT) Received: from mail-we0-x22c.google.com (mail-we0-x22c.google.com [2a00:1450:400c:c03::22c]) by mx.google.com with ESMTPS id o1si6047383wjz.15.2013.06.12.06.09.06 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 12 Jun 2013 06:09:06 -0700 (PDT) Received-SPF: neutral (google.com: 2a00:1450:400c:c03::22c is neither permitted nor denied by best guess record for domain of daniel.lezcano@linaro.org) client-ip=2a00:1450:400c:c03::22c; Received: by mail-we0-f172.google.com with SMTP id q56so6992480wes.3 for ; Wed, 12 Jun 2013 06:09:06 -0700 (PDT) X-Received: by 10.194.58.11 with SMTP id m11mr9821034wjq.45.1371042546427; Wed, 12 Jun 2013 06:09:06 -0700 (PDT) Received: from mai.home (AToulouse-654-1-404-219.w82-125.abo.wanadoo.fr. [82.125.3.219]) by mx.google.com with ESMTPSA id x13sm24555864wib.3.2013.06.12.06.09.04 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 12 Jun 2013 06:09:05 -0700 (PDT) From: Daniel Lezcano To: rjw@sisk.pl Cc: linux-pm@vger.kernel.org, linaro-kernel@lists.linaro.org, patches@linaro.org Subject: [PATCH 8/8] cpuidle: Check the device is not already registered Date: Wed, 12 Jun 2013 15:08:55 +0200 Message-Id: <1371042535-22630-8-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1371042535-22630-1-git-send-email-daniel.lezcano@linaro.org> References: <1371042535-22630-1-git-send-email-daniel.lezcano@linaro.org> X-Gm-Message-State: ALoCoQl189dFP4SRsqGu9R4Asm6f5CVQALveIvyG0zqg+LJejan6mqQpnC0ELLjt0CL4HuV0q4vh 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 7c3f625..59b697877 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;