What about i2c_smbus_read_block_data() ?
I'm working on a driver for LM93. I've got some code by Mark Hoffman, (c)2004. It doesn't compile on a recent kernel, because it heavily uses a function called i2c_smbus_read_block_data(). Googling for that, I found this old mail in the archives (October 2005):
http://lists.lm-sensors.org/pipermail/lm-sensors/2005-October/013971.html
Jean, what do you say to that today? Can we have that function back in mainline, or do I have to find another solution?
If you agree to add it, I could prepare a patch for it, if you don't have a recent version handy.
Thanks,
Hans
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Am Mittwoch, 4. April 2007 21:49 schrieb Hans-Jürgen Koch:
Quoted 11 lines
I'm working on a driver for LM93. I've got some code by Mark Hoffman, (c)2004. It doesn't compile on a recent kernel, because it heavily uses a function called
i2c_smbus_read_block_data(). Googling for that, I found this old mail in the archives (October 2005):http://lists.lm-sensors.org/pipermail/lm-sensors/2005-October/013971.html
Jean, what do you say to that today? Can we have that function back in mainline, or do I have to find another solution?
If you agree to add it, I could prepare a patch for it, if you don't have a recent version handy.
Answering my own question: After looking at i2c-core.c et al., I find it quite obvious that this function should be added, if a driver needs it.
I attached a patch that does this. Would that be acceptable? I can resend it when I have the LM93 patch ready.
Thanks,
Hans
drivers/i2c/i2c-core.c +17 -0
@@ -994,6 +994,22 @@ I2C_SMBUS_WORD_DATA,&data); } +s32 i2c_smbus_read_block_data (struct i2c_client *client,u8 command, +u8 *values) +{ +union i2c_smbus_data data; +int i; +if (i2c_smbus_xfer (client->adapter, client->addr, client->flags, +I2C_SMBUS_READ , command, +I2C_SMBUS_BLOCK_DATA , &data)) +return -1 ; +else { +for (i =1 ; i <= data.block[0 ]; i++) + values[i-1 ] = data.block[i]; +return data.block[0 ]; + } +} +s32 i2c_smbus_write_block_data (struct i2c_client *client,u8 command,u8 length,const u8 *values) {
@@ -1238,6 +1254,7 @@EXPORT_SYMBOL (i2c_smbus_write_byte_data);EXPORT_SYMBOL (i2c_smbus_read_word_data);EXPORT_SYMBOL (i2c_smbus_write_word_data); +EXPORT_SYMBOL (i2c_smbus_read_block_data);EXPORT_SYMBOL (i2c_smbus_write_block_data);EXPORT_SYMBOL (i2c_smbus_read_i2c_block_data);EXPORT_SYMBOL (i2c_smbus_write_i2c_block_data);
include/linux/i2c.h +2 -0
@@ -87,6 +87,8 @@extern s32 i2c_smbus_read_word_data (struct i2c_client * client,u8 command);extern s32 i2c_smbus_write_word_data (struct i2c_client * client,u8 command,u16 value); +extern s32 i2c_smbus_read_block_data (struct i2c_client *client,u8 command, +u8 *values);extern s32 i2c_smbus_write_block_data (struct i2c_client * client,u8 command,u8 length,const u8 *values);
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Hello:
Quoted 13 lines · Hans-Jürgen Koch
Am Mittwoch, 4. April 2007 21:49 schrieb Hans-Jürgen Koch:
Quoted 11 lines
I'm working on a driver for LM93. I've got some code by Mark Hoffman, (c)2004. It doesn't compile on a recent kernel, because it heavily uses a function called
i2c_smbus_read_block_data(). Googling for that, I found this old mail in the archives (October 2005):http://lists.lm-sensors.org/pipermail/lm-sensors/2005-October/013971.html
Jean, what do you say to that today? Can we have that function back in mainline, or do I have to find another solution?
If you agree to add it, I could prepare a patch for it, if you don't have a recent version handy.
Quoted 5 lines
Answering my own question: After looking at
i2c-core.cet al., I find it quite obvious that this function should be added, if a driver needs it.I attached a patch that does this. Would that be acceptable? I can resend it when I have the LM93 patch ready.
I think if you put it in the same patchset with lm93.c, that will be fine.
Jean: I can do the initial review of this one for you when it's ready.
Regards,
Signature · 8 lines
Mark M. Hoffman [email protected] _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Hi Mark, Hans-Jürgen,
Quoted 9 lines · Mark M. Hoffman
Quoted 8 lines · Hans-Jürgen Koch
Am Mittwoch, 4. April 2007 21:49 schrieb Hans-Jürgen Koch:
Quoted 7 lines
I'm working on a driver for LM93. I've got some code by Mark Hoffman, (c)2004. It doesn't compile on a recent kernel, because it heavily uses a function called
i2c_smbus_read_block_data(). Googling for that, I found this old mail in the archives (October 2005):http://lists.lm-sensors.org/pipermail/lm-sensors/2005-October/013971.html
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
Jean, what do you say to that today? Can we have that function back in mainline, or do I have to find another solution?
If you agree to add it, I could prepare a patch for it, if you don't have a recent version handy.Answering my own question: After looking at
i2c-core.cet al., I find it quite obvious that this function should be added, if a driver needs it.
True.
Quoted 4 lines
Quoted 2 lines
I attached a patch that does this. Would that be acceptable? I can resend it when I have the LM93 patch ready.
I think if you put it in the same patchset with
lm93.c, that will be fine.
I have a different variant of this patch in my local tree, which takes the i2c-core changes that happened in the meantime into account. I'm attaching it to this post if someone want to take a look and/or comment. In fact I think I'll schedule this patch for merge into 2.6.22 regardless of the state of the lm93 driver patch. I'm a bit tired to have to maintain that patch off-tree and to see people waste their time wondering where that function has gone, searching the mailing list for explanations, finding the patch and resubmitting it. We all have better things to do.
Anyway, the key point for Hans-Jürgen is: you can assume that function i2c_smbus_read_block_data() will be available to you when your lm93 driver patch is merged upstream.
Quoted 1 line
Jean: I can do the initial review of this one for you when it's ready.
Great, thanks!
Signature · 1 line
Jean Delvare
Subject: i2c: Restore i2c_smbus_read_block_data
Add back the i2c_smbus_read_block_data function, it is needed by the upcoming lm93 driver.
--- drivers/i2c/i2c-core.c | 16 ++++++++++++++++ include/linux/i2c.h | 3 +++ 2 files changed, 19 insertions(+)
drivers/i2c/i2c-core.c +16 -0
@@ -1300,6 +1300,22 @@ s32 i2c_smbus_write_word_data(struct i2c }EXPORT_SYMBOL (i2c_smbus_write_word_data); +/* Returns the number of read bytes */ +s32 i2c_smbus_read_block_data (struct i2c_client *client,u8 command, +u8 *values) +{ +union i2c_smbus_data data; + +if (i2c_smbus_xfer (client->adapter, client->addr, client->flags, +I2C_SMBUS_READ , command, +I2C_SMBUS_BLOCK_DATA , &data)) +return -1 ; + +memcpy (values, &data.block[1 ], data.block[0 ]); +return data.block[0 ]; +} +EXPORT_SYMBOL (i2c_smbus_read_block_data); +s32 i2c_smbus_write_block_data (struct i2c_client *client,u8 command,u8 length,const u8 *values) {
include/linux/i2c.h +3 -0
@@ -82,6 +82,9 @@ extern s32 i2c_smbus_write_byte_data(strextern s32 i2c_smbus_read_word_data (struct i2c_client * client,u8 command);extern s32 i2c_smbus_write_word_data (struct i2c_client * client,u8 command,u16 value); +/* Returns the number of read bytes */ +extern s32 i2c_smbus_read_block_data (struct i2c_client *client, +u8 command,u8 *values);extern s32 i2c_smbus_write_block_data (struct i2c_client * client,u8 command,u8 length,const u8 *values);
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Am Sonntag 08 April 2007 10:58 schrieb Jean Delvare:
Quoted 5 lines
I have a different variant of this patch in my local tree, which takes the i2c-core changes that happened in the meantime into account. I'm attaching it to this post if someone want to take a look and/or comment.
Looks allright to me.
Quoted 2 lines
In fact I think I'll schedule this patch for merge into 2.6.22 regardless of the state of the lm93 driver patch.
Good idea. I will submit a first version of the LM93 patch next Thursday or Friday. It's ready, but I cannot test it until then.
Quoted 5 lines
I'm a bit tired to
have to maintain that patch off-tree and to see people waste their time wondering where that function has gone, searching the mailing list for explanations, finding the patch and resubmitting it. We all have better things to do.
I second that.
Quoted 4 lines
Anyway, the key point for Hans-Jürgen is: you can assume that function
i2c_smbus_read_block_data()will be available to you when your lm93 driver patch is merged upstream.
Fine.
Thanks,
Hans
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors