Skip to contentSkip to conversation

platform/chrome: cros_ec_typec: Make try power role optional

PATCH In review Prashant Malani 3 participants 3 messages Jan 27, 2022 – Jan 31, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 platform/chrome: cros_ec_typec: Make try power role optional

Some boards prefer not to specify a try-power-role. Update the port property parsing logic to not error out in case a try-power-role is not specified.

---
 drivers/platform/chrome/cros_ec_typec.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
drivers/platform/chrome/cros_ec_typec.c +8 -7
index 5de0bfb0bc4d..ee12658009e5 100644
@@ -115,17 +115,18 @@ static int cros_typec_parse_port_props(struct typec_capability *cap,
 		return ret;
 	cap->data = ret;
 
+	/* Try-power-role is optional. */
 	ret = fwnode_property_read_string(fwnode, "try-power-role", &buf);
 	if (ret) {
-		dev_err(dev, "try-power-role not found: %d\n", ret);
-		return ret;
+		dev_warn(dev, "try-power-role not found: %d\n", ret);
+		cap->prefer_role = TYPEC_NO_PREFERRED_ROLE;
+	} else {
+		ret = typec_find_power_role(buf);
+		if (ret < 0)
+			return ret;
+		cap->prefer_role = ret;
 	}
 
-	ret = typec_find_power_role(buf);
-	if (ret < 0)
-		return ret;
-	cap->prefer_role = ret;
-
 	cap->fwnode = fwnode;
 
 	return 0;
Signature · 1 line
2.35.0.rc0.227.g00780c9af4-goog
#1 lore raw

Hi Prashant,

Quoted 6 lines · Prashant Malani

Some boards prefer not to specify a try-power-role. Update the port property parsing logic to not error out in case a try-power-role is not specified.

This looks good to me.

Heikki, if this usage of TYPEC_NO_PREFERRED_ROLE looks good to you, I can merge it.

Benson

Quoted 37 lines
---
 drivers/platform/chrome/cros_ec_typec.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
drivers/platform/chrome/cros_ec_typec.c +8 -7
index 5de0bfb0bc4d..ee12658009e5 100644
@@ -115,17 +115,18 @@ static int cros_typec_parse_port_props(struct typec_capability *cap,
 		return ret;
 	cap->data = ret;
 
+	/* Try-power-role is optional. */
 	ret = fwnode_property_read_string(fwnode, "try-power-role", &buf);
 	if (ret) {
-		dev_err(dev, "try-power-role not found: %d\n", ret);
-		return ret;
+		dev_warn(dev, "try-power-role not found: %d\n", ret);
+		cap->prefer_role = TYPEC_NO_PREFERRED_ROLE;
+	} else {
+		ret = typec_find_power_role(buf);
+		if (ret < 0)
+			return ret;
+		cap->prefer_role = ret;
 	}
 
-	ret = typec_find_power_role(buf);
-	if (ret < 0)
-		return ret;
-	cap->prefer_role = ret;
-
 	cap->fwnode = fwnode;
 
 	return 0;
Signature · 1 line
2.35.0.rc0.227.g00780c9af4-goog
Signature · 7 lines
Benson Leung
Staff Software Engineer
Chrome OS Kernel
Google Inc.
[email protected]
Chromium OS Project
[email protected]
#2 lore raw

Hi,

Quoted 7 lines · Benson Leung

Hi Prashant,

Quoted 4 lines · Prashant Malani

Some boards prefer not to specify a try-power-role. Update the port property parsing logic to not error out in case a try-power-role is not specified.

Quoted 7 lines
Quoted 2 lines

This looks good to me.

Heikki, if this usage of TYPEC_NO_PREFERRED_ROLE looks good to you, I can merge it.

This is OK by me. FWIW:

thanks,

Quoted 34 lines
Quoted 34 lines
---
 drivers/platform/chrome/cros_ec_typec.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
drivers/platform/chrome/cros_ec_typec.c +8 -7
index 5de0bfb0bc4d..ee12658009e5 100644
@@ -115,17 +115,18 @@ static int cros_typec_parse_port_props(struct typec_capability *cap,
 		return ret;
 	cap->data = ret;
 
+	/* Try-power-role is optional. */
 	ret = fwnode_property_read_string(fwnode, "try-power-role", &buf);
 	if (ret) {
-		dev_err(dev, "try-power-role not found: %d\n", ret);
-		return ret;
+		dev_warn(dev, "try-power-role not found: %d\n", ret);
+		cap->prefer_role = TYPEC_NO_PREFERRED_ROLE;
+	} else {
+		ret = typec_find_power_role(buf);
+		if (ret < 0)
+			return ret;
+		cap->prefer_role = ret;
 	}
 
-	ret = typec_find_power_role(buf);
-	if (ret < 0)
-		return ret;
-	cap->prefer_role = ret;
-
 	cap->fwnode = fwnode;
 
 	return 0;
Signature · 1 line
heikki