summaryrefslogtreecommitdiff
path: root/drivers/mfd/cros_ec_dev.c
diff options
context:
space:
mode:
authorEnric Balletbo i Serra <enric.balletbo@collabora.com>2019-09-02 11:53:06 +0200
committerLee Jones <lee.jones@linaro.org>2019-09-02 11:34:07 +0100
commit5156fb75ead1dad9cdd250db898011e92c6ecb22 (patch)
tree438f552db4c07eb0a855577c6178edd6acfebbcc /drivers/mfd/cros_ec_dev.c
parent840d9f131f65b021e0a73f3371f3194897dba6ad (diff)
downloadlinux-5156fb75ead1dad9cdd250db898011e92c6ecb22.tar.gz
mfd: cros_ec: Use kzalloc and cros_ec_cmd_xfer_status helper
This patch makes use of cros_ec_cmd_xfer_status() instead of cros_ec_cmd_xfer() so we can remove some redundant code. It also uses kzalloc instead of kmalloc so we can remove more redundant code. Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com> Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Gwendal Grignou <gwendal@chromium.org> Tested-by: Gwendal Grignou <gwendal@chromium.org> Signed-off-by: Lee Jones <lee.jones@linaro.org>
Diffstat (limited to 'drivers/mfd/cros_ec_dev.c')
-rw-r--r--drivers/mfd/cros_ec_dev.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/drivers/mfd/cros_ec_dev.c b/drivers/mfd/cros_ec_dev.c
index 091d428f5531..148f39c79f41 100644
--- a/drivers/mfd/cros_ec_dev.c
+++ b/drivers/mfd/cros_ec_dev.c
@@ -30,18 +30,15 @@ static int cros_ec_check_features(struct cros_ec_dev *ec, int feature)
if (ec->features[0] == -1U && ec->features[1] == -1U) {
/* features bitmap not read yet */
-
- msg = kmalloc(sizeof(*msg) + sizeof(ec->features), GFP_KERNEL);
+ msg = kzalloc(sizeof(*msg) + sizeof(ec->features), GFP_KERNEL);
if (!msg)
return -ENOMEM;
- msg->version = 0;
msg->command = EC_CMD_GET_FEATURES + ec->cmd_offset;
msg->insize = sizeof(ec->features);
- msg->outsize = 0;
- ret = cros_ec_cmd_xfer(ec->ec_dev, msg);
- if (ret < 0 || msg->result != EC_RES_SUCCESS) {
+ ret = cros_ec_cmd_xfer_status(ec->ec_dev, msg);
+ if (ret < 0) {
dev_warn(ec->dev, "cannot get EC features: %d/%d\n",
ret, msg->result);
memset(ec->features, 0, sizeof(ec->features));
@@ -90,8 +87,8 @@ static void cros_ec_sensors_register(struct cros_ec_dev *ec)
params = (struct ec_params_motion_sense *)msg->data;
params->cmd = MOTIONSENSE_CMD_DUMP;
- ret = cros_ec_cmd_xfer(ec->ec_dev, msg);
- if (ret < 0 || msg->result != EC_RES_SUCCESS) {
+ ret = cros_ec_cmd_xfer_status(ec->ec_dev, msg);
+ if (ret < 0) {
dev_warn(ec->dev, "cannot get EC sensor information: %d/%d\n",
ret, msg->result);
goto error;
@@ -118,8 +115,8 @@ static void cros_ec_sensors_register(struct cros_ec_dev *ec)
for (i = 0; i < sensor_num; i++) {
params->cmd = MOTIONSENSE_CMD_INFO;
params->info.sensor_num = i;
- ret = cros_ec_cmd_xfer(ec->ec_dev, msg);
- if (ret < 0 || msg->result != EC_RES_SUCCESS) {
+ ret = cros_ec_cmd_xfer_status(ec->ec_dev, msg);
+ if (ret < 0) {
dev_warn(ec->dev, "no info for EC sensor %d : %d/%d\n",
i, ret, msg->result);
continue;