Skip to content

Commit a8db7a3

Browse files
Prashant Malanibleungatchromium
authored andcommitted
platform/chrome: cros_ec_typec: Use existing feature check
Replace the cros_typec_feature_supported() function with the pre-existing cros_ec_check_features() function which does the same thing. Signed-off-by: Prashant Malani <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Benson Leung <[email protected]>
1 parent 3abc16a commit a8db7a3

File tree

1 file changed

+5
-22
lines changed

1 file changed

+5
-22
lines changed

drivers/platform/chrome/cros_ec_typec.c

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,24 +1054,6 @@ static int cros_typec_get_cmd_version(struct cros_typec_data *typec)
10541054
return 0;
10551055
}
10561056

1057-
/* Check the EC feature flags to see if TYPEC_* features are supported. */
1058-
static int cros_typec_feature_supported(struct cros_typec_data *typec, enum ec_feature_code feature)
1059-
{
1060-
struct ec_response_get_features resp = {};
1061-
int ret;
1062-
1063-
ret = cros_typec_ec_command(typec, 0, EC_CMD_GET_FEATURES, NULL, 0,
1064-
&resp, sizeof(resp));
1065-
if (ret < 0) {
1066-
dev_warn(typec->dev,
1067-
"Failed to get features, assuming typec feature=%d unsupported.\n",
1068-
feature);
1069-
return 0;
1070-
}
1071-
1072-
return resp.flags[feature / 32] & EC_FEATURE_MASK_1(feature);
1073-
}
1074-
10751057
static void cros_typec_port_work(struct work_struct *work)
10761058
{
10771059
struct cros_typec_data *typec = container_of(work, struct cros_typec_data, port_work);
@@ -1113,6 +1095,7 @@ MODULE_DEVICE_TABLE(of, cros_typec_of_match);
11131095

11141096
static int cros_typec_probe(struct platform_device *pdev)
11151097
{
1098+
struct cros_ec_dev *ec_dev = NULL;
11161099
struct device *dev = &pdev->dev;
11171100
struct cros_typec_data *typec;
11181101
struct ec_response_usb_pd_ports resp;
@@ -1132,10 +1115,10 @@ static int cros_typec_probe(struct platform_device *pdev)
11321115
return ret;
11331116
}
11341117

1135-
typec->typec_cmd_supported = !!cros_typec_feature_supported(typec,
1136-
EC_FEATURE_TYPEC_CMD);
1137-
typec->needs_mux_ack = !!cros_typec_feature_supported(typec,
1138-
EC_FEATURE_TYPEC_MUX_REQUIRE_AP_ACK);
1118+
ec_dev = dev_get_drvdata(&typec->ec->ec->dev);
1119+
typec->typec_cmd_supported = !!cros_ec_check_features(ec_dev, EC_FEATURE_TYPEC_CMD);
1120+
typec->needs_mux_ack = !!cros_ec_check_features(ec_dev,
1121+
EC_FEATURE_TYPEC_MUX_REQUIRE_AP_ACK);
11391122

11401123
ret = cros_typec_ec_command(typec, 0, EC_CMD_USB_PD_PORTS, NULL, 0,
11411124
&resp, sizeof(resp));

0 commit comments

Comments
 (0)