Merge remote-tracking branches 'spi/topic/sunxi', 'spi/topic/tegra114', 'spi/topic...
[firefly-linux-kernel-4.4.55.git] / drivers / i2c / i2c-core.c
index fb84ff36bd69012240f814002b98627f1a72194e..5fb80b8962a2ad7d8e78dcee01df68cb639d3602 100644 (file)
@@ -104,6 +104,11 @@ static int i2c_device_match(struct device *dev, struct device_driver *drv)
 static int i2c_device_uevent(struct device *dev, struct kobj_uevent_env *env)
 {
        struct i2c_client       *client = to_i2c_client(dev);
+       int rc;
+
+       rc = acpi_device_uevent_modalias(dev, env);
+       if (rc != -ENODEV)
+               return rc;
 
        if (add_uevent_var(env, "MODALIAS=%s%s",
                           I2C_MODULE_PREFIX, client->name))
@@ -256,10 +261,9 @@ 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) {
-               i2c_set_clientdata(client, NULL);
+       if (status)
                acpi_dev_pm_detach(&client->dev, true);
-       }
+
        return status;
 }
 
@@ -267,7 +271,7 @@ static int i2c_device_remove(struct device *dev)
 {
        struct i2c_client       *client = i2c_verify_client(dev);
        struct i2c_driver       *driver;
-       int                     status;
+       int status = 0;
 
        if (!client || !dev->driver)
                return 0;
@@ -276,12 +280,8 @@ static int i2c_device_remove(struct device *dev)
        if (driver->remove) {
                dev_dbg(dev, "remove\n");
                status = driver->remove(client);
-       } else {
-               dev->driver = NULL;
-               status = 0;
        }
-       if (status == 0)
-               i2c_set_clientdata(client, NULL);
+
        acpi_dev_pm_detach(&client->dev, true);
        return status;
 }
@@ -409,6 +409,12 @@ static ssize_t
 show_modalias(struct device *dev, struct device_attribute *attr, char *buf)
 {
        struct i2c_client *client = to_i2c_client(dev);
+       int len;
+
+       len = acpi_device_modalias(dev, buf, PAGE_SIZE -1);
+       if (len != -ENODEV)
+               return len;
+
        return sprintf(buf, "%s%s\n", I2C_MODULE_PREFIX, client->name);
 }