i2c: Use u16 for data length

The length will never be negative.

Signed-off-by: Tim Crawford <tcrawford@system76.com>
This commit is contained in:
Tim Crawford
2021-08-02 11:56:47 -06:00
committed by Jeremy Soller
parent 784202383e
commit 2a3830fb57
4 changed files with 18 additions and 18 deletions

View File

@@ -94,8 +94,8 @@ void i2c_stop(struct I2C * i2c) {
i2c_reset(i2c, false);
}
static int16_t i2c_transaction(struct I2C * i2c, uint8_t * data, int16_t length, bool read) {
int16_t i;
static int16_t i2c_transaction(struct I2C * i2c, uint8_t * data, uint16_t length, bool read) {
uint16_t i;
for (i = 0; i < length; i++) {
if (read) {
// If last byte
@@ -153,10 +153,10 @@ static int16_t i2c_transaction(struct I2C * i2c, uint8_t * data, int16_t length,
return i;
}
int16_t i2c_read(struct I2C * i2c, uint8_t * data, int16_t length) __reentrant {
int16_t i2c_read(struct I2C * i2c, uint8_t * data, uint16_t length) __reentrant {
return i2c_transaction(i2c, data, length, true);
}
int16_t i2c_write(struct I2C * i2c, uint8_t * data, int16_t length) __reentrant {
int16_t i2c_write(struct I2C * i2c, uint8_t * data, uint16_t length) __reentrant {
return i2c_transaction(i2c, data, length, false);
}