aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/i2c/chips/pcf85748
-rw-r--r--drivers/i2c/chips/pcf8574.c14
2 files changed, 10 insertions, 12 deletions
diff --git a/Documentation/i2c/chips/pcf8574 b/Documentation/i2c/chips/pcf8574
index 2752c8ce3167..5c1ad1376b62 100644
--- a/Documentation/i2c/chips/pcf8574
+++ b/Documentation/i2c/chips/pcf8574
@@ -62,8 +62,6 @@ if the corresponding output is set as 1, otherwise the current output
62value, that is to say 0. 62value, that is to say 0.
63 63
64The write file is read/write. Writing a value outputs it on the I/O 64The write file is read/write. Writing a value outputs it on the I/O
65port. Reading returns the last written value. 65port. Reading returns the last written value. As it is not possible
66 66to read this value from the chip, you need to write at least once to
67On module initialization the chip is configured as eight inputs (all 67this file before you can read back from it.
68outputs to 1), so you can connect any circuit to the PCF8574(A) without
69being afraid of short-circuit.
diff --git a/drivers/i2c/chips/pcf8574.c b/drivers/i2c/chips/pcf8574.c
index 32b25427eaba..21c6dd69193c 100644
--- a/drivers/i2c/chips/pcf8574.c
+++ b/drivers/i2c/chips/pcf8574.c
@@ -48,14 +48,11 @@ static unsigned short normal_i2c[] = { 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26,
48/* Insmod parameters */ 48/* Insmod parameters */
49I2C_CLIENT_INSMOD_2(pcf8574, pcf8574a); 49I2C_CLIENT_INSMOD_2(pcf8574, pcf8574a);
50 50
51/* Initial values */
52#define PCF8574_INIT 255 /* All outputs on (input mode) */
53
54/* Each client has this additional data */ 51/* Each client has this additional data */
55struct pcf8574_data { 52struct pcf8574_data {
56 struct i2c_client client; 53 struct i2c_client client;
57 54
58 u8 write; /* Remember last written value */ 55 int write; /* Remember last written value */
59}; 56};
60 57
61static int pcf8574_attach_adapter(struct i2c_adapter *adapter); 58static int pcf8574_attach_adapter(struct i2c_adapter *adapter);
@@ -85,7 +82,11 @@ static DEVICE_ATTR(read, S_IRUGO, show_read, NULL);
85static ssize_t show_write(struct device *dev, struct device_attribute *attr, char *buf) 82static ssize_t show_write(struct device *dev, struct device_attribute *attr, char *buf)
86{ 83{
87 struct pcf8574_data *data = i2c_get_clientdata(to_i2c_client(dev)); 84 struct pcf8574_data *data = i2c_get_clientdata(to_i2c_client(dev));
88 return sprintf(buf, "%u\n", data->write); 85
86 if (data->write < 0)
87 return data->write;
88
89 return sprintf(buf, "%d\n", data->write);
89} 90}
90 91
91static ssize_t set_write(struct device *dev, struct device_attribute *attr, const char *buf, 92static ssize_t set_write(struct device *dev, struct device_attribute *attr, const char *buf,
@@ -206,8 +207,7 @@ static int pcf8574_detach_client(struct i2c_client *client)
206static void pcf8574_init_client(struct i2c_client *client) 207static void pcf8574_init_client(struct i2c_client *client)
207{ 208{
208 struct pcf8574_data *data = i2c_get_clientdata(client); 209 struct pcf8574_data *data = i2c_get_clientdata(client);
209 data->write = PCF8574_INIT; 210 data->write = -EAGAIN;
210 i2c_smbus_write_byte(client, data->write);
211} 211}
212 212
213static int __init pcf8574_init(void) 213static int __init pcf8574_init(void)