From: "Arnd Bergmann" <arnd@arndb.de>
To: "Damien Le Moal" <damien.lemoal@opensource.wdc.com>,
"Thomas Bogendoerfer" <tsbogend@alpha.franken.de>,
linux-mips@vger.kernel.org
Cc: llvm@lists.linux.dev, kbuild-all@lists.01.org,
linux-kernel@vger.kernel.org
Subject: Re: drivers/ata/ahci_st.c:229:34: warning: unused variable 'st_ahci_match'
Date: Thu, 13 Oct 2022 09:33:29 +0200 [thread overview]
Message-ID: <4429d1ec-579e-4b0d-a8d8-06b9a5877a9c@app.fastmail.com> (raw)
In-Reply-To: <4517c95f-1dad-5a8c-5202-073d0a7eff29@opensource.wdc.com>
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.
Arnd
next prev parent reply other threads:[~2022-10-13 7:33 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-12 6:37 kernel test robot
2022-10-13 6:13 ` Damien Le Moal
2022-10-13 7:33 ` Arnd Bergmann [this message]
2022-10-13 7:48 ` Damien Le Moal
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=4429d1ec-579e-4b0d-a8d8-06b9a5877a9c@app.fastmail.com \
--to=arnd@arndb.de \
--cc=damien.lemoal@opensource.wdc.com \
--cc=kbuild-all@lists.01.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=tsbogend@alpha.franken.de \
/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
all inboxes | Powered by JetHome®