* [rtc-linux] [PATCH 1/2] rtc: ds1307: fix ds1307_native_smbus_read_block_data function
@ 2016-04-02 22:10 Nicolas Boullis
2016-04-18 22:16 ` [rtc-linux] " Alexandre Belloni
2016-04-18 22:27 ` Alexandre Belloni
0 siblings, 2 replies; 3+ messages in thread
From: Nicolas Boullis @ 2016-04-02 22:10 UTC (permalink / raw)
To: Alessandro Zummo, Alexandre Belloni, rtc-linux
[-- Attachment #1: Type: text/plain, Size: 1869 bytes --]
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 <nboullis@debian.org>
---
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.
diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
index b2156ee..19e7353 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,
--
--
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 rtc-linux+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [rtc-linux] Re: [PATCH 1/2] rtc: ds1307: fix ds1307_native_smbus_read_block_data function
2016-04-02 22:10 [rtc-linux] [PATCH 1/2] rtc: ds1307: fix ds1307_native_smbus_read_block_data function Nicolas Boullis
@ 2016-04-18 22:16 ` Alexandre Belloni
2016-04-18 22:27 ` Alexandre Belloni
1 sibling, 0 replies; 3+ messages in thread
From: Alexandre Belloni @ 2016-04-18 22:16 UTC (permalink / raw)
To: Nicolas Boullis, Wolfram Sang; +Cc: Alessandro Zummo, rtc-linux
Hi,
On 03/04/2016 at 00:10:37 +0200, Nicolas Boullis wrote :
> 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 <nboullis@debian.org>
>
> ---
>
> 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.
>
I think it will be difficult to change it now.
Wolfram, you may have an opinion?
> diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
> index b2156ee..19e7353 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,
--
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 rtc-linux+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [rtc-linux] Re: [PATCH 1/2] rtc: ds1307: fix ds1307_native_smbus_read_block_data function
2016-04-02 22:10 [rtc-linux] [PATCH 1/2] rtc: ds1307: fix ds1307_native_smbus_read_block_data function Nicolas Boullis
2016-04-18 22:16 ` [rtc-linux] " Alexandre Belloni
@ 2016-04-18 22:27 ` Alexandre Belloni
1 sibling, 0 replies; 3+ messages in thread
From: Alexandre Belloni @ 2016-04-18 22:27 UTC (permalink / raw)
To: Nicolas Boullis; +Cc: Alessandro Zummo, rtc-linux
On 03/04/2016 at 00:10:37 +0200, Nicolas Boullis wrote :
> 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 <nboullis@debian.org>
>
Applied, thanks.
--
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 rtc-linux+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-04-18 22:27 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-02 22:10 [rtc-linux] [PATCH 1/2] rtc: ds1307: fix ds1307_native_smbus_read_block_data function Nicolas Boullis
2016-04-18 22:16 ` [rtc-linux] " Alexandre Belloni
2016-04-18 22:27 ` Alexandre Belloni
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.