From patchwork Mon Jun 24 13:17:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 167566 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp4218970ilk; Mon, 24 Jun 2019 06:17:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqxkh+Pr2hxdsliZnBikXew4OsJVIwDwhpLBveMmzJmoHpy6DzpaIqRugIXcVq7NnMs2Ztcr X-Received: by 2002:a63:1657:: with SMTP id 23mr30776385pgw.98.1561382251826; Mon, 24 Jun 2019 06:17:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561382251; cv=none; d=google.com; s=arc-20160816; b=qPNzOWOMCFPXqB6A9ICanXqhXbbhAJJ3Zj0cT9q+BH8Q4lPiLgQhTuEDrVgP+M1teF NmReQ5BrlFwdspamE83x+AMDzS/b40/MHxDGvzs4uOzqJ3aNVKyFoSYvyxTuKt6/iJfi c4/8HLsfFY7tP8tygQU+JqUCyCk8RU5JyNo266IyAse+iASpxHybD/932ATMED9XULhE SCeBZk4WUS8zstVxe4A5jrnuGRa2DffB/Tp8rh0yReFGeGAfoNJCk3KtRvvYot3O7Wnn dwEgR4ZhumMOloSb6/3ji1FXFDgTUxb0oTWDqu2nbBBZzZOnq85RC0aflcU0IYUJ6qPS rkZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=efC80koaOeT2KpDCiZsg2W4r8KMOQMdu6ewHJAqZM1c=; b=tnHivR13fm7WSP3jSr+mAvF6SgZzHUnrfhF7kRHW9zEDucHUsMveRBbuY6/VJFqNfA IbXTG8aqOF1aPAuxmB/ypXtceyDlZrTXWW8nOslE10o1YsSsOwy1q/yC5yoseiTxIThl PH49aTNCptjS9nriMZ+zvaEuuFVqZNveKLqLzPelOpvlwqAhh8Vy656Hfn2E+sTu3MHK t8FtnAsc2HclDjC7O0TB/DtD7pSo4pY620ZM4nk7fZAjCD+rP8L3jTEaDkxxBmzJOFsU YDa9+7cxCh4fKOY5mptiabo8IjacpBTKPeJIpBafGYU+UeU4fgmNSCHl5fa8ubqJjJvR jKnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qQXz36bU; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-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 t10si9997655plo.297.2019.06.24.06.17.31; Mon, 24 Jun 2019 06:17:31 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-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=qQXz36bU; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-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 S1728665AbfFXNRa (ORCPT + 11 others); Mon, 24 Jun 2019 09:17:30 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:36449 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728646AbfFXNRa (ORCPT ); Mon, 24 Jun 2019 09:17:30 -0400 Received: by mail-wr1-f68.google.com with SMTP id n4so12688639wrs.3 for ; Mon, 24 Jun 2019 06:17:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=efC80koaOeT2KpDCiZsg2W4r8KMOQMdu6ewHJAqZM1c=; b=qQXz36bUWSjMxGO1GiOAaRejTpoS188FGJ60lh8ehW1GwnXUxUcrf3WMswMNMA17tb 3JquDEdlsoGOtjCi0/v4qOs3ui/yQT0oPyKTBDUoiqwBJEUm9yMu/KvmtN4HK0w/yBqj 3CEm1JupxSoMH5rqYw1OGPLRFG6g87EwCghEOwSFkWwUsd5QWDv5lOmlWsdFtjeWqPK0 8Ywz6hqkZJNj2i5+OaCQFVA8Y+T4z3KyqiY7MSUSZbGNmxvm4Tb0b0el9ngNS50RdYu5 3Ia4trUgcm5P92NadSlDdWPClvjXlTPr+UBrP1bTgtAx7vTV1H6kzGQ2rJruDkTKWyWB 06ag== 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; bh=efC80koaOeT2KpDCiZsg2W4r8KMOQMdu6ewHJAqZM1c=; b=VGCQD7ai/cmWldbuFtvbZmTnbU/qFcYfTtAB4I59dz91E7tsAV0WExwDcHhytYu59l wA5QEgTzJV3tF+QHcfIfWEWra+Hml5IEo9a4mYLQyiaLstqyowli/UEf1Y5Mv61shsB9 oVBJkxhTr7E9kndnQx6FFFykDxSmePwFYxLgk7FIE5Mt4M3yORV1M3au6R3kAS9wzMc8 iQtM6wZPcOH9E+kFaDL374xzYWDQiXUgAftkABE5h9owTOKoz7MY2J0n1o317ZwMVzOG vv6xDlbaCp2Rh3QkbxdGPDA4ti+CQ+UclGeZcTH19jBuIkstj5w2D7T6+0LnmEpPhh70 LX/w== X-Gm-Message-State: APjAAAUpG7SUFsKj8oKBAqIRiiRxfUJz2tRb/BjWJNKNRey88xX+VeY0 IWKzKdO0xNZ4zhBbhEwrFPGfrKLXxrQ= X-Received: by 2002:adf:fc91:: with SMTP id g17mr20193129wrr.194.1561382249035; Mon, 24 Jun 2019 06:17:29 -0700 (PDT) Received: from clegane.local (209.94.129.77.rev.sfr.net. [77.129.94.209]) by smtp.gmail.com with ESMTPSA id x8sm24952817wre.73.2019.06.24.06.17.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 24 Jun 2019 06:17:28 -0700 (PDT) From: Daniel Lezcano To: viresh.kumar@linaro.org Cc: rjw@rjwysocki.net, edubezval@gmail.com, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org (open list:CPU FREQUENCY SCALING FRAMEWORK) Subject: [PATCH v2 1/2] cpufreq: Move the IS_ENABLED(CPU_THERMAL) macro in a stub Date: Mon, 24 Jun 2019 15:17:14 +0200 Message-Id: <20190624131715.1857-1-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.17.1 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The cpufreq_online and the cpufreq_offline [un]register the driver as a cooling device. This is done if the driver is flagged as a cooling device in addition with a IS_ENABLED macro to compile out the branching code. Group this test in a stub function added in the cpufreq header instead of having the IS_ENABLED in the code path. Signed-off-by: Daniel Lezcano --- drivers/cpufreq/cpufreq.c | 6 ++---- include/linux/cpufreq.h | 5 +++++ 2 files changed, 7 insertions(+), 4 deletions(-) -- 2.17.1 diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 85ff958e01f1..aee024e42618 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -1378,8 +1378,7 @@ static int cpufreq_online(unsigned int cpu) if (cpufreq_driver->ready) cpufreq_driver->ready(policy); - if (IS_ENABLED(CONFIG_CPU_THERMAL) && - cpufreq_driver->flags & CPUFREQ_IS_COOLING_DEV) + if (cpufreq_thermal_control_enabled(cpufreq_driver)) policy->cdev = of_cpufreq_cooling_register(policy); pr_debug("initialization complete\n"); @@ -1469,8 +1468,7 @@ static int cpufreq_offline(unsigned int cpu) goto unlock; } - if (IS_ENABLED(CONFIG_CPU_THERMAL) && - cpufreq_driver->flags & CPUFREQ_IS_COOLING_DEV) { + if (cpufreq_thermal_control_enabled(cpufreq_driver)) { cpufreq_cooling_unregister(policy->cdev); policy->cdev = NULL; } diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index d01a74fbc4db..53ec82d75565 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h @@ -409,6 +409,11 @@ int cpufreq_unregister_driver(struct cpufreq_driver *driver_data); const char *cpufreq_get_current_driver(void); void *cpufreq_get_driver_data(void); +static inline int cpufreq_thermal_control_enabled(struct cpufreq_driver *drv) +{ + return IS_ENABLED(CPU_THERMAL) && (drv->flags & CPUFREQ_IS_COOLING_DEV); +} + static inline void cpufreq_verify_within_limits(struct cpufreq_policy *policy, unsigned int min, unsigned int max) {