summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSujeev Dias <sdias@codeaurora.org>2017-05-12 15:21:07 -0700
committerSujeev Dias <sdias@codeaurora.org>2017-05-31 14:07:31 -0700
commit66551f19b58ac0bcb63636a721d11da80db59c97 (patch)
tree5762bd7a9ea979460f8fbb602b870ee07380e8e3
parent6491d72c2a91df75e3e79b0eb9f0792b4988552f (diff)
mhi: core: Only allow registration if channel is supported by endpoint.
Not all endpoints support all channels supported by MHI host. Only allow clients to register if requested channel is supported by endpoint. CRs-Fixed: 2053250 Change-Id: Ib4bd8d21b8f43d693da30b8fafe2cb9d2e128a17 Signed-off-by: Sujeev Dias <sdias@codeaurora.org>
-rw-r--r--drivers/platform/msm/mhi/mhi_main.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/drivers/platform/msm/mhi/mhi_main.c b/drivers/platform/msm/mhi/mhi_main.c
index 78aa1beb870d..702f9ad5ddfb 100644
--- a/drivers/platform/msm/mhi/mhi_main.c
+++ b/drivers/platform/msm/mhi/mhi_main.c
@@ -508,6 +508,7 @@ int mhi_register_channel(struct mhi_client_handle **client_handle,
struct mhi_client_config *client_config;
const char *node_name;
enum MHI_CLIENT_CHANNEL chan;
+ struct mhi_chan_info chan_info = {0};
int ret;
if (!client_info || client_info->dev->of_node == NULL)
@@ -537,6 +538,14 @@ int mhi_register_channel(struct mhi_client_handle **client_handle,
mhi_log(mhi_dev_ctxt, MHI_MSG_INFO,
"Registering channel 0x%x for client\n", chan);
+ /* check if it's a supported channel by endpoint */
+ ret = get_chan_props(mhi_dev_ctxt, chan, &chan_info);
+ if (ret) {
+ mhi_log(mhi_dev_ctxt, MHI_MSG_ERROR,
+ "Client try to register unsupported chan:%d\n", chan);
+ return -EINVAL;
+ }
+
*client_handle = kzalloc(sizeof(struct mhi_client_handle), GFP_KERNEL);
if (NULL == *client_handle)
return -ENOMEM;
@@ -567,7 +576,7 @@ int mhi_register_channel(struct mhi_client_handle **client_handle,
if (MHI_CLIENT_IP_HW_0_IN == chan)
client_config->intmod_t = 10;
- get_chan_props(mhi_dev_ctxt, chan, &client_config->chan_info);
+ client_config->chan_info = chan_info;
ret = enable_bb_ctxt(mhi_dev_ctxt, &mhi_dev_ctxt->chan_bb_list[chan],
client_config->chan_info.max_desc, chan,
client_config->client_info.max_payload);