All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 1/1] device property: Align return codes of __acpi_node_get_property_reference
@ 2017-09-26  9:08 Sakari Ailus
  2017-10-03 23:40 ` Rafael J. Wysocki
  0 siblings, 1 reply; 2+ messages in thread
From: Sakari Ailus @ 2017-09-26  9:08 UTC (permalink / raw)
  To: linux-acpi
  Cc: devicetree, robh, frowand.list, mika.westerberg, rafael, hverkuil

acpi_fwnode_get_reference_args(), the function implementing ACPI
support for fwnode_property_get_reference_args(), returns directly
error codes from __acpi_node_get_property_reference(). The latter uses
different error codes than the OF implementation. In particular, the OF
implementation uses -ENOENT to indicate that the property is not found, a
reference entry is empty and there are no more references.

Document and align the error codes for property for
fwnode_property_get_reference_args() so that they match with
of_parse_phandle_with_args().

Fixes: 3e3119d3088f ("device property: Introduce fwnode_property_get_reference_args")
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
The patch was called "device property: Align return codes of
acpi_fwnode_get_reference_with_args", and is an alternative to the set
"[RFC 0/5] Align and document return values of phandle and reference
parsing for OF and ACPI".

since v2:

- Change the functionality of __acpi_node_get_property_reference rather
  than that of acpi_fwnode_get_reference_args.

 drivers/acpi/property.c | 19 +++++++++----------
 drivers/base/property.c |  4 ++++
 2 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c
index 3fb8ff513461..5a8ac5e1081b 100644
--- a/drivers/acpi/property.c
+++ b/drivers/acpi/property.c
@@ -571,10 +571,9 @@ static int acpi_data_get_property_array(const struct acpi_device_data *data,
  *     }
  * }
  *
- * Calling this function with index %2 return %-ENOENT and with index %3
- * returns the last entry. If the property does not contain any more values
- * %-ENODATA is returned. The NULL entry must be single integer and
- * preferably contain value %0.
+ * Calling this function with index %2 or index %3 return %-ENOENT. If the
+ * property does not contain any more values %-ENOENT is returned. The NULL
+ * entry must be single integer and preferably contain value %0.
  *
  * Return: %0 on success, negative error code on failure.
  */
@@ -590,7 +589,7 @@ int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode,
 
 	data = acpi_device_data_of_node(fwnode);
 	if (!data)
-		return -EINVAL;
+		return -ENOENT;
 
 	ret = acpi_data_get_property(data, propname, ACPI_TYPE_ANY, &obj);
 	if (ret)
@@ -635,7 +634,7 @@ int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode,
 			ret = acpi_bus_get_device(element->reference.handle,
 						  &device);
 			if (ret)
-				return -ENODEV;
+				return -EINVAL;
 
 			nargs = 0;
 			element++;
@@ -649,11 +648,11 @@ int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode,
 				else if (type == ACPI_TYPE_LOCAL_REFERENCE)
 					break;
 				else
-					return -EPROTO;
+					return -EINVAL;
 			}
 
 			if (nargs > MAX_ACPI_REFERENCE_ARGS)
-				return -EPROTO;
+				return -EINVAL;
 
 			if (idx == index) {
 				args->adev = device;
@@ -670,13 +669,13 @@ int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode,
 				return -ENOENT;
 			element++;
 		} else {
-			return -EPROTO;
+			return -EINVAL;
 		}
 
 		idx++;
 	}
 
-	return -ENODATA;
+	return -ENOENT;
 }
 EXPORT_SYMBOL_GPL(__acpi_node_get_property_reference);
 
diff --git a/drivers/base/property.c b/drivers/base/property.c
index 0c8958747c8b..a9ee5efe22d9 100644
--- a/drivers/base/property.c
+++ b/drivers/base/property.c
@@ -682,6 +682,10 @@ EXPORT_SYMBOL_GPL(fwnode_property_match_string);
  * Caller is responsible to call fwnode_handle_put() on the returned
  * args->fwnode pointer.
  *
+ * Returns: %0 on success
+ *	    %-ENOENT when the index is out of bounds, the index has an empty
+ *		     reference or the property was not found
+ *	    %-EINVAL on parse error
  */
 int fwnode_property_get_reference_args(const struct fwnode_handle *fwnode,
 				       const char *prop, const char *nargs_prop,
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v3 1/1] device property: Align return codes of __acpi_node_get_property_reference
  2017-09-26  9:08 [PATCH v3 1/1] device property: Align return codes of __acpi_node_get_property_reference Sakari Ailus
@ 2017-10-03 23:40 ` Rafael J. Wysocki
  0 siblings, 0 replies; 2+ messages in thread
From: Rafael J. Wysocki @ 2017-10-03 23:40 UTC (permalink / raw)
  To: Sakari Ailus
  Cc: linux-acpi, devicetree, robh, frowand.list, mika.westerberg,
	rafael, hverkuil

On Tuesday, September 26, 2017 11:08:27 AM CEST Sakari Ailus wrote:
> acpi_fwnode_get_reference_args(), the function implementing ACPI
> support for fwnode_property_get_reference_args(), returns directly
> error codes from __acpi_node_get_property_reference(). The latter uses
> different error codes than the OF implementation. In particular, the OF
> implementation uses -ENOENT to indicate that the property is not found, a
> reference entry is empty and there are no more references.
> 
> Document and align the error codes for property for
> fwnode_property_get_reference_args() so that they match with
> of_parse_phandle_with_args().
> 
> Fixes: 3e3119d3088f ("device property: Introduce fwnode_property_get_reference_args")
> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>

Applied, thanks!

> ---
> The patch was called "device property: Align return codes of
> acpi_fwnode_get_reference_with_args", and is an alternative to the set
> "[RFC 0/5] Align and document return values of phandle and reference
> parsing for OF and ACPI".
> 
> since v2:
> 
> - Change the functionality of __acpi_node_get_property_reference rather
>   than that of acpi_fwnode_get_reference_args.
> 
>  drivers/acpi/property.c | 19 +++++++++----------
>  drivers/base/property.c |  4 ++++
>  2 files changed, 13 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c
> index 3fb8ff513461..5a8ac5e1081b 100644
> --- a/drivers/acpi/property.c
> +++ b/drivers/acpi/property.c
> @@ -571,10 +571,9 @@ static int acpi_data_get_property_array(const struct acpi_device_data *data,
>   *     }
>   * }
>   *
> - * Calling this function with index %2 return %-ENOENT and with index %3
> - * returns the last entry. If the property does not contain any more values
> - * %-ENODATA is returned. The NULL entry must be single integer and
> - * preferably contain value %0.
> + * Calling this function with index %2 or index %3 return %-ENOENT. If the
> + * property does not contain any more values %-ENOENT is returned. The NULL
> + * entry must be single integer and preferably contain value %0.
>   *
>   * Return: %0 on success, negative error code on failure.
>   */
> @@ -590,7 +589,7 @@ int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode,
>  
>  	data = acpi_device_data_of_node(fwnode);
>  	if (!data)
> -		return -EINVAL;
> +		return -ENOENT;
>  
>  	ret = acpi_data_get_property(data, propname, ACPI_TYPE_ANY, &obj);
>  	if (ret)
> @@ -635,7 +634,7 @@ int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode,
>  			ret = acpi_bus_get_device(element->reference.handle,
>  						  &device);
>  			if (ret)
> -				return -ENODEV;
> +				return -EINVAL;
>  
>  			nargs = 0;
>  			element++;
> @@ -649,11 +648,11 @@ int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode,
>  				else if (type == ACPI_TYPE_LOCAL_REFERENCE)
>  					break;
>  				else
> -					return -EPROTO;
> +					return -EINVAL;
>  			}
>  
>  			if (nargs > MAX_ACPI_REFERENCE_ARGS)
> -				return -EPROTO;
> +				return -EINVAL;
>  
>  			if (idx == index) {
>  				args->adev = device;
> @@ -670,13 +669,13 @@ int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode,
>  				return -ENOENT;
>  			element++;
>  		} else {
> -			return -EPROTO;
> +			return -EINVAL;
>  		}
>  
>  		idx++;
>  	}
>  
> -	return -ENODATA;
> +	return -ENOENT;
>  }
>  EXPORT_SYMBOL_GPL(__acpi_node_get_property_reference);
>  
> diff --git a/drivers/base/property.c b/drivers/base/property.c
> index 0c8958747c8b..a9ee5efe22d9 100644
> --- a/drivers/base/property.c
> +++ b/drivers/base/property.c
> @@ -682,6 +682,10 @@ EXPORT_SYMBOL_GPL(fwnode_property_match_string);
>   * Caller is responsible to call fwnode_handle_put() on the returned
>   * args->fwnode pointer.
>   *
> + * Returns: %0 on success
> + *	    %-ENOENT when the index is out of bounds, the index has an empty
> + *		     reference or the property was not found
> + *	    %-EINVAL on parse error
>   */
>  int fwnode_property_get_reference_args(const struct fwnode_handle *fwnode,
>  				       const char *prop, const char *nargs_prop,
> 



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-10-03 23:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-26  9:08 [PATCH v3 1/1] device property: Align return codes of __acpi_node_get_property_reference Sakari Ailus
2017-10-03 23:40 ` Rafael J. Wysocki

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.