Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4435692imu; Tue, 29 Jan 2019 01:17:20 -0800 (PST) X-Google-Smtp-Source: ALg8bN4KocHjzReD5C5ZalY43/jtsEKbQoz9vGi8xUB97c8AHwo1a/Q2XbAli3vrMdkT0styNZIy X-Received: by 2002:aa7:8758:: with SMTP id g24mr24884790pfo.250.1548753440107; Tue, 29 Jan 2019 01:17:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548753440; cv=none; d=google.com; s=arc-20160816; b=W0LS0iXlOLAEIezdNIP90B6IdPx2q0JbhMyI4lOT0J4GZYBAjXVC3muvTIpe/ycb9a c9tP5SaBZ8a6U52qLLyoO7naCbBOJitbM2dD6s30kAUfm3SJYC4p2ZR92+9Z9it5Qe4Q rPbSN9+yh0QjV4vveyCCQQOdYSZ2VJAuUgHBWFM4J6Cv8+JAwIn0bWutp7DQjemc6aT6 krEHDGJVHnnG+N8zH0yWUtfZWM4CJVlSV21PzXrSFoTvM+j8S35AuC5RADsg4IZ4HWKm ANJZ4uuybLVL7EXLWtOderzJMVtSBf0KqtyY8wqBZud0uwsX1MXkcrXJYPZ36JB9gYtU 2Y5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=5X5QKK2tBiAEW1D1siDTuE5MYQmrLG2VxxWhkSDspks=; b=BRdUqZP09ooLd0Z9yXHHPy5jlOPEmiQ8Q+ZCpJwht0Tp7stZgSSOE0VMoipuN5nwNC rvBG17f6Xj7IxmutRHcudz6oYtWWzZuxUjZUd/q3uZyY2zzh8wjOpO2p8W+KonMmHlp3 Q0qSBnSG540CTRArxzdH1507jPm5usdmXjqDVRTNucNN532sSq5AE5dFO8P90emJ6fTj DQu0aJ/f2yIJ+8TtdH1wOk1wsFpzBOo0Bsjuhu4BEas0H+37nrcsaeAFAzGyIiPBPeTU oJ2LRNO1CFB6OfQDXAA0B0/PyEmq3LzADF63t6kzSeAw2DZwS1u7SL2IgomC5+c5y66m fWkg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d13si34239549pgu.40.2019.01.29.01.17.04; Tue, 29 Jan 2019 01:17:20 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727890AbfA2JQ3 (ORCPT + 99 others); Tue, 29 Jan 2019 04:16:29 -0500 Received: from mail-ot1-f65.google.com ([209.85.210.65]:34155 "EHLO mail-ot1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725298AbfA2JQ2 (ORCPT ); Tue, 29 Jan 2019 04:16:28 -0500 Received: by mail-ot1-f65.google.com with SMTP id t5so17291332otk.1; Tue, 29 Jan 2019 01:16:28 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=5X5QKK2tBiAEW1D1siDTuE5MYQmrLG2VxxWhkSDspks=; b=TI9fOqt5A3ep37cuAmVHs0j8x4Qt2EUDEr92C7pxn9cwkB20U3Xld5mBLYI4T03SXA lL2t52haDsdQniXH+3FJCS22U2/+AExv+Ssd78S/ED7F/NicfF0EAO3EWrqrQbdjticU 4Z0m1qTghJ7MjraYpJE6Tq0fRfZOtk8HoQ+/9dPDQGH5U/TuPf7YXQaPqAVvYWSMHCdy /RFPvFCJF3eJ8aAYf15+BgV3Gh8oyYPPgrECcc2MEI6hBJvpUUrNf0ikYp8cn87/8VVM afkdxjVvluk0F6H2/1LaDTsFl1+AOac2zqLuXL5KfWOZg76KfYxpuxzn2J/YB9YyW1k4 U6nA== X-Gm-Message-State: AJcUukesqdoYGrLn/rgLsZRRpfu6WowKE59Qb6WRyaS63PTuvJz62PnC O8SGYpq5njzjPCrNKFRsfQ255NKcB+5D3D5G07o= X-Received: by 2002:a9d:60b:: with SMTP id 11mr18406170otn.200.1548753387615; Tue, 29 Jan 2019 01:16:27 -0800 (PST) MIME-Version: 1.0 References: <6077cb33d7e078bb0e85776bad99fdb476f16d0c.1548737236.git.amit.kucheria@linaro.org> <20190129053618.laa6nscfvlmhhkb5@vireshk-i7> <20190129070938.lqhejdu4ilra65ow@vireshk-i7> In-Reply-To: <20190129070938.lqhejdu4ilra65ow@vireshk-i7> From: "Rafael J. Wysocki" Date: Tue, 29 Jan 2019 10:16:15 +0100 Message-ID: Subject: Re: [PATCH v5 2/9] cpufreq: Auto-register the driver as a thermal cooling device if asked To: Viresh Kumar , Amit Kucheria Cc: Linux Kernel Mailing List , "Rafael J. Wysocki" , Sudeep Holla , Linux PM list Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 29, 2019 at 8:09 AM Viresh Kumar wrote: > > On 29-01-19, 11:50, Amit Kucheria wrote: > > On Tue, Jan 29, 2019 at 11:16 AM Amit Kucheria wrote: > > > > > > On Tue, Jan 29, 2019 at 11:06 AM Viresh Kumar wrote: > > > > > > > > On 29-01-19, 10:25, Amit Kucheria wrote: > > > > > All cpufreq drivers do similar things to register as a cooling device. > > > > > Provide a cpufreq driver flag so drivers can just ask the cpufreq core > > > > > to register the cooling device on their behalf. This allows us to get > > > > > rid of duplicated code in the drivers. > > > > > > > > > > In order to allow this, we add a struct thermal_cooling_device pointer > > > > > to struct cpufreq_policy so that drivers don't need to store it in a > > > > > private data structure. > > > > > > > > > > Suggested-by: Stephen Boyd > > > > > Suggested-by: Viresh Kumar > > > > > Signed-off-by: Amit Kucheria > > > > > Reviewed-by: Matthias Kaehlcke > > > > > Tested-by: Matthias Kaehlcke > > > > > Acked-by: Viresh Kumar > > > > > --- > > > > > drivers/cpufreq/cpufreq.c | 13 +++++++++++++ > > > > > include/linux/cpufreq.h | 9 +++++++++ > > > > > 2 files changed, 22 insertions(+) > > > > > > > > > > diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c > > > > > index e35a886e00bc..0f9b50d3ee91 100644 > > > > > --- a/drivers/cpufreq/cpufreq.c > > > > > +++ b/drivers/cpufreq/cpufreq.c > > > > > @@ -19,6 +19,7 @@ > > > > > > > > > > #include > > > > > #include > > > > > +#include > > > > > #include > > > > > #include > > > > > #include > > > > > @@ -1318,6 +1319,11 @@ static int cpufreq_online(unsigned int cpu) > > > > > if (cpufreq_driver->ready) > > > > > cpufreq_driver->ready(policy); > > > > > > > > > > +#if IS_ENABLED(CONFIG_CPU_THERMAL) > > > > > + if (cpufreq_driver->flags & CPUFREQ_IS_COOLING_DEV) > > > > > + policy->cdev = of_cpufreq_cooling_register(policy); > > > > > +#endif > > > > > > > > I am not sure if Rafael wanted it this way but maybe something like this: > > > > > > > > if (IS_ENABLED(CONFIG_CPU_THERMAL) && > > > > cpufreq_driver->flags & CPUFREQ_IS_COOLING_DEV)) > > > > policy->cdev = of_cpufreq_cooling_register(policy); > > > > > > > > We never wanted ifdef hackery to be in there :) > > > > > > OK, that makes more sense. Should I just send out a fixup patch or the > > > entire series? > > Single patch should be fine I believe. > > > FWIW, I checked drivers/cpufreq and drivers/thermal before converting > > over and there is a mixed use of #if IS_ENABLED and if(IS_ENABLED). > > > > Perhaps we should clean it up? > > No objections from me on that. Generally speaking, though, "if (IS_ENABLED(SYMBOL))" can only be used if all of the symbols in the conditional branch are defined regardless of whether or not SYMBOL itself is defined, so careful there.