diff options
author | Heinrich Schuchardt | 2020-10-30 03:05:47 +0100 |
---|---|---|
committer | Heinrich Schuchardt | 2020-10-30 14:20:26 +0100 |
commit | 0ca4b558b59d69d0b39ce42664c601690ecc8d6c (patch) | |
tree | a044a3a24453fc4f1f1da1cbe2ee19e2b3708c72 /drivers/rtc | |
parent | 314bed6c854e41b2edd5cefb7009e3b6040abd28 (diff) |
rtc: use probe() to initialize emulated RTC
Currently the emulated RTC is initialized in the emul_rtc_get() get
function. This does not match the design of the driver model.
Move the initialization of the emulated RTC to the probe() function.
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Diffstat (limited to 'drivers/rtc')
-rw-r--r-- | drivers/rtc/emul_rtc.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/drivers/rtc/emul_rtc.c b/drivers/rtc/emul_rtc.c index c98c24bbb3d..209b4965c17 100644 --- a/drivers/rtc/emul_rtc.c +++ b/drivers/rtc/emul_rtc.c @@ -30,12 +30,6 @@ static int emul_rtc_get(struct udevice *dev, struct rtc_time *time) struct emul_rtc *priv = dev_get_priv(dev); u64 now; - if (!priv->offset_us) { - /* Use the build date as initial time */ - priv->offset_us = U_BOOT_EPOCH * 1000000ULL - timer_get_us(); - priv->isdst = -1; - } - now = timer_get_us() + priv->offset_us; do_div(now, 1000000); rtc_to_tm(now, time); @@ -63,6 +57,17 @@ static int emul_rtc_set(struct udevice *dev, const struct rtc_time *time) return 0; } +int emul_rtc_probe(struct udevice *dev) +{ + struct emul_rtc *priv = dev_get_priv(dev); + + /* Use the build date as initial time */ + priv->offset_us = U_BOOT_EPOCH * 1000000ULL - timer_get_us(); + priv->isdst = -1; + + return 0; +} + static const struct rtc_ops emul_rtc_ops = { .get = emul_rtc_get, .set = emul_rtc_set, @@ -72,6 +77,7 @@ U_BOOT_DRIVER(rtc_emul) = { .name = "rtc_emul", .id = UCLASS_RTC, .ops = &emul_rtc_ops, + .probe = emul_rtc_probe, .priv_auto_alloc_size = sizeof(struct emul_rtc), }; |