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 Misc cleanup. No functional changes, no ...



details:   https://anonhg.NetBSD.org/src/rev/2a15f1404219
branches:  trunk
changeset: 368138:2a15f1404219
user:      tsutsui <tsutsui%NetBSD.org@localhost>
date:      Sat Jun 25 14:27:43 2022 +0000

description:
Misc cleanup.  No functional changes, no regression on TT030.

- KNF and TAB/space
- make local functions static
- avoid unnesessary __USE()
- use proper integer types
- remove a register keyword

diffstat:

 sys/arch/atari/dev/kbd.c |  333 +++++++++++++++++++++++-----------------------
 1 files changed, 168 insertions(+), 165 deletions(-)

diffs (truncated from 632 to 300 lines):

diff -r 23c279a18e24 -r 2a15f1404219 sys/arch/atari/dev/kbd.c
--- a/sys/arch/atari/dev/kbd.c  Sat Jun 25 13:24:34 2022 +0000
+++ b/sys/arch/atari/dev/kbd.c  Sat Jun 25 14:27:43 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kbd.c,v 1.49 2021/08/07 16:18:46 thorpej Exp $ */
+/*     $NetBSD: kbd.c,v 1.50 2022/06/25 14:27:43 tsutsui Exp $ */
 
 /*
  * Copyright (c) 1995 Leo Weppelman
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kbd.c,v 1.49 2021/08/07 16:18:46 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kbd.c,v 1.50 2022/06/25 14:27:43 tsutsui Exp $");
 
 #include "mouse.h"
 #include "ite.h"
@@ -106,12 +106,12 @@
 static struct kbd_softc kbd_softc;
 
 /* {b,c}devsw[] function prototypes */
-dev_type_open(kbdopen);
-dev_type_close(kbdclose);
-dev_type_read(kbdread);
-dev_type_ioctl(kbdioctl);
-dev_type_poll(kbdpoll);
-dev_type_kqfilter(kbdkqfilter);
+static dev_type_open(kbdopen);
+static dev_type_close(kbdclose);
+static dev_type_read(kbdread);
+static dev_type_ioctl(kbdioctl);
+static dev_type_poll(kbdpoll);
+static dev_type_kqfilter(kbdkqfilter);
 
 /* Interrupt handler */
 void   kbdintr(int);
@@ -119,7 +119,7 @@
 static void kbdsoft(void *);
 static void kbdattach(device_t, device_t, void *);
 static int  kbdmatch(device_t, cfdata_t, void *);
-#if NITE>0
+#if NITE > 0
 static int  kbd_do_modifier(uint8_t);
 #endif
 static int  kbd_write_poll(const uint8_t *, int);
@@ -161,20 +161,20 @@
 };
 
 static struct wskbd_consops kbd_consops = {
-        kbd_getc,
+       kbd_getc,
        kbd_pollc,
        kbd_bell
 };
 
 /* Pointer to keymaps. */
 static struct wskbd_mapdata kbd_mapdata = {
-        atarikbd_keydesctab,
+       atarikbd_keydesctab,
        KB_US
 };
 #endif /* WSKBD */
 
 /*ARGSUSED*/
-static int
+static int
 kbdmatch(device_t parent, cfdata_t cf, void *aux)
 {
 
@@ -207,16 +207,16 @@
        /*
         * Clear error conditions
         */
-       while (KBD->ac_cs & (A_IRQ|A_RXRDY))
+       while ((KBD->ac_cs & (A_IRQ | A_RXRDY)) != 0)
                timeout = KBD->ac_da;
 
        /*
         * Now send the reset string, and read+ignore its response
         */
-       if (!kbd_write_poll(kbd_rst, 2))
+       if (kbd_write_poll(kbd_rst, 2) == 0)
                printf("kbd: error cannot reset keyboard\n");
        for (timeout = 1000; timeout > 0; timeout--) {
-               if (KBD->ac_cs & (A_IRQ|A_RXRDY)) {
+               if ((KBD->ac_cs & (A_IRQ | A_RXRDY)) != 0) {
                        timeout = KBD->ac_da;
                        timeout = 100;
                }
@@ -231,7 +231,7 @@
 
        kbd_softc.k_sicookie = softint_establish(SOFTINT_SERIAL, kbdsoft, NULL);
 
-#if NWSKBD>0
+#if NWSKBD > 0
        if (self != NULL) {
                /*
                 * Try to attach the wskbd.
@@ -258,20 +258,19 @@
 void
 kbdenable(void)
 {
-       int s, code;
+       int s;
 
        s = spltty();
 
        /*
         * Clear error conditions...
         */
-       while (KBD->ac_cs & (A_IRQ|A_RXRDY))
-               code = KBD->ac_da;
-       __USE(code);
+       while ((KBD->ac_cs & (A_IRQ | A_RXRDY)) != 0)
+               (void)KBD->ac_da;
        /*
         * Enable interrupts from MFP
         */
-       MFP->mf_iprb  = (u_int8_t)~IB_AINT;
+       MFP->mf_iprb  = (uint8_t)~IB_AINT;
        MFP->mf_ierb |= IB_AINT;
        MFP->mf_imrb |= IB_AINT;
 
@@ -281,7 +280,8 @@
        splx(s);
 }
 
-int kbdopen(dev_t dev, int flags, int mode, struct lwp *l)
+static int
+kbdopen(dev_t dev, int flags, int mode, struct lwp *l)
 {
 
        if (kbd_softc.k_events.ev_io)
@@ -292,7 +292,7 @@
        return 0;
 }
 
-int
+static int
 kbdclose(dev_t dev, int flags, int mode, struct lwp *l)
 {
 
@@ -303,64 +303,64 @@
        return 0;
 }
 
-int
+static int
 kbdread(dev_t dev, struct uio *uio, int flags)
 {
 
        return ev_read(&kbd_softc.k_events, uio, flags);
 }
 
-int
+static int
 kbdioctl(dev_t dev, u_long cmd, register void *data, int flag, struct lwp *l)
 {
-       register struct kbd_softc *k = &kbd_softc;
+       struct kbd_softc *k = &kbd_softc;
        struct kbdbell  *kb;
 
        switch (cmd) {
-               case KIOCTRANS:
-                       if (*(int *)data == TR_UNTRANS_EVENT)
-                               return 0;
-                       break;
-
-               case KIOCGTRANS:
-                       /*
-                        * Get translation mode
-                        */
-                       *(int *)data = TR_UNTRANS_EVENT;
-                       return 0;
-
-               case KIOCSDIRECT:
-                       k->k_event_mode = *(int *)data;
+       case KIOCTRANS:
+               if (*(int *)data == TR_UNTRANS_EVENT)
                        return 0;
-               
-               case KIOCRINGBELL:
-                       kb = (struct kbdbell *)data;
-                       if (kb)
-                               kbd_bell_sparms(kb->volume, kb->pitch,
-                                   kb->duration);
-                       kbdbell();
-                       return 0;
+               break;
+
+       case KIOCGTRANS:
+               /*
+                * Get translation mode
+                */
+               *(int *)data = TR_UNTRANS_EVENT;
+               return 0;
 
-               case FIONBIO:   /* we will remove this someday (soon???) */
-                       return 0;
+       case KIOCSDIRECT:
+               k->k_event_mode = *(int *)data;
+               return 0;
+
+       case KIOCRINGBELL:
+               kb = (struct kbdbell *)data;
+               if (kb)
+                       kbd_bell_sparms(kb->volume, kb->pitch,
+                           kb->duration);
+               kbdbell();
+               return 0;
 
-               case FIOASYNC:
-                       k->k_events.ev_async = *(int *)data != 0;
-                               return 0;
+       case FIONBIO:   /* we will remove this someday (soon???) */
+               return 0;
+
+       case FIOASYNC:
+               k->k_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)
-                               return EPERM;
-                       return 0;
+       case FIOSETOWN:
+               if (-*(int *)data != k->k_events.ev_io->p_pgid &&
+                   *(int *)data != k->k_events.ev_io->p_pid)
+                       return EPERM;
+               return 0;
 
-               case TIOCSPGRP:
-                       if (*(int *)data != k->k_events.ev_io->p_pgid)
-                               return EPERM;
-                       return 0;
+       case TIOCSPGRP:
+               if (*(int *)data != k->k_events.ev_io->p_pgid)
+                       return EPERM;
+               return 0;
 
-               default:
-                       return ENOTTY;
+       default:
+               return ENOTTY;
        }
 
        /*
@@ -369,14 +369,14 @@
        return EOPNOTSUPP;              /* misuse, but what the heck */
 }
 
-int
-kbdpoll (dev_t dev, int events, struct lwp *l)
+static int
+kbdpoll(dev_t dev, int events, struct lwp *l)
 {
 
        return ev_poll(&kbd_softc.k_events, events, l);
 }
 
-int
+static int
 kbdkqfilter(dev_t dev, struct knote *kn)
 {
 
@@ -388,28 +388,29 @@
  */
 void
 kbdintr(int sr)
-       /* sr:   sr at time of interrupt        */
+       /* sr: sr at time of interrupt  */
 {
-       int     code;
-       int     got_char = 0;
+       uint8_t code;
+       bool got_char = false;
 
        /*
         * There may be multiple keys available. Read them all.
         */
-       while (KBD->ac_cs & (A_RXRDY|A_OE|A_PE)) {
-               got_char = 1;
-               if (KBD->ac_cs & (A_OE|A_PE)) {
-                       code = KBD->ac_da;      /* Silently ignore errors */
+       while ((KBD->ac_cs & (A_RXRDY | A_OE | A_PE)) != 0) {
+               got_char = true;
+               code = KBD->ac_da;
+               if ((KBD->ac_cs & (A_OE | A_PE)) != 0) {
+                       /* Silently ignore errors */
                        continue;
                }
-               kbd_ring[kbd_rbput++ & KBD_RING_MASK] = KBD->ac_da;
+               kbd_ring[kbd_rbput++ & KBD_RING_MASK] = code;
        }
-       __USE(code);
 
        /*
         * If characters are waiting for transmit, send them.



Home | Main Index | Thread Index | Old Index