diff options
Diffstat (limited to 'drivers/i2c/i2c-core.c')
-rw-r--r-- | drivers/i2c/i2c-core.c | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index 5923cfa390c8..d74c0b34248e 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c | |||
@@ -615,6 +615,22 @@ void i2c_unlock_adapter(struct i2c_adapter *adapter) | |||
615 | } | 615 | } |
616 | EXPORT_SYMBOL_GPL(i2c_unlock_adapter); | 616 | EXPORT_SYMBOL_GPL(i2c_unlock_adapter); |
617 | 617 | ||
618 | static void i2c_dev_set_name(struct i2c_adapter *adap, | ||
619 | struct i2c_client *client) | ||
620 | { | ||
621 | struct acpi_device *adev = ACPI_COMPANION(&client->dev); | ||
622 | |||
623 | if (adev) { | ||
624 | dev_set_name(&client->dev, "i2c-%s", acpi_dev_name(adev)); | ||
625 | return; | ||
626 | } | ||
627 | |||
628 | /* For 10-bit clients, add an arbitrary offset to avoid collisions */ | ||
629 | dev_set_name(&client->dev, "%d-%04x", i2c_adapter_id(adap), | ||
630 | client->addr | ((client->flags & I2C_CLIENT_TEN) | ||
631 | ? 0xa000 : 0)); | ||
632 | } | ||
633 | |||
618 | /** | 634 | /** |
619 | * i2c_new_device - instantiate an i2c device | 635 | * i2c_new_device - instantiate an i2c device |
620 | * @adap: the adapter managing the device | 636 | * @adap: the adapter managing the device |
@@ -671,12 +687,9 @@ i2c_new_device(struct i2c_adapter *adap, struct i2c_board_info const *info) | |||
671 | client->dev.bus = &i2c_bus_type; | 687 | client->dev.bus = &i2c_bus_type; |
672 | client->dev.type = &i2c_client_type; | 688 | client->dev.type = &i2c_client_type; |
673 | client->dev.of_node = info->of_node; | 689 | client->dev.of_node = info->of_node; |
674 | ACPI_HANDLE_SET(&client->dev, info->acpi_node.handle); | 690 | ACPI_COMPANION_SET(&client->dev, info->acpi_node.companion); |
675 | 691 | ||
676 | /* For 10-bit clients, add an arbitrary offset to avoid collisions */ | 692 | i2c_dev_set_name(adap, client); |
677 | dev_set_name(&client->dev, "%d-%04x", i2c_adapter_id(adap), | ||
678 | client->addr | ((client->flags & I2C_CLIENT_TEN) | ||
679 | ? 0xa000 : 0)); | ||
680 | status = device_register(&client->dev); | 693 | status = device_register(&client->dev); |
681 | if (status) | 694 | if (status) |
682 | goto out_err; | 695 | goto out_err; |
@@ -1100,7 +1113,7 @@ static acpi_status acpi_i2c_add_device(acpi_handle handle, u32 level, | |||
1100 | return AE_OK; | 1113 | return AE_OK; |
1101 | 1114 | ||
1102 | memset(&info, 0, sizeof(info)); | 1115 | memset(&info, 0, sizeof(info)); |
1103 | info.acpi_node.handle = handle; | 1116 | info.acpi_node.companion = adev; |
1104 | info.irq = -1; | 1117 | info.irq = -1; |
1105 | 1118 | ||
1106 | INIT_LIST_HEAD(&resource_list); | 1119 | INIT_LIST_HEAD(&resource_list); |