Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/x68k/dev Tidy up callout(9) implementation to handl...
details: https://anonhg.NetBSD.org/src/rev/cdabef8c679a
branches: trunk
changeset: 961888:cdabef8c679a
user: tsutsui <tsutsui%NetBSD.org@localhost>
date: Sat Apr 24 16:24:14 2021 +0000
description:
Tidy up callout(9) implementation to handle mouse packets.
- define and use proper macro to specify ticks
- use callout_schedule(9) rather than callout_reset(9) to restart timer
No functional changes.
diffstat:
sys/arch/x68k/dev/ms.c | 24 +++++++++++++++++-------
1 files changed, 17 insertions(+), 7 deletions(-)
diffs (64 lines):
diff -r cacf63f775f3 -r cdabef8c679a sys/arch/x68k/dev/ms.c
--- a/sys/arch/x68k/dev/ms.c Sat Apr 24 16:14:08 2021 +0000
+++ b/sys/arch/x68k/dev/ms.c Sat Apr 24 16:24:14 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ms.c,v 1.35 2021/02/07 16:13:56 tsutsui Exp $ */
+/* $NetBSD: ms.c,v 1.36 2021/04/24 16:24:14 tsutsui Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -45,7 +45,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ms.c,v 1.35 2021/02/07 16:13:56 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ms.c,v 1.36 2021/04/24 16:24:14 tsutsui Exp $");
#include <sys/param.h>
#include <sys/conf.h>
@@ -87,6 +87,16 @@
#define MS_BPS 4800
/*
+ * Send mouse commands per MS_TICK.
+ */
+#ifndef HZ
+#define HZ 100
+#endif
+#define MS_TICK 2
+#define MS_TIMEOUT_SEC 5
+#define MS_TIMEOUT ((MS_TIMEOUT_SEC * HZ) / MS_TICK)
+
+/*
* Mouse state. A SHARP X1/X680x0 mouse is a fairly simple device,
* producing three-byte blobs of the form:
*
@@ -258,7 +268,7 @@
ms->ms_nodata = 0;
/* start sequencer */
- ms_modem(ms);
+ callout_reset(&ms->ms_modem_ch, MS_TICK, ms_modem, ms);
return 0;
}
@@ -649,9 +659,9 @@
mutex_enter(&ms->ms_lock);
- if (ms->ms_nodata++ > 250) { /* XXX */
- log(LOG_ERR, "%s: no data for 5 secs. resetting.\n",
- device_xname(ms->ms_dev));
+ if (ms->ms_nodata++ > MS_TIMEOUT) {
+ log(LOG_ERR, "%s: no data for %d secs. resetting.\n",
+ device_xname(ms->ms_dev), MS_TIMEOUT_SEC);
ms->ms_byteno = -1;
ms->ms_nodata = 0;
ms->ms_rts = 0;
@@ -670,5 +680,5 @@
}
mutex_exit(&ms->ms_lock);
- callout_reset(&ms->ms_modem_ch, 2, ms_modem, ms);
+ callout_schedule(&ms->ms_modem_ch, MS_TICK);
}
Home |
Main Index |
Thread Index |
Old Index