diff options
author | Nathan Binkert <nate@cvs.openbsd.org> | 2002-07-10 03:09:35 +0000 |
---|---|---|
committer | Nathan Binkert <nate@cvs.openbsd.org> | 2002-07-10 03:09:35 +0000 |
commit | bbb411fb1ec4930274283ba73d948fb94912095c (patch) | |
tree | 43854233b03a085a56dc18191e265eb3cb4e341e /sys | |
parent | a708e51596bbd1fb458db46dc0c35a8384a1342e (diff) |
Try to be more portable
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/usb/ucom.c | 49 | ||||
-rw-r--r-- | sys/dev/usb/ucomvar.h | 20 |
2 files changed, 38 insertions, 31 deletions
diff --git a/sys/dev/usb/ucom.c b/sys/dev/usb/ucom.c index 0c2a8d88ff6..8641049c3e6 100644 --- a/sys/dev/usb/ucom.c +++ b/sys/dev/usb/ucom.c @@ -1,5 +1,5 @@ -/* $OpenBSD: ucom.c,v 1.11 2002/05/07 18:29:18 nate Exp $ */ -/* $NetBSD: ucom.c,v 1.39 2001/08/16 22:31:24 augustss Exp $ */ +/* $OpenBSD: ucom.c,v 1.12 2002/07/10 03:09:34 nate Exp $ */ +/* $NetBSD: ucom.c,v 1.42 2002/03/17 19:41:04 atatat Exp $ */ /* * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc. @@ -85,12 +85,16 @@ int ucomdebug = 0; #define UCOMUNIT_MASK 0x3ffff #define UCOMDIALOUT_MASK 0x80000 #define UCOMCALLUNIT_MASK 0x40000 + +#define LINESW(tp, func) ((tp)->t_linesw->func) #endif #if defined(__OpenBSD__) #define UCOMUNIT_MASK 0x3f #define UCOMDIALOUT_MASK 0x80 #define UCOMCALLUNIT_MASK 0x40 + +#define LINESW(tp, func) (linesw[(tp)->t_line].func) #endif #define UCOMUNIT(x) (minor(x) & UCOMUNIT_MASK) @@ -147,7 +151,7 @@ Static int ucomparam(struct tty *, struct termios *); Static void ucomstart(struct tty *); Static void ucom_shutdown(struct ucom_softc *); Static int ucom_do_ioctl(struct ucom_softc *, u_long, caddr_t, - int, struct proc *); + int, usb_proc_ptr); Static void ucom_dtr(struct ucom_softc *, int); Static void ucom_rts(struct ucom_softc *, int); Static void ucom_break(struct ucom_softc *, int); @@ -297,7 +301,7 @@ ucom_shutdown(struct ucom_softc *sc) } int -ucomopen(dev_t dev, int flag, int mode, struct proc *p) +ucomopen(dev_t dev, int flag, int mode, usb_proc_ptr p) { int unit = UCOMUNIT(dev); usbd_status err; @@ -463,7 +467,7 @@ ucomopen(dev_t dev, int flag, int mode, struct proc *p) if (error) goto bad; - error = (*linesw[tp->t_line].l_open)(dev, tp); + error = (*LINESW(tp, l_open))(dev, tp); if (error) goto bad; @@ -504,7 +508,7 @@ bad: } int -ucomclose(dev_t dev, int flag, int mode, struct proc *p) +ucomclose(dev_t dev, int flag, int mode, usb_proc_ptr p) { struct ucom_softc *sc = ucom_cd.cd_devs[UCOMUNIT(dev)]; struct tty *tp = sc->sc_tty; @@ -515,7 +519,7 @@ ucomclose(dev_t dev, int flag, int mode, struct proc *p) sc->sc_refcnt++; - (*linesw[tp->t_line].l_close)(tp, flag); + (*LINESW(tp, l_close))(tp, flag); ttyclose(tp); #if defined(__NetBSD__) @@ -551,7 +555,7 @@ ucomread(dev_t dev, struct uio *uio, int flag) return (EIO); sc->sc_refcnt++; - error = ((*linesw[tp->t_line].l_read)(tp, uio, flag)); + error = (*LINESW(tp, l_read))(tp, uio, flag); if (--sc->sc_refcnt < 0) usb_detach_wakeup(USBDEV(sc->sc_dev)); return (error); @@ -568,18 +572,15 @@ ucomwrite(dev_t dev, struct uio *uio, int flag) return (EIO); sc->sc_refcnt++; - error = ((*linesw[tp->t_line].l_write)(tp, uio, flag)); + error = (*LINESW(tp, l_write))(tp, uio, flag); if (--sc->sc_refcnt < 0) usb_detach_wakeup(USBDEV(sc->sc_dev)); return (error); } -#if 0 +#if defined(__NetBSD__) int -ucompoll(dev, events, p) - dev_t dev; - int events; - struct proc *p; +ucompoll(dev_t dev, int events, usb_proc_ptr p) { struct ucom_softc *sc = ucom_cd.cd_devs[UCOMUNIT(dev)]; struct tty *tp = sc->sc_tty; @@ -589,7 +590,7 @@ ucompoll(dev, events, p) return (EIO); sc->sc_refcnt++; - error = ((*linesw[tp->t_line].l_poll)(tp, events, p)); + error = (*LINESW(tp, l_poll))(tp, events, p); if (--sc->sc_refcnt < 0) usb_detach_wakeup(USBDEV(sc->sc_dev)); return (error); @@ -606,7 +607,7 @@ ucomtty(dev_t dev) } int -ucomioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) +ucomioctl(dev_t dev, u_long cmd, caddr_t data, int flag, usb_proc_ptr p) { struct ucom_softc *sc = ucom_cd.cd_devs[UCOMUNIT(dev)]; int error; @@ -620,7 +621,7 @@ ucomioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) Static int ucom_do_ioctl(struct ucom_softc *sc, u_long cmd, caddr_t data, - int flag, struct proc *p) + int flag, usb_proc_ptr p) { struct tty *tp = sc->sc_tty; int error; @@ -631,7 +632,7 @@ ucom_do_ioctl(struct ucom_softc *sc, u_long cmd, caddr_t data, DPRINTF(("ucomioctl: cmd=0x%08lx\n", cmd)); - error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, p); + error = (*LINESW(tp, l_ioctl))(tp, cmd, data, flag, p); if (error >= 0) return (error); @@ -805,7 +806,7 @@ ucom_status_change(struct ucom_softc *sc) sc->sc_methods->ucom_get_status(sc->sc_parent, sc->sc_portno, &sc->sc_lsr, &sc->sc_msr); if (ISSET((sc->sc_msr ^ old_msr), UMSR_DCD)) - (*linesw[tp->t_line].l_modem)(tp, + (*LINESW(tp, l_modem))(tp, ISSET(sc->sc_msr, UMSR_DCD)); } else { sc->sc_lsr = 0; @@ -866,7 +867,7 @@ ucomparam(struct tty *tp, struct termios *t) * explicit request. */ DPRINTF(("ucomparam: l_modem\n")); - (void) (*linesw[tp->t_line].l_modem)(tp, 1 /* XXX carrier */ ); + (void) (*LINESW(tp, l_modem))(tp, 1 /* XXX carrier */ ); #if 0 XXX what if the hardware is not open @@ -1033,7 +1034,7 @@ ucomwritecb(usbd_xfer_handle xfer, usbd_private_handle p, usbd_status status) CLR(tp->t_state, TS_FLUSH); else ndflush(&tp->t_outq, cc); - (*linesw[tp->t_line].l_start)(tp); + (*LINESW(tp, l_start))(tp); splx(s); return; @@ -1067,7 +1068,7 @@ ucomreadcb(usbd_xfer_handle xfer, usbd_private_handle p, usbd_status status) { struct ucom_softc *sc = (struct ucom_softc *)p; struct tty *tp = sc->sc_tty; - int (*rint)(int c, struct tty *tp) = linesw[tp->t_line].l_rint; + int (*rint)(int c, struct tty *tp) = LINESW(tp, l_rint); usbd_status err; u_int32_t cc; u_char *cp; @@ -1168,9 +1169,9 @@ ucomsubmatch(struct device *parent, void *match, void *aux) ucomsubmatch(struct device *parent, struct cfdata *cf, void *aux) #endif { - struct ucom_attach_args *uca = aux; + struct ucom_attach_args *uca = aux; #if defined(__OpenBSD__) - struct cfdata *cf = match; + struct cfdata *cf = match; #endif if (uca->portno != UCOM_UNK_PORTNO && diff --git a/sys/dev/usb/ucomvar.h b/sys/dev/usb/ucomvar.h index 3899af5c7bd..da0957ae539 100644 --- a/sys/dev/usb/ucomvar.h +++ b/sys/dev/usb/ucomvar.h @@ -1,5 +1,5 @@ -/* $OpenBSD: ucomvar.h,v 1.10 2002/05/07 18:29:18 nate Exp $ */ -/* $NetBSD: ucomvar.h,v 1.9 2001/01/23 21:56:17 augustss Exp $ */ +/* $OpenBSD: ucomvar.h,v 1.11 2002/07/10 03:09:34 nate Exp $ */ +/* $NetBSD: ucomvar.h,v 1.10 2001/12/31 12:15:21 augustss Exp $ */ /* * Copyright (c) 1999 The NetBSD Foundation, Inc. @@ -40,6 +40,11 @@ #if defined(__NetBSD__) +/* Macros to clear/set/test flags. */ +#define SET(t, f) (t) |= (f) +#define CLR(t, f) (t) &= ~(f) +#define ISSET(t, f) ((t) & (f)) + #include "locators.h" #endif @@ -56,7 +61,7 @@ struct ucom_methods { #define UCOM_SET_BREAK 3 int (*ucom_param)(void *sc, int portno, struct termios *); int (*ucom_ioctl)(void *sc, int portno, u_long cmd, - caddr_t data, int flag, struct proc *p); + caddr_t data, int flag, usb_proc_ptr p); int (*ucom_open)(void *sc, int portno); void (*ucom_close)(void *sc, int portno); void (*ucom_read)(void *sc, int portno, u_char **ptr, u_int32_t *count); @@ -105,10 +110,11 @@ struct ucom_attach_args { void *arg; }; -int ucomprint(void *aux, const char *pnp); -#if defined(__OpenBSD__) -int ucomsubmatch(struct device *parent, void *cf, void *aux); +#if defined(__NetBSD__) +int ucomsubmatch(struct device *, struct cfdata *, void *); #else -int ucomsubmatch(struct device *parent, struct cfdata *cf, void *aux); +int ucomsubmatch(struct device *, void *, void *); #endif + +int ucomprint(void *aux, const char *pnp); void ucom_status_change(struct ucom_softc *); |