Re: [PATCH] regulator: core: Streamline debugfs operations

From: Geert Uytterhoeven
Date: Wed May 24 2023 - 02:43:04 EST


Hi Mark,

On Tue, May 23, 2023 at 5:16 PM Mark Brown <broonie@xxxxxxxxxx> wrote:
> On Tue, May 23, 2023 at 05:03:58PM +0200, Geert Uytterhoeven wrote:
>
> > - if (!regulator->debugfs) {
> > + if (IS_ERR(regulator->debugfs))
> > rdev_dbg(rdev, "Failed to create debugfs directory\n");
> > - } else {
> > - debugfs_create_u32("uA_load", 0444, regulator->debugfs,
> > - &regulator->uA_load);
> > - }
> > +
> > + debugfs_create_u32("uA_load", 0444, regulator->debugfs,
> > + &regulator->uA_load);
>
> No, it's actually useful to not just dump these files in the root
> directory if we fail to create the per regulator directory.

If regulator->debugfs is an error, no files are dumped in the root
directory.

By design, all debugfs functions are no-ops when passed an error,
cfr. the comment quoted above:

Other debugfs functions handle the fact that the "dentry"
passed to them could be an error and they don't crash in that case.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx

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