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

Commit a322e67b authored by Sudheer Papothi's avatar Sudheer Papothi
Browse files

soundwire: Update pm runtime last busy for read/write functions



When soundwire read/write operations are called after auto suspend
is triggered, then pm runtime last busy field should be updated
properly for current time. Change updates pm runtime last busy
field after soundwire read/write operations to avoid pm runtime
suspend during read/write operations.

Change-Id: I675f52d96634ed0628ac6d9473337ec531fdba5b
Signed-off-by: default avatarSudheer Papothi <spapothi@codeaurora.org>
parent 84099f52
Loading
Loading
Loading
Loading
+22 −4
Original line number Diff line number Diff line
@@ -459,12 +459,16 @@ static int swrm_read(struct swr_master *master, u8 dev_num, u32 reg_addr,
{
	struct swr_mstr_ctrl *swrm = swr_get_ctrl_data(master);

	if (!swrm) {
		dev_err(&master->dev, "%s: swrm is NULL\n", __func__);
		return -EINVAL;
	}

	if (pm_runtime_suspended(&swrm->pdev->dev)) {
		dev_dbg(swrm->dev, "%s: suspended state, enable pm_runtime\n",
			__func__);
		pm_runtime_get_sync(&swrm->pdev->dev);
		pm_runtime_mark_last_busy(&swrm->pdev->dev);
		pm_runtime_put_autosuspend(&swrm->pdev->dev);
		swrm->is_suspend = true;
	}

	if (dev_num) {
@@ -479,6 +483,11 @@ static int swrm_read(struct swr_master *master, u8 dev_num, u32 reg_addr,
			return -EINVAL;
		}
	}
	pm_runtime_mark_last_busy(&swrm->pdev->dev);
	if (swrm->is_suspend) {
		pm_runtime_put_autosuspend(&swrm->pdev->dev);
		swrm->is_suspend = false;
	}
	return 0;
}

@@ -488,12 +497,16 @@ static int swrm_write(struct swr_master *master, u8 dev_num, u32 reg_addr,
	struct swr_mstr_ctrl *swrm = swr_get_ctrl_data(master);
	int ret = 0;

	if (!swrm) {
		dev_err(&master->dev, "%s: swrm is NULL\n", __func__);
		return -EINVAL;
	}

	if (pm_runtime_suspended(&swrm->pdev->dev)) {
		dev_dbg(swrm->dev, "%s: suspended state, enable pm_runtime\n",
			__func__);
		pm_runtime_get_sync(&swrm->pdev->dev);
		pm_runtime_mark_last_busy(&swrm->pdev->dev);
		pm_runtime_put_autosuspend(&swrm->pdev->dev);
		swrm->is_suspend = true;
	}

	if (dev_num) {
@@ -507,6 +520,11 @@ static int swrm_write(struct swr_master *master, u8 dev_num, u32 reg_addr,
			return -EINVAL;
		}
	}
	pm_runtime_mark_last_busy(&swrm->pdev->dev);
	if (swrm->is_suspend) {
		pm_runtime_put_autosuspend(&swrm->pdev->dev);
		swrm->is_suspend = false;
	}
	return ret;
}

+1 −0
Original line number Diff line number Diff line
@@ -92,6 +92,7 @@ struct swr_mstr_ctrl {
	struct list_head mport_list;
	int state;
	struct platform_device *pdev;
	bool is_suspend;
};

#endif /* _SWR_WCD_CTRL_H */