[0/4] siox: Move some complexity into the core

Message ID cover.1708328466.git.u.kleine-koenig@pengutronix.de
Headers
Series siox: Move some complexity into the core |

Message

Uwe Kleine-König Feb. 19, 2024, 7:46 a.m. UTC
  Hello,

the reference handling in siox is a bit strange. With
siox_master_alloc() to get a reference on the master that is passed to
the core calling siox_master_register(). So until siox_master_register()
is called successfully the driver has to call siox_master_put() in the
error path, but on remove siox_master_unregister cares for that. While
that technically works, it's unusual and surprising to use. This serie's
first patch cleans that up and then introduces devm functions to make it
even easier to use.

A nice (and intended) side effect is that the gpio bus driver gets rid
of it's remove callback, so I don't have to adapt it for my quest that
changes the prototype of .remove().

Best regards
Uwe

Uwe Kleine-König (4):
  siox: Don't pass the reference on a master in siox_master_register()
  siox: Provide a devm variant of siox_master_alloc()
  siox: Provide a devm variant of siox_master_register()
  siox: bus-gpio: Simplify using devm_siox_* functions

 drivers/siox/siox-bus-gpio.c | 62 ++++++++++++------------------------
 drivers/siox/siox-core.c     | 45 ++++++++++++++++++++++++++
 drivers/siox/siox.h          |  4 +++
 3 files changed, 69 insertions(+), 42 deletions(-)


base-commit: d37e1e4c52bc60578969f391fb81f947c3e83118
  

Comments

Thorsten Scherer Feb. 27, 2024, 10:21 a.m. UTC | #1
Hello Uwe, Hello Greg,

On Mon, Feb 19, 2024 at 08:46:28AM +0100, Uwe Kleine-König wrote:
> Hello,
> 
> the reference handling in siox is a bit strange. With
> siox_master_alloc() to get a reference on the master that is passed to
> the core calling siox_master_register(). So until siox_master_register()
> is called successfully the driver has to call siox_master_put() in the
> error path, but on remove siox_master_unregister cares for that. While
> that technically works, it's unusual and surprising to use. This serie's
> first patch cleans that up and then introduces devm functions to make it
> even easier to use.
> 
> A nice (and intended) side effect is that the gpio bus driver gets rid
> of it's remove callback, so I don't have to adapt it for my quest that
> changes the prototype of .remove().

I only compile tested this as I currently do not have access to test
hardware.

The series looks sensible.

Acked-by: Thorsten Scherer <t.scherer@eckelmann.de>

@gregkh: Would you please pick up Uwe's series as well?

Thank you both.

Best regards
Thorsten

> Best regards
> Uwe
> 
> Uwe Kleine-König (4):
>   siox: Don't pass the reference on a master in siox_master_register()
>   siox: Provide a devm variant of siox_master_alloc()
>   siox: Provide a devm variant of siox_master_register()
>   siox: bus-gpio: Simplify using devm_siox_* functions
> 
>  drivers/siox/siox-bus-gpio.c | 62 ++++++++++++------------------------
>  drivers/siox/siox-core.c     | 45 ++++++++++++++++++++++++++
>  drivers/siox/siox.h          |  4 +++
>  3 files changed, 69 insertions(+), 42 deletions(-)
> 
> 
> base-commit: d37e1e4c52bc60578969f391fb81f947c3e83118
> -- 
> 2.43.0
>