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 <jayanna@codeaurora.org>
This commit is contained in:
Jay Jayanna 2020-03-09 17:49:49 -07:00
commit d7067f6740

View file

@ -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;