mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <sha@pengutronix.de>
To: Ahmad Fatoum <a.fatoum@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 1/2] of: implement of_append_property
Date: Tue, 9 Aug 2022 11:24:18 +0200	[thread overview]
Message-ID: <20220809092418.GM31528@pengutronix.de> (raw)
In-Reply-To: <20220809055733.1544311-1-a.fatoum@pengutronix.de>

On Tue, Aug 09, 2022 at 07:57:32AM +0200, Ahmad Fatoum wrote:
> board code fix up the device tree for OS consumption. Sometimes it's
> useful for the fixup to append onto an existing property.
> Add a helper that simplifies this.
> 
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
>  drivers/of/base.c | 36 ++++++++++++++++++++++++++++++++++++
>  include/of.h      |  8 ++++++++
>  2 files changed, 44 insertions(+)
> 
> diff --git a/drivers/of/base.c b/drivers/of/base.c
> index 101b2f74c74f..0893bdf3e04f 100644
> --- a/drivers/of/base.c
> +++ b/drivers/of/base.c
> @@ -2321,6 +2321,42 @@ int of_set_property(struct device_node *np, const char *name, const void *val, i
>  	return 0;
>  }
>  
> +int of_append_property(struct device_node *np, const char *name, const void *val, int len)
> +{
> +	struct property *pp;
> +	void *buf = NULL;
> +	int orig_len = 0;
> +
> +	if (!np)
> +		return -ENOENT;
> +
> +	pp = of_find_property(np, name, NULL);

	if (!pp) {
		of_new_property(np, name, val, len);
		return 0;
	}

With that you can make the rest of the function more straight forward.

Sascha

-- 
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 |



      parent reply	other threads:[~2022-08-09  9:25 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-09  5:57 Ahmad Fatoum
2022-08-09  5:57 ` [PATCH 2/2] test: self: add tests for of_append_property Ahmad Fatoum
2022-08-09  7:26 ` [PATCH 1/2] of: implement of_append_property Marco Felsch
2022-08-09  8:29   ` Ahmad Fatoum
2022-08-09  9:24 ` 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=20220809092418.GM31528@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