diff options
author | Utkarsh Patel <utkarsh.h.patel@intel.com> | 2020-12-09 22:09:02 -0800 |
---|---|---|
committer | Benson Leung <bleung@chromium.org> | 2021-01-05 12:57:15 -0800 |
commit | ba8ce515454e1fc5e73ff8989c18c596a3449fef (patch) | |
tree | 7c86d33dfd9c65391ca3a9238d90dc8ba463e239 /drivers/platform/chrome/cros_ec_typec.c | |
parent | 1563090965421f7e96cc006c150180f1526a24f7 (diff) | |
download | linux-stable-ba8ce515454e1fc5e73ff8989c18c596a3449fef.tar.gz linux-stable-ba8ce515454e1fc5e73ff8989c18c596a3449fef.tar.bz2 linux-stable-ba8ce515454e1fc5e73ff8989c18c596a3449fef.zip |
platform/chrome: cros_ec_typec: Parameterize cros_typec_cmds_supported()
cros_typec_cmds_supported() is currently being used to check only one
feature flag.
Add a new feature parameter to it so that it can be used to check
multiple feature flags supported in cros_ec.
Rename cros_typec_cmds_supported() to cros_typec_feature_supported().
Signed-off-by: Utkarsh Patel <utkarsh.h.patel@intel.com>
Reviewed-by: Prashant Malani <pmalani@chromium.org>
Signed-off-by: Benson Leung <bleung@chromium.org>
Link: https://lore.kernel.org/r/20201210060903.2205-2-utkarsh.h.patel@intel.com
Diffstat (limited to 'drivers/platform/chrome/cros_ec_typec.c')
-rw-r--r-- | drivers/platform/chrome/cros_ec_typec.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c index fd446f9029a0..6068433dd2e2 100644 --- a/drivers/platform/chrome/cros_ec_typec.c +++ b/drivers/platform/chrome/cros_ec_typec.c @@ -974,8 +974,8 @@ static int cros_typec_get_cmd_version(struct cros_typec_data *typec) return 0; } -/* Check the EC feature flags to see if TYPEC_* commands are supported. */ -static int cros_typec_cmds_supported(struct cros_typec_data *typec) +/* Check the EC feature flags to see if TYPEC_* features are supported. */ +static int cros_typec_feature_supported(struct cros_typec_data *typec, enum ec_feature_code feature) { struct ec_response_get_features resp = {}; int ret; @@ -984,11 +984,12 @@ static int cros_typec_cmds_supported(struct cros_typec_data *typec) &resp, sizeof(resp)); if (ret < 0) { dev_warn(typec->dev, - "Failed to get features, assuming typec commands unsupported.\n"); + "Failed to get features, assuming typec feature=%d unsupported.\n", + feature); return 0; } - return resp.flags[EC_FEATURE_TYPEC_CMD / 32] & EC_FEATURE_MASK_1(EC_FEATURE_TYPEC_CMD); + return resp.flags[feature / 32] & EC_FEATURE_MASK_1(feature); } static void cros_typec_port_work(struct work_struct *work) @@ -1050,7 +1051,8 @@ static int cros_typec_probe(struct platform_device *pdev) return ret; } - typec->typec_cmd_supported = !!cros_typec_cmds_supported(typec); + typec->typec_cmd_supported = !!cros_typec_feature_supported(typec, + EC_FEATURE_TYPEC_CMD); ret = cros_typec_ec_command(typec, 0, EC_CMD_USB_PD_PORTS, NULL, 0, &resp, sizeof(resp)); |