Skip to content

Commit 0fabf9f

Browse files
robherringdlezcano
authored andcommitted
clocksource/drivers/timer-ti-dm: Use of_address_to_resource()
Replace of_get_address() and of_translate_address() calls with single call to of_address_to_resource(). Signed-off-by: Rob Herring <robh@kernel.org> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Link: https://lore.kernel.org/r/20230319163220.226273-1-robh@kernel.org
1 parent f68a40e commit 0fabf9f

1 file changed

Lines changed: 27 additions & 30 deletions

File tree

drivers/clocksource/timer-ti-dm-systimer.c

Lines changed: 27 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -251,24 +251,22 @@ static void __init dmtimer_systimer_assign_alwon(void)
251251
counter_32k = -ENODEV;
252252

253253
for_each_matching_node(np, dmtimer_match_table) {
254+
struct resource res;
254255
if (!dmtimer_is_preferred(np))
255256
continue;
256257

257-
if (of_property_read_bool(np, "ti,timer-alwon")) {
258-
const __be32 *addr;
259-
260-
addr = of_get_address(np, 0, NULL, NULL);
261-
pa = of_translate_address(np, addr);
262-
if (pa) {
263-
/* Quirky omap3 boards must use dmtimer12 */
264-
if (quirk_unreliable_oscillator &&
265-
pa == 0x48318000)
266-
continue;
267-
268-
of_node_put(np);
269-
break;
270-
}
271-
}
258+
if (!of_property_read_bool(np, "ti,timer-alwon"))
259+
continue;
260+
261+
if (of_address_to_resource(np, 0, &res))
262+
continue;
263+
264+
/* Quirky omap3 boards must use dmtimer12 */
265+
if (quirk_unreliable_oscillator && res.start == 0x48318000)
266+
continue;
267+
268+
of_node_put(np);
269+
break;
272270
}
273271

274272
/* Usually no need for dmtimer clocksource if we have counter32 */
@@ -285,24 +283,22 @@ static void __init dmtimer_systimer_assign_alwon(void)
285283
static u32 __init dmtimer_systimer_find_first_available(void)
286284
{
287285
struct device_node *np;
288-
const __be32 *addr;
289286
u32 pa = 0;
290287

291288
for_each_matching_node(np, dmtimer_match_table) {
289+
struct resource res;
292290
if (!dmtimer_is_preferred(np))
293291
continue;
294292

295-
addr = of_get_address(np, 0, NULL, NULL);
296-
pa = of_translate_address(np, addr);
297-
if (pa) {
298-
if (pa == clocksource || pa == clockevent) {
299-
pa = 0;
300-
continue;
301-
}
302-
303-
of_node_put(np);
304-
break;
305-
}
293+
if (of_address_to_resource(np, 0, &res))
294+
continue;
295+
296+
if (res.start == clocksource || res.start == clockevent)
297+
continue;
298+
299+
pa = res.start;
300+
of_node_put(np);
301+
break;
306302
}
307303

308304
return pa;
@@ -812,7 +808,7 @@ static int __init dmtimer_clocksource_init(struct device_node *np)
812808
*/
813809
static int __init dmtimer_systimer_init(struct device_node *np)
814810
{
815-
const __be32 *addr;
811+
struct resource res;
816812
u32 pa;
817813

818814
/* One time init for the preferred timer configuration */
@@ -826,8 +822,9 @@ static int __init dmtimer_systimer_init(struct device_node *np)
826822
return -EINVAL;
827823
}
828824

829-
addr = of_get_address(np, 0, NULL, NULL);
830-
pa = of_translate_address(np, addr);
825+
826+
of_address_to_resource(np, 0, &res);
827+
pa = (u32)res.start;
831828
if (!pa)
832829
return -EINVAL;
833830

0 commit comments

Comments
 (0)