]> git.hungrycats.org Git - linux/commitdiff
[PATCH] I2C: fix forced i2c chip drivers have no name
authorJean Delvare <khali@linux-fr.org>
Mon, 15 Mar 2004 05:08:29 +0000 (21:08 -0800)
committerGreg Kroah-Hartman <greg@kroah.com>
Mon, 15 Mar 2004 05:08:29 +0000 (21:08 -0800)
I just noticed that I am doing something wrong in the i2c chip drivers I
ported to Linux 2.6. If these drivers are forced to a specific chip type
("kind" as we call it internally), then the device doesn't have its name
set (and defaults to an empty string).

Affected drivers: gl518sm, lm83, lm90, w83l785ts.

I could verify the problem on my ADM1032 chip (lm90 driver). I also
verified that the proposed patch fixes the issue.

You may notice that I fix the problem differently for gl518sm and
w83l785ts on the one hand, and lm83 and lm90 on the other hand. This is
because the first two drivers are not expected to support more a single
chip in the future, while lm90 already does and lm83 could someday (for
example, support for the LM82 could be added on request).

drivers/i2c/chips/gl518sm.c
drivers/i2c/chips/lm83.c
drivers/i2c/chips/lm90.c
drivers/i2c/chips/w83l785ts.c

index c20db2abbb273877169680f853ec55ee224da002..224a497f04f422accf85947051373b0e9dbe25a6 100644 (file)
@@ -345,7 +345,6 @@ static int gl518_detect(struct i2c_adapter *adapter, int address, int kind)
        struct i2c_client *new_client;
        struct gl518_data *data;
        int err = 0;
-       const char *name = "";
 
        if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA |
                                     I2C_FUNC_SMBUS_WORD_DATA))
@@ -385,10 +384,8 @@ static int gl518_detect(struct i2c_adapter *adapter, int address, int kind)
                i = gl518_read_value(new_client, GL518_REG_REVISION);
                if (i == 0x00) {
                        kind = gl518sm_r00;
-                       name = "gl518sm";
                } else if (i == 0x80) {
                        kind = gl518sm_r80;
-                       name = "gl518sm";
                } else {
                        if (kind <= 0)
                                dev_info(&adapter->dev,
@@ -400,7 +397,7 @@ static int gl518_detect(struct i2c_adapter *adapter, int address, int kind)
        }
 
        /* Fill in the remaining client fields */
-       strlcpy(new_client->name, name, I2C_NAME_SIZE);
+       strlcpy(new_client->name, "gl518sm", I2C_NAME_SIZE);
        new_client->id = gl518_id++;
        data->type = kind;
        data->valid = 0;
index be418e5689aa3ee9801dd9b2cc71a5faf876652c..f4e7d2723b7337e709cf252f30970a7ab2d27999 100644 (file)
@@ -284,7 +284,6 @@ static int lm83_detect(struct i2c_adapter *adapter, int address, int kind)
                if (man_id == 0x01) { /* National Semiconductor */
                        if (chip_id == 0x03) {
                                kind = lm83;
-                               name = "lm83";
                        }
                }
 
@@ -296,6 +295,10 @@ static int lm83_detect(struct i2c_adapter *adapter, int address, int kind)
                }
        }
 
+       if (kind == lm83) {
+               name = "lm83";
+       }
+
        /* We can fill in the remaining client fields */
        strlcpy(new_client->name, name, I2C_NAME_SIZE);
        new_client->id = lm83_id++;
index c665e58e532a3b86d5e5a716c247b01641ac471a..dd8e98b034132bf71acf72b3cfd2217d0f72d095 100644 (file)
@@ -337,7 +337,6 @@ static int lm90_detect(struct i2c_adapter *adapter, int address, int kind)
                                LM90_REG_R_CONFIG2) & 0xF8) == 0x00
                           && reg_convrate <= 0x09))) {
                                kind = lm90;
-                               name = "lm90";
                        }
                }
                else if (man_id == 0x41) { /* Analog Devices */
@@ -345,7 +344,6 @@ static int lm90_detect(struct i2c_adapter *adapter, int address, int kind)
                         && (kind == 0 /* skip detection */
                          || (reg_config1 & 0x3F) == 0x00)) {
                                kind = adm1032;
-                               name = "adm1032";
                        }
                }
 
@@ -357,6 +355,12 @@ static int lm90_detect(struct i2c_adapter *adapter, int address, int kind)
                }
        }
 
+       if (kind == lm90) {
+               name = "lm90";
+       } else if (kind == adm1032) {
+               name = "adm1032";
+       }
+
        /* We can fill in the remaining client fields */
        strlcpy(new_client->name, name, I2C_NAME_SIZE);
        new_client->id = lm90_id++;
index 88fc398eb1e5c049bab674fe85d10e4bb9b0a35e..ad5bb437f13967972e906a8cac140bef59f85465 100644 (file)
@@ -159,7 +159,6 @@ static int w83l785ts_detect(struct i2c_adapter *adapter, int address, int kind)
        struct i2c_client *new_client;
        struct w83l785ts_data *data;
        int err = 0;
-       const char *name = "";
 
 
        if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
@@ -220,7 +219,6 @@ static int w83l785ts_detect(struct i2c_adapter *adapter, int address, int kind)
                if (man_id == 0x5CA3) { /* Winbond */
                        if (chip_id == 0x70) { /* W83L785TS-S */
                                kind = w83l785ts;                       
-                               name = "w83l785ts";
                        }
                }
        
@@ -233,7 +231,7 @@ static int w83l785ts_detect(struct i2c_adapter *adapter, int address, int kind)
        }
 
        /* We can fill in the remaining client fields. */
-       strlcpy(new_client->name, name, I2C_NAME_SIZE);
+       strlcpy(new_client->name, "w83l785ts", I2C_NAME_SIZE);
        new_client->id = w83l785ts_id++;
        data->valid = 0;
        init_MUTEX(&data->update_lock);