All of lore.kernel.org
 help / color / mirror / Atom feed
From: Li Chen <me@linux.beauty>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Li Chen <lchen@ambarella.com>, Jonathan Corbet <corbet@lwn.net>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Randy Dunlap <rdunlap@infradead.org>,
	"open list:DOCUMENTATION" <linux-doc@vger.kernel.org>,
	open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 01/15] debugfs: allow to use regmap for print regs
Date: Mon, 23 Jan 2023 21:47:37 +0800	[thread overview]
Message-ID: <87a629icqu.wl-me@linux.beauty> (raw)
In-Reply-To: <Y851DWfj+hZIiR38@kroah.com>


Hi Greg,

On Mon, 23 Jan 2023 19:52:45 +0800,
Greg Kroah-Hartman wrote:
>
> On Mon, Jan 23, 2023 at 03:32:16PM +0800, Li Chen wrote:
> > Currently, debugfs_regset32 only contains void __iomem *base,
> > and it is not friendly to regmap user.
> >
> > Let's add regmap to debugfs_regset32, and add regmap
> > support to debugfs_print_reg32.
> >
> > Signed-off-by: Li Chen <me@linux.beauty>
> > Change-Id: I8ef015ed0906a4ad85b7592f771dcf64c23f7832
>
> No change-id please.

Sorry, my bad, will remove it in v2.

> > ---
> >  Documentation/filesystems/debugfs.rst |  2 ++
> >  fs/debugfs/file.c                     | 43 ++++++++++++++++++++++++++-
> >  include/linux/debugfs.h               | 11 +++++++
> >  3 files changed, 55 insertions(+), 1 deletion(-)
> >
> > diff --git a/Documentation/filesystems/debugfs.rst b/Documentation/filesystems/debugfs.rst
> > index dc35da8b8792..b2c76ac3a333 100644
> > --- a/Documentation/filesystems/debugfs.rst
> > +++ b/Documentation/filesystems/debugfs.rst
> > @@ -178,6 +178,8 @@ file::
> >
> >      void debugfs_print_regs32(struct seq_file *s, const struct debugfs_reg32 *regs,
> >  			 int nregs, void __iomem *base, char *prefix);
> > +    void debugfs_print_regmap_regs32(struct seq_file *s, const struct debugfs_reg32 *regs,
> > +			 int nregs, struct regmap *regmap*, char *prefix);
>
> One too many "*" characters on that last line, right?

Good catch! I will remove it in V2.

> >
> >  The "base" argument may be 0, but you may want to build the reg32 array
> >  using __stringify, and a number of register names (macros) are actually
> > diff --git a/fs/debugfs/file.c b/fs/debugfs/file.c
> > index b54f470e0d03..2fb792843b30 100644
> > --- a/fs/debugfs/file.c
> > +++ b/fs/debugfs/file.c
> > @@ -1137,14 +1137,55 @@ void debugfs_print_regs32(struct seq_file *s, const struct debugfs_reg32 *regs,
> >  }
> >  EXPORT_SYMBOL_GPL(debugfs_print_regs32);
> >
> > +/**
> > + * debugfs_print_regmap_regs32 - use seq_print to describe a set of registers
> > + * @s: the seq_file structure being used to generate output
> > + * @regs: an array if struct debugfs_reg32 structures
> > + * @nregs: the length of the above array
> > + * @regmap: regmap to be used in reading the registers
> > + * @prefix: a string to be prefixed to every output line
> > + *
> > + * This function outputs a text block describing the current values of
> > + * some 32-bit hardware registers. It is meant to be used within debugfs
> > + * files based on seq_file that need to show registers, intermixed with other
> > + * information. The prefix argument may be used to specify a leading string,
> > + * because some peripherals have several blocks of identical registers,
> > + * for example configuration of dma channels
> > + */
> > +void debugfs_print_regmap_regs32(struct seq_file *s, const struct debugfs_reg32 *regs,
> > +			  int nregs, struct regmap *regmap, char *prefix)
> > +{
> > +	int i;
> > +	u32 val;
> > +
> > +	for (i = 0; i < nregs; i++, regs++) {
> > +		if (prefix)
> > +			seq_printf(s, "%s", prefix);
> > +		regmap_read(regmap, regs->offset, &val);
> > +		seq_printf(s, "%s = 0x%08x\n", regs->name, val);
> > +		if (seq_has_overflowed(s))
> > +			break;
> > +	}
> > +}
> > +EXPORT_SYMBOL_GPL(debugfs_print_regmap_regs32);
> > +
> >  static int debugfs_regset32_show(struct seq_file *s, void *data)
> >  {
> >  	struct debugfs_regset32 *regset = s->private;
> >
> > +	void __iomem *base = regset->base;
> > +	struct regmap *regmap = regset->regmap;
>
> Why the extra blank line?  Did you run checkpatch?

Yeah, I do checkpatch & sparse(coccinelle crash somehow)
for all my patches(but forget to remove gerrit's Change-ID finally, sorry).

checkpatch didn't find this extra blank line.

I will remove it in v2, thanks!

> And it's generally not considered a good idea to dereference a pointer
> _before_ it is checked.  It will not crash, but static checkers will
> have a field day with it.

Ok, will check regset before access in v2.

> > +
> > +	if ((regmap && base) || (!regmap && !base))
> > +		return -EINVAL;
> > +
> >  	if (regset->dev)
> >  		pm_runtime_get_sync(regset->dev);
> >
> > -	debugfs_print_regs32(s, regset->regs, regset->nregs, regset->base, "");
> > +	if (base)
> > +		debugfs_print_regs32(s, regset->regs, regset->nregs, base, "");
> > +	else
> > +		debugfs_print_regmap_regs32(s, regset->regs, regset->nregs, regmap, "");
> >
> >  	if (regset->dev)
> >  		pm_runtime_put(regset->dev);
> > diff --git a/include/linux/debugfs.h b/include/linux/debugfs.h
> > index ea2d919fd9c7..87dfea6a25a0 100644
> > --- a/include/linux/debugfs.h
> > +++ b/include/linux/debugfs.h
> > @@ -17,6 +17,7 @@
> >
> >  #include <linux/types.h>
> >  #include <linux/compiler.h>
> > +#include <linux/regmap.h>
>
> No need to include this here, just provide a prototype for "struct
> regmap" and all will be fine.

Well noted, I will forward declare "struct regmap" in debugfs.h,
and move regmap.h to debugfs.c(regmap_read is used here).

Thanks for your review.

Regards,
Li

      reply	other threads:[~2023-01-23 13:49 UTC|newest]

Thread overview: 113+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-23  7:32 [PATCH 00/15] Ambarella S6LM SoC bring-up Li Chen
2023-01-23  7:32 ` Li Chen
2023-01-23  7:32 ` Li Chen
2023-01-23  7:32 ` [PATCH 02/15] dt-bindings: vendor-prefixes: add Ambarella prefix Li Chen
2023-01-23  8:02   ` Krzysztof Kozlowski
2023-01-23  7:32 ` [PATCH 05/15] arm64: Kconfig: Introduce CONFIG_ARCH_AMBARELLA Li Chen
2023-01-23  7:32   ` Li Chen
2023-01-23  8:32   ` Arnd Bergmann
2023-01-23  8:32     ` Arnd Bergmann
2023-01-23  7:32 ` [PATCH 10/15] serial: ambarella: add support for Ambarella uart_port Li Chen
2023-01-23  9:50   ` Greg Kroah-Hartman
2023-01-23  9:50     ` Greg Kroah-Hartman
2023-01-23  9:50     ` Greg Kroah-Hartman
2023-01-23  9:51   ` Greg Kroah-Hartman
2023-01-23  9:51     ` Greg Kroah-Hartman
2023-01-23  9:51     ` Greg Kroah-Hartman
2023-01-25 10:01     ` Li Chen
2023-01-25 10:01       ` Li Chen
2023-01-25 10:01       ` Li Chen
     [not found] ` <20230123073305.149940-4-lchen@ambarella.com>
2023-01-23  8:03   ` [PATCH 03/15] dt-bindings: arm: ambarella: Add binding for Ambarella ARM platforms Krzysztof Kozlowski
2023-01-23  8:03     ` Krzysztof Kozlowski
2023-01-23 13:58     ` Li Chen
2023-01-23 13:58       ` Li Chen
     [not found] ` <20230123073305.149940-5-lchen@ambarella.com>
2023-01-23  8:07   ` [PATCH 04/15] dt-bindings: arm: add support for Ambarella SoC Krzysztof Kozlowski
2023-01-23  8:07     ` Krzysztof Kozlowski
2023-01-23 15:09     ` Li Chen
2023-01-23 15:09       ` Li Chen
2023-01-23 15:52       ` Krzysztof Kozlowski
2023-01-23 15:52         ` Krzysztof Kozlowski
     [not found] ` <20230123073305.149940-8-lchen@ambarella.com>
2023-01-23  8:11   ` [PATCH 07/15] dt-bindings: clock: Add Ambarella clock bindings Krzysztof Kozlowski
2023-01-23  8:11     ` Krzysztof Kozlowski
2023-01-25  9:28     ` Li Chen
2023-01-25  9:28       ` Li Chen
2023-01-25  9:55       ` Krzysztof Kozlowski
2023-01-25  9:55         ` Krzysztof Kozlowski
2023-01-25 12:06         ` Li Chen
2023-01-25 12:06           ` Li Chen
2023-01-25 12:14           ` Krzysztof Kozlowski
2023-01-25 12:14             ` Krzysztof Kozlowski
2023-01-25 13:40             ` Li Chen
2023-01-25 13:40               ` Li Chen
2023-01-26 11:29               ` Krzysztof Kozlowski
2023-01-26 11:29                 ` Krzysztof Kozlowski
2023-01-27 14:48                 ` Li Chen
2023-01-27 14:48                   ` Li Chen
2023-01-27 15:08                   ` Krzysztof Kozlowski
2023-01-27 15:08                     ` Krzysztof Kozlowski
2023-01-28  9:42                     ` Li Chen
2023-01-28  9:42                       ` Li Chen
2023-01-28 10:08                       ` Krzysztof Kozlowski
2023-01-28 10:08                         ` Krzysztof Kozlowski
2023-01-28 10:11                         ` Li Chen
2023-01-28 10:11                           ` Li Chen
2023-02-06 11:28                     ` Li Chen
2023-02-06 11:28                       ` Li Chen
2023-02-06 13:41                       ` Krzysztof Kozlowski
2023-02-06 13:41                         ` Krzysztof Kozlowski
2023-02-06 14:57                         ` Li Chen
2023-02-06 14:57                           ` Li Chen
2023-02-08 10:27                           ` Krzysztof Kozlowski
2023-02-08 10:27                             ` Krzysztof Kozlowski
2023-01-27 15:11                   ` Krzysztof Kozlowski
2023-01-27 15:11                     ` Krzysztof Kozlowski
2023-01-28  9:45                     ` Li Chen
2023-01-28  9:45                       ` Li Chen
     [not found] ` <20230123073305.149940-10-lchen@ambarella.com>
2023-01-23  8:11   ` [PATCH 09/15] dt-bindings: serial: add support for Ambarella Krzysztof Kozlowski
2023-01-23  8:11     ` Krzysztof Kozlowski
2023-01-25  9:54     ` Li Chen
2023-01-25  9:54       ` Li Chen
2023-01-25  9:56       ` Krzysztof Kozlowski
2023-01-25  9:56         ` Krzysztof Kozlowski
2023-01-28  9:22         ` Li Chen
2023-01-28  9:22           ` Li Chen
     [not found] ` <20230123073305.149940-12-lchen@ambarella.com>
2023-01-23  8:13   ` [PATCH 11/15] dt-bindings: mtd: Add binding " Krzysztof Kozlowski
2023-01-23  8:13     ` Krzysztof Kozlowski
2023-01-23  8:13     ` Krzysztof Kozlowski
     [not found] ` <20230123073305.149940-14-lchen@ambarella.com>
2023-01-23  8:13   ` [PATCH 13/15] dt-bindings: pinctrl: add support " Krzysztof Kozlowski
2023-01-23  8:13     ` Krzysztof Kozlowski
2023-01-23 12:32   ` Linus Walleij
2023-01-23 12:32     ` Linus Walleij
2023-01-28 10:05     ` Li Chen
2023-01-28 10:05       ` Li Chen
     [not found] ` <20230123073305.149940-16-lchen@ambarella.com>
2023-01-23  8:20   ` [PATCH 15/15] arm64: dts: ambarella: introduce Ambarella s6lm SoC Krzysztof Kozlowski
2023-01-23  8:20     ` Krzysztof Kozlowski
     [not found] ` <20230123073305.149940-13-lchen@ambarella.com>
2023-01-23  8:32   ` [PATCH 12/15] mtd: nand: add Ambarella nand support Miquel Raynal
2023-01-23  8:32     ` Miquel Raynal
2023-01-23  8:32     ` Miquel Raynal
2023-01-23  8:39 ` [PATCH 00/15] Ambarella S6LM SoC bring-up Arnd Bergmann
2023-01-23  8:39   ` Arnd Bergmann
2023-01-23  8:39   ` Arnd Bergmann
2023-01-24  2:08   ` Bagas Sanjaya
2023-01-24  2:08     ` Bagas Sanjaya
2023-01-24  2:08     ` Bagas Sanjaya
2023-01-25  2:24   ` Li Chen
2023-01-25  2:24     ` Li Chen
     [not found] ` <20230123073305.149940-7-lchen@ambarella.com>
2023-01-23  8:29   ` [PATCH 06/15] soc: add Ambarella driver Arnd Bergmann
2023-01-23  8:29     ` Arnd Bergmann
2023-01-24  7:58     ` Li Chen
2023-01-24  7:58       ` Li Chen
2023-01-24 15:46       ` Arnd Bergmann
2023-01-24 15:46         ` Arnd Bergmann
2023-01-29  7:21         ` Li Chen
2023-01-29  7:21           ` Li Chen
2023-01-23 11:48   ` Conor.Dooley
2023-01-23 11:48     ` Conor.Dooley
2023-01-24  8:27     ` Li Chen
2023-01-24  8:27       ` Li Chen
2023-01-24  8:46       ` Conor.Dooley
2023-01-24  8:46         ` Conor.Dooley
2023-01-24 14:24         ` Li Chen
2023-01-24 14:24           ` Li Chen
     [not found] ` <20230123073305.149940-2-lchen@ambarella.com>
2023-01-23 11:52   ` [PATCH 01/15] debugfs: allow to use regmap for print regs Greg Kroah-Hartman
2023-01-23 13:47     ` Li Chen [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=87a629icqu.wl-me@linux.beauty \
    --to=me@linux.beauty \
    --cc=corbet@lwn.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=lchen@ambarella.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=rdunlap@infradead.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.