@@ -83,9 +83,10 @@ static bool mtk_rng_wait_ready(struct hwrng *rng, bool wait)
static int mtk_rng_read(struct hwrng *rng, void *buf, size_t max, bool wait)
{
struct mtk_rng *priv = to_mtk_rng(rng);
+ struct device *dev = (struct device *)priv->rng.priv;
int retval = 0;
- pm_runtime_get_sync((struct device *)priv->rng.priv);
+ pm_runtime_get_sync(dev);
while (max >= sizeof(u32)) {
if (!mtk_rng_wait_ready(rng, wait))
@@ -97,8 +98,8 @@ static int mtk_rng_read(struct hwrng *rng, void *buf, size_t max, bool wait)
max -= sizeof(u32);
}
- pm_runtime_mark_last_busy((struct device *)priv->rng.priv);
- pm_runtime_put_sync_autosuspend((struct device *)priv->rng.priv);
+ pm_runtime_mark_last_busy(dev);
+ pm_runtime_put_sync_autosuspend(dev);
return retval || !wait ? retval : -EIO;
}
Add a local variable for a struct device pointer instead of obtaining the hwrng priv field and casting it as a struct device pointer whenever it's needed. Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> --- drivers/char/hw_random/mtk-rng.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)