Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/hpcsh/dev Don't reschedule the callout in the scann...



details:   https://anonhg.NetBSD.org/src/rev/5ca86a8341cf
branches:  trunk
changeset: 825941:5ca86a8341cf
user:      uwe <uwe%NetBSD.org@localhost>
date:      Mon Aug 07 23:42:11 2017 +0000

description:
Don't reschedule the callout in the scanning function itself, as that
conflicts with using the same function for polled console.

Makes early ddb work with wscons console again on my Jornada 690.

diffstat:

 sys/arch/hpcsh/dev/pfckbd.c |  66 +++++++++++++++++++++-----------------------
 1 files changed, 32 insertions(+), 34 deletions(-)

diffs (183 lines):

diff -r 2cfe6ab50d66 -r 5ca86a8341cf sys/arch/hpcsh/dev/pfckbd.c
--- a/sys/arch/hpcsh/dev/pfckbd.c       Mon Aug 07 22:08:12 2017 +0000
+++ b/sys/arch/hpcsh/dev/pfckbd.c       Mon Aug 07 23:42:11 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pfckbd.c,v 1.29 2012/02/12 16:34:08 matt Exp $ */
+/*     $NetBSD: pfckbd.c,v 1.30 2017/08/07 23:42:11 uwe Exp $  */
 
 /*-
  * Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  * currently, HP Jornada 680/690, HITACHI PERSONA HPW-50PAD only.
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pfckbd.c,v 1.29 2012/02/12 16:34:08 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pfckbd.c,v 1.30 2017/08/07 23:42:11 uwe Exp $");
 
 #include "debug_hpcsh.h"
 
@@ -66,7 +66,7 @@
        struct hpckbd_ic_if pc_if;
        struct hpckbd_if *pc_hpckbd;
        uint16_t pc_column[8];
-       void (*pc_callout)(void *);
+       void (*pc_callout)(struct pfckbd_core *);
 } pfckbd_core;
 
 static int pfckbd_match(device_t, cfdata_t, void *);
@@ -83,17 +83,17 @@
 
 static void pfckbd_input(struct pfckbd_core *, int, uint16_t);
 
-static void (*pfckbd_callout_lookup(void))(void *);
-static void pfckbd_callout_unknown(void *);
-static void pfckbd_callout_hp(void *);
-static void pfckbd_callout_hitachi(void *);
+static void (*pfckbd_callout_lookup(void))(struct pfckbd_core *);
+static void pfckbd_callout(void *);
+static void pfckbd_callout_hp(struct pfckbd_core *);
+static void pfckbd_callout_hitachi(struct pfckbd_core *);
 void pfckbd_poll_hitachi_power(void);
 
 
 /* callout function table. this function is platfrom specific. */
 static const struct {
        platid_mask_t *platform;
-       void (*func)(void *);
+       void (*func)(struct pfckbd_core *);
 } pfckbd_calloutfunc_table[] = {
        { &platid_mask_MACH_HP          , pfckbd_callout_hp },
        { &platid_mask_MACH_HITACHI     , pfckbd_callout_hitachi }
@@ -144,9 +144,13 @@
        config_found(self, &haa, hpckbd_print);
 
        /* install callout handler */
-       callout_init(&pfckbd_core.pc_soft_ch, 0);
-       callout_reset(&pfckbd_core.pc_soft_ch, 1,
-                     pfckbd_core.pc_callout, &pfckbd_core);
+       if (pfckbd_core.pc_callout != NULL) {
+               callout_init(&pfckbd_core.pc_soft_ch, 0);
+               callout_reset(&pfckbd_core.pc_soft_ch, 1,
+                             pfckbd_callout, &pfckbd_core);
+       }
+       else
+               aprint_error_dev(self, "unsupported platform\n");
 
        if (!pmf_device_register(self, NULL, NULL))
                aprint_error_dev(self, "unable to establish power handler\n");
@@ -191,12 +195,22 @@
 {
        struct pfckbd_core *pc = ic;
 
-       if (pc->pc_enabled)
+       if (pc->pc_enabled && pc->pc_callout != NULL)
                (*pc->pc_callout)(pc);
 
        return 0;
 }
 
+static void
+pfckbd_callout(void *arg)
+{
+       struct pfckbd_core *pc = arg;
+
+       (*pc->pc_callout)(pc);
+       callout_schedule(&pc->pc_soft_ch, 1);
+}
+
+
 /*
  * Called by platform specific scan routines to report key events to hpckbd
  */
@@ -230,7 +244,7 @@
 
 /* Look up appropriate callback handler */
 static void
-(*pfckbd_callout_lookup(void))(void *)
+(*pfckbd_callout_lookup(void))(struct pfckbd_core *)
 {
        int i, n;
 
@@ -242,22 +256,14 @@
                                 pfckbd_calloutfunc_table[i].platform))
                        return pfckbd_calloutfunc_table[i].func;
 
-       return pfckbd_callout_unknown;
-}
-
-/* Placeholder for unknown platform */
-static void
-pfckbd_callout_unknown(void *arg)
-{
-
-       printf("%s: unknown keyboard switch\n", __func__);
+       return NULL;
 }
 
 /*
  * HP Jornada680/690, HP620LX
  */
 static void
-pfckbd_callout_hp(void *arg)
+pfckbd_callout_hp(struct pfckbd_core *pc)
 {
 #define PFCKBD_HP_PDCR_MASK 0xcc0c
 #define PFCKBD_HP_PECR_MASK 0xf0cf
@@ -288,13 +294,12 @@
 #undef PD
 #undef PE
 
-       struct pfckbd_core *pc = arg;
        uint16_t dc, ec;
        int column;
        uint16_t data;
 
        if (!pc->pc_enabled)
-               goto reinstall;
+               return;
 
        /* bits in D/E control regs we do not touch (XXX: can they change?) */
        dc = _reg_read_2(SH7709_PDCR) & ~PFCKBD_HP_PDCR_MASK;
@@ -330,16 +335,13 @@
        /* (ignore) extra keys/events (recorder buttons, lid, cable &c) */
        data = _reg_read_1(SH7709_PGDR) | (_reg_read_1(SH7709_PHDR) << 8);
 #endif
-
- reinstall:
-       callout_schedule(&pc->pc_soft_ch, 1);
 }
 
 /*
  * HITACH PERSONA (HPW-50PAD)
  */
 static void
-pfckbd_callout_hitachi(void *arg)
+pfckbd_callout_hitachi(struct pfckbd_core *pc)
 {
 #define PFCKBD_HITACHI_PCCR_MASK 0xfff3
 #define PFCKBD_HITACHI_PDCR_MASK 0x000c
@@ -389,13 +391,12 @@
                PC(3), PC(2), PD(1), PC(0)
        };
 
-       struct pfckbd_core *pc = arg;
        uint16_t cc, dc, ec;
        uint8_t data[2], cd, dd, ed;
        int i;
 
        if (!pc->pc_enabled)
-               goto reinstall;
+               return;
 
        /* bits in C/D/E control regs we do not touch (XXX: can they change?) */
        cc = _reg_read_2(SH7709_PCCR) & ~PFCKBD_HITACHI_PCCR_MASK;
@@ -432,9 +433,6 @@
        _reg_write_2(SH7709_PCCR, cc | (0x5555 & PFCKBD_HITACHI_PCCR_MASK));
        _reg_write_2(SH7709_PDCR, dc | (0x5555 & PFCKBD_HITACHI_PDCR_MASK));
        _reg_write_2(SH7709_PECR, ec | (0x5555 & PFCKBD_HITACHI_PECR_MASK));
-
- reinstall:
-       callout_schedule(&pc->pc_soft_ch, 1);
 }
 
 void



Home | Main Index | Thread Index | Old Index