diff mbox series

[v3,15/17] firmware: turris-mox-rwtm: Use container_of() instead of hwrng .priv member

Message ID 20240617144532.17385-16-kabel@kernel.org (mailing list archive)
State Superseded
Delegated to: Arnd Bergmann
Headers show
Series Updates for turris-mox-rwtm driver | expand

Commit Message

Marek Behún June 17, 2024, 2:45 p.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 [1].

[1] https://lore.kernel.org/soc/ZmLhQBdmg613KdET@gondor.apana.org.au/

Signed-off-by: Marek Behún <kabel@kernel.org>
---
 drivers/firmware/turris-mox-rwtm.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Andy Shevchenko June 17, 2024, 8:27 p.m. UTC | #1
On Mon, Jun 17, 2024 at 4:46 PM Marek Behún <kabel@kernel.org> wrote:
>
> 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 [1].

> [1] https://lore.kernel.org/soc/ZmLhQBdmg613KdET@gondor.apana.org.au/
>

You can make this to be a Link tag.

Link: ...URL... [1]
diff mbox series

Patch

diff --git a/drivers/firmware/turris-mox-rwtm.c b/drivers/firmware/turris-mox-rwtm.c
index 5a850dc27fe3..135adfa9fb1f 100644
--- a/drivers/firmware/turris-mox-rwtm.c
+++ b/drivers/firmware/turris-mox-rwtm.c
@@ -260,7 +260,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;
 
@@ -489,7 +489,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)