Skip to contentSkip to conversation

Forced i2c chip drivers have no name

PATCH New Jean Delvare 2 participants 3 messages May 19, 2005

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Forced i2c chip drivers have no name

Hi Greg,

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).

Please apply (on top of your current tree),
Thanks.

drivers/i2c/chips/gl518sm.c renamed from drivers/i2c/chips.orig/gl518sm.c +1 -4
diff -ruN linux-2.6.4+i2c/drivers/i2c/chips.orig/gl518sm.c linux-2.6.4+i2c/drivers/i2c/chips/gl518sm.c
@@ -349,7 +349,6 @@
 	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))
@@ -389,10 +388,8 @@
 		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,
@@ -404,7 +401,7 @@
 	}
 
 	/* 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;
drivers/i2c/chips/lm83.c renamed from drivers/i2c/chips.orig/lm83.c +4 -1
diff -ruN linux-2.6.4+i2c/drivers/i2c/chips.orig/lm83.c linux-2.6.4+i2c/drivers/i2c/chips/lm83.c
@@ -288,7 +288,6 @@
 		if (man_id = 0x01) { /* National Semiconductor */
 			if (chip_id = 0x03) {
 				kind = lm83;
-				name = "lm83";
 			}
 		}
 
@@ -298,6 +297,10 @@
 			    "chip_id=0x%02X).\n", man_id, chip_id);
 			goto exit_free;
 		}
+	}
+
+	if (kind = lm83) {
+		name = "lm83";
 	}
 
 	/* We can fill in the remaining client fields */
drivers/i2c/chips/lm90.c renamed from drivers/i2c/chips.orig/lm90.c +6 -2
diff -ruN linux-2.6.4+i2c/drivers/i2c/chips.orig/lm90.c linux-2.6.4+i2c/drivers/i2c/chips/lm90.c
@@ -341,7 +341,6 @@
 				LM90_REG_R_CONFIG2) & 0xF8) = 0x00
 			   && reg_convrate <= 0x09))) {
 				kind = lm90;
-				name = "lm90";
 			}
 		}
 		else if (man_id = 0x41) { /* Analog Devices */
@@ -349,7 +348,6 @@
 			 && (kind = 0 /* skip detection */
 			  || (reg_config1 & 0x3F) = 0x00)) {
 				kind = adm1032;
-				name = "adm1032";
 			}
 		}
 
@@ -359,6 +357,12 @@
 			    "chip_id=0x%02X).\n", man_id, chip_id);
 			goto exit_free;
 		}
+	}
+
+	if (kind = lm90) {
+		name = "lm90";
+	} else if (kind = adm1032) {
+		name = "adm1032";
 	}
 
 	/* We can fill in the remaining client fields */
drivers/i2c/chips/w83l785ts.c renamed from drivers/i2c/chips.orig/w83l785ts.c +1 -3
diff -ruN linux-2.6.4+i2c/drivers/i2c/chips.orig/w83l785ts.c linux-2.6.4+i2c/drivers/i2c/chips/w83l785ts.c
@@ -163,7 +163,6 @@
 	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))
@@ -224,7 +223,6 @@
 		if (man_id = 0x5CA3) { /* Winbond */
 			if (chip_id = 0x70) { /* W83L785TS-S */
 				kind = w83l785ts;			
-				name = "w83l785ts";
 			}
 		}
 	
@@ -237,7 +235,7 @@
 	}
 
 	/* 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);
Signature · 2 lines
Jean Delvare
http://www.ensicaen.ismra.fr/~delvare/
Applied
#1 lore raw

PATCH 1/1 Forced i2c chip drivers have no name

Quoted 6 lines · Jean Delvare

Hi Greg,

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).

Nice catch.

Quoted 5 lines

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.

Quoted 7 lines

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).

Please apply (on top of your current tree),

Applied, thanks.

greg k-h

#2 lore raw

PATCH 1/1 Forced i2c chip drivers have no name

In reply to Jean Delvare
Quoted 6 lines
Quoted 4 lines

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).

Nice catch.

You probably meant "shame on you" ;) I actually thought I was smarter that other chip driver authors and tried doing things differently... Turned out to be a bad idea.

I'm lucky that the missed path wasn't leading to anything critical.

Signature · 2 lines
Jean Delvare
http://www.ensicaen.ismra.fr/~delvare/