diff mbox series

[v1,4/5] clk: tegra: Add stubs needed for compile testing

Message ID 20210606222817.12388-5-digetx@gmail.com (mailing list archive)
State Not Applicable, archived
Headers show
Series Compile-test NVIDIA Tegra CPUIDLE driver | expand

Commit Message

Dmitry Osipenko June 6, 2021, 10:28 p.m. UTC
Add stubs needed for compile-testing of tegra-cpuidle driver.

Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
 include/linux/clk/tegra.h | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Daniel Lezcano June 16, 2021, 7:08 p.m. UTC | #1
On 07/06/2021 00:28, Dmitry Osipenko wrote:
> Add stubs needed for compile-testing of tegra-cpuidle driver.
> 
> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
> ---
>  include/linux/clk/tegra.h | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/include/linux/clk/tegra.h b/include/linux/clk/tegra.h
> index d128ad1570aa..9bd06d8a5436 100644
> --- a/include/linux/clk/tegra.h
> +++ b/include/linux/clk/tegra.h
> @@ -42,7 +42,11 @@ struct tegra_cpu_car_ops {
>  #endif
>  };
>  
> +#ifdef CONFIG_ARCH_TEGRA
>  extern struct tegra_cpu_car_ops *tegra_cpu_car_ops;
> +#else
> +static struct tegra_cpu_car_ops *tegra_cpu_car_ops __maybe_unused;
> +#endif

Why not just have __may_be_unused without the #ifdef ?

>  static inline void tegra_wait_cpu_in_reset(u32 cpu)
>  {
>
Dmitry Osipenko June 16, 2021, 7:35 p.m. UTC | #2
16.06.2021 22:08, Daniel Lezcano пишет:
> On 07/06/2021 00:28, Dmitry Osipenko wrote:
>> Add stubs needed for compile-testing of tegra-cpuidle driver.
>>
>> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
>> ---
>>  include/linux/clk/tegra.h | 4 ++++
>>  1 file changed, 4 insertions(+)
>>
>> diff --git a/include/linux/clk/tegra.h b/include/linux/clk/tegra.h
>> index d128ad1570aa..9bd06d8a5436 100644
>> --- a/include/linux/clk/tegra.h
>> +++ b/include/linux/clk/tegra.h
>> @@ -42,7 +42,11 @@ struct tegra_cpu_car_ops {
>>  #endif
>>  };
>>  
>> +#ifdef CONFIG_ARCH_TEGRA
>>  extern struct tegra_cpu_car_ops *tegra_cpu_car_ops;
>> +#else
>> +static struct tegra_cpu_car_ops *tegra_cpu_car_ops __maybe_unused;
>> +#endif
> 
> Why not just have __may_be_unused without the #ifdef ?

The first variant is an external symbol. The tegra_cpu_car_ops* must be
specified somewhere, otherwise linkage will fail. The __maybe_unused
won't help here because symbol must be resolved by linker for the code
where it's used.

The latter variant is a static NULL pointer marked as __maybe_unused.
This allows to include header file universally without producing
compiler warning about the unused static variable during compile-testing.
diff mbox series

Patch

diff --git a/include/linux/clk/tegra.h b/include/linux/clk/tegra.h
index d128ad1570aa..9bd06d8a5436 100644
--- a/include/linux/clk/tegra.h
+++ b/include/linux/clk/tegra.h
@@ -42,7 +42,11 @@  struct tegra_cpu_car_ops {
 #endif
 };
 
+#ifdef CONFIG_ARCH_TEGRA
 extern struct tegra_cpu_car_ops *tegra_cpu_car_ops;
+#else
+static struct tegra_cpu_car_ops *tegra_cpu_car_ops __maybe_unused;
+#endif
 
 static inline void tegra_wait_cpu_in_reset(u32 cpu)
 {