diff mbox series

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

Message ID 20230828101757.9724-1-aboutphysycs@gmail.com (mailing list archive)
State Handled Elsewhere
Headers show
Series char: hw_random: mpfs-rng: removed unneeded call to platform_set_drvdata() | expand

Checks

Context Check Description
conchuod/cover_letter success Single patches do not need cover letters
conchuod/tree_selection success Guessed tree name to be for-next at HEAD 9f944d2e0ab3
conchuod/fixes_present success Fixes tag not required for -next series
conchuod/maintainers_pattern success MAINTAINERS pattern errors before the patch: 4 and now 4
conchuod/verify_signedoff success Signed-off-by tag matches author and committer
conchuod/kdoc success Errors and warnings before: 0 this patch: 0
conchuod/build_rv64_clang_allmodconfig success Errors and warnings before: 9 this patch: 9
conchuod/module_param success Was 0 now: 0
conchuod/build_rv64_gcc_allmodconfig success Errors and warnings before: 9 this patch: 9
conchuod/build_rv32_defconfig success Build OK
conchuod/dtb_warn_rv64 success Errors and warnings before: 12 this patch: 12
conchuod/header_inline success No static functions without inline keyword in header files
conchuod/checkpatch success total: 0 errors, 0 warnings, 0 checks, 8 lines checked
conchuod/build_rv64_nommu_k210_defconfig success Build OK
conchuod/verify_fixes success No Fixes tag
conchuod/build_rv64_nommu_virt_defconfig success Build OK

Commit Message

Andrei Coardos Aug. 28, 2023, 10:17 a.m. UTC
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.

Signed-off-by: Andrei Coardos <aboutphysycs@gmail.com>
---
 drivers/char/hw_random/mpfs-rng.c | 2 --
 1 file changed, 2 deletions(-)

Comments

Conor Dooley Aug. 28, 2023, 11:03 a.m. UTC | #1
On Mon, Aug 28, 2023 at 01:17:57PM +0300, Andrei Coardos wrote:
> 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.

Acked-by: Conor Dooley <conor.dooley@microchip.com>

Thanks,
Conor.

> 
> Signed-off-by: Andrei Coardos <aboutphysycs@gmail.com>
> ---
>  drivers/char/hw_random/mpfs-rng.c | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/drivers/char/hw_random/mpfs-rng.c b/drivers/char/hw_random/mpfs-rng.c
> index c6972734ae62..0994024daa70 100644
> --- a/drivers/char/hw_random/mpfs-rng.c
> +++ b/drivers/char/hw_random/mpfs-rng.c
> @@ -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");
> -- 
> 2.34.1
>
Alexandru Ardelean Sept. 1, 2023, 6:07 a.m. UTC | #2
On Mon, Aug 28, 2023 at 2:06 PM Conor Dooley <conor.dooley@microchip.com> wrote:
>
> On Mon, Aug 28, 2023 at 01:17:57PM +0300, Andrei Coardos wrote:
> > 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.
>
> Acked-by: Conor Dooley <conor.dooley@microchip.com>
>
> Thanks,
> Conor.
>
> >
> > Signed-off-by: Andrei Coardos <aboutphysycs@gmail.com>
> > ---
> >  drivers/char/hw_random/mpfs-rng.c | 2 --
> >  1 file changed, 2 deletions(-)
> >
> > diff --git a/drivers/char/hw_random/mpfs-rng.c b/drivers/char/hw_random/mpfs-rng.c
> > index c6972734ae62..0994024daa70 100644
> > --- a/drivers/char/hw_random/mpfs-rng.c
> > +++ b/drivers/char/hw_random/mpfs-rng.c
> > @@ -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);

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:

Reviewed-by: Alexandru Ardelean <alex@shruggie.ro>

> >       if (ret)
> >               return dev_err_probe(&pdev->dev, ret, "Failed to register MPFS hwrng\n");
> > --
> > 2.34.1
> >
Conor Dooley Sept. 1, 2023, 6:25 a.m. UTC | #3
On Fri, Sep 01, 2023 at 09:07:56AM +0300, Alexandru Ardelean wrote:
> On Mon, Aug 28, 2023 at 2:06 PM Conor Dooley <conor.dooley@microchip.com> wrote:
> >
> > On Mon, Aug 28, 2023 at 01:17:57PM +0300, Andrei Coardos wrote:
> > > 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.
> >
> > Acked-by: Conor Dooley <conor.dooley@microchip.com>
> >
> > Thanks,
> > Conor.
> >
> > >
> > > Signed-off-by: Andrei Coardos <aboutphysycs@gmail.com>
> > > ---
> > >  drivers/char/hw_random/mpfs-rng.c | 2 --
> > >  1 file changed, 2 deletions(-)
> > >
> > > diff --git a/drivers/char/hw_random/mpfs-rng.c b/drivers/char/hw_random/mpfs-rng.c
> > > index c6972734ae62..0994024daa70 100644
> > > --- a/drivers/char/hw_random/mpfs-rng.c
> > > +++ b/drivers/char/hw_random/mpfs-rng.c
> > > @@ -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);
> 
> 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:

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

> 
> Reviewed-by: Alexandru Ardelean <alex@shruggie.ro>
> 
> > >       if (ret)
> > >               return dev_err_probe(&pdev->dev, ret, "Failed to register MPFS hwrng\n");
> > > --
> > > 2.34.1
> > >
Herbert Xu Sept. 15, 2023, 10:38 a.m. UTC | #4
On Mon, Aug 28, 2023 at 01:17:57PM +0300, Andrei Coardos wrote:
> 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.
> 
> Signed-off-by: Andrei Coardos <aboutphysycs@gmail.com>
> ---
>  drivers/char/hw_random/mpfs-rng.c | 2 --
>  1 file changed, 2 deletions(-)

Patch applied.  Thanks.
diff mbox series

Patch

diff --git a/drivers/char/hw_random/mpfs-rng.c b/drivers/char/hw_random/mpfs-rng.c
index c6972734ae62..0994024daa70 100644
--- a/drivers/char/hw_random/mpfs-rng.c
+++ b/drivers/char/hw_random/mpfs-rng.c
@@ -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");