From patchwork Wed Jun 12 13:08:49 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 17827 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qe0-f72.google.com (mail-qe0-f72.google.com [209.85.128.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 5133A23903 for ; Wed, 12 Jun 2013 13:08:58 +0000 (UTC) Received: by mail-qe0-f72.google.com with SMTP id 1sf4731976qec.7 for ; Wed, 12 Jun 2013 06:08:57 -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=wPGL+2lm1h8zUaJ9MkU3YR4ALKbbMQIWrtJE9wN0VG4=; b=B2C+b88p9q/pwb1IwotTZh57fG30tWKCqT19sFXm1MA7aUZrgSHVK6ybx9KiaoDUn6 1DNOCsBsI3sTt+jUkAl8emiQ/+m3/ycJJ9fEi65e1MC7gFAoF1+agMVFREmKV2dVDsZJ 0HQCN9jiwBlBL2lBLinYrmyIeyydh+hTUmoWNThqkUna5YXgUf7CRpKkCLsJqxoEci6d wIEY5YVaBI46hK7cV/os8wym1zfhuTfvjEziB6Viunnl9Fvqn+p9WMGZdGQVszC3I5IT AsFI9VCugpdszsUPglObeMcuw4ULN9B6eiQoeBNQRu+EPizgioGVjUp2NQJ+uCQbhBMA S3zg== X-Received: by 10.236.193.196 with SMTP id k44mr10981502yhn.40.1371042537858; Wed, 12 Jun 2013 06:08:57 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.24.51 with SMTP id r19ls2394405qef.73.gmail; Wed, 12 Jun 2013 06:08:57 -0700 (PDT) X-Received: by 10.52.117.16 with SMTP id ka16mr8065075vdb.43.1371042537657; Wed, 12 Jun 2013 06:08:57 -0700 (PDT) Received: from mail-vc0-f175.google.com (mail-vc0-f175.google.com [209.85.220.175]) by mx.google.com with ESMTPS id zt2si8552499vdb.128.2013.06.12.06.08.57 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 12 Jun 2013 06:08:57 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.175 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.175; Received: by mail-vc0-f175.google.com with SMTP id hr11so6121573vcb.20 for ; Wed, 12 Jun 2013 06:08:57 -0700 (PDT) X-Received: by 10.52.171.80 with SMTP id as16mr8338067vdc.90.1371042537539; Wed, 12 Jun 2013 06:08:57 -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 gx3csp143385vec; Wed, 12 Jun 2013 06:08:57 -0700 (PDT) X-Received: by 10.194.235.99 with SMTP id ul3mr12082771wjc.6.1371042536573; Wed, 12 Jun 2013 06:08:56 -0700 (PDT) Received: from mail-wg0-x233.google.com (mail-wg0-x233.google.com [2a00:1450:400c:c00::233]) by mx.google.com with ESMTPS id pl9si7174496wjb.159.2013.06.12.06.08.56 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 12 Jun 2013 06:08:56 -0700 (PDT) Received-SPF: neutral (google.com: 2a00:1450:400c:c00::233 is neither permitted nor denied by best guess record for domain of daniel.lezcano@linaro.org) client-ip=2a00:1450:400c:c00::233; Received: by mail-wg0-f51.google.com with SMTP id e11so2728273wgh.18 for ; Wed, 12 Jun 2013 06:08:56 -0700 (PDT) X-Received: by 10.180.39.236 with SMTP id s12mr4452380wik.14.1371042536182; Wed, 12 Jun 2013 06:08:56 -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.08.54 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 12 Jun 2013 06:08:55 -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 2/8] cpuidle: Check cpuidle_enable_device succeed Date: Wed, 12 Jun 2013 15:08:49 +0200 Message-Id: <1371042535-22630-2-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: ALoCoQlBb7NBUPlhNYOyVjyTDH/1PkhCiq4MRMmf0Es07znUUpbvsMuW5I1kXir9mWB8tymjTU+m X-Original-Sender: daniel.lezcano@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.175 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: , The previous patch changed the order of the framework initialization, the governors are registered first and then the drivers can register their devices. We can safely remove the __cpuidle_register_device call hack in the cpuidle_enable_device function and check if the driver is registered before enabling it. The cpuidle_register_function can check consistently the return code when enabling the device. Signed-off-by: Daniel Lezcano --- drivers/cpuidle/cpuidle.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c index fdc432f..52ec46b 100644 --- a/drivers/cpuidle/cpuidle.c +++ b/drivers/cpuidle/cpuidle.c @@ -292,15 +292,12 @@ int cpuidle_enable_device(struct cpuidle_device *dev) if (!drv || !cpuidle_curr_governor) return -EIO; + if (dev->registered == 0) + return -EINVAL; + if (!dev->state_count) dev->state_count = drv->state_count; - if (dev->registered == 0) { - ret = __cpuidle_register_device(dev); - if (ret) - return ret; - } - poll_idle_init(drv); ret = cpuidle_add_device_sysfs(dev); @@ -415,13 +412,17 @@ int cpuidle_register_device(struct cpuidle_device *dev) return ret; } - cpuidle_enable_device(dev); + ret = cpuidle_enable_device(dev); + if (ret) { + mutex_unlock(&cpuidle_lock); + return ret; + } + cpuidle_install_idle_handler(); mutex_unlock(&cpuidle_lock); return 0; - } EXPORT_SYMBOL_GPL(cpuidle_register_device);