Skip to contentSkip to conversation

i2c: Simplify i2c_device_probe

PATCH In review Jean Delvare 2 participants 2 messages Jun 3, 2008 1 message not in the archive

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

PATCH 1/1 i2c: Simplify i2c_device_probe

i2c_driver.id_table is mandatory now, so we can simplify i2c_device_probe() a bit.

---
 drivers/i2c/i2c-core.c |    9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)
drivers/i2c/i2c-core.c +2 -7
@@ -101,19 +101,14 @@ static int i2c_device_probe(struct devic
 {
 	struct i2c_client	*client = to_i2c_client(dev);
 	struct i2c_driver	*driver = to_i2c_driver(dev->driver);
-	const struct i2c_device_id *id;
 	int status;
 
-	if (!driver->probe)
+	if (!driver->probe || !driver->id_table)
 		return -ENODEV;
 	client->driver = driver;
 	dev_dbg(dev, "probe\n");
 
-	if (driver->id_table)
-		id = i2c_match_id(driver->id_table, client);
-	else
-		id = NULL;
-	status = driver->probe(client, id);
+	status = driver->probe(client, i2c_match_id(driver->id_table, client));
 	if (status)
 		client->driver = NULL;
 	return status;
Signature · 6 lines
Jean Delvare

_______________________________________________
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 22 lines · Jean Delvare

i2c_driver.id_table is mandatory now, so we can simplify i2c_device_probe() a bit.

---
 drivers/i2c/i2c-core.c |    9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)
drivers/i2c/i2c-core.c +1 -2
@@ -101,19 +101,14 @@ static int i2c_device_probe(struct devic
 {
 	struct i2c_client	*client = to_i2c_client(dev);
 	struct i2c_driver	*driver = to_i2c_driver(dev->driver);
-	const struct i2c_device_id *id;
 	int status;
 
-	if (!driver->probe)
+	if (!driver->probe || !driver->id_table)
 		return -ENODEV;
 	client->driver = driver;
 	dev_dbg(dev, "probe\n");

drivers/i2c/i2c-core.c static int i2c_device_probe(struct devic · line 114

Quoted 10 lines
drivers/i2c/i2c-core.c +1 -5
 
-	if (driver->id_table)
-		id = i2c_match_id(driver->id_table, client);
-	else
-		id = NULL;
-	status = driver->probe(client, id);
+	status = driver->probe(client, i2c_match_id(driver->id_table, client));
 	if (status)
 		client->driver = NULL;
 	return status;

Looks ok, will give it a test tommorow if possible.

Quoted 3 lines
Signature · 2 lines
-- 
Jean Delvare
Signature · 11 lines
-- 
Ben

Q:      What's a light-year?
A:      One-third less calories than a regular year.


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