aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c/chips/pcf8574.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/i2c/chips/pcf8574.c')
-rw-r--r--drivers/i2c/chips/pcf8574.c14
1 files changed, 7 insertions, 7 deletions
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)