Skip to contentSkip to conversation

platform/x86: i2c-multi-instantiate: Derive the device name from parent

PATCH In review Heikki Krogerus 2 participants 2 messages Sep 20, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 platform/x86: i2c-multi-instantiate: Derive the device name from parent

When naming the new devices, instead of using the ACPI ID in the name as base, using the parent device's name. That makes it possible to support multiple multi-instance i2c devices of the same type in the same system.

This fixes an issue seen on some Intel Kaby Lake based boards:

sysfs: cannot create duplicate filename '/devices/pci0000:00/0000:00:15.0/i2c_designware.0/i2c-0/i2c-INT3515-tps6598x.0'

Fixes 2336dfadfb1e ("platform/x86: i2c-multi-instantiate: Allow to have same slaves")
---
 drivers/platform/x86/i2c-multi-instantiate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/x86/i2c-multi-instantiate.c +1 -1
index 61fe341a85aa..ea68f6ed66ae 100644
@@ -90,7 +90,7 @@ static int i2c_multi_inst_probe(struct platform_device *pdev)
 	for (i = 0; i < multi->num_clients && inst_data[i].type; i++) {
 		memset(&board_info, 0, sizeof(board_info));
 		strlcpy(board_info.type, inst_data[i].type, I2C_NAME_SIZE);
-		snprintf(name, sizeof(name), "%s-%s.%d", match->id,
+		snprintf(name, sizeof(name), "%s-%s.%d", dev_name(dev),
 			 inst_data[i].type, i);
 		board_info.dev_name = name;
 		switch (inst_data[i].flags & IRQ_RESOURCE_TYPE) {
Signature · 1 line
2.23.0
Reviewed-by on v1 1/1
#1 lore raw

Hi,

Quoted 5 lines · Heikki Krogerus

When naming the new devices, instead of using the ACPI ID in the name as base, using the parent device's name. That makes it possible to support multiple multi-instance i2c devices of the same type in the same system.

Quoted 8 lines

This fixes an issue seen on some Intel Kaby Lake based boards:

sysfs: cannot create duplicate filename '/devices/pci0000:00/0000:00:15.0/i2c_designware.0/i2c-0/i2c-INT3515-tps6598x.0'

Fixes 2336dfadfb1e ("platform/x86: i2c-multi-instantiate: Allow to have same slaves")

Patch looks good to me:

Regards,

Hans

Quoted 18 lines
---
  drivers/platform/x86/i2c-multi-instantiate.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/x86/i2c-multi-instantiate.c +1 -1
index 61fe341a85aa..ea68f6ed66ae 100644
@@ -90,7 +90,7 @@ static int i2c_multi_inst_probe(struct platform_device *pdev)
  	for (i = 0; i < multi->num_clients && inst_data[i].type; i++) {
  		memset(&board_info, 0, sizeof(board_info));
  		strlcpy(board_info.type, inst_data[i].type, I2C_NAME_SIZE);
-		snprintf(name, sizeof(name), "%s-%s.%d", match->id,
+		snprintf(name, sizeof(name), "%s-%s.%d", dev_name(dev),
  			 inst_data[i].type, i);
  		board_info.dev_name = name;
  		switch (inst_data[i].flags & IRQ_RESOURCE_TYPE) {