From 2c04602122aeccb1252276f29314afbcce57cd10 Mon Sep 17 00:00:00 2001 From: Arun Prakash Date: Fri, 29 May 2020 20:16:27 +0530 Subject: [PATCH] net: qrtr: mhi_dev: Handle mhi register error case Handle -EEXIST error case while register state callback with mhi device. If channel is open during registration no callback will issue instead mhi stack return -EEXIST to notify the client. Further state change notification will be informed via registered callback. commit net: qrtr: mhi_dev: Handle mhi register error case (f1eeca90b18b7). Change-Id: Icf60de35d23393a0808ef90058c1108e950d02b9 Signed-off-by: Arun Prakash Signed-off-by: Manoharan Vijaya Raghavan --- net/qrtr/mhi_dev.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/net/qrtr/mhi_dev.c b/net/qrtr/mhi_dev.c index 1eb5649eb50b..3f6091c1656b 100644 --- a/net/qrtr/mhi_dev.c +++ b/net/qrtr/mhi_dev.c @@ -202,6 +202,7 @@ static int qrtr_mhi_dev_probe(struct platform_device *pdev) struct qrtr_mhi_dev_ep *qep; struct device_node *node; int rc; + struct mhi_dev_client_cb_data cb_data; qep = devm_kzalloc(&pdev->dev, sizeof(*qep), GFP_KERNEL); if (!qep) @@ -228,8 +229,21 @@ static int qrtr_mhi_dev_probe(struct platform_device *pdev) */ rc = mhi_register_state_cb(qrtr_mhi_dev_state_cb, qep, QRTR_MHI_DEV_OUT); - if (rc) + if (rc == -EEXIST) { + /** + * MHI stack will return -EEXIST if mhi channel is already + * opend by the host and will not invoke reqistered callback. + * But future state change notification will inform through + * registered callback. + */ + complete_all(&qep->out_tre); + cb_data.user_data = (void *)qep; + cb_data.channel = QRTR_MHI_DEV_OUT; + cb_data.ctrl_info = MHI_STATE_CONNECTED; + qrtr_mhi_dev_state_cb(&cb_data); + } else if (rc) { return rc; + } return 0; }