version 1.88, 2011/11/19 22:51:24 |
version 1.88.2.2, 2012/02/24 09:11:42 |
Line 50 __KERNEL_RCSID(0, "$NetBSD$"); |
|
Line 50 __KERNEL_RCSID(0, "$NetBSD$"); |
|
#include <sys/poll.h> |
#include <sys/poll.h> |
#include <sys/queue.h> |
#include <sys/queue.h> |
#include <sys/kauth.h> |
#include <sys/kauth.h> |
#if defined(__NetBSD__) |
|
#include "rnd.h" |
|
#if NRND > 0 |
|
#include <sys/rnd.h> |
#include <sys/rnd.h> |
#endif |
|
#endif |
|
|
|
#include <dev/usb/usb.h> |
#include <dev/usb/usb.h> |
|
|
Line 129 struct ucom_softc { |
|
Line 124 struct ucom_softc { |
|
|
|
void *sc_si; |
void *sc_si; |
|
|
struct ucom_methods *sc_methods; |
const struct ucom_methods *sc_methods; |
void *sc_parent; |
void *sc_parent; |
int sc_portno; |
int sc_portno; |
|
|
Line 146 struct ucom_softc { |
|
Line 141 struct ucom_softc { |
|
int sc_refcnt; |
int sc_refcnt; |
u_char sc_dying; /* disconnecting */ |
u_char sc_dying; /* disconnecting */ |
|
|
#if defined(__NetBSD__) && NRND > 0 |
|
krndsource_t sc_rndsource; /* random source */ |
krndsource_t sc_rndsource; /* random source */ |
#endif |
|
}; |
}; |
|
|
dev_type_open(ucomopen); |
dev_type_open(ucomopen); |
Line 246 ucom_attach(device_t parent, device_t se |
|
Line 239 ucom_attach(device_t parent, device_t se |
|
DPRINTF(("ucom_attach: tty_attach %p\n", tp)); |
DPRINTF(("ucom_attach: tty_attach %p\n", tp)); |
tty_attach(tp); |
tty_attach(tp); |
|
|
#if defined(__NetBSD__) && NRND > 0 |
|
rnd_attach_source(&sc->sc_rndsource, device_xname(sc->sc_dev), |
rnd_attach_source(&sc->sc_rndsource, device_xname(sc->sc_dev), |
RND_TYPE_TTY, 0); |
RND_TYPE_TTY, 0); |
#endif |
|
|
|
if (!pmf_device_register(self, NULL, NULL)) |
if (!pmf_device_register(self, NULL, NULL)) |
aprint_error_dev(self, "couldn't establish power handler\n"); |
aprint_error_dev(self, "couldn't establish power handler\n"); |
Line 320 ucom_detach(device_t self, int flags) |
|
Line 311 ucom_detach(device_t self, int flags) |
|
} |
} |
|
|
/* Detach the random source */ |
/* Detach the random source */ |
#if defined(__NetBSD__) && NRND > 0 |
|
rnd_detach_source(&sc->sc_rndsource); |
rnd_detach_source(&sc->sc_rndsource); |
#endif |
|
|
|
return (0); |
return (0); |
} |
} |
Line 370 ucomopen(dev_t dev, int flag, int mode, |
|
Line 359 ucomopen(dev_t dev, int flag, int mode, |
|
int s, i; |
int s, i; |
int error; |
int error; |
|
|
|
/* XXX This is a hopefully temporary stopgap for kern/42848. */ |
|
if ((flag & (FREAD|FWRITE)) != (FREAD|FWRITE)) |
|
return (EINVAL); |
|
|
if (sc == NULL) |
if (sc == NULL) |
return (ENXIO); |
return (ENXIO); |
|
|
Line 656 ucomwrite(dev_t dev, struct uio *uio, in |
|
Line 649 ucomwrite(dev_t dev, struct uio *uio, in |
|
int |
int |
ucompoll(dev_t dev, int events, struct lwp *l) |
ucompoll(dev_t dev, int events, struct lwp *l) |
{ |
{ |
struct ucom_softc *sc = device_lookup_private(&ucom_cd, UCOMUNIT(dev)); |
struct ucom_softc *sc; |
struct tty *tp = sc->sc_tty; |
struct tty *tp; |
int revents; |
int revents; |
|
|
if (sc->sc_dying) |
sc = device_lookup_private(&ucom_cd, UCOMUNIT(dev)); |
|
if (sc == NULL || sc->sc_dying) |
return (POLLHUP); |
return (POLLHUP); |
|
|
|
tp = sc->sc_tty; |
|
|
sc->sc_refcnt++; |
sc->sc_refcnt++; |
revents = ((*tp->t_linesw->l_poll)(tp, events, l)); |
revents = ((*tp->t_linesw->l_poll)(tp, events, l)); |
if (--sc->sc_refcnt < 0) |
if (--sc->sc_refcnt < 0) |
Line 1037 ucomstop(struct tty *tp, int flag) |
|
Line 1033 ucomstop(struct tty *tp, int flag) |
|
{ |
{ |
#if 0 |
#if 0 |
/*struct ucom_softc *sc = |
/*struct ucom_softc *sc = |
device_lookup_private(&ucom_cd, UCOMUNIT(dev));*/ |
device_lookup_private(&ucom_cd, UCOMUNIT(tp->t_dev));*/ |
int s; |
int s; |
|
|
s = spltty(); |
s = spltty(); |
Line 1067 ucom_write_status(struct ucom_softc *sc, |
|
Line 1063 ucom_write_status(struct ucom_softc *sc, |
|
break; |
break; |
case USBD_NORMAL_COMPLETION: |
case USBD_NORMAL_COMPLETION: |
usbd_get_xfer_status(ub->ub_xfer, NULL, NULL, &cc, NULL); |
usbd_get_xfer_status(ub->ub_xfer, NULL, NULL, &cc, NULL); |
#if defined(__NetBSD__) && NRND > 0 |
|
rnd_add_uint32(&sc->sc_rndsource, cc); |
rnd_add_uint32(&sc->sc_rndsource, cc); |
#endif |
|
/*FALLTHROUGH*/ |
/*FALLTHROUGH*/ |
default: |
default: |
SIMPLEQ_REMOVE_HEAD(&sc->sc_obuff_full, ub_link); |
SIMPLEQ_REMOVE_HEAD(&sc->sc_obuff_full, ub_link); |
Line 1243 ucomreadcb(usbd_xfer_handle xfer, usbd_p |
|
Line 1237 ucomreadcb(usbd_xfer_handle xfer, usbd_p |
|
|
|
usbd_get_xfer_status(xfer, NULL, (void *)&cp, &cc, NULL); |
usbd_get_xfer_status(xfer, NULL, (void *)&cp, &cc, NULL); |
|
|
if (cc == 0) { |
#ifdef UCOM_DEBUG |
aprint_normal_dev(sc->sc_dev, |
/* This is triggered by uslsa(4) occasionally. */ |
"ucomreadcb: zero length xfer!\n"); |
if ((ucomdebug > 0) && (cc == 0)) { |
|
device_printf(sc->sc_dev, "ucomreadcb: zero length xfer!\n"); |
} |
} |
|
#endif |
|
|
KDASSERT(cp == ub->ub_data); |
KDASSERT(cp == ub->ub_data); |
|
|
#if defined(__NetBSD__) && NRND > 0 |
|
rnd_add_uint32(&sc->sc_rndsource, cc); |
rnd_add_uint32(&sc->sc_rndsource, cc); |
#endif |
|
|
|
if (sc->sc_opening) { |
if (sc->sc_opening) { |
ucomsubmitread(sc, ub); |
ucomsubmitread(sc, ub); |