Skip to contentSkip to conversation

char: hw_random: mpfs-rng: removed unneeded call to platform_set_drvdata()

PATCH In review Andrei Coardos 4 participants 5 messages Aug 28, 2023 – Sep 15, 2023

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

PATCH 1/1 char: hw_random: mpfs-rng: removed unneeded call to platform_set_drvdata()

This function call was found to be unnecessary as there is no equivalent platform_get_drvdata() call to access the private data of the driver. Also, the private data is defined in this driver, so there is no risk of it being accessed outside of this driver file.

---
 drivers/char/hw_random/mpfs-rng.c | 2 --
 1 file changed, 2 deletions(-)
drivers/char/hw_random/mpfs-rng.c +0 -2
index c6972734ae62..0994024daa70 100644
@@ -79,8 +79,6 @@ static int mpfs_rng_probe(struct platform_device *pdev)
 	rng_priv->rng.read = mpfs_rng_read;
 	rng_priv->rng.name = pdev->name;
 
-	platform_set_drvdata(pdev, rng_priv);
-
 	ret = devm_hwrng_register(&pdev->dev, &rng_priv->rng);
 	if (ret)
 		return dev_err_probe(&pdev->dev, ret, "Failed to register MPFS hwrng\n");
Signature · 7 lines
2.34.1


_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 4 lines · Andrei Coardos

This function call was found to be unnecessary as there is no equivalent platform_get_drvdata() call to access the private data of the driver. Also, the private data is defined in this driver, so there is no risk of it being accessed outside of this driver file.

I think Greg previously pointed out to you that is it not sufficient to check for platform_get_drvdata() alone, because the information could be accessed without going through that helper. That's not the case here, but it could be true elsewhere.

Thanks,
Conor.

Quoted 22 lines
---
 drivers/char/hw_random/mpfs-rng.c | 2 --
 1 file changed, 2 deletions(-)
drivers/char/hw_random/mpfs-rng.c +0 -2
index c6972734ae62..0994024daa70 100644
@@ -79,8 +79,6 @@ static int mpfs_rng_probe(struct platform_device *pdev)
 	rng_priv->rng.read = mpfs_rng_read;
 	rng_priv->rng.name = pdev->name;
 
-	platform_set_drvdata(pdev, rng_priv);
-
 	ret = devm_hwrng_register(&pdev->dev, &rng_priv->rng);
 	if (ret)
 		return dev_err_probe(&pdev->dev, ret, "Failed to register MPFS hwrng\n");
Signature · 1 line
2.34.1

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

Reviewed-by
#2 lore raw
Quoted 31 lines · Conor Dooley
Quoted 4 lines · Andrei Coardos

This function call was found to be unnecessary as there is no equivalent platform_get_drvdata() call to access the private data of the driver. Also, the private data is defined in this driver, so there is no risk of it being accessed outside of this driver file.

I think Greg previously pointed out to you that is it not sufficient to check for platform_get_drvdata() alone, because the information could be accessed without going through that helper. That's not the case here, but it could be true elsewhere.

Thanks,
Conor.

Quoted 14 lines
---
 drivers/char/hw_random/mpfs-rng.c | 2 --
 1 file changed, 2 deletions(-)
drivers/char/hw_random/mpfs-rng.c +0 -0
index c6972734ae62..0994024daa70 100644
@@ -79,8 +79,6 @@ static int mpfs_rng_probe(struct platform_device *pdev)
      rng_priv->rng.read = mpfs_rng_read;
      rng_priv->rng.name = pdev->name;
 
Quoted 3 lines

drivers/char/hw_random/mpfs-rng.c static int mpfs_rng_probe(struct platform_device *pdev) · line 82

Quoted 3 lines
drivers/char/hw_random/mpfs-rng.c +0 -2
-     platform_set_drvdata(pdev, rng_priv);
-
      ret = devm_hwrng_register(&pdev->dev, &rng_priv->rng);

A question would be if there is a desire to keep the prints below, or would this be sufficient?

          return devm_hwrng_register(&pdev->dev, &rng_priv->rng);

If there is the desire to keep the prints, then:

Quoted 5 lines
Quoted 5 lines
drivers/char/hw_random/mpfs-rng.c +0 -1
      if (ret)
              return dev_err_probe(&pdev->dev, ret, "Failed to register MPFS hwrng\n");
--

2.34.1

maintainer
#3 lore raw
Quoted 39 lines · Alexandru Ardelean
Quoted 31 lines · Conor Dooley
Quoted 4 lines · Andrei Coardos

This function call was found to be unnecessary as there is no equivalent platform_get_drvdata() call to access the private data of the driver. Also, the private data is defined in this driver, so there is no risk of it being accessed outside of this driver file.

I think Greg previously pointed out to you that is it not sufficient to check for platform_get_drvdata() alone, because the information could be accessed without going through that helper. That's not the case here, but it could be true elsewhere.

Thanks,
Conor.

Quoted 14 lines
---
 drivers/char/hw_random/mpfs-rng.c | 2 --
 1 file changed, 2 deletions(-)
drivers/char/hw_random/mpfs-rng.c +0 -0
index c6972734ae62..0994024daa70 100644
@@ -79,8 +79,6 @@ static int mpfs_rng_probe(struct platform_device *pdev)
      rng_priv->rng.read = mpfs_rng_read;
      rng_priv->rng.name = pdev->name;
 
Quoted 3 lines

drivers/char/hw_random/mpfs-rng.c static int mpfs_rng_probe(struct platform_device *pdev) · line 82

Quoted 3 lines
drivers/char/hw_random/mpfs-rng.c +0 -2
-     platform_set_drvdata(pdev, rng_priv);
-
      ret = devm_hwrng_register(&pdev->dev, &rng_priv->rng);

A question would be if there is a desire to keep the prints below, or would this be sufficient?

Quoted 3 lines
          return devm_hwrng_register(&pdev->dev, &rng_priv->rng);

If there is the desire to keep the prints, then:

Yeah, I'd like to keep a print in the failing case, thanks.

Quoted 8 lines
Quoted 5 lines
Quoted 5 lines
drivers/char/hw_random/mpfs-rng.c +0 -1
      if (ret)
              return dev_err_probe(&pdev->dev, ret, "Failed to register MPFS hwrng\n");
--

2.34.1

maintainer
#4 lore raw
In reply to Andrei Coardos
Quoted 9 lines · Andrei Coardos

This function call was found to be unnecessary as there is no equivalent platform_get_drvdata() call to access the private data of the driver. Also, the private data is defined in this driver, so there is no risk of it being accessed outside of this driver file.

---
 drivers/char/hw_random/mpfs-rng.c | 2 --
 1 file changed, 2 deletions(-)

Patch applied. Thanks.

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

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