Re: [PATCH v2 2/3] i2c: designware-platdrv: complete reset control devm conversion

From: Philipp Zabel

Date: Tue Nov 11 2025 - 09:33:42 EST


On Di, 2025-11-11 at 13:43 +0100, Philipp Zabel wrote:
> On Di, 2025-11-11 at 14:45 +0300, Artem Shimko wrote:
> > The driver still manually calls reset_control_assert() in error paths and
> > remove function. This creates inconsistent resource management and misses
> > the benefits of full device-managed approach.
> >
> > Register devm_add_action_or_reset() callback after acquiring reset control
> > to handle automatic assertion on probe errors and driver removal. This
> > eliminates all manual reset_control_assert() calls while maintaining
> > identical reset behavior through automatic devm resource management.
> >
> > Signed-off-by: Artem Shimko <a.shimko.dev@xxxxxxxxx>
> > ---
> > drivers/i2c/busses/i2c-designware-platdrv.c | 34 ++++++++++++---------
> > 1 file changed, 19 insertions(+), 15 deletions(-)
> >
> > diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c
> > index c77029e520dc..d334af1d7c6f 100644
> > --- a/drivers/i2c/busses/i2c-designware-platdrv.c
> > +++ b/drivers/i2c/busses/i2c-designware-platdrv.c
> > @@ -206,6 +206,13 @@ static void i2c_dw_remove_lock_support(struct dw_i2c_dev *dev)
> > i2c_dw_semaphore_cb_table[dev->semaphore_idx].remove(dev);
> > }
> >
> > +static void dw_i2c_plat_assert_reset(void *data)
> > +{
> > + struct dw_i2c_dev *dev = data;
> > +
> > + reset_control_assert(dev->rst);
> > +}
> > +
> > static int dw_i2c_plat_probe(struct platform_device *pdev)
> > {
> > u32 flags = (uintptr_t)device_get_match_data(&pdev->dev);
> > @@ -240,34 +247,34 @@ static int dw_i2c_plat_probe(struct platform_device *pdev)
> > if (IS_ERR(dev->rst))
> > return PTR_ERR(dev->rst);
> >
> > + ret = devm_add_action_or_reset(device, dw_i2c_plat_assert_reset, dev);
> > + if (ret)
> > + return ret;
> > +
>
> This is already done by patch 1. Drop these hunks

See [1], _deasserted() already includes assert-on-detach.

[1] https://docs.kernel.org/driver-api/reset.html#c.devm_reset_control_get_optional_exclusive_deasserted

regards
Philipp