Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

MIPS: AR7: Make ar7_register_devices much more durable

[Ralf: Fixed up the rejects and changed all the new printk(KERN_...); to
pr_xxx() as suggested by Wu.]

Signed-off-by: Alexander Clouter <alex@digriz.org.uk>
To: linux-mips@linux-mips.org
Patchwork: http://patchwork.linux-mips.org/patch/920/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>

authored by

Alexander Clouter and committed by
Ralf Baechle
7084338e 632b629c

+82 -67
+82 -67
arch/mips/ar7/platform.c
··· 529 529 /***************************************************************************** 530 530 * Init 531 531 ****************************************************************************/ 532 - static int __init ar7_register_devices(void) 532 + static int __init ar7_register_uarts(void) 533 533 { 534 - u16 chip_id; 535 - int res; 536 - u32 *bootcr, val; 537 534 #ifdef CONFIG_SERIAL_8250 538 - static struct uart_port uart_port[2] __initdata; 535 + static struct uart_port uart_port __initdata; 539 536 struct clk *bus_clk; 537 + int res; 540 538 541 - memset(uart_port, 0, sizeof(struct uart_port) * 2); 539 + memset(&uart_port, 0, sizeof(struct uart_port)); 542 540 543 541 bus_clk = clk_get(NULL, "bus"); 544 542 if (IS_ERR(bus_clk)) 545 543 panic("unable to get bus clk\n"); 546 544 547 - uart_port[0].type = PORT_16550A; 548 - uart_port[0].line = 0; 549 - uart_port[0].irq = AR7_IRQ_UART0; 550 - uart_port[0].uartclk = clk_get_rate(bus_clk) / 2; 551 - uart_port[0].iotype = UPIO_MEM32; 552 - uart_port[0].mapbase = AR7_REGS_UART0; 553 - uart_port[0].membase = ioremap(uart_port[0].mapbase, 256); 554 - uart_port[0].regshift = 2; 555 - res = early_serial_setup(&uart_port[0]); 545 + uart_port.type = PORT_16550A; 546 + uart_port.uartclk = clk_get_rate(bus_clk) / 2; 547 + uart_port.iotype = UPIO_MEM32; 548 + uart_port.regshift = 2; 549 + 550 + uart_port.line = 0; 551 + uart_port.irq = AR7_IRQ_UART0; 552 + uart_port.mapbase = AR7_REGS_UART0; 553 + uart_port.membase = ioremap(uart_port.mapbase, 256); 554 + 555 + res = early_serial_setup(&uart_port); 556 556 if (res) 557 557 return res; 558 558 559 559 /* Only TNETD73xx have a second serial port */ 560 560 if (ar7_has_second_uart()) { 561 - uart_port[1].type = PORT_16550A; 562 - uart_port[1].line = 1; 563 - uart_port[1].irq = AR7_IRQ_UART1; 564 - uart_port[1].uartclk = clk_get_rate(bus_clk) / 2; 565 - uart_port[1].iotype = UPIO_MEM32; 566 - uart_port[1].mapbase = UR8_REGS_UART1; 567 - uart_port[1].membase = ioremap(uart_port[1].mapbase, 256); 568 - uart_port[1].regshift = 2; 569 - res = early_serial_setup(&uart_port[1]); 561 + uart_port.line = 1; 562 + uart_port.irq = AR7_IRQ_UART1; 563 + uart_port.mapbase = UR8_REGS_UART1; 564 + uart_port.membase = ioremap(uart_port.mapbase, 256); 565 + 566 + res = early_serial_setup(&uart_port); 570 567 if (res) 571 568 return res; 572 569 } 573 - #endif /* CONFIG_SERIAL_8250 */ 570 + #endif 571 + 572 + return 0; 573 + } 574 + 575 + static int __init ar7_register_devices(void) 576 + { 577 + void __iomem *bootcr; 578 + u32 val; 579 + u16 chip_id; 580 + int res; 581 + 582 + res = ar7_register_uarts(); 583 + if (res) 584 + pr_err("unable to setup uart(s): %d\n", res); 585 + 574 586 res = platform_device_register(&physmap_flash); 575 587 if (res) 576 - return res; 588 + pr_warning("unable to register physmap-flash: %d\n", res); 577 589 578 590 ar7_device_disable(vlynq_low_data.reset_bit); 579 591 res = platform_device_register(&vlynq_low); 580 592 if (res) 581 - return res; 593 + pr_warning("unable to register vlynq-low: %d\n", res); 582 594 583 595 if (ar7_has_high_vlynq()) { 584 596 ar7_device_disable(vlynq_high_data.reset_bit); 585 597 res = platform_device_register(&vlynq_high); 586 598 if (res) 587 - return res; 599 + pr_warning("unable to register vlynq-high: %d\n", res); 588 600 } 589 601 590 602 if (ar7_has_high_cpmac()) { 591 - res = fixed_phy_add(PHY_POLL, cpmac_high.id, &fixed_phy_status); 592 - if (res && res != -ENODEV) 593 - return res; 594 - cpmac_get_mac(1, cpmac_high_data.dev_addr); 595 - res = platform_device_register(&cpmac_high); 596 - if (res) 597 - return res; 598 - } else { 603 + if (!res) { 604 + cpmac_get_mac(1, cpmac_high_data.dev_addr); 605 + 606 + res = platform_device_register(&cpmac_high); 607 + if (res) 608 + pr_warning("unable to register cpmac-high: %d\n", res); 609 + } else 610 + pr_warning("unable to add cpmac-high phy: %d\n", res); 611 + } else 599 612 cpmac_low_data.phy_mask = 0xffffffff; 600 - } 601 613 602 614 res = fixed_phy_add(PHY_POLL, cpmac_low.id, &fixed_phy_status); 603 - if (res && res != -ENODEV) 604 - return res; 605 - 606 - cpmac_get_mac(0, cpmac_low_data.dev_addr); 607 - res = platform_device_register(&cpmac_low); 608 - if (res) 609 - return res; 615 + if (!res) { 616 + cpmac_get_mac(0, cpmac_low_data.dev_addr); 617 + res = platform_device_register(&cpmac_low); 618 + if (res) 619 + pr_warning("unable to register cpmac-low: %d\n", res); 620 + } else 621 + pr_warning("unable to add cpmac-low phy: %d\n", res); 610 622 611 623 detect_leds(); 612 624 res = platform_device_register(&ar7_gpio_leds); 613 625 if (res) 614 - return res; 626 + pr_warning("unable to register leds: %d\n", res); 615 627 616 628 res = platform_device_register(&ar7_udc); 617 - 618 - chip_id = ar7_chip_id(); 619 - switch (chip_id) { 620 - case AR7_CHIP_7100: 621 - case AR7_CHIP_7200: 622 - ar7_wdt_res.start = AR7_REGS_WDT; 623 - break; 624 - case AR7_CHIP_7300: 625 - ar7_wdt_res.start = UR8_REGS_WDT; 626 - break; 627 - default: 628 - break; 629 - } 630 - 631 - ar7_wdt_res.end = ar7_wdt_res.start + 0x20; 632 - 633 - bootcr = (u32 *)ioremap_nocache(AR7_REGS_DCL, 4); 634 - val = *bootcr; 635 - iounmap(bootcr); 629 + if (res) 630 + pr_warning("unable to register usb slave: %d\n", res); 636 631 637 632 /* Register watchdog only if enabled in hardware */ 638 - if (val & AR7_WDT_HW_ENA) 639 - res = platform_device_register(&ar7_wdt); 633 + bootcr = ioremap_nocache(AR7_REGS_DCL, 4); 634 + val = readl(bootcr); 635 + iounmap(bootcr); 636 + if (val & AR7_WDT_HW_ENA) { 637 + chip_id = ar7_chip_id(); 638 + switch (chip_id) { 639 + case AR7_CHIP_7100: 640 + case AR7_CHIP_7200: 641 + ar7_wdt_res.start = AR7_REGS_WDT; 642 + break; 643 + case AR7_CHIP_7300: 644 + ar7_wdt_res.start = UR8_REGS_WDT; 645 + break; 646 + default: 647 + break; 648 + } 640 649 641 - return res; 650 + ar7_wdt_res.end = ar7_wdt_res.start + 0x20; 651 + res = platform_device_register(&ar7_wdt); 652 + if (res) 653 + pr_warning("unable to register watchdog: %d\n", res); 654 + } 655 + 656 + return 0; 642 657 } 643 658 arch_initcall(ar7_register_devices);