[PATCH 3/3] hwrng: npcm - Add a local variable for struct device pointer
Sakari Ailus
sakari.ailus at linux.intel.com
Thu Apr 10 00:06:23 PDT 2025
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 at linux.intel.com>
---
drivers/char/hw_random/npcm-rng.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/char/hw_random/npcm-rng.c b/drivers/char/hw_random/npcm-rng.c
index 9ff00f096f38..beec96391af7 100644
--- a/drivers/char/hw_random/npcm-rng.c
+++ b/drivers/char/hw_random/npcm-rng.c
@@ -54,10 +54,11 @@ static void npcm_rng_cleanup(struct hwrng *rng)
static int npcm_rng_read(struct hwrng *rng, void *buf, size_t max, bool wait)
{
struct npcm_rng *priv = to_npcm_rng(rng);
+ struct device *dev = (struct device *)priv->rng.priv
int retval = 0;
int ready;
- pm_runtime_get_sync((struct device *)priv->rng.priv);
+ pm_runtime_get_sync(dev);
while (max) {
if (wait) {
@@ -79,8 +80,8 @@ static int npcm_rng_read(struct hwrng *rng, void *buf, size_t max, bool wait)
max--;
}
- 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;
}
--
2.39.5
More information about the Linux-mediatek
mailing list