From d7067f6740428f2a8963497672fe25695aeac1fb Mon Sep 17 00:00:00 2001 From: Jay Jayanna Date: Mon, 9 Mar 2020 17:49:49 -0700 Subject: [PATCH] net: qrtr: mhi: Set mhi driver data before registering with qrtr The original design was to not send anything from qrtr-mhi until a packet was received from the remote side. This would leave enough time for the probe function to set up the driver_date. With the new requirement to queue a hello packet (for Linux to Linux communication), we may see the hello packet being scheduled and sent before we can return and set the drvdata. The changes to address the above requirement brings in a possibility that driver_data in mhi layer is NULL sometimes. Check device pointer for NULL in ul callback and return if it is NULL. Move the setting of driver data before registering it as an endpoint with the qrtr framework. Change-Id: Ida94d95485d2432f38e6cb0c82fa21af7bc73af3 Signed-off-by: Jay Jayanna --- net/qrtr/mhi.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/net/qrtr/mhi.c b/net/qrtr/mhi.c index ab21357fe1b0..519bd2186d85 100644 --- a/net/qrtr/mhi.c +++ b/net/qrtr/mhi.c @@ -62,6 +62,9 @@ static void qcom_mhi_qrtr_ul_callback(struct mhi_device *mhi_dev, struct qrtr_mhi_pkt *pkt; unsigned long flags; + if (!qdev) + return; + spin_lock_irqsave(&qdev->ul_lock, flags); if (list_empty(&qdev->ul_pkts)) { spin_unlock_irqrestore(&qdev->ul_lock, flags); @@ -171,12 +174,12 @@ static int qcom_mhi_qrtr_probe(struct mhi_device *mhi_dev, INIT_LIST_HEAD(&qdev->ul_pkts); spin_lock_init(&qdev->ul_lock); + dev_set_drvdata(&mhi_dev->dev, qdev); + rc = qrtr_endpoint_register(&qdev->ep, net_id, rt); if (rc) return rc; - dev_set_drvdata(&mhi_dev->dev, qdev); - dev_dbg(qdev->dev, "QTI MHI QRTR driver probed\n"); return 0;