Skip to content

Commit b386cdd

Browse files
committed
evbarm/generic_v5: fix setstatclockrate crash
setstatclockrate is an optional function for timers that currently cannot be multiplexed through device trees. We don't provide an implementation in the am18 code, but we need to make sure the imx23 driver doesn't crash us.
1 parent c6010d4 commit b386cdd

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

sys/arch/arm/imx/imx23_timrot.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ static const struct device_compatible_entry compat_data[] = {
7878
DEVICE_COMPAT_EOL
7979
};
8080

81-
static struct imx23_timrot_softc *timer_sc;
81+
static struct imx23_timrot_softc *timer_sc = NULL;
8282

8383
#define TIMROT_SOFT_RST_LOOP 455 /* At least 1 us ... */
8484
#define TIMROT_READ(sc, reg) \
@@ -197,9 +197,11 @@ setstatclockrate(int newhz)
197197
{
198198
struct imx23_timrot_softc *sc = timer_sc;
199199

200-
TIMER_WRITE_2(sc, HW_TIMROT_TIMCOUNT1,
201-
__SHIFTIN(SOURCE_32KHZ_HZ / newhz - 1,
202-
HW_TIMROT_TIMCOUNT1_FIXED_COUNT));
200+
if(sc != NULL) {
201+
TIMER_WRITE_2(sc, HW_TIMROT_TIMCOUNT1,
202+
__SHIFTIN(SOURCE_32KHZ_HZ / newhz - 1,
203+
HW_TIMROT_TIMCOUNT1_FIXED_COUNT));
204+
}
203205
}
204206

205207
/*

0 commit comments

Comments
 (0)