Module Name: src Committed By: thorpej Date: Wed Mar 6 02:31:44 UTC 2024
Modified Files: src/sys/dev/ic: mc146818.c mc146818var.h Log Message: Expose mc146818_{get,set}time_ymdhms() and allow a front-end to override these function pointers in the TODR handle, allowing the front-end to wrap mc146818_{get,set}time_ymdhms() with special handling, if needed. To generate a diff of this commit: cvs rdiff -u -r1.20 -r1.21 src/sys/dev/ic/mc146818.c cvs rdiff -u -r1.7 -r1.8 src/sys/dev/ic/mc146818var.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/ic/mc146818.c diff -u src/sys/dev/ic/mc146818.c:1.20 src/sys/dev/ic/mc146818.c:1.21 --- src/sys/dev/ic/mc146818.c:1.20 Wed Jan 1 19:24:03 2020 +++ src/sys/dev/ic/mc146818.c Wed Mar 6 02:31:44 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: mc146818.c,v 1.20 2020/01/01 19:24:03 thorpej Exp $ */ +/* $NetBSD: mc146818.c,v 1.21 2024/03/06 02:31:44 thorpej Exp $ */ /*- * Copyright (c) 2003 Izumi Tsutsui. All rights reserved. @@ -29,7 +29,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: mc146818.c,v 1.20 2020/01/01 19:24:03 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mc146818.c,v 1.21 2024/03/06 02:31:44 thorpej Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -43,9 +43,6 @@ __KERNEL_RCSID(0, "$NetBSD: mc146818.c,v #include <dev/ic/mc146818reg.h> #include <dev/ic/mc146818var.h> -int mc146818_gettime_ymdhms(todr_chip_handle_t, struct clock_ymdhms *); -int mc146818_settime_ymdhms(todr_chip_handle_t, struct clock_ymdhms *); - void mc146818_attach(struct mc146818_softc *sc) { @@ -61,11 +58,14 @@ mc146818_attach(struct mc146818_softc *s handle = &sc->sc_handle; handle->cookie = sc; - handle->todr_gettime = NULL; - handle->todr_settime = NULL; - handle->todr_gettime_ymdhms = mc146818_gettime_ymdhms; - handle->todr_settime_ymdhms = mc146818_settime_ymdhms; - handle->todr_setwen = NULL; + KASSERT(handle->todr_gettime == NULL); + KASSERT(handle->todr_settime == NULL); + if (handle->todr_gettime_ymdhms == NULL) { + handle->todr_gettime_ymdhms = mc146818_gettime_ymdhms; + } + if (handle->todr_settime_ymdhms == NULL) { + handle->todr_settime_ymdhms = mc146818_settime_ymdhms; + } todr_attach(handle); } @@ -103,7 +103,7 @@ mc146818_gettime_ymdhms(todr_chip_handle dt->dt_wday = FROMREG((*sc->sc_mcread)(sc, MC_DOW)); dt->dt_day = FROMREG((*sc->sc_mcread)(sc, MC_DOM)); dt->dt_mon = FROMREG((*sc->sc_mcread)(sc, MC_MONTH)); - year = FROMREG((*sc->sc_mcread)(sc, MC_YEAR)); + year = FROMREG((*sc->sc_mcread)(sc, MC_YEAR)); if (sc->sc_getcent) { cent = (*sc->sc_getcent)(sc); year += cent * 100; Index: src/sys/dev/ic/mc146818var.h diff -u src/sys/dev/ic/mc146818var.h:1.7 src/sys/dev/ic/mc146818var.h:1.8 --- src/sys/dev/ic/mc146818var.h:1.7 Wed May 14 13:29:29 2008 +++ src/sys/dev/ic/mc146818var.h Wed Mar 6 02:31:44 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: mc146818var.h,v 1.7 2008/05/14 13:29:29 tsutsui Exp $ */ +/* $NetBSD: mc146818var.h,v 1.8 2024/03/06 02:31:44 thorpej Exp $ */ /*- * Copyright (c) 2003 Izumi Tsutsui. All rights reserved. @@ -24,6 +24,9 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#ifndef _DEV_IC_MC146818VAR_H_ +#define _DEV_IC_MC146818VAR_H_ + struct mc146818_softc { device_t sc_dev; @@ -45,4 +48,8 @@ struct mc146818_softc { void (*sc_setcent)(struct mc146818_softc *, u_int); }; -void mc146818_attach(struct mc146818_softc *); +void mc146818_attach(struct mc146818_softc *); +int mc146818_gettime_ymdhms(todr_chip_handle_t, struct clock_ymdhms *); +int mc146818_settime_ymdhms(todr_chip_handle_t, struct clock_ymdhms *); + +#endif /* _DEV_IC_MC146818VAR_H_ */