Re: [PATCH 1/2] of: implement of_append_property

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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




[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux