mirror of https://gitee.com/openkylin/linux.git
staging: comedi: avoid using timeval
Comedi uses 32-bit seconds for its timestamps, on both 32-bit and 64-bit machines. For all I can tell, this was originally meant as a 'timespec', which would overflow in 2038 because of the use of a signed 'long' on 32-bit machines, but it is now used as an array of two unsigned 'lsampl_t' values in comedilib, which will only overflow in 2106, on both 32-bit and 64-bit machines. In an effort to get rid of all uses of 'struct timeval' in the kernel, this replaces the internal code with a call to ktime_get_real_ts64() and a comment at the location of the conversion. Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
533364c7c6
commit
70db384cd6
|
@ -1256,16 +1256,17 @@ static int parse_insn(struct comedi_device *dev, struct comedi_insn *insn,
|
||||||
switch (insn->insn) {
|
switch (insn->insn) {
|
||||||
case INSN_GTOD:
|
case INSN_GTOD:
|
||||||
{
|
{
|
||||||
struct timeval tv;
|
struct timespec64 tv;
|
||||||
|
|
||||||
if (insn->n != 2) {
|
if (insn->n != 2) {
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
do_gettimeofday(&tv);
|
ktime_get_real_ts64(&tv);
|
||||||
data[0] = tv.tv_sec;
|
/* unsigned data safe until 2106 */
|
||||||
data[1] = tv.tv_usec;
|
data[0] = (unsigned int)tv.tv_sec;
|
||||||
|
data[1] = tv.tv_nsec / NSEC_PER_USEC;
|
||||||
ret = 2;
|
ret = 2;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue