aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSakari Ailus <sakari.ailus@linux.intel.com>2018-07-17 10:19:16 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2018-07-23 06:44:52 -0400
commit18f1e58d1536f69d4e35f6eabaa07e57eb317314 (patch)
tree4a1d8b66e52cc9352c16846895a9df0119b9cda7
parent6561eb3d3a23c4d38ba428396b7a14e184804535 (diff)
ACPI: property: Use data node name and reg property for graphs
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. Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-rw-r--r--drivers/acpi/property.c51
1 files changed, 42 insertions, 9 deletions
diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c
index 10af340eedd2..693cf05b0cc4 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)
1027 return NULL; 1027 return NULL;
1028} 1028}
1029 1029
1030/*
1031 * Return true if the node is an ACPI graph node. Called on either ports
1032 * or endpoints.
1033 */
1034static bool is_acpi_graph_node(struct fwnode_handle *fwnode,
1035 const char *str)
1036{
1037 unsigned int len = strlen(str);
1038 const char *name;
1039
1040 if (!len || !is_acpi_data_node(fwnode))
1041 return false;
1042
1043 name = to_acpi_data_node(fwnode)->name;
1044
1045 return (fwnode_property_present(fwnode, "reg") &&
1046 !strncmp(name, str, len) && name[len] == '@') ||
1047 fwnode_property_present(fwnode, str);
1048}
1049
1030/** 1050/**
1031 * acpi_graph_get_next_endpoint - Get next endpoint ACPI firmware node 1051 * acpi_graph_get_next_endpoint - Get next endpoint ACPI firmware node
1032 * @fwnode: Pointer to the parent firmware node 1052 * @fwnode: Pointer to the parent firmware node
@@ -1045,8 +1065,14 @@ static struct fwnode_handle *acpi_graph_get_next_endpoint(
1045 if (!prev) { 1065 if (!prev) {
1046 do { 1066 do {
1047 port = fwnode_get_next_child_node(fwnode, port); 1067 port = fwnode_get_next_child_node(fwnode, port);
1048 /* Ports must have port property */ 1068 /*
1049 if (fwnode_property_present(port, "port")) 1069 * The names of the port nodes begin with "port@"
1070 * followed by the number of the port node and they also
1071 * have a "reg" property that also has the number of the
1072 * port node. For compatibility reasons a node is also
1073 * recognised as a port node from the "port" property.
1074 */
1075 if (is_acpi_graph_node(port, "port"))
1050 break; 1076 break;
1051 } while (port); 1077 } while (port);
1052 } else { 1078 } else {
@@ -1061,12 +1087,18 @@ static struct fwnode_handle *acpi_graph_get_next_endpoint(
1061 port = fwnode_get_next_child_node(fwnode, port); 1087 port = fwnode_get_next_child_node(fwnode, port);
1062 if (!port) 1088 if (!port)
1063 break; 1089 break;
1064 if (fwnode_property_present(port, "port")) 1090 if (is_acpi_graph_node(port, "port"))
1065 endpoint = fwnode_get_next_child_node(port, NULL); 1091 endpoint = fwnode_get_next_child_node(port, NULL);
1066 } 1092 }
1067 1093
1068 /* Endpoints must have "endpoint" property */ 1094 /*
1069 if (!fwnode_property_present(endpoint, "endpoint")) 1095 * The names of the endpoint nodes begin with "endpoint@" followed by
1096 * the number of the endpoint node and they also have a "reg" property
1097 * that also has the number of the endpoint node. For compatibility
1098 * reasons a node is also recognised as an endpoint node from the
1099 * "endpoint" property.
1100 */
1101 if (!is_acpi_graph_node(endpoint, "endpoint"))
1070 return NULL; 1102 return NULL;
1071 1103
1072 return endpoint; 1104 return endpoint;
@@ -1139,8 +1171,7 @@ acpi_graph_get_remote_endpoint(const struct fwnode_handle *__fwnode)
1139 1171
1140 fwnode = acpi_graph_get_child_prop_value(fwnode, "port", port_nr); 1172 fwnode = acpi_graph_get_child_prop_value(fwnode, "port", port_nr);
1141 1173
1142 return acpi_graph_get_child_prop_value(fwnode, "endpoint", 1174 return acpi_graph_get_child_prop_value(fwnode, "endpoint", endpoint_nr);
1143 endpoint_nr);
1144} 1175}
1145 1176
1146static bool acpi_fwnode_device_is_available(const struct fwnode_handle *fwnode) 1177static bool acpi_fwnode_device_is_available(const struct fwnode_handle *fwnode)
@@ -1217,8 +1248,10 @@ static int acpi_fwnode_graph_parse_endpoint(const struct fwnode_handle *fwnode,
1217 1248
1218 endpoint->local_fwnode = fwnode; 1249 endpoint->local_fwnode = fwnode;
1219 1250
1220 fwnode_property_read_u32(port_fwnode, "port", &endpoint->port); 1251 if (fwnode_property_read_u32(port_fwnode, "reg", &endpoint->port))
1221 fwnode_property_read_u32(fwnode, "endpoint", &endpoint->id); 1252 fwnode_property_read_u32(port_fwnode, "port", &endpoint->port);
1253 if (fwnode_property_read_u32(fwnode, "reg", &endpoint->id))
1254 fwnode_property_read_u32(fwnode, "endpoint", &endpoint->id);
1222 1255
1223 return 0; 1256 return 0;
1224} 1257}