From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Richard Weinberger <richard@nod.at>,
Vignesh Raghavendra <vigneshr@ti.com>,
Tudor Ambarus <Tudor.Ambarus@microchip.com>,
Pratyush Yadav <p.yadav@ti.com>, Michael Walle <michael@walle.cc>,
MTD Maling List <linux-mtd@lists.infradead.org>
Subject: Re: [PATCH] mtd: Replace the expert mode symbols with a single helper
Date: Thu, 27 Jan 2022 13:22:24 +0100 [thread overview]
Message-ID: <20220127132224.0d095bc6@xps13> (raw)
In-Reply-To: <CAMuHMdWkr8FFC3KKWY6A1Csz9Jz6MB7EmsTgs2miRfntwVoeoA@mail.gmail.com>
Hi Geert,
geert@linux-m68k.org wrote on Thu, 27 Jan 2022 13:01:18 +0100:
> Hi Miquel,
>
> On Thu, Jan 27, 2022 at 12:08 PM Miquel Raynal
> <miquel.raynal@bootlin.com> wrote:
> > Reduce the number of exported symbols by replacing:
> > - mtd_expert_analysis_warning (the error string)
> > - mtd_expert_analysis_mode (the boolean)
> > with a single helper:
> > - mtd_check_expert_analysis_mode
> >
> > Calling this helper will both check/return the content of the internal
> > boolean -which is not exported anymore- and as well WARN_ONCE() the
> > user.
> >
> > While on this function, make the error string local to the helper and
> > set it const.
> >
> > Update all the consumers.
> >
> > Suggested-by: Geert Uytterhoeven <geert@linux-m68k.org>
> > Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
>
> Thanks for your patch!
>
> > --- a/drivers/mtd/mtdcore.c
> > +++ b/drivers/mtd/mtdcore.c
> > @@ -358,6 +358,19 @@ static int mtd_partname_debug_show(struct seq_file *s, void *p)
> >
> > DEFINE_SHOW_ATTRIBUTE(mtd_partname_debug);
> >
> > +static bool mtd_expert_analysis_mode;
> > +
> > +bool mtd_check_expert_analysis_mode(void)
> > +{
> > + const char *mtd_expert_analysis_warning =
> > + "Bad block checks have been entirely disabled.\n"
> > + "This is only reserved for post-mortem forensics and debug purposes.\n"
> > + "Never enable this mode if you do not know what you are doing!\n";
> > +
> > + return WARN_ONCE(mtd_expert_analysis_mode, mtd_expert_analysis_warning);
> > +}
> > +EXPORT_SYMBOL_GPL(mtd_check_expert_analysis_mode);
>
> Please put this inside #ifndef CONFIG_DEBUG_FS, as it wastes
> 176 bytes for the message, and probably the same for the WARN_ONCE(),
> for production kernels.
Yes I will do that. I sent this version before seeing your first answer
about the #ifdef request and arguing about it.
>
> > +
> > static struct dentry *dfs_dir_mtd;
> >
> > static void mtd_debugfs_populate(struct mtd_info *mtd)
>
> > --- a/include/linux/mtd/mtd.h
> > +++ b/include/linux/mtd/mtd.h
> > @@ -711,7 +711,6 @@ static inline int mtd_is_bitflip_or_eccerr(int err) {
> >
> > unsigned mtd_mmap_capabilities(struct mtd_info *mtd);
> >
> > -extern char *mtd_expert_analysis_warning;
> > -extern bool mtd_expert_analysis_mode;
> > +bool mtd_check_expert_analysis_mode(void);
>
> #ifdef CONFIG_DEBUG_FS
> bool mtd_check_expert_analysis_mode(void);
> #else
> static inline bool mtd_check_expert_analysis_mode(void) { return false; }
> #endif
>
> >
> > #endif /* __MTD_MTD_H__ */
>
> Gr{oetje,eeting}s,
>
> Geert
>
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
>
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like that.
> -- Linus Torvalds
Thanks,
Miquèl
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
prev parent reply other threads:[~2022-01-27 12:23 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-27 11:08 [PATCH] mtd: Replace the expert mode symbols with a single helper Miquel Raynal
2022-01-27 12:01 ` Geert Uytterhoeven
2022-01-27 12:22 ` Miquel Raynal [this message]
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=20220127132224.0d095bc6@xps13 \
--to=miquel.raynal@bootlin.com \
--cc=Tudor.Ambarus@microchip.com \
--cc=geert@linux-m68k.org \
--cc=linux-mtd@lists.infradead.org \
--cc=michael@walle.cc \
--cc=p.yadav@ti.com \
--cc=richard@nod.at \
--cc=vigneshr@ti.com \
/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;
as well as URLs for NNTP newsgroup(s).