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@xxxxxxxxxxxxxxx> Reviewed-by: David Gibson <david@xxxxxxxxxxxxxxxxxxxxx> > --- > 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:
signature.asc
Description: PGP signature