Building the Linux kernel with Clang and LLVM
 help / color / mirror / Atom feed
From: Xuewen Yan <xuewen.yan@unisoc.com>
To: <lkp@intel.com>, <rjw@rjwysocki.net>, <daniel.lezcano@kernel.org>
Cc: <devel@acpica.org>, <jeson.gao@unisoc.com>,
	<linux-acpi@vger.kernel.org>, <linux-pm@vger.kernel.org>,
	<llvm@lists.linux.dev>, <lukasz.luba@arm.com>,
	<oe-kbuild-all@lists.linux.dev>, <rafael@kernel.org>,
	<ke.wang@unisoc.com>, <di.shen@unisoc.com>,
	<xuewen.yan94@gmail.com>
Subject: [RFC PATCH] drivers/powercap: fix build error when CONFIG_SMP is not set
Date: Mon, 10 Mar 2025 10:56:55 +0800	[thread overview]
Message-ID: <20250310025655.576-1-xuewen.yan@unisoc.com> (raw)
In-Reply-To: <202503070326.9hEUez42-lkp@intel.com>

When CONFIG_ENERGY_MODEL=y and CONFIG_SMP=n, there is build error:

>> drivers/powercap/dtpm_cpu.c:83:15: error: call to undeclared function 'sched_cpu_util';
ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
      83 |                 sum_util += sched_cpu_util(cpu);
         |                             ^
   1 error generated.

This is because the sched_cpu_util depends on CONFIG_SMP,
so using the #ifdef to guarantee the dependence.

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202503070326.9hEUez42-lkp@intel.com/
Signed-off-by: Xuewen Yan <xuewen.yan@unisoc.com>
---
 drivers/powercap/dtpm_cpu.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/powercap/dtpm_cpu.c b/drivers/powercap/dtpm_cpu.c
index 6b6f51b21550..b935e8c38b45 100644
--- a/drivers/powercap/dtpm_cpu.c
+++ b/drivers/powercap/dtpm_cpu.c
@@ -68,6 +68,7 @@ static u64 set_pd_power_limit(struct dtpm *dtpm, u64 power_limit)
 	return power_limit;
 }
 
+#ifdef CONFIG_SMP
 static u64 scale_pd_power_uw(struct cpumask *pd_mask, u64 power)
 {
 	unsigned long max, sum_util = 0;
@@ -84,6 +85,12 @@ static u64 scale_pd_power_uw(struct cpumask *pd_mask, u64 power)
 
 	return (power * ((sum_util << 10) / max)) >> 10;
 }
+#else /* !CONFIG_SMP */
+static inline u64 scale_pd_power_uw(struct cpumask *pd_mask, u64 power)
+{
+	return power;
+}
+#endif
 
 static u64 get_pd_power_uw(struct dtpm *dtpm)
 {
-- 
2.25.1


      reply	other threads:[~2025-03-10  2:59 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-06 19:34 [rafael-pm:bleeding-edge 103/108] drivers/powercap/dtpm_cpu.c:83:15: error: call to undeclared function 'sched_cpu_util'; ISO C99 and later do not support implicit function declarations kernel test robot
2025-03-10  2:56 ` Xuewen Yan [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250310025655.576-1-xuewen.yan@unisoc.com \
    --to=xuewen.yan@unisoc.com \
    --cc=daniel.lezcano@kernel.org \
    --cc=devel@acpica.org \
    --cc=di.shen@unisoc.com \
    --cc=jeson.gao@unisoc.com \
    --cc=ke.wang@unisoc.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=llvm@lists.linux.dev \
    --cc=lukasz.luba@arm.com \
    --cc=oe-kbuild-all@lists.linux.dev \
    --cc=rafael@kernel.org \
    --cc=rjw@rjwysocki.net \
    --cc=xuewen.yan94@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox