X-Git-Url: https://git.karo-electronics.de/?a=blobdiff_plain;f=drivers%2Fi2c%2Fi2c-core.c;h=5923cfa390c86de6528559c229ace0a4b39b402c;hb=022a0e218704fe48eb15b7d0d0072cfaec5f2a82;hp=75ba8608383e4b1d26e65a389f099f7028e7b733;hpb=5add515830646d3a994f515c61f5bebe2b5bb40a;p=karo-tx-linux.git diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index 75ba8608383e..5923cfa390c8 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c @@ -248,7 +248,7 @@ static int i2c_device_probe(struct device *dev) driver = to_i2c_driver(dev->driver); if (!driver->probe || !driver->id_table) return -ENODEV; - client->driver = driver; + if (!device_can_wakeup(&client->dev)) device_init_wakeup(&client->dev, client->flags & I2C_CLIENT_WAKE); @@ -257,7 +257,6 @@ static int i2c_device_probe(struct device *dev) acpi_dev_pm_attach(&client->dev, true); status = driver->probe(client, i2c_match_id(driver->id_table, client)); if (status) { - client->driver = NULL; i2c_set_clientdata(client, NULL); acpi_dev_pm_detach(&client->dev, true); } @@ -281,10 +280,8 @@ static int i2c_device_remove(struct device *dev) dev->driver = NULL; status = 0; } - if (status == 0) { - client->driver = NULL; + if (status == 0) i2c_set_clientdata(client, NULL); - } acpi_dev_pm_detach(&client->dev, true); return status; } @@ -1614,9 +1611,14 @@ static int i2c_cmd(struct device *dev, void *_arg) { struct i2c_client *client = i2c_verify_client(dev); struct i2c_cmd_arg *arg = _arg; + struct i2c_driver *driver; + + if (!client || !client->dev.driver) + return 0; - if (client && client->driver && client->driver->command) - client->driver->command(client, arg->cmd, arg->arg); + driver = to_i2c_driver(client->dev.driver); + if (driver->command) + driver->command(client, arg->cmd, arg->arg); return 0; }