Skip to content

Commit f4d3023

Browse files
committed
i2c/aspeed: Set pdev name corresponding to bus
Our device name is derived from the address the peripheral sits at in mmio space; this is not useful for users. Instead name it after the i2c bus. Milton explains why this is important for IRQ debugging: The aspeed i2c controller has an irq per bus and this has been exposed as an irq domain. However, each irq is requested the same device name, leaving one to guess which irq in /proc/interrupts corresponds to which device. While the controller irq number is unique and happens to match, it is not obvious that there is no offset. The driver registers the bus with the numbered bus api, so the global bus number is known an we can predict it before registering. The information that this is from an ast-i2c bus is in the irq controller name or could be found from the matching i2c bus device in sysfs. Excerpt of /proc/interrupts before this patch: 220: 1094 ast-i2c 0 Edge ast-i2c-bus 221: 0 ast-i2c 1 Edge ast-i2c-bus 222: 9438 ast-i2c 2 Edge ast-i2c-bus 223: 26480 ast-i2c 3 Edge ast-i2c-bus New excerpt from /proc/interrupts: 220: 1094 ast-i2c 0 Edge i2c-0 221: 0 ast-i2c 1 Edge i2c-1 222: 9438 ast-i2c 2 Edge i2c-2 223: 26480 ast-i2c 3 Edge i2c-3 224: 0 ast-i2c 4 Edge i2c-4 New example proc/irq/ directory: /proc/irq/222: i2c-2 spurious Signed-off-by: Joel Stanley <[email protected]>
1 parent 7c5a38f commit f4d3023

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

drivers/i2c/busses/i2c-aspeed.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,13 @@ static int ast_i2c_probe_bus(struct platform_device *pdev)
693693
if (ret)
694694
return -ENXIO;
695695

696+
/*
697+
* Set a useful name derived from the bus number; the device tree
698+
* should provide us with one that corresponds to the hardware
699+
* numbering
700+
*/
701+
dev_set_name(&pdev->dev, "i2c-%d", bus_num);
702+
696703
bus->pclk = devm_clk_get(&pdev->dev, NULL);
697704
if (IS_ERR(bus->pclk)) {
698705
dev_dbg(&pdev->dev, "clk_get failed\n");
@@ -711,7 +718,7 @@ static int ast_i2c_probe_bus(struct platform_device *pdev)
711718
}
712719

713720
ret = devm_request_irq(&pdev->dev, bus->irq, ast_i2c_bus_irq,
714-
0, "ast-i2c-bus", bus);
721+
0, dev_name(&pdev->dev), bus);
715722
if (ret) {
716723
dev_err(&pdev->dev, "devm_request_irq failed\n");
717724
return -ENXIO;
@@ -727,8 +734,8 @@ static int ast_i2c_probe_bus(struct platform_device *pdev)
727734
bus->adap.algo_data = bus;
728735
bus->adap.dev.parent = &pdev->dev;
729736
bus->adap.dev.of_node = pdev->dev.of_node;
730-
snprintf(bus->adap.name, sizeof(bus->adap.name), "Aspeed i2c at %p",
731-
bus->base);
737+
snprintf(bus->adap.name, sizeof(bus->adap.name), "Aspeed i2c-%d",
738+
bus_num);
732739

733740
bus->dev = &pdev->dev;
734741

0 commit comments

Comments
 (0)