LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Masahiro Yamada <masahiroy@kernel.org>
To: "Péter Ujfalusi" <peter.ujfalusi@gmail.com>
Cc: Linux Kbuild mailing list <linux-kbuild@vger.kernel.org>,
	Arnd Bergmann <arnd@arndb.de>,
	"David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	Jaroslav Kysela <perex@perex.cz>,
	Kalle Valo <kvalo@codeaurora.org>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Luca Coelho <luciano.coelho@intel.com>,
	Mark Brown <broonie@kernel.org>, Takashi Iwai <tiwai@suse.com>,
	ALSA Development Mailing List <alsa-devel@alsa-project.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	linux-wireless@vger.kernel.org,
	Networking <netdev@vger.kernel.org>
Subject: Re: [PATCH] kconfig: forbid symbols that end with '_MODULE'
Date: Thu, 26 Aug 2021 11:28:24 +0900	[thread overview]
Message-ID: <CAK7LNATDMzR1DnwwAcQFHaKZeGVYDZ1oDKL-QOe_7DaB_yByAA@mail.gmail.com> (raw)
In-Reply-To: <9df591f6-53fc-4567-8758-0eb1be4eade5@gmail.com>

On Wed, Aug 25, 2021 at 8:59 PM Péter Ujfalusi <peter.ujfalusi@gmail.com> wrote:
>
> Hi,
>
> On 25/08/2021 07:16, Masahiro Yamada wrote:
> > Kconfig (syncconfig) generates include/generated/autoconf.h to make
> > CONFIG options available to the pre-processor.
> >
> > The macros are suffixed with '_MODULE' for symbols with the value 'm'.
> >
> > Here is a conflict; CONFIG_FOO=m results in '#define CONFIG_FOO_MODULE 1',
> > but CONFIG_FOO_MODULE=y also results in the same define.
> >
> > fixdep always assumes CONFIG_FOO_MODULE comes from CONFIG_FOO=m, so the
> > dependency is not properly tracked for symbols that end with '_MODULE'.
> >
> > This commit makes Kconfig error out if it finds a symbol suffixed with
> > '_MODULE'. This restriction does not exist if the module feature is not
> > supported (at least from the Kconfig perspective).
> >
> > It detected one error:
> >   error: SND_SOC_DM365_VOICE_CODEC_MODULE: symbol name must not end with '_MODULE'
> >
> > Rename it to SND_SOC_DM365_VOICE_CODEC_MODULAR. Commit 147162f57515
> > ("ASoC: ti: fix SND_SOC_DM365_VOICE_CODEC dependencies") added it for
> > internal use. So, this renaming has no impact on users.
> >
> > Remove a comment from drivers/net/wireless/intel/iwlwifi/Kconfig since
> > this is a hard error now.
> >
> > Add a comment to include/linux/kconfig.h in order not to worry observant
> > developers.
> >
> > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> > ---
> >
> >  drivers/net/wireless/intel/iwlwifi/Kconfig |  1 -
> >  include/linux/kconfig.h                    |  3 ++
> >  scripts/kconfig/parser.y                   | 40 +++++++++++++++++++++-
> >  sound/soc/ti/Kconfig                       |  2 +-
> >  4 files changed, 43 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/net/wireless/intel/iwlwifi/Kconfig b/drivers/net/wireless/intel/iwlwifi/Kconfig
> > index 1085afbefba8..5b238243617c 100644
> > --- a/drivers/net/wireless/intel/iwlwifi/Kconfig
> > +++ b/drivers/net/wireless/intel/iwlwifi/Kconfig
> > @@ -70,7 +70,6 @@ config IWLMVM
> >         of the devices that use this firmware is available here:
> >         https://wireless.wiki.kernel.org/en/users/drivers/iwlwifi#firmware
> >
> > -# don't call it _MODULE -- will confuse Kconfig/fixdep/...
> >  config IWLWIFI_OPMODE_MODULAR
> >       bool
> >       default y if IWLDVM=m
> > diff --git a/include/linux/kconfig.h b/include/linux/kconfig.h
> > index 20d1079e92b4..54f677e742fe 100644
> > --- a/include/linux/kconfig.h
> > +++ b/include/linux/kconfig.h
> > @@ -53,6 +53,9 @@
> >   * IS_MODULE(CONFIG_FOO) evaluates to 1 if CONFIG_FOO is set to 'm', 0
> >   * otherwise.  CONFIG_FOO=m results in "#define CONFIG_FOO_MODULE 1" in
> >   * autoconf.h.
> > + * CONFIG_FOO_MODULE=y would also result in "#define CONFIG_FOO_MODULE 1",
> > + * but Kconfig forbids symbol names that end with '_MODULE', so that would
> > + * not happen.
> >   */
> >  #define IS_MODULE(option) __is_defined(option##_MODULE)
> >
> > diff --git a/scripts/kconfig/parser.y b/scripts/kconfig/parser.y
> > index 2af7ce4e1531..b0f73f74ccd3 100644
> > --- a/scripts/kconfig/parser.y
> > +++ b/scripts/kconfig/parser.y
> > @@ -475,6 +475,37 @@ assign_val:
> >
> >  %%
> >
> > +/*
> > + * Symbols suffixed with '_MODULE' would cause a macro conflict in autoconf.h,
> > + * and also confuse the interaction between syncconfig and fixdep.
> > + * Error out if a symbol with the '_MODULE' suffix is found.
> > + */
> > +static int sym_check_name(struct symbol *sym)
> > +{
> > +     static const char *suffix = "_MODULE";
> > +     static const size_t suffix_len = strlen("_MODULE");
> > +     char *name;
> > +     size_t len;
> > +
> > +     name = sym->name;
> > +
> > +     if (!name)
> > +             return 0;
> > +
> > +     len = strlen(name);
> > +
> > +     if (len < suffix_len)
> > +             return 0;
> > +
> > +     if (strcmp(name + len - suffix_len, suffix))
> > +             return 0;
> > +
> > +     fprintf(stderr, "error: %s: symbol name must not end with '%s'\n",
> > +             name, suffix);
> > +
> > +     return -1;
> > +}
> > +
> >  void conf_parse(const char *name)
> >  {
> >       struct symbol *sym;
> > @@ -493,8 +524,15 @@ void conf_parse(const char *name)
> >
> >       if (yynerrs)
> >               exit(1);
> > -     if (!modules_sym)
> > +
> > +     if (modules_sym) {
> > +             for_all_symbols(i, sym) {
> > +                     if (sym_check_name(sym))
> > +                             yynerrs++;
> > +             }
> > +     } else {
> >               modules_sym = sym_find( "n" );
> > +     }
> >
> >       if (!menu_has_prompt(&rootmenu)) {
> >               current_entry = &rootmenu;
> > diff --git a/sound/soc/ti/Kconfig b/sound/soc/ti/Kconfig
> > index 698d7bc84dcf..c56a5789056f 100644
> > --- a/sound/soc/ti/Kconfig
> > +++ b/sound/soc/ti/Kconfig
> > @@ -211,7 +211,7 @@ config SND_SOC_DM365_VOICE_CODEC
> >         Say Y if you want to add support for SoC On-chip voice codec
> >  endchoice
> >
> > -config SND_SOC_DM365_VOICE_CODEC_MODULE
> > +config SND_SOC_DM365_VOICE_CODEC_MODULAR
>
> This Kconfig option is only used to select the codecs needed for the
> voice mode, I think it would be better to use something like
>
> SND_SOC_DM365_SELECT_VOICE_CODECS ?


I do not have a strong opinion.
I am fine with any name unless it ends with _MODULE.


The sound subsystem maintainers and Arnd,
author of 147162f575152db800 are CC'ed.

If they suggest a better name, I'd be happy to adopt it.



-- 
Best Regards
Masahiro Yamada

  reply	other threads:[~2021-08-26  2:29 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-25  4:16 Masahiro Yamada
2021-08-25  9:52 ` Mark Brown
2021-08-25 11:59 ` Péter Ujfalusi
2021-08-26  2:28   ` Masahiro Yamada [this message]
2021-09-01  7:07     ` Péter Ujfalusi
2021-08-25 15:34 ` Boris Kolpackov
2021-08-26  2:24   ` Masahiro Yamada
2021-08-26 12:16     ` Boris Kolpackov

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=CAK7LNATDMzR1DnwwAcQFHaKZeGVYDZ1oDKL-QOe_7DaB_yByAA@mail.gmail.com \
    --to=masahiroy@kernel.org \
    --cc=alsa-devel@alsa-project.org \
    --cc=arnd@arndb.de \
    --cc=broonie@kernel.org \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=kvalo@codeaurora.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=luciano.coelho@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=peter.ujfalusi@gmail.com \
    --cc=tiwai@suse.com \
    --subject='Re: [PATCH] kconfig: forbid symbols that end with '\''_MODULE'\''' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).