diff mbox series

[v5,13/16] firmware: turris-mox-rwtm: Use container_of() instead of hwrng .priv member

Message ID 20240831092050.23093-14-kabel@kernel.org (mailing list archive)
State Accepted
Commit 21733f5902bee79357dad9994865df5229b538a3
Delegated to: Arnd Bergmann
Headers show
Series Updates for turris-mox-rwtm driver | expand

Commit Message

Marek BehĂșn Aug. 31, 2024, 9:20 a.m. UTC
Use container_of() to get driver private structure from hwnrg structure,
instead of the hwrng's .priv member, as suggested by Herbert for another
driver.

Link: https://lore.kernel.org/soc/ZmLhQBdmg613KdET@gondor.apana.org.au/
Signed-off-by: Marek BehĂșn <kabel@kernel.org>
Reviewed-by: Andy Shevchenko <andy@kernel.org>
---
 drivers/firmware/turris-mox-rwtm.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/drivers/firmware/turris-mox-rwtm.c b/drivers/firmware/turris-mox-rwtm.c
index 9f6bda969943..52f97235c3a6 100644
--- a/drivers/firmware/turris-mox-rwtm.c
+++ b/drivers/firmware/turris-mox-rwtm.c
@@ -259,7 +259,7 @@  static int check_get_random_support(struct mox_rwtm *rwtm)
 
 static int mox_hwrng_read(struct hwrng *rng, void *data, size_t max, bool wait)
 {
-	struct mox_rwtm *rwtm = (struct mox_rwtm *) rng->priv;
+	struct mox_rwtm *rwtm = container_of(rng, struct mox_rwtm, hwrng);
 	struct armada_37xx_rwtm_tx_msg msg;
 	int ret;
 
@@ -487,7 +487,6 @@  static int turris_mox_rwtm_probe(struct platform_device *pdev)
 
 	rwtm->hwrng.name = DRIVER_NAME "_hwrng";
 	rwtm->hwrng.read = mox_hwrng_read;
-	rwtm->hwrng.priv = (unsigned long) rwtm;
 
 	ret = devm_hwrng_register(dev, &rwtm->hwrng);
 	if (ret)