Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/sgimips/mace Use todr_[gs]ettime_ymdhms() format.
details: https://anonhg.NetBSD.org/src/rev/6cddb57abad8
branches: trunk
changeset: 749949:6cddb57abad8
user: tsutsui <tsutsui%NetBSD.org@localhost>
date: Sun Dec 13 11:03:33 2009 +0000
description:
Use todr_[gs]ettime_ymdhms() format.
diffstat:
sys/arch/sgimips/mace/mcclock_mace.c | 66 ++++++++++++++---------------------
1 files changed, 27 insertions(+), 39 deletions(-)
diffs (125 lines):
diff -r a220bd19a5fd -r 6cddb57abad8 sys/arch/sgimips/mace/mcclock_mace.c
--- a/sys/arch/sgimips/mace/mcclock_mace.c Sun Dec 13 09:38:22 2009 +0000
+++ b/sys/arch/sgimips/mace/mcclock_mace.c Sun Dec 13 11:03:33 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mcclock_mace.c,v 1.11 2009/12/12 14:44:09 tsutsui Exp $ */
+/* $NetBSD: mcclock_mace.c,v 1.12 2009/12/13 11:03:33 tsutsui Exp $ */
/*
* Copyright (c) 2001 Antti Kantee. All Rights Reserved.
@@ -65,7 +65,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mcclock_mace.c,v 1.11 2009/12/12 14:44:09 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mcclock_mace.c,v 1.12 2009/12/13 11:03:33 tsutsui Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -97,10 +97,10 @@
static int mcclock_mace_match(struct device *, struct cfdata *, void *);
static void mcclock_mace_attach(struct device*, struct device *, void *);
-static int mcclock_mace_gettime(struct todr_chip_handle *,
- struct timeval *);
-static int mcclock_mace_settime(struct todr_chip_handle *,
- struct timeval *);
+static int mcclock_mace_gettime_ymdhms(struct todr_chip_handle *,
+ struct clock_ymdhms *);
+static int mcclock_mace_settime_ymdhms(struct todr_chip_handle *,
+ struct clock_ymdhms *);
unsigned int ds1687_read(void *arg, unsigned int addr);
void ds1687_write(void *arg, unsigned int addr, unsigned int data);
@@ -146,8 +146,8 @@
printf("\n");
sc->sc_todrch.cookie = sc;
- sc->sc_todrch.todr_gettime = mcclock_mace_gettime;
- sc->sc_todrch.todr_settime = mcclock_mace_settime;
+ sc->sc_todrch.todr_gettime_ymdhms = mcclock_mace_gettime_ymdhms;
+ sc->sc_todrch.todr_settime_ymdhms = mcclock_mace_settime_ymdhms;
sc->sc_todrch.todr_setwen = NULL;
todr_attach(&sc->sc_todrch);
@@ -175,11 +175,11 @@
}
static int
-mcclock_mace_gettime(struct todr_chip_handle *todrch, struct timeval *tv)
+mcclock_mace_gettime_ymdhms(struct todr_chip_handle *todrch,
+ struct clock_ymdhms *dt)
{
struct mcclock_mace_softc *sc =
(struct mcclock_mace_softc *)todrch->cookie;
- struct clock_ymdhms dt;
ds1687_todregs regs;
int s;
@@ -187,49 +187,37 @@
DS1687_GETTOD(sc, ®s);
splx(s);
- dt.dt_sec = FROMBCD(regs[DS1687_SOFT_SEC]);
- dt.dt_min = FROMBCD(regs[DS1687_SOFT_MIN]);
- dt.dt_hour = FROMBCD(regs[DS1687_SOFT_HOUR]);
- dt.dt_wday = FROMBCD(regs[DS1687_SOFT_DOW]);
- dt.dt_day = FROMBCD(regs[DS1687_SOFT_DOM]);
- dt.dt_mon = FROMBCD(regs[DS1687_SOFT_MONTH]);
- dt.dt_year = FROMBCD(regs[DS1687_SOFT_YEAR]) +
+ dt->dt_sec = FROMBCD(regs[DS1687_SOFT_SEC]);
+ dt->dt_min = FROMBCD(regs[DS1687_SOFT_MIN]);
+ dt->dt_hour = FROMBCD(regs[DS1687_SOFT_HOUR]);
+ dt->dt_wday = FROMBCD(regs[DS1687_SOFT_DOW]);
+ dt->dt_day = FROMBCD(regs[DS1687_SOFT_DOM]);
+ dt->dt_mon = FROMBCD(regs[DS1687_SOFT_MONTH]);
+ dt->dt_year = FROMBCD(regs[DS1687_SOFT_YEAR]) +
(100 * FROMBCD(regs[DS1687_SOFT_CENTURY]));
- /* simple sanity checks */
- if (dt.dt_mon > 12 || dt.dt_day > 31 ||
- dt.dt_hour >= 24 || dt.dt_min >= 60 || dt.dt_sec >= 60)
- return (EIO);
-
- tv->tv_sec = (long)clock_ymdhms_to_secs(&dt);
- if (tv->tv_sec == -1)
- return (ERANGE);
- tv->tv_usec = 0;
-
return (0);
}
static int
-mcclock_mace_settime(struct todr_chip_handle *todrch, struct timeval *tv)
+mcclock_mace_settime_ymdhms(struct todr_chip_handle *todrch,
+ struct clock_ymdhms *dt)
{
struct mcclock_mace_softc *sc =
(struct mcclock_mace_softc *)todrch->cookie;
- struct clock_ymdhms dt;
ds1687_todregs regs;
int s;
- clock_secs_to_ymdhms((time_t)(tv->tv_sec + (tv->tv_usec > 500000)),&dt);
-
memset(®s, 0, sizeof(regs));
- regs[DS1687_SOFT_SEC] = TOBCD(dt.dt_sec);
- regs[DS1687_SOFT_MIN] = TOBCD(dt.dt_min);
- regs[DS1687_SOFT_HOUR] = TOBCD(dt.dt_hour);
- regs[DS1687_SOFT_DOW] = TOBCD(dt.dt_wday);
- regs[DS1687_SOFT_DOM] = TOBCD(dt.dt_day);
- regs[DS1687_SOFT_MONTH] = TOBCD(dt.dt_mon);
- regs[DS1687_SOFT_YEAR] = TOBCD(dt.dt_year % 100);
- regs[DS1687_SOFT_CENTURY] = TOBCD(dt.dt_year / 100);
+ regs[DS1687_SOFT_SEC] = TOBCD(dt->dt_sec);
+ regs[DS1687_SOFT_MIN] = TOBCD(dt->dt_min);
+ regs[DS1687_SOFT_HOUR] = TOBCD(dt->dt_hour);
+ regs[DS1687_SOFT_DOW] = TOBCD(dt->dt_wday);
+ regs[DS1687_SOFT_DOM] = TOBCD(dt->dt_day);
+ regs[DS1687_SOFT_MONTH] = TOBCD(dt->dt_mon);
+ regs[DS1687_SOFT_YEAR] = TOBCD(dt->dt_year % 100);
+ regs[DS1687_SOFT_CENTURY] = TOBCD(dt->dt_year / 100);
s = splhigh();
DS1687_PUTTOD(sc, ®s);
splx(s);
Home |
Main Index |
Thread Index |
Old Index