Re: [PATCH 06/10] ACPI: property: Use data node name and reg property for graphs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wednesday, June 27, 2018 11:37:23 AM CEST Sakari Ailus wrote:
> Instead of using the port and endpoint properties, rely on the names of
> the port and endpoint nodes as well as the reg property, as on DT.

The special meaning of "reg" should be documented somewhere, I suppose?

> Signed-off-by: Sakari Ailus <sakari.ailus@xxxxxxxxxxxxxxx>
> ---
>  drivers/acpi/property.c | 47 ++++++++++++++++++++++++++++++++++++++---------
>  1 file changed, 38 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c
> index 10af340eedd23..d26142aa19d1a 100644
> --- a/drivers/acpi/property.c
> +++ b/drivers/acpi/property.c
> @@ -1027,6 +1027,26 @@ struct fwnode_handle *acpi_node_get_parent(const struct fwnode_handle *fwnode)
>  	return NULL;
>  }
>  
> +/*
> + * Return true if the node is an ACPI graph node. Called on either ports
> + * or endpoints.
> + */
> +static bool is_acpi_graph_node(struct fwnode_handle *fwnode,
> +			       const char *str)
> +{
> +	unsigned int len = strlen(str);
> +	const char *name;
> +
> +	if (!len || !is_acpi_data_node(fwnode))
> +		return false;
> +
> +	name = to_acpi_data_node(fwnode)->name;
> +
> +	return (fwnode_property_present(fwnode, "reg") &&
> +		!strncmp(name, str, len) && name[len] == '@') ||
> +		fwnode_property_present(fwnode, str);
> +}
> +
>  /**
>   * acpi_graph_get_next_endpoint - Get next endpoint ACPI firmware node
>   * @fwnode: Pointer to the parent firmware node
> @@ -1045,8 +1065,12 @@ static struct fwnode_handle *acpi_graph_get_next_endpoint(
>  	if (!prev) {
>  		do {
>  			port = fwnode_get_next_child_node(fwnode, port);
> -			/* Ports must have port property */
> -			if (fwnode_property_present(port, "port"))
> +			/*
> +			 * Ports must have port property or their name begins
> +			 * with "port" and they have the reg property to tell
> +			 * the number of the port.
> +			 */
> +			if (is_acpi_graph_node(port, "port"))
>  				break;
>  		} while (port);
>  	} else {
> @@ -1061,12 +1085,16 @@ static struct fwnode_handle *acpi_graph_get_next_endpoint(
>  		port = fwnode_get_next_child_node(fwnode, port);
>  		if (!port)
>  			break;
> -		if (fwnode_property_present(port, "port"))
> +		if (is_acpi_graph_node(port, "port"))
>  			endpoint = fwnode_get_next_child_node(port, NULL);
>  	}
>  
> -	/* Endpoints must have "endpoint" property */
> -	if (!fwnode_property_present(endpoint, "endpoint"))
> +	/*
> +	 * Endpoints must have "endpoint" property or their name beings
> +	 * with "endpoint" and they have the reg property to tell the
> +	 * number of the endpoint.
> +	 */
> +	if (!is_acpi_graph_node(endpoint, "endpoint"))
>  		return NULL;
>  
>  	return endpoint;
> @@ -1139,8 +1167,7 @@ acpi_graph_get_remote_endpoint(const struct fwnode_handle *__fwnode)
>  
>  	fwnode = acpi_graph_get_child_prop_value(fwnode, "port", port_nr);
>  
> -	return acpi_graph_get_child_prop_value(fwnode, "endpoint",
> -					       endpoint_nr);
> +	return acpi_graph_get_child_prop_value(fwnode, "endpoint", endpoint_nr);
>  }
>  
>  static bool acpi_fwnode_device_is_available(const struct fwnode_handle *fwnode)
> @@ -1217,8 +1244,10 @@ static int acpi_fwnode_graph_parse_endpoint(const struct fwnode_handle *fwnode,
>  
>  	endpoint->local_fwnode = fwnode;
>  
> -	fwnode_property_read_u32(port_fwnode, "port", &endpoint->port);
> -	fwnode_property_read_u32(fwnode, "endpoint", &endpoint->id);
> +	if (fwnode_property_read_u32(port_fwnode, "reg", &endpoint->port))
> +		fwnode_property_read_u32(port_fwnode, "port", &endpoint->port);
> +	if (fwnode_property_read_u32(fwnode, "reg", &endpoint->id))
> +		fwnode_property_read_u32(fwnode, "endpoint", &endpoint->id);
>  
>  	return 0;
>  }
> 


--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux IBM ACPI]     [Linux Power Management]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux