Messages in this thread | | | From | BARRE Sebastien <> | Date | Tue, 6 Jan 2009 14:35:05 +0100 | Subject | RE: [PATCH] rtc-ds1307: True SMBus compatibility |
| |
Hello,
> -----Original Message----- > From: Ed Swierk [mailto:eswierk@aristanetworks.com] > Sent: Monday, January 05, 2009 6:36 PM > To: i2c@lm-sensors.org; David Brownell; Alessandro Zummo; linux- > kernel@vger.kernel.org; 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@aristanetworks.com>
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
| |