diff options
| author | Ian Lepore <ian@FreeBSD.org> | 2017-07-31 21:53:00 +0000 |
|---|---|---|
| committer | Ian Lepore <ian@FreeBSD.org> | 2017-07-31 21:53:00 +0000 |
| commit | 13fd9ff7678ebdfe3cac9c9da237de2e09e841c3 (patch) | |
| tree | 86798efe47b8dc96759ecb5837a0e799b0d4cdd4 /sys/dev/iicbus/ds1307.c | |
| parent | 03515a51917d23e9634912f97e4d3bb46dd5c5f4 (diff) | |
Notes
Diffstat (limited to 'sys/dev/iicbus/ds1307.c')
| -rw-r--r-- | sys/dev/iicbus/ds1307.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/sys/dev/iicbus/ds1307.c b/sys/dev/iicbus/ds1307.c index d93e13d0775b1..7332c820dc094 100644 --- a/sys/dev/iicbus/ds1307.c +++ b/sys/dev/iicbus/ds1307.c @@ -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; @@ -380,10 +387,6 @@ ds1307_settime(device_t dev, struct timespec *ts) } 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); data[DS1307_HOUR] = TOBCD(ct.hour) | pmflags; |
