ACPI: property: Remove dead code
PATCH v2 4/5 ACPI: property: Satisfy kernel doc validator (part 2)
In reply to Andy ShevchenkoCHECK drivers/acpi/property.c
warning: Function parameter or member '__fwnode' not described in 'acpi_graph_get_remote_endpoint'
warning: Excess function parameter 'fwnode' description in 'acpi_graph_get_remote_endpoint'
warning: Excess function parameter 'endpoint' description in 'acpi_graph_get_remote_endpoint'
--- drivers/acpi/property.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/acpi/property.c +1 -2
@@ -1212,8 +1212,7 @@ static struct fwnode_handle *acpi_graph_get_child_prop_value(/** * acpi_graph_get_remote_endpoint - Parses and returns remote end of an endpoint -* @fwnode: Endpoint firmware node pointing to a remote device -* @endpoint: Firmware node of remote endpoint is filled here if not %NULL +* @__fwnode: Endpoint firmware node pointing to a remote device * * Returns the remote endpoint corresponding to @__fwnode. NULL on error. */
Signature · 1 line
2.30.0
PATCH v2 5/5 ACPI: property: Refactor acpi_data_prop_read_single()
In reply to Andy ShevchenkoRefactor acpi_data_prop_read_single() for less LOCs and better maintenance.
--- drivers/acpi/property.c | 80 ++++++++++++++++++----------------------- 1 file changed, 34 insertions(+), 46 deletions(-)
drivers/acpi/property.c +34 -46
@@ -785,60 +785,48 @@ static int acpi_data_prop_read_single(const struct acpi_device_data *data, enum dev_prop_type proptype, void *val) { const union acpi_object *obj; -int ret; +int ret =0 ; -if (proptype >=DEV_PROP_U8 && proptype <=DEV_PROP_U64 ) { +if (proptype >=DEV_PROP_U8 && proptype <=DEV_PROP_U64 ) ret =acpi_data_get_property (data, propname,ACPI_TYPE_INTEGER , &obj); -if (ret) -return ret; - -switch (proptype) { -case DEV_PROP_U8 : -if (obj->integer.value >U8_MAX ) -return -EOVERFLOW ; - -if (val) - *(u8 *)val = obj->integer.value; - -break ; -case DEV_PROP_U16 : -if (obj->integer.value >U16_MAX ) -return -EOVERFLOW ; - -if (val) - *(u16 *)val = obj->integer.value; - -break ; -case DEV_PROP_U32 : -if (obj->integer.value >U32_MAX ) -return -EOVERFLOW ; - -if (val) - *(u32 *)val = obj->integer.value; - -break ; -default : -if (val) - *(u64 *)val = obj->integer.value; - -break ; - } - -if (!val) -return 1 ; - }else if (proptype ==DEV_PROP_STRING ) { +else if (proptype ==DEV_PROP_STRING ) ret =acpi_data_get_property (data, propname,ACPI_TYPE_STRING , &obj); -if (ret) -return ret; +if (ret) +return ret; +switch (proptype) { +case DEV_PROP_U8 : +if (obj->integer.value >U8_MAX ) +return -EOVERFLOW ; +if (val) + *(u8 *)val = obj->integer.value; +break ; +case DEV_PROP_U16 : +if (obj->integer.value >U16_MAX ) +return -EOVERFLOW ; +if (val) + *(u16 *)val = obj->integer.value; +break ; +case DEV_PROP_U32 : +if (obj->integer.value >U32_MAX ) +return -EOVERFLOW ; +if (val) + *(u32 *)val = obj->integer.value; +break ; +case DEV_PROP_U64 : +if (val) + *(u64 *)val = obj->integer.value; +break ; +case DEV_PROP_STRING :if (val) *(char **)val = obj->string.pointer; -return 1 ; - }else { - ret = -EINVAL ; +default : +return -EINVAL ; } -return ret; + +/* When no storage provided return number of available values */ +return val ?0 :1 ; } static int acpi_copy_property_array_u8(const union acpi_object *items, u8 *val,
Signature · 1 line
2.30.0
PATCH v2 2/5 ACPI: property: Make acpi_node_prop_read() static
In reply to Andy ShevchenkoThere is no users outside of property.c. No need to export acpi_node_prop_read(), hence make it static.
--- drivers/acpi/property.c | 6 +++--- include/linux/acpi.h | 11 ----------- 2 files changed, 3 insertions(+), 14 deletions(-)
drivers/acpi/property.c +3 -3
@@ -993,9 +993,9 @@ static int acpi_data_prop_read(const struct acpi_device_data *data,* of the property. Otherwise, read at most @nval values to the array at the * location pointed to by @val. */ -int acpi_node_prop_read (const struct fwnode_handle *fwnode, -const char *propname,enum dev_prop_type proptype, -void *val,size_t nval) +static int acpi_node_prop_read (const struct fwnode_handle *fwnode, +const char *propname,enum dev_prop_type proptype, +void *val,size_t nval) {return acpi_data_prop_read (acpi_device_data_of_node (fwnode), propname, proptype, val, nval);
include/linux/acpi.h +0 -11
@@ -1121,9 +1121,6 @@ acpi_data_add_props(struct acpi_device_data *data, const guid_t *guid,int acpi_node_prop_get (const struct fwnode_handle *fwnode,const char *propname,void **valptr); -int acpi_node_prop_read (const struct fwnode_handle *fwnode, -const char *propname,enum dev_prop_type proptype, -void *val,size_t nval);struct fwnode_handle *acpi_get_next_subnode (const struct fwnode_handle *fwnode,struct fwnode_handle *child);
@@ -1225,14 +1222,6 @@ static inline int acpi_node_prop_get(const struct fwnode_handle *fwnode,return -ENXIO ; } -static inline int acpi_node_prop_read (const struct fwnode_handle *fwnode, -const char *propname, -enum dev_prop_type proptype, -void *val,size_t nval) -{ -return -ENXIO ; -} -static inline struct fwnode_handle *acpi_get_next_subnode (const struct fwnode_handle *fwnode,struct fwnode_handle *child)
Signature · 1 line
2.30.0
PATCH v2 1/5 ACPI: property: Remove dead code
After the commit 3a7a2ab839ad couple of functions became a dead code. Moreover, for all these years nobody used them. Remove.
--- drivers/acpi/property.c | 20 -------------------- include/linux/acpi.h | 21 --------------------- 2 files changed, 41 deletions(-)
drivers/acpi/property.c +0 -20
@@ -841,20 +841,6 @@ static int acpi_data_prop_read_single(const struct acpi_device_data *data,return ret; } -int acpi_dev_prop_read_single (struct acpi_device *adev,const char *propname, -enum dev_prop_type proptype,void *val) -{ -int ret; - -if (!adev || !val) -return -EINVAL ; - - ret =acpi_data_prop_read_single (&adev->data, propname, proptype, val); -if (ret <0 || proptype !=ACPI_TYPE_STRING ) -return ret; -return 0 ; -} -static int acpi_copy_property_array_u8 (const union acpi_object *items,u8 *val,size_t nval) {
@@ -995,12 +981,6 @@ static int acpi_data_prop_read(const struct acpi_device_data *data,return ret; } -int acpi_dev_prop_read (const struct acpi_device *adev,const char *propname, -enum dev_prop_type proptype,void *val,size_t nval) -{ -return adev ?acpi_data_prop_read (&adev->data, propname, proptype, val, nval) : -EINVAL ; -} -/** * acpi_node_prop_read - retrieve the value of an ACPI property with given name. * @fwnode: Firmware node to get the property from.
include/linux/acpi.h +0 -21
@@ -1121,14 +1121,9 @@ acpi_data_add_props(struct acpi_device_data *data, const guid_t *guid,int acpi_node_prop_get (const struct fwnode_handle *fwnode,const char *propname,void **valptr); -int acpi_dev_prop_read_single (struct acpi_device *adev, -const char *propname,enum dev_prop_type proptype, -void *val);int acpi_node_prop_read (const struct fwnode_handle *fwnode,const char *propname,enum dev_prop_type proptype,void *val,size_t nval); -int acpi_dev_prop_read (const struct acpi_device *adev,const char *propname, -enum dev_prop_type proptype,void *val,size_t nval);struct fwnode_handle *acpi_get_next_subnode (const struct fwnode_handle *fwnode,struct fwnode_handle *child);
@@ -1230,14 +1225,6 @@ static inline int acpi_node_prop_get(const struct fwnode_handle *fwnode,return -ENXIO ; } -static inline int acpi_dev_prop_read_single (const struct acpi_device *adev, -const char *propname, -enum dev_prop_type proptype, -void *val) -{ -return -ENXIO ; -} - static inline int acpi_node_prop_read(const struct fwnode_handle *fwnode, const char *propname, enum dev_prop_type proptype,
@@ -1246,14 +1233,6 @@ static inline int acpi_node_prop_read(const struct fwnode_handle *fwnode,return -ENXIO ; } -static inline int acpi_dev_prop_read (const struct acpi_device *adev, -const char *propname, -enum dev_prop_type proptype, -void *val,size_t nval) -{ -return -ENXIO ; -} -static inline struct fwnode_handle *acpi_get_next_subnode (const struct fwnode_handle *fwnode,struct fwnode_handle *child)
Signature · 1 line
2.30.0
PATCH v2 3/5 ACPI: property: Satisfy kernel doc validator (part 1)
CHECK drivers/acpi/property.c
warning: Function parameter or member 'data' not described in 'acpi_data_get_property_array'
warning: Excess function parameter 'adev' description in 'acpi_data_get_property_array'
--- drivers/acpi/property.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/acpi/property.c +1 -1
@@ -564,7 +564,7 @@ int acpi_node_prop_get(const struct fwnode_handle *fwnode,/** * acpi_data_get_property_array - return an ACPI array property with given name -* @adev: ACPI data object to get the property from +* @data: ACPI data object to get the property from * @name: Name of the property * @type: Expected type of array elements * @obj: Location to store a pointer to the property value (if not NULL)
Signature · 1 line
2.30.0
Rafael J. Wysocki
maintainerRe: [PATCH v2 5/5] ACPI: property: Refactor acpi_data_prop_read_single()
In reply to Andy ShevchenkoQuoted 24 lines · Andy Shevchenko
Refactor
acpi_data_prop_read_single()for less LOCs and better maintenance.Signed-off-by Andy Shevchenko <[email protected]>--- drivers/acpi/property.c | 80 ++++++++++++++++++----------------------- 1 file changed, 34 insertions(+), 46 deletions(-)drivers/acpi/property.c +2
-4@@ -785,60 +785,48 @@ static int acpi_data_prop_read_single(const struct acpi_device_data *data, enum dev_prop_type proptype, void *val) {const union acpi_object *obj; -int ret; +int ret =0 ; -if (proptype >=DEV_PROP_U8 && proptype <=DEV_PROP_U64 ) { +if (proptype >=DEV_PROP_U8 && proptype <=DEV_PROP_U64 ) ret =acpi_data_get_property (data, propname,ACPI_TYPE_INTEGER , &obj); -if (ret) -return ret;
drivers/acpi/property.c static int acpi_data_prop_read_single(const struct acpi_device_data *data, · line 803
Quoted 10 lines
drivers/acpi/property.c +0
-10- -switch (proptype) { -case DEV_PROP_U8 : -if (obj->integer.value >U8_MAX ) -return -EOVERFLOW ; - -if (val) - *(u8 *)val = obj->integer.value; - -break ;
The empty lines of code above are intentional, so please retain them.
Quoted 22 lines
drivers/acpi/property.c +0
-22-case DEV_PROP_U16 : -if (obj->integer.value >U16_MAX ) -return -EOVERFLOW ; - -if (val) - *(u16 *)val = obj->integer.value; - -break ; -case DEV_PROP_U32 : -if (obj->integer.value >U32_MAX ) -return -EOVERFLOW ; - -if (val) - *(u32 *)val = obj->integer.value; - -break ; -default : -if (val) - *(u64 *)val = obj->integer.value; - -break ; - }
drivers/acpi/property.c static int acpi_data_prop_read_single(const struct acpi_device_data *data, · line 795
Quoted 10 lines
drivers/acpi/property.c +3
-6- -if (!val) -return 1 ; - }else if (proptype ==DEV_PROP_STRING ) { +else if (proptype ==DEV_PROP_STRING ) ret =acpi_data_get_property (data, propname,ACPI_TYPE_STRING , &obj); -if (ret) -return ret; +if (ret) +return ret;
else if (!val)
ret = 1;
Quoted 25 lines
drivers/acpi/property.c +24
-0+switch (proptype) { +case DEV_PROP_U8 : +if (obj->integer.value >U8_MAX ) +return -EOVERFLOW ; +if (val) + *(u8 *)val = obj->integer.value; +break ; +case DEV_PROP_U16 : +if (obj->integer.value >U16_MAX ) +return -EOVERFLOW ; +if (val) + *(u16 *)val = obj->integer.value; +break ; +case DEV_PROP_U32 : +if (obj->integer.value >U32_MAX ) +return -EOVERFLOW ; +if (val) + *(u32 *)val = obj->integer.value; +break ; +case DEV_PROP_U64 : +if (val) + *(u64 *)val = obj->integer.value; +break ; +case DEV_PROP_STRING :
drivers/acpi/property.c static int acpi_data_prop_read_single(const struct acpi_device_data *data, · line 841
Quoted 10 lines
drivers/acpi/property.c +2
-4if (val) *(char **)val = obj->string.pointer; -return 1 ; - }else { - ret = -EINVAL ; +default : +return -EINVAL ; } -return ret;
Retain this.
drivers/acpi/property.c static int acpi_data_prop_read_single(const struct acpi_device_data *data, · line 829
Quoted 3 lines
drivers/acpi/property.c +3
-0+ +/* When no storage provided return number of available values */ +return val ?0 :1 ;
And this is just not looking good to me, sorry.
Quoted 4 lines
drivers/acpi/property.c +0
-1} static int acpi_copy_property_array_u8(const union acpi_object *items, u8 *val, --
Rafael J. Wysocki
maintainerQuoted 6 lines · Andy Shevchenko
After the commit
3a7a2ab839adcouple of functions became a dead code. Moreover, for all these years nobody used them. Remove.Fixes 3a7a2ab839ad ("ACPI / property: Extend fwnode_property_* to data-only subnodes")Signed-off-by Andy Shevchenko <[email protected]>
Patches [1-4/5] from this series applied as 5.12 material and please see my comments for the last one sent separately.
Thanks!
Quoted 95 lines
--- drivers/acpi/property.c | 20 -------------------- include/linux/acpi.h | 21 --------------------- 2 files changed, 41 deletions(-)drivers/acpi/property.c +0
-20@@ -841,20 +841,6 @@ static int acpi_data_prop_read_single(const struct acpi_device_data *data,return ret; } -int acpi_dev_prop_read_single (struct acpi_device *adev,const char *propname, -enum dev_prop_type proptype,void *val) -{ -int ret; - -if (!adev || !val) -return -EINVAL ; - - ret =acpi_data_prop_read_single (&adev->data, propname, proptype, val); -if (ret <0 || proptype !=ACPI_TYPE_STRING ) -return ret; -return 0 ; -} -static int acpi_copy_property_array_u8 (const union acpi_object *items,u8 *val,size_t nval) {@@ -995,12 +981,6 @@ static int acpi_data_prop_read(const struct acpi_device_data *data,return ret; } -int acpi_dev_prop_read (const struct acpi_device *adev,const char *propname, -enum dev_prop_type proptype,void *val,size_t nval) -{ -return adev ?acpi_data_prop_read (&adev->data, propname, proptype, val, nval) : -EINVAL ; -} -/** * acpi_node_prop_read - retrieve the value of an ACPI property with given name. * @fwnode: Firmware node to get the property from. include/linux/acpi.h +0
-22@@ -1121,14 +1121,9 @@ acpi_data_add_props(struct acpi_device_data *data, const guid_t *guid,int acpi_node_prop_get (const struct fwnode_handle *fwnode,const char *propname,void **valptr); -int acpi_dev_prop_read_single (struct acpi_device *adev, -const char *propname,enum dev_prop_type proptype, -void *val);int acpi_node_prop_read (const struct fwnode_handle *fwnode,const char *propname,enum dev_prop_type proptype,void *val,size_t nval); -int acpi_dev_prop_read (const struct acpi_device *adev,const char *propname, -enum dev_prop_type proptype,void *val,size_t nval);struct fwnode_handle *acpi_get_next_subnode (const struct fwnode_handle *fwnode,struct fwnode_handle *child);@@ -1230,14 +1225,6 @@ static inline int acpi_node_prop_get(const struct fwnode_handle *fwnode,return -ENXIO ; } -static inline int acpi_dev_prop_read_single (const struct acpi_device *adev, -const char *propname, -enum dev_prop_type proptype, -void *val) -{ -return -ENXIO ; -} - static inline int acpi_node_prop_read(const struct fwnode_handle *fwnode, const char *propname, enum dev_prop_type proptype,@@ -1246,14 +1233,6 @@ static inline int acpi_node_prop_read(const struct fwnode_handle *fwnode,return -ENXIO ; } -static inline int acpi_dev_prop_read (const struct acpi_device *adev, -const char *propname, -enum dev_prop_type proptype, -void *val,size_t nval) -{ -return -ENXIO ; -} -static inline struct fwnode_handle *acpi_get_next_subnode (const struct fwnode_handle *fwnode,struct fwnode_handle *child) --2.30.0
Re: [PATCH v2 5/5] ACPI: property: Refactor acpi_data_prop_read_single()
In reply to Rafael J. WysockiQuoted 4 lines · Rafael J. Wysocki
Quoted 1 line · Andy Shevchenko
Refactor
acpi_data_prop_read_single()for less LOCs and better maintenance.
Thanks for review, my answers below.
...
Quoted 5 lines
drivers/acpi/property.c static int acpi_data_prop_read_single(const struct acpi_device_data *data, · line 795
Quoted 2 lines
drivers/acpi/property.c +2
-0+if (ret) +return ret;else if (!val)
ret = 1;
But then it become a bug again :-)
...
Quoted 1 line
And this is just not looking good to me, sorry.
Yeah, I think this patch is not needed right now. At least it seems no gain from it.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Rafael J. Wysocki
maintainerRe: [PATCH v2 5/5] ACPI: property: Refactor acpi_data_prop_read_single()
Quoted 11 lines · Andy Shevchenko
Quoted 4 lines · Rafael J. Wysocki
Quoted 1 line · Andy Shevchenko
Refactor
acpi_data_prop_read_single()for less LOCs and better maintenance.Thanks for review, my answers below.
...
Quoted 7 lines
Quoted 5 lines
drivers/acpi/property.c static int acpi_data_prop_read_single(const struct acpi_device_data *data, · line 795
Quoted 2 lines
drivers/acpi/property.c +2
-0+if (ret) +return ret;else if (!val)
ret = 1;But then it become a bug again :-)
I'm not sure why? The checks below will still happen and they may cause an error to be returned.
Quoted 6 lines
...
Quoted 1 line
And this is just not looking good to me, sorry.
Yeah, I think this patch is not needed right now. At least it seems no gain from it.
OK
Re: [PATCH v2 5/5] ACPI: property: Refactor acpi_data_prop_read_single()
Quoted 5 lines · Rafael J. Wysocki
Quoted 3 lines · Andy Shevchenko
Quoted 2 lines · Rafael J. Wysocki
On Fri, Feb 12, 2021 at 3:14 PM Andy Shevchenko
<[email protected]> wrote:
...
Quoted 10 lines
Quoted 7 lines
Quoted 5 lines
drivers/acpi/property.c static int acpi_data_prop_read_single(const struct acpi_device_data *data, · line 795
Quoted 2 lines
drivers/acpi/property.c +2
-0+if (ret) +return ret;else if (!val)
ret = 1;But then it become a bug again :-)
I'm not sure why? The checks below will still happen and they may cause an error to be returned.
Oh, I misinterpreted ret = as plain return. Right. Seems okay.
Signature · 2 lines
With Best Regards, Andy Shevchenko