From patchwork Tue Jun 25 11:32:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 167705 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp5431818ilk; Tue, 25 Jun 2019 04:33:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqwlNo7asbEzl5KDHcHB/jUPovqy7G6YYNyrGt6wY6QLiFDYmaIvSCLsZbFigfqM8JzqoAjV X-Received: by 2002:a63:2c43:: with SMTP id s64mr38210097pgs.50.1561462383675; Tue, 25 Jun 2019 04:33:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561462383; cv=none; d=google.com; s=arc-20160816; b=UNvqkzyaLnRPE6FGADNOrMOE/nFmteXe6+OeN4c62nOJCbEK46I5IQsfKTox5EyjxW 1JUpqXbuO9WBPzkbjMsgRpbymcNQwjZPZmam7qf+bhnPyPJNIrfc4aN2q5Z8Gnipt3lj opLmFnY5+ceOmmx3bEudmMImwz1mTR2y538STfQCeUB32afT8NbD5KA4NQBE0tsJdLMb OhOi9twCfOhs+jDEKMlVBqH1wim/lD2PglF3uYzQbzb3b775AKz05sUv5Db3qjpcrkUD W9AL0VbP1ZMFZkn752Y0Y+HWtn2OttbFJ77v9WqMFmgkopVLAniP0znn1TAXxA7AW7zb Uq6A== 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=gfN0VPkayONHtS3i29yH7uw5pjX/DRIDiiwHlkhXdNXUNGGc6tFafjnYiQZx1ZW5RF DMCJmdtUccAJUex66zs5YMOzQ4OSBg9MMnvlCKKQy2KBtgmZgOvrpC7hWsrG9EsLyYE/ No4VgwuxLXzFS+bJwpyRGgcDdOr+bUo2ejuUzi6+1Ju7vOHKu9b0nF661L4B48nYqXhi gT/x9xIHxZJJKyuAp08VidgTqYv3FWp7I+jWBsuVjDZ6wDbkzPkjHIbGYyD4qofMyegw D5h6Oq/eEj8RViQBHMJv4efLkA81mlCRr1S7wZBvDBBNyhpjx7HPvvoQiv8EnVtv19w0 n9gA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=b8O+q8+p; 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 d36si164513pla.113.2019.06.25.04.33.02; Tue, 25 Jun 2019 04:33:03 -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=b8O+q8+p; 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 S1730609AbfFYLdB (ORCPT + 11 others); Tue, 25 Jun 2019 07:33:01 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:40684 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730546AbfFYLdB (ORCPT ); Tue, 25 Jun 2019 07:33:01 -0400 Received: by mail-wr1-f66.google.com with SMTP id p11so17439941wre.7 for ; Tue, 25 Jun 2019 04:33:00 -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=b8O+q8+prWiPegbdgjjfIFOuD5BkeaA7JfC1MHz+Tc9x43b1tRTTjSTLnGoMlFQ6ul 6aPkd4to4AnqNt1LUjRofjOUM3WGxDCGW6r/LDUCpIt71dR8i78wdpcep75jh7hjCjlI NOB//JopuNBp6KX8Nakjz+38eK4WMv6pIjMIUqWF8hSPUTD1zl9rREM4NNJ/IxniZN94 n/GrA2nFH/lMlM8bACKhMEzqvlJT2YsaQ4Vog3WehS2DK6a/hp8sBQEf6hVbGRFkKtFd Ogqz5CUtiy2m8PfP5NtZ5/BgFkvchuk8P0m9F8fe/MyuaH58/HbhixDhKiZf83g5NjSJ 4SXw== 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=Brko5TZzasCi/NvxZDl0pOjK0QYyYLJ3KaUNO4mKKUd8j+/wYrzHfoRtWlTAa8Gh/S 2V+FL9nl7RJSs7jwRNSzuDKy913Dc8SPMi8YEPXCjz6eBfL4bea4SzbpQhwiPYllvaug t5IYJJGE5yJP6FYrpyxG11C2UYaCYV1p8aCZhJg/UCJFWM6G1nNDc8Lvb5KIauSmT9iq gnXUvWzT7iVOaN7tTHPJFUUnyegnlE6TbfppltS7OK1iHbfLcgrfQ4BDoSjLJrh3HLFw Zk3CsSC+1uXtXmSyhW9J3pXwgLSdNDHb4HFgnthMarbXrsHOgbxmC10wYACZngsIOEor lfPA== X-Gm-Message-State: APjAAAVSAZgQevH8cZaVPs2vIcqeSNoaX69+j78bdvTYIlcefB5s6sNF jhQR1IMYlt60hcPjvk29ognzxQ== X-Received: by 2002:adf:b78c:: with SMTP id s12mr49273824wre.264.1561462379160; Tue, 25 Jun 2019 04:32:59 -0700 (PDT) Received: from clegane.local (191.184.66.86.rev.sfr.net. [86.66.184.191]) by smtp.gmail.com with ESMTPSA id j7sm19254284wru.54.2019.06.25.04.32.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 25 Jun 2019 04:32:58 -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 V3 1/3] cpufreq: Move the IS_ENABLED(CPU_THERMAL) macro in a stub Date: Tue, 25 Jun 2019 13:32:41 +0200 Message-Id: <20190625113244.18146-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) {