Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

i2c: Keep client->driver and client->dev.driver in sync

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>

authored by

Hans Verkuil and committed by
Jean Delvare
50c3304a 5edc68b8

+5 -1
+5 -1
drivers/i2c/i2c-core.c
··· 90 90 { 91 91 struct i2c_client *client = to_i2c_client(dev); 92 92 struct i2c_driver *driver = to_i2c_driver(dev->driver); 93 + int status; 93 94 94 95 if (!driver->probe) 95 96 return -ENODEV; 96 97 client->driver = driver; 97 98 dev_dbg(dev, "probe\n"); 98 - return driver->probe(client); 99 + status = driver->probe(client); 100 + if (status) 101 + client->driver = NULL; 102 + return status; 99 103 } 100 104 101 105 static int i2c_device_remove(struct device *dev)