Skip to contentSkip to conversation

i2c: xiic: Make bus names unique

PATCH Applied Robert Hancock 3 participants 4 messages Jan 27, 2022 – Mar 2, 2022

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

PATCH 1/1 i2c: xiic: Make bus names unique

This driver is for an FPGA logic core, so there can be arbitrarily many instances of the bus on a given system. Previously all of the I2C bus names were "xiic-i2c" which caused issues with lm_sensors when trying to map human-readable names to sensor inputs because it could not properly distinguish the busses, for example. Append the platform device name to the I2C bus name so it is unique between different instances.

Fixes e1d5b6598cdc ("i2c: Add support for Xilinx XPS IIC Bus Interface")
---
 drivers/i2c/busses/i2c-xiic.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/i2c/busses/i2c-xiic.c +2 -1
index eb789cfb9973..ffefe3c482e9 100644
@@ -734,7 +734,6 @@ static const struct i2c_adapter_quirks xiic_quirks = {
 
 static const struct i2c_adapter xiic_adapter = {
 	.owner = THIS_MODULE,
-	.name = DRIVER_NAME,
 	.class = I2C_CLASS_DEPRECATED,
 	.algo = &xiic_algorithm,
 	.quirks = &xiic_quirks,
@@ -771,6 +770,8 @@ static int xiic_i2c_probe(struct platform_device *pdev)
 	i2c_set_adapdata(&i2c->adap, i2c);
 	i2c->adap.dev.parent = &pdev->dev;
 	i2c->adap.dev.of_node = pdev->dev.of_node;
+	snprintf(i2c->adap.name, sizeof(i2c->adap.name),
+		 DRIVER_NAME " %s", pdev->name);
 
 	mutex_init(&i2c->lock);
 
Signature · 1 line
2.31.1
#1 lore raw
Quoted 9 lines · Robert Hancock

This driver is for an FPGA logic core, so there can be arbitrarily many instances of the bus on a given system. Previously all of the I2C bus names were "xiic-i2c" which caused issues with lm_sensors when trying to map human-readable names to sensor inputs because it could not properly distinguish the busses, for example. Append the platform device name to the I2C bus name so it is unique between different instances.

Fixes e1d5b6598cdc ("i2c: Add support for Xilinx XPS IIC Bus Interface")

Michal, is this okay with you?

Tested-by
#2 lore raw
Quoted 8 lines · Wolfram Sang
Quoted 7 lines · Robert Hancock

This driver is for an FPGA logic core, so there can be arbitrarily many instances of the bus on a given system. Previously all of the I2C bus names were "xiic-i2c" which caused issues with lm_sensors when trying to map human-readable names to sensor inputs because it could not properly distinguish the busses, for example. Append the platform device name to the I2C bus name so it is unique between different instances.

Quoted 5 lines
Quoted 2 lines
Fixes e1d5b6598cdc ("i2c: Add support for Xilinx XPS IIC Bus Interface")

Michal, is this okay with you?

Origin state

~# cat /sys/class/i2c-adapter/i2c-0/name
xiic-i2c

new state.

~# cat /sys/class/i2c-adapter/i2c-0/name
xiic-i2c 40800000.i2c

I am fine with it.

Thanks,
Michal

Applied
#3 lore raw
In reply to Robert Hancock
Quoted 9 lines · Robert Hancock

This driver is for an FPGA logic core, so there can be arbitrarily many instances of the bus on a given system. Previously all of the I2C bus names were "xiic-i2c" which caused issues with lm_sensors when trying to map human-readable names to sensor inputs because it could not properly distinguish the busses, for example. Append the platform device name to the I2C bus name so it is unique between different instances.

Fixes e1d5b6598cdc ("i2c: Add support for Xilinx XPS IIC Bus Interface")

Applied to for-next, thanks!