The chip treats weekday 1 == Sunday, correct dt_wday adjustment logic

appropriately.  NB: the old code would never write weekday zero that,
I've been told, might cause the RTC to reset.
Pointed out by kenh.
This commit is contained in:
uwe 2002-12-03 17:54:54 +00:00
parent 25c20430c3
commit 23c0293ee7
1 changed files with 2 additions and 7 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: rtc.c,v 1.8 2002/10/02 16:02:16 thorpej Exp $ */
/* $NetBSD: rtc.c,v 1.9 2002/12/03 17:54:54 uwe Exp $ */
/*
* Copyright (c) 2001 Valeriy E. Ushakov
@ -223,7 +223,6 @@ rtc_settime(handle, tv)
struct rtc_ebus_softc *sc = handle->cookie;
struct clock_ymdhms dt;
u_int year;
u_int wday;
clock_secs_to_ymdhms(tv->tv_sec, &dt);
@ -231,10 +230,6 @@ rtc_settime(handle, tv)
if (year >= 100 && rtc_auto_century_adjust != 0)
year -= 100;
wday = dt.dt_wday;
if (wday == 0)
wday = 7;
/* stop updates */
mc146818_write(sc, MC_REGB,
(mc146818_read(sc, MC_REGB) | MC_REGB_SET));
@ -242,7 +237,7 @@ rtc_settime(handle, tv)
mc146818_write(sc, MC_SEC, dt.dt_sec);
mc146818_write(sc, MC_MIN, dt.dt_min);
mc146818_write(sc, MC_HOUR, dt.dt_hour);
mc146818_write(sc, MC_DOW, wday);
mc146818_write(sc, MC_DOW, dt.dt_wday + 1);
mc146818_write(sc, MC_DOM, dt.dt_day);
mc146818_write(sc, MC_MONTH, dt.dt_mon);
mc146818_write(sc, MC_YEAR, year);