From patchwork Thu Nov 27 00:37:51 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 5390751 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 5D2EA9F319 for ; Thu, 27 Nov 2014 00:38:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 958A6201E4 for ; Thu, 27 Nov 2014 00:38:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A7F5420155 for ; Thu, 27 Nov 2014 00:38:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752760AbaK0Aic (ORCPT ); Wed, 26 Nov 2014 19:38:32 -0500 Received: from mail-pa0-f43.google.com ([209.85.220.43]:55292 "EHLO mail-pa0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751699AbaK0Aib (ORCPT ); Wed, 26 Nov 2014 19:38:31 -0500 Received: by mail-pa0-f43.google.com with SMTP id kx10so3880835pab.30 for ; Wed, 26 Nov 2014 16:38:31 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=UBx1YB8zUf6NbkZW1ZiHRCqX4gCJXl6YiAvEFS1bsS4=; b=h2zQgcaMiSVKcvcUUlYw5k9JPjod2vXMrBDK1n7u7QaIJ7JdA54llgeGi4G+1/s4FH EknO8Ll7ihf//fTocf7xusY7BI6vMeV1FJQo/P5lCQzaHQhzTyTbB/+iOLp7PPQn0NPk fziyqSGxCxx9NZdOuAbPw+bfczn07SQ9XJ171bQpI1V6vylchSBlCWjquUjAQ0/l7g7K VOMmLyBY/9H2U8PgAS3WAaQ6YlY2c+P4ihNd77XCtlONbALgV5I4GYeqJzZcDvIVUpig JH1x/RSBj6EXG6yYZEW32t9tkRkB06qydQCAzQPadexpb88oso0HiE6pGHxdgy/m2W3g Vbqw== X-Gm-Message-State: ALoCoQk/l6KqANpRTWfk1tTU/7p+vvolBnstJt4po9liYsemcwSsjuNMWK4BJuKR4gbrEbJhRpN6 X-Received: by 10.70.87.173 with SMTP id az13mr46317223pdb.134.1417048711375; Wed, 26 Nov 2014 16:38:31 -0800 (PST) Received: from localhost ([122.167.111.40]) by mx.google.com with ESMTPSA id cy4sm5421552pdb.0.2014.11.26.16.38.30 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 26 Nov 2014 16:38:30 -0800 (PST) From: Viresh Kumar To: Rafael Wysocki , edubezval@gmail.com Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, l.majewski@samsung.com, Viresh Kumar Subject: [PATCH V2 3/4] cpufreq: Introduce ->ready() callback for cpufreq drivers Date: Thu, 27 Nov 2014 06:07:51 +0530 Message-Id: <8291de0dd69c731f1fc259acee190e26481f9f77.1417048449.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.0.3.693.g996b0fd In-Reply-To: References: In-Reply-To: References: Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently there is no callback for cpufreq drivers which is called once the policy is ready to be used. There are some requirements where such a callback is required. One of them is registering a cooling device with the help of of_cpufreq_cooling_register(). This routine tries to get 'struct cpufreq_policy' for CPUs which isn't yet initialed at the time ->init() is called and so we face issues while registering the cooling device. Because we can't register cooling device from ->init(), we need a callback that is called after the policy is ready to be used and hence we introduce ->ready() callback. Signed-off-by: Viresh Kumar Reviewed-by: Eduardo Valentin Tested-by: Eduardo Valentin Reviewed-by: Lukasz Majewski --- drivers/cpufreq/cpufreq.c | 5 +++++ include/linux/cpufreq.h | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index de2c3e1..a09a29c 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -1285,8 +1285,13 @@ static int __cpufreq_add_dev(struct device *dev, struct subsys_interface *sif) up_write(&policy->rwsem); kobject_uevent(&policy->kobj, KOBJ_ADD); + up_read(&cpufreq_rwsem); + /* Callback for handling stuff after policy is ready */ + if (cpufreq_driver->ready) + cpufreq_driver->ready(policy); + pr_debug("initialization complete\n"); return 0; diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index db3c130..4d078ce 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h @@ -267,6 +267,10 @@ struct cpufreq_driver { void (*stop_cpu)(struct cpufreq_policy *policy); int (*suspend)(struct cpufreq_policy *policy); int (*resume)(struct cpufreq_policy *policy); + + /* Will be called after the driver is fully initialized */ + void (*ready)(struct cpufreq_policy *policy); + struct freq_attr **attr; /* platform specific boost support code */