[SPARC]: Fix bus handling in build_device_resources().

We mistakedly modify 'bus' in the innermost loop. What
should happen is that at each register index iteration,
we start with the same 'bus'.

So preserve it's value at the top level, and use a loop
local variable 'dbus' for iteration.

This bug causes registers other than the first to be
decoded improperly.

Signed-off-by: David S. Miller <davem@davemloft.net>

+8 -6
+4 -3
arch/sparc/kernel/of_device.c
··· 495 495 u32 *reg = (preg + (index * ((na + ns) * 4))); 496 496 struct device_node *dp = op->node; 497 497 struct device_node *pp = p_op->node; 498 - struct of_bus *pbus; 498 + struct of_bus *pbus, *dbus; 499 499 u64 size, result = OF_BAD_ADDR; 500 500 unsigned long flags; 501 501 int dna, dns; ··· 516 516 517 517 dna = na; 518 518 dns = ns; 519 + dbus = bus; 519 520 520 521 while (1) { 521 522 dp = pp; ··· 529 528 pbus = of_match_bus(pp); 530 529 pbus->count_cells(dp, &pna, &pns); 531 530 532 - if (build_one_resource(dp, bus, pbus, addr, 531 + if (build_one_resource(dp, dbus, pbus, addr, 533 532 dna, dns, pna)) 534 533 break; 535 534 536 535 dna = pna; 537 536 dns = pns; 538 - bus = pbus; 537 + dbus = pbus; 539 538 } 540 539 541 540 build_res:
+4 -3
arch/sparc64/kernel/of_device.c
··· 581 581 u32 *reg = (preg + (index * ((na + ns) * 4))); 582 582 struct device_node *dp = op->node; 583 583 struct device_node *pp = p_op->node; 584 - struct of_bus *pbus; 584 + struct of_bus *pbus, *dbus; 585 585 u64 size, result = OF_BAD_ADDR; 586 586 unsigned long flags; 587 587 int dna, dns; ··· 599 599 600 600 dna = na; 601 601 dns = ns; 602 + dbus = bus; 602 603 603 604 while (1) { 604 605 dp = pp; ··· 612 611 pbus = of_match_bus(pp); 613 612 pbus->count_cells(dp, &pna, &pns); 614 613 615 - if (build_one_resource(dp, bus, pbus, addr, 614 + if (build_one_resource(dp, dbus, pbus, addr, 616 615 dna, dns, pna)) 617 616 break; 618 617 619 618 dna = pna; 620 619 dns = pns; 621 - bus = pbus; 620 + dbus = pbus; 622 621 } 623 622 624 623 build_res: