[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2176862.3cxL0kyTvc@avalon>
Date: Wed, 21 Feb 2018 14:19:02 +0200
From: Laurent Pinchart <laurent.pinchart@...asonboard.com>
To: Geert Uytterhoeven <geert@...ux-m68k.org>
Cc: Laurent Pinchart <laurent.pinchart+renesas@...asonboard.com>,
DRI Development <dri-devel@...ts.freedesktop.org>,
Linux-Renesas <linux-renesas-soc@...r.kernel.org>,
Pantelis Antoniou <pantelis.antoniou@...sulko.com>,
Rob Herring <robh@...nel.org>,
Frank Rowand <frowand.list@...il.com>,
Matt Porter <mporter@...sulko.com>,
Koen Kooi <koen@...inion.thruhere.net>,
Guenter Roeck <linux@...ck-us.net>,
Marek Vasut <marex@...x.de>, Wolfram Sang <wsa@...-dreams.de>,
"open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS"
<devicetree@...r.kernel.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
Linux I2C <linux-i2c@...r.kernel.org>
Subject: Re: [PATCH v4 04/16] of: changesets: Introduce changeset helper methods
Hi Geert,
On Wednesday, 21 February 2018 12:21:50 EET Geert Uytterhoeven wrote:
> On Wed, Feb 21, 2018 at 12:10 AM, Laurent Pinchart wrote:
> > From: Pantelis Antoniou <pantelis.antoniou@...sulko.com>
> >
> > Changesets are very powerful, but the lack of a helper API
> > makes using them cumbersome. Introduce a simple copy based
> > API that makes things considerably easier.
> >
> > To wit, adding a property using the raw API.
> >
> > struct property *prop;
> > prop = kzalloc(sizeof(*prop)), GFP_KERNEL);
> > prop->name = kstrdup("compatible");
> > prop->value = kstrdup("foo,bar");
> > prop->length = strlen(prop->value) + 1;
> > of_changeset_add_property(ocs, np, prop);
> >
> > while using the helper API
> >
> > of_changeset_add_property_string(ocs, np, "compatible",
> >
> > "foo,bar");
> >
> > Signed-off-by: Pantelis Antoniou <pantelis.antoniou@...sulko.com>
> > [Fixed memory leak in __of_changeset_add_update_property_copy()]
> > Signed-off-by: Laurent Pinchart
> > <laurent.pinchart+renesas@...asonboard.com>
>
> You missed one fix I have in my topic/overlays branch
> https://git.kernel.org/pub/scm/linux/kernel/git/geert/renesas-drivers.git/co
> mmit/?h=topic/overlays&id=150f95b9dec77ce371c229f7ac4d6dd8620bef4a
> > --- a/include/linux/of.h
> > +++ b/include/linux/of.h
> >
> > +/**
> > + * of_changeset_add_property_u32 - Create a new u32 property
> > + *
> > + * @ocs: changeset pointer
> > + * @np: device node pointer
> > + * @name: name of the property
> > + * @val: value in host endian format
> > + *
> > + * Adds a u32 property to the changeset.
> > + *
> > + * Returns zero on success, a negative error value otherwise.
> > + */
> > +static inline int of_changeset_add_property_u32(struct of_changeset *ocs,
> > + struct device_node *np, const char *name, u32 val)
> > +{
> > + val = cpu_to_be32(val);
>
> You must use an intermediate, to avoid complaints from sparse:
>
> __be32 x = cpu_to_be32(val);
>
> > + return __of_changeset_add_update_property_copy(ocs, np, name,
> > &val,
> > + sizeof(val), false);
>
> s/val/x/
I'll fix both in the next version, thanks.
> > +}
> > +
> > +/**
> > + * of_changeset_update_property_u32 - Update u32 property
> > + *
> > + * @ocs: changeset pointer
> > + * @np: device node pointer
> > + * @name: name of the property
> > + * @val: value in host endian format
> > + *
> > + * Updates a u32 property to the changeset.
> > + *
> > + * Returns zero on success, a negative error value otherwise.
> > + */
> > +static inline int of_changeset_update_property_u32(
> > + struct of_changeset *ocs, struct device_node *np,
> > + const char *name, u32 val)
> > +{
> > + val = cpu_to_be32(val);
>
> Oh, a new one.
>
> > + return __of_changeset_add_update_property_copy(ocs, np, name,
> > &val,
> > + sizeof(val), true);
> > +}
--
Regards,
Laurent Pinchart
Powered by blists - more mailing lists