Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/atari/dev Rename and reformat softc stuff for reada...



details:   https://anonhg.NetBSD.org/src/rev/f6fca0af8311
branches:  trunk
changeset: 368140:f6fca0af8311
user:      tsutsui <tsutsui%NetBSD.org@localhost>
date:      Sat Jun 25 15:10:26 2022 +0000

description:
Rename and reformat softc stuff for readablity, and misc more cleanups.

No binary change.

diffstat:

 sys/arch/atari/dev/kbd.c |  215 ++++++++++++++++++++++++----------------------
 1 files changed, 113 insertions(+), 102 deletions(-)

diffs (truncated from 557 to 300 lines):

diff -r f817e7d74d95 -r f6fca0af8311 sys/arch/atari/dev/kbd.c
--- a/sys/arch/atari/dev/kbd.c  Sat Jun 25 14:39:19 2022 +0000
+++ b/sys/arch/atari/dev/kbd.c  Sat Jun 25 15:10:26 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kbd.c,v 1.51 2022/06/25 14:39:19 tsutsui Exp $ */
+/*     $NetBSD: kbd.c,v 1.52 2022/06/25 15:10:26 tsutsui Exp $ */
 
 /*
  * Copyright (c) 1995 Leo Weppelman
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kbd.c,v 1.51 2022/06/25 14:39:19 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kbd.c,v 1.52 2022/06/25 15:10:26 tsutsui Exp $");
 
 #include "mouse.h"
 #include "ite.h"
@@ -78,21 +78,21 @@
 #define KBD_RING_MASK  255   /* Modulo mask for above                       */
 
 struct kbd_softc {
-       int             k_event_mode;   /* if 1, collect events,        */
+       int             sc_event_mode;  /* if 1, collect events,        */
                                        /*   else pass to ite           */
-       struct evvar    k_events;       /* event queue state            */
-       uint8_t         k_soft_cs;      /* control-reg. copy            */
-       uint8_t         k_package[20];  /* XXX package being build      */
-       uint8_t         k_pkg_size;     /* Size of the package          */
-       uint8_t         k_pkg_idx;      /* Running pkg assembly index   */
-       uint8_t         k_pkg_type;     /* Type of package              */
-       const uint8_t   *k_sendp;       /* Output pointer               */
-       int             k_send_cnt;     /* Chars left for output        */
+       struct evvar    sc_events;      /* event queue state            */
+       uint8_t         sc_soft_cs;     /* control-reg. copy            */
+       uint8_t         sc_package[20]; /* XXX package being build      */
+       uint8_t         sc_pkg_size;    /* Size of the package          */
+       uint8_t         sc_pkg_idx;     /* Running pkg assembly index   */
+       uint8_t         sc_pkg_type;    /* Type of package              */
+       const uint8_t   *sc_sendp;      /* Output pointer               */
+       int             sc_send_cnt;    /* Chars left for output        */
 #if NWSKBD > 0
-       device_t        k_wskbddev;   /* pointer to wskbd for sending strokes */
-       int             k_pollingmode;  /* polling mode on? whatever it is... */
+       device_t        sc_wskbddev;  /* pointer to wskbd for sending strokes */
+       int             sc_pollingmode; /* polling mode on? whatever it is... */
 #endif
-       void            *k_sicookie;    /* softint(9) cookie            */
+       void            *sc_sicookie;   /* softint(9) cookie            */
 };
 
 /* WSKBD */
@@ -128,7 +128,7 @@
 static volatile u_int  kbd_rbput = 0;  /* 'put' index                  */
 static u_int           kbd_rbget = 0;  /* 'get' index                  */
 
-static struct kbd_softc kbd_softc;
+static struct kbd_softc kbd_softc;     /* XXX */
 
 /* {b,c}devsw[] function prototypes */
 static dev_type_open(kbdopen);
@@ -209,6 +209,7 @@
 static void
 kbdattach(device_t parent, device_t self, void *aux)
 {
+       struct kbd_softc *sc = &kbd_softc;
        int timeout;
        const uint8_t kbd_rst[]  = { 0x80, 0x01 };
        const uint8_t kbd_icmd[] = { 0x12, 0x15 };
@@ -224,7 +225,7 @@
         */
        KBD->ac_cs = A_RESET;
        delay(100);     /* XXX: enough? */
-       KBD->ac_cs = kbd_softc.k_soft_cs = KBD_INIT | A_RXINT;
+       KBD->ac_cs = sc->sc_soft_cs = KBD_INIT | A_RXINT;
 
        /*
         * Clear error conditions
@@ -251,7 +252,7 @@
 
        printf("\n");
 
-       kbd_softc.k_sicookie = softint_establish(SOFTINT_SERIAL, kbdsoft, NULL);
+       sc->sc_sicookie = softint_establish(SOFTINT_SERIAL, kbdsoft, NULL);
 
 #if NWSKBD > 0
        if (self != NULL) {
@@ -267,10 +268,10 @@
                waa.keymap = &kbd_mapdata;
                waa.accessops = &kbd_accessops;
                waa.accesscookie = NULL;
-               kbd_softc.k_wskbddev = config_found(self, &waa, wskbddevprint,
+               sc->sc_wskbddev = config_found(self, &waa, wskbddevprint,
                    CFARGS_NONE);
 
-               kbd_softc.k_pollingmode = 0;
+               sc->sc_pollingmode = 0;
 
                kbdenable();
        }
@@ -280,6 +281,7 @@
 void
 kbdenable(void)
 {
+       struct kbd_softc *sc = &kbd_softc;
        int s;
 
        s = spltty();
@@ -296,47 +298,50 @@
        MFP->mf_ierb |= IB_AINT;
        MFP->mf_imrb |= IB_AINT;
 
-       kbd_softc.k_event_mode   = 0;
-       kbd_softc.k_events.ev_io = 0;
-       kbd_softc.k_pkg_size     = 0;
+       sc->sc_event_mode   = 0;
+       sc->sc_events.ev_io = 0;
+       sc->sc_pkg_size     = 0;
        splx(s);
 }
 
 static int
 kbdopen(dev_t dev, int flags, int mode, struct lwp *l)
 {
+       struct kbd_softc *sc = &kbd_softc;
 
-       if (kbd_softc.k_events.ev_io)
+       if (sc->sc_events.ev_io)
                return EBUSY;
 
-       kbd_softc.k_events.ev_io = l->l_proc;
-       ev_init(&kbd_softc.k_events);
+       sc->sc_events.ev_io = l->l_proc;
+       ev_init(&sc->sc_events);
        return 0;
 }
 
 static int
 kbdclose(dev_t dev, int flags, int mode, struct lwp *l)
 {
+       struct kbd_softc *sc = &kbd_softc;
 
        /* Turn off event mode, dump the queue */
-       kbd_softc.k_event_mode = 0;
-       ev_fini(&kbd_softc.k_events);
-       kbd_softc.k_events.ev_io = NULL;
+       sc->sc_event_mode = 0;
+       ev_fini(&sc->sc_events);
+       sc->sc_events.ev_io = NULL;
        return 0;
 }
 
 static int
 kbdread(dev_t dev, struct uio *uio, int flags)
 {
+       struct kbd_softc *sc = &kbd_softc;
 
-       return ev_read(&kbd_softc.k_events, uio, flags);
+       return ev_read(&sc->sc_events, uio, flags);
 }
 
 static int
-kbdioctl(dev_t dev, u_long cmd, register void *data, int flag, struct lwp *l)
+kbdioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l)
 {
-       struct kbd_softc *k = &kbd_softc;
-       struct kbdbell  *kb;
+       struct kbd_softc *sc = &kbd_softc;
+       struct kbdbell *kb;
 
        switch (cmd) {
        case KIOCTRANS:
@@ -352,7 +357,7 @@
                return 0;
 
        case KIOCSDIRECT:
-               k->k_event_mode = *(int *)data;
+               sc->sc_event_mode = *(int *)data;
                return 0;
 
        case KIOCRINGBELL:
@@ -367,17 +372,17 @@
                return 0;
 
        case FIOASYNC:
-               k->k_events.ev_async = *(int *)data != 0;
+               sc->sc_events.ev_async = *(int *)data != 0;
                return 0;
 
        case FIOSETOWN:
-               if (-*(int *)data != k->k_events.ev_io->p_pgid &&
-                   *(int *)data != k->k_events.ev_io->p_pid)
+               if (-*(int *)data != sc->sc_events.ev_io->p_pgid &&
+                   *(int *)data != sc->sc_events.ev_io->p_pid)
                        return EPERM;
                return 0;
 
        case TIOCSPGRP:
-               if (*(int *)data != k->k_events.ev_io->p_pgid)
+               if (*(int *)data != sc->sc_events.ev_io->p_pgid)
                        return EPERM;
                return 0;
 
@@ -394,15 +399,17 @@
 static int
 kbdpoll(dev_t dev, int events, struct lwp *l)
 {
+       struct kbd_softc *sc = &kbd_softc;
 
-       return ev_poll(&kbd_softc.k_events, events, l);
+       return ev_poll(&sc->sc_events, events, l);
 }
 
 static int
 kbdkqfilter(dev_t dev, struct knote *kn)
 {
+       struct kbd_softc *sc = &kbd_softc;
 
-       return ev_kqfilter(&kbd_softc.k_events, kn);
+       return ev_kqfilter(&sc->sc_events, kn);
 }
 
 /*
@@ -412,6 +419,7 @@
 kbdintr(int sr)
        /* sr: sr at time of interrupt  */
 {
+       struct kbd_softc *sc = &kbd_softc;
        uint8_t code;
        bool got_char = false;
 
@@ -431,19 +439,19 @@
        /*
         * If characters are waiting for transmit, send them.
         */
-       if ((kbd_softc.k_soft_cs & A_TXINT) != 0 &&
+       if ((sc->sc_soft_cs & A_TXINT) != 0 &&
            (KBD->ac_cs & A_TXRDY) != 0) {
-               if (kbd_softc.k_sendp != NULL)
-                       KBD->ac_da = *kbd_softc.k_sendp++;
-               if (--kbd_softc.k_send_cnt <= 0) {
+               if (sc->sc_sendp != NULL)
+                       KBD->ac_da = *sc->sc_sendp++;
+               if (--sc->sc_send_cnt <= 0) {
                        /*
                         * The total package has been transmitted,
                         * wakeup anyone waiting for it.
                         */
-                       KBD->ac_cs = (kbd_softc.k_soft_cs &= ~A_TXINT);
-                       kbd_softc.k_sendp    = NULL;
-                       kbd_softc.k_send_cnt = 0;
-                       wakeup((void *)&kbd_softc.k_send_cnt);
+                       KBD->ac_cs = (sc->sc_soft_cs &= ~A_TXINT);
+                       sc->sc_sendp = NULL;
+                       sc->sc_send_cnt = 0;
+                       wakeup((void *)&sc->sc_send_cnt);
                }
        }
 
@@ -451,7 +459,7 @@
         * Activate software-level to handle possible input.
         */
        if (got_char)
-               softint_schedule(kbd_softc.k_sicookie);
+               softint_schedule(sc->sc_sicookie);
 }
 
 /*
@@ -460,9 +468,9 @@
 static void
 kbdsoft(void *junk1)
 {
+       struct kbd_softc *sc = &kbd_softc;
        int s;
        uint8_t code;
-       struct kbd_softc *k = &kbd_softc;
        struct firm_event *fe;
        int put, get, n;
 
@@ -484,24 +492,25 @@
                         * If collecting a package, stuff it in and
                         * continue.
                         */
-                       if (k->k_pkg_size && (k->k_pkg_idx < k->k_pkg_size)) {
-                           k->k_package[k->k_pkg_idx++] = code;
-                               if (k->k_pkg_idx == k->k_pkg_size) {
+                       if (sc->sc_pkg_size &&
+                           (sc->sc_pkg_idx < sc->sc_pkg_size)) {
+                               sc->sc_package[sc->sc_pkg_idx++] = code;
+                               if (sc->sc_pkg_idx == sc->sc_pkg_size) {
                                        /*
                                         * Package is complete.
                                         */
-                                       switch (k->k_pkg_type) {
+                                       switch (sc->sc_pkg_type) {
 #if NMOUSE > 0
                                        case KBD_AMS_PKG:
                                        case KBD_RMS_PKG:
                                        case KBD_JOY1_PKG:
                                                mouse_soft(



Home | Main Index | Thread Index | Old Index