Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 77315
b: refs/heads/master
c: 569be44
h: refs/heads/master
i:
  77313: cfeadb3
  77311: 543be86
v: v3
  • Loading branch information
Jean Delvare authored and Jean Delvare committed Jan 27, 2008
1 parent 5c3cec1 commit f0a44cc
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: b3af547e197fa3ca648d148dd8d36befe989e5a0
refs/heads/master: 569be443e3c1329fc6725988004f5d8a32fe3be5
3 changes: 0 additions & 3 deletions trunk/Documentation/i2c/i2c-stub
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ int chip_addr[10]:

CAVEATS:

There are independent arrays for byte/data and word/data commands. Depending
on if/how a target driver mixes them, you'll need to be careful.

If your target driver polls some byte or word waiting for it to change, the
stub could lock it up. Use i2cset to unlock it.

Expand Down
15 changes: 8 additions & 7 deletions trunk/drivers/i2c/busses/i2c-stub.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
i2c-stub.c - Part of lm_sensors, Linux kernel modules for hardware
monitoring
i2c-stub.c - I2C/SMBus chip emulator
Copyright (c) 2004 Mark M. Hoffman <mhoffman@lightlink.com>
Copyright (C) 2007 Jean Delvare <khali@linux-fr.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -37,8 +37,8 @@ MODULE_PARM_DESC(chip_addr,

struct stub_chip {
u8 pointer;
u8 bytes[256];
u16 words[256];
u16 words[256]; /* Byte operations use the LSB as per SMBus
specification */
};

static struct stub_chip *stub_chips;
Expand Down Expand Up @@ -75,7 +75,7 @@ static s32 stub_xfer(struct i2c_adapter * adap, u16 addr, unsigned short flags,
"wrote 0x%02x.\n",
addr, command);
} else {
data->byte = chip->bytes[chip->pointer++];
data->byte = chip->words[chip->pointer++] & 0xff;
dev_dbg(&adap->dev, "smbus byte - addr 0x%02x, "
"read 0x%02x.\n",
addr, data->byte);
Expand All @@ -86,12 +86,13 @@ static s32 stub_xfer(struct i2c_adapter * adap, u16 addr, unsigned short flags,

case I2C_SMBUS_BYTE_DATA:
if (read_write == I2C_SMBUS_WRITE) {
chip->bytes[command] = data->byte;
chip->words[command] &= 0xff00;
chip->words[command] |= data->byte;
dev_dbg(&adap->dev, "smbus byte data - addr 0x%02x, "
"wrote 0x%02x at 0x%02x.\n",
addr, data->byte, command);
} else {
data->byte = chip->bytes[command];
data->byte = chip->words[command] & 0xff;
dev_dbg(&adap->dev, "smbus byte data - addr 0x%02x, "
"read 0x%02x at 0x%02x.\n",
addr, data->byte, command);
Expand Down

0 comments on commit f0a44cc

Please sign in to comment.