Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

platform/chrome: cros_ec_proto: Update cros_ec_cmd_xfer() call-sites

Since all the other call-sites of cros_ec_cmd_xfer() have been converted
to use cros_ec_cmd_xfer_status() instead, update the remaining
call-sites to prepare for the merge of cros_ec_cmd_xfer() into
cros_ec_cmd_xfer_status().

As part of this update, change the error handling inside
cros_ec_get_sensor_count() such that the legacy LPC interface is tried
on all error values, not just when msg->result != EC_RESULT_SUCCESS.

Note that there is a slight change in API in cros_ec_get_sensor_count():
it will return a negative number of sensors when there are no sensors
on arm platform when MOTIONSENSE_CMD_DUMP is not supported (typical for
sensorless chromebook) instead of 0. However, this is not a problem when
probing the EC as we ignore errors only looking for cros_ec_get_sensor_count()
returning a positive number of sensors.

Signed-off-by: Prashant Malani <pmalani@chromium.org>
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
Tested-by: Gwendal Grignou <gwendal@chromium.org>
Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>

authored by

Prashant Malani and committed by
Enric Balletbo i Serra
64b02e54 dd92f7df

+4 -11
+4 -11
drivers/platform/chrome/cros_ec_proto.c
··· 650 650 msg->insize = size; 651 651 msg->outsize = 0; 652 652 653 - ret = cros_ec_cmd_xfer(ec_dev, msg); 653 + ret = cros_ec_cmd_xfer_status(ec_dev, msg); 654 654 if (ret > 0) { 655 655 ec_dev->event_size = ret - 1; 656 656 ec_dev->event_data = *event; ··· 694 694 msg->insize = sizeof(ec_dev->event_data.data); 695 695 msg->outsize = 0; 696 696 697 - ec_dev->event_size = cros_ec_cmd_xfer(ec_dev, msg); 697 + ec_dev->event_size = cros_ec_cmd_xfer_status(ec_dev, msg); 698 698 ec_dev->event_data.event_type = EC_MKBP_EVENT_KEY_MATRIX; 699 699 memcpy(&ec_dev->event_data.data, msg->data, 700 700 sizeof(ec_dev->event_data.data)); ··· 883 883 params = (struct ec_params_motion_sense *)msg->data; 884 884 params->cmd = MOTIONSENSE_CMD_DUMP; 885 885 886 - ret = cros_ec_cmd_xfer(ec->ec_dev, msg); 886 + ret = cros_ec_cmd_xfer_status(ec->ec_dev, msg); 887 887 if (ret < 0) { 888 888 sensor_count = ret; 889 - } else if (msg->result != EC_RES_SUCCESS) { 890 - sensor_count = -EPROTO; 891 889 } else { 892 890 resp = (struct ec_response_motion_sense *)msg->data; 893 891 sensor_count = resp->dump.sensor_count; ··· 896 898 * Check legacy mode: Let's find out if sensors are accessible 897 899 * via LPC interface. 898 900 */ 899 - if (sensor_count == -EPROTO && 900 - ec->cmd_offset == 0 && 901 - ec_dev->cmd_readmem) { 901 + if (sensor_count < 0 && ec->cmd_offset == 0 && ec_dev->cmd_readmem) { 902 902 ret = ec_dev->cmd_readmem(ec_dev, EC_MEMMAP_ACC_STATUS, 903 903 1, &status); 904 904 if (ret >= 0 && ··· 911 915 */ 912 916 sensor_count = 0; 913 917 } 914 - } else if (sensor_count == -EPROTO) { 915 - /* EC responded, but does not understand DUMP command. */ 916 - sensor_count = 0; 917 918 } 918 919 return sensor_count; 919 920 }