X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=drivers%2Fi2c%2Fchips%2Fpcf8574.c;h=e5b31329b56e146e1022be115c0d7e0cbdc88ede;hb=61a517a063abf659cbf61df11f8e2131fdafccec;hp=32b25427eaba6e54ecc0a6674ab60a0a18f2c297;hpb=3b9f6cb8a1ec791be79c6c7595fea922f12d1e64;p=linux-2.6 diff --git a/drivers/i2c/chips/pcf8574.c b/drivers/i2c/chips/pcf8574.c index 32b25427ea..e5b31329b5 100644 --- a/drivers/i2c/chips/pcf8574.c +++ b/drivers/i2c/chips/pcf8574.c @@ -41,21 +41,20 @@ #include /* Addresses to scan */ -static unsigned short normal_i2c[] = { 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - I2C_CLIENT_END }; +static const unsigned short normal_i2c[] = { + 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, + 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, + I2C_CLIENT_END +}; /* 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); @@ -68,7 +67,6 @@ static struct i2c_driver pcf8574_driver = { .driver = { .name = "pcf8574", }, - .id = I2C_DRIVERID_PCF8574, .attach_adapter = pcf8574_attach_adapter, .detach_client = pcf8574_detach_client, }; @@ -85,7 +83,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, @@ -206,8 +208,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)