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

Commit d3ca23df authored by Chris Lew's avatar Chris Lew Committed by Gerrit - the friendly Code Review server
Browse files

diag: mhi: Fix error handling for DCI channel failure



Not all targets support the DCI channel over MHI. Fix
error handling to only cleanup the failing device if
MHI registration fails.

Change-Id: I5ba23d69bc1fa3c08468d930f5f50151bfcd5bc0
Signed-off-by: default avatarChris Lew <clew@codeaurora.org>
parent 9cc3223e
Loading
Loading
Loading
Loading
+16 −8
Original line number Diff line number Diff line
@@ -672,6 +672,20 @@ static int diag_mhi_register_ch(int id, struct diag_mhi_ch_t *ch)
	return mhi_register_channel(&ch->hdl, &ch->client_info);
}

static void diag_mhi_dev_exit(int dev)
{
	struct diag_mhi_info *mhi_info = NULL;

	mhi_info = &diag_mhi[dev];
	if (!mhi_info)
		return;
	if (mhi_info->mhi_wq)
		destroy_workqueue(mhi_info->mhi_wq);
	mhi_close(mhi_info->id);
	if (mhi_info->mempool_init)
		diagmem_exit(driver, mhi_info->mempool);
}

int diag_mhi_init()
{
	int i;
@@ -717,22 +731,16 @@ int diag_mhi_init()

	return 0;
fail:
	diag_mhi_exit();
	diag_mhi_dev_exit(i);
	return -ENOMEM;
}

void diag_mhi_exit()
{
	int i;
	struct diag_mhi_info *mhi_info = NULL;

	for (i = 0; i < NUM_MHI_DEV; i++) {
		mhi_info = &diag_mhi[i];
		if (mhi_info->mhi_wq)
			destroy_workqueue(mhi_info->mhi_wq);
		mhi_close(mhi_info->id);
		if (mhi_info->mempool_init)
			diagmem_exit(driver, mhi_info->mempool);
		diag_mhi_dev_exit(i);
	}
}