From: Nicolas Boullis Date: Sat, 2 Apr 2016 22:10:37 +0000 (+0200) Subject: rtc: ds1307: fix ds1307_native_smbus_read_block_data function X-Git-Tag: v4.7-rc1~86^2~26 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=1d87951c398e35118a0fb67b287022f008513f42;p=karo-tx-linux.git rtc: ds1307: fix ds1307_native_smbus_read_block_data function The i2c_smbus_read_i2c_block_data function returns 0 on success, not the number of bytes written. Hence, when there are 32 bytes or less to send, the ds1307_native_smbus_write_block_data function returns 0 on success, while it returns the number of bytes when there are more than 32. The ds1307_write_block_data always returns the number of bytes on success. Signed-off-by: Nicolas Boullis Signed-off-by: Alexandre Belloni --- diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c index ecb7dbae9be9..eed5c06bf624 100644 --- a/drivers/rtc/rtc-ds1307.c +++ b/drivers/rtc/rtc-ds1307.c @@ -275,9 +275,13 @@ static s32 ds1307_native_smbus_write_block_data(const struct i2c_client *client, { u8 suboffset = 0; - if (length <= I2C_SMBUS_BLOCK_MAX) - return i2c_smbus_write_i2c_block_data(client, + if (length <= I2C_SMBUS_BLOCK_MAX) { + s32 retval = i2c_smbus_write_i2c_block_data(client, command, length, values); + if (retval < 0) + return retval; + return length; + } while (suboffset < length) { s32 retval = i2c_smbus_write_i2c_block_data(client,