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

Commit 9e1c1825 authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "soc: qcom: bgcom: use pm_runtime_status_suspended of spi"

parents 1ca6b747 c24fa138
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -161,6 +161,10 @@ int bgcom_set_spi_state(enum bgcom_spi_state state)
{
	struct bg_spi_priv *bg_spi = container_of(bg_com_drv,
						struct bg_spi_priv, lhandle);
	struct device spi_dev = bg_spi->spi->master->dev;
	ktime_t time_start, delta;
	s64 time_elapsed;

	if (state < 0 || state > 1)
		return -EINVAL;

@@ -168,6 +172,15 @@ int bgcom_set_spi_state(enum bgcom_spi_state state)
		return 0;

	mutex_lock(&bg_spi->xfer_mutex);
	if (state == BGCOM_SPI_BUSY) {
		time_start = ktime_get();
		while (!pm_runtime_status_suspended(spi_dev.parent)) {
			delta = ktime_sub(ktime_get(), time_start);
			time_elapsed = ktime_to_ms(delta);
			BUG_ON(time_elapsed > 5 * MSEC_PER_SEC);
			msleep(100);
		}
	}
	spi_state = state;
	mutex_unlock(&bg_spi->xfer_mutex);
	return 0;