RE: [PATCH] rtc-ds1307: True SMBus compatibility
From: BARRE Sebastien
Date: Tue Jan 06 2009 - 08:44:52 EST
Hello,
> -----Original Message-----
> From: Ed Swierk [mailto:eswierk@xxxxxxxxxxxxxxxxxx]
> Sent: Monday, January 05, 2009 6:36 PM
> To: i2c@xxxxxxxxxxxxxx; David Brownell; Alessandro Zummo; linux-
> kernel@xxxxxxxxxxxxxxx; Andrew Morton; BARRE Sebastien
> Subject: [PATCH] rtc-ds1307: True SMBus compatibility
>
> Following up to Sebastien Barre's recent patch, here I go one step
> further, replacing i2c block transfers with SMBus byte transfers.
> Sticking to pure SMBus makes the driver work on our board, which has an
> nVidia SMBus controller driving a DS1339; nforce2 controllers
> unfortunately don't support any flavor of i2c block transfer.
>
> Reading or writing registers repeatedly until they stick is rather
> nauseating but I'm aiming for correctness if not elegance. I would
> appreciate any suggestions for improvement.
>
> Signed-off-by: Ed Swierk <eswierk@xxxxxxxxxxxxxxxxxx>
I've read your patch quicly, I will test it on my board as soon as possible.
> +static s32 ds1307_write_block_data(struct i2c_client *client, u8 command,
> + u8 length, const u8 *values)
> +{
> + u8 currvalues[I2C_SMBUS_BLOCK_MAX];
> + s32 ret;
> + pr_debug("ds1307_write_block_data (length=%d)\n", length);
You can delete the next 3 lines, they are not useful:
> + ret = ds1307_read_block_data_once(client, command, length, currvalues);
> + if (ret < 0)
> + return ret;
> + do {
> + s32 i, ret;
> + for (i = 0; i < length; i++) {
> + ret = i2c_smbus_write_byte_data(client, command + i,
> + *(values + i));
> + if (ret < 0)
> + return ret;
> + }
> + ret = ds1307_read_block_data_once(client, command, length, currvalues);
> + if (ret < 0)
> + return ret;
> + } while (memcmp(currvalues, values, length));
> + return length;
> +}
--
SÃbastien BarrÃ
Bureau d'Ãtude - DÃveloppement
SDEL ContrÃle Commande
D2A - Rue Nungesser et Coli
44860 Saint Aignan de Grand Lieu
FRANCE
TÃl : +33(0)2 40 84 50 88
Fax : +33(0)2 40 84 51 10
N§²æìr¸yúèØb²X¬¶ÇvØ^)Þ{.nÇ+·¥{±êçzX§¶¡Ü}©²ÆzÚ&j:+v¨¾«êçzZ+Ê+zf£¢·h§~Ûiÿûàz¹®w¥¢¸?¨èÚ&¢)ßfù^jÇy§m
á@A«a¶Úÿ0¶ìh®åi