From: Greg KH <greg@kroah.com>
To: linux-kernel@vger.kernel.org, sensors@stimpy.netroedge.com
Subject: Re: [PATCH] I2C patches for 2.6.10
Date: Fri, 7 Jan 2005 21:39:34 -0800 [thread overview]
Message-ID: <1105162774832@kroah.com> (raw)
In-Reply-To: <1105162774441@kroah.com>
ChangeSet 1.1938.439.48, 2005/01/06 13:55:55-08:00, khali@linux-fr.org
[PATCH] I2C: Add byte commands to i2c-stub
While working on EEPROMs, DDC/EDID and the like these last few days, I
wanted to use your i2c-stub driver to test my code. However, I noticed
that it wouldn't handle byte commands, while both i2cdetect and the
eeprom driver need it for proper operation. Thus I added this
functionality to the driver. What do you think about it?
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
Documentation/i2c/i2c-stub | 9 +++++++--
drivers/i2c/busses/i2c-stub.c | 22 ++++++++++++++++++++--
2 files changed, 27 insertions(+), 4 deletions(-)
diff -Nru a/Documentation/i2c/i2c-stub b/Documentation/i2c/i2c-stub
--- a/Documentation/i2c/i2c-stub 2005-01-07 14:54:26 -08:00
+++ b/Documentation/i2c/i2c-stub 2005-01-07 14:54:26 -08:00
@@ -2,13 +2,18 @@
DESCRIPTION:
-This module is a very simple fake I2C/SMBus driver. It implements three
-types of SMBus commands: write quick, (r/w) byte data, and (r/w) word data.
+This module is a very simple fake I2C/SMBus driver. It implements four
+types of SMBus commands: write quick, (r/w) byte, (r/w) byte data, and
+(r/w) word data.
No hardware is needed nor associated with this module. It will accept write
quick commands to all addresses; it will respond to the other commands (also
to all addresses) by reading from or writing to an array in memory. It will
also spam the kernel logs for every command it handles.
+
+A pointer register with auto-increment is implemented for all byte
+operations. This allows for continuous byte reads like those supported by
+EEPROMs, among others.
The typical use-case is like this:
1. load this module
diff -Nru a/drivers/i2c/busses/i2c-stub.c b/drivers/i2c/busses/i2c-stub.c
--- a/drivers/i2c/busses/i2c-stub.c 2005-01-07 14:54:26 -08:00
+++ b/drivers/i2c/busses/i2c-stub.c 2005-01-07 14:54:26 -08:00
@@ -28,6 +28,7 @@
#include <linux/errno.h>
#include <linux/i2c.h>
+static u8 stub_pointer;
static u8 stub_bytes[256];
static u16 stub_words[256];
@@ -44,6 +45,22 @@
ret = 0;
break;
+ case I2C_SMBUS_BYTE:
+ if (read_write == I2C_SMBUS_WRITE) {
+ stub_pointer = command;
+ dev_dbg(&adap->dev, "smbus byte - addr 0x%02x, "
+ "wrote 0x%02x.\n",
+ addr, command);
+ } else {
+ data->byte = stub_bytes[stub_pointer++];
+ dev_dbg(&adap->dev, "smbus byte - addr 0x%02x, "
+ "read 0x%02x.\n",
+ addr, data->byte);
+ }
+
+ ret = 0;
+ break;
+
case I2C_SMBUS_BYTE_DATA:
if (read_write == I2C_SMBUS_WRITE) {
stub_bytes[command] = data->byte;
@@ -56,6 +73,7 @@
"read 0x%02x at 0x%02x.\n",
addr, data->byte, command);
}
+ stub_pointer = command + 1;
ret = 0;
break;
@@ -87,8 +105,8 @@
static u32 stub_func(struct i2c_adapter *adapter)
{
- return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE_DATA |
- I2C_FUNC_SMBUS_WORD_DATA;
+ return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE |
+ I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA;
}
static struct i2c_algorithm smbus_algorithm = {
next prev parent reply other threads:[~2005-01-08 9:30 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-01-08 5:38 [BK PATCH] I2C patches for 2.6.10 Greg KH
2005-01-08 5:39 ` [PATCH] " Greg KH
2005-01-08 5:39 ` Greg KH
2005-01-08 5:39 ` Greg KH
2005-01-08 5:39 ` Greg KH
2005-01-08 5:39 ` Greg KH [this message]
2005-01-08 5:39 ` Greg KH
2005-01-08 5:39 ` Greg KH
2005-01-08 5:39 ` Greg KH
2005-01-08 5:39 ` Greg KH
2005-01-08 5:39 ` Greg KH
2005-01-08 5:39 ` Greg KH
2005-01-08 5:39 ` Greg KH
2005-01-08 5:39 ` Greg KH
2005-01-08 5:39 ` Greg KH
2005-01-08 5:39 ` Greg KH
2005-01-08 5:39 ` Greg KH
2005-01-08 5:39 ` Greg KH
2005-01-08 5:39 ` Greg KH
2005-01-08 5:39 ` Greg KH
2005-01-08 5:39 ` Greg KH
2005-01-08 5:39 ` Greg KH
2005-01-08 5:39 ` Greg KH
2005-01-08 5:39 ` Greg KH
2005-01-08 6:22 ` Mark M. Hoffman
2005-01-08 10:15 ` Jean Delvare
2005-01-08 15:37 ` Greg KH
2005-01-08 19:09 ` [BK PATCH] " Christoph Hellwig
2005-01-08 22:28 ` Greg KH
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=1105162774832@kroah.com \
--to=greg@kroah.com \
--cc=linux-kernel@vger.kernel.org \
--cc=sensors@stimpy.netroedge.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).