From: Sascha Hauer <sha@pengutronix.de>
To: Ahmad Fatoum <a.fatoum@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 1/2] of: base: factor out duplication for property formatting
Date: Mon, 8 Aug 2022 13:18:49 +0200 [thread overview]
Message-ID: <20220808111849.GE7333@pengutronix.de> (raw)
In-Reply-To: <20220808065639.453483-1-a.fatoum@pengutronix.de>
On Mon, Aug 08, 2022 at 08:56:38AM +0200, Ahmad Fatoum wrote:
> We have the same chunk of code with minuscule difference in both
> __of_print_nodes and __of_print_property. Factor it out to simplify
> the follow-up commit.
>
> No functional change.
>
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
> drivers/of/base.c | 33 +++++++++++++++++++--------------
> 1 file changed, 19 insertions(+), 14 deletions(-)
Applied, thanks
Sascha
>
> diff --git a/drivers/of/base.c b/drivers/of/base.c
> index 101b2f74c74f..ac5a14f49919 100644
> --- a/drivers/of/base.c
> +++ b/drivers/of/base.c
> @@ -2006,6 +2006,22 @@ int of_property_read_string_helper(const struct device_node *np,
> return i <= 0 ? -ENODATA : i;
> }
>
> +static void __of_print_property_prefixed(const struct property *p, int indent,
> + const char *prefix)
> +{
> + unsigned length;
> +
> + printf("%s%*s%s", prefix, indent * 8, "", p->name);
> +
> + length = p->length;
> + if (length) {
> + printf(" = ");
> + of_print_property(of_property_get_value(p), length);
> + }
> +
> + printf(";\n");
> +}
> +
> static int __of_print_nodes(struct device_node *node, int indent, const char *prefix)
> {
> struct device_node *n;
> @@ -2020,14 +2036,8 @@ static int __of_print_nodes(struct device_node *node, int indent, const char *pr
>
> printf("%s%*s%s%s\n", prefix, indent * 8, "", node->name, node->name ? " {" : "{");
>
> - list_for_each_entry(p, &node->properties, list) {
> - printf("%s%*s%s", prefix, (indent + 1) * 8, "", p->name);
> - if (p->length) {
> - printf(" = ");
> - of_print_property(of_property_get_value(p), p->length);
> - }
> - printf(";\n");
> - }
> + list_for_each_entry(p, &node->properties, list)
> + __of_print_property_prefixed(p, indent + 1, prefix);
>
> if (ctrlc())
> return -EINTR;
> @@ -2049,12 +2059,7 @@ void of_print_nodes(struct device_node *node, int indent)
>
> static void __of_print_property(struct property *p, int indent)
> {
> - printf("%*s%s", indent * 8, "", p->name);
> - if (p->length) {
> - printf(" = ");
> - of_print_property(of_property_get_value(p), p->length);
> - }
> - printf(";\n");
> + __of_print_property_prefixed(p, indent, "");
> }
>
> void of_print_properties(struct device_node *node)
> --
> 2.30.2
>
>
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
prev parent reply other threads:[~2022-08-08 11:20 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-08 6:56 Ahmad Fatoum
2022-08-08 6:56 ` [PATCH 2/2] commands: of_dump: support limiting size of printed properties Ahmad Fatoum
2022-08-08 11:18 ` Sascha Hauer [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=20220808111849.GE7333@pengutronix.de \
--to=sha@pengutronix.de \
--cc=a.fatoum@pengutronix.de \
--cc=barebox@lists.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox