RE: [PATCH v2 03/10] mfd: rz-mtu3: use device-managed mfd_add_devices()

From: Cosmin-Gabriel Tanislav

Date: Thu May 07 2026 - 10:21:38 EST


> From: Lee Jones <lee@xxxxxxxxxx>
> Sent: Thursday, May 7, 2026 3:46 PM
>
> On Fri, 10 Apr 2026, Cosmin Tanislav wrote:
>
> > Replace mfd_add_devices() and the custom cleanup action with
> > devm_mfd_add_devices().
> >
> > Remove the ret variable as it is now unused.
>
> Do this first, then the changes in the first patch make more sense.
>

Doing the devm_mfd_add_devices() conversion first would not be a simple
replacement, as devm_add_action_or_reset() would also need to be moved
before it to keep the intermediate patch correct.

Otherwise, on release, the reset will be asserted before the MFD devices
are removed. Doing the reset conversion first fixes that without extra
logic changes.

Alternatively, we can squash the two conversions to avoid the
intermediate states entirely, and remove struct rz_mtu3_priv::rstc in a
new separate patch. What do you think about this variant?

> > Signed-off-by: Cosmin Tanislav <cosmin-gabriel.tanislav.xa@xxxxxxxxxxx>
> > ---
> >
> > V2:
> > * no changes
> >
> > drivers/mfd/rz-mtu3.c | 15 ++-------------
> > 1 file changed, 2 insertions(+), 13 deletions(-)
> >
> > diff --git a/drivers/mfd/rz-mtu3.c b/drivers/mfd/rz-mtu3.c
> > index 6b9c6831dffa9..3be6f6c900b82 100644
> > --- a/drivers/mfd/rz-mtu3.c
> > +++ b/drivers/mfd/rz-mtu3.c
> > @@ -300,11 +300,6 @@ void rz_mtu3_disable(struct rz_mtu3_channel *ch)
> > }
> > EXPORT_SYMBOL_GPL(rz_mtu3_disable);
> >
> > -static void rz_mtu3_mfd_remove(void *data)
> > -{
> > - mfd_remove_devices(data);
> > -}
> > -
> > static const struct mfd_cell rz_mtu3_devs[] = {
> > {
> > .name = "rz-mtu3-counter",
> > @@ -320,7 +315,6 @@ static int rz_mtu3_probe(struct platform_device *pdev)
> > struct rz_mtu3_priv *priv;
> > struct rz_mtu3 *ddata;
> > unsigned int i;
> > - int ret;
> >
> > ddata = devm_kzalloc(&pdev->dev, sizeof(*ddata), GFP_KERNEL);
> > if (!ddata)
> > @@ -353,13 +347,8 @@ static int rz_mtu3_probe(struct platform_device *pdev)
> > mutex_init(&ddata->channels[i].lock);
> > }
> >
> > - ret = mfd_add_devices(&pdev->dev, 0, rz_mtu3_devs,
> > - ARRAY_SIZE(rz_mtu3_devs), NULL, 0, NULL);
> > - if (ret < 0)
> > - return ret;
> > -
> > - return devm_add_action_or_reset(&pdev->dev, rz_mtu3_mfd_remove,
> > - &pdev->dev);
> > + return devm_mfd_add_devices(&pdev->dev, 0, rz_mtu3_devs,
> > + ARRAY_SIZE(rz_mtu3_devs), NULL, 0, NULL);
> > }
> >
> > static const struct of_device_id rz_mtu3_of_match[] = {
> > --
> > 2.53.0
>
> --
> Lee Jones