Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 68588
b: refs/heads/master
c: 553515e
h: refs/heads/master
v: v3
  • Loading branch information
Jean Delvare authored and Jean Delvare committed Oct 13, 2007
1 parent d53c271 commit de7fe22
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 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: 95a7f10eadcd88cfd6640e44c7b8cf9ac1afafe7
refs/heads/master: 553515e5c54dbf3340cd6773aaf0acb53291d6ad
8 changes: 3 additions & 5 deletions trunk/Documentation/i2c/chips/pcf8574
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ if the corresponding output is set as 1, otherwise the current output
value, that is to say 0.

The write file is read/write. Writing a value outputs it on the I/O
port. Reading returns the last written value.

On module initialization the chip is configured as eight inputs (all
outputs to 1), so you can connect any circuit to the PCF8574(A) without
being afraid of short-circuit.
port. Reading returns the last written value. As it is not possible
to read this value from the chip, you need to write at least once to
this file before you can read back from it.
14 changes: 7 additions & 7 deletions trunk/drivers/i2c/chips/pcf8574.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,11 @@ static unsigned short normal_i2c[] = { 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26,
/* Insmod parameters */
I2C_CLIENT_INSMOD_2(pcf8574, pcf8574a);

/* Initial values */
#define PCF8574_INIT 255 /* All outputs on (input mode) */

/* Each client has this additional data */
struct pcf8574_data {
struct i2c_client client;

u8 write; /* Remember last written value */
int write; /* Remember last written value */
};

static int pcf8574_attach_adapter(struct i2c_adapter *adapter);
Expand Down Expand Up @@ -85,7 +82,11 @@ static DEVICE_ATTR(read, S_IRUGO, show_read, NULL);
static ssize_t show_write(struct device *dev, struct device_attribute *attr, char *buf)
{
struct pcf8574_data *data = i2c_get_clientdata(to_i2c_client(dev));
return sprintf(buf, "%u\n", data->write);

if (data->write < 0)
return data->write;

return sprintf(buf, "%d\n", data->write);
}

static ssize_t set_write(struct device *dev, struct device_attribute *attr, const char *buf,
Expand Down Expand Up @@ -206,8 +207,7 @@ static int pcf8574_detach_client(struct i2c_client *client)
static void pcf8574_init_client(struct i2c_client *client)
{
struct pcf8574_data *data = i2c_get_clientdata(client);
data->write = PCF8574_INIT;
i2c_smbus_write_byte(client, data->write);
data->write = -EAGAIN;
}

static int __init pcf8574_init(void)
Expand Down

0 comments on commit de7fe22

Please sign in to comment.