Skip to content

Commit

Permalink
i2c/aspeed: Set pdev name corresponding to bus
Browse files Browse the repository at this point in the history
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 <joel@jms.id.au>
  • Loading branch information
shenki committed Feb 10, 2016
1 parent 7c5a38f commit f4d3023
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions drivers/i2c/busses/i2c-aspeed.c
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,13 @@ static int ast_i2c_probe_bus(struct platform_device *pdev)
if (ret)
return -ENXIO;

/*
* Set a useful name derived from the bus number; the device tree
* should provide us with one that corresponds to the hardware
* numbering
*/
dev_set_name(&pdev->dev, "i2c-%d", bus_num);

bus->pclk = devm_clk_get(&pdev->dev, NULL);
if (IS_ERR(bus->pclk)) {
dev_dbg(&pdev->dev, "clk_get failed\n");
Expand All @@ -711,7 +718,7 @@ static int ast_i2c_probe_bus(struct platform_device *pdev)
}

ret = devm_request_irq(&pdev->dev, bus->irq, ast_i2c_bus_irq,
0, "ast-i2c-bus", bus);
0, dev_name(&pdev->dev), bus);
if (ret) {
dev_err(&pdev->dev, "devm_request_irq failed\n");
return -ENXIO;
Expand All @@ -727,8 +734,8 @@ static int ast_i2c_probe_bus(struct platform_device *pdev)
bus->adap.algo_data = bus;
bus->adap.dev.parent = &pdev->dev;
bus->adap.dev.of_node = pdev->dev.of_node;
snprintf(bus->adap.name, sizeof(bus->adap.name), "Aspeed i2c at %p",
bus->base);
snprintf(bus->adap.name, sizeof(bus->adap.name), "Aspeed i2c-%d",
bus_num);

bus->dev = &pdev->dev;

Expand Down

0 comments on commit f4d3023

Please sign in to comment.