Module Name: src
Committed By: thorpej
Date: Fri Jan 3 01:24:48 UTC 2020
Modified Files:
src/sys/kern: kern_todr.c
Log Message:
- In todr_gettime(), in the todr_gettime_ymdhms, pre-zero the clock_ymdhms
struct before asking the back-end to fill it in.
- Tidy up todr_settime() a teensy bit.
To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/sys/kern/kern_todr.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/kern/kern_todr.c
diff -u src/sys/kern/kern_todr.c:1.45 src/sys/kern/kern_todr.c:1.46
--- src/sys/kern/kern_todr.c:1.45 Wed Jan 1 23:15:24 2020
+++ src/sys/kern/kern_todr.c Fri Jan 3 01:24:48 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_todr.c,v 1.45 2020/01/01 23:15:24 thorpej Exp $ */
+/* $NetBSD: kern_todr.c,v 1.46 2020/01/03 01:24:48 thorpej Exp $ */
/*-
* Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@
#include "opt_todr.h"
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_todr.c,v 1.45 2020/01/01 23:15:24 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_todr.c,v 1.46 2020/01/03 01:24:48 thorpej Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@@ -397,8 +397,7 @@ do { \
static int
todr_gettime(todr_chip_handle_t tch, struct timeval *tvp)
{
- struct clock_ymdhms dt;
- int rv;
+ int rv;
/*
* Write-enable is used even when reading the TODR because
@@ -418,6 +417,7 @@ todr_gettime(todr_chip_handle_t tch, str
todr_debug("TODR-GET-SECS", rv, NULL, tvp);
return rv;
} else if (tch->todr_gettime_ymdhms) {
+ struct clock_ymdhms dt = { 0 };
ENABLE_TODR_WRITES();
rv = tch->todr_gettime_ymdhms(tch, &dt);
DISABLE_TODR_WRITES();
@@ -455,12 +455,10 @@ todr_gettime(todr_chip_handle_t tch, str
static int
todr_settime(todr_chip_handle_t tch, struct timeval *tvp)
{
- struct clock_ymdhms dt;
- int rv;
+ int rv;
if (tch->todr_settime) {
- /* See comments above in gettime why this is ifdef'd */
- struct timeval copy = *tvp;
+ struct timeval copy = *tvp;
copy.tv_sec -= rtc_offset * 60;
ENABLE_TODR_WRITES();
rv = tch->todr_settime(tch, ©);
@@ -468,7 +466,8 @@ todr_settime(todr_chip_handle_t tch, str
todr_debug("TODR-SET-SECS", rv, NULL, tvp);
return rv;
} else if (tch->todr_settime_ymdhms) {
- time_t sec = tvp->tv_sec - rtc_offset * 60;
+ struct clock_ymdhms dt;
+ time_t sec = tvp->tv_sec - rtc_offset * 60;
if (tvp->tv_usec >= 500000)
sec++;
clock_secs_to_ymdhms(sec, &dt);
@@ -477,7 +476,7 @@ todr_settime(todr_chip_handle_t tch, str
DISABLE_TODR_WRITES();
todr_debug("TODR-SET-YMDHMS", rv, &dt, NULL);
return rv;
- } else {
- return ENXIO;
}
+
+ return ENXIO;
}