Re: [PATCH v4 1/2] i2c: i2c-xiic: fix clearing of bnb irq

From: Andi Shyti

Date: Wed Nov 18 2026 - 08:22:25 EST


Hi Thilo,

...

> +static void xiic_clear_en_bnb(struct xiic_i2c *i2c)
> +{
> + u8 sr = 0, isr = 0;
> + int ret;
> +
> + isr = xiic_getreg8(i2c, XIIC_IISR_OFFSET);
> + if (!(isr & XIIC_INTR_BNB_MASK)) {
> + xiic_irq_en(i2c, XIIC_INTR_BNB_MASK);
> + return;
> + }
> +
> + ret = read_poll_timeout_atomic(xiic_getreg8, sr,
> + sr & XIIC_SR_BUS_BUSY_MASK, 0, XIIC_BB_TIMEOUT_US, 0,
> + i2c, XIIC_SR_REG_OFFSET);

this is a bit of an overkill: you are forcing tight loops for
1ms. If you consider that the minimum wait is 1ns, in 1ms you
will end up busy looping a lot of time. Please, don't set the
delay_us to '0', but calculate a proper waiting time between
reads.

Andi

> + if (ret) {
> + dev_err(i2c->dev, "Failed to clear bnb\n");
> + return;
> + }
> +
> + xiic_setreg8(i2c, XIIC_IISR_OFFSET, XIIC_INTR_BNB_MASK);
> + xiic_irq_en(i2c, XIIC_INTR_BNB_MASK);
> +}