All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Hans-Jürgen Koch" <hjk@linutronix.de>
To: lm-sensors@vger.kernel.org
Subject: Re: [lm-sensors] What about i2c_smbus_read_block_data() ?
Date: Wed, 04 Apr 2007 21:32:34 +0000	[thread overview]
Message-ID: <200704042332.34959.hjk@linutronix.de> (raw)
In-Reply-To: <200704042149.21264.hjk@linutronix.de>

[-- Attachment #1: Type: text/plain, Size: 932 bytes --]

Am Mittwoch, 4. April 2007 21:49 schrieb Hans-Jürgen Koch:
> 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

[-- Attachment #2: add-i2c_smbus_read_block_data.patch --]
[-- Type: text/x-diff, Size: 1921 bytes --]

Index: linux-2.6.21-rc/drivers/i2c/i2c-core.c
===================================================================
--- linux-2.6.21-rc.orig/drivers/i2c/i2c-core.c	2007-04-04 22:40:55.000000000 +0200
+++ linux-2.6.21-rc/drivers/i2c/i2c-core.c	2007-04-04 23:01:40.000000000 +0200
@@ -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);
Index: linux-2.6.21-rc/include/linux/i2c.h
===================================================================
--- linux-2.6.21-rc.orig/include/linux/i2c.h	2007-04-04 22:46:15.000000000 +0200
+++ linux-2.6.21-rc/include/linux/i2c.h	2007-04-04 22:47:19.000000000 +0200
@@ -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);

[-- Attachment #3: Type: text/plain, Size: 153 bytes --]

_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

  reply	other threads:[~2007-04-04 21:32 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-04 19:49 [lm-sensors] What about i2c_smbus_read_block_data() ? Hans-Jürgen Koch
2007-04-04 21:32 ` Hans-Jürgen Koch [this message]
2007-04-05  2:42 ` Mark M. Hoffman
2007-04-08  8:58 ` Jean Delvare
2007-04-08  9:26 ` Hans-Jürgen Koch

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200704042332.34959.hjk@linutronix.de \
    --to=hjk@linutronix.de \
    --cc=lm-sensors@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.