diff options
-rw-r--r-- | drivers/i2c/i2c-core.c | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index f74af33f5ddc..bc9a294c07f7 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c | |||
@@ -618,6 +618,22 @@ void i2c_unlock_adapter(struct i2c_adapter *adapter) | |||
618 | } | 618 | } |
619 | EXPORT_SYMBOL_GPL(i2c_unlock_adapter); | 619 | EXPORT_SYMBOL_GPL(i2c_unlock_adapter); |
620 | 620 | ||
621 | static void i2c_dev_set_name(struct i2c_adapter *adap, | ||
622 | struct i2c_client *client) | ||
623 | { | ||
624 | struct acpi_device *adev = ACPI_COMPANION(&client->dev); | ||
625 | |||
626 | if (adev) { | ||
627 | dev_set_name(&client->dev, "i2c-%s", acpi_dev_name(adev)); | ||
628 | return; | ||
629 | } | ||
630 | |||
631 | /* For 10-bit clients, add an arbitrary offset to avoid collisions */ | ||
632 | dev_set_name(&client->dev, "%d-%04x", i2c_adapter_id(adap), | ||
633 | client->addr | ((client->flags & I2C_CLIENT_TEN) | ||
634 | ? 0xa000 : 0)); | ||
635 | } | ||
636 | |||
621 | /** | 637 | /** |
622 | * i2c_new_device - instantiate an i2c device | 638 | * i2c_new_device - instantiate an i2c device |
623 | * @adap: the adapter managing the device | 639 | * @adap: the adapter managing the device |
@@ -676,10 +692,7 @@ i2c_new_device(struct i2c_adapter *adap, struct i2c_board_info const *info) | |||
676 | client->dev.of_node = info->of_node; | 692 | client->dev.of_node = info->of_node; |
677 | ACPI_COMPANION_SET(&client->dev, info->acpi_node.companion); | 693 | ACPI_COMPANION_SET(&client->dev, info->acpi_node.companion); |
678 | 694 | ||
679 | /* For 10-bit clients, add an arbitrary offset to avoid collisions */ | 695 | i2c_dev_set_name(adap, client); |
680 | dev_set_name(&client->dev, "%d-%04x", i2c_adapter_id(adap), | ||
681 | client->addr | ((client->flags & I2C_CLIENT_TEN) | ||
682 | ? 0xa000 : 0)); | ||
683 | status = device_register(&client->dev); | 696 | status = device_register(&client->dev); |
684 | if (status) | 697 | if (status) |
685 | goto out_err; | 698 | goto out_err; |