Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 4 Mar 2018 21:58:32 +0000 (UTC)
From:      Ian Lepore <ian@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r330416 - head/sys/dev/iicbus
Message-ID:  <201803042158.w24LwWO5098200@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ian
Date: Sun Mar  4 21:58:32 2018
New Revision: 330416
URL: https://svnweb.freebsd.org/changeset/base/330416

Log:
  The year is stored in a single byte in sram, in binary format, as a count
  of years since the century, so strip the century out when converting to or
  from bcd_clocktime format (the conversion routines will infer century by
  pivoting on 70).

Modified:
  head/sys/dev/iicbus/rtc8583.c

Modified: head/sys/dev/iicbus/rtc8583.c
==============================================================================
--- head/sys/dev/iicbus/rtc8583.c	Sun Mar  4 21:41:05 2018	(r330415)
+++ head/sys/dev/iicbus/rtc8583.c	Sun Mar  4 21:58:32 2018	(r330416)
@@ -237,7 +237,7 @@ rtc8583_gettime(device_t dev, struct timespec *ts)
 	bct.hour = tregs.hour & 0x3f;
 	bct.day  = tregs.day & 0x3f;
 	bct.mon  = tregs.month & 0x1f;
-	bct.year = (bin2bcd(sreg / 100) << 8) | bin2bcd(sreg % 100);
+	bct.year = bin2bcd(sreg % 100);
 
 	clock_dbgprint_bcd(sc->dev, CLOCK_DBG_READ, &bct); 
 	return (clock_bcd_to_ts(&bct, ts, false));
@@ -269,7 +269,7 @@ rtc8583_settime(device_t dev, struct timespec *ts)
 		return (err);
 	err = rtc8583_writeto(sc->dev, RTC8583_SC_REG, &tregs,
 	    sizeof(tregs), IIC_WAIT);
-	sreg = bcd2bin(bct.year & 0xff) + 100 * bcd2bin(bct.year >> 8);
+	sreg = bcd2bin(bct.year & 0xff);
 	/* save to year to sram */
 	rtc8583_write1(sc, RTC8583_USERSRAM_REG, sreg);
 	iicbus_release_bus(sc->busdev, sc->dev);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201803042158.w24LwWO5098200>