Skip to content

Commit

Permalink
i2c: Keep client->driver and client->dev.driver in sync
Browse files Browse the repository at this point in the history
Ensure that client->driver is set to NULL if the probe() returns an
error (this keeps client->driver and client->dev.driver in sync).

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Acked-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
  • Loading branch information
Hans Verkuil authored and Jean Delvare committed Mar 12, 2008
1 parent 5edc68b commit 50c3304
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion drivers/i2c/i2c-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,16 @@ static int i2c_device_probe(struct device *dev)
{
struct i2c_client *client = to_i2c_client(dev);
struct i2c_driver *driver = to_i2c_driver(dev->driver);
int status;

if (!driver->probe)
return -ENODEV;
client->driver = driver;
dev_dbg(dev, "probe\n");
return driver->probe(client);
status = driver->probe(client);
if (status)
client->driver = NULL;
return status;
}

static int i2c_device_remove(struct device *dev)
Expand Down

0 comments on commit 50c3304

Please sign in to comment.