Skip to contentSkip to conversation

i2c: Documentation: fix device matching description

PATCH Ben Dooks 3 participants 3 messages Jun 3, 2008 – Jun 4, 2008 2 messages not in the archive

Subsystems (2)
lore
Share & tools
lore

Ben Dooks

author
#0 lore raw

The matching process described for new style clients in Documentation/i2c/writing-clients is classed as out-of-date as it requires the presence of an .id_table entry in the driver's i2c_driver entry.

Documentation/i2c/writing-clients +14 -4
Index: linux-2.6.26-rc4-quilt3/Documentation/i2c/writing-clients
===================================================================
@@ -25,12 +25,23 @@ routines, and should be zero-initialized
 provide.  A client structure holds device-specific information like the
 driver model device node, and its I2C address.
 
+/* iff driver uses driver model ("new style") binding model: */
+
+static struct i2c_device_id foo_idtable[] = {
+	{ "foo", my_id_for_foo },
+	{ "bar", my_id_for_bar },
+	{ }
+};
+
+MODULE_DEVICE_TABLE(i2c, foo_idtable);
+
 static struct i2c_driver foo_driver = {
 	.driver = {
 		.name	= "foo",
 	},
 
 	/* iff driver uses driver model ("new style") binding model: */
+	.id_table	= foo_ids,
 	.probe		= foo_probe,
 	.remove		= foo_remove,
 
@@ -173,10 +184,9 @@ handle may be used during foo_probe().  
 (zero not a negative status code) it may save the handle and use it until
 foo_remove() returns.  That binding model is used by most Linux drivers.
 
-Drivers match devices when i2c_client.driver_name and the driver name are
-the same; this approach is used in several other busses that don't have
-device typing support in the hardware.  The driver and module name should
-match, so hotplug/coldplug mechanisms will modprobe the driver.
+The probe function is called when an entry in the id_table name field
+matches the device's name. The probe function is passed the entry that
+was matched so that it can support different versions of a device.
 
 
 Device Creation (Standard driver model)
Signature · 8 lines
Ben ([email protected], http://www.fluff.org/)

  'a smiley only costs 4 bytes'

_______________________________________________
i2c mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/i2c

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw
Quoted 36 lines · Ben Dooks

The matching process described for new style clients in Documentation/i2c/writing-clients is classed as out-of-date as it requires the presence of an .id_table entry in the driver's i2c_driver entry.

Index: linux-2.6.26-rc4-quilt3/Documentation/i2c/writing-clients
===================================================================

Documentation/i2c/writing-clients +11 -0
@@ -25,12 +25,23 @@ routines, and should be zero-initialized
 provide.  A client structure holds device-specific information like the
 driver model device node, and its I2C address.
 
+/* iff driver uses driver model ("new style") binding model: */
+
+static struct i2c_device_id foo_idtable[] = {
+	{ "foo", my_id_for_foo },
+	{ "bar", my_id_for_bar },
+	{ }
+};
+
+MODULE_DEVICE_TABLE(i2c, foo_idtable);
+
 static struct i2c_driver foo_driver = {
 	.driver = {
 		.name	= "foo",
 	},
 
 	/* iff driver uses driver model ("new style") binding model: */
+	.id_table	= foo_ids,
 	.probe		= foo_probe,
 	.remove		= foo_remove,
 

Documentation/i2c/writing-clients handle may be used during foo_probe(). · line 189

Quoted 10 lines
Documentation/i2c/writing-clients +3 -4
@@ -173,10 +184,9 @@ handle may be used during foo_probe().  
 (zero not a negative status code) it may save the handle and use it until
 foo_remove() returns.  That binding model is used by most Linux drivers.
 
-Drivers match devices when i2c_client.driver_name and the driver name are
-the same; this approach is used in several other busses that don't have
-device typing support in the hardware.  The driver and module name should
-match, so hotplug/coldplug mechanisms will modprobe the driver.
+The probe function is called when an entry in the id_table name field
+matches the device's name. The probe function is passed the entry that
+was matched so that it can support different versions of a device.

Hmm, that would have read better as:

The probe function is called when an entry in the id_table name field matches the device's name. It is passed the entry that was matched so the driver knows which one in the table matched.

Signature · 8 lines
Ben ([email protected], http://www.fluff.org/)

  'a smiley only costs 4 bytes'

_______________________________________________
i2c mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/i2c

A message that is not in the archive (sent off-list or not yet received): [email protected]

#4 lore raw
Quoted 50 lines · Ben Dooks
Quoted 36 lines · Ben Dooks

The matching process described for new style clients in Documentation/i2c/writing-clients is classed as out-of-date as it requires the presence of an .id_table entry in the driver's i2c_driver entry.

Index: linux-2.6.26-rc4-quilt3/Documentation/i2c/writing-clients
===================================================================

Documentation/i2c/writing-clients +11 -0
@@ -25,12 +25,23 @@ routines, and should be zero-initialized
 provide.  A client structure holds device-specific information like the
 driver model device node, and its I2C address.
 
+/* iff driver uses driver model ("new style") binding model: */
+
+static struct i2c_device_id foo_idtable[] = {
+	{ "foo", my_id_for_foo },
+	{ "bar", my_id_for_bar },
+	{ }
+};
+
+MODULE_DEVICE_TABLE(i2c, foo_idtable);
+
 static struct i2c_driver foo_driver = {
 	.driver = {
 		.name	= "foo",
 	},
 
 	/* iff driver uses driver model ("new style") binding model: */
+	.id_table	= foo_ids,
 	.probe		= foo_probe,
 	.remove		= foo_remove,
 

Documentation/i2c/writing-clients handle may be used during foo_probe(). · line 189

Quoted 10 lines
Documentation/i2c/writing-clients +3 -4
@@ -173,10 +184,9 @@ handle may be used during foo_probe().  
 (zero not a negative status code) it may save the handle and use it until
 foo_remove() returns.  That binding model is used by most Linux drivers.
 
-Drivers match devices when i2c_client.driver_name and the driver name are
-the same; this approach is used in several other busses that don't have
-device typing support in the hardware.  The driver and module name should
-match, so hotplug/coldplug mechanisms will modprobe the driver.
+The probe function is called when an entry in the id_table name field
+matches the device's name. The probe function is passed the entry that
+was matched so that it can support different versions of a device.

Hmm, that would have read better as:

Quoted 3 lines

The probe function is called when an entry in the id_table name field matches the device's name. It is passed the entry that was matched so the driver knows which one in the table matched.

Applied and queued for 2.6.26, if I have more patches to send to Linus (2.6.27 otherwise). Thank you.

Signature · 6 lines
Jean Delvare

_______________________________________________
i2c mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/i2c