Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4ccc28f7 authored by Roel Kluin's avatar Roel Kluin Committed by Jean Delvare
Browse files

i2c: Timeouts off by 1



with while (timeout++ < MAX_TIMEOUT); timeout reaches MAX_TIMEOUT + 1
after the loop, so the tests below are off by one.

Signed-off-by: default avatarRoel Kluin <roel.kluin@gmail.com>
Signed-off-by: default avatarJean Delvare <khali@linux-fr.org>
parent b4348f32
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -284,7 +284,7 @@ static int ali1535_transaction(struct i2c_adapter *adap)
		 && (timeout++ < MAX_TIMEOUT));
		 && (timeout++ < MAX_TIMEOUT));


	/* If the SMBus is still busy, we give up */
	/* If the SMBus is still busy, we give up */
	if (timeout >= MAX_TIMEOUT) {
	if (timeout > MAX_TIMEOUT) {
		result = -ETIMEDOUT;
		result = -ETIMEDOUT;
		dev_err(&adap->dev, "SMBus Timeout!\n");
		dev_err(&adap->dev, "SMBus Timeout!\n");
	}
	}
+1 −1
Original line number Original line Diff line number Diff line
@@ -306,7 +306,7 @@ static int ali15x3_transaction(struct i2c_adapter *adap)
		 && (timeout++ < MAX_TIMEOUT));
		 && (timeout++ < MAX_TIMEOUT));


	/* If the SMBus is still busy, we give up */
	/* If the SMBus is still busy, we give up */
	if (timeout >= MAX_TIMEOUT) {
	if (timeout > MAX_TIMEOUT) {
		result = -ETIMEDOUT;
		result = -ETIMEDOUT;
		dev_err(&adap->dev, "SMBus Timeout!\n");
		dev_err(&adap->dev, "SMBus Timeout!\n");
	}
	}
+2 −2
Original line number Original line Diff line number Diff line
@@ -126,7 +126,7 @@ static int amd756_transaction(struct i2c_adapter *adap)
		} while ((temp & (GS_HST_STS | GS_SMB_STS)) &&
		} while ((temp & (GS_HST_STS | GS_SMB_STS)) &&
		         (timeout++ < MAX_TIMEOUT));
		         (timeout++ < MAX_TIMEOUT));
		/* If the SMBus is still busy, we give up */
		/* If the SMBus is still busy, we give up */
		if (timeout >= MAX_TIMEOUT) {
		if (timeout > MAX_TIMEOUT) {
			dev_dbg(&adap->dev, "Busy wait timeout (%04x)\n", temp);
			dev_dbg(&adap->dev, "Busy wait timeout (%04x)\n", temp);
			goto abort;
			goto abort;
		}
		}
@@ -143,7 +143,7 @@ static int amd756_transaction(struct i2c_adapter *adap)
	} while ((temp & GS_HST_STS) && (timeout++ < MAX_TIMEOUT));
	} while ((temp & GS_HST_STS) && (timeout++ < MAX_TIMEOUT));


	/* If the SMBus is still busy, we give up */
	/* If the SMBus is still busy, we give up */
	if (timeout >= MAX_TIMEOUT) {
	if (timeout > MAX_TIMEOUT) {
		dev_dbg(&adap->dev, "Completion timeout!\n");
		dev_dbg(&adap->dev, "Completion timeout!\n");
		goto abort;
		goto abort;
	}
	}
+4 −4
Original line number Original line Diff line number Diff line
@@ -237,7 +237,7 @@ static int i801_transaction(int xact)
		status = inb_p(SMBHSTSTS);
		status = inb_p(SMBHSTSTS);
	} while ((status & SMBHSTSTS_HOST_BUSY) && (timeout++ < MAX_TIMEOUT));
	} while ((status & SMBHSTSTS_HOST_BUSY) && (timeout++ < MAX_TIMEOUT));


	result = i801_check_post(status, timeout >= MAX_TIMEOUT);
	result = i801_check_post(status, timeout > MAX_TIMEOUT);
	if (result < 0)
	if (result < 0)
		return result;
		return result;


@@ -257,9 +257,9 @@ static void i801_wait_hwpec(void)
	} while ((!(status & SMBHSTSTS_INTR))
	} while ((!(status & SMBHSTSTS_INTR))
		 && (timeout++ < MAX_TIMEOUT));
		 && (timeout++ < MAX_TIMEOUT));


	if (timeout >= MAX_TIMEOUT) {
	if (timeout > MAX_TIMEOUT)
		dev_dbg(&I801_dev->dev, "PEC Timeout!\n");
		dev_dbg(&I801_dev->dev, "PEC Timeout!\n");
	}

	outb_p(status, SMBHSTSTS);
	outb_p(status, SMBHSTSTS);
}
}


@@ -344,7 +344,7 @@ static int i801_block_transaction_byte_by_byte(union i2c_smbus_data *data,
		while ((!(status & SMBHSTSTS_BYTE_DONE))
		while ((!(status & SMBHSTSTS_BYTE_DONE))
		       && (timeout++ < MAX_TIMEOUT));
		       && (timeout++ < MAX_TIMEOUT));


		result = i801_check_post(status, timeout >= MAX_TIMEOUT);
		result = i801_check_post(status, timeout > MAX_TIMEOUT);
		if (result < 0)
		if (result < 0)
			return result;
			return result;


+1 −1
Original line number Original line Diff line number Diff line
@@ -112,7 +112,7 @@ static int sch_transaction(void)
	} while ((temp & 0x08) && (timeout++ < MAX_TIMEOUT));
	} while ((temp & 0x08) && (timeout++ < MAX_TIMEOUT));


	/* If the SMBus is still busy, we give up */
	/* If the SMBus is still busy, we give up */
	if (timeout >= MAX_TIMEOUT) {
	if (timeout > MAX_TIMEOUT) {
		dev_err(&sch_adapter.dev, "SMBus Timeout!\n");
		dev_err(&sch_adapter.dev, "SMBus Timeout!\n");
		result = -ETIMEDOUT;
		result = -ETIMEDOUT;
	}
	}
Loading