Re: [PATCH v2 3/6] i2c: pasemi: Improve timeout handling

Andi Shyti
2025-04-17T12:57:48Z

Hi Sven,

> static int pasemi_smb_waitready(struct pasemi_smbus *smbus)
> {
> int timeout = 100;
> + int ret;

can you please declare this "ret" inside the if() statement
below?

> unsigned int status;
>
> if (smbus->use_irq) {
> reinit_completion(&smbus->irq_completion);
> reg_write(smbus, REG_IMASK, SMSTA_XEN | SMSTA_MTN);
> - wait_for_completion_timeout(&smbus->irq_completion, msecs_to_jiffies(100));
> + ret = wait_for_completion_timeout(&smbus->irq_completion, msecs_to_jiffies(100));
> reg_write(smbus, REG_IMASK, 0);
> status = reg_read(smbus, REG_SMSTA);
> +
> + if (ret < 0) {
> + dev_err(smbus->dev,
> + "Completion wait failed with %d, status 0x%08x\n",
> + ret, status);
> + return ret;
> + } else if (ret == 0) {
> + dev_warn(smbus->dev, "Timeout, status 0x%08x\n", status);
> + return -ETIME;
> + }
> } else {
> status = reg_read(smbus, REG_SMSTA);
> while (!(status & SMSTA_XEN) && timeout--) {
> msleep(1);
> status = reg_read(smbus, REG_SMSTA);
> }
> +
> + if (timeout < 0) {
> + dev_warn(smbus->dev, "Timeout, status 0x%08x\n", status);

this is an error and it's treated as an error, can we please
print dev_err()?

Andi

> + return -ETIME;
> + }
> }