devicetree-compiler.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: Ayush Singh <ayush@beagleboard.org>
Cc: d-gole@ti.com, lorforlinux@beagleboard.org,
	jkridner@beagleboard.org, robertcnelson@beagleboard.org,
	nenad.marinkovic@mikroe.com, Andrew Davis <afd@ti.com>,
	Geert Uytterhoeven <geert@linux-m68k.org>,
	Robert Nelson <robertcnelson@gmail.com>,
	devicetree-compiler@vger.kernel.org
Subject: Re: [PATCH 4/4] libfdt: Add fdt_setprop_namelen_string()
Date: Wed, 4 Dec 2024 11:32:58 +1100	[thread overview]
Message-ID: <Z0-jOg1MiD7yv035@zatzit> (raw)
In-Reply-To: <20241203-setprop-namelen-v1-4-d1ea333fbd6c@beagleboard.org>

[-- Attachment #1: Type: text/plain, Size: 2482 bytes --]

On Wed, Dec 04, 2024 at 12:00:02AM +0530, Ayush Singh wrote:
> Macro using fdt_setprop_namelen() internally similar to
> `fdt_setprop_string()`.
> 
> Signed-off-by: Ayush Singh <ayush@beagleboard.org>

Reviewed-by: David Gibson <david@gibson.dropbear.id.au>

> ---
>  libfdt/libfdt.h | 32 ++++++++++++++++++++++++++++++++
>  1 file changed, 32 insertions(+)
> 
> diff --git a/libfdt/libfdt.h b/libfdt/libfdt.h
> index c9c81f039365b6d244932786a84a05f065e67c33..5c79c7150d196062246319735b36a6111978ad56 100644
> --- a/libfdt/libfdt.h
> +++ b/libfdt/libfdt.h
> @@ -1919,6 +1919,38 @@ static inline int fdt_setprop_cell(void *fdt, int nodeoffset, const char *name,
>  #define fdt_setprop_string(fdt, nodeoffset, name, str) \
>  	fdt_setprop((fdt), (nodeoffset), (name), (str), strlen(str)+1)
>  
> +/**
> + * fdt_setprop_namelen_string - set a property to a string value
> + * @fdt: pointer to the device tree blob
> + * @nodeoffset: offset of the node whose property to change
> + * @name: name of the property to change
> + * @namelen: number of characters of name to consider
> + * @str: string value for the property
> + *
> + * fdt_setprop_namelen_string() sets the value of the named property in the
> + * given node to the given string value (using the length of the
> + * string to determine the new length of the property), or creates a
> + * new property with that value if it does not already exist.
> + *
> + * This function may insert or delete data from the blob, and will
> + * therefore change the offsets of some existing nodes.
> + *
> + * returns:
> + *	0, on success
> + *	-FDT_ERR_NOSPACE, there is insufficient free space in the blob to
> + *		contain the new property value
> + *	-FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
> + *	-FDT_ERR_BADLAYOUT,
> + *	-FDT_ERR_BADMAGIC,
> + *	-FDT_ERR_BADVERSION,
> + *	-FDT_ERR_BADSTATE,
> + *	-FDT_ERR_BADSTRUCTURE,
> + *	-FDT_ERR_BADLAYOUT,
> + *	-FDT_ERR_TRUNCATED, standard meanings
> + */
> +#define fdt_setprop_namelen_string(fdt, nodeoffset, name, namelen, str)    \
> +	fdt_setprop_namelen((fdt), (nodeoffset), (name), (namelen), (str), \
> +			    strlen(str) + 1)
>  
>  /**
>   * fdt_setprop_empty - set a property to an empty value
> 

-- 
David Gibson (he or they)	| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you, not the other way
				| around.
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2024-12-04  0:34 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-03 18:29 [PATCH 0/4] libfdt: Add namelen variants for setprop Ayush Singh
2024-12-03 18:29 ` [PATCH 1/4] libfdt: add fdt_get_property_namelen_w() Ayush Singh
2024-12-04  0:21   ` David Gibson
2024-12-03 18:30 ` [PATCH 2/4] libfdt_internal: fdt_find_string_len_() Ayush Singh
2024-12-04  0:22   ` David Gibson
2024-12-03 18:30 ` [PATCH 3/4] libfdt: Add fdt_setprop_namelen() Ayush Singh
2024-12-04  0:29   ` David Gibson
2024-12-04  7:39     ` Ayush Singh
2024-12-04 23:45       ` David Gibson
2024-12-03 18:30 ` [PATCH 4/4] libfdt: Add fdt_setprop_namelen_string() Ayush Singh
2024-12-04  0:32   ` David Gibson [this message]
2024-12-04  0:34 ` [PATCH 0/4] libfdt: Add namelen variants for setprop David Gibson

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=Z0-jOg1MiD7yv035@zatzit \
    --to=david@gibson.dropbear.id.au \
    --cc=afd@ti.com \
    --cc=ayush@beagleboard.org \
    --cc=d-gole@ti.com \
    --cc=devicetree-compiler@vger.kernel.org \
    --cc=geert@linux-m68k.org \
    --cc=jkridner@beagleboard.org \
    --cc=lorforlinux@beagleboard.org \
    --cc=nenad.marinkovic@mikroe.com \
    --cc=robertcnelson@beagleboard.org \
    --cc=robertcnelson@gmail.com \
    /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;
as well as URLs for NNTP newsgroup(s).