From patchwork Thu Jan 10 00:00:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Kucheria X-Patchwork-Id: 155106 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp1281311jaa; Wed, 9 Jan 2019 16:01:25 -0800 (PST) X-Google-Smtp-Source: ALg8bN71R6ln5E3M+T3pcKcYvxmqpgYKbeOLgCS6LKBbDikXPg8oPJBubx7iM7ZVSbQ/K6oK4fiR X-Received: by 2002:a17:902:bd92:: with SMTP id q18mr8106264pls.167.1547078485206; Wed, 09 Jan 2019 16:01:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547078485; cv=none; d=google.com; s=arc-20160816; b=kD5xbXDoJEdwjX7RXxmh1oIRIR6haLCuqIorkyzNnlVmXae5x4f2ZA/KzP/3SpZEkd p6dE1HCym1d8TCU82tQmm5hvLvKIPmQ6BhJwxq90Q5WJ7zYiAGg3FiP9sM04irdlkgSP v47qqPKh/3lC9ioKuOZzXs1va9es7JJ5z8ZRwoQif1sEoWJOHNC7mOtc2Y9tU0Q6mrCY ErQxbEQIh0bJukcBo7Mz+DdmAbTwT+g+EH9Vb1Jvjb+++KgMNB3n9wzqZf3/8Yzpf1iA vzeHZ5OhKM3AlzwtfOmUs6bsld6lXUrFLO/zmPzU+GvjRPEJIBUPvDLX3/CWBuuPMX1+ tSRw== 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=R+2fIfZV9+VepnsOFSOVlfHY2uVeuMeSf6BtQ3cq7O+iacUNPEU+cPcOIqJeMPiHg2 Wf+To43YeN1R2P8GVWj/4fGJG789hqVInCH7yZHUKTKB9iDn4j/Yw5iWCGLj1KqUBMnQ 94PZFia8jJuk3RoPmq4epSS0mlv6eePRvrIT+z4cILyLy0vcytLVQjQOdzxjlXR6sudW lQwN/pBEc65QOk2mQ+6Ti17MjEzLw9BsDwHwmLA3cPoBL9w+bZiuMuY7eVkQMaEyPpV5 4obRKTOK9A5DU21fHD/B5g1jXJlQJAuxwVHONUtOJb5zyr9jepgdU2dr9i0qUF3pO3CZ JR9A== 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-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-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 c22si8778795pgb.254.2019.01.09.16.01.24; Wed, 09 Jan 2019 16:01:25 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-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-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-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 S1726869AbfAJABY (ORCPT + 15 others); Wed, 9 Jan 2019 19:01:24 -0500 Received: from mail-wr1-f65.google.com ([209.85.221.65]:43254 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726767AbfAJABY (ORCPT ); Wed, 9 Jan 2019 19:01:24 -0500 Received: by mail-wr1-f65.google.com with SMTP id r10so9433370wrs.10 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=lAj1CBlm9DqxJ4dB5K6Tv/6yoE8SCJwisOmQTm1Gyupyi/Sw+BJyV0r0+bDSonooWf QikPFnvhzO4IirxDHlIIY2mPxVqdCEruaLNhn/pOoA7dArDlhW1uedt+yFa/v0y5vHPg 2rxK7pYqbvANPJInJNAprTvo9dWs2bHQ8PcumbH0Zsq6pr20Iyq0icVLnvGydmTfEabv V3ghDZ5PySXJYoZvHAd8OkeM6VWkXY4ZLOY10TkwDD4/9HVpEAyZbEnsfycm/blM56q/ zldPB4vUhrR4iR9Y7jKXxgWWkQBseTi+1Boc1aEi6EQqkNqlPhlwozhxBPXgGbQ+4AAP iEXg== X-Gm-Message-State: AJcUukcgWf/3yYhoYSq/JH1NQV7+arsOETdM45adj/xHDZ5gfDGrVwIH IjFVjp2kBsnSq1UxxcIs4Q78pQ== 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-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@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(+) -- 2.17.1 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__ */