mbox series

[0/3] hwrng: xgene - Some improvements

Message ID 20230214162829.113148-1-u.kleine-koenig@pengutronix.de (mailing list archive)
Headers show
Series hwrng: xgene - Some improvements | expand

Message

Uwe Kleine-König Feb. 14, 2023, 4:28 p.m. UTC
Hello,

while working on the quest to make struct platform_driver::remove() return void
I stumbled over the xgene-rng driver because it didn't return 0 in .remove().

Looking at it I found two other patch opportunities, here is the result.

I think the driver has some more problems:

 - device_init_wakeup() is only called after devm_hwrng_register(). After the
   latter returns the respective callbacks can be called. Is the device already
   in the right state before device_init_wakeup(..., 1)?

 - Similar problem on .remove(): device_init_wakeup(..., 0) is called before
   hwrng_unregister() happens.

 - If there are two (or more) devices of that type, .probe() for the 2nd overwrites
   xgene_rng_func.priv of the first one.

Best regards
Uwe

Uwe Kleine-König (3):
  hwrng: xgene - Simplify using dev_err_probe()
  hwrng: xgene - Simplify using devm_clk_get_optional_enabled()
  hwrng: xgene - Improve error reporting for problems during .remove()

 drivers/char/hw_random/xgene-rng.c | 44 ++++++++----------------------
 1 file changed, 11 insertions(+), 33 deletions(-)

base-commit: e05dec85e78317f251eddd27e0357b2253d9dfc4

Comments

Herbert Xu March 10, 2023, 11:25 a.m. UTC | #1
On Tue, Feb 14, 2023 at 05:28:26PM +0100, Uwe Kleine-König wrote:
> Hello,
> 
> while working on the quest to make struct platform_driver::remove() return void
> I stumbled over the xgene-rng driver because it didn't return 0 in .remove().
> 
> Looking at it I found two other patch opportunities, here is the result.
> 
> I think the driver has some more problems:
> 
>  - device_init_wakeup() is only called after devm_hwrng_register(). After the
>    latter returns the respective callbacks can be called. Is the device already
>    in the right state before device_init_wakeup(..., 1)?
> 
>  - Similar problem on .remove(): device_init_wakeup(..., 0) is called before
>    hwrng_unregister() happens.
> 
>  - If there are two (or more) devices of that type, .probe() for the 2nd overwrites
>    xgene_rng_func.priv of the first one.
> 
> Best regards
> Uwe
> 
> Uwe Kleine-König (3):
>   hwrng: xgene - Simplify using dev_err_probe()
>   hwrng: xgene - Simplify using devm_clk_get_optional_enabled()
>   hwrng: xgene - Improve error reporting for problems during .remove()
> 
>  drivers/char/hw_random/xgene-rng.c | 44 ++++++++----------------------
>  1 file changed, 11 insertions(+), 33 deletions(-)
> 
> base-commit: e05dec85e78317f251eddd27e0357b2253d9dfc4
> -- 
> 2.39.1

All applied.  Thanks.