/** * octeon_i2c_wait - wait for the IFLG to be set * @i2c: The struct octeon_i2c * * Returns 0 on success, otherwise a negative errno. */ static int octeon_i2c_wait(struct octeon_i2c *i2c) { long time_left; /* * Some chip revisions don't assert the irq in the interrupt * controller. So we must poll for the IFLG change. */ if (i2c->broken_irq_mode) { u64 end = get_jiffies_64() + i2c->adap.timeout; while (!octeon_i2c_test_iflg(i2c) && time_before64(get_jiffies_64(), end)) usleep_range(I2C_OCTEON_EVENT_WAIT / 2, I2C_OCTEON_EVENT_WAIT); return octeon_i2c_test_iflg(i2c) ? 0 : -ETIMEDOUT; } i2c->int_enable(i2c); time_left = wait_event_timeout(i2c->queue, octeon_i2c_test_iflg(i2c), i2c->adap.timeout); i2c->int_disable(i2c); if (i2c->broken_irq_check && !time_left && octeon_i2c_test_iflg(i2c)) { dev_err(i2c->dev, "broken irq connection detected, switching to polling mode.\n"); i2c->broken_irq_mode = true; return 0; } if (!time_left) return -ETIMEDOUT; return 0; }
/** * octeon_i2c_wait - wait for the IFLG to be set. * @i2c: The struct octeon_i2c. * * Returns 0 on success, otherwise a negative errno. */ static int octeon_i2c_wait(struct octeon_i2c *i2c) { int result; octeon_i2c_int_enable(i2c); result = wait_event_interruptible_timeout(i2c->queue, octeon_i2c_test_iflg(i2c), i2c->adap.timeout); octeon_i2c_int_disable(i2c); if (result < 0) { dev_dbg(i2c->dev, "%s: wait interrupted\n", __func__); return result; } else if (result == 0) { dev_dbg(i2c->dev, "%s: timeout\n", __func__); <<<<<<< HEAD
/** * octeon_i2c_wait - wait for the IFLG to be set. * @i2c: The struct octeon_i2c. * * Returns 0 on success, otherwise a negative errno. */ static int octeon_i2c_wait(struct octeon_i2c *i2c) { long result; octeon_i2c_int_enable(i2c); result = wait_event_timeout(i2c->queue, octeon_i2c_test_iflg(i2c), i2c->adap.timeout); octeon_i2c_int_disable(i2c); if (result == 0) { dev_dbg(i2c->dev, "%s: timeout\n", __func__); return -ETIMEDOUT; } return 0; }