MHI will use the mhi_controller data structure to store the QRTR endpoint id, as explained previously. Signed-off-by: Juha-Matti Tilli --- net/qrtr/mhi.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/net/qrtr/mhi.c b/net/qrtr/mhi.c index 630ce0da060e5..41b58ab854725 100644 --- a/net/qrtr/mhi.c +++ b/net/qrtr/mhi.c @@ -7,6 +7,7 @@ #include #include #include +#include #include "qrtr.h" @@ -116,6 +117,17 @@ static ssize_t endpoint_show(struct device *dev, static DEVICE_ATTR_RO(endpoint); +static void qcom_mhi_qrtr_free_mhi_id(void *mhi_cntrl_void) +{ + struct mhi_controller *mhi_cntrl = mhi_cntrl_void; + u32 id = mhi_cntrl->qrtr_endpoint_id; + + if (id != 0) + qrtr_endpoint_free_data_id(id); + mhi_cntrl->qrtr_endpoint_id = 0; + mhi_cntrl->free_qrtr_endpoint_id = NULL; +} + static int qcom_mhi_qrtr_probe(struct mhi_device *mhi_dev, const struct mhi_device_id *id) { @@ -130,6 +142,23 @@ static int qcom_mhi_qrtr_probe(struct mhi_device *mhi_dev, qdev->dev = &mhi_dev->dev; qdev->ep.xmit = qcom_mhi_qrtr_send; + spin_lock(&mhi_dev->mhi_cntrl->qrtr_endpoint_lock); + if (mhi_dev->mhi_cntrl->qrtr_endpoint_id) { + qdev->ep.endpoint_data_id = + mhi_dev->mhi_cntrl->qrtr_endpoint_id; + } else { + rc = qrtr_endpoint_get_data_id(&qdev->ep.endpoint_data_id); + if (rc) { + spin_unlock(&mhi_dev->mhi_cntrl->qrtr_endpoint_lock); + return -ENOMEM; + } + mhi_dev->mhi_cntrl->qrtr_endpoint_id = + qdev->ep.endpoint_data_id; + mhi_dev->mhi_cntrl->free_qrtr_endpoint_id = + qcom_mhi_qrtr_free_mhi_id; + } + spin_unlock(&mhi_dev->mhi_cntrl->qrtr_endpoint_lock); + dev_set_drvdata(&mhi_dev->dev, qdev); /* start channels */ @@ -150,6 +179,9 @@ static int qcom_mhi_qrtr_probe(struct mhi_device *mhi_dev, dev_dbg(qdev->dev, "Qualcomm MHI QRTR driver probed\n"); + mhi_dev->mhi_cntrl->qrtr_endpoint_id = qdev->ep.id; + mhi_dev->mhi_cntrl->free_qrtr_endpoint_id = qcom_mhi_qrtr_free_mhi_id; + return 0; err_unregister: -- 2.34.1