[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <8f9304d0-5f28-7378-626b-d734fa7a39a0@opensource.wdc.com>
Date: Thu, 13 Oct 2022 16:48:30 +0900
From: Damien Le Moal <damien.lemoal@...nsource.wdc.com>
To: Arnd Bergmann <arnd@...db.de>,
Thomas Bogendoerfer <tsbogend@...ha.franken.de>,
linux-mips@...r.kernel.org
Cc: llvm@...ts.linux.dev, kbuild-all@...ts.01.org,
linux-kernel@...r.kernel.org
Subject: Re: drivers/ata/ahci_st.c:229:34: warning: unused variable
'st_ahci_match'
On 2022/10/13 16:33, Arnd Bergmann wrote:
> On Thu, Oct 13, 2022, at 8:13 AM, Damien Le Moal wrote:
>> On 10/12/22 15:37, kernel test robot wrote:
>
>> I am at a loss with this one... There are plenty of patterns similar to
>> drivers/ata/ahci_st.c doing something like:
>>
>> static const struct of_device_id st_ahci_match[] = {
>>
>> { .compatible = "st,ahci", },
>>
>> { /* sentinel */ }
>>
>> };
>>
>> MODULE_DEVICE_TABLE(of, st_ahci_match);
>>
>> For instance, in drivers/pwm/pwm-sti.c, we have:
>>
>>
>> And countless others like this for STI and other arch too.
>>
>> So if CONFIG_MODULE is not enabled, how come we are not submerged with
>> warnings about unused variables ? Is mips arch special in this regard ?
>> Or am I missing something ?
>
> It has nothing to do with MIPS, the problem is
>
> .of_match_table = of_match_ptr(st_ahci_match),
>
> The 'of_match_ptr()' sets the pointer to NULL when CONFIG_OF is
> disabled, which avoids a build failure when st_ahci_match[]
> itself is in an #ifdef.
>
> In this driver, there is no #ifdef around st_ahci_match[], so we
> simply want
>
> .of_match_table = st_ahci_match,
>
> The thing with the MODULE_DEVICE_TABLE() is that it would
> create another reference if CONFIG_MODULE is enabled, but not
> for a built-in driver, so you only get this type of warning
> for randconfig builds that have the driver built-in and OF
> disabled.
>
> It's a common mistake, and we should probably remove most
> of the of_match_ptr() references as you rarely have drivers
> that optionally use OF support but benefit from compiling
> that support out on kernels without OF.
Got it. Thanks for the info !
Will patch this and check other ata drivers for the same issue.
--
Damien Le Moal
Western Digital Research
Powered by blists - more mailing lists