struct xi2cps *id = adap->algo_data;
unsigned int count, retries;
unsigned long timeout;
+ int ret;
/* Waiting for bus-ready. If bus not ready, it returns after timeout */
timeout = jiffies + XI2CPS_TIMEOUT;
xi2cps_msend(id);
/* Wait for the signal of completion */
- wait_for_completion_interruptible(&id->xfer_done);
+ ret = wait_for_completion_interruptible_timeout(
+ &id->xfer_done, HZ);
+ if (ret == 0) {
+ dev_err(id->adap.dev.parent,
+ "timeout waiting on completion\n");
+ return -ETIMEDOUT;
+ }
xi2cps_writereg(XI2CPS_IXR_ALL_INTR_MASK, XI2CPS_IDR_OFFSET);
/* If it is bus arbitration error, try again */