From patchwork Thu Jun 27 21:02:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 167991 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2830063ilk; Thu, 27 Jun 2019 14:02:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqxRzaISS7GiHGvn/i1wwgvtq2vOBMT4JtYOv+DeDj4KKDSOoTgTwwiqnk9ZB4NfFS2oL4k0 X-Received: by 2002:a17:902:934a:: with SMTP id g10mr7198375plp.18.1561669348862; Thu, 27 Jun 2019 14:02:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561669348; cv=none; d=google.com; s=arc-20160816; b=nloIwf+kLtm5e1vx7oJ+wHcp2iiLax4ewd1aYzsQJKWw9FQ6JXV4VIjOyA22BUY61h fzim0jVqTVrcycwAxT+tUpBQW10TXK9Ja9kYvCozvSJ3Ei1F5nLBF0u1O8igQGGUVqNf GI8GIzvHqTQJO0t2NGB1C+rpOPvxCd9fh0LyAAfGRybT3rI9gkRuWiEKmM+UvMAPceh2 mFPk4NB2A+MB509Bo/+nUUrfYrU09QZ1dR2RCg1TKC07IMEZVdrEqO8jfrrvn9IZt4gX BmPC+Rd06Dnm1VvYwpR5o9BONR1uSDcxC+QTrrtm06QV1d8ArKn+jBcTVlHQZFyx6Tag HBFg== 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=Jb+mp+rDj9DLSvOVTi217/rhPZn5ckg46P7fvQWw8bI=; b=USWKK8fQPZFG9C5TJJ43aEwKzzOxFI2GxjW8A35z1lyMI7EFuUhx7tbvW6YbS/+Nis S/NTSfpQJz/MTHWAAsfNj1eD9Fk9FYivvJfv6/0Z+WUdBH+wj5R5G2tD2ddlIZ+3vG9L EmhNVvFYTTxOkReLZAesj84Rd3rIbYoza2F8FsyorHIsPHhaoizFZ2cT4bcdg8H+p5yV aiRfizO1jiDu7xSFdhmDr8bPMnr0cUvXXKbQrNgW5tnkb/5PfUSUhKWE7NCB6IF/d0Ud wfz4hFiruNiIHsBMitSkxgyZ4ZgaTHjOg/Due2cjI4h7ZFzavpFDk4eMIUQkF3XWAWZQ XYrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XVUwEFJc; 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 61si3417344plq.157.2019.06.27.14.02.28; Thu, 27 Jun 2019 14:02:28 -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=XVUwEFJc; 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 S1726441AbfF0VC1 (ORCPT + 11 others); Thu, 27 Jun 2019 17:02:27 -0400 Received: from mail-wm1-f67.google.com ([209.85.128.67]:39265 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726384AbfF0VC1 (ORCPT ); Thu, 27 Jun 2019 17:02:27 -0400 Received: by mail-wm1-f67.google.com with SMTP id z23so6960484wma.4 for ; Thu, 27 Jun 2019 14:02:26 -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=Jb+mp+rDj9DLSvOVTi217/rhPZn5ckg46P7fvQWw8bI=; b=XVUwEFJc76EMd/mccv9X0ByGbh5iraSJs6Fk0OV4yyos19CgBVM6X+EZu2DTrk15MH QFIul6likq8ngMyjhWhD9ZKaSzO4OGFTtnzLfQ0BMr5m9PKCKS3ebXdYFnehLUzI/vyY x7rQ0QPKjDy+HN1XV6GX0gyAJSE71tT1JY7wmarTtdJaZqq6oQZlHF5cxGpNCuU3Rgsd cT7Raw8bQg9MRKwBjIppz0fN/3MDThple+CpwnWebHEDxHeiX1R+WFtwt40jZSPqwN5t ca7dvDZq2t09/d5KGzLjFVfxZIqoed/K9rK7QxYmOnkoPfKtfgcrPu6PvAfe8kSROxG4 6hKQ== 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=Jb+mp+rDj9DLSvOVTi217/rhPZn5ckg46P7fvQWw8bI=; b=ujGDYcRZB9LTPIsbpXaYG5wGLs+TCo0fuWOkmFe1ndras3biZRu/U122SaK3EKu8j9 0h8JFoeQR6F1bY3PzHHrDDf1/pN9u5BKFAqCZH3o3tYhlyS3KIdJuz81CIbhW76X50gr 2Cxu23+TQGZBMQ45vmuZivZ4A5i8y+mXduQOSQ0ylBvWfwB9gI+lqgsbPNN5kB42LaGK B0RXb0YFbKDPuo0OhARzidhHlqNjh5zIw83U9/7E3/chTjBYsAyGDQpTkUO49mlTrpWb bxYTARZrs0yafBDKrIo+/nS/z+irwu4QQiPrb0TRTTFIpY0OPZJYWrUulG9CVJSKgMD5 7XAA== X-Gm-Message-State: APjAAAVru08CNoVxRUJUEIRwwrXd64FEnzEfE1i/MkupYfsGxlkEJYUY CgYCHS4PKQBek5qdD+wqGx3F8w== X-Received: by 2002:a1c:7008:: with SMTP id l8mr4221000wmc.64.1561669345669; Thu, 27 Jun 2019 14:02:25 -0700 (PDT) Received: from clegane.local (11.117.130.77.rev.sfr.net. [77.130.117.11]) by smtp.gmail.com with ESMTPSA id k82sm107902wma.15.2019.06.27.14.02.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Jun 2019 14:02:25 -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 V4 1/3] cpufreq: Move the IS_ENABLED(CPU_THERMAL) macro in a stub Date: Thu, 27 Jun 2019 23:02:06 +0200 Message-Id: <20190627210209.32600-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. Suggested-by: Rafael J. Wysocki Signed-off-by: Daniel Lezcano Acked-by: Viresh Kumar --- drivers/cpufreq/cpufreq.c | 6 ++---- include/linux/cpufreq.h | 6 ++++++ 2 files changed, 8 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..a1467aa7f58b 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h @@ -409,6 +409,12 @@ 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(CONFIG_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) {