device property: check fwnode type in to_of_node()
Subsystems (4)
Andy Shevchenko
reviewerPATCH 1/3 device property: check fwnode type in to_of_node()
Potentially one of platform can support both ACPI and OF. In that case when we call to_of_node() for non-OF fwnode types we will get non-NULL result, which is wrong. Check for the type and return a correspondent result.
--- include/linux/of.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
include/linux/of.h +2 -1
@@ -136,7 +136,8 @@ static inline bool is_of_node(struct fwnode_handle *fwnode)static inline struct device_node *to_of_node (struct fwnode_handle *fwnode) { - return fwnode ? container_of(fwnode, struct device_node, fwnode) : NULL; +return is_of_node (fwnode) ? + container_of(fwnode, struct device_node, fwnode) : NULL; }static inline bool of_have_populated_dt (void )
Signature · 1 line
2.5.0
Andy Shevchenko
reviewerPATCH 2/3 device property: fallback to pset when gettng one string
The one string as an equivalent to an array of one element. Allow user to read one string as a plain string.
--- drivers/base/property.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/base/property.c +2 -1
@@ -462,7 +462,8 @@ int fwnode_property_read_string(struct fwnode_handle *fwnode,return acpi_dev_prop_read (to_acpi_node (fwnode), propname,DEV_PROP_STRING , val,1 ); -return -ENXIO ; +return pset_prop_read_array (to_pset (fwnode), propname, +DEV_PROP_STRING , val,1 ); }EXPORT_SYMBOL_GPL (fwnode_property_read_string);
Signature · 1 line
2.5.0
Re: [PATCH v1 2/3] device property: fallback to pset when gettng one string
Quoted 4 lines · Andy Shevchenko
The one string as an equivalent to an array of one element. Allow user to read one string as a plain string.
Signed-off-by Andy Shevchenko <[email protected]>
Andy Shevchenko
reviewerPATCH 3/3 device property: attach 'else if' to the proper 'if'
In reply to Andy ShevchenkoObviously in the current place the 'else' keyword is redundant, though it seems quite correct when we check if nval is in allowed range.
Reattach the condition branch there.
--- drivers/acpi/property.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/acpi/property.c +4 -4
@@ -528,13 +528,14 @@ int acpi_dev_prop_read(struct acpi_device *adev, const char *propname,if (!val)return obj->package.count; -else if (nval <=0 ) -return -EINVAL ;if (nval > obj->package.count)return -EOVERFLOW ; +else if (nval <=0 ) +return -EINVAL ; items = obj->package.elements; +switch (proptype) {case DEV_PROP_U8 : ret =acpi_copy_property_array_u8 (items, (u8 *)val, nval);
@@ -552,8 +553,7 @@ int acpi_dev_prop_read(struct acpi_device *adev, const char *propname, ret =acpi_copy_property_array_string (items, (char **)val, nval);break ;default : - ret = -EINVAL ; -break ; +return -EINVAL ; }return ret; }
Signature · 1 line
2.5.0
Andy Shevchenko
reviewerRe: [PATCH v1 3/3] device property: attach 'else if' to the proper 'if'
Quoted 5 lines · Andy Shevchenko
Obviously in the current place the 'else' keyword is redundant, though it seems
quite correct when we check if nval is in allowed range.Reattach the condition branch there.
Rafael, it would be nice to have these fixes in 4.3 as well if you have no objections.
One comment below.
Quoted 15 lines
Signed-off-by Andy Shevchenko <[email protected]>--- drivers/acpi/property.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)drivers/acpi/property.c +0
-0@@ -528,13 +528,14 @@ int acpi_dev_prop_read(struct acpi_device *adev, const char *propname, if (!val)return obj->package.count;
drivers/acpi/property.c int acpi_dev_prop_read(struct acpi_device · line 539
Quoted 10 lines
drivers/acpi/property.c +3
-2-else if (nval <=0 ) -return -EINVAL ;if (nval > obj->package.count)return -EOVERFLOW ; +else if (nval <=0 ) +return -EINVAL ; items = obj->package.elements; +
This…
drivers/acpi/property.c int acpi_dev_prop_read(struct acpi_device *adev, · line 558
Quoted 13 lines
drivers/acpi/property.c +0
-0switch (proptype) {case DEV_PROP_U8 :ret = acpi_copy_property_array_u8(items, (u8 *)val,
nval);drivers/acpi/property.c +1
-2@@ -552,8 +553,7 @@ int acpi_dev_prop_read(struct acpi_device *adev,const char *propname, ret =acpi_copy_property_array_string (items, (char **)val, nval);break ;default : - ret = -EINVAL ; -break ; +return -EINVAL ;
…and this seem left overs. If you wish I can resend this patch without them.
Quoted 3 lines
drivers/acpi/property.c +0
-0}return ret;
}
Signature · 2 lines
Andy Shevchenko <[email protected]> Intel Finland Oy
Re: [PATCH v1 3/3] device property: attach 'else if' to the proper 'if'
In reply to Andy ShevchenkoQuoted 6 lines · Andy Shevchenko
Obviously in the current place the 'else' keyword is redundant, though it seems quite correct when we check if nval is in allowed range.
Reattach the condition branch there.
Signed-off-by Andy Shevchenko <[email protected]>
When the leftovers you mentioned are dropped you can add my,
Quoted 5 lines · Andy Shevchenko
Potentially one of platform can support both ACPI and OF. In that case when we call
to_of_node()for non-OF fwnode types we will get non-NULL result, which is wrong. Check for the type and return a correspondent result.Signed-off-by Andy Shevchenko <[email protected]>
Quoted 5 lines · Andy Shevchenko
Potentially one of platform can support both ACPI and OF. In that case when we call
to_of_node()for non-OF fwnode types we will get non-NULL result, which is wrong. Check for the type and return a correspondent result.Signed-off-by Andy Shevchenko <[email protected]>
Added [1/3] to the 4.3 queue with a minor change in [3/3] (dropped the last hunk) and the Reviewed-by tags from Mika.
Thanks!
Signature · 2 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.