Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 945dddaf authored by Sujeev Dias's avatar Sujeev Dias
Browse files

mhi: core: fix incorrect mhi device probe failure



mhi device drivers do not always required to assign a status_cb
function pointer during driver registration. Fail probe only
if selected device requires notifications from MHI host and
status_cb is not assigned.

CRs-Fixed: 2237541
Change-Id: Ie26737f0f281e172007f7b468d7b072d589341df
Signed-off-by: default avatarSujeev Dias <sdias@codeaurora.org>
parent 9219c292
Loading
Loading
Loading
Loading
+17 −12
Original line number Diff line number Diff line
@@ -1139,26 +1139,27 @@ static int mhi_driver_probe(struct device *dev)
	struct mhi_event *mhi_event;
	struct mhi_chan *ul_chan = mhi_dev->ul_chan;
	struct mhi_chan *dl_chan = mhi_dev->dl_chan;
	bool offload_ch = ((ul_chan && ul_chan->offload_ch) ||
			   (dl_chan && dl_chan->offload_ch));

	/* all offload channels require status_cb to be defined */
	if (offload_ch) {
		if (!mhi_dev->status_cb)

	if (ul_chan) {
		/* lpm notification require status_cb */
		if (ul_chan->lpm_notify && !mhi_drv->status_cb)
			return -EINVAL;
		mhi_dev->status_cb = mhi_drv->status_cb;
	}

	if (ul_chan && !offload_ch) {
		if (!mhi_drv->ul_xfer_cb)
		if (!ul_chan->offload_ch && !mhi_drv->ul_xfer_cb)
			return -EINVAL;

		ul_chan->xfer_cb = mhi_drv->ul_xfer_cb;
		mhi_dev->status_cb = mhi_drv->status_cb;
	}

	if (dl_chan && !offload_ch) {
		if (!mhi_drv->dl_xfer_cb)
	if (dl_chan) {
		if (dl_chan->lpm_notify && !mhi_drv->status_cb)
			return -EINVAL;
		dl_chan->xfer_cb = mhi_drv->dl_xfer_cb;

		if (!dl_chan->offload_ch && !mhi_drv->dl_xfer_cb)
			return -EINVAL;

		mhi_event = &mhi_cntrl->mhi_event[dl_chan->er_index];

		/*
@@ -1168,6 +1169,10 @@ static int mhi_driver_probe(struct device *dev)
		 */
		if (mhi_event->cl_manage && !mhi_drv->status_cb)
			return -EINVAL;

		dl_chan->xfer_cb = mhi_drv->dl_xfer_cb;

		/* ul & dl uses same status cb */
		mhi_dev->status_cb = mhi_drv->status_cb;
	}