Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1317668imu; Wed, 9 Jan 2019 16:03:01 -0800 (PST) X-Google-Smtp-Source: ALg8bN7WK0ve9LJffL+kgJJVesxMKGIeZDBkHS+ziMBhfzZ+7ND8Ku4w7ktV/o1I3pa3coQ68Hg3 X-Received: by 2002:a63:1408:: with SMTP id u8mr7355903pgl.271.1547078581875; Wed, 09 Jan 2019 16:03:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547078581; cv=none; d=google.com; s=arc-20160816; b=p565FaPxB/A7/VgxTJjJVntADuw3eWeTvrDhcjPivkcjHuzvpO1JeXAFDqO9xFaKa4 lmwG1DxhfN1aLCtM0Hko4KDW91/XW9xb05asYJxKDg78OpbnbwbnMDQouZPxV5XHhAwS bvEQt3iYOg3fjOf+J9ydNaN0RFqo1z7BcTexuzApRvlotcnjrM6atiBocZubUJRvZmSh UreWWsoZMEOv7DJIRyDUsWMCH2TvPWPZ5zsIwTGTShz+++pu/xYt1XqZ/s0AFposdWaw 8lqzRWdDjjgzI02Tk8//yurMAXlg0OBpKjmNLzJQJDI3xIrR/MPumtaSIzxot1Jy0Wf2 yCog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=PI9R955mUdxl9wa+5VxK6ncJI/NHFyvZwL7fY0NRhzM=; b=EEBiobS1YIFN3YCwuwUqwjBSPM+tdh0CyGFbPTCJHz3mqrPs8cP+kEil+j7v6IbA33 MR8N2+klcxhvSsNOHTIqamBMx0dsPzbu8zEWYy0em9v0maFUJtUUEi9fWXDFopKoogF7 skrYKXPWJo49yGIuQUPExU5aKmxKqz5fRLS3wE/Frx+hSHlFvRzPKIc64pzP32/fo+3t kOtm9cFrTrjNfTSucskdMlAWQ1bLTUBo7r3fE6Hh/EOPGZmkT/hnz9xCeqRiJ31RRSPT vTx2FLD2u5XUQ00c6tFWPXgMkfW1N8SJzSNKB5/bEU2LY1csVJvnXsz7f4FIKjPnbGDF 4vdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=esoDudYY; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f95si17351668plb.60.2019.01.09.16.02.46; Wed, 09 Jan 2019 16:03:01 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=esoDudYY; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726913AbfAJABZ (ORCPT + 99 others); Wed, 9 Jan 2019 19:01:25 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:35942 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726863AbfAJABY (ORCPT ); Wed, 9 Jan 2019 19:01:24 -0500 Received: by mail-wr1-f66.google.com with SMTP id u4so9465528wrp.3 for ; Wed, 09 Jan 2019 16:01:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=PI9R955mUdxl9wa+5VxK6ncJI/NHFyvZwL7fY0NRhzM=; b=esoDudYYCO44v0DxqBUshEhDqpTRIzcw4JL/wu5ynj7Qfp3tSrwtEcdG6JBmCvY3JH K0oyxh/OO7NysHSsQhKVRI46Tz3XtGLc5ojoTiGRZSv4E1Yhxh6S0icVMw2I1QnoVIam T59rYFPVhXYqko3aJvEQpGKjmsWehCpuN1cm0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=PI9R955mUdxl9wa+5VxK6ncJI/NHFyvZwL7fY0NRhzM=; b=JZnU+aGHhGNfUFXEanp0Cc0XKoDbI1Pnngm4ZSrPvQEpajjdtxMA8H8/5QKkfQVxgt BKZmle2HbaNcSi036yDpCuRSh3/BCVFypv5kMIyI+2Th32bISpJL/RlOj/Ivig2cBnt4 1a+ii27U5cOBTKhQG6zaidTAoeJMYpODAg6j7YI0SUBb9l+tq25f5q2IUxK7O9IeoMBq bh3EH8W3LNRQjfViIRgSPL5Jnoz15SVyykEwd/PmUlJTYUEHD+WVOk44pBfMX7eUVvOF u+twKUWqvnP+wBvdYtIKegg9wkyQoxrENue//V+AX5JF8/vS/Cng2KyiEfsJfjipbQ4s pxuw== X-Gm-Message-State: AJcUukda8l2iQDbGOFhF0lGfb1uMjzTfb9c8/9cErlw/i4ega98cEU9W /7kZ9yiNwXw8JnmMgcjWIUBEbZ1MfFg= X-Received: by 2002:adf:d1d2:: with SMTP id m18mr7129620wri.138.1547078482542; Wed, 09 Jan 2019 16:01:22 -0800 (PST) Received: from localhost ([49.248.171.190]) by smtp.gmail.com with ESMTPSA id o64sm12316497wmo.47.2019.01.09.16.01.20 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 09 Jan 2019 16:01:21 -0800 (PST) From: Amit Kucheria To: linux-kernel@vger.kernel.org Cc: linux-arm-msm@vger.kernel.org, bjorn.andersson@linaro.org, viresh.kumar@linaro.org, edubezval@gmail.com, andy.gross@linaro.org, tdas@codeaurora.org, swboyd@chromium.org, dianders@chromium.org, mka@chromium.org, Amit Daniel Kachhap , Javi Merino , Zhang Rui , Daniel Lezcano , linux-pm@vger.kernel.org (open list:THERMAL/CPU_COOLING) Subject: [PATCH v1 3/7] cpu_cooling: Add generic driver ready callback Date: Thu, 10 Jan 2019 05:30:52 +0530 Message-Id: <9cccfabf22ccae92dfd31175b57baab3206eac0d.1547078153.git.amit.kucheria@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org All cpufreq drivers do similar things to register as a cooling device. Provide a generic call back so we can get rid of duplicated code in the drivers. Signed-off-by: Amit Kucheria Suggested-by: Stephen Boyd --- drivers/thermal/cpu_cooling.c | 18 ++++++++++++++++++ include/linux/cpu_cooling.h | 9 +++++++++ 2 files changed, 27 insertions(+) diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index dfd23245f778..5154ffc12332 100644 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c @@ -694,6 +694,7 @@ __cpufreq_cooling_register(struct device_node *np, cpufreq_cdev->clipped_freq = cpufreq_cdev->freq_table[0].frequency; cpufreq_cdev->cdev = cdev; + policy->cooldev = cdev; mutex_lock(&cooling_list_lock); /* Register the notifier for first cpufreq cooling device */ @@ -785,6 +786,23 @@ of_cpufreq_cooling_register(struct cpufreq_policy *policy) } EXPORT_SYMBOL_GPL(of_cpufreq_cooling_register); +/** + * generic_cpufreq_ready - generic driver callback to register a thermal_cooling_device + * @policy: cpufreq policy + */ +void generic_cpufreq_ready(struct cpufreq_policy *policy) +{ + struct thermal_cooling_device **cdev = &policy->cooldev; + + *cdev = of_cpufreq_cooling_register(policy); + if (IS_ERR(*cdev)) { + pr_err("Failed to register cpufreq cooling device for CPU%d: %ld\n", + policy->cpu, PTR_ERR(cdev)); + cdev = NULL; + } +} +EXPORT_SYMBOL_GPL(generic_cpufreq_ready); + /** * cpufreq_cooling_unregister - function to remove cpufreq cooling device. * @cdev: thermal cooling device pointer. diff --git a/include/linux/cpu_cooling.h b/include/linux/cpu_cooling.h index de0dafb9399d..d7815bb2967a 100644 --- a/include/linux/cpu_cooling.h +++ b/include/linux/cpu_cooling.h @@ -65,12 +65,21 @@ void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev) */ struct thermal_cooling_device * of_cpufreq_cooling_register(struct cpufreq_policy *policy); + +/** + * generic_cpufreq_ready - generic driver callback to register a thermal_cooling_device + * @policy: cpufreq policy + */ +void generic_cpufreq_ready(struct cpufreq_policy *policy); #else static inline struct thermal_cooling_device * of_cpufreq_cooling_register(struct cpufreq_policy *policy) { return NULL; } + +void generic_cpufreq_ready(struct cpufreq_policy *policy) {} + #endif /* defined(CONFIG_THERMAL_OF) && defined(CONFIG_CPU_THERMAL) */ #endif /* __CPU_COOLING_H__ */ -- 2.17.1