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>
This commit is contained in:
parent
840d9f131f
commit
5156fb75ea
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue