summaryrefslogtreecommitdiff
path: root/drivers/i2c/i2c-core.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/i2c/i2c-core.c')
-rw-r--r--drivers/i2c/i2c-core.c46
1 files changed, 13 insertions, 33 deletions
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index d74c0b3..3be58f8 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -248,17 +248,16 @@ 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);
dev_dbg(dev, "probe\n");
- 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);
}
return status;
}
@@ -280,9 +279,10 @@ static int i2c_device_remove(struct device *dev)
dev->driver = NULL;
status = 0;
}
- if (status == 0)
+ if (status == 0) {
+ client->driver = NULL;
i2c_set_clientdata(client, NULL);
- acpi_dev_pm_detach(&client->dev, true);
+ }
return status;
}
@@ -615,22 +615,6 @@ void i2c_unlock_adapter(struct i2c_adapter *adapter)
}
EXPORT_SYMBOL_GPL(i2c_unlock_adapter);
-static void i2c_dev_set_name(struct i2c_adapter *adap,
- struct i2c_client *client)
-{
- struct acpi_device *adev = ACPI_COMPANION(&client->dev);
-
- if (adev) {
- dev_set_name(&client->dev, "i2c-%s", acpi_dev_name(adev));
- return;
- }
-
- /* For 10-bit clients, add an arbitrary offset to avoid collisions */
- dev_set_name(&client->dev, "%d-%04x", i2c_adapter_id(adap),
- client->addr | ((client->flags & I2C_CLIENT_TEN)
- ? 0xa000 : 0));
-}
-
/**
* i2c_new_device - instantiate an i2c device
* @adap: the adapter managing the device
@@ -687,9 +671,12 @@ i2c_new_device(struct i2c_adapter *adap, struct i2c_board_info const *info)
client->dev.bus = &i2c_bus_type;
client->dev.type = &i2c_client_type;
client->dev.of_node = info->of_node;
- ACPI_COMPANION_SET(&client->dev, info->acpi_node.companion);
+ ACPI_HANDLE_SET(&client->dev, info->acpi_node.handle);
- i2c_dev_set_name(adap, client);
+ /* For 10-bit clients, add an arbitrary offset to avoid collisions */
+ dev_set_name(&client->dev, "%d-%04x", i2c_adapter_id(adap),
+ client->addr | ((client->flags & I2C_CLIENT_TEN)
+ ? 0xa000 : 0));
status = device_register(&client->dev);
if (status)
goto out_err;
@@ -1113,7 +1100,7 @@ static acpi_status acpi_i2c_add_device(acpi_handle handle, u32 level,
return AE_OK;
memset(&info, 0, sizeof(info));
- info.acpi_node.companion = adev;
+ info.acpi_node.handle = handle;
info.irq = -1;
INIT_LIST_HEAD(&resource_list);
@@ -1124,10 +1111,8 @@ static acpi_status acpi_i2c_add_device(acpi_handle handle, u32 level,
if (ret < 0 || !info.addr)
return AE_OK;
- adev->power.flags.ignore_parent = true;
strlcpy(info.type, dev_name(&adev->dev), sizeof(info.type));
if (!i2c_new_device(adapter, &info)) {
- adev->power.flags.ignore_parent = false;
dev_err(&adapter->dev,
"failed to add I2C device %s from ACPI\n",
dev_name(&adev->dev));
@@ -1624,14 +1609,9 @@ 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;
- driver = to_i2c_driver(client->dev.driver);
- if (driver->command)
- driver->command(client, arg->cmd, arg->arg);
+ if (client && client->driver && client->driver->command)
+ client->driver->command(client, arg->cmd, arg->arg);
return 0;
}