2023-07-26 07:29:31

by YingKun Meng

[permalink] [raw]
Subject: [PATCH] ASoC: loongson: mark OF related data as maybe unused

The ASoC Sound Card driver can be compile tested with !CONFIG_OF
making 'loongson_asoc_dt_ids' unused:

sound/soc/loongson/loongson_card.c:200:34: warning: unused variable 'loongson_asoc_dt_ids' [-Wunused-const-variable]

Here we solve it in the same way as [1].

[1] https://lore.kernel.org/all/[email protected]/

Reported-by: kernel test robot <[email protected]>
Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]
Fixes: d24028606e76 ("ASoC: loongson: Add Loongson ASoC Sound Card Support")
Signed-off-by: YingKun Meng <[email protected]>
---
sound/soc/loongson/loongson_card.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/soc/loongson/loongson_card.c b/sound/soc/loongson/loongson_card.c
index 9ded16329747..7dd7adc13484 100644
--- a/sound/soc/loongson/loongson_card.c
+++ b/sound/soc/loongson/loongson_card.c
@@ -197,7 +197,7 @@ static int loongson_asoc_card_probe(struct platform_device *pdev)
return ret;
}

-static const struct of_device_id loongson_asoc_dt_ids[] = {
+static const struct of_device_id loongson_asoc_dt_ids[] __maybe_unused = {
{ .compatible = "loongson,ls-audio-card" },
{ /* sentinel */ },
};
--
2.33.0



2023-07-26 07:48:59

by Xi Ruoyao

[permalink] [raw]
Subject: Re: [PATCH] ASoC: loongson: mark OF related data as maybe unused

On Wed, 2023-07-26 at 15:06 +0800, YingKun Meng wrote:
> The ASoC Sound Card driver can be compile tested with !CONFIG_OF
> making 'loongson_asoc_dt_ids' unused:
>
> sound/soc/loongson/loongson_card.c:200:34: warning: unused variable
> 'loongson_asoc_dt_ids' [-Wunused-const-variable]

Hmm, why not guard the definition with #ifdef CONFIG_OF instead?

Source text is first and foremost for the human reader, not for the
compiler, and an ifdef clearly shows the condition when the definition
is not used.

> Here we solve it in the same way as [1].
>
> [1] https://lore.kernel.org/all/[email protected]/
>
> Reported-by: kernel test robot <[email protected]>
> Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]
> Fixes: d24028606e76 ("ASoC: loongson: Add Loongson ASoC Sound Card Support")
> Signed-off-by: YingKun Meng <[email protected]>
> ---
>  sound/soc/loongson/loongson_card.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/sound/soc/loongson/loongson_card.c b/sound/soc/loongson/loongson_card.c
> index 9ded16329747..7dd7adc13484 100644
> --- a/sound/soc/loongson/loongson_card.c
> +++ b/sound/soc/loongson/loongson_card.c
> @@ -197,7 +197,7 @@ static int loongson_asoc_card_probe(struct platform_device *pdev)
>         return ret;
>  }
>  
> -static const struct of_device_id loongson_asoc_dt_ids[] = {
> +static const struct of_device_id loongson_asoc_dt_ids[] __maybe_unused = {
>         { .compatible = "loongson,ls-audio-card" },
>         { /* sentinel */ },
>  };

--
Xi Ruoyao <[email protected]>
School of Aerospace Science and Technology, Xidian University

2023-07-26 08:47:14

by Krzysztof Kozlowski

[permalink] [raw]
Subject: Re: [PATCH] ASoC: loongson: mark OF related data as maybe unused

On 26/07/2023 09:20, Xi Ruoyao wrote:
> On Wed, 2023-07-26 at 15:06 +0800, YingKun Meng wrote:
>> The ASoC Sound Card driver can be compile tested with !CONFIG_OF
>> making 'loongson_asoc_dt_ids' unused:
>>
>> sound/soc/loongson/loongson_card.c:200:34: warning: unused variable
>> 'loongson_asoc_dt_ids' [-Wunused-const-variable]
>
> Hmm, why not guard the definition with #ifdef CONFIG_OF instead?
>
> Source text is first and foremost for the human reader, not for the
> compiler, and an ifdef clearly shows the condition when the definition
> is not used.

Rather drop of_match_ptr so this can be used also on ACPI.

Best regards,
Krzysztof


2023-07-26 10:59:32

by YingKun Meng

[permalink] [raw]
Subject: Re: [PATCH] ASoC: loongson: mark OF related data as maybe unused


On 2023/7/26 16:05, Krzysztof Kozlowski wrote:
> On 26/07/2023 09:20, Xi Ruoyao wrote:
>> On Wed, 2023-07-26 at 15:06 +0800, YingKun Meng wrote:
>>> The ASoC Sound Card driver can be compile tested with !CONFIG_OF
>>> making 'loongson_asoc_dt_ids' unused:
>>>
>>> sound/soc/loongson/loongson_card.c:200:34: warning: unused variable
>>> 'loongson_asoc_dt_ids' [-Wunused-const-variable]
>> Hmm, why not guard the definition with #ifdef CONFIG_OF instead?
>>
>> Source text is first and foremost for the human reader, not for the
>> compiler, and an ifdef clearly shows the condition when the definition
>> is not used.
> Rather drop of_match_ptr so this can be used also on ACPI.

This is more reasonable.

Please ignore the the patch,i will resend a new one.


Thanks,
Yingkun