'timeval' is used to create header timestamps for the data dump.
32-bit systems using 'struct timeval' will break in the year 2038,
So we have to replace that code with more appropriate types.
This patch changes the dgnc driver to use ktime_t instead of timeval.
It uses ktime_get() to get current timestamp. It is better than
do_gettimeofday() as it uses the monotonic clock.
---
Changes since v1:
* Reword commit message
* Fixed line over 80 characters warning on line :471
Signed-off-by: Somya Anand <
somyaa...@gmail.com>
---
drivers/staging/dgnc/dgnc_tty.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index 03c1506..340bce8 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -49,7 +49,7 @@
#include <linux/delay.h> /* For udelay */
#include <linux/uaccess.h> /* For copy_from_user/copy_to_user */
#include <linux/pci.h>
-
+#include <linux/ktime.h>
#include "dgnc_driver.h"
#include "dgnc_tty.h"
#include "dgnc_types.h"
@@ -452,7 +452,7 @@ void dgnc_tty_uninit(struct dgnc_board *brd)
*/
void dgnc_sniff_nowait_nolock(struct channel_t *ch, unsigned char *text, unsigned char *buf, int len)
{
- struct timeval tv;
+ ktime_t kt;
int n;
int r;
int nbuf;
@@ -471,10 +471,10 @@ void dgnc_sniff_nowait_nolock(struct channel_t *ch, unsigned char *text, unsigne
if (!(ch->ch_sniff_flags & SNIFF_OPEN))
goto exit;
- do_gettimeofday(&tv);
-
+ kt = ktime_get();
/* Create our header for data dump */
- p += sprintf(p, "<%ld %ld><%s><", tv.tv_sec, tv.tv_usec, text);
+ p += sprintf(p, "<%llu %llu><%s><", ktime_divns(kt, NSEC_PER_SEC),
+ ktime_to_us(kt), text);
tmpbuflen = p - tmpbuf;
do {
--
1.9.1