Commit f09513c7 authored by Jean Delvare's avatar Jean Delvare Committed by Greg Kroah-Hartman

[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).
parent 5e044de4
...@@ -345,7 +345,6 @@ static int gl518_detect(struct i2c_adapter *adapter, int address, int kind) ...@@ -345,7 +345,6 @@ static int gl518_detect(struct i2c_adapter *adapter, int address, int kind)
struct i2c_client *new_client; struct i2c_client *new_client;
struct gl518_data *data; struct gl518_data *data;
int err = 0; int err = 0;
const char *name = "";
if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA |
I2C_FUNC_SMBUS_WORD_DATA)) I2C_FUNC_SMBUS_WORD_DATA))
...@@ -385,10 +384,8 @@ static int gl518_detect(struct i2c_adapter *adapter, int address, int kind) ...@@ -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); i = gl518_read_value(new_client, GL518_REG_REVISION);
if (i == 0x00) { if (i == 0x00) {
kind = gl518sm_r00; kind = gl518sm_r00;
name = "gl518sm";
} else if (i == 0x80) { } else if (i == 0x80) {
kind = gl518sm_r80; kind = gl518sm_r80;
name = "gl518sm";
} else { } else {
if (kind <= 0) if (kind <= 0)
dev_info(&adapter->dev, dev_info(&adapter->dev,
...@@ -400,7 +397,7 @@ static int gl518_detect(struct i2c_adapter *adapter, int address, int kind) ...@@ -400,7 +397,7 @@ static int gl518_detect(struct i2c_adapter *adapter, int address, int kind)
} }
/* Fill in the remaining client fields */ /* 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++; new_client->id = gl518_id++;
data->type = kind; data->type = kind;
data->valid = 0; data->valid = 0;
......
...@@ -284,7 +284,6 @@ static int lm83_detect(struct i2c_adapter *adapter, int address, int kind) ...@@ -284,7 +284,6 @@ static int lm83_detect(struct i2c_adapter *adapter, int address, int kind)
if (man_id == 0x01) { /* National Semiconductor */ if (man_id == 0x01) { /* National Semiconductor */
if (chip_id == 0x03) { if (chip_id == 0x03) {
kind = lm83; kind = lm83;
name = "lm83";
} }
} }
...@@ -296,6 +295,10 @@ static int lm83_detect(struct i2c_adapter *adapter, int address, int kind) ...@@ -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 */ /* We can fill in the remaining client fields */
strlcpy(new_client->name, name, I2C_NAME_SIZE); strlcpy(new_client->name, name, I2C_NAME_SIZE);
new_client->id = lm83_id++; new_client->id = lm83_id++;
......
...@@ -337,7 +337,6 @@ static int lm90_detect(struct i2c_adapter *adapter, int address, int kind) ...@@ -337,7 +337,6 @@ static int lm90_detect(struct i2c_adapter *adapter, int address, int kind)
LM90_REG_R_CONFIG2) & 0xF8) == 0x00 LM90_REG_R_CONFIG2) & 0xF8) == 0x00
&& reg_convrate <= 0x09))) { && reg_convrate <= 0x09))) {
kind = lm90; kind = lm90;
name = "lm90";
} }
} }
else if (man_id == 0x41) { /* Analog Devices */ else if (man_id == 0x41) { /* Analog Devices */
...@@ -345,7 +344,6 @@ static int lm90_detect(struct i2c_adapter *adapter, int address, int kind) ...@@ -345,7 +344,6 @@ static int lm90_detect(struct i2c_adapter *adapter, int address, int kind)
&& (kind == 0 /* skip detection */ && (kind == 0 /* skip detection */
|| (reg_config1 & 0x3F) == 0x00)) { || (reg_config1 & 0x3F) == 0x00)) {
kind = adm1032; kind = adm1032;
name = "adm1032";
} }
} }
...@@ -357,6 +355,12 @@ static int lm90_detect(struct i2c_adapter *adapter, int address, int kind) ...@@ -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 */ /* We can fill in the remaining client fields */
strlcpy(new_client->name, name, I2C_NAME_SIZE); strlcpy(new_client->name, name, I2C_NAME_SIZE);
new_client->id = lm90_id++; new_client->id = lm90_id++;
......
...@@ -159,7 +159,6 @@ static int w83l785ts_detect(struct i2c_adapter *adapter, int address, int kind) ...@@ -159,7 +159,6 @@ static int w83l785ts_detect(struct i2c_adapter *adapter, int address, int kind)
struct i2c_client *new_client; struct i2c_client *new_client;
struct w83l785ts_data *data; struct w83l785ts_data *data;
int err = 0; int err = 0;
const char *name = "";
if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 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) ...@@ -220,7 +219,6 @@ static int w83l785ts_detect(struct i2c_adapter *adapter, int address, int kind)
if (man_id == 0x5CA3) { /* Winbond */ if (man_id == 0x5CA3) { /* Winbond */
if (chip_id == 0x70) { /* W83L785TS-S */ if (chip_id == 0x70) { /* W83L785TS-S */
kind = w83l785ts; kind = w83l785ts;
name = "w83l785ts";
} }
} }
...@@ -233,7 +231,7 @@ static int w83l785ts_detect(struct i2c_adapter *adapter, int address, int kind) ...@@ -233,7 +231,7 @@ static int w83l785ts_detect(struct i2c_adapter *adapter, int address, int kind)
} }
/* We can fill in the remaining client fields. */ /* 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++; new_client->id = w83l785ts_id++;
data->valid = 0; data->valid = 0;
init_MUTEX(&data->update_lock); init_MUTEX(&data->update_lock);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment