Skip to contentSkip to conversation

char: hw_random: xiphera-trng: removed unnneded platform_set_drvdata()

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

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

PATCH 1/1 char: hw_random: xiphera-trng: removed unnneded 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/xiphera-trng.c | 2 --
 1 file changed, 2 deletions(-)
drivers/char/hw_random/xiphera-trng.c +0 -2
index 2a9fea72b2e0..1fa4b70246f0 100644
@@ -122,8 +122,6 @@ static int xiphera_trng_probe(struct platform_device *pdev)
 		return ret;
 	}
 
-	platform_set_drvdata(pdev, trng);
-
 	return 0;
 }
 
Signature · 1 line
2.34.1
#1 lore raw
Quoted 16 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/xiphera-trng.c | 2 --
 1 file changed, 2 deletions(-)
drivers/char/hw_random/xiphera-trng.c +0 -0
index 2a9fea72b2e0..1fa4b70246f0 100644

drivers/char/hw_random/xiphera-trng.c static int xiphera_trng_probe(struct platform_device *pdev) · line 125

Quoted 6 lines
drivers/char/hw_random/xiphera-trng.c +0 -2
@@ -122,8 +122,6 @@ static int xiphera_trng_probe(struct platform_device *pdev)
                return ret;
        }
 
-       platform_set_drvdata(pdev, trng);
-
        return 0;

This entire block could become now:

        return devm_hwrng_register(dev, &trng->rng);
Quoted 5 lines
drivers/char/hw_random/xiphera-trng.c +0 -1
 }
 
--

2.34.1

Reviewed-by
#2 lore raw
Quoted 21 lines · Alexandru Ardelean
Quoted 19 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/xiphera-trng.c | 2 --
 1 file changed, 2 deletions(-)
drivers/char/hw_random/xiphera-trng.c +0 -0
index 2a9fea72b2e0..1fa4b70246f0 100644
@@ -122,8 +122,6 @@ static int xiphera_trng_probe(struct platform_device *pdev)
                return ret;
        }
 
Quoted 8 lines

drivers/char/hw_random/xiphera-trng.c static int xiphera_trng_probe(struct platform_device *pdev) · line 125

Quoted 3 lines
drivers/char/hw_random/xiphera-trng.c +0 -2
-       platform_set_drvdata(pdev, trng);
-
        return 0;

This entire block could become now:

        return devm_hwrng_register(dev, &trng->rng);

Coming back here.
I wonder if there is a desire to keep the prints above. If yes, then this is fine as-is.
With that:

Quoted 5 lines
Quoted 5 lines
drivers/char/hw_random/xiphera-trng.c +0 -1
 }
 
--

2.34.1

maintainer
#3 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/xiphera-trng.c | 2 --
 1 file changed, 2 deletions(-)

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