From 23c0293ee778d7fd435d5c4cbfd993098cbd46d4 Mon Sep 17 00:00:00 2001 From: uwe Date: Tue, 3 Dec 2002 17:54:54 +0000 Subject: [PATCH] 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. --- sys/arch/sparc/dev/rtc.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/sys/arch/sparc/dev/rtc.c b/sys/arch/sparc/dev/rtc.c index dabaa2f4e0aa..2ef5fa8aad48 100644 --- a/sys/arch/sparc/dev/rtc.c +++ b/sys/arch/sparc/dev/rtc.c @@ -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);