diff options
-rw-r--r-- | Documentation/i2c/chips/pcf8574 | 8 | ||||
-rw-r--r-- | drivers/i2c/chips/pcf8574.c | 14 |
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 | |||
62 | value, that is to say 0. | 62 | value, that is to say 0. |
63 | 63 | ||
64 | The write file is read/write. Writing a value outputs it on the I/O | 64 | The write file is read/write. Writing a value outputs it on the I/O |
65 | port. Reading returns the last written value. | 65 | port. Reading returns the last written value. As it is not possible |
66 | 66 | to read this value from the chip, you need to write at least once to | |
67 | On module initialization the chip is configured as eight inputs (all | 67 | this file before you can read back from it. |
68 | outputs to 1), so you can connect any circuit to the PCF8574(A) without | ||
69 | being 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 */ |
49 | I2C_CLIENT_INSMOD_2(pcf8574, pcf8574a); | 49 | I2C_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 */ |
55 | struct pcf8574_data { | 52 | struct 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 | ||
61 | static int pcf8574_attach_adapter(struct i2c_adapter *adapter); | 58 | static int pcf8574_attach_adapter(struct i2c_adapter *adapter); |
@@ -85,7 +82,11 @@ static DEVICE_ATTR(read, S_IRUGO, show_read, NULL); | |||
85 | static ssize_t show_write(struct device *dev, struct device_attribute *attr, char *buf) | 82 | static 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 | ||
91 | static ssize_t set_write(struct device *dev, struct device_attribute *attr, const char *buf, | 92 | static 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) | |||
206 | static void pcf8574_init_client(struct i2c_client *client) | 207 | static 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 | ||
213 | static int __init pcf8574_init(void) | 213 | static int __init pcf8574_init(void) |