Re: [PATCH v5 1/4] device property: allow to constify properties
From: Andy Shevchenko
Date: Fri Feb 03 2017 - 06:41:09 EST
On Thu, 2017-02-02 at 17:41 -0800, Dmitry Torokhov wrote:
> There is no reason why statically defined properties should be
> modifiable,
> so let's make device_add_properties() and the rest of pset_*()
> functions to
> take const pointers to properties.
>
> This will allow us to mark properties as const/__initconst at
> definition
> sites.
>
Looks good to me.
FWIW:
Reviewed-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
Though, nitpicks below.
Â
> Âstatic struct property_set *pset_copy_set(const struct property_set
> *pset)
> Â{
> - const struct property_entry *entry;
> + struct property_entry *props;
Can we leave the name?
Â
> - p->properties = kcalloc(n + 1, sizeof(*entry), GFP_KERNEL);
>
> + p->properties = props = kcalloc(n + 1, sizeof(*props),
> GFP_KERNEL);
> Â if (!p->properties) {
> Â kfree(p);
> Â return ERR_PTR(-ENOMEM);
> Â }
> Â
> Â for (i = 0; i < n; i++) {
> - int ret = pset_copy_entry(&p->properties[i],
> + int ret = pset_copy_entry(&props[i],
> Â ÂÂ&pset->properties[i]);
Do we need these changes?
--
Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
Intel Finland Oy