summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sys/dev/usb/ugen.c2
-rw-r--r--sys/dev/usb/usb.c4
-rw-r--r--sys/dev/usb/usb_quirks.c38
-rw-r--r--sys/dev/usb/usb_quirks.h14
-rw-r--r--sys/dev/usb/usb_subr.c288
-rw-r--r--sys/dev/usb/usbdi.c2
-rw-r--r--sys/dev/usb/usbdi.h4
-rw-r--r--sys/dev/usb/usbdivar.h3
8 files changed, 161 insertions, 194 deletions
diff --git a/sys/dev/usb/ugen.c b/sys/dev/usb/ugen.c
index 7e935d7..b76465d 100644
--- a/sys/dev/usb/ugen.c
+++ b/sys/dev/usb/ugen.c
@@ -1314,7 +1314,7 @@ ugen_do_ioctl(struct ugen_softc *sc, int endpt, u_long cmd,
}
case USB_GET_DEVICEINFO:
usbd_fill_deviceinfo(sc->sc_udev,
- (struct usb_device_info *)addr);
+ (struct usb_device_info *)addr, 1);
break;
default:
return (EINVAL);
diff --git a/sys/dev/usb/usb.c b/sys/dev/usb/usb.c
index 7979161..2b4ad42 100644
--- a/sys/dev/usb/usb.c
+++ b/sys/dev/usb/usb.c
@@ -530,7 +530,7 @@ usbioctl(devt, cmd, data, flag, p)
dev = sc->sc_bus->devices[addr];
if (dev == 0)
return (ENXIO);
- usbd_fill_deviceinfo(dev, di);
+ usbd_fill_deviceinfo(dev, di, 1);
break;
}
@@ -677,7 +677,7 @@ usbd_add_event(type, dev)
}
ueq->ue.ue_type = type;
ueq->ue.ue_cookie = dev->cookie;
- usbd_fill_deviceinfo(dev, &ueq->ue.ue_device);
+ usbd_fill_deviceinfo(dev, &ueq->ue.ue_device, 0);
microtime(&thetime);
TIMEVAL_TO_TIMESPEC(&thetime, &ueq->ue.ue_time);
TAILQ_INSERT_TAIL(&usb_events, ueq, next);
diff --git a/sys/dev/usb/usb_quirks.c b/sys/dev/usb/usb_quirks.c
index e965a36..b89e264 100644
--- a/sys/dev/usb/usb_quirks.c
+++ b/sys/dev/usb/usb_quirks.c
@@ -1,4 +1,4 @@
-/* $NetBSD: usb_quirks.c,v 1.30 2000/10/24 03:59:16 explorer Exp $ */
+/* $NetBSD: usb_quirks.c,v 1.38 2001/04/15 10:26:36 augustss Exp $ */
/* $FreeBSD$ */
/*
@@ -50,21 +50,23 @@
extern int usbdebug;
#endif
-Static struct usbd_quirk_entry {
+#define ANY 0xffff
+
+Static const struct usbd_quirk_entry {
u_int16_t idVendor;
u_int16_t idProduct;
u_int16_t bcdDevice;
struct usbd_quirks quirks;
} usb_quirks[] = {
{ USB_VENDOR_KYE, USB_PRODUCT_KYE_NICHE, 0x100, { UQ_NO_SET_PROTO}},
- { USB_VENDOR_INSIDEOUT,USB_PRODUCT_INSIDEOUT_EDGEPORT4,
+ { USB_VENDOR_INSIDEOUT, USB_PRODUCT_INSIDEOUT_EDGEPORT4,
0x094, { UQ_SWAP_UNICODE}},
{ USB_VENDOR_BTC, USB_PRODUCT_BTC_BTC7932, 0x100, { UQ_NO_STRINGS }},
{ USB_VENDOR_ADS, USB_PRODUCT_ADS_UBS10BT, 0x002, { UQ_NO_STRINGS }},
{ USB_VENDOR_PERACOM, USB_PRODUCT_PERACOM_SERIAL1, 0x101, { UQ_NO_STRINGS }},
{ USB_VENDOR_WACOM, USB_PRODUCT_WACOM_CT0405U, 0x101, { UQ_NO_STRINGS }},
{ USB_VENDOR_DALLAS, USB_PRODUCT_DALLAS_J6502, 0x0a2, { UQ_BAD_ADC }},
- { USB_VENDOR_DALLAS, USB_PRODUCT_DALLAS_J6502, 0x0a2, { UQ_NO_XU }},
+ { USB_VENDOR_DALLAS, USB_PRODUCT_DALLAS_J6502, 0x0a2, { UQ_AU_NO_XU }},
{ USB_VENDOR_ALTEC, USB_PRODUCT_ALTEC_ADA70, 0x103, { UQ_BAD_ADC }},
{ USB_VENDOR_ALTEC, USB_PRODUCT_ALTEC_ASC495, 0x000, { UQ_BAD_AUDIO }},
{ USB_VENDOR_QTRONIX, USB_PRODUCT_QTRONIX_980N, 0x110, { UQ_SPUR_BUT_UP }},
@@ -73,22 +75,36 @@ Static struct usbd_quirk_entry {
{ USB_VENDOR_MCT, USB_PRODUCT_MCT_USB232, 0x102, { UQ_BUS_POWERED }},
{ USB_VENDOR_METRICOM, USB_PRODUCT_METRICOM_RICOCHET_GS,
0x100, { UQ_ASSUME_CM_OVER_DATA | UQ_NO_STRINGS }},
+ { USB_VENDOR_TI, USB_PRODUCT_TI_UTUSB41, 0x110, { UQ_POWER_CLAIM }},
{ USB_VENDOR_ACERP, USB_PRODUCT_ACERP_ACERSCAN_320U,
- 0x000, { UQ_NO_STRINGS }},
+ 0x000, { UQ_NO_STRINGS }},
+ { USB_VENDOR_TELEX, USB_PRODUCT_TELEX_MIC1, 0x009, { UQ_AU_NO_FRAC }},
+ { USB_VENDOR_SILICONPORTALS, USB_PRODUCT_SILICONPORTALS_YAPPHONE,
+ 0x100, { UQ_AU_INP_ASYNC }},
+ /* XXX These should have a revision number, but I don't know what they are. */
+ { USB_VENDOR_HP, USB_PRODUCT_HP_895C, ANY, { UQ_BROKEN_BIDIR }},
+ { USB_VENDOR_HP, USB_PRODUCT_HP_880C, ANY, { UQ_BROKEN_BIDIR }},
+ { USB_VENDOR_HP, USB_PRODUCT_HP_815C, ANY, { UQ_BROKEN_BIDIR }},
+ { USB_VENDOR_HP, USB_PRODUCT_HP_810C, ANY, { UQ_BROKEN_BIDIR }},
+ { USB_VENDOR_HP, USB_PRODUCT_HP_830C, ANY, { UQ_BROKEN_BIDIR }},
+
{ 0, 0, 0, { 0 } }
};
-struct usbd_quirks usbd_no_quirk = { 0 };
+const struct usbd_quirks usbd_no_quirk = { 0 };
-struct usbd_quirks *
+const struct usbd_quirks *
usbd_find_quirk(usb_device_descriptor_t *d)
{
- struct usbd_quirk_entry *t;
+ const struct usbd_quirk_entry *t;
+ u_int16_t vendor = UGETW(d->idVendor);
+ u_int16_t product = UGETW(d->idProduct);
+ u_int16_t revision = UGETW(d->bcdDevice);
for (t = usb_quirks; t->idVendor != 0; t++) {
- if (t->idVendor == UGETW(d->idVendor) &&
- t->idProduct == UGETW(d->idProduct) &&
- t->bcdDevice == UGETW(d->bcdDevice))
+ if (t->idVendor == vendor &&
+ t->idProduct == product &&
+ (t->bcdDevice == ANY || t->bcdDevice == revision))
break;
}
#ifdef USB_DEBUG
diff --git a/sys/dev/usb/usb_quirks.h b/sys/dev/usb/usb_quirks.h
index 5cbba83..2a36a06 100644
--- a/sys/dev/usb/usb_quirks.h
+++ b/sys/dev/usb/usb_quirks.h
@@ -1,4 +1,4 @@
-/* $NetBSD: usb_quirks.h,v 1.11 2000/04/27 15:26:50 augustss Exp $ */
+/* $NetBSD: usb_quirks.h,v 1.20 2001/04/15 09:38:01 augustss Exp $ */
/* $FreeBSD$ */
/*
@@ -48,10 +48,14 @@ struct usbd_quirks {
#define UQ_BUS_POWERED 0x0020 /* device is bus powered, despite claim */
#define UQ_BAD_AUDIO 0x0040 /* device claims audio class, but isn't */
#define UQ_SPUR_BUT_UP 0x0080 /* spurious mouse button up events */
-#define UQ_NO_XU 0x0100 /* audio device has broken extension unit */
-#define UQ_ASSUME_CM_OVER_DATA 0x0200 /* modem device breaks on cm over data */
+#define UQ_AU_NO_XU 0x0100 /* audio device has broken extension unit */
+#define UQ_POWER_CLAIM 0x0200 /* hub lies about power status */
+#define UQ_AU_NO_FRAC 0x0400 /* don't adjust for fractional samples */
+#define UQ_AU_INP_ASYNC 0x0800 /* input is async despite claim of adaptive */
+#define UQ_ASSUME_CM_OVER_DATA 0x1000 /* modem device breaks on cm over data */
+#define UQ_BROKEN_BIDIR 0x2000 /* printer has broken bidir mode */
};
-extern struct usbd_quirks usbd_no_quirk;
+extern const struct usbd_quirks usbd_no_quirk;
-struct usbd_quirks *usbd_find_quirk(usb_device_descriptor_t *);
+const struct usbd_quirks *usbd_find_quirk(usb_device_descriptor_t *);
diff --git a/sys/dev/usb/usb_subr.c b/sys/dev/usb/usb_subr.c
index 8b467f3..f14c02a 100644
--- a/sys/dev/usb/usb_subr.c
+++ b/sys/dev/usb/usb_subr.c
@@ -75,19 +75,21 @@ extern int usbdebug;
#define DPRINTFN(n,x)
#endif
-Static usbd_status usbd_set_config(usbd_device_handle, int);
+Static usbd_status usbd_set_config(usbd_device_handle, int);
+Static void usbd_devinfo_vp(usbd_device_handle, char *, char *, int);
Static char *usbd_get_string(usbd_device_handle, int, char *);
Static int usbd_getnewaddr(usbd_bus_handle bus);
#if defined(__NetBSD__)
Static int usbd_print(void *aux, const char *pnp);
Static int usbd_submatch(device_ptr_t, struct cfdata *cf, void *);
#elif defined(__OpenBSD__)
+Static int usbd_print(void *aux, const char *pnp);
Static int usbd_submatch(device_ptr_t, void *, void *);
#endif
Static void usbd_free_iface_data(usbd_device_handle dev, int ifcno);
Static void usbd_kill_pipe(usbd_pipe_handle);
-Static usbd_status usbd_probe_and_attach
- (device_ptr_t parent, usbd_device_handle dev, int port, int addr);
+Static usbd_status usbd_probe_and_attach(device_ptr_t parent,
+ usbd_device_handle dev, int port, int addr);
Static u_int32_t usb_cookie_no = 0;
@@ -109,7 +111,7 @@ struct usb_knowndev {
#include <dev/usb/usbdevs_data.h>
#endif /* USBVERBOSE */
-Static const char *usbd_error_strs[] = {
+Static const char * const usbd_error_strs[] = {
"NORMAL_COMPLETION",
"IN_PROGRESS",
"PENDING_REQUESTS",
@@ -133,8 +135,7 @@ Static const char *usbd_error_strs[] = {
};
const char *
-usbd_errstr(err)
- usbd_status err;
+usbd_errstr(usbd_status err)
{
static char buffer[5];
@@ -147,11 +148,8 @@ usbd_errstr(err)
}
usbd_status
-usbd_get_string_desc(dev, sindex, langid, sdesc)
- usbd_device_handle dev;
- int sindex;
- int langid;
- usb_string_descriptor_t *sdesc;
+usbd_get_string_desc(usbd_device_handle dev, int sindex, int langid,
+ usb_string_descriptor_t *sdesc)
{
usb_device_request_t req;
usbd_status err;
@@ -169,10 +167,7 @@ usbd_get_string_desc(dev, sindex, langid, sdesc)
}
char *
-usbd_get_string(dev, si, buf)
- usbd_device_handle dev;
- int si;
- char *buf;
+usbd_get_string(usbd_device_handle dev, int si, char *buf)
{
int swap = dev->quirks->uq_flags & UQ_SWAP_UNICODE;
usb_string_descriptor_t us;
@@ -214,15 +209,29 @@ usbd_get_string(dev, si, buf)
return (buf);
}
-void
-usbd_devinfo_vp(dev, v, p)
- usbd_device_handle dev;
- char *v, *p;
+Static void
+usbd_trim_spaces(char *p)
+{
+ char *q, *e;
+
+ if (p == NULL)
+ return;
+ q = e = p;
+ while (*q == ' ') /* skip leading spaces */
+ q++;
+ while ((*p = *q++)) /* copy string */
+ if (*p++ != ' ') /* remember last non-space */
+ e = p;
+ *e = 0; /* kill trailing spaces */
+}
+
+Static void
+usbd_devinfo_vp(usbd_device_handle dev, char *v, char *p, int usedev)
{
usb_device_descriptor_t *udd = &dev->ddesc;
char *vendor = 0, *product = 0;
#ifdef USBVERBOSE
- struct usb_knowndev *kdp;
+ const struct usb_knowndev *kdp;
#endif
if (dev == NULL) {
@@ -230,8 +239,15 @@ usbd_devinfo_vp(dev, v, p)
return;
}
- vendor = usbd_get_string(dev, udd->iManufacturer, v);
- product = usbd_get_string(dev, udd->iProduct, p);
+ if (usedev) {
+ vendor = usbd_get_string(dev, udd->iManufacturer, v);
+ usbd_trim_spaces(vendor);
+ product = usbd_get_string(dev, udd->iProduct, p);
+ usbd_trim_spaces(product);
+ } else {
+ vendor = NULL;
+ product = NULL;
+ }
#ifdef USBVERBOSE
if (vendor == NULL || product == NULL) {
for(kdp = usb_knowndevs;
@@ -243,44 +259,39 @@ usbd_devinfo_vp(dev, v, p)
break;
}
if (kdp->vendorname != NULL) {
- if (!vendor)
- vendor = kdp->vendorname;
- if (!product)
- product = (kdp->flags & USB_KNOWNDEV_NOPROD) == 0 ?
+ if (vendor == NULL)
+ vendor = kdp->vendorname;
+ if (product == NULL)
+ product = (kdp->flags & USB_KNOWNDEV_NOPROD) == 0 ?
kdp->productname : NULL;
}
}
#endif
- if (vendor != NULL)
+ if (vendor != NULL && *vendor)
strcpy(v, vendor);
else
sprintf(v, "vendor 0x%04x", UGETW(udd->idVendor));
- if (product != NULL)
+ if (product != NULL && *product)
strcpy(p, product);
else
sprintf(p, "product 0x%04x", UGETW(udd->idProduct));
}
int
-usbd_printBCD(cp, bcd)
- char *cp;
- int bcd;
+usbd_printBCD(char *cp, int bcd)
{
return (sprintf(cp, "%x.%02x", bcd >> 8, bcd & 0xff));
}
void
-usbd_devinfo(dev, showclass, cp)
- usbd_device_handle dev;
- int showclass;
- char *cp;
+usbd_devinfo(usbd_device_handle dev, int showclass, char *cp)
{
usb_device_descriptor_t *udd = &dev->ddesc;
char vendor[USB_MAX_STRING_LEN];
char product[USB_MAX_STRING_LEN];
int bcdDevice, bcdUSB;
- usbd_devinfo_vp(dev, vendor, product);
+ usbd_devinfo_vp(dev, vendor, product, 1);
cp += sprintf(cp, "%s %s", vendor, product);
if (showclass)
cp += sprintf(cp, ", class %d/%d",
@@ -297,9 +308,7 @@ usbd_devinfo(dev, showclass, cp)
/* Delay for a certain number of ms */
void
-usb_delay_ms(bus, ms)
- usbd_bus_handle bus;
- u_int ms;
+usb_delay_ms(usbd_bus_handle bus, u_int ms)
{
/* Wait at least two clock ticks so we know the time has passed. */
if (bus->use_polling || cold)
@@ -310,18 +319,13 @@ usb_delay_ms(bus, ms)
/* Delay given a device handle. */
void
-usbd_delay_ms(dev, ms)
- usbd_device_handle dev;
- u_int ms;
+usbd_delay_ms(usbd_device_handle dev, u_int ms)
{
usb_delay_ms(dev->bus, ms);
}
usbd_status
-usbd_reset_port(dev, port, ps)
- usbd_device_handle dev;
- int port;
- usb_port_status_t *ps;
+usbd_reset_port(usbd_device_handle dev, int port, usb_port_status_t *ps)
{
usb_device_request_t req;
usbd_status err;
@@ -363,10 +367,7 @@ usbd_reset_port(dev, port, ps)
}
usb_interface_descriptor_t *
-usbd_find_idesc(cd, ifaceidx, altidx)
- usb_config_descriptor_t *cd;
- int ifaceidx;
- int altidx;
+usbd_find_idesc(usb_config_descriptor_t *cd, int ifaceidx, int altidx)
{
char *p = (char *)cd;
char *end = p + UGETW(cd->wTotalLength);
@@ -397,11 +398,8 @@ usbd_find_idesc(cd, ifaceidx, altidx)
}
usb_endpoint_descriptor_t *
-usbd_find_edesc(cd, ifaceidx, altidx, endptidx)
- usb_config_descriptor_t *cd;
- int ifaceidx;
- int altidx;
- int endptidx;
+usbd_find_edesc(usb_config_descriptor_t *cd, int ifaceidx, int altidx,
+ int endptidx)
{
char *p = (char *)cd;
char *end = p + UGETW(cd->wTotalLength);
@@ -433,21 +431,20 @@ usbd_find_edesc(cd, ifaceidx, altidx, endptidx)
}
usbd_status
-usbd_fill_iface_data(dev, ifaceidx, altidx)
- usbd_device_handle dev;
- int ifaceidx;
- int altidx;
+usbd_fill_iface_data(usbd_device_handle dev, int ifaceidx, int altidx)
{
usbd_interface_handle ifc = &dev->ifaces[ifaceidx];
+ usb_interface_descriptor_t *idesc;
char *p, *end;
int endpt, nendpt;
DPRINTFN(4,("usbd_fill_iface_data: ifaceidx=%d altidx=%d\n",
ifaceidx, altidx));
- ifc->device = dev;
- ifc->idesc = usbd_find_idesc(dev->cdesc, ifaceidx, altidx);
- if (ifc->idesc == 0)
+ idesc = usbd_find_idesc(dev->cdesc, ifaceidx, altidx);
+ if (idesc == NULL)
return (USBD_INVAL);
+ ifc->device = dev;
+ ifc->idesc = idesc;
ifc->index = ifaceidx;
ifc->altindex = altidx;
nendpt = ifc->idesc->bNumEndpoints;
@@ -493,15 +490,15 @@ usbd_fill_iface_data(dev, ifaceidx, altidx)
return (USBD_NORMAL_COMPLETION);
bad:
- if (ifc->endpoints != NULL)
+ if (ifc->endpoints != NULL) {
free(ifc->endpoints, M_USB);
+ ifc->endpoints = NULL;
+ }
return (USBD_INVAL);
}
void
-usbd_free_iface_data(dev, ifcno)
- usbd_device_handle dev;
- int ifcno;
+usbd_free_iface_data(usbd_device_handle dev, int ifcno)
{
usbd_interface_handle ifc = &dev->ifaces[ifcno];
if (ifc->endpoints)
@@ -509,9 +506,7 @@ usbd_free_iface_data(dev, ifcno)
}
Static usbd_status
-usbd_set_config(dev, conf)
- usbd_device_handle dev;
- int conf;
+usbd_set_config(usbd_device_handle dev, int conf)
{
usb_device_request_t req;
@@ -524,10 +519,7 @@ usbd_set_config(dev, conf)
}
usbd_status
-usbd_set_config_no(dev, no, msg)
- usbd_device_handle dev;
- int no;
- int msg;
+usbd_set_config_no(usbd_device_handle dev, int no, int msg)
{
int index;
usb_config_descriptor_t cd;
@@ -549,10 +541,7 @@ usbd_set_config_no(dev, no, msg)
}
usbd_status
-usbd_set_config_index(dev, index, msg)
- usbd_device_handle dev;
- int index;
- int msg;
+usbd_set_config_index(usbd_device_handle dev, int index, int msg)
{
usb_status_t ds;
usb_config_descriptor_t cd, *cdp;
@@ -634,6 +623,7 @@ usbd_set_config_index(dev, index, msg)
#endif
power = cdp->bMaxPower * 2;
if (power > dev->powersrc->power) {
+ DPRINTF(("power exceeded %d %d\n", power,dev->powersrc->power));
/* XXX print nicer message. */
if (msg)
printf("%s: device addr %d (config %d) exceeds power "
@@ -688,12 +678,8 @@ usbd_set_config_index(dev, index, msg)
/* XXX add function for alternate settings */
usbd_status
-usbd_setup_pipe(dev, iface, ep, ival, pipe)
- usbd_device_handle dev;
- usbd_interface_handle iface;
- struct usbd_endpoint *ep;
- int ival;
- usbd_pipe_handle *pipe;
+usbd_setup_pipe(usbd_device_handle dev, usbd_interface_handle iface,
+ struct usbd_endpoint *ep, int ival, usbd_pipe_handle *pipe)
{
usbd_pipe_handle p;
usbd_status err;
@@ -730,8 +716,7 @@ usbd_setup_pipe(dev, iface, ep, ival, pipe)
/* Abort the device control pipe. */
void
-usbd_kill_pipe(pipe)
- usbd_pipe_handle pipe;
+usbd_kill_pipe(usbd_pipe_handle pipe)
{
pipe->methods->close(pipe);
pipe->endpoint->refcnt--;
@@ -739,8 +724,7 @@ usbd_kill_pipe(pipe)
}
int
-usbd_getnewaddr(bus)
- usbd_bus_handle bus;
+usbd_getnewaddr(usbd_bus_handle bus)
{
int addr;
@@ -752,11 +736,8 @@ usbd_getnewaddr(bus)
usbd_status
-usbd_probe_and_attach(parent, dev, port, addr)
- device_ptr_t parent;
- usbd_device_handle dev;
- int port;
- int addr;
+usbd_probe_and_attach(device_ptr_t parent, usbd_device_handle dev,
+ int port, int addr)
{
struct usb_attach_arg uaa;
usb_device_descriptor_t *dd = &dev->ddesc;
@@ -923,13 +904,8 @@ usbd_probe_and_attach(parent, dev, port, addr)
* and attach a driver.
*/
usbd_status
-usbd_new_device(parent, bus, depth, lowspeed, port, up)
- device_ptr_t parent;
- usbd_bus_handle bus;
- int depth;
- int lowspeed;
- int port;
- struct usbd_port *up;
+usbd_new_device(device_ptr_t parent, usbd_bus_handle bus, int depth,
+ int lowspeed, int port, struct usbd_port *up)
{
usbd_device_handle dev;
usb_device_descriptor_t *dd;
@@ -1057,12 +1033,12 @@ usbd_new_device(parent, bus, depth, lowspeed, port, up)
}
usbd_add_event(USB_EVENT_ATTACH, dev);
+
return (USBD_NORMAL_COMPLETION);
}
usbd_status
-usbd_reload_device_desc(dev)
- usbd_device_handle dev;
+usbd_reload_device_desc(usbd_device_handle dev)
{
usbd_status err;
@@ -1078,9 +1054,7 @@ usbd_reload_device_desc(dev)
}
void
-usbd_remove_device(dev, up)
- usbd_device_handle dev;
- struct usbd_port *up;
+usbd_remove_device(usbd_device_handle dev, struct usbd_port *up)
{
DPRINTF(("usbd_remove_device: %p\n", dev));
@@ -1094,9 +1068,7 @@ usbd_remove_device(dev, up)
#if defined(__NetBSD__) || defined(__OpenBSD__)
int
-usbd_print(aux, pnp)
- void *aux;
- const char *pnp;
+usbd_print(void *aux, const char *pnp)
{
struct usb_attach_arg *uaa = aux;
char devinfo[1024];
@@ -1132,17 +1104,11 @@ usbd_print(aux, pnp)
#if defined(__NetBSD__)
int
-usbd_submatch(parent, cf, aux)
- struct device *parent;
- struct cfdata *cf;
- void *aux;
+usbd_submatch(struct device *parent, struct cfdata *cf, void *aux)
{
#elif defined(__OpenBSD__)
int
-usbd_submatch(parent, match, aux)
- struct device *parent;
- void *match;
- void *aux;
+usbd_submatch(struct device *parent, void *match, void *aux)
{
struct cfdata *cf = match;
#endif
@@ -1158,24 +1124,24 @@ usbd_submatch(parent, match, aux)
uaa->release, cf->uhubcf_release));
if (uaa->port != 0 && /* root hub has port 0, it should match */
((uaa->port != 0 &&
- cf->uhubcf_port != UHUB_UNK_PORT &&
- cf->uhubcf_port != uaa->port) ||
- (uaa->configno != UHUB_UNK_CONFIGURATION &&
- cf->uhubcf_configuration != UHUB_UNK_CONFIGURATION &&
- cf->uhubcf_configuration != uaa->configno) ||
- (uaa->ifaceno != UHUB_UNK_INTERFACE &&
- cf->uhubcf_interface != UHUB_UNK_INTERFACE &&
- cf->uhubcf_interface != uaa->ifaceno) ||
- (uaa->vendor != UHUB_UNK_VENDOR &&
- cf->uhubcf_vendor != UHUB_UNK_VENDOR &&
- cf->uhubcf_vendor != uaa->vendor) ||
- (uaa->product != UHUB_UNK_PRODUCT &&
- cf->uhubcf_product != UHUB_UNK_PRODUCT &&
- cf->uhubcf_product != uaa->product) ||
- (uaa->release != UHUB_UNK_RELEASE &&
- cf->uhubcf_release != UHUB_UNK_RELEASE &&
- cf->uhubcf_release != uaa->release)
- )
+ cf->uhubcf_port != UHUB_UNK_PORT &&
+ cf->uhubcf_port != uaa->port) ||
+ (uaa->configno != UHUB_UNK_CONFIGURATION &&
+ cf->uhubcf_configuration != UHUB_UNK_CONFIGURATION &&
+ cf->uhubcf_configuration != uaa->configno) ||
+ (uaa->ifaceno != UHUB_UNK_INTERFACE &&
+ cf->uhubcf_interface != UHUB_UNK_INTERFACE &&
+ cf->uhubcf_interface != uaa->ifaceno) ||
+ (uaa->vendor != UHUB_UNK_VENDOR &&
+ cf->uhubcf_vendor != UHUB_UNK_VENDOR &&
+ cf->uhubcf_vendor != uaa->vendor) ||
+ (uaa->product != UHUB_UNK_PRODUCT &&
+ cf->uhubcf_product != UHUB_UNK_PRODUCT &&
+ cf->uhubcf_product != uaa->product) ||
+ (uaa->release != UHUB_UNK_RELEASE &&
+ cf->uhubcf_release != UHUB_UNK_RELEASE &&
+ cf->uhubcf_release != uaa->release)
+ )
)
return 0;
return ((*cf->cf_attach->ca_match)(parent, cf, aux));
@@ -1184,30 +1150,15 @@ usbd_submatch(parent, match, aux)
#endif
void
-usbd_fill_deviceinfo(dev, di)
- usbd_device_handle dev;
- struct usb_device_info *di;
+usbd_fill_deviceinfo(usbd_device_handle dev, struct usb_device_info *di,
+ int usedev)
{
struct usbd_port *p;
int i, err, s;
di->bus = USBDEVUNIT(dev->bus->bdev);
di->addr = dev->address;
-
- if (dev->subdevs) {
- for (i = 0; dev->subdevs[i] &&
- i < MAXDEVNAMES; i++) {
- strncpy(di->devnames[i], USBDEVPTRNAME(dev->subdevs[i]),
- MAXDEVNAMELEN);
- di->devnames[i][MAXDEVNAMELEN-1] = '\0'; /* terminate */
- }
- } else {
- i = 0;
- }
- for (/*i is set */; i < MAXDEVNAMES; i++)
- di->devnames[i][0] = 0; /* empty */
-
- usbd_devinfo_vp(dev, di->vendor, di->product);
+ usbd_devinfo_vp(dev, di->vendor, di->product, usedev);
usbd_printBCD(di->release, UGETW(dev->ddesc.bcdDevice));
di->vendorNo = UGETW(dev->ddesc.idVendor);
di->productNo = UGETW(dev->ddesc.idProduct);
@@ -1219,6 +1170,19 @@ usbd_fill_deviceinfo(dev, di)
di->power = dev->self_powered ? 0 : dev->power;
di->lowspeed = dev->lowspeed;
+ if (dev->subdevs != NULL) {
+ for (i = 0; dev->subdevs[i] &&
+ i < MAXDEVNAMES; i++) {
+ strncpy(di->devnames[i], USBDEVPTRNAME(dev->subdevs[i]),
+ MAXDEVNAMELEN);
+ di->devnames[i][MAXDEVNAMELEN-1] = '\0';
+ }
+ } else {
+ i = 0;
+ }
+ for (/*i is set */; i < MAXDEVNAMES; i++)
+ di->devnames[i][0] = 0; /* empty */
+
if (dev->hub) {
for (i = 0;
i < sizeof(di->ports) / sizeof(di->ports[0]) &&
@@ -1246,8 +1210,7 @@ usbd_fill_deviceinfo(dev, di)
}
void
-usb_free_device(dev)
- usbd_device_handle dev;
+usb_free_device(usbd_device_handle dev)
{
int ifcidx, nifc;
@@ -1284,9 +1247,7 @@ usb_free_device(dev)
* been disconnected.
*/
void
-usb_disconnect_port(up, parent)
- struct usbd_port *up;
- device_ptr_t parent;
+usb_disconnect_port(struct usbd_port *up, device_ptr_t parent)
{
usbd_device_handle dev = up->device;
const char *hubname = USBDEVPTRNAME(parent);
@@ -1302,15 +1263,6 @@ usb_disconnect_port(up, parent)
}
#endif
- if (dev->cdesc == NULL) {
- /* Partially attached device, just drop it. */
- dev->bus->devices[dev->address] = 0;
- up->device = 0;
- return;
- }
-
- usbd_add_event(USB_EVENT_DETACH, dev);
-
if (dev->subdevs != NULL) {
DPRINTFN(3,("usb_disconnect_port: disconnect subdevs\n"));
for (i = 0; dev->subdevs[i]; i++) {
@@ -1336,11 +1288,7 @@ usb_disconnect_port(up, parent)
}
#ifdef __OpenBSD__
-void *usb_realloc(p, size, pool, flags)
- void *p;
- u_int size;
- int pool;
- int flags;
+void *usb_realloc(void *p, u_int size, int pool, int flags)
{
void *q;
diff --git a/sys/dev/usb/usbdi.c b/sys/dev/usb/usbdi.c
index 6203e8a..9acffce 100644
--- a/sys/dev/usb/usbdi.c
+++ b/sys/dev/usb/usbdi.c
@@ -1047,7 +1047,7 @@ usbd_do_request_async(dev, req, data)
return (USBD_NORMAL_COMPLETION);
}
-struct usbd_quirks *
+const struct usbd_quirks *
usbd_get_quirks(dev)
usbd_device_handle dev;
{
diff --git a/sys/dev/usb/usbdi.h b/sys/dev/usb/usbdi.h
index acf3bb3..a66fec7 100644
--- a/sys/dev/usb/usbdi.h
+++ b/sys/dev/usb/usbdi.h
@@ -162,7 +162,7 @@ int usbd_get_no_alts(usb_config_descriptor_t *, int);
usbd_status usbd_get_interface
(usbd_interface_handle iface, u_int8_t *aiface);
void usbd_fill_deviceinfo
- (usbd_device_handle dev, struct usb_device_info *di);
+ (usbd_device_handle dev, struct usb_device_info *di, int usedev);
int usbd_get_interface_altindex(usbd_interface_handle iface);
usb_interface_descriptor_t *usbd_find_idesc
@@ -179,7 +179,7 @@ const char *usbd_errstr(usbd_status err);
void usbd_add_event(int, usbd_device_handle);
void usbd_devinfo(usbd_device_handle, int, char *);
-struct usbd_quirks *usbd_get_quirks(usbd_device_handle);
+const struct usbd_quirks *usbd_get_quirks(usbd_device_handle);
usb_endpoint_descriptor_t *usbd_get_endpoint_descriptor
(usbd_interface_handle iface, u_int8_t address);
diff --git a/sys/dev/usb/usbdivar.h b/sys/dev/usb/usbdivar.h
index ef939e1..9166d72 100644
--- a/sys/dev/usb/usbdivar.h
+++ b/sys/dev/usb/usbdivar.h
@@ -134,7 +134,7 @@ struct usbd_device {
struct usbd_interface *ifaces; /* array of all interfaces */
usb_device_descriptor_t ddesc; /* device descriptor */
usb_config_descriptor_t *cdesc; /* full config descr */
- struct usbd_quirks *quirks; /* device quirks, always set */
+ const struct usbd_quirks *quirks; /* device quirks, always set */
struct usbd_hub *hub; /* only if this is a hub */
device_ptr_t *subdevs; /* sub-devices, 0 terminated */
};
@@ -210,7 +210,6 @@ void usbd_finish(void);
/* Routines from usb_subr.c */
int usbctlprint(void *, const char *);
void usb_delay_ms(usbd_bus_handle, u_int);
-void usbd_devinfo_vp(usbd_device_handle, char *, char *);
usbd_status usbd_reset_port(usbd_device_handle dev,
int port, usb_port_status_t *ps);
usbd_status usbd_setup_pipe(usbd_device_handle dev,
OpenPOWER on IntegriCloud