From f09513c726e890d0841806d4b96b0a7e64ba1e4d Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Sun, 14 Mar 2004 21:08:29 -0800 Subject: [PATCH] [PATCH] I2C: fix forced i2c chip drivers have no name 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 | 5 +---- drivers/i2c/chips/lm83.c | 5 ++++- drivers/i2c/chips/lm90.c | 8 ++++++-- drivers/i2c/chips/w83l785ts.c | 4 +--- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/drivers/i2c/chips/gl518sm.c b/drivers/i2c/chips/gl518sm.c index c20db2abbb27..224a497f04f4 100644 --- a/drivers/i2c/chips/gl518sm.c +++ b/drivers/i2c/chips/gl518sm.c @@ -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; diff --git a/drivers/i2c/chips/lm83.c b/drivers/i2c/chips/lm83.c index be418e5689aa..f4e7d2723b73 100644 --- a/drivers/i2c/chips/lm83.c +++ b/drivers/i2c/chips/lm83.c @@ -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++; diff --git a/drivers/i2c/chips/lm90.c b/drivers/i2c/chips/lm90.c index c665e58e532a..dd8e98b03413 100644 --- a/drivers/i2c/chips/lm90.c +++ b/drivers/i2c/chips/lm90.c @@ -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++; diff --git a/drivers/i2c/chips/w83l785ts.c b/drivers/i2c/chips/w83l785ts.c index 88fc398eb1e5..ad5bb437f139 100644 --- a/drivers/i2c/chips/w83l785ts.c +++ b/drivers/i2c/chips/w83l785ts.c @@ -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); -- 2.39.5