Skip to content

Commit 297d34e

Browse files
Prashant Malanibleungatchromium
authored andcommitted
platform/chrome: cros_ec_proto: Use ec_command for check_features
Use the existing cros_ec_command() for cros_ec_check_features(). This eliminates an unnecessary duplication of the memory allocation/free and memory copy code. Signed-off-by: Prashant Malani <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Benson Leung <[email protected]>
1 parent 7ff2278 commit 297d34e

File tree

1 file changed

+3
-17
lines changed

1 file changed

+3
-17
lines changed

drivers/platform/chrome/cros_ec_proto.c

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -813,33 +813,19 @@ EXPORT_SYMBOL(cros_ec_get_host_event);
813813
bool cros_ec_check_features(struct cros_ec_dev *ec, int feature)
814814
{
815815
struct ec_response_get_features *features = &ec->features;
816-
struct cros_ec_command *msg;
817816
int ret;
818817

819818
if (features->flags[0] == -1U && features->flags[1] == -1U) {
820819
/* features bitmap not read yet */
821-
msg = kzalloc(sizeof(*msg) + sizeof(*features), GFP_KERNEL);
822-
if (!msg) {
823-
dev_err(ec->dev, "failed to allocate memory to get EC features\n");
824-
return false;
825-
}
826-
827-
msg->command = EC_CMD_GET_FEATURES + ec->cmd_offset;
828-
msg->insize = sizeof(*features);
829-
830-
ret = cros_ec_cmd_xfer_status(ec->ec_dev, msg);
820+
ret = cros_ec_command(ec->ec_dev, 0, EC_CMD_GET_FEATURES + ec->cmd_offset,
821+
NULL, 0, features, sizeof(*features));
831822
if (ret < 0) {
832-
dev_warn(ec->dev, "cannot get EC features: %d/%d\n",
833-
ret, msg->result);
823+
dev_warn(ec->dev, "cannot get EC features: %d\n", ret);
834824
memset(features, 0, sizeof(*features));
835-
} else {
836-
memcpy(features, msg->data, sizeof(*features));
837825
}
838826

839827
dev_dbg(ec->dev, "EC features %08x %08x\n",
840828
features->flags[0], features->flags[1]);
841-
842-
kfree(msg);
843829
}
844830

845831
return !!(features->flags[feature / 32] & EC_FEATURE_MASK_0(feature));

0 commit comments

Comments
 (0)