From: Michal Simek Date: Tue, 27 Aug 2013 09:52:32 +0000 (+0200) Subject: microblaze: timer: Clear driver init function X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=cfd4eaefd0a8d4a7f464f43a11f1be26664385b7;p=linux-beck.git microblaze: timer: Clear driver init function - Use of_iomap - Use of_property_read_u32 - Fix printk Signed-off-by: Michal Simek --- diff --git a/arch/microblaze/kernel/timer.c b/arch/microblaze/kernel/timer.c index 6cb7f3b1914a..e10e0b8548ab 100644 --- a/arch/microblaze/kernel/timer.c +++ b/arch/microblaze/kernel/timer.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -29,7 +30,7 @@ #include #include -static unsigned int timer_baseaddr; +static void __iomem *timer_baseaddr; static unsigned int freq_div_hz; static unsigned int timer_clock_freq; @@ -242,26 +243,27 @@ static void __init xilinx_timer_init(struct device_node *timer) { u32 irq; u32 timer_num = 1; - const void *prop; + int ret; + + timer_baseaddr = of_iomap(timer, 0); + if (!timer_baseaddr) { + pr_err("ERROR: invalid timer base address\n"); + BUG(); + } - timer_baseaddr = be32_to_cpup(of_get_property(timer, "reg", NULL)); - timer_baseaddr = (unsigned long) ioremap(timer_baseaddr, PAGE_SIZE); irq = irq_of_parse_and_map(timer, 0); - timer_num = be32_to_cpup(of_get_property(timer, - "xlnx,one-timer-only", NULL)); + + of_property_read_u32(timer, "xlnx,one-timer-only", &timer_num); if (timer_num) { - pr_emerg("Please enable two timers in HW\n"); + pr_emerg("Please enable two timers in HW\n"); BUG(); } - pr_info("%s #0 at 0x%08x, irq=%d\n", - timer->name, timer_baseaddr, irq); + pr_info("%s: irq=%d\n", timer->full_name, irq); /* If there is clock-frequency property than use it */ - prop = of_get_property(timer, "clock-frequency", NULL); - if (prop) - timer_clock_freq = be32_to_cpup(prop); - else + ret = of_property_read_u32(timer, "clock-frequency", &timer_clock_freq); + if (ret < 0) timer_clock_freq = cpuinfo.cpu_clock_freq; freq_div_hz = timer_clock_freq / HZ;