Author: ian
Date: Mon Jul 31 21:53:00 2017
New Revision: 321821
URL: https://svnweb.freebsd.org/changeset/base/321821

Log:
  No need to call getnanotime() now that the waiting is done by the central
  subr_rtc code, switch from CLOCKF_SETTIME_NO_TS to CLOCKF_SETTIME_NO_ADJ
  so that we get fed a timestamp, but it's not adjusted to compensate for
  inaccuracy in setting time.

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

Modified: head/sys/dev/iicbus/ds1307.c
==============================================================================
--- head/sys/dev/iicbus/ds1307.c        Mon Jul 31 21:52:08 2017        
(r321820)
+++ head/sys/dev/iicbus/ds1307.c        Mon Jul 31 21:53:00 2017        
(r321821)
@@ -303,12 +303,12 @@ ds1307_start(void *xdev)
            CTLFLAG_RW | CTLTYPE_UINT | CTLFLAG_MPSAFE, sc, 0,
            ds1307_sqw_out_sysctl, "IU", "DS1307 square-wave output state");
 
-        /*
-         * Register as a clock with 1 second resolution.  Schedule the
-         * clock_settime() method to be called just after top-of-second;
-         * resetting the time resets top-of-second in the hardware.
-         */
-       clock_register_flags(dev, 1000000, CLOCKF_SETTIME_NO_TS);
+       /*
+        * Register as a clock with 1 second resolution.  Schedule the
+        * clock_settime() method to be called just after top-of-second;
+        * resetting the time resets top-of-second in the hardware.
+        */
+       clock_register_flags(dev, 1000000, CLOCKF_SETTIME_NO_ADJ);
        clock_schedule(dev, 1);
 }
 
@@ -368,6 +368,13 @@ ds1307_settime(device_t dev, struct timespec *ts)
 
        sc = device_get_softc(dev);
 
+       /*
+        * We request a timespec with no resolution-adjustment.  That also
+        * disables utc adjustment, so apply that ourselves.
+        */
+       ts->tv_sec -= utc_offset();
+       clock_ts_to_ct(ts, &ct);
+
        /* If the chip is in AM/PM mode, adjust hour and set flags as needed. */
        if (sc->sc_use_ampm) {
                pmflags = DS1307_HOUR_USE_AMPM;
@@ -379,10 +386,6 @@ ds1307_settime(device_t dev, struct timespec *ts)
                        ct.hour = 12;
        } else
                pmflags = 0;
-
-       getnanotime(ts);
-       ts->tv_sec -= utc_offset();
-       clock_ts_to_ct(ts, &ct);
 
        data[DS1307_SECS]    = TOBCD(ct.sec);
        data[DS1307_MINS]    = TOBCD(ct.min);
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to