2024-05-31 08:58:23

by Marek Vasut

[permalink] [raw]
Subject: [PATCH] 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.

Signed-off-by: Marek Vasut <[email protected]>
---
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(-)

diff --git a/drivers/char/hw_random/stm32-rng.c b/drivers/char/hw_random/stm32-rng.c
index d08c870eb8d1f..9d041a67c295a 100644
--- a/drivers/char/hw_random/stm32-rng.c
+++ b/drivers/char/hw_random/stm32-rng.c
@@ -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;

--
2.43.0



2024-05-31 10:51:41

by Uwe Kleine-König

[permalink] [raw]
Subject: Re: [PATCH] hwrng: stm32 - use sizeof(*priv) instead of sizeof(struct stm32_rng_private)

On Fri, May 31, 2024 at 10:57:34AM +0200, Marek Vasut wrote:
> 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.

Acked-by: Uwe Kleine-K?nig <[email protected]>

Best regards
Uwe

--
Pengutronix e.K. | Uwe Kleine-K?nig |
Industrial Linux Solutions | https://www.pengutronix.de/ |


Attachments:
(No filename) (612.00 B)
signature.asc (499.00 B)
Download all attachments

2024-05-31 13:50:40

by Gatien CHEVALLIER

[permalink] [raw]
Subject: Re: [PATCH] hwrng: stm32 - use sizeof(*priv) instead of sizeof(struct stm32_rng_private)

Hi Marek,

On 5/31/24 10:57, Marek Vasut wrote:
> 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.
>
> Signed-off-by: Marek Vasut <[email protected]>
> ---
> 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(-)
>
> diff --git a/drivers/char/hw_random/stm32-rng.c b/drivers/char/hw_random/stm32-rng.c
> index d08c870eb8d1f..9d041a67c295a 100644
> --- a/drivers/char/hw_random/stm32-rng.c
> +++ b/drivers/char/hw_random/stm32-rng.c
> @@ -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;
>

Acked-by: Gatien Chevallier <[email protected]>

Thanks,
Gatien