All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 3/3] MIPS: AR7 make ar7_register_devices much more durable
@ 2010-01-31 19:39 Alexander Clouter
  2010-02-01  6:32 ` Wu Zhangjin
  2010-02-01 19:02 ` Ralf Baechle
  0 siblings, 2 replies; 4+ messages in thread
From: Alexander Clouter @ 2010-01-31 19:39 UTC (permalink / raw)
  To: linux-mips

MIPS: AR7 make ar7_register_devices much more durable

Signed-off-by: Alexander Clouter <alex@digriz.org.uk>
---
 arch/mips/ar7/platform.c |  157 +++++++++++++++++++++++++---------------------
 1 files changed, 86 insertions(+), 71 deletions(-)

diff --git a/arch/mips/ar7/platform.c b/arch/mips/ar7/platform.c
index 65facec..e654e73 100644
--- a/arch/mips/ar7/platform.c
+++ b/arch/mips/ar7/platform.c
@@ -529,115 +529,130 @@ static struct platform_device ar7_wdt = {
 /*****************************************************************************
  * Init
  ****************************************************************************/
-static int __init ar7_register_devices(void)
+static int __init ar7_register_uarts(void)
 {
-	u16 chip_id;
-	int res;
-	u32 *bootcr, val;
 #ifdef CONFIG_SERIAL_8250
-	static struct uart_port uart_port[2] __initdata;
+	static struct uart_port uart_port __initdata;
 	struct clk *bus_clk;
+	int res;
 
-	memset(uart_port, 0, sizeof(struct uart_port) * 2);
-
+	memset(&uart_port, 0, sizeof(struct uart_port));
+ 
 	bus_clk = clk_get(NULL, "bus");
 	if (IS_ERR(bus_clk))
 		panic("unable to get bus clk\n");
-
-	uart_port[0].type	= PORT_16550A;
-	uart_port[0].line	= 0;
-	uart_port[0].irq	= AR7_IRQ_UART0;
-	uart_port[0].uartclk	= clk_get_rate(bus_clk) / 2;
-	uart_port[0].iotype	= UPIO_MEM32;
-	uart_port[0].mapbase	= AR7_REGS_UART0;
-	uart_port[0].membase	= ioremap(uart_port[0].mapbase, 256);
-	uart_port[0].regshift	= 2;
-	res = early_serial_setup(&uart_port[0]);
+ 
+	uart_port.type		= PORT_16550A;
+	uart_port.uartclk	= clk_get_rate(bus_clk) / 2;
+	uart_port.iotype	= UPIO_MEM32;
+	uart_port.regshift	= 2;
+
+	uart_port.line		= 0;
+	uart_port.irq		= AR7_IRQ_UART0;
+	uart_port.mapbase	= AR7_REGS_UART0;
+	uart_port.membase	= ioremap(uart_port.mapbase, 256);
+
+	res = early_serial_setup(&uart_port);
 	if (res)
 		return res;
-
+ 
 	/* Only TNETD73xx have a second serial port */
 	if (ar7_has_second_uart()) {
-		uart_port[1].type	= PORT_16550A;
-		uart_port[1].line	= 1;
-		uart_port[1].irq	= AR7_IRQ_UART1;
-		uart_port[1].uartclk	= clk_get_rate(bus_clk) / 2;
-		uart_port[1].iotype	= UPIO_MEM32;
-		uart_port[1].mapbase	= UR8_REGS_UART1;
-		uart_port[1].membase 	= ioremap(uart_port[1].mapbase, 256);
-		uart_port[1].regshift	= 2;
-		res = early_serial_setup(&uart_port[1]);
+		uart_port.line		= 1;
+		uart_port.irq		= AR7_IRQ_UART1;
+		uart_port.mapbase	= UR8_REGS_UART1;
+		uart_port.membase	= ioremap(uart_port.mapbase, 256);
+
+		res = early_serial_setup(&uart_port);
 		if (res)
 			return res;
-	}
-#endif /* CONFIG_SERIAL_8250 */
+ 	}
+#endif
+
+	return 0;
+}
+
+static int __init ar7_register_devices(void)
+{
+	void __iomem *bootcr;
+	u32 val;
+	u16 chip_id;
+	int res;
+
+	res = ar7_register_uarts();
+	if (res)
+		printk(KERN_ERR "unable to setup uart(s): %d\n", res);
+
 	res = platform_device_register(&physmap_flash);
 	if (res)
-		return res;
+		printk(KERN_WARNING "unable to register physmap-flash: %d\n", res);
 
 	ar7_device_disable(vlynq_low_data.reset_bit);
 	res = platform_device_register(&vlynq_low);
 	if (res)
-		return res;
+		printk(KERN_WARNING "unable to register vlynq-low: %d\n", res);
 
 	if (ar7_has_high_vlynq()) {
 		ar7_device_disable(vlynq_high_data.reset_bit);
 		res = platform_device_register(&vlynq_high);
 		if (res)
-			return res;
+			printk(KERN_WARNING "unable to register vlynq-high: %d\n", res);
 	}
 
 	if (ar7_has_high_cpmac()) {
-		res = fixed_phy_add(PHY_POLL, cpmac_high.id, &fixed_phy_status);
-		if (res && res != -ENODEV)
-			return res;
-		cpmac_get_mac(1, cpmac_high_data.dev_addr);
-		res = platform_device_register(&cpmac_high);
-		if (res)
-			return res;
-	} else {
+		if (!res) {
+			cpmac_get_mac(1, cpmac_high_data.dev_addr);
+
+			res = platform_device_register(&cpmac_high);
+			if (res)
+				printk(KERN_WARNING "unable to register cpmac-high: %d\n", res);
+		} else
+			printk(KERN_WARNING "unable to add cpmac-high phy: %d\n", res);
+	} else
 		cpmac_low_data.phy_mask = 0xffffffff;
-	}
 
 	res = fixed_phy_add(PHY_POLL, cpmac_low.id, &fixed_phy_status);
-	if (res && res != -ENODEV)
-		return res;
-
-	cpmac_get_mac(0, cpmac_low_data.dev_addr);
-	res = platform_device_register(&cpmac_low);
-	if (res)
-		return res;
+	if (!res) {
+		cpmac_get_mac(0, cpmac_low_data.dev_addr);
+		res = platform_device_register(&cpmac_low);
+		if (res)
+			printk(KERN_WARNING "unable to register cpmac-low: %d\n", res);
+	} else
+		printk(KERN_WARNING "unable to add cpmac-low phy: %d\n", res);
 
 	detect_leds();
 	res = platform_device_register(&ar7_gpio_leds);
 	if (res)
-		return res;
+		printk(KERN_WARNING "unable to register leds: %d\n", res);
 
 	res = platform_device_register(&ar7_udc);
-
-	chip_id = ar7_chip_id();
-	switch (chip_id) {
-	case AR7_CHIP_7100:
-	case AR7_CHIP_7200:
-		ar7_wdt_res.start = AR7_REGS_WDT;
-		break;
-	case AR7_CHIP_7300:
-		ar7_wdt_res.start = UR8_REGS_WDT;
-		break;
-	default:
-		break;
-	}
-
-	ar7_wdt_res.end = ar7_wdt_res.start + 0x20;
-
-	bootcr = (u32 *)ioremap_nocache(AR7_REGS_DCL, 4);
-	val = *bootcr;
-	iounmap(bootcr);
+	if (res)
+		printk(KERN_WARNING "unable to register usb slave: %d\n", res);
 
 	/* Register watchdog only if enabled in hardware */
-	if (val & AR7_WDT_HW_ENA)
-		res = platform_device_register(&ar7_wdt);
+	bootcr = ioremap_nocache(AR7_REGS_DCL, 4);
+	val = readl(bootcr);
+ 	iounmap(bootcr);
+	if (val & AR7_WDT_HW_ENA) {
+		chip_id = ar7_chip_id();
+		switch (chip_id) {
+		case AR7_CHIP_7100:
+		case AR7_CHIP_7200:
+			ar7_wdt_res.start = AR7_REGS_WDT;
+			break;
+		case AR7_CHIP_7300:
+			ar7_wdt_res.start = UR8_REGS_WDT;
+			break;
+		default:
+			break;
+		}
+
+		ar7_wdt_res.end = ar7_wdt_res.start + 0x20;
+ 		res = platform_device_register(&ar7_wdt);
+		if (res)
+			printk(KERN_WARNING "unable to register watchdog: %d\n", res);
+	}
 
-	return res;
+	return 0;
 }
 arch_initcall(ar7_register_devices);
-- 
1.6.6

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 3/3] MIPS: AR7 make ar7_register_devices much more durable
  2010-01-31 19:39 [PATCH 3/3] MIPS: AR7 make ar7_register_devices much more durable Alexander Clouter
@ 2010-02-01  6:32 ` Wu Zhangjin
  2010-02-01 19:02 ` Ralf Baechle
  1 sibling, 0 replies; 4+ messages in thread
From: Wu Zhangjin @ 2010-02-01  6:32 UTC (permalink / raw)
  To: Alexander Clouter; +Cc: linux-mips

On Sun, 2010-01-31 at 19:39 +0000, Alexander Clouter wrote:
> MIPS: AR7 make ar7_register_devices much more durable
> 

All of the printk(KERN_XXX stuff can be replaced by pr_xxx defined in
include/linux/kernel.h

Regards,
	Wu Zhangjin

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 3/3] MIPS: AR7 make ar7_register_devices much more durable
  2010-01-31 19:39 [PATCH 3/3] MIPS: AR7 make ar7_register_devices much more durable Alexander Clouter
  2010-02-01  6:32 ` Wu Zhangjin
@ 2010-02-01 19:02 ` Ralf Baechle
  2010-02-01 20:15   ` Alexander Clouter
  1 sibling, 1 reply; 4+ messages in thread
From: Ralf Baechle @ 2010-02-01 19:02 UTC (permalink / raw)
  To: Alexander Clouter; +Cc: linux-mips

On Sun, Jan 31, 2010 at 07:39:57PM +0000, Alexander Clouter wrote:

> MIPS: AR7 make ar7_register_devices much more durable

patches/0070-03.patch:85: space before tab in indent.
 	}
patches/0070-03.patch:192: space before tab in indent.
 	iounmap(bootcr);
patches/0070-03.patch:208: space before tab in indent.
 		res = platform_device_register(&ar7_wdt);
error: patch failed: arch/mips/ar7/platform.c:529
error: arch/mips/ar7/platform.c: patch does not apply

Grrr :-)

I've fixed that up, also the pr_xxx changes suggested by Wu.  Queued
for 2.6.34.

Thanks,

  Ralf

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 3/3] MIPS: AR7 make ar7_register_devices much more durable
  2010-02-01 19:02 ` Ralf Baechle
@ 2010-02-01 20:15   ` Alexander Clouter
  0 siblings, 0 replies; 4+ messages in thread
From: Alexander Clouter @ 2010-02-01 20:15 UTC (permalink / raw)
  To: linux-mips

Ralf Baechle <ralf@linux-mips.org> wrote:
>
> On Sun, Jan 31, 2010 at 07:39:57PM +0000, Alexander Clouter wrote:
> 
>> MIPS: AR7 make ar7_register_devices much more durable
> 
> patches/0070-03.patch:85: space before tab in indent.
>        }
> patches/0070-03.patch:192: space before tab in indent.
>        iounmap(bootcr);
> patches/0070-03.patch:208: space before tab in indent.
>                res = platform_device_register(&ar7_wdt);
> error: patch failed: arch/mips/ar7/platform.c:529
> error: arch/mips/ar7/platform.c: patch does not apply
> 
> Grrr :-)
> 
My grovelling apologies, I do normally worship at the altar of 
checkpatch.pl however my faith was recently shattered by the acceptance 
for lines longer than 80 chars...

> I've fixed that up, also the pr_xxx changes suggested by Wu.  Queued
> for 2.6.34.
> 
I have some other code for you to rewrite if you are willing?

All this manual fixing up does makeme ponder if you are trying to avoid 
doing something else you should be doing though :)

Sorry again and also my thanks

-- 
Alexander Clouter
.sigmonster says: YOW!!  The land of the rising SONY!!

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-02-01 21:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-31 19:39 [PATCH 3/3] MIPS: AR7 make ar7_register_devices much more durable Alexander Clouter
2010-02-01  6:32 ` Wu Zhangjin
2010-02-01 19:02 ` Ralf Baechle
2010-02-01 20:15   ` Alexander Clouter

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.