linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2.6] I2C: Kill i2c_client.id
@ 2005-01-16 18:46 Jean Delvare
  2005-01-16 19:10 ` [PATCH 2.6] I2C: Kill i2c_client.id (1/5) Jean Delvare
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Jean Delvare @ 2005-01-16 18:46 UTC (permalink / raw)
  To: Greg KH; +Cc: LKML, LM Sensors

Hi Greg,

As discussed earlier on the LKML [1], here comes a patch set killing the
id member of the i2c_client structure. Let me recap my main reasons for
doing so:

1* A client is already uniquely identified by the combination of the
number of the bus it sits on and the address it is located at on this
bus.

2* The i2c core doesn't make use of this struct member. Such an id, if
needed, would thus be private data and as such would belong to the data
member. In fact, none of the drivers using this field really needs it as
far as I could see.

Killing that useless struct member will let us save some memory and kill
some useless code (not much, admittedly).

I will send 5 different patches, to be applied in order, although
nothing critical will happen if applied in a different order. In each
patch, most chucks are themselves independent from each other, so if any
is rejected or delayed for some reason, the rest can still be applied.

(1/5) Stop using i2c_client.id in i2c/chips drivers (mostly hardware
      monitoring drivers).
(2/5) Stop using i2c_client.id in media/video drivers.
(3/5) Stop using i2c_client.id in misc drivers.
(4/5) Deprecate i2c_client.id.
(5/5) Documentation update.

Thanks.

[1] http://lkml.org/lkml/2004/12/27/132

-- 
Jean Delvare
http://khali.linux-fr.org/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 2.6] I2C: Kill i2c_client.id (1/5)
  2005-01-16 18:46 [PATCH 2.6] I2C: Kill i2c_client.id Jean Delvare
@ 2005-01-16 19:10 ` Jean Delvare
  2005-01-16 19:27 ` [PATCH 2.6] I2C: Kill i2c_client.id (2/5) Jean Delvare
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Jean Delvare @ 2005-01-16 19:10 UTC (permalink / raw)
  To: Greg KH; +Cc: LKML, LM Sensors

(1/5) Stop using i2c_client.id in i2c/chips drivers (mostly hardware
      monitoring drivers).

Drivers affected:
* adm1021
* adm1025
* adm1026
* adm1031
* ds1621
* fscher
* gl518sm
* isp1301_omap
* lm75
* lm77
* lm80
* lm83
* lm85
* lm87
* lm90
* max1619
* pcf8574
* pcf8591
* rtc8564
* smsc47m1
* w83l785ts

The vast majority of these drivers simply defined the i2c_client id
struct member but never used it, so they are not affected at all by the
change. Exceptions are:

* lm85 and rtc8564, which would at least display the id in a debug
message when assigning it. Not really useful though, as the id was then
never used.

* adm1026, which used the assigned id in all driver messages. However,
since dev_* calls will append the bus number and client address to these
messages, the id information is redundant and can go away. Also, the
driver would allow some GPIO reprogramming on the first client only
(id=0) and removing the id doesn't allow that anymore. I would restore a
similar functionality if needed, but the ADM1026 chip is found on very
few motherboards and none of these has more than one ADM1026 chip AFAIK,
so it doesn't seem to be worth the effort.

Signed-off-by: Jean Delvare <khali@linux-fr.org>

diff -ruN linux-2.6.11-rc1.orig/drivers/i2c/chips/adm1021.c linux-2.6.11-rc1/drivers/i2c/chips/adm1021.c
--- linux-2.6.11-rc1.orig/drivers/i2c/chips/adm1021.c	2004-12-24 22:33:49.000000000 +0100
+++ linux-2.6.11-rc1/drivers/i2c/chips/adm1021.c	2005-01-16 12:50:29.000000000 +0100
@@ -147,8 +147,6 @@
 	.detach_client	= adm1021_detach_client,
 };
 
-static int adm1021_id;
-
 #define show(value)	\
 static ssize_t show_##value(struct device *dev, char *buf)		\
 {									\
@@ -299,8 +297,6 @@
 	/* Fill in the remaining client fields and put it into the global list */
 	strlcpy(new_client->name, type_name, I2C_NAME_SIZE);
 	data->type = kind;
-
-	new_client->id = adm1021_id++;
 	data->valid = 0;
 	init_MUTEX(&data->update_lock);
 
diff -ruN linux-2.6.11-rc1.orig/drivers/i2c/chips/adm1025.c linux-2.6.11-rc1/drivers/i2c/chips/adm1025.c
--- linux-2.6.11-rc1.orig/drivers/i2c/chips/adm1025.c	2004-12-24 22:33:47.000000000 +0100
+++ linux-2.6.11-rc1/drivers/i2c/chips/adm1025.c	2005-01-16 12:50:29.000000000 +0100
@@ -148,12 +148,6 @@
 };
 
 /*
- * Internal variables
- */
-
-static int adm1025_id;
-
-/*
  * Sysfs stuff
  */
 
@@ -397,7 +391,6 @@
 
 	/* We can fill in the remaining client fields */
 	strlcpy(new_client->name, name, I2C_NAME_SIZE);
-	new_client->id = adm1025_id++;
 	data->valid = 0;
 	init_MUTEX(&data->update_lock);
 
diff -ruN linux-2.6.11-rc1.orig/drivers/i2c/chips/adm1026.c linux-2.6.11-rc1/drivers/i2c/chips/adm1026.c
--- linux-2.6.11-rc1.orig/drivers/i2c/chips/adm1026.c	2005-01-14 18:37:07.000000000 +0100
+++ linux-2.6.11-rc1/drivers/i2c/chips/adm1026.c	2005-01-16 12:52:45.000000000 +0100
@@ -313,8 +313,6 @@
 	.detach_client  = adm1026_detach_client,
 };
 
-static int adm1026_id;
-
 int adm1026_attach_adapter(struct i2c_adapter *adapter)
 {
 	if (!(adapter->class & I2C_CLASS_HWMON)) {
@@ -363,49 +361,47 @@
 	int value, i;
 	struct adm1026_data *data = i2c_get_clientdata(client);
 
-        dev_dbg(&client->dev,"(%d): Initializing device\n", client->id);
+        dev_dbg(&client->dev, "Initializing device\n");
 	/* Read chip config */
 	data->config1 = adm1026_read_value(client, ADM1026_REG_CONFIG1);
 	data->config2 = adm1026_read_value(client, ADM1026_REG_CONFIG2);
 	data->config3 = adm1026_read_value(client, ADM1026_REG_CONFIG3);
 
 	/* Inform user of chip config */
-	dev_dbg(&client->dev, "(%d): ADM1026_REG_CONFIG1 is: 0x%02x\n",
-		client->id, data->config1);
+	dev_dbg(&client->dev, "ADM1026_REG_CONFIG1 is: 0x%02x\n",
+		data->config1);
 	if ((data->config1 & CFG1_MONITOR) == 0) {
-		dev_dbg(&client->dev, "(%d): Monitoring not currently "
-			"enabled.\n", client->id);
+		dev_dbg(&client->dev, "Monitoring not currently "
+			"enabled.\n");
 	}
 	if (data->config1 & CFG1_INT_ENABLE) {
-		dev_dbg(&client->dev, "(%d): SMBALERT interrupts are "
-			"enabled.\n", client->id);
+		dev_dbg(&client->dev, "SMBALERT interrupts are "
+			"enabled.\n");
 	}
 	if (data->config1 & CFG1_AIN8_9) {
-		dev_dbg(&client->dev, "(%d): in8 and in9 enabled. "
-			"temp3 disabled.\n", client->id);
+		dev_dbg(&client->dev, "in8 and in9 enabled. "
+			"temp3 disabled.\n");
 	} else {
-		dev_dbg(&client->dev, "(%d): temp3 enabled.  in8 and "
-			"in9 disabled.\n", client->id);
+		dev_dbg(&client->dev, "temp3 enabled.  in8 and "
+			"in9 disabled.\n");
 	}
 	if (data->config1 & CFG1_THERM_HOT) {
-		dev_dbg(&client->dev, "(%d): Automatic THERM, PWM, "
-			"and temp limits enabled.\n", client->id);
+		dev_dbg(&client->dev, "Automatic THERM, PWM, "
+			"and temp limits enabled.\n");
 	}
 
 	value = data->config3;
 	if (data->config3 & CFG3_GPIO16_ENABLE) {
-		dev_dbg(&client->dev, "(%d): GPIO16 enabled.  THERM"
-			"pin disabled.\n", client->id);
+		dev_dbg(&client->dev, "GPIO16 enabled.  THERM"
+			"pin disabled.\n");
 	} else {
-		dev_dbg(&client->dev, "(%d): THERM pin enabled.  "
-			"GPIO16 disabled.\n", client->id);
+		dev_dbg(&client->dev, "THERM pin enabled.  "
+			"GPIO16 disabled.\n");
 	}
 	if (data->config3 & CFG3_VREF_250) {
-		dev_dbg(&client->dev, "(%d): Vref is 2.50 Volts.\n",
-			client->id);
+		dev_dbg(&client->dev, "Vref is 2.50 Volts.\n");
 	} else {
-		dev_dbg(&client->dev, "(%d): Vref is 1.82 Volts.\n",
-			client->id);
+		dev_dbg(&client->dev, "Vref is 1.82 Volts.\n");
 	}
 	/* Read and pick apart the existing GPIO configuration */
 	value = 0;
@@ -423,12 +419,11 @@
 	adm1026_print_gpio(client);
 
 	/* If the user asks us to reprogram the GPIO config, then
-	 *   do it now.  But only if this is the first ADM1026.
+	 * do it now.
 	 */
-	if (client->id == 0
-	    && (gpio_input[0] != -1 || gpio_output[0] != -1
+	if (gpio_input[0] != -1 || gpio_output[0] != -1
 		|| gpio_inverted[0] != -1 || gpio_normal[0] != -1
-		|| gpio_fan[0] != -1)) {
+		|| gpio_fan[0] != -1) {
 		adm1026_fixup_gpio(client);
 	}
 
@@ -448,8 +443,7 @@
 	value = adm1026_read_value(client, ADM1026_REG_CONFIG1);
 	/* Set MONITOR, clear interrupt acknowledge and s/w reset */
 	value = (value | CFG1_MONITOR) & (~CFG1_INT_CLEAR & ~CFG1_RESET);
-	dev_dbg(&client->dev, "(%d): Setting CONFIG to: 0x%02x\n",
-		client->id, value);
+	dev_dbg(&client->dev, "Setting CONFIG to: 0x%02x\n", value);
 	data->config1 = value;
 	adm1026_write_value(client, ADM1026_REG_CONFIG1, value);
 
@@ -467,31 +461,30 @@
 	struct adm1026_data *data = i2c_get_clientdata(client);
 	int  i;
 
-	dev_dbg(&client->dev, "(%d): GPIO config is:", client->id);
+	dev_dbg(&client->dev, "GPIO config is:");
 	for (i = 0;i <= 7;++i) {
 		if (data->config2 & (1 << i)) {
-			dev_dbg(&client->dev, "\t(%d): %sGP%s%d\n", client->id,
+			dev_dbg(&client->dev, "\t%sGP%s%d\n",
 				data->gpio_config[i] & 0x02 ? "" : "!",
 				data->gpio_config[i] & 0x01 ? "OUT" : "IN",
 				i);
 		} else {
-			dev_dbg(&client->dev, "\t(%d): FAN%d\n",
-				client->id, i);
+			dev_dbg(&client->dev, "\tFAN%d\n", i);
 		}
 	}
 	for (i = 8;i <= 15;++i) {
-		dev_dbg(&client->dev, "\t(%d): %sGP%s%d\n", client->id,
+		dev_dbg(&client->dev, "\t%sGP%s%d\n",
 			data->gpio_config[i] & 0x02 ? "" : "!",
 			data->gpio_config[i] & 0x01 ? "OUT" : "IN",
 			i);
 	}
 	if (data->config3 & CFG3_GPIO16_ENABLE) {
-		dev_dbg(&client->dev, "\t(%d): %sGP%s16\n", client->id,
+		dev_dbg(&client->dev, "\t%sGP%s16\n",
 			data->gpio_config[16] & 0x02 ? "" : "!",
 			data->gpio_config[16] & 0x01 ? "OUT" : "IN");
 	} else {
 		/* GPIO16 is THERM  */
-		dev_dbg(&client->dev, "\t(%d): THERM\n", client->id);
+		dev_dbg(&client->dev, "\tTHERM\n");
 	}
 }
 
@@ -582,8 +575,7 @@
 	if (!data->valid
 	    || (jiffies - data->last_reading > ADM1026_DATA_INTERVAL)) {
 		/* Things that change quickly */
-		dev_dbg(&client->dev,"(%d): Reading sensor values\n", 
-			client->id);
+		dev_dbg(&client->dev,"Reading sensor values\n");
 		for (i = 0;i <= 16;++i) {
 			data->in[i] =
 			    adm1026_read_value(client, ADM1026_REG_IN[i]);
@@ -631,8 +623,7 @@
 	if (!data->valid || (jiffies - data->last_config > 
 		ADM1026_CONFIG_INTERVAL)) {
 		/* Things that don't change often */
-		dev_dbg(&client->dev, "(%d): Reading config values\n", 
-			client->id);
+		dev_dbg(&client->dev, "Reading config values\n");
 		for (i = 0;i <= 16;++i) {
 			data->in_min[i] = adm1026_read_value(client, 
 				ADM1026_REG_IN_MIN[i]);
@@ -712,8 +703,7 @@
 		data->last_config = jiffies;
 	};  /* last_config */
 
-	dev_dbg(&client->dev, "(%d): Setting VID from GPIO11-15.\n", 
-		client->id);
+	dev_dbg(&client->dev, "Setting VID from GPIO11-15.\n");
 	data->vid = (data->gpio >> 11) & 0x1f;
 	data->valid = 1;
 	up(&data->update_lock);
@@ -1608,16 +1598,10 @@
 	strlcpy(new_client->name, type_name, I2C_NAME_SIZE);
 
 	/* Fill in the remaining client fields */
-	new_client->id = adm1026_id++;
 	data->type = kind;
 	data->valid = 0;
 	init_MUTEX(&data->update_lock);
 
-	dev_dbg(&new_client->dev, "(%d): Assigning ID %d to %s at %d,0x%02x\n",
-		new_client->id, new_client->id, new_client->name,
-		i2c_adapter_id(new_client->adapter),
-		new_client->addr);
-
 	/* Tell the I2C layer a new client has arrived */
 	if ((err = i2c_attach_client(new_client)))
 		goto exitfree;
diff -ruN linux-2.6.11-rc1.orig/drivers/i2c/chips/adm1031.c linux-2.6.11-rc1/drivers/i2c/chips/adm1031.c
--- linux-2.6.11-rc1.orig/drivers/i2c/chips/adm1031.c	2004-12-24 22:34:32.000000000 +0100
+++ linux-2.6.11-rc1/drivers/i2c/chips/adm1031.c	2005-01-16 12:50:29.000000000 +0100
@@ -110,8 +110,6 @@
 	.detach_client = adm1031_detach_client,
 };
 
-static int adm1031_id;
-
 static inline u8 adm1031_read_value(struct i2c_client *client, u8 reg)
 {
 	return i2c_smbus_read_byte_data(client, reg);
@@ -781,8 +779,6 @@
 	data->chip_type = kind;
 
 	strlcpy(new_client->name, name, I2C_NAME_SIZE);
-
-	new_client->id = adm1031_id++;
 	data->valid = 0;
 	init_MUTEX(&data->update_lock);
 
diff -ruN linux-2.6.11-rc1.orig/drivers/i2c/chips/ds1621.c linux-2.6.11-rc1/drivers/i2c/chips/ds1621.c
--- linux-2.6.11-rc1.orig/drivers/i2c/chips/ds1621.c	2004-12-24 22:35:40.000000000 +0100
+++ linux-2.6.11-rc1/drivers/i2c/chips/ds1621.c	2005-01-16 12:50:29.000000000 +0100
@@ -95,8 +95,6 @@
 	.detach_client	= ds1621_detach_client,
 };
 
-static int ds1621_id;
-
 /* All registers are word-sized, except for the configuration register.
    DS1621 uses a high-byte first convention, which is exactly opposite to
    the usual practice. */
@@ -232,8 +230,6 @@
 
 	/* Fill in remaining client fields and put it into the global list */
 	strlcpy(new_client->name, "ds1621", I2C_NAME_SIZE);
-
-	new_client->id = ds1621_id++;
 	data->valid = 0;
 	init_MUTEX(&data->update_lock);
 
diff -ruN linux-2.6.11-rc1.orig/drivers/i2c/chips/fscher.c linux-2.6.11-rc1/drivers/i2c/chips/fscher.c
--- linux-2.6.11-rc1.orig/drivers/i2c/chips/fscher.c	2005-01-14 18:36:52.000000000 +0100
+++ linux-2.6.11-rc1/drivers/i2c/chips/fscher.c	2005-01-16 12:50:29.000000000 +0100
@@ -151,12 +151,6 @@
 };
 
 /*
- * Internal variables
- */
-
-static int fscher_id;
-
-/*
  * Sysfs stuff
  */
 
@@ -337,7 +331,6 @@
 	/* Fill in the remaining client fields and put it into the
 	 * global list */
 	strlcpy(new_client->name, "fscher", I2C_NAME_SIZE);
-	new_client->id = fscher_id++;
 	data->valid = 0;
 	init_MUTEX(&data->update_lock);
 
diff -ruN linux-2.6.11-rc1.orig/drivers/i2c/chips/gl518sm.c linux-2.6.11-rc1/drivers/i2c/chips/gl518sm.c
--- linux-2.6.11-rc1.orig/drivers/i2c/chips/gl518sm.c	2004-12-24 22:35:39.000000000 +0100
+++ linux-2.6.11-rc1/drivers/i2c/chips/gl518sm.c	2005-01-16 12:50:29.000000000 +0100
@@ -159,12 +159,6 @@
 };
 
 /*
- * Internal variables
- */
-
-static int gl518_id;
-
-/*
  * Sysfs stuff
  */
 
@@ -396,7 +390,6 @@
 
 	/* Fill in the remaining client fields */
 	strlcpy(new_client->name, "gl518sm", I2C_NAME_SIZE);
-	new_client->id = gl518_id++;
 	data->type = kind;
 	data->valid = 0;
 	init_MUTEX(&data->update_lock);
diff -ruN linux-2.6.11-rc1.orig/drivers/i2c/chips/isp1301_omap.c linux-2.6.11-rc1/drivers/i2c/chips/isp1301_omap.c
--- linux-2.6.11-rc1.orig/drivers/i2c/chips/isp1301_omap.c	2005-01-14 18:36:52.000000000 +0100
+++ linux-2.6.11-rc1/drivers/i2c/chips/isp1301_omap.c	2005-01-16 12:50:29.000000000 +0100
@@ -1503,7 +1503,6 @@
 	isp->client.addr = address;
 	i2c_set_clientdata(&isp->client, isp);
 	isp->client.adapter = bus;
-	isp->client.id = 1301;
 	isp->client.driver = &isp1301_driver;
 	strlcpy(isp->client.name, DRIVER_NAME, I2C_NAME_SIZE);
 	i2c = &isp->client;
diff -ruN linux-2.6.11-rc1.orig/drivers/i2c/chips/lm75.c linux-2.6.11-rc1/drivers/i2c/chips/lm75.c
--- linux-2.6.11-rc1.orig/drivers/i2c/chips/lm75.c	2004-12-24 22:33:48.000000000 +0100
+++ linux-2.6.11-rc1/drivers/i2c/chips/lm75.c	2005-01-16 12:50:29.000000000 +0100
@@ -73,8 +73,6 @@
 	.detach_client	= lm75_detach_client,
 };
 
-static int lm75_id;
-
 #define show(value)	\
 static ssize_t show_##value(struct device *dev, char *buf)		\
 {									\
@@ -196,8 +194,6 @@
 
 	/* Fill in the remaining client fields and put it into the global list */
 	strlcpy(new_client->name, name, I2C_NAME_SIZE);
-
-	new_client->id = lm75_id++;
 	data->valid = 0;
 	init_MUTEX(&data->update_lock);
 
diff -ruN linux-2.6.11-rc1.orig/drivers/i2c/chips/lm77.c linux-2.6.11-rc1/drivers/i2c/chips/lm77.c
--- linux-2.6.11-rc1.orig/drivers/i2c/chips/lm77.c	2004-12-24 22:36:00.000000000 +0100
+++ linux-2.6.11-rc1/drivers/i2c/chips/lm77.c	2005-01-16 12:50:29.000000000 +0100
@@ -81,8 +81,6 @@
 	.detach_client	= lm77_detach_client,
 };
 
-static int lm77_id;
-
 /* straight from the datasheet */
 #define LM77_TEMP_MIN (-55000)
 #define LM77_TEMP_MAX 125000
@@ -295,8 +293,6 @@
 
 	/* Fill in the remaining client fields and put it into the global list */
 	strlcpy(new_client->name, name, I2C_NAME_SIZE);
-
-	new_client->id = lm77_id++;
 	data->valid = 0;
 	init_MUTEX(&data->update_lock);
 
diff -ruN linux-2.6.11-rc1.orig/drivers/i2c/chips/lm80.c linux-2.6.11-rc1/drivers/i2c/chips/lm80.c
--- linux-2.6.11-rc1.orig/drivers/i2c/chips/lm80.c	2004-12-24 22:33:52.000000000 +0100
+++ linux-2.6.11-rc1/drivers/i2c/chips/lm80.c	2005-01-16 12:50:29.000000000 +0100
@@ -141,12 +141,6 @@
 static int lm80_write_value(struct i2c_client *client, u8 reg, u8 value);
 
 /*
- * Internal variables
- */
-
-static int lm80_id;
-
-/*
  * Driver data (common to all clients)
  */
 
@@ -425,8 +419,6 @@
 
 	/* Fill in the remaining client fields and put it into the global list */
 	strlcpy(new_client->name, name, I2C_NAME_SIZE);
-
-	new_client->id = lm80_id++;
 	data->valid = 0;
 	init_MUTEX(&data->update_lock);
 
diff -ruN linux-2.6.11-rc1.orig/drivers/i2c/chips/lm83.c linux-2.6.11-rc1/drivers/i2c/chips/lm83.c
--- linux-2.6.11-rc1.orig/drivers/i2c/chips/lm83.c	2004-12-24 22:34:32.000000000 +0100
+++ linux-2.6.11-rc1/drivers/i2c/chips/lm83.c	2005-01-16 12:50:29.000000000 +0100
@@ -150,12 +150,6 @@
 };
 
 /*
- * Internal variables
- */
-
-static int lm83_id;
-
-/*
  * Sysfs stuff
  */
 
@@ -312,7 +306,6 @@
 
 	/* We can fill in the remaining client fields */
 	strlcpy(new_client->name, name, I2C_NAME_SIZE);
-	new_client->id = lm83_id++;
 	data->valid = 0;
 	init_MUTEX(&data->update_lock);
 
diff -ruN linux-2.6.11-rc1.orig/drivers/i2c/chips/lm85.c linux-2.6.11-rc1/drivers/i2c/chips/lm85.c
--- linux-2.6.11-rc1.orig/drivers/i2c/chips/lm85.c	2005-01-14 18:37:07.000000000 +0100
+++ linux-2.6.11-rc1/drivers/i2c/chips/lm85.c	2005-01-16 12:50:29.000000000 +0100
@@ -389,9 +389,6 @@
 	.detach_client  = lm85_detach_client,
 };
 
-/* Unique ID assigned to each LM85 detected */
-static int lm85_id;
-
 
 /* 4 Fans */
 static ssize_t show_fan(struct device *dev, char *buf, int nr)
@@ -1148,16 +1145,10 @@
 	strlcpy(new_client->name, type_name, I2C_NAME_SIZE);
 
 	/* Fill in the remaining client fields */
-	new_client->id = lm85_id++;
 	data->type = kind;
 	data->valid = 0;
 	init_MUTEX(&data->update_lock);
 
-	dev_dbg(&adapter->dev, "Assigning ID %d to %s at %d,0x%02x\n",
-		new_client->id, new_client->name,
-		i2c_adapter_id(new_client->adapter),
-		new_client->addr);
-
 	/* Tell the I2C layer a new client has arrived */
 	if ((err = i2c_attach_client(new_client)))
 		goto ERROR1;
diff -ruN linux-2.6.11-rc1.orig/drivers/i2c/chips/lm87.c linux-2.6.11-rc1/drivers/i2c/chips/lm87.c
--- linux-2.6.11-rc1.orig/drivers/i2c/chips/lm87.c	2004-12-24 22:35:39.000000000 +0100
+++ linux-2.6.11-rc1/drivers/i2c/chips/lm87.c	2005-01-16 12:50:29.000000000 +0100
@@ -203,12 +203,6 @@
 };
 
 /*
- * Internal variables
- */
-
-static int lm87_id;
-
-/*
  * Sysfs stuff
  */
 
@@ -569,7 +563,6 @@
 
 	/* We can fill in the remaining client fields */
 	strlcpy(new_client->name, "lm87", I2C_NAME_SIZE);
-	new_client->id = lm87_id++;
 	data->valid = 0;
 	init_MUTEX(&data->update_lock);
 
diff -ruN linux-2.6.11-rc1.orig/drivers/i2c/chips/lm90.c linux-2.6.11-rc1/drivers/i2c/chips/lm90.c
--- linux-2.6.11-rc1.orig/drivers/i2c/chips/lm90.c	2005-01-14 18:36:52.000000000 +0100
+++ linux-2.6.11-rc1/drivers/i2c/chips/lm90.c	2005-01-16 12:50:29.000000000 +0100
@@ -190,12 +190,6 @@
 };
 
 /*
- * Internal variables
- */
-
-static int lm90_id;
-
-/*
  * Sysfs stuff
  */
 
@@ -427,7 +421,6 @@
 
 	/* We can fill in the remaining client fields */
 	strlcpy(new_client->name, name, I2C_NAME_SIZE);
-	new_client->id = lm90_id++;
 	data->valid = 0;
 	init_MUTEX(&data->update_lock);
 
diff -ruN linux-2.6.11-rc1.orig/drivers/i2c/chips/max1619.c linux-2.6.11-rc1/drivers/i2c/chips/max1619.c
--- linux-2.6.11-rc1.orig/drivers/i2c/chips/max1619.c	2004-12-24 22:35:25.000000000 +0100
+++ linux-2.6.11-rc1/drivers/i2c/chips/max1619.c	2005-01-16 12:50:29.000000000 +0100
@@ -117,12 +117,6 @@
 };
 
 /*
- * Internal variables
- */
-
-static int max1619_id;
-
-/*
  * Sysfs stuff
  */
 
@@ -267,7 +261,6 @@
 
 	/* We can fill in the remaining client fields */
 	strlcpy(new_client->name, name, I2C_NAME_SIZE);
-	new_client->id = max1619_id++;
 	data->valid = 0;
 	init_MUTEX(&data->update_lock);
 
diff -ruN linux-2.6.11-rc1.orig/drivers/i2c/chips/pcf8574.c linux-2.6.11-rc1/drivers/i2c/chips/pcf8574.c
--- linux-2.6.11-rc1.orig/drivers/i2c/chips/pcf8574.c	2004-12-24 22:34:00.000000000 +0100
+++ linux-2.6.11-rc1/drivers/i2c/chips/pcf8574.c	2005-01-16 12:50:29.000000000 +0100
@@ -77,8 +77,6 @@
 	.detach_client	= pcf8574_detach_client,
 };
 
-static int pcf8574_id;
-
 /* following are the sysfs callback functions */
 static ssize_t show_read(struct device *dev, char *buf)
 {
@@ -159,8 +157,6 @@
 
 	/* Fill in the remaining client fields and put it into the global list */
 	strlcpy(new_client->name, client_name, I2C_NAME_SIZE);
-
-	new_client->id = pcf8574_id++;
 	init_MUTEX(&data->update_lock);
 
 	/* Tell the I2C layer a new client has arrived */
diff -ruN linux-2.6.11-rc1.orig/drivers/i2c/chips/pcf8591.c linux-2.6.11-rc1/drivers/i2c/chips/pcf8591.c
--- linux-2.6.11-rc1.orig/drivers/i2c/chips/pcf8591.c	2004-12-24 22:35:50.000000000 +0100
+++ linux-2.6.11-rc1/drivers/i2c/chips/pcf8591.c	2005-01-16 12:50:29.000000000 +0100
@@ -98,8 +98,6 @@
 	.detach_client	= pcf8591_detach_client,
 };
 
-static int pcf8591_id;
-
 /* following are the sysfs callback functions */
 #define show_in_channel(channel)					\
 static ssize_t show_in##channel##_input(struct device *dev, char *buf)	\
@@ -201,8 +199,6 @@
 	/* Fill in the remaining client fields and put it into the global 
 	   list */
 	strlcpy(new_client->name, "pcf8591", I2C_NAME_SIZE);
-
-	new_client->id = pcf8591_id++;
 	init_MUTEX(&data->update_lock);
 
 	/* Tell the I2C layer a new client has arrived */
diff -ruN linux-2.6.11-rc1.orig/drivers/i2c/chips/rtc8564.c linux-2.6.11-rc1/drivers/i2c/chips/rtc8564.c
--- linux-2.6.11-rc1.orig/drivers/i2c/chips/rtc8564.c	2004-12-24 22:33:49.000000000 +0100
+++ linux-2.6.11-rc1/drivers/i2c/chips/rtc8564.c	2005-01-16 12:50:29.000000000 +0100
@@ -163,14 +163,12 @@
 
 	strlcpy(new_client->name, "RTC8564", I2C_NAME_SIZE);
 	i2c_set_clientdata(new_client, d);
-	new_client->id = rtc8564_driver.id;
 	new_client->flags = I2C_CLIENT_ALLOW_USE | I2C_DF_NOTIFY;
 	new_client->addr = addr;
 	new_client->adapter = adap;
 	new_client->driver = &rtc8564_driver;
 
 	_DBG(1, "client=%p", new_client);
-	_DBG(1, "client.id=%d", new_client->id);
 
 	/* init ctrl1 reg */
 	data[0] = 0;
diff -ruN linux-2.6.11-rc1.orig/drivers/i2c/chips/smsc47m1.c linux-2.6.11-rc1/drivers/i2c/chips/smsc47m1.c
--- linux-2.6.11-rc1.orig/drivers/i2c/chips/smsc47m1.c	2005-01-14 18:36:52.000000000 +0100
+++ linux-2.6.11-rc1/drivers/i2c/chips/smsc47m1.c	2005-01-16 12:50:29.000000000 +0100
@@ -108,7 +108,6 @@
 struct smsc47m1_data {
 	struct i2c_client client;
 	struct semaphore lock;
-	int sysctl_id;
 
 	struct semaphore update_lock;
 	unsigned long last_updated;	/* In jiffies */
@@ -133,8 +132,6 @@
 		int init);
 
 
-static int smsc47m1_id;
-
 static struct i2c_driver smsc47m1_driver = {
 	.owner		= THIS_MODULE,
 	.name		= "smsc47m1",
@@ -420,8 +417,6 @@
 	new_client->flags = 0;
 
 	strlcpy(new_client->name, "smsc47m1", I2C_NAME_SIZE);
-
-	new_client->id = smsc47m1_id++;
 	init_MUTEX(&data->update_lock);
 
 	/* If no function is properly configured, there's no point in
diff -ruN linux-2.6.11-rc1.orig/drivers/i2c/chips/w83l785ts.c linux-2.6.11-rc1/drivers/i2c/chips/w83l785ts.c
--- linux-2.6.11-rc1.orig/drivers/i2c/chips/w83l785ts.c	2004-12-24 22:34:26.000000000 +0100
+++ linux-2.6.11-rc1/drivers/i2c/chips/w83l785ts.c	2005-01-16 12:50:29.000000000 +0100
@@ -114,12 +114,6 @@
 };
 
 /*
- * Internal variables
- */
-
-static int w83l785ts_id = 0;
-
-/*
  * Sysfs stuff
  */
 
@@ -229,7 +223,6 @@
 
 	/* We can fill in the remaining client fields. */
 	strlcpy(new_client->name, "w83l785ts", I2C_NAME_SIZE);
-	new_client->id = w83l785ts_id++;
 	data->valid = 0;
 	init_MUTEX(&data->update_lock);
 


-- 
Jean Delvare
http://khali.linux-fr.org/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 2.6] I2C: Kill i2c_client.id (2/5)
  2005-01-16 18:46 [PATCH 2.6] I2C: Kill i2c_client.id Jean Delvare
  2005-01-16 19:10 ` [PATCH 2.6] I2C: Kill i2c_client.id (1/5) Jean Delvare
@ 2005-01-16 19:27 ` Jean Delvare
  2005-01-16 19:39 ` [PATCH 2.6] I2C: Kill i2c_client.id (3/5) Jean Delvare
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Jean Delvare @ 2005-01-16 19:27 UTC (permalink / raw)
  To: Greg KH; +Cc: LKML, Michael Hunold, Gerd Knorr

(2/5) Stop using i2c_client.id in media/video drivers.

Affected drivers:
* adv7170
* adv7175
* bt819
* bt856
* bttv
* cx88
* ovcamchip
* saa5246a
* saa5249
* saa7110
* saa7111
* saa7114
* saa7134
* saa7185
* tda7432
* tda9840
* tda9875
* tea6415c
* tea6420
* tuner-3036
* vpx3220

Most drivers here would include the id as part of their i2c client name
(e.g. adv7170[0]). This looks more like an habit than something really
needed, so I replaced the various printf by strlcpy, which should be
slightly faster. As said earlier, clients can be differenciated thanks
to their bus id and address if needed, so I don't think that including
this information in the client name is wise anyway.

Other drivers would either set the id to -1 or to a unique value but
then never use it. These drivers are unaffected by the changes.

Signed-off-by: Jean Delvare <khali@linux-fr.org>

diff -ruN linux-2.6.11-rc1.orig/drivers/media/video/adv7170.c linux-2.6.11-rc1/drivers/media/video/adv7170.c
--- linux-2.6.11-rc1.orig/drivers/media/video/adv7170.c	2005-01-14 18:36:52.000000000 +0100
+++ linux-2.6.11-rc1/drivers/media/video/adv7170.c	2005-01-16 12:50:29.000000000 +0100
@@ -402,7 +402,6 @@
 	.force			= force
 };
 
-static int adv7170_i2c_id = 0;
 static struct i2c_driver i2c_driver_adv7170;
 
 static int
@@ -432,7 +431,6 @@
 	client->adapter = adapter;
 	client->driver = &i2c_driver_adv7170;
 	client->flags = I2C_CLIENT_ALLOW_USE;
-	client->id = adv7170_i2c_id++;
 	if ((client->addr == I2C_ADV7170 >> 1) ||
 	    (client->addr == (I2C_ADV7170 >> 1) + 1)) {
 		dname = adv7170_name;
@@ -444,8 +442,7 @@
 		kfree(client);
 		return 0;
 	}
-	snprintf(I2C_NAME(client), sizeof(I2C_NAME(client)) - 1,
-		"%s[%d]", dname, client->id);
+	strlcpy(I2C_NAME(client), dname, sizeof(I2C_NAME(client)));
 
 	encoder = kmalloc(sizeof(struct adv7170), GFP_KERNEL);
 	if (encoder == NULL) {
diff -ruN linux-2.6.11-rc1.orig/drivers/media/video/adv7175.c linux-2.6.11-rc1/drivers/media/video/adv7175.c
--- linux-2.6.11-rc1.orig/drivers/media/video/adv7175.c	2005-01-14 18:36:52.000000000 +0100
+++ linux-2.6.11-rc1/drivers/media/video/adv7175.c	2005-01-16 12:50:29.000000000 +0100
@@ -452,7 +452,6 @@
 	.force			= force
 };
 
-static int adv7175_i2c_id = 0;
 static struct i2c_driver i2c_driver_adv7175;
 
 static int
@@ -482,7 +481,6 @@
 	client->adapter = adapter;
 	client->driver = &i2c_driver_adv7175;
 	client->flags = I2C_CLIENT_ALLOW_USE;
-	client->id = adv7175_i2c_id++;
 	if ((client->addr == I2C_ADV7175 >> 1) ||
 	    (client->addr == (I2C_ADV7175 >> 1) + 1)) {
 		dname = adv7175_name;
@@ -494,8 +492,7 @@
 		kfree(client);
 		return 0;
 	}
-	snprintf(I2C_NAME(client), sizeof(I2C_NAME(client)) - 1,
-		"%s[%d]", dname, client->id);
+	strlcpy(I2C_NAME(client), dname, sizeof(I2C_NAME(client)));
 
 	encoder = kmalloc(sizeof(struct adv7175), GFP_KERNEL);
 	if (encoder == NULL) {
diff -ruN linux-2.6.11-rc1.orig/drivers/media/video/bt819.c linux-2.6.11-rc1/drivers/media/video/bt819.c
--- linux-2.6.11-rc1.orig/drivers/media/video/bt819.c	2005-01-14 18:36:52.000000000 +0100
+++ linux-2.6.11-rc1/drivers/media/video/bt819.c	2005-01-16 12:50:29.000000000 +0100
@@ -517,7 +517,6 @@
 	.force			= force
 };
 
-static int bt819_i2c_id = 0;
 static struct i2c_driver i2c_driver_bt819;
 
 static int
@@ -546,7 +545,6 @@
 	client->adapter = adapter;
 	client->driver = &i2c_driver_bt819;
 	client->flags = I2C_CLIENT_ALLOW_USE;
-	client->id = bt819_i2c_id++;
 
 	decoder = kmalloc(sizeof(struct bt819), GFP_KERNEL);
 	if (decoder == NULL) {
@@ -568,16 +566,13 @@
 	id = bt819_read(client, 0x17);
 	switch (id & 0xf0) {
 	case 0x70:
-	        snprintf(I2C_NAME(client), sizeof(I2C_NAME(client)) - 1,
-			 "bt819a[%d]", client->id);
+		strlcpy(I2C_NAME(client), "bt819a", sizeof(I2C_NAME(client)));
 		break;
 	case 0x60:
-		snprintf(I2C_NAME(client), sizeof(I2C_NAME(client)) - 1,
-			 "bt817a[%d]", client->id);
+		strlcpy(I2C_NAME(client), "bt817a", sizeof(I2C_NAME(client)));
 		break;
 	case 0x20:
-		snprintf(I2C_NAME(client), sizeof(I2C_NAME(client)) - 1,
-			 "bt815a[%d]", client->id);
+		strlcpy(I2C_NAME(client), "bt815a", sizeof(I2C_NAME(client)));
 		break;
 	default:
 		dprintk(1,
diff -ruN linux-2.6.11-rc1.orig/drivers/media/video/bt856.c linux-2.6.11-rc1/drivers/media/video/bt856.c
--- linux-2.6.11-rc1.orig/drivers/media/video/bt856.c	2005-01-14 18:36:52.000000000 +0100
+++ linux-2.6.11-rc1/drivers/media/video/bt856.c	2005-01-16 12:50:29.000000000 +0100
@@ -306,7 +306,6 @@
 	.force			= force
 };
 
-static int bt856_i2c_id = 0;
 static struct i2c_driver i2c_driver_bt856;
 
 static int
@@ -335,9 +334,7 @@
 	client->adapter = adapter;
 	client->driver = &i2c_driver_bt856;
 	client->flags = I2C_CLIENT_ALLOW_USE;
-	client->id = bt856_i2c_id++;
-	snprintf(I2C_NAME(client), sizeof(I2C_NAME(client)) - 1,
-		"bt856[%d]", client->id);
+	strlcpy(I2C_NAME(client), "bt856", sizeof(I2C_NAME(client)));
 
 	encoder = kmalloc(sizeof(struct bt856), GFP_KERNEL);
 	if (encoder == NULL) {
diff -ruN linux-2.6.11-rc1.orig/drivers/media/video/bttv-i2c.c linux-2.6.11-rc1/drivers/media/video/bttv-i2c.c
--- linux-2.6.11-rc1.orig/drivers/media/video/bttv-i2c.c	2005-01-14 18:36:52.000000000 +0100
+++ linux-2.6.11-rc1/drivers/media/video/bttv-i2c.c	2005-01-16 12:50:29.000000000 +0100
@@ -336,7 +336,6 @@
 
 static struct i2c_client bttv_i2c_client_template = {
 	I2C_DEVNAME("bttv internal"),
-        .id       = -1,
 };
 
 
diff -ruN linux-2.6.11-rc1.orig/drivers/media/video/cx88/cx88-i2c.c linux-2.6.11-rc1/drivers/media/video/cx88/cx88-i2c.c
--- linux-2.6.11-rc1.orig/drivers/media/video/cx88/cx88-i2c.c	2004-12-24 22:34:31.000000000 +0100
+++ linux-2.6.11-rc1/drivers/media/video/cx88/cx88-i2c.c	2005-01-16 12:50:29.000000000 +0100
@@ -141,7 +141,6 @@
 
 static struct i2c_client cx8800_i2c_client_template = {
         I2C_DEVNAME("cx88xx internal"),
-        .id   = -1,
 };
 
 static char *i2c_devs[128] = {
diff -ruN linux-2.6.11-rc1.orig/drivers/media/video/ovcamchip/ovcamchip_core.c linux-2.6.11-rc1/drivers/media/video/ovcamchip/ovcamchip_core.c
--- linux-2.6.11-rc1.orig/drivers/media/video/ovcamchip/ovcamchip_core.c	2004-12-24 22:35:28.000000000 +0100
+++ linux-2.6.11-rc1/drivers/media/video/ovcamchip/ovcamchip_core.c	2005-01-16 12:50:29.000000000 +0100
@@ -422,7 +422,6 @@
 
 static struct i2c_client client_template = {
 	I2C_DEVNAME("(unset)"),
-	.id =		-1,
 	.driver =	&driver,
 };
 
diff -ruN linux-2.6.11-rc1.orig/drivers/media/video/saa5246a.c linux-2.6.11-rc1/drivers/media/video/saa5246a.c
--- linux-2.6.11-rc1.orig/drivers/media/video/saa5246a.c	2004-12-24 22:34:33.000000000 +0100
+++ linux-2.6.11-rc1/drivers/media/video/saa5246a.c	2005-01-16 12:50:29.000000000 +0100
@@ -185,7 +185,6 @@
 };
 
 static struct i2c_client client_template = {
-	.id 		= -1,
 	.driver		= &i2c_driver_videotext,
 	.name		= "(unset)",
 };
diff -ruN linux-2.6.11-rc1.orig/drivers/media/video/saa5249.c linux-2.6.11-rc1/drivers/media/video/saa5249.c
--- linux-2.6.11-rc1.orig/drivers/media/video/saa5249.c	2004-12-24 22:35:23.000000000 +0100
+++ linux-2.6.11-rc1/drivers/media/video/saa5249.c	2005-01-16 12:50:29.000000000 +0100
@@ -255,7 +255,6 @@
 };
 
 static struct i2c_client client_template = {
-	.id 		= -1,
 	.driver		= &i2c_driver_videotext,
 	.name		= "(unset)",
 };
diff -ruN linux-2.6.11-rc1.orig/drivers/media/video/saa7110.c linux-2.6.11-rc1/drivers/media/video/saa7110.c
--- linux-2.6.11-rc1.orig/drivers/media/video/saa7110.c	2005-01-14 18:36:52.000000000 +0100
+++ linux-2.6.11-rc1/drivers/media/video/saa7110.c	2005-01-16 12:50:29.000000000 +0100
@@ -476,7 +476,6 @@
 	.force			= force
 };
 
-static int saa7110_i2c_id = 0;
 static struct i2c_driver i2c_driver_saa7110;
 
 static int
@@ -507,9 +506,7 @@
 	client->adapter = adapter;
 	client->driver = &i2c_driver_saa7110;
 	client->flags = I2C_CLIENT_ALLOW_USE;
-	client->id = saa7110_i2c_id++;
-	snprintf(I2C_NAME(client), sizeof(I2C_NAME(client)) - 1,
-		"saa7110[%d]", client->id);
+	strlcpy(I2C_NAME(client), "saa7110", sizeof(I2C_NAME(client)));
 
 	decoder = kmalloc(sizeof(struct saa7110), GFP_KERNEL);
 	if (decoder == 0) {
diff -ruN linux-2.6.11-rc1.orig/drivers/media/video/saa7111.c linux-2.6.11-rc1/drivers/media/video/saa7111.c
--- linux-2.6.11-rc1.orig/drivers/media/video/saa7111.c	2004-12-24 22:35:50.000000000 +0100
+++ linux-2.6.11-rc1/drivers/media/video/saa7111.c	2005-01-16 12:50:29.000000000 +0100
@@ -500,7 +500,6 @@
 	.force			= force
 };
 
-static int saa7111_i2c_id = 0;
 static struct i2c_driver i2c_driver_saa7111;
 
 static int
@@ -530,9 +529,7 @@
 	client->adapter = adapter;
 	client->driver = &i2c_driver_saa7111;
 	client->flags = I2C_CLIENT_ALLOW_USE;
-	client->id = saa7111_i2c_id++;
-	snprintf(I2C_NAME(client), sizeof(I2C_NAME(client)) - 1,
-		"saa7111[%d]", client->id);
+	strlcpy(I2C_NAME(client), "saa7111", sizeof(I2C_NAME(client)));
 
 	decoder = kmalloc(sizeof(struct saa7111), GFP_KERNEL);
 	if (decoder == NULL) {
diff -ruN linux-2.6.11-rc1.orig/drivers/media/video/saa7114.c linux-2.6.11-rc1/drivers/media/video/saa7114.c
--- linux-2.6.11-rc1.orig/drivers/media/video/saa7114.c	2005-01-14 18:36:52.000000000 +0100
+++ linux-2.6.11-rc1/drivers/media/video/saa7114.c	2005-01-16 12:50:29.000000000 +0100
@@ -838,7 +838,6 @@
 	.force			= force
 };
 
-static int saa7114_i2c_id = 0;
 static struct i2c_driver i2c_driver_saa7114;
 
 static int
@@ -871,9 +870,7 @@
 	client->adapter = adapter;
 	client->driver = &i2c_driver_saa7114;
 	client->flags = I2C_CLIENT_ALLOW_USE;
-	client->id = saa7114_i2c_id++;
-	snprintf(I2C_NAME(client), sizeof(I2C_NAME(client)) - 1,
-		"saa7114[%d]", client->id);
+	strlcpy(I2C_NAME(client), "saa7114", sizeof(I2C_NAME(client)));
 
 	decoder = kmalloc(sizeof(struct saa7114), GFP_KERNEL);
 	if (decoder == NULL) {
diff -ruN linux-2.6.11-rc1.orig/drivers/media/video/saa7134/saa7134-i2c.c linux-2.6.11-rc1/drivers/media/video/saa7134/saa7134-i2c.c
--- linux-2.6.11-rc1.orig/drivers/media/video/saa7134/saa7134-i2c.c	2004-12-24 22:34:01.000000000 +0100
+++ linux-2.6.11-rc1/drivers/media/video/saa7134/saa7134-i2c.c	2005-01-16 12:50:29.000000000 +0100
@@ -362,7 +362,6 @@
 
 static struct i2c_client saa7134_client_template = {
 	I2C_DEVNAME("saa7134 internal"),
-        .id        = -1,
 };
 
 /* ----------------------------------------------------------- */
diff -ruN linux-2.6.11-rc1.orig/drivers/media/video/saa7185.c linux-2.6.11-rc1/drivers/media/video/saa7185.c
--- linux-2.6.11-rc1.orig/drivers/media/video/saa7185.c	2005-01-14 18:36:52.000000000 +0100
+++ linux-2.6.11-rc1/drivers/media/video/saa7185.c	2005-01-16 12:50:29.000000000 +0100
@@ -398,7 +398,6 @@
 	.force			= force
 };
 
-static int saa7185_i2c_id = 0;
 static struct i2c_driver i2c_driver_saa7185;
 
 static int
@@ -427,9 +426,7 @@
 	client->adapter = adapter;
 	client->driver = &i2c_driver_saa7185;
 	client->flags = I2C_CLIENT_ALLOW_USE;
-	client->id = saa7185_i2c_id++;
-	snprintf(I2C_NAME(client), sizeof(I2C_NAME(client)) - 1,
-		"saa7185[%d]", client->id);
+	strlcpy(I2C_NAME(client), "saa7185", sizeof(I2C_NAME(client)));
 
 	encoder = kmalloc(sizeof(struct saa7185), GFP_KERNEL);
 	if (encoder == NULL) {
diff -ruN linux-2.6.11-rc1.orig/drivers/media/video/tda7432.c linux-2.6.11-rc1/drivers/media/video/tda7432.c
--- linux-2.6.11-rc1.orig/drivers/media/video/tda7432.c	2005-01-14 18:36:52.000000000 +0100
+++ linux-2.6.11-rc1/drivers/media/video/tda7432.c	2005-01-16 12:50:29.000000000 +0100
@@ -528,7 +528,6 @@
 static struct i2c_client client_template =
 {
 	I2C_DEVNAME("tda7432"),
-        .id         = -1,
 	.driver     = &driver,
 };
 
diff -ruN linux-2.6.11-rc1.orig/drivers/media/video/tda9840.c linux-2.6.11-rc1/drivers/media/video/tda9840.c
--- linux-2.6.11-rc1.orig/drivers/media/video/tda9840.c	2004-12-24 22:35:23.000000000 +0100
+++ linux-2.6.11-rc1/drivers/media/video/tda9840.c	2005-01-16 12:50:29.000000000 +0100
@@ -51,9 +51,6 @@
 static struct i2c_driver driver;
 static struct i2c_client client_template;
 
-/* unique ID allocation */
-static int tda9840_id = 0;
-
 static int command(struct i2c_client *client, unsigned int cmd, void *arg)
 {
 	int result;
@@ -179,7 +176,6 @@
 
 	/* fill client structure */
 	memcpy(client, &client_template, sizeof(struct i2c_client));
-	client->id = tda9840_id++;
 	client->addr = address;
 	client->adapter = adapter;
 
diff -ruN linux-2.6.11-rc1.orig/drivers/media/video/tda9875.c linux-2.6.11-rc1/drivers/media/video/tda9875.c
--- linux-2.6.11-rc1.orig/drivers/media/video/tda9875.c	2005-01-14 18:36:52.000000000 +0100
+++ linux-2.6.11-rc1/drivers/media/video/tda9875.c	2005-01-16 12:50:29.000000000 +0100
@@ -399,7 +399,6 @@
 static struct i2c_client client_template =
 {
         I2C_DEVNAME("tda9875"),
-        .id        = -1,
         .driver    = &driver,
 };
 
diff -ruN linux-2.6.11-rc1.orig/drivers/media/video/tea6415c.c linux-2.6.11-rc1/drivers/media/video/tea6415c.c
--- linux-2.6.11-rc1.orig/drivers/media/video/tea6415c.c	2004-12-24 22:35:23.000000000 +0100
+++ linux-2.6.11-rc1/drivers/media/video/tea6415c.c	2005-01-16 12:50:29.000000000 +0100
@@ -51,9 +51,6 @@
 static struct i2c_driver driver;
 static struct i2c_client client_template;
 
-/* unique ID allocation */
-static int tea6415c_id = 0;
-
 /* this function is called by i2c_probe */
 static int detect(struct i2c_adapter *adapter, int address, int kind)
 {
@@ -73,7 +70,6 @@
 
 	/* fill client structure */
 	memcpy(client, &client_template, sizeof(struct i2c_client));
-	client->id = tea6415c_id++;
 	client->addr = address;
 	client->adapter = adapter;
 
diff -ruN linux-2.6.11-rc1.orig/drivers/media/video/tea6420.c linux-2.6.11-rc1/drivers/media/video/tea6420.c
--- linux-2.6.11-rc1.orig/drivers/media/video/tea6420.c	2004-12-24 22:34:45.000000000 +0100
+++ linux-2.6.11-rc1/drivers/media/video/tea6420.c	2005-01-16 12:50:29.000000000 +0100
@@ -48,9 +48,6 @@
 static struct i2c_driver driver;
 static struct i2c_client client_template;
 
-/* unique ID allocation */
-static int tea6420_id = 0;
-
 /* make a connection between the input 'i' and the output 'o'
    with gain 'g' for the tea6420-client 'client' (note: i = 6 means 'mute') */
 static int tea6420_switch(struct i2c_client *client, int i, int o, int g)
@@ -111,7 +108,6 @@
 
 	/* fill client structure */
 	memcpy(client, &client_template, sizeof(struct i2c_client));
-	client->id = tea6420_id++;
 	client->addr = address;
 	client->adapter = adapter;
 
diff -ruN linux-2.6.11-rc1.orig/drivers/media/video/tuner-3036.c linux-2.6.11-rc1/drivers/media/video/tuner-3036.c
--- linux-2.6.11-rc1.orig/drivers/media/video/tuner-3036.c	2005-01-14 18:36:52.000000000 +0100
+++ linux-2.6.11-rc1/drivers/media/video/tuner-3036.c	2005-01-16 12:50:29.000000000 +0100
@@ -192,7 +192,6 @@
 
 static struct i2c_client client_template =
 {
-        .id 		= -1,
         .driver		= &i2c_driver_tuner,
 	.name		= "SAB3036",
 };
diff -ruN linux-2.6.11-rc1.orig/drivers/media/video/vpx3220.c linux-2.6.11-rc1/drivers/media/video/vpx3220.c
--- linux-2.6.11-rc1.orig/drivers/media/video/vpx3220.c	2005-01-14 18:36:52.000000000 +0100
+++ linux-2.6.11-rc1/drivers/media/video/vpx3220.c	2005-01-16 12:50:29.000000000 +0100
@@ -587,7 +587,6 @@
 	.force			= force
 };
 
-static int vpx3220_i2c_id = 0;
 static struct i2c_driver vpx3220_i2c_driver;
 
 static int
@@ -634,7 +633,6 @@
 	client->adapter = adapter;
 	client->driver = &vpx3220_i2c_driver;
 	client->flags = I2C_CLIENT_ALLOW_USE;
-	client->id = vpx3220_i2c_id++;
 
 	/* Check for manufacture ID and part number */
 	if (kind < 0) {
@@ -655,16 +653,16 @@
 		    vpx3220_read(client, 0x01);
 		switch (pn) {
 		case 0x4680:
-			snprintf(I2C_NAME(client), sizeof(I2C_NAME(client)) - 1,
-				 "vpx3220a[%d]", client->id);
+			strlcpy(I2C_NAME(client), "vpx3220a",
+				sizeof(I2C_NAME(client)));
 			break;
 		case 0x4260:
-			snprintf(I2C_NAME(client), sizeof(I2C_NAME(client)) - 1,
-				 "vpx3216b[%d]", client->id);
+			strlcpy(I2C_NAME(client), "vpx3216b",
+				sizeof(I2C_NAME(client)));
 			break;
 		case 0x4280:
-			snprintf(I2C_NAME(client), sizeof(I2C_NAME(client)) - 1,
-				 "vpx3214c[%d]", client->id);
+			strlcpy(I2C_NAME(client), "vpx3214c",
+				sizeof(I2C_NAME(client)));
 			break;
 		default:
 			dprintk(1,
@@ -675,9 +673,8 @@
 			return 0;
 		}
 	} else {
-		snprintf(I2C_NAME(client), sizeof(I2C_NAME(client)) - 1,
-			 "forced vpx32xx[%d]",
-		client->id);
+		strlcpy(I2C_NAME(client), "forced vpx32xx",
+			sizeof(I2C_NAME(client)));
 	}
 
 	decoder = kmalloc(sizeof(struct vpx3220), GFP_KERNEL);


-- 
Jean Delvare
http://khali.linux-fr.org/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 2.6] I2C: Kill i2c_client.id (3/5)
  2005-01-16 18:46 [PATCH 2.6] I2C: Kill i2c_client.id Jean Delvare
  2005-01-16 19:10 ` [PATCH 2.6] I2C: Kill i2c_client.id (1/5) Jean Delvare
  2005-01-16 19:27 ` [PATCH 2.6] I2C: Kill i2c_client.id (2/5) Jean Delvare
@ 2005-01-16 19:39 ` Jean Delvare
  2005-01-16 19:46 ` [PATCH 2.6] I2C: Kill i2c_client.id (4/5) Jean Delvare
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Jean Delvare @ 2005-01-16 19:39 UTC (permalink / raw)
  To: Greg KH; +Cc: LKML, Russell King

(3/5) Stop using i2c_client.id in misc drivers.

Affected drivers:
* acorn/char/pcf8583
* acorn/char/i2c
* i2c/i2c-dev
* macintosh/therm_windtunnel
* sound/oss/dmasound/dac3550a
* sound/ppc/keywest

The Acorn pcf8583 driver would give the i2c_client id the same value as
the i2c_driver id, and later test that client id (in i2c). I changed it
to test the client's driver id instead. The result is the same and the
client id is then useless and can be removed.

All other drivers here would allocate the client id to some value and
then never use it. They are unaffected by the change.

Signed-off-by: Jean Delvare <khali@linux-fr.org>

diff -ruN linux-2.6.11-rc1.orig/drivers/acorn/char/i2c.c linux-2.6.11-rc1/drivers/acorn/char/i2c.c
--- linux-2.6.11-rc1.orig/drivers/acorn/char/i2c.c	2004-12-24 22:35:49.000000000 +0100
+++ linux-2.6.11-rc1/drivers/acorn/char/i2c.c	2005-01-16 12:50:29.000000000 +0100
@@ -313,7 +313,7 @@
 
 static int ioc_client_reg(struct i2c_client *client)
 {
-	if (client->id == I2C_DRIVERID_PCF8583 &&
+	if (client->driver->id == I2C_DRIVERID_PCF8583 &&
 	    client->addr == 0x50) {
 		struct rtc_tm rtctm;
 		unsigned int year;
diff -ruN linux-2.6.11-rc1.orig/drivers/acorn/char/pcf8583.c linux-2.6.11-rc1/drivers/acorn/char/pcf8583.c
--- linux-2.6.11-rc1.orig/drivers/acorn/char/pcf8583.c	2004-12-24 22:35:28.000000000 +0100
+++ linux-2.6.11-rc1/drivers/acorn/char/pcf8583.c	2005-01-16 12:50:29.000000000 +0100
@@ -51,7 +51,6 @@
 		return -ENOMEM;
 
 	memset(c, 0, sizeof(*c));
-	c->id		= pcf8583_driver.id;
 	c->addr		= addr;
 	c->adapter	= adap;
 	c->driver	= &pcf8583_driver;
diff -ruN linux-2.6.11-rc1.orig/drivers/i2c/i2c-dev.c linux-2.6.11-rc1/drivers/i2c/i2c-dev.c
--- linux-2.6.11-rc1.orig/drivers/i2c/i2c-dev.c	2004-12-24 22:35:24.000000000 +0100
+++ linux-2.6.11-rc1/drivers/i2c/i2c-dev.c	2005-01-16 12:50:29.000000000 +0100
@@ -507,7 +507,6 @@
 
 static struct i2c_client i2cdev_client_template = {
 	.name		= "I2C /dev entry",
-	.id		= 1,
 	.addr		= -1,
 	.driver		= &i2cdev_driver,
 };
diff -ruN linux-2.6.11-rc1.orig/drivers/macintosh/therm_windtunnel.c linux-2.6.11-rc1/drivers/macintosh/therm_windtunnel.c
--- linux-2.6.11-rc1.orig/drivers/macintosh/therm_windtunnel.c	2004-12-24 22:35:23.000000000 +0100
+++ linux-2.6.11-rc1/drivers/macintosh/therm_windtunnel.c	2005-01-16 12:50:29.000000000 +0100
@@ -47,8 +47,6 @@
 #define LOG_TEMP		0			/* continously log temperature */
 
 #define I2C_DRIVERID_G4FAN	0x9001			/* fixme */
-#define THERMOSTAT_CLIENT_ID	1
-#define FAN_CLIENT_ID		2
 
 static int 			do_probe( struct i2c_adapter *adapter, int addr, int kind);
 
@@ -372,7 +370,6 @@
 		goto out;
 	printk("ADM1030 fan controller [@%02x]\n", cl->addr );
 
-	cl->id = FAN_CLIENT_ID;
 	strlcpy( cl->name, "ADM1030 fan controller", sizeof(cl->name) );
 
 	if( !i2c_attach_client(cl) )
@@ -412,7 +409,6 @@
 	x.overheat_temp = os_temp;
 	x.overheat_hyst = hyst_temp;
 	
-	cl->id = THERMOSTAT_CLIENT_ID;
 	strlcpy( cl->name, "DS1775 thermostat", sizeof(cl->name) );
 
 	if( !i2c_attach_client(cl) )
diff -ruN linux-2.6.11-rc1.orig/sound/oss/dmasound/dac3550a.c linux-2.6.11-rc1/sound/oss/dmasound/dac3550a.c
--- linux-2.6.11-rc1.orig/sound/oss/dmasound/dac3550a.c	2004-12-24 22:34:26.000000000 +0100
+++ linux-2.6.11-rc1/sound/oss/dmasound/dac3550a.c	2005-01-16 12:50:29.000000000 +0100
@@ -40,9 +40,6 @@
 static int daca_detect_client(struct i2c_adapter *adapter, int address);
 static int daca_detach_client(struct i2c_client *client);
 
-/* Unique ID allocation */
-static int daca_id;
-
 struct i2c_driver daca_driver = {  
 	.owner			= THIS_MODULE,
 	.name			= "DAC3550A driver  V " DACA_VERSION,
@@ -176,7 +173,6 @@
 	new_client->driver = &daca_driver;
 	new_client->flags = 0;
 	strcpy(new_client->name, client_name);
-	new_client->id = daca_id++; /* racy... */
 
 	if (daca_init_client(new_client))
 		goto bail;
diff -ruN linux-2.6.11-rc1.orig/sound/ppc/keywest.c linux-2.6.11-rc1/sound/ppc/keywest.c
--- linux-2.6.11-rc1.orig/sound/ppc/keywest.c	2004-12-24 22:35:39.000000000 +0100
+++ linux-2.6.11-rc1/sound/ppc/keywest.c	2005-01-16 12:50:29.000000000 +0100
@@ -76,8 +76,6 @@
 	new_client->flags = 0;
 
 	strcpy(i2c_device_name(new_client), keywest_ctx->name);
-
-	new_client->id = keywest_ctx->id++; /* Automatically unique */
 	keywest_ctx->client = new_client;
 	
 	/* Tell the i2c layer a new client has arrived */


-- 
Jean Delvare
http://khali.linux-fr.org/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 2.6] I2C: Kill i2c_client.id (4/5)
  2005-01-16 18:46 [PATCH 2.6] I2C: Kill i2c_client.id Jean Delvare
                   ` (2 preceding siblings ...)
  2005-01-16 19:39 ` [PATCH 2.6] I2C: Kill i2c_client.id (3/5) Jean Delvare
@ 2005-01-16 19:46 ` Jean Delvare
  2005-01-16 19:49 ` [PATCH 2.6] I2C: Kill i2c_client.id (5/5) Jean Delvare
  2005-01-19 23:37 ` [PATCH 2.6] I2C: Kill i2c_client.id Greg KH
  5 siblings, 0 replies; 7+ messages in thread
From: Jean Delvare @ 2005-01-16 19:46 UTC (permalink / raw)
  To: Greg KH; +Cc: LKML, LM Sensors

> (4/5) Deprecate i2c_client.id.

Now that i2c_client.id has no more users in the kernel (none that I
could find at least) we could remove that struct member. I however think
that it's better to only deprecate it at the moment, in case I missed
users or any of the other patches are delayed for some reason. We could
then delete the id member definitely in a month or so.

Signed-off-by: Jean Delvare <khali@linux-fr.org>

diff -ruN linux-2.6.11-rc1.orig/include/linux/i2c.h linux-2.6.11-rc1/include/linux/i2c.h
--- linux-2.6.11-rc1.orig/include/linux/i2c.h	2004-12-24 22:34:01.000000000 +0100
+++ linux-2.6.11-rc1/include/linux/i2c.h	2005-01-16 18:41:51.000000000 +0100
@@ -144,7 +144,7 @@
  * function is mainly used for lookup & other admin. functions.
  */
 struct i2c_client {
-	int id;
+	__attribute__ ((deprecated)) int id;
 	unsigned int flags;		/* div., see below		*/
 	unsigned int addr;		/* chip address - NOTE: 7bit 	*/
 					/* addresses are stored in the	*/


-- 
Jean Delvare
http://khali.linux-fr.org/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 2.6] I2C: Kill i2c_client.id (5/5)
  2005-01-16 18:46 [PATCH 2.6] I2C: Kill i2c_client.id Jean Delvare
                   ` (3 preceding siblings ...)
  2005-01-16 19:46 ` [PATCH 2.6] I2C: Kill i2c_client.id (4/5) Jean Delvare
@ 2005-01-16 19:49 ` Jean Delvare
  2005-01-19 23:37 ` [PATCH 2.6] I2C: Kill i2c_client.id Greg KH
  5 siblings, 0 replies; 7+ messages in thread
From: Jean Delvare @ 2005-01-16 19:49 UTC (permalink / raw)
  To: Greg KH; +Cc: LKML, LM Sensors

> (5/5) Documentation update.

Finally, updates are required to the i2c/writing-client and
i2c/porting-client documents. Remove any reference to i2c_client id and
invite porters to discard that struct member.

Thanks.

Signed-off-by: Jean Delvare <khali@linux-fr.org>

diff -ruN linux-2.6.11-rc1.orig/Documentation/i2c/porting-clients linux-2.6.11-rc1/Documentation/i2c/porting-clients
--- linux-2.6.11-rc1.orig/Documentation/i2c/porting-clients	2004-12-24 22:34:27.000000000 +0100
+++ linux-2.6.11-rc1/Documentation/i2c/porting-clients	2005-01-16 18:33:55.000000000 +0100
@@ -49,9 +49,8 @@
   static void lm75_update_client(struct i2c_client *client);
 
 * [Sysctl] All sysctl stuff is of course gone (defines, ctl_table
-  and functions). Instead, right after the static id definition
-  line, you have to define show and set functions for each sysfs
-  file. Only define set for writable values. Take a look at an
+  and functions). Instead, you have to define show and set functions for
+  each sysfs file. Only define set for writable values. Take a look at an
   existing 2.6 driver for details (lm78 for example). Don't forget
   to define the attributes for each file (this is that step that
   links callback functions). Use the file names specified in
@@ -86,6 +85,7 @@
   Replace the sysctl directory registration by calls to
   device_create_file. Move the driver initialization before any
   sysfs file creation.
+  Drop client->id.
 
 * [Init] Limits must not be set by the driver (can be done later in
   user-space). Chip should not be reset default (although a module
diff -ruN linux-2.6.11-rc1.orig/Documentation/i2c/writing-clients linux-2.6.11-rc1/Documentation/i2c/writing-clients
--- linux-2.6.11-rc1.orig/Documentation/i2c/writing-clients	2004-12-24 22:34:26.000000000 +0100
+++ linux-2.6.11-rc1/Documentation/i2c/writing-clients	2005-01-16 12:50:29.000000000 +0100
@@ -344,9 +344,6 @@
 
 For now, you can ignore the `flags' parameter. It is there for future use.
 
-  /* Unique ID allocation */
-  static int foo_id = 0;
-
   int foo_detect_client(struct i2c_adapter *adapter, int address, 
                         unsigned short flags, int kind)
   {
@@ -482,7 +479,6 @@
     data->type = kind;
     /* SENSORS ONLY END */
 
-    new_client->id = foo_id++; /* Automatically unique */
     data->valid = 0; /* Only if you use this field */
     init_MUTEX(&data->update_lock); /* Only if you use this field */
 


-- 
Jean Delvare
http://khali.linux-fr.org/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 2.6] I2C: Kill i2c_client.id
  2005-01-16 18:46 [PATCH 2.6] I2C: Kill i2c_client.id Jean Delvare
                   ` (4 preceding siblings ...)
  2005-01-16 19:49 ` [PATCH 2.6] I2C: Kill i2c_client.id (5/5) Jean Delvare
@ 2005-01-19 23:37 ` Greg KH
  5 siblings, 0 replies; 7+ messages in thread
From: Greg KH @ 2005-01-19 23:37 UTC (permalink / raw)
  To: Jean Delvare; +Cc: LKML, LM Sensors

On Sun, Jan 16, 2005 at 07:46:53PM +0100, Jean Delvare wrote:
> Hi Greg,
> 
> As discussed earlier on the LKML [1], here comes a patch set killing the
> id member of the i2c_client structure. Let me recap my main reasons for
> doing so:

I've applied all 5 patches, and then just deleted the field altogether
(mainly because sparse complained about it, and there's no reason to
have it around anymore.)

thanks for doing this work, it was really needed.

greg k-h

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2005-01-19 23:39 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-01-16 18:46 [PATCH 2.6] I2C: Kill i2c_client.id Jean Delvare
2005-01-16 19:10 ` [PATCH 2.6] I2C: Kill i2c_client.id (1/5) Jean Delvare
2005-01-16 19:27 ` [PATCH 2.6] I2C: Kill i2c_client.id (2/5) Jean Delvare
2005-01-16 19:39 ` [PATCH 2.6] I2C: Kill i2c_client.id (3/5) Jean Delvare
2005-01-16 19:46 ` [PATCH 2.6] I2C: Kill i2c_client.id (4/5) Jean Delvare
2005-01-16 19:49 ` [PATCH 2.6] I2C: Kill i2c_client.id (5/5) Jean Delvare
2005-01-19 23:37 ` [PATCH 2.6] I2C: Kill i2c_client.id Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).