Skip to contentSkip to conversation

I2C: Kill i2c_client.id

PATCH In review Jean Delvare 2 participants 7 messages Jan 16, 2005 – Jan 19, 2005

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 I2C: Kill i2c_client.id

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

Signature · 2 lines
Jean Delvare
http://khali.linux-fr.org/
#1 lore raw

PATCH 1/1 I2C: Kill i2c_client.id (1/5)

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

drivers/i2c/chips/adm1021.c +0 -4
diff -ruN linux-2.6.11-rc1.orig/drivers/i2c/chips/adm1021.c linux-2.6.11-rc1/drivers/i2c/chips/adm1021.c
@@ -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);
 
drivers/i2c/chips/adm1025.c +0 -7
diff -ruN linux-2.6.11-rc1.orig/drivers/i2c/chips/adm1025.c linux-2.6.11-rc1/drivers/i2c/chips/adm1025.c
@@ -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);
 
drivers/i2c/chips/adm1026.c +32 -48

180 lines not on this page · raw message

drivers/i2c/chips/adm1031.c +0 -4
diff -ruN linux-2.6.11-rc1.orig/drivers/i2c/chips/adm1031.c linux-2.6.11-rc1/drivers/i2c/chips/adm1031.c
@@ -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);
 
drivers/i2c/chips/ds1621.c +0 -4
diff -ruN linux-2.6.11-rc1.orig/drivers/i2c/chips/ds1621.c linux-2.6.11-rc1/drivers/i2c/chips/ds1621.c
@@ -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);
 
drivers/i2c/chips/fscher.c +0 -7
diff -ruN linux-2.6.11-rc1.orig/drivers/i2c/chips/fscher.c linux-2.6.11-rc1/drivers/i2c/chips/fscher.c
@@ -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);
 
drivers/i2c/chips/gl518sm.c +0 -7
diff -ruN linux-2.6.11-rc1.orig/drivers/i2c/chips/gl518sm.c linux-2.6.11-rc1/drivers/i2c/chips/gl518sm.c
@@ -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);
drivers/i2c/chips/isp1301_omap.c +0 -1
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
@@ -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;
drivers/i2c/chips/lm75.c +0 -4
diff -ruN linux-2.6.11-rc1.orig/drivers/i2c/chips/lm75.c linux-2.6.11-rc1/drivers/i2c/chips/lm75.c
@@ -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);
 
drivers/i2c/chips/lm77.c +0 -4
diff -ruN linux-2.6.11-rc1.orig/drivers/i2c/chips/lm77.c linux-2.6.11-rc1/drivers/i2c/chips/lm77.c
@@ -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);
 
drivers/i2c/chips/lm80.c +0 -8
diff -ruN linux-2.6.11-rc1.orig/drivers/i2c/chips/lm80.c linux-2.6.11-rc1/drivers/i2c/chips/lm80.c
@@ -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);
 
drivers/i2c/chips/lm83.c +0 -7
diff -ruN linux-2.6.11-rc1.orig/drivers/i2c/chips/lm83.c linux-2.6.11-rc1/drivers/i2c/chips/lm83.c
@@ -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);
 
drivers/i2c/chips/lm85.c +0 -9
diff -ruN linux-2.6.11-rc1.orig/drivers/i2c/chips/lm85.c linux-2.6.11-rc1/drivers/i2c/chips/lm85.c
@@ -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;
drivers/i2c/chips/lm87.c +0 -7
diff -ruN linux-2.6.11-rc1.orig/drivers/i2c/chips/lm87.c linux-2.6.11-rc1/drivers/i2c/chips/lm87.c
@@ -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);
 
drivers/i2c/chips/lm90.c +0 -7
diff -ruN linux-2.6.11-rc1.orig/drivers/i2c/chips/lm90.c linux-2.6.11-rc1/drivers/i2c/chips/lm90.c
@@ -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);
 
drivers/i2c/chips/max1619.c +0 -7
diff -ruN linux-2.6.11-rc1.orig/drivers/i2c/chips/max1619.c linux-2.6.11-rc1/drivers/i2c/chips/max1619.c
@@ -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);
 
drivers/i2c/chips/pcf8574.c +0 -4
diff -ruN linux-2.6.11-rc1.orig/drivers/i2c/chips/pcf8574.c linux-2.6.11-rc1/drivers/i2c/chips/pcf8574.c
@@ -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 */
drivers/i2c/chips/pcf8591.c +0 -4
diff -ruN linux-2.6.11-rc1.orig/drivers/i2c/chips/pcf8591.c linux-2.6.11-rc1/drivers/i2c/chips/pcf8591.c
@@ -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 */
drivers/i2c/chips/rtc8564.c +0 -2
diff -ruN linux-2.6.11-rc1.orig/drivers/i2c/chips/rtc8564.c linux-2.6.11-rc1/drivers/i2c/chips/rtc8564.c
@@ -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;
drivers/i2c/chips/smsc47m1.c +0 -5
diff -ruN linux-2.6.11-rc1.orig/drivers/i2c/chips/smsc47m1.c linux-2.6.11-rc1/drivers/i2c/chips/smsc47m1.c
@@ -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
drivers/i2c/chips/w83l785ts.c +0 -7
diff -ruN linux-2.6.11-rc1.orig/drivers/i2c/chips/w83l785ts.c linux-2.6.11-rc1/drivers/i2c/chips/w83l785ts.c
@@ -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);
 
Signature · 2 lines
Jean Delvare
http://khali.linux-fr.org/
#2 lore raw

PATCH 1/1 I2C: Kill i2c_client.id (2/5)

In reply to Jean Delvare

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

drivers/media/video/adv7170.c +1 -4
diff -ruN linux-2.6.11-rc1.orig/drivers/media/video/adv7170.c linux-2.6.11-rc1/drivers/media/video/adv7170.c
@@ -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) {
drivers/media/video/adv7175.c +1 -4
diff -ruN linux-2.6.11-rc1.orig/drivers/media/video/adv7175.c linux-2.6.11-rc1/drivers/media/video/adv7175.c
@@ -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) {
drivers/media/video/bt819.c +3 -8
diff -ruN linux-2.6.11-rc1.orig/drivers/media/video/bt819.c linux-2.6.11-rc1/drivers/media/video/bt819.c
@@ -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,
drivers/media/video/bt856.c +1 -4
diff -ruN linux-2.6.11-rc1.orig/drivers/media/video/bt856.c linux-2.6.11-rc1/drivers/media/video/bt856.c
@@ -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) {
drivers/media/video/bttv-i2c.c +0 -1
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
@@ -336,7 +336,6 @@
 
 static struct i2c_client bttv_i2c_client_template = {
 	I2C_DEVNAME("bttv internal"),
-        .id       = -1,
 };
 
 
drivers/media/video/cx88/cx88-i2c.c +0 -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
@@ -141,7 +141,6 @@
 
 static struct i2c_client cx8800_i2c_client_template = {
         I2C_DEVNAME("cx88xx internal"),
-        .id   = -1,
 };
 
 static char *i2c_devs[128] = {
drivers/media/video/ovcamchip/ovcamchip_core.c +0 -1
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
@@ -422,7 +422,6 @@
 
 static struct i2c_client client_template = {
 	I2C_DEVNAME("(unset)"),
-	.id =		-1,
 	.driver =	&driver,
 };
 
drivers/media/video/saa5246a.c +0 -1
diff -ruN linux-2.6.11-rc1.orig/drivers/media/video/saa5246a.c linux-2.6.11-rc1/drivers/media/video/saa5246a.c
@@ -185,7 +185,6 @@
 };
 
 static struct i2c_client client_template = {
-	.id 		= -1,
 	.driver		= &i2c_driver_videotext,
 	.name		= "(unset)",
 };
drivers/media/video/saa5249.c +0 -1
diff -ruN linux-2.6.11-rc1.orig/drivers/media/video/saa5249.c linux-2.6.11-rc1/drivers/media/video/saa5249.c
@@ -255,7 +255,6 @@
 };
 
 static struct i2c_client client_template = {
-	.id 		= -1,
 	.driver		= &i2c_driver_videotext,
 	.name		= "(unset)",
 };
drivers/media/video/saa7110.c +1 -4
diff -ruN linux-2.6.11-rc1.orig/drivers/media/video/saa7110.c linux-2.6.11-rc1/drivers/media/video/saa7110.c
@@ -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) {
drivers/media/video/saa7111.c +1 -4
diff -ruN linux-2.6.11-rc1.orig/drivers/media/video/saa7111.c linux-2.6.11-rc1/drivers/media/video/saa7111.c
@@ -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) {
drivers/media/video/saa7114.c +1 -4
diff -ruN linux-2.6.11-rc1.orig/drivers/media/video/saa7114.c linux-2.6.11-rc1/drivers/media/video/saa7114.c
@@ -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) {
drivers/media/video/saa7134/saa7134-i2c.c +0 -1
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
@@ -362,7 +362,6 @@
 
 static struct i2c_client saa7134_client_template = {
 	I2C_DEVNAME("saa7134 internal"),
-        .id        = -1,
 };
 
 /* ----------------------------------------------------------- */
drivers/media/video/saa7185.c +1 -4
diff -ruN linux-2.6.11-rc1.orig/drivers/media/video/saa7185.c linux-2.6.11-rc1/drivers/media/video/saa7185.c
@@ -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) {
drivers/media/video/tda7432.c +0 -1
diff -ruN linux-2.6.11-rc1.orig/drivers/media/video/tda7432.c linux-2.6.11-rc1/drivers/media/video/tda7432.c
@@ -528,7 +528,6 @@
 static struct i2c_client client_template =
 {
 	I2C_DEVNAME("tda7432"),
-        .id         = -1,
 	.driver     = &driver,
 };
 
drivers/media/video/tda9840.c +0 -4
diff -ruN linux-2.6.11-rc1.orig/drivers/media/video/tda9840.c linux-2.6.11-rc1/drivers/media/video/tda9840.c
@@ -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;
 
drivers/media/video/tda9875.c +0 -1
diff -ruN linux-2.6.11-rc1.orig/drivers/media/video/tda9875.c linux-2.6.11-rc1/drivers/media/video/tda9875.c
@@ -399,7 +399,6 @@
 static struct i2c_client client_template =
 {
         I2C_DEVNAME("tda9875"),
-        .id        = -1,
         .driver    = &driver,
 };
 
drivers/media/video/tea6415c.c +0 -4
diff -ruN linux-2.6.11-rc1.orig/drivers/media/video/tea6415c.c linux-2.6.11-rc1/drivers/media/video/tea6415c.c
@@ -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;
 
drivers/media/video/tea6420.c +0 -4
diff -ruN linux-2.6.11-rc1.orig/drivers/media/video/tea6420.c linux-2.6.11-rc1/drivers/media/video/tea6420.c
@@ -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;
 
drivers/media/video/tuner-3036.c +0 -1
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
@@ -192,7 +192,6 @@
 
 static struct i2c_client client_template =
 {
-        .id 		= -1,
         .driver		= &i2c_driver_tuner,
 	.name		= "SAB3036",
 };
drivers/media/video/vpx3220.c +8 -11
diff -ruN linux-2.6.11-rc1.orig/drivers/media/video/vpx3220.c linux-2.6.11-rc1/drivers/media/video/vpx3220.c
@@ -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);
Signature · 2 lines
Jean Delvare
http://khali.linux-fr.org/
#3 lore raw

PATCH 1/1 I2C: Kill i2c_client.id (3/5)

In reply to Jean Delvare

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

drivers/acorn/char/i2c.c +1 -1
diff -ruN linux-2.6.11-rc1.orig/drivers/acorn/char/i2c.c linux-2.6.11-rc1/drivers/acorn/char/i2c.c
@@ -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;
drivers/acorn/char/pcf8583.c +0 -1
diff -ruN linux-2.6.11-rc1.orig/drivers/acorn/char/pcf8583.c linux-2.6.11-rc1/drivers/acorn/char/pcf8583.c
@@ -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;
drivers/i2c/i2c-dev.c +0 -1
diff -ruN linux-2.6.11-rc1.orig/drivers/i2c/i2c-dev.c linux-2.6.11-rc1/drivers/i2c/i2c-dev.c
@@ -507,7 +507,6 @@
 
 static struct i2c_client i2cdev_client_template = {
 	.name		= "I2C /dev entry",
-	.id		= 1,
 	.addr		= -1,
 	.driver		= &i2cdev_driver,
 };
drivers/macintosh/therm_windtunnel.c +0 -4
diff -ruN linux-2.6.11-rc1.orig/drivers/macintosh/therm_windtunnel.c linux-2.6.11-rc1/drivers/macintosh/therm_windtunnel.c
@@ -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) )
sound/oss/dmasound/dac3550a.c +0 -4
diff -ruN linux-2.6.11-rc1.orig/sound/oss/dmasound/dac3550a.c linux-2.6.11-rc1/sound/oss/dmasound/dac3550a.c
@@ -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;
sound/ppc/keywest.c +0 -2
diff -ruN linux-2.6.11-rc1.orig/sound/ppc/keywest.c linux-2.6.11-rc1/sound/ppc/keywest.c
@@ -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 */
Signature · 2 lines
Jean Delvare
http://khali.linux-fr.org/
#4 lore raw

PATCH 1/1 I2C: Kill i2c_client.id (4/5)

In reply to Jean Delvare
Quoted 1 line

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

include/linux/i2c.h +1 -1
diff -ruN linux-2.6.11-rc1.orig/include/linux/i2c.h linux-2.6.11-rc1/include/linux/i2c.h
@@ -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	*/
Signature · 2 lines
Jean Delvare
http://khali.linux-fr.org/
#5 lore raw

PATCH 1/1 I2C: Kill i2c_client.id (5/5)

In reply to Jean Delvare
Quoted 1 line

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

Documentation/i2c/porting-clients +3 -3
diff -ruN linux-2.6.11-rc1.orig/Documentation/i2c/porting-clients linux-2.6.11-rc1/Documentation/i2c/porting-clients
@@ -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
Documentation/i2c/writing-clients +0 -4
diff -ruN linux-2.6.11-rc1.orig/Documentation/i2c/writing-clients linux-2.6.11-rc1/Documentation/i2c/writing-clients
@@ -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 */
 
Signature · 2 lines
Jean Delvare
http://khali.linux-fr.org/
#6 lore raw
In reply to Jean Delvare
Quoted 5 lines · Jean Delvare

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