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

Commit af716c70 authored by Arjun Singh's avatar Arjun Singh
Browse files

soc: qcom: bgcom: Removes double pointer conflicts on resume/suspend



Use single pointer for bgcom_suspend and bgcom_resume APIs to resolve
device crash on continuous device suspend/resume.

Change-Id: I0cd202e74b98aa2ce2ebcbd6c8092c6b1d95610b
Signed-off-by: default avatarArjun Singh <arsingh@codeaurora.org>
parent 259f2973
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -197,14 +197,14 @@ int bgcom_ahb_write(void *handle, uint32_t ahb_start_addr,
 * @handle: BGCOM handle associated with the channel
 * Return 0 on success or -Ve on error
*/
int bgcom_suspend(void **handle);
int bgcom_suspend(void *handle);

/**
 * bgcom_resume() - Resumes the channel.
 * @handle: BGCOM handle associated with the channel
 * Return 0 on success or -Ve on error
*/
int bgcom_resume(void **handle);
int bgcom_resume(void *handle);

int bgcom_set_spi_state(enum bgcom_spi_state state);

+12 −12
Original line number Diff line number Diff line
@@ -464,7 +464,7 @@ int bgcom_ahb_read(void *handle, uint32_t ahb_start_addr,
		return -EBUSY;
	}

	if (bgcom_resume(&handle)) {
	if (bgcom_resume(handle)) {
		pr_err("Failed to resume\n");
		return -EBUSY;
	}
@@ -525,7 +525,7 @@ int bgcom_ahb_write(void *handle, uint32_t ahb_start_addr,
		return -EBUSY;
	}

	if (bgcom_resume(&handle)) {
	if (bgcom_resume(handle)) {
		pr_err("Failed to resume\n");
		return -EBUSY;
	}
@@ -574,7 +574,7 @@ int bgcom_fifo_write(void *handle, uint32_t num_words,
		return -EBUSY;
	}

	if (bgcom_resume(&handle)) {
	if (bgcom_resume(handle)) {
		pr_err("Failed to resume\n");
		return -EBUSY;
	}
@@ -757,23 +757,23 @@ static int is_bg_resume(void *handle)
	return cmnd_reg & BIT(31);
}

int bgcom_resume(void **handle)
int bgcom_resume(void *handle)
{
	struct bg_spi_priv *bg_spi;
	struct bg_context *cntx;
	int retry = 0;

	if (*handle == NULL)
	if (handle == NULL)
		return -EINVAL;

	cntx = *handle;
	cntx = (struct bg_context *)handle;
	bg_spi = cntx->bg_spi;

	mutex_lock(&bg_resume_mutex);
	if (bg_spi->bg_state == BGCOM_STATE_ACTIVE)
		goto unlock;
	do {
		if (is_bg_resume(*handle)) {
		if (is_bg_resume(handle)) {
			bg_spi->bg_state = BGCOM_STATE_ACTIVE;
			break;
		}
@@ -783,29 +783,29 @@ int bgcom_resume(void **handle)

unlock:
	mutex_unlock(&bg_resume_mutex);
	pr_info("BG Resumed in %d retries\n", retry);
	pr_info("BG retries for wake up : %d\n", retry);
	return (retry == MAX_RETRY ? -ETIMEDOUT : 0);
}
EXPORT_SYMBOL(bgcom_resume);

int bgcom_suspend(void **handle)
int bgcom_suspend(void *handle)
{
	struct bg_spi_priv *bg_spi;
	struct bg_context *cntx;
	uint32_t cmnd_reg = 0;
	int ret = 0;

	if (*handle == NULL)
	if (handle == NULL)
		return -EINVAL;

	cntx = *handle;
	cntx = (struct bg_context *)handle;
	bg_spi = cntx->bg_spi;
	mutex_lock(&bg_resume_mutex);
	if (bg_spi->bg_state == BGCOM_STATE_SUSPEND)
		goto unlock;

	cmnd_reg |= BIT(31);
	ret = bgcom_reg_write(*handle, BG_CMND_REG, 1, &cmnd_reg);
	ret = bgcom_reg_write(handle, BG_CMND_REG, 1, &cmnd_reg);
	if (ret == 0)
		bg_spi->bg_state = BGCOM_STATE_SUSPEND;