rtc: ds1307: fix ds1307_native_smbus_read_block_data function
PATCH 1/2 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.
---
Should the behavior of the i2c_smbus_write_i2c_block_data function be changed to be consistant with that of the i2c_smbus_read_i2c_block_data function?
It might be more consistent, but the impact is certainly much larger, and that's far beyond the scope of the RTC subsystem.
drivers/rtc/rtc-ds1307.c +6 -2
@@ -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,
Signature · 9 lines
-- You received this message because you are subscribed to "rtc-linux". Membership options at http://groups.google.com/group/rtc-linux . Please read http://groups.google.com/group/rtc-linux/web/checklist before submitting a driver. --- You received this message because you are subscribed to the Google Groups "rtc-linux" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
Hi,
Quoted 12 lines · Nicolas Boullis
The
i2c_smbus_read_i2c_block_datafunction 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_datafunction returns 0 on success, while it returns the number of bytes when there are more than 32.The
ds1307_write_block_dataalways returns the number of bytes on success.Signed-off-by Nicolas Boullis <[email protected]>
Quoted 9 lines
---
Should the behavior of the
i2c_smbus_write_i2c_block_datafunction be changed to be consistant with that of thei2c_smbus_read_i2c_block_datafunction?It might be more consistent, but the impact is certainly much larger, and that's far beyond the scope of the RTC subsystem.
I think it will be difficult to change it now.
Wolfram, you may have an opinion?
Quoted 20 lines
drivers/rtc/rtc-ds1307.c +6
-2@@ -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,
Signature · 14 lines
Alexandre Belloni, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com -- -- You received this message because you are subscribed to "rtc-linux". Membership options at http://groups.google.com/group/rtc-linux . Please read http://groups.google.com/group/rtc-linux/web/checklist before submitting a driver. --- You received this message because you are subscribed to the Google Groups "rtc-linux" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
Alexandre Belloni
AppliedQuoted 12 lines · Nicolas Boullis
The
i2c_smbus_read_i2c_block_datafunction 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_datafunction returns 0 on success, while it returns the number of bytes when there are more than 32.The
ds1307_write_block_dataalways returns the number of bytes on success.Signed-off-by Nicolas Boullis <[email protected]>
Applied, thanks.
Signature · 14 lines
Alexandre Belloni, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com -- -- You received this message because you are subscribed to "rtc-linux". Membership options at http://groups.google.com/group/rtc-linux . Please read http://groups.google.com/group/rtc-linux/web/checklist before submitting a driver. --- You received this message because you are subscribed to the Google Groups "rtc-linux" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.