Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/emips/ebus Misc KNF.
details: https://anonhg.NetBSD.org/src/rev/721c694aa3f7
branches: trunk
changeset: 765969:721c694aa3f7
user: tsutsui <tsutsui%NetBSD.org@localhost>
date: Sun Jun 12 05:06:23 2011 +0000
description:
Misc KNF.
diffstat:
sys/arch/emips/ebus/dz_ebus.c | 414 +++++++++++++++++++++--------------------
1 files changed, 214 insertions(+), 200 deletions(-)
diffs (truncated from 797 to 300 lines):
diff -r 545a71471827 -r 721c694aa3f7 sys/arch/emips/ebus/dz_ebus.c
--- a/sys/arch/emips/ebus/dz_ebus.c Sun Jun 12 04:44:27 2011 +0000
+++ b/sys/arch/emips/ebus/dz_ebus.c Sun Jun 12 05:06:23 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dz_ebus.c,v 1.2 2011/04/24 16:26:55 rmind Exp $ */
+/* $NetBSD: dz_ebus.c,v 1.3 2011/06/12 05:06:23 tsutsui Exp $ */
/*-
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dz_ebus.c,v 1.2 2011/04/24 16:26:55 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dz_ebus.c,v 1.3 2011/06/12 05:06:23 tsutsui Exp $");
#include "opt_ddb.h"
@@ -58,13 +58,15 @@
#include <emips/ebus/ebusvar.h>
#include <emips/emips/cons.h>
-//#include <emips/emips/machdep.h>
+#if 0
+#include <emips/emips/machdep.h>
+#endif
#include "ioconf.h" /* for dz_cd */
-#define DZ_C2I(c) ((c)<<3) /* convert controller # to index */
-#define DZ_I2C(c) ((c)>>3) /* convert minor to controller # */
-#define DZ_PORT(u) ((u)&07) /* extract the port # */
+#define DZ_C2I(c) ((c) << 3) /* convert controller # to index */
+#define DZ_I2C(c) ((c) >> 3) /* convert minor to controller # */
+#define DZ_PORT(u) ((u) & 07) /* extract the port # */
struct dz_softc {
struct device sc_dev; /* Autoconf blaha */
@@ -80,7 +82,7 @@
struct dz_linestate {
struct dz_softc *dz_sc; /* backpointer to softc */
int dz_line; /* channel number */
- struct tty * dz_tty; /* what we work on */
+ struct tty *dz_tty; /* what we work on */
} sc_dz;
};
@@ -118,7 +120,7 @@
{
struct tty *tp;
int unit, line;
- struct dz_softc *sc;
+ struct dz_softc *sc;
int s, error = 0;
unit = DZ_I2C(minor(dev));
@@ -133,10 +135,10 @@
tp = sc->sc_dz.dz_tty;
if (tp == NULL)
- return (ENODEV);
- tp->t_oproc = dzstart;
- tp->t_param = dzparam;
- tp->t_dev = dev;
+ return ENODEV;
+ tp->t_oproc = dzstart;
+ tp->t_param = dzparam;
+ tp->t_dev = dev;
if (kauth_authorize_device_tty(l->l_cred, KAUTH_DEVICE_TTY_OPEN, tp))
return (EBUSY);
@@ -150,34 +152,34 @@
tp->t_lflag = TTYDEF_LFLAG;
tp->t_ispeed = tp->t_ospeed = TTYDEF_SPEED;
}
- (void) dzparam(tp, &tp->t_termios);
+ (void)dzparam(tp, &tp->t_termios);
ttsetwater(tp);
}
- /* we have no modem control but..*/
+ /* we have no modem control but..*/
if (dzmctl(sc, line, TIOCM_DTR, DMBIS) & TIOCM_CD)
- tp->t_state |= TS_CARR_ON;
- s = spltty();
- while (!(flag & O_NONBLOCK) && !(tp->t_cflag & CLOCAL) &&
- !(tp->t_state & TS_CARR_ON)) {
- tp->t_wopen++;
- error = ttysleep(tp, &tp->t_rawcv, true, 0);
- tp->t_wopen--;
- if (error)
- break;
- }
- (void) splx(s);
+ tp->t_state |= TS_CARR_ON;
+ s = spltty();
+ while (!(flag & O_NONBLOCK) && !(tp->t_cflag & CLOCAL) &&
+ !(tp->t_state & TS_CARR_ON)) {
+ tp->t_wopen++;
+ error = ttysleep(tp, &tp->t_rawcv, true, 0);
+ tp->t_wopen--;
+ if (error)
+ break;
+ }
+ (void)splx(s);
if (error)
- return (error);
- return ((*tp->t_linesw->l_open)(dev, tp));
+ return error;
+ return (*tp->t_linesw->l_open)(dev, tp);
}
+
int
dzclose(dev_t dev, int flag, int mode, struct lwp *l)
{
- struct dz_softc *sc;
+ struct dz_softc *sc;
struct tty *tp;
int unit, line;
-
unit = DZ_I2C(minor(dev));
line = DZ_PORT(minor(dev));
sc = (void *)dz_cd.cd_devs[unit];
@@ -187,36 +189,37 @@
(*tp->t_linesw->l_close)(tp, flag);
/* Make sure a BREAK state is not left enabled. */
- (void) dzmctl(sc, line, TIOCM_BRK, DMBIC);
+ (void)dzmctl(sc, line, TIOCM_BRK, DMBIC);
/* Do a hangup if so required. */
if ((tp->t_cflag & HUPCL) || tp->t_wopen || !(tp->t_state & TS_ISOPEN))
(void) dzmctl(sc, line, 0, DMSET);
- return (ttyclose(tp));
+ return ttyclose(tp);
}
+
int
dzread(dev_t dev, struct uio *uio, int flag)
{
struct tty *tp;
- struct dz_softc *sc;
+ struct dz_softc *sc;
sc = (void *)dz_cd.cd_devs[DZ_I2C(minor(dev))];
tp = sc->sc_dz.dz_tty;
- return ((*tp->t_linesw->l_read)(tp, uio, flag));
+ return (*tp->t_linesw->l_read)(tp, uio, flag);
}
int
dzwrite(dev_t dev, struct uio *uio, int flag)
{
struct tty *tp;
- struct dz_softc *sc;
+ struct dz_softc *sc;
sc = (void *)dz_cd.cd_devs[DZ_I2C(minor(dev))];
tp = sc->sc_dz.dz_tty;
- return ((*tp->t_linesw->l_write)(tp, uio, flag));
+ return (*tp->t_linesw->l_write)(tp, uio, flag);
}
/*ARGSUSED*/
@@ -235,56 +238,57 @@
error = (*tp->t_linesw->l_ioctl)(tp, cmd, data, flag, l);
if (error >= 0)
- return (error);
+ return error;
error = ttioctl(tp, cmd, data, flag, l);
if (error >= 0)
- return (error);
+ return error;
switch (cmd) {
case TIOCSBRK:
- (void) dzmctl(sc, line, TIOCM_BRK, DMBIS);
+ (void)dzmctl(sc, line, TIOCM_BRK, DMBIS);
break;
case TIOCCBRK:
- (void) dzmctl(sc, line, TIOCM_BRK, DMBIC);
+ (void)dzmctl(sc, line, TIOCM_BRK, DMBIC);
break;
case TIOCSDTR:
- (void) dzmctl(sc, line, TIOCM_DTR, DMBIS);
+ (void)dzmctl(sc, line, TIOCM_DTR, DMBIS);
break;
case TIOCCDTR:
- (void) dzmctl(sc, line, TIOCM_DTR, DMBIC);
+ (void)dzmctl(sc, line, TIOCM_DTR, DMBIC);
break;
case TIOCMSET:
- (void) dzmctl(sc, line, *(int *)data, DMSET);
+ (void)dzmctl(sc, line, *(int *)data, DMSET);
break;
case TIOCMBIS:
- (void) dzmctl(sc, line, *(int *)data, DMBIS);
+ (void)dzmctl(sc, line, *(int *)data, DMBIS);
break;
case TIOCMBIC:
- (void) dzmctl(sc, line, *(int *)data, DMBIC);
+ (void)dzmctl(sc, line, *(int *)data, DMBIC);
break;
case TIOCMGET:
- *(int *)data = (dzmctl(sc, line, 0, DMGET) & ~TIOCM_BRK);
+ *(int *)data = dzmctl(sc, line, 0, DMGET) & ~TIOCM_BRK;
break;
default:
- return (EPASSTHROUGH);
+ return EPASSTHROUGH;
}
- return (0);
+ return 0;
}
/*ARGSUSED*/
void
dzstop(struct tty *tp, int flag)
{
+
if (tp->t_state & TS_BUSY)
if (!(tp->t_state & TS_TTSTOP))
tp->t_state |= TS_FLUSH;
@@ -293,22 +297,22 @@
struct tty *
dztty(dev_t dev)
{
- struct dz_softc *sc = (void *)dz_cd.cd_devs[DZ_I2C(minor(dev))];
- struct tty *tp = sc->sc_dz.dz_tty;
+ struct dz_softc *sc = (void *)dz_cd.cd_devs[DZ_I2C(minor(dev))];
+ struct tty *tp = sc->sc_dz.dz_tty;
- return (tp);
+ return tp;
}
int
-dzpoll( dev_t dev, int events, struct lwp *l)
+dzpoll(dev_t dev, int events, struct lwp *l)
{
+ struct dz_softc *sc;
struct tty *tp;
- struct dz_softc *sc;
sc = (void *)dz_cd.cd_devs[DZ_I2C(minor(dev))];
tp = sc->sc_dz.dz_tty;
- return ((*tp->t_linesw->l_poll)(tp, events, l));
+ return (*tp->t_linesw->l_poll)(tp, events, l);
}
void
@@ -335,7 +339,7 @@
tp->t_state |= TS_BUSY;
- /* was idle, get it started */
+ /* was idle, get it started */
dzxint(sc,USI_TXRDY);
splx(s);
}
@@ -348,13 +352,13 @@
int act_baud, divisor, error;
if (baudrate <= 0)
- return (0);
+ return 0;
- divisor = (rclk/8)/(baudrate);
- divisor = (divisor/2) + (divisor&1);
+ divisor = (rclk / 8) / (baudrate);
+ divisor = (divisor / 2) + (divisor & 1);
if (divisor <= 0)
- return (-1);
+ return -1;
act_baud = rclk / (divisor * 16);
/* 10 times error in percent: */
@@ -362,9 +366,9 @@
/* 3.0% maximum error tolerance: */
if (error < -30 || error > 30)
- return (-1);
+ return -1;
Home |
Main Index |
Thread Index |
Old Index