diff options
author | Daniel Lezcano <daniel.lezcano@linaro.org> | 2016-06-02 12:46:11 -0400 |
---|---|---|
committer | Daniel Lezcano <daniel.lezcano@linaro.org> | 2016-06-28 04:19:21 -0400 |
commit | 524a7f08983daa756ad355a302fb67bd90713dd0 (patch) | |
tree | 761c9c8848f1f4044478882648dc73fc492b4069 /drivers/clocksource | |
parent | 802fa498dbd27d5dea57e624606c8f8ec47d1915 (diff) |
clocksource/drivers/bcm2835_timer: Convert init function to return error
The init functions do not return any error. They behave as the following:
- panic, thus leading to a kernel crash while another timer may work and
make the system boot up correctly
or
- print an error and let the caller unaware if the state of the system
Change that by converting the init functions to return an error conforming
to the CLOCKSOURCE_OF_RET prototype.
Proper error handling (rollback, errno value) will be changed later case
by case, thus this change just return back an error or success in the init
function.
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Acked-by: Eric Anholt <eric@anholt.net>
Diffstat (limited to 'drivers/clocksource')
-rw-r--r-- | drivers/clocksource/bcm2835_timer.c | 40 |
1 files changed, 27 insertions, 13 deletions
diff --git a/drivers/clocksource/bcm2835_timer.c b/drivers/clocksource/bcm2835_timer.c index 6f2822928963..2dcf896b5381 100644 --- a/drivers/clocksource/bcm2835_timer.c +++ b/drivers/clocksource/bcm2835_timer.c | |||
@@ -80,19 +80,24 @@ static irqreturn_t bcm2835_time_interrupt(int irq, void *dev_id) | |||
80 | } | 80 | } |
81 | } | 81 | } |
82 | 82 | ||
83 | static void __init bcm2835_timer_init(struct device_node *node) | 83 | static int __init bcm2835_timer_init(struct device_node *node) |
84 | { | 84 | { |
85 | void __iomem *base; | 85 | void __iomem *base; |
86 | u32 freq; | 86 | u32 freq; |
87 | int irq; | 87 | int irq, ret; |
88 | struct bcm2835_timer *timer; | 88 | struct bcm2835_timer *timer; |
89 | 89 | ||
90 | base = of_iomap(node, 0); | 90 | base = of_iomap(node, 0); |
91 | if (!base) | 91 | if (!base) { |
92 | panic("Can't remap registers"); | 92 | pr_err("Can't remap registers"); |
93 | return -ENXIO; | ||
94 | } | ||
93 | 95 | ||
94 | if (of_property_read_u32(node, "clock-frequency", &freq)) | 96 | ret = of_property_read_u32(node, "clock-frequency", &freq); |
95 | panic("Can't read clock-frequency"); | 97 | if (ret) { |
98 | pr_err("Can't read clock-frequency"); | ||
99 | return ret; | ||
100 | } | ||
96 | 101 | ||
97 | system_clock = base + REG_COUNTER_LO; | 102 | system_clock = base + REG_COUNTER_LO; |
98 | sched_clock_register(bcm2835_sched_read, 32, freq); | 103 | sched_clock_register(bcm2835_sched_read, 32, freq); |
@@ -101,12 +106,16 @@ static void __init bcm2835_timer_init(struct device_node *node) | |||
101 | freq, 300, 32, clocksource_mmio_readl_up); | 106 | freq, 300, 32, clocksource_mmio_readl_up); |
102 | 107 | ||
103 | irq = irq_of_parse_and_map(node, DEFAULT_TIMER); | 108 | irq = irq_of_parse_and_map(node, DEFAULT_TIMER); |
104 | if (irq <= 0) | 109 | if (irq <= 0) { |
105 | panic("Can't parse IRQ"); | 110 | pr_err("Can't parse IRQ"); |
111 | return -EINVAL; | ||
112 | } | ||
106 | 113 | ||
107 | timer = kzalloc(sizeof(*timer), GFP_KERNEL); | 114 | timer = kzalloc(sizeof(*timer), GFP_KERNEL); |
108 | if (!timer) | 115 | if (!timer) { |
109 | panic("Can't allocate timer struct\n"); | 116 | pr_err("Can't allocate timer struct\n"); |
117 | return -ENOMEM; | ||
118 | } | ||
110 | 119 | ||
111 | timer->control = base + REG_CONTROL; | 120 | timer->control = base + REG_CONTROL; |
112 | timer->compare = base + REG_COMPARE(DEFAULT_TIMER); | 121 | timer->compare = base + REG_COMPARE(DEFAULT_TIMER); |
@@ -121,12 +130,17 @@ static void __init bcm2835_timer_init(struct device_node *node) | |||
121 | timer->act.dev_id = timer; | 130 | timer->act.dev_id = timer; |
122 | timer->act.handler = bcm2835_time_interrupt; | 131 | timer->act.handler = bcm2835_time_interrupt; |
123 | 132 | ||
124 | if (setup_irq(irq, &timer->act)) | 133 | ret = setup_irq(irq, &timer->act); |
125 | panic("Can't set up timer IRQ\n"); | 134 | if (ret) { |
135 | pr_err("Can't set up timer IRQ\n"); | ||
136 | return ret; | ||
137 | } | ||
126 | 138 | ||
127 | clockevents_config_and_register(&timer->evt, freq, 0xf, 0xffffffff); | 139 | clockevents_config_and_register(&timer->evt, freq, 0xf, 0xffffffff); |
128 | 140 | ||
129 | pr_info("bcm2835: system timer (irq = %d)\n", irq); | 141 | pr_info("bcm2835: system timer (irq = %d)\n", irq); |
142 | |||
143 | return 0; | ||
130 | } | 144 | } |
131 | CLOCKSOURCE_OF_DECLARE(bcm2835, "brcm,bcm2835-system-timer", | 145 | CLOCKSOURCE_OF_DECLARE_RET(bcm2835, "brcm,bcm2835-system-timer", |
132 | bcm2835_timer_init); | 146 | bcm2835_timer_init); |