Module Name: src
Committed By: tsutsui
Date: Fri Jul 3 13:36:09 UTC 2009
Modified Files:
src/sys/arch/atari/dev: kbd.c
Log Message:
KNF, use uint8_t, and misc cosmetics.
To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/sys/arch/atari/dev/kbd.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/atari/dev/kbd.c
diff -u src/sys/arch/atari/dev/kbd.c:1.36 src/sys/arch/atari/dev/kbd.c:1.37
--- src/sys/arch/atari/dev/kbd.c:1.36 Wed Mar 18 10:22:24 2009
+++ src/sys/arch/atari/dev/kbd.c Fri Jul 3 13:36:09 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: kbd.c,v 1.36 2009/03/18 10:22:24 cegger Exp $ */
+/* $NetBSD: kbd.c,v 1.37 2009/07/03 13:36:09 tsutsui Exp $ */
/*
* Copyright (c) 1995 Leo Weppelman
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kbd.c,v 1.36 2009/03/18 10:22:24 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kbd.c,v 1.37 2009/07/03 13:36:09 tsutsui Exp $");
#include "mouse.h"
#include "ite.h"
@@ -97,12 +97,12 @@
* - If an ite is present the data may be fed to it.
*/
-u_char kbd_modifier; /* Modifier mask */
+uint8_t kbd_modifier; /* Modifier mask */
-static u_char kbd_ring[KBD_RING_SIZE];
+static uint8_t kbd_ring[KBD_RING_SIZE];
static volatile u_int kbd_rbput = 0; /* 'put' index */
static u_int kbd_rbget = 0; /* 'get' index */
-static u_char kbd_soft = 0; /* 1: Softint has been scheduled*/
+static uint8_t kbd_soft = 0; /* 1: Softint has been scheduled*/
static struct kbd_softc kbd_softc;
@@ -121,10 +121,10 @@
static void kbdattach(struct device *, struct device *, void *);
static int kbdmatch(struct device *, struct cfdata *, void *);
#if NITE>0
-static int kbd_do_modifier(u_char);
+static int kbd_do_modifier(uint8_t);
#endif
-static int kbd_write_poll(u_char *, int);
-static void kbd_pkg_start(struct kbd_softc *, u_char);
+static int kbd_write_poll(uint8_t *, int);
+static void kbd_pkg_start(struct kbd_softc *, uint8_t);
CFATTACH_DECL(kbd, sizeof(struct device),
kbdmatch, kbdattach, NULL, NULL);
@@ -168,18 +168,19 @@
static int
kbdmatch(struct device *pdp, struct cfdata *cfp, void *auxp)
{
+
if (!strcmp((char *)auxp, "kbd"))
- return (1);
- return (0);
+ return 1;
+ return 0;
}
/*ARGSUSED*/
static void
kbdattach(struct device *pdp, struct device *dp, void *auxp)
{
- int timeout;
- u_char kbd_rst[] = { 0x80, 0x01 };
- u_char kbd_icmd[] = { 0x12, 0x15 };
+ int timeout;
+ uint8_t kbd_rst[] = { 0x80, 0x01 };
+ uint8_t kbd_icmd[] = { 0x12, 0x15 };
/*
* Disable keyboard interrupts from MFP
@@ -245,7 +246,7 @@
void
kbdenable(void)
{
- int s, code;
+ int s, code;
s = spltty();
@@ -269,32 +270,35 @@
int kbdopen(dev_t dev, int flags, int mode, struct lwp *l)
{
+
if (kbd_softc.k_events.ev_io)
return EBUSY;
kbd_softc.k_events.ev_io = l->l_proc;
ev_init(&kbd_softc.k_events);
- return (0);
+ return 0;
}
int
kbdclose(dev_t dev, int flags, int mode, struct lwp *l)
{
+
/* 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;
- return (0);
+ return 0;
}
int
kbdread(dev_t dev, struct uio *uio, int flags)
{
+
return ev_read(&kbd_softc.k_events, uio, flags);
}
int
-kbdioctl(dev_t dev,u_long cmd,register void *data,int flag,struct lwp *l)
+kbdioctl(dev_t dev, u_long cmd, register void *data, int flag, struct lwp *l)
{
register struct kbd_softc *k = &kbd_softc;
struct kbdbell *kb;
@@ -320,7 +324,7 @@
kb = (struct kbdbell *)data;
if (kb)
kbd_bell_sparms(kb->volume, kb->pitch,
- kb->duration);
+ kb->duration);
kbdbell();
return 0;
@@ -355,14 +359,15 @@
int
kbdpoll (dev_t dev, int events, struct lwp *l)
{
- return ev_poll (&kbd_softc.k_events, events, l);
+
+ return ev_poll(&kbd_softc.k_events, events, l);
}
int
kbdkqfilter(dev_t dev, struct knote *kn)
{
- return (ev_kqfilter(&kbd_softc.k_events, kn));
+ return ev_kqfilter(&kbd_softc.k_events, kn);
}
/*
@@ -425,12 +430,11 @@
void
kbdsoft(void *junk1, void *junk2)
{
- int s;
- u_char code;
- struct kbd_softc *k = &kbd_softc;
- struct firm_event *fe;
- int put;
- int n, get;
+ int s;
+ uint8_t code;
+ struct kbd_softc *k = &kbd_softc;
+ struct firm_event *fe;
+ int put, get, n;
kbd_soft = 0;
get = kbd_rbget;
@@ -457,13 +461,13 @@
/*
* Package is complete.
*/
- switch(k->k_pkg_type) {
+ switch (k->k_pkg_type) {
#if NMOUSE > 0
case KBD_AMS_PKG:
case KBD_RMS_PKG:
case KBD_JOY1_PKG:
mouse_soft((REL_MOUSE *)k->k_package,
- k->k_pkg_size, k->k_pkg_type);
+ k->k_pkg_size, k->k_pkg_type);
#endif /* NMOUSE */
}
k->k_pkg_size = 0;
@@ -479,9 +483,9 @@
}
#if NWSKBD>0
/*
- * If we have attached a wskbd and not in polling mode and
- * nobody has opened us directly, then send the keystroke
- * to the wskbd.
+ * If we have attached a wskbd and not in polling mode
+ * and nobody has opened us directly, then send the
+ * keystroke to the wskbd.
*/
if (kbd_softc.k_pollingmode == 0
@@ -523,7 +527,7 @@
put = (put + 1) % EV_QSIZE;
if (put == k->k_events.ev_get) {
log(LOG_WARNING,
- "keyboard event queue overflow\n");
+ "keyboard event queue overflow\n");
splx(s);
continue;
}
@@ -538,9 +542,9 @@
}
}
-static u_char sound[] = {
- 0xA8,0x01,0xA9,0x01,0xAA,0x01,0x00,
- 0xF8,0x10,0x10,0x10,0x00,0x20,0x03
+static uint8_t sound[] = {
+ 0xA8, 0x01, 0xA9, 0x01, 0xAA, 0x01, 0x00,
+ 0xF8, 0x10, 0x10, 0x10, 0x00, 0x20, 0x03
};
void
@@ -609,9 +613,9 @@
int
kbdgetcn(void)
{
- u_char code;
- int s = spltty();
- int ints_active;
+ uint8_t code;
+ int s = spltty();
+ int ints_active;
ints_active = 0;
if (MFP->mf_imrb & IB_AINT) {
@@ -633,11 +637,11 @@
}
if (ints_active) {
- MFP->mf_iprb = (u_int8_t)~IB_AINT;
+ MFP->mf_iprb = (uint8_t)~IB_AINT;
MFP->mf_imrb |= IB_AINT;
}
- splx (s);
+ splx(s);
return code;
}
@@ -645,7 +649,7 @@
* Write a command to the keyboard in 'polled' mode.
*/
static int
-kbd_write_poll(u_char *cmd, int len)
+kbd_write_poll(uint8_t *cmd, int len)
{
int timeout;
@@ -653,17 +657,17 @@
KBD->ac_da = *cmd++;
for (timeout = 100; !(KBD->ac_cs & A_TXRDY); timeout--)
delay(10);
- if (!(KBD->ac_cs & A_TXRDY))
- return (0);
+ if ((KBD->ac_cs & A_TXRDY) == 0)
+ return 0;
}
- return (1);
+ return 1;
}
/*
* Write a command to the keyboard. Return when command is send.
*/
void
-kbd_write(u_char *cmd, int len)
+kbd_write(uint8_t *cmd, int len)
{
struct kbd_softc *k = &kbd_softc;
int sps;
@@ -709,8 +713,9 @@
* Setup softc-fields to assemble a keyboard package.
*/
static void
-kbd_pkg_start(struct kbd_softc *kp, u_char msg_start)
+kbd_pkg_start(struct kbd_softc *kp, uint8_t msg_start)
{
+
kp->k_pkg_idx = 1;
kp->k_package[0] = msg_start;
switch (msg_start) {
@@ -747,19 +752,19 @@
}
}
-#if NITE>0
+#if NITE > 0
/*
* Modifier processing
*/
static int
-kbd_do_modifier(u_char code)
+kbd_do_modifier(uint8_t code)
{
- u_char up, mask;
+ uint8_t up, mask;
up = KBD_RELEASED(code);
mask = 0;
- switch(KBD_SCANCODE(code)) {
+ switch (KBD_SCANCODE(code)) {
case KBD_LEFT_SHIFT:
mask = KBD_MOD_LSHIFT;
break;
@@ -774,11 +779,11 @@
break;
case KBD_CAPS_LOCK:
/* CAPSLOCK is a toggle */
- if(!up)
+ if (!up)
kbd_modifier ^= KBD_MOD_CAPS;
return 1;
}
- if(mask) {
+ if (mask) {
if(up)
kbd_modifier &= ~mask;
else
@@ -799,6 +804,7 @@
static int
kbd_enable(void *c, int on)
{
+
/* Wonder what this is supposed to do... */
return 0;
}
@@ -806,6 +812,7 @@
static void
kbd_set_leds(void *c, int leds)
{
+
/* we can not set the leds */
}
@@ -814,8 +821,7 @@
{
struct wskbd_bell_data *kd;
- switch (cmd)
- {
+ switch (cmd) {
case WSKBDIO_COMPLEXBELL:
kd = (struct wskbd_bell_data *)data;
kbd_bell(0, kd->pitch, kd->period, kd->volume);
@@ -823,10 +829,10 @@
case WSKBDIO_SETLEDS:
return 0;
case WSKBDIO_GETLEDS:
- *(int*)data = 0;
+ *(int *)data = 0;
return 0;
case WSKBDIO_GTYPE:
- *(u_int*)data = WSKBD_TYPE_ATARI;
+ *(u_int *)data = WSKBD_TYPE_ATARI;
return 0;
}
@@ -834,7 +840,7 @@
* We are supposed to return EPASSTHROUGH to wscons if we didn't
* understand.
*/
- return (EPASSTHROUGH);
+ return EPASSTHROUGH;
}
static void
@@ -850,12 +856,14 @@
static void
kbd_pollc(void *c, int on)
{
+
kbd_softc.k_pollingmode = on;
}
static void
kbd_bell(void *v, u_int pitch, u_int duration, u_int volume)
{
+
kbd_bell_sparms(volume, pitch, duration);
kbdbell();
}