Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion arch/arm/boot/dts/ast2400.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@
interrupts = <4>;
};

i2c5: i2c-bus@0x180 {
i2c5: i2c-bus@180 {
#address-cells = <1>;
#size-cells = <0>;
reg = <0x180 0x40>;
Expand Down
28 changes: 20 additions & 8 deletions drivers/i2c/busses/i2c-aspeed.c
Original file line number Diff line number Diff line change
Expand Up @@ -693,13 +693,6 @@ 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 Down Expand Up @@ -828,7 +821,26 @@ static int ast_i2c_probe_controller(struct platform_device *pdev)
controller->irq);

for_each_child_of_node(pdev->dev.of_node, np) {
of_platform_device_create(np, NULL, &pdev->dev);
int ret;
u32 bus_num;
char bus_id[sizeof("i2c-12345")];

/*
* Set a useful name derived from the bus number; the device
* tree should provide us with one that corresponds to the
* hardware numbering. If the property is missing the
* probe would fail so just skip it here.
*/

ret = of_property_read_u32(np, "bus", &bus_num);
if (ret)
continue;

ret = snprintf(bus_id, sizeof(bus_id), "i2c-%u", bus_num);
if (ret >= sizeof(bus_id))
continue;

of_platform_device_create(np, bus_id, &pdev->dev);
of_node_put(np);
}

Expand Down