From 91747af56140bd76dde0550592117f3555bd16d5 Mon Sep 17 00:00:00 2001 From: Puja Gupta Date: Mon, 15 May 2017 11:15:07 -0700 Subject: [PATCH] soc: qcom: Fix checks for QMI response values The return values from QMI could be compared directly and was incorrectly interpreted in service locator and notifier. Also initialize structure in service locator so as to not have garbage values in them. Change-Id: I7f8f27857706e9508b64289d9263c79494c17a8d Signed-off-by: Puja Gupta --- drivers/soc/qcom/service-locator.c | 9 ++++----- drivers/soc/qcom/service-notifier.c | 21 +++++++++------------ include/soc/qcom/msm_qmi_interface.h | 2 +- 3 files changed, 14 insertions(+), 18 deletions(-) diff --git a/drivers/soc/qcom/service-locator.c b/drivers/soc/qcom/service-locator.c index 97cd11201262..f19db5fe99b3 100644 --- a/drivers/soc/qcom/service-locator.c +++ b/drivers/soc/qcom/service-locator.c @@ -31,7 +31,6 @@ #define SERVREG_LOC_SERVICE_INSTANCE_ID 1 -#define QMI_RESP_BIT_SHIFT(x) (x << 16) #define QMI_SERVREG_LOC_SERVER_INITIAL_TIMEOUT 2000 #define QMI_SERVREG_LOC_SERVER_TIMEOUT 2000 #define INITIAL_TIMEOUT 100000 @@ -199,9 +198,9 @@ static int servreg_loc_send_msg(struct msg_desc *req_desc, } /* Check the response */ - if (QMI_RESP_BIT_SHIFT(resp->resp.result) != QMI_RESULT_SUCCESS_V01) { + if (resp->resp.result != QMI_RESULT_SUCCESS_V01) { pr_err("QMI request for client %s failed 0x%x\n", - pd->client_name, QMI_RESP_BIT_SHIFT(resp->resp.error)); + pd->client_name, resp->resp.error); return -EREMOTEIO; } return rc; @@ -220,7 +219,7 @@ static int service_locator_send_msg(struct pd_qmi_client_data *pd) return -EAGAIN; } - req = kmalloc(sizeof( + req = kzalloc(sizeof( struct qmi_servreg_loc_get_domain_list_req_msg_v01), GFP_KERNEL); if (!req) { @@ -228,7 +227,7 @@ static int service_locator_send_msg(struct pd_qmi_client_data *pd) rc = -ENOMEM; goto out; } - resp = kmalloc(sizeof( + resp = kzalloc(sizeof( struct qmi_servreg_loc_get_domain_list_resp_msg_v01), GFP_KERNEL); if (!resp) { diff --git a/drivers/soc/qcom/service-notifier.c b/drivers/soc/qcom/service-notifier.c index b5681a5c6817..221ae0c1fefb 100644 --- a/drivers/soc/qcom/service-notifier.c +++ b/drivers/soc/qcom/service-notifier.c @@ -30,7 +30,6 @@ #include #include "service-notifier-private.h" -#define QMI_RESP_BIT_SHIFT(x) (x << 16) #define SERVREG_NOTIF_NAME_LENGTH QMI_SERVREG_NOTIF_NAME_LENGTH_V01 #define SERVREG_NOTIF_SERVICE_ID SERVREG_NOTIF_SERVICE_ID_V01 #define SERVREG_NOTIF_SERVICE_VERS SERVREG_NOTIF_SERVICE_VERS_V01 @@ -225,9 +224,8 @@ static void send_ind_ack(struct work_struct *work) } /* Check the response */ - if (QMI_RESP_BIT_SHIFT(resp.resp.result) != QMI_RESULT_SUCCESS_V01) - pr_err("QMI request failed 0x%x\n", - QMI_RESP_BIT_SHIFT(resp.resp.error)); + if (resp.resp.result != QMI_RESULT_SUCCESS_V01) + pr_err("QMI request failed 0x%x\n", resp.resp.error); pr_info("Indication ACKed for transid %d, service %s, instance %d!\n", data->ind_msg.transaction_id, data->ind_msg.service_path, data->instance_id); @@ -318,9 +316,8 @@ static int send_notif_listener_msg_req(struct service_notif_info *service_notif, } /* Check the response */ - if (QMI_RESP_BIT_SHIFT(resp.resp.result) != QMI_RESULT_SUCCESS_V01) { - pr_err("QMI request failed 0x%x\n", - QMI_RESP_BIT_SHIFT(resp.resp.error)); + if (resp.resp.result != QMI_RESULT_SUCCESS_V01) { + pr_err("QMI request failed 0x%x\n", resp.resp.error); return -EREMOTEIO; } @@ -645,15 +642,15 @@ static int send_pd_restart_req(const char *service_path, } /* Check response if PDR is disabled */ - if (QMI_RESP_BIT_SHIFT(resp.resp.result) == QMI_ERR_DISABLED_V01) { - pr_err("PD restart is disabled 0x%x\n", - QMI_RESP_BIT_SHIFT(resp.resp.error)); + if (resp.resp.result == QMI_RESULT_FAILURE_V01 && + resp.resp.error == QMI_ERR_DISABLED_V01) { + pr_err("PD restart is disabled 0x%x\n", resp.resp.error); return -EOPNOTSUPP; } /* Check the response for other error case*/ - if (QMI_RESP_BIT_SHIFT(resp.resp.result) != QMI_RESULT_SUCCESS_V01) { + if (resp.resp.result != QMI_RESULT_SUCCESS_V01) { pr_err("QMI request for PD restart failed 0x%x\n", - QMI_RESP_BIT_SHIFT(resp.resp.error)); + resp.resp.error); return -EREMOTEIO; } diff --git a/include/soc/qcom/msm_qmi_interface.h b/include/soc/qcom/msm_qmi_interface.h index 5ca808dd1fc2..38f390ee71b7 100644 --- a/include/soc/qcom/msm_qmi_interface.h +++ b/include/soc/qcom/msm_qmi_interface.h @@ -92,7 +92,6 @@ enum qmi_result_type_v01 { QMI_RESULT_TYPE_MIN_ENUM_VAL_V01 = INT_MIN, QMI_RESULT_SUCCESS_V01 = 0, QMI_RESULT_FAILURE_V01 = 1, - QMI_ERR_DISABLED_V01 = 0x45, QMI_RESULT_TYPE_MAX_ENUM_VAL_V01 = INT_MAX, }; @@ -106,6 +105,7 @@ enum qmi_error_type_v01 { QMI_ERR_CLIENT_IDS_EXHAUSTED_V01 = 0x0005, QMI_ERR_INVALID_ID_V01 = 0x0029, QMI_ERR_ENCODING_V01 = 0x003A, + QMI_ERR_DISABLED_V01 = 0x0045, QMI_ERR_INCOMPATIBLE_STATE_V01 = 0x005A, QMI_ERR_NOT_SUPPORTED_V01 = 0x005E, QMI_ERR_TYPE_MAX_ENUM_VAL_V01 = INT_MAX,