EC feature flags now require more than 32 bits to be represented. In
order to make cros_ec_check_features() usable for more recent features,
update it to account for the extra 32 bits of features.
Signed-off-by: Prashant Malani <[email protected]>
---
Changes in v2:
- No changes.
drivers/platform/chrome/cros_ec_proto.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/platform/chrome/cros_ec_proto.c b/drivers/platform/chrome/cros_ec_proto.c
index a7404d69b2d3..772edad80593 100644
--- a/drivers/platform/chrome/cros_ec_proto.c
+++ b/drivers/platform/chrome/cros_ec_proto.c
@@ -813,6 +813,7 @@ EXPORT_SYMBOL(cros_ec_get_host_event);
int cros_ec_check_features(struct cros_ec_dev *ec, int feature)
{
struct cros_ec_command *msg;
+ u32 mask;
int ret;
if (ec->features[0] == -1U && ec->features[1] == -1U) {
@@ -839,7 +840,12 @@ int cros_ec_check_features(struct cros_ec_dev *ec, int feature)
kfree(msg);
}
- return ec->features[feature / 32] & EC_FEATURE_MASK_0(feature);
+ if (feature >= 32)
+ mask = EC_FEATURE_MASK_1(feature);
+ else
+ mask = EC_FEATURE_MASK_0(feature);
+
+ return ec->features[feature / 32] & mask;
}
EXPORT_SYMBOL_GPL(cros_ec_check_features);
--
2.32.0.554.ge1b32706d8-goog
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]>
---
Changes in v2:
- Dropped unnecessary NULL checks, per review comments.
drivers/platform/chrome/cros_ec_typec.c | 27 +++++--------------------
1 file changed, 5 insertions(+), 22 deletions(-)
diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c
index 27c068c4c38d..262a891eded3 100644
--- a/drivers/platform/chrome/cros_ec_typec.c
+++ b/drivers/platform/chrome/cros_ec_typec.c
@@ -1054,24 +1054,6 @@ static int cros_typec_get_cmd_version(struct cros_typec_data *typec)
return 0;
}
-/* 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;
-
- ret = cros_typec_ec_command(typec, 0, EC_CMD_GET_FEATURES, NULL, 0,
- &resp, sizeof(resp));
- if (ret < 0) {
- dev_warn(typec->dev,
- "Failed to get features, assuming typec feature=%d unsupported.\n",
- feature);
- return 0;
- }
-
- return resp.flags[feature / 32] & EC_FEATURE_MASK_1(feature);
-}
-
static void cros_typec_port_work(struct work_struct *work)
{
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);
static int cros_typec_probe(struct platform_device *pdev)
{
+ struct cros_ec_dev *ec_dev = NULL;
struct device *dev = &pdev->dev;
struct cros_typec_data *typec;
struct ec_response_usb_pd_ports resp;
@@ -1132,10 +1115,10 @@ static int cros_typec_probe(struct platform_device *pdev)
return ret;
}
- typec->typec_cmd_supported = !!cros_typec_feature_supported(typec,
- EC_FEATURE_TYPEC_CMD);
- typec->needs_mux_ack = !!cros_typec_feature_supported(typec,
- EC_FEATURE_TYPEC_MUX_REQUIRE_AP_ACK);
+ ec_dev = dev_get_drvdata(&typec->ec->ec->dev);
+ typec->typec_cmd_supported = !!cros_ec_check_features(ec_dev, EC_FEATURE_TYPEC_CMD);
+ typec->needs_mux_ack = !!cros_ec_check_features(ec_dev,
+ EC_FEATURE_TYPEC_MUX_REQUIRE_AP_ACK);
ret = cros_typec_ec_command(typec, 0, EC_CMD_USB_PD_PORTS, NULL, 0,
&resp, sizeof(resp));
--
2.32.0.554.ge1b32706d8-goog
Friendly ping.
On Tue, Aug 3, 2021 at 10:36 AM Prashant Malani <[email protected]> wrote:
>
> EC feature flags now require more than 32 bits to be represented. In
> order to make cros_ec_check_features() usable for more recent features,
> update it to account for the extra 32 bits of features.
>
> Signed-off-by: Prashant Malani <[email protected]>
> ---
> Changes in v2:
> - No changes.
>
> drivers/platform/chrome/cros_ec_proto.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/platform/chrome/cros_ec_proto.c b/drivers/platform/chrome/cros_ec_proto.c
> index a7404d69b2d3..772edad80593 100644
> --- a/drivers/platform/chrome/cros_ec_proto.c
> +++ b/drivers/platform/chrome/cros_ec_proto.c
> @@ -813,6 +813,7 @@ EXPORT_SYMBOL(cros_ec_get_host_event);
> int cros_ec_check_features(struct cros_ec_dev *ec, int feature)
> {
> struct cros_ec_command *msg;
> + u32 mask;
> int ret;
>
> if (ec->features[0] == -1U && ec->features[1] == -1U) {
> @@ -839,7 +840,12 @@ int cros_ec_check_features(struct cros_ec_dev *ec, int feature)
> kfree(msg);
> }
>
> - return ec->features[feature / 32] & EC_FEATURE_MASK_0(feature);
> + if (feature >= 32)
> + mask = EC_FEATURE_MASK_1(feature);
> + else
> + mask = EC_FEATURE_MASK_0(feature);
> +
> + return ec->features[feature / 32] & mask;
> }
> EXPORT_SYMBOL_GPL(cros_ec_check_features);
>
> --
> 2.32.0.554.ge1b32706d8-goog
>
On Tue, 3 Aug 2021 10:36:19 -0700, Prashant Malani wrote:
> EC feature flags now require more than 32 bits to be represented. In
> order to make cros_ec_check_features() usable for more recent features,
> update it to account for the extra 32 bits of features.
Applied the whole series, thanks!
[1/2] platform/chrome: cros_ec_proto: Update feature check
commit: 3c645a03579d15de3b6ffd6d75801011d80416fc
[2/2] platform/chrome: cros_ec_typec: Use existing feature check
commit: 7ddbb62d7b43e3334a52427cd9666d90a833bd19
Best regards,
--
Benson Leung
Staff Software Engineer
Chrome OS Kernel
Google Inc.
[email protected]
Chromium OS Project
[email protected]