Re: [PATCH v4 2/2] i2c: core: support recovery for single-ended GPIOs

From: 李杰

Date: Mon May 11 2026 - 03:25:29 EST


Thanks for the heads-up, Wolfram.

No problem from my side. I can send a v5 rebased on top of
b47bc7c022dd if Linus prefers, or leave it to be resolved when
applying since the conflict should be trivial.

Thanks,
Jie Li

On Sat, May 9, 2026 at 12:10 PM Wolfram Sang
<wsa+renesas@xxxxxxxxxxxxxxxxxxxx> wrote:
>
> On Sat, May 09, 2026 at 11:12:08AM +0200, Jie Li wrote:
> > Currently, i2c_init_recovery() only assigns the set_sda/set_scl
> > hooks if gpiod_get_direction() returns GPIO_LINE_DIRECTION_OUT.
> >
> > This logic fails on certain SoC controllers where open-drain lines
> > in a high-impedance state are physically reported as inputs. This
> > leads to a "deadlock" where the I2C core refuses to assign the
> > recovery hooks because it incorrectly assumes the pins are
> > input-only, even though they are fully capable of driving the bus
> > low for recovery.
> >
> > Update the recovery initialization to use the new
> > gpiod_is_single_ended() helper. If a GPIO is configured as
> > open-drain or open-source in the firmware, it is safe to assume
> > it can be used for bus recovery, even if the current hardware
> > direction is reported as input.
> >
> > Signed-off-by: Jie Li <jie.i.li@xxxxxxxxx>
> > Reviewed-by: Linus Walleij <linusw@xxxxxxxxxx>
> > Acked-by: Wolfram Sang <wsa+renesas@xxxxxxxxxxxxxxxxxxxx>
>
> I overlooked that the change with GPIO_LINE_DIRECTION_OUT I suggested
> for this patch is at the same location as commit[1]. I already pushed
> out said commit for -rc3 and it is, thus, already in -next, too. No big
> harm, but there will be a little conflict when applying. Sorry, Linus!
>
> [1] b47bc7c022dd ("i2c: Compare the return value of gpiod_get_direction against GPIO_LINE_DIRECTION_OUT")
>