]> err.no Git - linux-2.6/commitdiff
i2c: Clean up old chip drivers
authorJean Delvare <khali@linux-fr.org>
Mon, 14 Jul 2008 20:38:36 +0000 (22:38 +0200)
committerJean Delvare <khali@mahadeva.delvare>
Mon, 14 Jul 2008 20:38:36 +0000 (22:38 +0200)
Clean up old i2c chip drivers:
* Name the i2c_client "client" instead of "new_client".
* Drop useless initializations to 0.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
drivers/i2c/chips/eeprom.c
drivers/i2c/chips/max6875.c
drivers/i2c/chips/pca9539.c
drivers/i2c/chips/pcf8574.c
drivers/i2c/chips/pcf8591.c

index e22ec3b3aedf9f2f2e6adf98d2896b838ddaa58f..373ea8d8fe8f0dd7af8c2cbe343c41a48741f2d3 100644 (file)
@@ -158,7 +158,7 @@ static int eeprom_attach_adapter(struct i2c_adapter *adapter)
 /* This function is called by i2c_probe */
 static int eeprom_detect(struct i2c_adapter *adapter, int address, int kind)
 {
-       struct i2c_client *new_client;
+       struct i2c_client *client;
        struct eeprom_data *data;
        int err = 0;
 
@@ -184,22 +184,20 @@ static int eeprom_detect(struct i2c_adapter *adapter, int address, int kind)
                goto exit;
        }
 
-       new_client = &data->client;
+       client = &data->client;
        memset(data->data, 0xff, EEPROM_SIZE);
-       i2c_set_clientdata(new_client, data);
-       new_client->addr = address;
-       new_client->adapter = adapter;
-       new_client->driver = &eeprom_driver;
-       new_client->flags = 0;
+       i2c_set_clientdata(client, data);
+       client->addr = address;
+       client->adapter = adapter;
+       client->driver = &eeprom_driver;
 
        /* Fill in the remaining client fields */
-       strlcpy(new_client->name, "eeprom", I2C_NAME_SIZE);
-       data->valid = 0;
+       strlcpy(client->name, "eeprom", I2C_NAME_SIZE);
        mutex_init(&data->update_lock);
        data->nature = UNKNOWN;
 
        /* Tell the I2C layer a new client has arrived */
-       if ((err = i2c_attach_client(new_client)))
+       if ((err = i2c_attach_client(client)))
                goto exit_kfree;
 
        /* Detect the Vaio nature of EEPROMs.
@@ -208,27 +206,27 @@ static int eeprom_detect(struct i2c_adapter *adapter, int address, int kind)
         && i2c_check_functionality(adapter, I2C_FUNC_SMBUS_READ_BYTE_DATA)) {
                char name[4];
 
-               name[0] = i2c_smbus_read_byte_data(new_client, 0x80);
-               name[1] = i2c_smbus_read_byte_data(new_client, 0x81);
-               name[2] = i2c_smbus_read_byte_data(new_client, 0x82);
-               name[3] = i2c_smbus_read_byte_data(new_client, 0x83);
+               name[0] = i2c_smbus_read_byte_data(client, 0x80);
+               name[1] = i2c_smbus_read_byte_data(client, 0x81);
+               name[2] = i2c_smbus_read_byte_data(client, 0x82);
+               name[3] = i2c_smbus_read_byte_data(client, 0x83);
 
                if (!memcmp(name, "PCG-", 4) || !memcmp(name, "VGN-", 4)) {
-                       dev_info(&new_client->dev, "Vaio EEPROM detected, "
+                       dev_info(&client->dev, "Vaio EEPROM detected, "
                                 "enabling privacy protection\n");
                        data->nature = VAIO;
                }
        }
 
        /* create the sysfs eeprom file */
-       err = sysfs_create_bin_file(&new_client->dev.kobj, &eeprom_attr);
+       err = sysfs_create_bin_file(&client->dev.kobj, &eeprom_attr);
        if (err)
                goto exit_detach;
 
        return 0;
 
 exit_detach:
-       i2c_detach_client(new_client);
+       i2c_detach_client(client);
 exit_kfree:
        kfree(data);
 exit:
index cf507b3f60f3567888bc4c964767744652bec99d..5a0285d8b6f9888f9477d4a1a7284f0dd5a7bee6 100644 (file)
@@ -170,7 +170,7 @@ static int max6875_detect(struct i2c_adapter *adapter, int address, int kind)
        struct i2c_client *real_client;
        struct i2c_client *fake_client;
        struct max6875_data *data;
-       int err = 0;
+       int err;
 
        if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WRITE_BYTE_DATA
                                     | I2C_FUNC_SMBUS_READ_BYTE))
@@ -195,7 +195,6 @@ static int max6875_detect(struct i2c_adapter *adapter, int address, int kind)
        real_client->addr = address;
        real_client->adapter = adapter;
        real_client->driver = &max6875_driver;
-       real_client->flags = 0;
        strlcpy(real_client->name, "max6875", I2C_NAME_SIZE);
        mutex_init(&data->update_lock);
 
@@ -204,7 +203,6 @@ static int max6875_detect(struct i2c_adapter *adapter, int address, int kind)
        fake_client->addr = address | 1;
        fake_client->adapter = adapter;
        fake_client->driver = &max6875_driver;
-       fake_client->flags = 0;
        strlcpy(fake_client->name, "max6875 subclient", I2C_NAME_SIZE);
 
        if ((err = i2c_attach_client(real_client)) != 0)
index f43c4e79b55e9b3cf9bf0bba1317a0196aadddea..58ab7f26be26d1327f17c10a709e2c5ccd3da74f 100644 (file)
@@ -113,7 +113,7 @@ static int pca9539_attach_adapter(struct i2c_adapter *adapter)
 /* This function is called by i2c_probe */
 static int pca9539_detect(struct i2c_adapter *adapter, int address, int kind)
 {
-       struct i2c_client *new_client;
+       struct i2c_client *client;
        struct pca9539_data *data;
        int err = 0;
 
@@ -127,29 +127,28 @@ static int pca9539_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 = &pca9539_driver;
-       new_client->flags = 0;
+       client = &data->client;
+       i2c_set_clientdata(client, data);
+       client->addr = address;
+       client->adapter = adapter;
+       client->driver = &pca9539_driver;
 
        if (kind < 0) {
                /* Detection: the pca9539 only has 8 registers (0-7).
                   A read of 7 should succeed, but a read of 8 should fail. */
-               if ((i2c_smbus_read_byte_data(new_client, 7) < 0) ||
-                   (i2c_smbus_read_byte_data(new_client, 8) >= 0))
+               if ((i2c_smbus_read_byte_data(client, 7) < 0) ||
+                   (i2c_smbus_read_byte_data(client, 8) >= 0))
                        goto exit_kfree;
        }
 
-       strlcpy(new_client->name, "pca9539", I2C_NAME_SIZE);
+       strlcpy(client->name, "pca9539", 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_kfree;
 
        /* Register sysfs hooks */
-       err = sysfs_create_group(&new_client->dev.kobj,
+       err = sysfs_create_group(&client->dev.kobj,
                                 &pca9539_defattr_group);
        if (err)
                goto exit_detach;
@@ -157,7 +156,7 @@ static int pca9539_detect(struct i2c_adapter *adapter, int address, int kind)
        return 0;
 
 exit_detach:
-       i2c_detach_client(new_client);
+       i2c_detach_client(client);
 exit_kfree:
        kfree(data);
 exit:
index ad2f7901a8c96a154496af66d6136cfabc3eac92..1b3db2b3ada9506d2a108f499753ba933d33be00 100644 (file)
@@ -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:
index d3a24524817a51820cbcd1be13feaa0ebc7216de..db735379f22fe512dfdc58402f8891d02bfbca69 100644 (file)
@@ -188,7 +188,7 @@ static int pcf8591_attach_adapter(struct i2c_adapter *adapter)
 /* This function is called by i2c_probe */
 static int pcf8591_detect(struct i2c_adapter *adapter, int address, int kind)
 {
-       struct i2c_client *new_client;
+       struct i2c_client *client;
        struct pcf8591_data *data;
        int err = 0;
 
@@ -203,12 +203,11 @@ static int pcf8591_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 = &pcf8591_driver;
-       new_client->flags = 0;
+       client = &data->client;
+       i2c_set_clientdata(client, data);
+       client->addr = address;
+       client->adapter = adapter;
+       client->driver = &pcf8591_driver;
 
        /* Now, we would do the remaining detection. But the PCF8591 is plainly
           impossible to detect! Stupid chip. */
@@ -219,31 +218,31 @@ static int pcf8591_detect(struct i2c_adapter *adapter, int address, int kind)
 
        /* Fill in the remaining client fields and put it into the global 
           list */
-       strlcpy(new_client->name, "pcf8591", I2C_NAME_SIZE);
+       strlcpy(client->name, "pcf8591", I2C_NAME_SIZE);
        mutex_init(&data->update_lock);
 
        /* Tell the I2C layer a new client has arrived */
-       if ((err = i2c_attach_client(new_client)))
+       if ((err = i2c_attach_client(client)))
                goto exit_kfree;
 
        /* Initialize the PCF8591 chip */
-       pcf8591_init_client(new_client);
+       pcf8591_init_client(client);
 
        /* Register sysfs hooks */
-       err = sysfs_create_group(&new_client->dev.kobj, &pcf8591_attr_group);
+       err = sysfs_create_group(&client->dev.kobj, &pcf8591_attr_group);
        if (err)
                goto exit_detach;
 
        /* Register input2 if not in "two differential inputs" mode */
        if (input_mode != 3) {
-               if ((err = device_create_file(&new_client->dev,
+               if ((err = device_create_file(&client->dev,
                                              &dev_attr_in2_input)))
                        goto exit_sysfs_remove;
        }
 
        /* Register input3 only in "four single ended inputs" mode */
        if (input_mode == 0) {
-               if ((err = device_create_file(&new_client->dev,
+               if ((err = device_create_file(&client->dev,
                                              &dev_attr_in3_input)))
                        goto exit_sysfs_remove;
        }
@@ -251,10 +250,10 @@ static int pcf8591_detect(struct i2c_adapter *adapter, int address, int kind)
        return 0;
 
 exit_sysfs_remove:
-       sysfs_remove_group(&new_client->dev.kobj, &pcf8591_attr_group_opt);
-       sysfs_remove_group(&new_client->dev.kobj, &pcf8591_attr_group);
+       sysfs_remove_group(&client->dev.kobj, &pcf8591_attr_group_opt);
+       sysfs_remove_group(&client->dev.kobj, &pcf8591_attr_group);
 exit_detach:
-       i2c_detach_client(new_client);
+       i2c_detach_client(client);
 exit_kfree:
        kfree(data);
 exit: