]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/blobdiff - drivers/i2c/chips/pcf8574.c
Merge branch 'linus' into core/softlockup
[mirror_ubuntu-hirsute-kernel.git] / drivers / i2c / chips / pcf8574.c
index 32b25427eaba6e54ecc0a6674ab60a0a18f2c297..1b3db2b3ada9506d2a108f499753ba933d33be00 100644 (file)
@@ -1,6 +1,4 @@
 /*
-    pcf8574.c - Part of lm_sensors, Linux kernel modules for hardware
-             monitoring
     Copyright (c) 2000  Frodo Looijaard <frodol@dds.nl>, 
                         Philip Edelbrock <phil@netroedge.com>,
                         Dan Eaton <dan.eaton@rocketlogix.com>
 #include <linux/i2c.h>
 
 /* 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 +65,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 +81,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,
@@ -127,7 +127,7 @@ static int pcf8574_attach_adapter(struct i2c_adapter *adapter)
 /* This function is called by i2c_probe */
 static int pcf8574_detect(struct i2c_adapter *adapter, int address, int kind)
 {
-       struct i2c_client *new_client;
+       struct i2c_client *client;
        struct pcf8574_data *data;
        int err = 0;
        const char *client_name = "";
@@ -142,12 +142,11 @@ static int pcf8574_detect(struct i2c_adapter *adapter, int address, int kind)
                goto exit;
        }
 
-       new_client = &data->client;
-       i2c_set_clientdata(new_client, data);
-       new_client->addr = address;
-       new_client->adapter = adapter;
-       new_client->driver = &pcf8574_driver;
-       new_client->flags = 0;
+       client = &data->client;
+       i2c_set_clientdata(client, data);
+       client->addr = address;
+       client->adapter = adapter;
+       client->driver = &pcf8574_driver;
 
        /* Now, we would do the remaining detection. But the PCF8574 is plainly
           impossible to detect! Stupid chip. */
@@ -166,23 +165,23 @@ static int pcf8574_detect(struct i2c_adapter *adapter, int address, int kind)
                client_name = "pcf8574";
 
        /* Fill in the remaining client fields and put it into the global list */
-       strlcpy(new_client->name, client_name, I2C_NAME_SIZE);
+       strlcpy(client->name, client_name, I2C_NAME_SIZE);
 
        /* Tell the I2C layer a new client has arrived */
-       if ((err = i2c_attach_client(new_client)))
+       if ((err = i2c_attach_client(client)))
                goto exit_free;
        
        /* Initialize the PCF8574 chip */
-       pcf8574_init_client(new_client);
+       pcf8574_init_client(client);
 
        /* Register sysfs hooks */
-       err = sysfs_create_group(&new_client->dev.kobj, &pcf8574_attr_group);
+       err = sysfs_create_group(&client->dev.kobj, &pcf8574_attr_group);
        if (err)
                goto exit_detach;
        return 0;
 
       exit_detach:
-       i2c_detach_client(new_client);
+       i2c_detach_client(client);
       exit_free:
        kfree(data);
       exit:
@@ -206,8 +205,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)