lkml.org 
[lkml]   [2022]   [Oct]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: drivers/ata/ahci_st.c:229:34: warning: unused variable 'st_ahci_match'
From
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

\
 
 \ /
  Last update: 2022-10-13 09:49    [W:0.536 / U:0.056 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site