Skip to contentSkip to conversation

hwrng: stm32 - use sizeof(*priv) instead of sizeof(struct stm32_rng_private)

PATCH In review Marek Vasut 4 participants 4 messages May 31, 2024 – Jun 7, 2024

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hwrng: stm32 - use sizeof(*priv) instead of sizeof(struct stm32_rng_private)

Use sizeof(*priv) instead of sizeof(struct stm32_rng_private), the former makes renaming of struct stm32_rng_private easier if necessary, as it removes one site where such rename has to happen. No functional change.

---
Cc: "Uwe Kleine-König" <[email protected]>
Cc: Alexandre Torgue <[email protected]>
Cc: Gatien Chevallier <[email protected]>
Cc: Herbert Xu <[email protected]>
Cc: Marek Vasut <[email protected]>
Cc: Maxime Coquelin <[email protected]>
Cc: Olivia Mackall <[email protected]>
Cc: Rob Herring <[email protected]>
Cc: Yang Yingliang <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]

---
 drivers/char/hw_random/stm32-rng.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/char/hw_random/stm32-rng.c +1 -1
index d08c870eb8d1f..9d041a67c295a 100644
@@ -517,7 +517,7 @@ static int stm32_rng_probe(struct platform_device *ofdev)
 	struct stm32_rng_private *priv;
 	struct resource *res;
 
-	priv = devm_kzalloc(dev, sizeof(struct stm32_rng_private), GFP_KERNEL);
+	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
 	if (!priv)
 		return -ENOMEM;
 
Signature · 1 line
2.43.0
Acked-by on v1 1/1
#1 lore raw
Quoted 4 lines · Marek Vasut

Use sizeof(*priv) instead of sizeof(struct stm32_rng_private), the former makes renaming of struct stm32_rng_private easier if necessary, as it removes one site where such rename has to happen. No functional change.

IMHO the main upside is that it's easier to spot that the allocation size is correct.

Best regards
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |
Acked-by on v1 1/1
#2 lore raw
In reply to Marek Vasut

Hi Marek,

Quoted 29 lines · Marek Vasut

Use sizeof(*priv) instead of sizeof(struct stm32_rng_private), the former makes renaming of struct stm32_rng_private easier if necessary, as it removes one site where such rename has to happen. No functional change.

---
Cc: "Uwe Kleine-König" <[email protected]>
Cc: Alexandre Torgue <[email protected]>
Cc: Gatien Chevallier <[email protected]>
Cc: Herbert Xu <[email protected]>
Cc: Marek Vasut <[email protected]>
Cc: Maxime Coquelin <[email protected]>
Cc: Olivia Mackall <[email protected]>
Cc: Rob Herring <[email protected]>
Cc: Yang Yingliang <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]

---
  drivers/char/hw_random/stm32-rng.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/char/hw_random/stm32-rng.c +0 -0
index d08c870eb8d1f..9d041a67c295a 100644

drivers/char/hw_random/stm32-rng.c static int stm32_rng_probe(struct platform_device *ofdev) · line 523

Quoted 8 lines
drivers/char/hw_random/stm32-rng.c +1 -1
@@ -517,7 +517,7 @@ static int stm32_rng_probe(struct platform_device *ofdev)
  	struct stm32_rng_private *priv;
  	struct resource *res;
 
-	priv = devm_kzalloc(dev, sizeof(struct stm32_rng_private), GFP_KERNEL);
+	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
  	if (!priv)
  		return -ENOMEM;
 

Thanks,
Gatien

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

maintainer
#3 lore raw
In reply to Marek Vasut
Quoted 20 lines · Marek Vasut

Use sizeof(*priv) instead of sizeof(struct stm32_rng_private), the former makes renaming of struct stm32_rng_private easier if necessary, as it removes one site where such rename has to happen. No functional change.

---
Cc: "Uwe Kleine-König" <[email protected]>
Cc: Alexandre Torgue <[email protected]>
Cc: Gatien Chevallier <[email protected]>
Cc: Herbert Xu <[email protected]>
Cc: Marek Vasut <[email protected]>
Cc: Maxime Coquelin <[email protected]>
Cc: Olivia Mackall <[email protected]>
Cc: Rob Herring <[email protected]>
Cc: Yang Yingliang <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]

Quoted 3 lines
---
 drivers/char/hw_random/stm32-rng.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch applied. Thanks.

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt