summaryrefslogtreecommitdiff
path: root/sys/dev/usb
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dev/usb')
-rw-r--r--sys/dev/usb/uhid.c41
-rw-r--r--sys/dev/usb/uhidev.h3
-rw-r--r--sys/dev/usb/ukbd.c24
-rw-r--r--sys/dev/usb/ums.c16
-rw-r--r--sys/dev/usb/utpms.c13
5 files changed, 36 insertions, 61 deletions
diff --git a/sys/dev/usb/uhid.c b/sys/dev/usb/uhid.c
index 31d8e9f18dd..d7beed1f209 100644
--- a/sys/dev/usb/uhid.c
+++ b/sys/dev/usb/uhid.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uhid.c,v 1.53 2011/07/03 15:47:17 matthew Exp $ */
+/* $OpenBSD: uhid.c,v 1.54 2013/11/15 08:17:44 pirofti Exp $ */
/* $NetBSD: uhid.c,v 1.57 2003/03/11 16:44:00 augustss Exp $ */
/*
@@ -83,7 +83,6 @@ struct uhid_softc {
#define UHID_IMMED 0x02 /* return read data immediately */
int sc_refcnt;
- u_char sc_dying;
};
#define UHIDUNIT(dev) (minor(dev))
@@ -100,7 +99,6 @@ int uhid_do_ioctl(struct uhid_softc*, u_long, caddr_t, int,
int uhid_match(struct device *, void *, void *);
void uhid_attach(struct device *, struct device *, void *);
int uhid_detach(struct device *, int);
-int uhid_activate(struct device *, int);
struct cfdriver uhid_cd = {
NULL, "uhid", DV_DULL
@@ -111,14 +109,12 @@ const struct cfattach uhid_ca = {
uhid_match,
uhid_attach,
uhid_detach,
- uhid_activate,
};
int
uhid_match(struct device *parent, void *match, void *aux)
{
- struct usb_attach_arg *uaa = aux;
- struct uhidev_attach_arg *uha = (struct uhidev_attach_arg *)uaa;
+ struct uhidev_attach_arg *uha = (struct uhidev_attach_arg *)aux;
DPRINTF(("uhid_match: report=%d\n", uha->reportid));
@@ -131,13 +127,13 @@ void
uhid_attach(struct device *parent, struct device *self, void *aux)
{
struct uhid_softc *sc = (struct uhid_softc *)self;
- struct usb_attach_arg *uaa = aux;
- struct uhidev_attach_arg *uha = (struct uhidev_attach_arg *)uaa;
+ struct uhidev_attach_arg *uha = (struct uhidev_attach_arg *)aux;
int size, repid;
void *desc;
sc->sc_hdev.sc_intr = uhid_intr;
sc->sc_hdev.sc_parent = uha->parent;
+ sc->sc_hdev.sc_udev = uha->uaa->device;
sc->sc_hdev.sc_report_id = uha->reportid;
uhidev_get_report_desc(uha->parent, &desc, &size);
@@ -151,19 +147,6 @@ uhid_attach(struct device *parent, struct device *self, void *aux)
}
int
-uhid_activate(struct device *self, int act)
-{
- struct uhid_softc *sc = (struct uhid_softc *)self;
-
- switch (act) {
- case DVACT_DEACTIVATE:
- sc->sc_dying = 1;
- break;
- }
- return (0);
-}
-
-int
uhid_detach(struct device *self, int flags)
{
struct uhid_softc *sc = (struct uhid_softc *)self;
@@ -239,7 +222,7 @@ uhidopen(dev_t dev, int flag, int mode, struct proc *p)
DPRINTF(("uhidopen: sc=%p\n", sc));
- if (sc->sc_dying)
+ if (usbd_is_dying(sc->sc_hdev.sc_udev))
return (ENXIO);
error = uhidev_open(&sc->sc_hdev);
@@ -303,7 +286,7 @@ uhid_do_read(struct uhid_softc *sc, struct uio *uio, int flag)
DPRINTFN(5, ("uhidread: sleep on %p\n", &sc->sc_q));
error = tsleep(&sc->sc_q, PZERO | PCATCH, "uhidrea", 0);
DPRINTFN(5, ("uhidread: woke, error=%d\n", error));
- if (sc->sc_dying)
+ if (usbd_is_dying(sc->sc_hdev.sc_udev))
error = EIO;
if (error) {
sc->sc_state &= ~UHID_ASLP;
@@ -354,7 +337,7 @@ uhid_do_write(struct uhid_softc *sc, struct uio *uio, int flag)
DPRINTFN(1, ("uhidwrite\n"));
- if (sc->sc_dying)
+ if (usbd_is_dying(sc->sc_hdev.sc_udev))
return (EIO);
size = sc->sc_hdev.sc_osize;
@@ -398,7 +381,7 @@ uhid_do_ioctl(struct uhid_softc *sc, u_long cmd, caddr_t addr,
DPRINTFN(2, ("uhidioctl: cmd=%lx\n", cmd));
- if (sc->sc_dying)
+ if (usbd_is_dying(sc->sc_hdev.sc_udev))
return (EIO);
switch (cmd) {
@@ -438,14 +421,14 @@ uhid_do_ioctl(struct uhid_softc *sc, u_long cmd, caddr_t addr,
break;
case USB_GET_DEVICEINFO:
- usbd_fill_deviceinfo(sc->sc_hdev.sc_parent->sc_udev,
+ usbd_fill_deviceinfo(sc->sc_hdev.sc_udev,
(struct usb_device_info *)addr, 1);
break;
case USB_GET_STRING_DESC:
{
struct usb_string_desc *si = (struct usb_string_desc *)addr;
- err = usbd_get_string_desc(sc->sc_hdev.sc_parent->sc_udev,
+ err = usbd_get_string_desc(sc->sc_hdev.sc_udev,
si->usd_string_index,
si->usd_language_id, &si->usd_desc, &size);
if (err)
@@ -490,7 +473,7 @@ uhidpoll(dev_t dev, int events, struct proc *p)
sc = uhid_cd.cd_devs[UHIDUNIT(dev)];
- if (sc->sc_dying)
+ if (usbd_is_dying(sc->sc_hdev.sc_udev))
return (POLLERR);
s = splusb();
@@ -546,7 +529,7 @@ uhidkqfilter(dev_t dev, struct knote *kn)
sc = uhid_cd.cd_devs[UHIDUNIT(dev)];
- if (sc->sc_dying)
+ if (usbd_is_dying(sc->sc_hdev.sc_udev))
return (EIO);
switch (kn->kn_filter) {
diff --git a/sys/dev/usb/uhidev.h b/sys/dev/usb/uhidev.h
index cbffaa744e8..dfe5c6488bf 100644
--- a/sys/dev/usb/uhidev.h
+++ b/sys/dev/usb/uhidev.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: uhidev.h,v 1.14 2013/11/01 12:05:26 mpi Exp $ */
+/* $OpenBSD: uhidev.h,v 1.15 2013/11/15 08:17:44 pirofti Exp $ */
/* $NetBSD: uhidev.h,v 1.3 2002/10/08 09:56:17 dan Exp $ */
/*
@@ -64,6 +64,7 @@ struct uhidev_softc {
struct uhidev {
struct device sc_dev; /* base device */
+ struct usbd_device *sc_udev; /* USB device */
struct uhidev_softc *sc_parent;
uByte sc_report_id;
u_int8_t sc_state;
diff --git a/sys/dev/usb/ukbd.c b/sys/dev/usb/ukbd.c
index 59e271f7ab0..07b5e6f697c 100644
--- a/sys/dev/usb/ukbd.c
+++ b/sys/dev/usb/ukbd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ukbd.c,v 1.61 2013/11/13 13:48:08 pirofti Exp $ */
+/* $OpenBSD: ukbd.c,v 1.62 2013/11/15 08:17:44 pirofti Exp $ */
/* $NetBSD: ukbd.c,v 1.85 2003/03/11 16:44:00 augustss Exp $ */
/*
@@ -132,8 +132,6 @@ struct ukbd_softc {
int sc_spl;
- u_char sc_dying;
-
struct hid_location sc_apple_fn;
void (*sc_munge)(void *, uint8_t *, u_int);
@@ -193,8 +191,7 @@ uint8_t ukbd_translate(const struct ukbd_translation *, size_t, uint8_t);
int
ukbd_match(struct device *parent, void *match, void *aux)
{
- struct usb_attach_arg *uaa = aux;
- struct uhidev_attach_arg *uha = (struct uhidev_attach_arg *)uaa;
+ struct uhidev_attach_arg *uha = (struct uhidev_attach_arg *)aux;
int size;
void *desc;
@@ -211,8 +208,7 @@ ukbd_attach(struct device *parent, struct device *self, void *aux)
{
struct ukbd_softc *sc = (struct ukbd_softc *)self;
struct hidkbd *kbd = &sc->sc_kbd;
- struct usb_attach_arg *uaa = aux;
- struct uhidev_attach_arg *uha = (struct uhidev_attach_arg *)uaa;
+ struct uhidev_attach_arg *uha = (struct uhidev_attach_arg *)aux;
struct usb_hid_descriptor *hid;
u_int32_t qflags;
int dlen, repid;
@@ -221,6 +217,7 @@ ukbd_attach(struct device *parent, struct device *self, void *aux)
sc->sc_hdev.sc_intr = ukbd_intr;
sc->sc_hdev.sc_parent = uha->parent;
+ sc->sc_hdev.sc_udev = uha->uaa->device;
sc->sc_hdev.sc_report_id = uha->reportid;
uhidev_get_report_desc(uha->parent, &desc, &dlen);
@@ -229,7 +226,7 @@ ukbd_attach(struct device *parent, struct device *self, void *aux)
sc->sc_hdev.sc_osize = hid_report_size(desc, dlen, hid_output, repid);
sc->sc_hdev.sc_fsize = hid_report_size(desc, dlen, hid_feature, repid);
- qflags = usbd_get_quirks(uha->parent->sc_udev)->uq_flags;
+ qflags = usbd_get_quirks(sc->sc_hdev.sc_udev)->uq_flags;
if (hidkbd_attach(self, kbd, 1, qflags, repid, desc, dlen) != 0)
return;
@@ -292,7 +289,7 @@ ukbd_attach(struct device *parent, struct device *self, void *aux)
/* Flash the leds; no real purpose, just shows we're alive. */
ukbd_set_leds(sc, WSKBD_LED_SCROLL | WSKBD_LED_NUM |
WSKBD_LED_CAPS | WSKBD_LED_COMPOSE);
- usbd_delay_ms(uha->parent->sc_udev, 400);
+ usbd_delay_ms(sc->sc_hdev.sc_udev, 400);
ukbd_set_leds(sc, 0);
hidkbd_attach_wskbd(kbd, layout, &ukbd_accessops);
@@ -309,7 +306,6 @@ ukbd_activate(struct device *self, int act)
case DVACT_DEACTIVATE:
if (kbd->sc_wskbddev != NULL)
rv = config_deactivate(kbd->sc_wskbddev);
- sc->sc_dying = 1;
break;
}
return (rv);
@@ -351,7 +347,7 @@ ukbd_enable(void *v, int on)
struct hidkbd *kbd = &sc->sc_kbd;
int rv;
- if (on && sc->sc_dying)
+ if (on && usbd_is_dying(sc->sc_hdev.sc_udev))
return EIO;
if ((rv = hidkbd_enable(kbd, on)) != 0)
@@ -372,7 +368,7 @@ ukbd_set_leds(void *v, int leds)
struct hidkbd *kbd = &sc->sc_kbd;
u_int8_t res;
- if (sc->sc_dying)
+ if (usbd_is_dying(sc->sc_hdev.sc_udev))
return;
if (sc->sc_ledsize && hidkbd_set_leds(kbd, leds, &res) != 0)
@@ -413,7 +409,7 @@ ukbd_cngetc(void *v, u_int *type, int *data)
DPRINTFN(0,("ukbd_cngetc: enter\n"));
kbd->sc_polling = 1;
while (kbd->sc_npollchar <= 0)
- usbd_dopoll(sc->sc_hdev.sc_parent->sc_udev);
+ usbd_dopoll(sc->sc_hdev.sc_udev);
kbd->sc_polling = 0;
hidkbd_cngetc(kbd, type, data);
DPRINTFN(0,("ukbd_cngetc: return 0x%02x\n", *data));
@@ -430,7 +426,7 @@ ukbd_cnpollc(void *v, int on)
sc->sc_spl = splusb();
else
splx(sc->sc_spl);
- usbd_set_polling(sc->sc_hdev.sc_parent->sc_udev, on);
+ usbd_set_polling(sc->sc_hdev.sc_udev, on);
}
void
diff --git a/sys/dev/usb/ums.c b/sys/dev/usb/ums.c
index edec275ce2b..8e6c2add007 100644
--- a/sys/dev/usb/ums.c
+++ b/sys/dev/usb/ums.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ums.c,v 1.37 2013/08/15 15:01:48 edd Exp $ */
+/* $OpenBSD: ums.c,v 1.38 2013/11/15 08:17:44 pirofti Exp $ */
/* $NetBSD: ums.c,v 1.60 2003/03/11 16:44:00 augustss Exp $ */
/*
@@ -59,7 +59,6 @@
struct ums_softc {
struct uhidev sc_hdev;
struct hidms sc_ms;
- char sc_dying;
};
void ums_intr(struct uhidev *addr, void *ibuf, u_int len);
@@ -94,8 +93,7 @@ const struct cfattach ums_ca = {
int
ums_match(struct device *parent, void *match, void *aux)
{
- struct usb_attach_arg *uaa = aux;
- struct uhidev_attach_arg *uha = (struct uhidev_attach_arg *)uaa;
+ struct uhidev_attach_arg *uha = (struct uhidev_attach_arg *)aux;
int size;
void *desc;
@@ -121,17 +119,18 @@ ums_attach(struct device *parent, struct device *self, void *aux)
{
struct ums_softc *sc = (struct ums_softc *)self;
struct hidms *ms = &sc->sc_ms;
- struct usb_attach_arg *uaa = aux;
- struct uhidev_attach_arg *uha = (struct uhidev_attach_arg *)uaa;
+ struct uhidev_attach_arg *uha = (struct uhidev_attach_arg *)aux;
+ struct usb_attach_arg *uaa = uha->uaa;
int size, repid;
void *desc;
u_int32_t quirks;
sc->sc_hdev.sc_intr = ums_intr;
sc->sc_hdev.sc_parent = uha->parent;
+ sc->sc_hdev.sc_udev = uaa->device;
sc->sc_hdev.sc_report_id = uha->reportid;
- quirks = usbd_get_quirks(uha->parent->sc_udev)->uq_flags;
+ quirks = usbd_get_quirks(sc->sc_hdev.sc_udev)->uq_flags;
uhidev_get_report_desc(uha->parent, &desc, &size);
repid = uha->reportid;
sc->sc_hdev.sc_isize = hid_report_size(desc, size, hid_input, repid);
@@ -175,7 +174,6 @@ ums_activate(struct device *self, int act)
case DVACT_DEACTIVATE:
if (ms->sc_wsmousedev != NULL)
rv = config_deactivate(ms->sc_wsmousedev);
- sc->sc_dying = 1;
break;
}
return (rv);
@@ -207,7 +205,7 @@ ums_enable(void *v)
struct hidms *ms = &sc->sc_ms;
int rv;
- if (sc->sc_dying)
+ if (usbd_is_dying(sc->sc_hdev.sc_udev))
return EIO;
if ((rv = hidms_enable(ms)) != 0)
diff --git a/sys/dev/usb/utpms.c b/sys/dev/usb/utpms.c
index 16a1321428c..09b34b91b59 100644
--- a/sys/dev/usb/utpms.c
+++ b/sys/dev/usb/utpms.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: utpms.c,v 1.2 2013/07/06 14:42:38 mpi Exp $ */
+/* $OpenBSD: utpms.c,v 1.3 2013/11/15 08:17:44 pirofti Exp $ */
/*
* Copyright (c) 2005, Johan Wallén
@@ -229,7 +229,6 @@ struct utpms_softc {
uint32_t sc_buttons; /* Button state. */
uint32_t sc_status; /* Status flags. */
#define UTPMS_ENABLED 1 /* Is the device enabled? */
-#define UTPMS_DYING 2 /* Is the device dying? */
#define UTPMS_VALID 4 /* Is the previous sample valid? */
};
@@ -265,8 +264,7 @@ const struct cfattach utpms_ca = {
int
utpms_match(struct device *parent, void *match, void *aux)
{
- struct usb_attach_arg *uaa = aux;
- struct uhidev_attach_arg *uha = (struct uhidev_attach_arg *)uaa;
+ struct uhidev_attach_arg *uha = (struct uhidev_attach_arg *)aux;
usb_device_descriptor_t *udd;
int i;
uint16_t vendor, product;
@@ -292,8 +290,7 @@ void
utpms_attach(struct device *parent, struct device *self, void *aux)
{
struct utpms_softc *sc = (struct utpms_softc *)self;
- struct usb_attach_arg *uaa = aux;
- struct uhidev_attach_arg *uha = (struct uhidev_attach_arg *)uaa;
+ struct uhidev_attach_arg *uha = (struct uhidev_attach_arg *)aux;
struct wsmousedev_attach_args a;
struct utpms_dev *pd;
usb_device_descriptor_t *udd;
@@ -301,6 +298,7 @@ utpms_attach(struct device *parent, struct device *self, void *aux)
uint16_t vendor, product;
sc->sc_datalen = UTPMS_DATA_LEN;
+ sc->sc_hdev.sc_udev = uha->uaa->device;
/* Fill in device-specific parameters. */
if ((udd = usbd_get_device_descriptor(uha->parent->sc_udev)) != NULL) {
@@ -375,7 +373,6 @@ utpms_activate(struct device *self, int act)
ret = 0;
if (sc->sc_wsmousedev != NULL)
ret = config_deactivate(sc->sc_wsmousedev);
- sc->sc_status |= UTPMS_DYING;
return (ret);
}
return (EOPNOTSUPP);
@@ -387,7 +384,7 @@ utpms_enable(void *v)
struct utpms_softc *sc = v;
/* Check that we are not detaching or already enabled. */
- if (sc->sc_status & UTPMS_DYING)
+ if (sc->sc_status & usbd_is_dying(sc->sc_hdev.sc_udev))
return (EIO);
if (sc->sc_status & UTPMS_ENABLED)
return (EBUSY);