From patchwork Wed May 29 17:43:29 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 17272 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f199.google.com (mail-vc0-f199.google.com [209.85.220.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 7139925E0E for ; Wed, 29 May 2013 17:43:42 +0000 (UTC) Received: by mail-vc0-f199.google.com with SMTP id hf12sf11611017vcb.6 for ; Wed, 29 May 2013 10:43:42 -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=WB/OwwmrKMraWCeCJNhC78SzTaqGu9Zet2dLBQGMuPM=; b=EwAVszlxC/VSWZKvnUYX6BkhUGjPpubRt8ohDlr48h1C90LTMFzyRrupNl4wbsL3hR Jl1O7u7s6OL5qxuBDzKx7hoBNqeLWFgfHHXey6QJNej0okNiHBTbv0Mn5nP3KqQdogsz xXlRLFW2YQm/lELea2ubCkWZ98dwUSLyrjT2ZcBLRtwWwAqi1LzXrYtFJo4O7dvsh0HB 4IdArf03It6lfm0t3S07RmeDitKLPe1E7/8MKSsMfmV7QgL3EzEAhFtcur/FMM/6sQAA DaSnqt+OxQBtx6ZqtBlMfwn+WkxJf+CJcvoQRk1wXP5HLxVNi89Z8Bfnm+XGiFPvaE1y ZWTA== X-Received: by 10.224.53.198 with SMTP id n6mr2171114qag.2.1369849421942; Wed, 29 May 2013 10:43:41 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.117.104 with SMTP id kd8ls1710209qeb.93.gmail; Wed, 29 May 2013 10:43:41 -0700 (PDT) X-Received: by 10.58.6.141 with SMTP id b13mr2303812vea.45.1369849421796; Wed, 29 May 2013 10:43:41 -0700 (PDT) Received: from mail-vb0-x236.google.com (mail-vb0-x236.google.com [2607:f8b0:400c:c02::236]) by mx.google.com with ESMTPS id gr7si22228638vdc.103.2013.05.29.10.43.41 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 29 May 2013 10:43:41 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400c:c02::236 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:c02::236; Received: by mail-vb0-f54.google.com with SMTP id f13so6471699vbg.13 for ; Wed, 29 May 2013 10:43:41 -0700 (PDT) X-Received: by 10.52.69.200 with SMTP id g8mr2009208vdu.4.1369849421678; Wed, 29 May 2013 10:43: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.229.199 with SMTP id jj7csp22128vcb; Wed, 29 May 2013 10:43:41 -0700 (PDT) X-Received: by 10.14.184.5 with SMTP id r5mr5122070eem.72.1369849419446; Wed, 29 May 2013 10:43:39 -0700 (PDT) Received: from mail-wi0-x22a.google.com (mail-wi0-x22a.google.com [2a00:1450:400c:c05::22a]) by mx.google.com with ESMTPS id i48si21654059eem.27.2013.05.29.10.43.39 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 29 May 2013 10:43:39 -0700 (PDT) Received-SPF: neutral (google.com: 2a00:1450:400c:c05::22a is neither permitted nor denied by best guess record for domain of daniel.lezcano@linaro.org) client-ip=2a00:1450:400c:c05::22a; Received: by mail-wi0-f170.google.com with SMTP id hr14so4507414wib.5 for ; Wed, 29 May 2013 10:43:38 -0700 (PDT) X-Received: by 10.194.104.105 with SMTP id gd9mr2142677wjb.1.1369849418909; Wed, 29 May 2013 10:43:38 -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.37 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 29 May 2013 10:43:38 -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 2/7] cpuidle: check cpuidle_enable_device succeed Date: Wed, 29 May 2013 19:43:29 +0200 Message-Id: <1369849414-7761-2-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: ALoCoQlMiJ5LWp6jbveAJBP95SMyGBA2PFlDUCPjEhlOskCBAov1Jm1tC7LKMrcPEwZsnTAEUk9d X-Original-Sender: daniel.lezcano@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:400c:c02::236 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 c3a93fe..f359bcb 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);