summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorChristian Weisgerber <naddy@cvs.openbsd.org>2022-04-12 19:41:12 +0000
committerChristian Weisgerber <naddy@cvs.openbsd.org>2022-04-12 19:41:12 +0000
commit2b77f7030fdb72b7a49cd6705cba5073634ee0dc (patch)
tree2ab0bf5c525c70ed4e7e1c88456e3644949beac2 /sys/dev
parente31499b305e66b9c159a512a815c32494332186d (diff)
constify USB host controller method tables and root hub descriptors
ok mglocker@
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/usb/dwc2/dwc2.c17
-rw-r--r--sys/dev/usb/ehci.c34
-rw-r--r--sys/dev/usb/ohci.c36
-rw-r--r--sys/dev/usb/uhci.c32
-rw-r--r--sys/dev/usb/usbdivar.h6
-rw-r--r--sys/dev/usb/xhci.c24
6 files changed, 78 insertions, 71 deletions
diff --git a/sys/dev/usb/dwc2/dwc2.c b/sys/dev/usb/dwc2/dwc2.c
index 9b9d1635f90..3ec8a3e767d 100644
--- a/sys/dev/usb/dwc2/dwc2.c
+++ b/sys/dev/usb/dwc2/dwc2.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dwc2.c,v 1.59 2021/11/28 09:25:02 mglocker Exp $ */
+/* $OpenBSD: dwc2.c,v 1.60 2022/04/12 19:41:11 naddy Exp $ */
/* $NetBSD: dwc2.c,v 1.32 2014/09/02 23:26:20 macallan Exp $ */
/*-
@@ -146,7 +146,7 @@ dwc2_free_bus_bandwidth(struct dwc2_hsotg *hsotg, u16 bw,
#define DWC2_INTR_ENDPT 1
-STATIC struct usbd_bus_methods dwc2_bus_methods = {
+STATIC const struct usbd_bus_methods dwc2_bus_methods = {
.open_pipe = dwc2_open,
.dev_setaddr = dwc2_setaddr,
.soft_intr = dwc2_softintr,
@@ -155,7 +155,7 @@ STATIC struct usbd_bus_methods dwc2_bus_methods = {
.freex = dwc2_freex,
};
-STATIC struct usbd_pipe_methods dwc2_root_ctrl_methods = {
+STATIC const struct usbd_pipe_methods dwc2_root_ctrl_methods = {
.transfer = dwc2_root_ctrl_transfer,
.start = dwc2_root_ctrl_start,
.abort = dwc2_root_ctrl_abort,
@@ -164,7 +164,7 @@ STATIC struct usbd_pipe_methods dwc2_root_ctrl_methods = {
.done = dwc2_root_ctrl_done,
};
-STATIC struct usbd_pipe_methods dwc2_root_intr_methods = {
+STATIC const struct usbd_pipe_methods dwc2_root_intr_methods = {
.transfer = dwc2_root_intr_transfer,
.start = dwc2_root_intr_start,
.abort = dwc2_root_intr_abort,
@@ -173,7 +173,7 @@ STATIC struct usbd_pipe_methods dwc2_root_intr_methods = {
.done = dwc2_root_intr_done,
};
-STATIC struct usbd_pipe_methods dwc2_device_ctrl_methods = {
+STATIC const struct usbd_pipe_methods dwc2_device_ctrl_methods = {
.transfer = dwc2_device_ctrl_transfer,
.start = dwc2_device_ctrl_start,
.abort = dwc2_device_ctrl_abort,
@@ -182,7 +182,7 @@ STATIC struct usbd_pipe_methods dwc2_device_ctrl_methods = {
.done = dwc2_device_ctrl_done,
};
-STATIC struct usbd_pipe_methods dwc2_device_intr_methods = {
+STATIC const struct usbd_pipe_methods dwc2_device_intr_methods = {
.transfer = dwc2_device_intr_transfer,
.start = dwc2_device_intr_start,
.abort = dwc2_device_intr_abort,
@@ -191,7 +191,7 @@ STATIC struct usbd_pipe_methods dwc2_device_intr_methods = {
.done = dwc2_device_intr_done,
};
-STATIC struct usbd_pipe_methods dwc2_device_bulk_methods = {
+STATIC const struct usbd_pipe_methods dwc2_device_bulk_methods = {
.transfer = dwc2_device_bulk_transfer,
.start = dwc2_device_bulk_start,
.abort = dwc2_device_bulk_abort,
@@ -200,7 +200,7 @@ STATIC struct usbd_pipe_methods dwc2_device_bulk_methods = {
.done = dwc2_device_bulk_done,
};
-STATIC struct usbd_pipe_methods dwc2_device_isoc_methods = {
+STATIC const struct usbd_pipe_methods dwc2_device_isoc_methods = {
.transfer = dwc2_device_isoc_transfer,
.start = dwc2_device_isoc_start,
.abort = dwc2_device_isoc_abort,
@@ -681,7 +681,6 @@ dwc2_root_ctrl_start(struct usbd_xfer *xfer)
switch (value) {
case C(0, UDESC_DEVICE):
l = min(len, USB_DEVICE_DESCRIPTOR_SIZE);
-// USETW(dwc2_devd.idVendor, sc->sc_id_vendor);
memcpy(buf, &dwc2_devd, l);
buf += l;
len -= l;
diff --git a/sys/dev/usb/ehci.c b/sys/dev/usb/ehci.c
index 350580c00b3..db59abf9919 100644
--- a/sys/dev/usb/ehci.c
+++ b/sys/dev/usb/ehci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ehci.c,v 1.218 2022/01/09 05:43:00 jsg Exp $ */
+/* $OpenBSD: ehci.c,v 1.219 2022/04/12 19:41:11 naddy Exp $ */
/* $NetBSD: ehci.c,v 1.66 2004/06/30 03:11:56 mycroft Exp $ */
/*
@@ -218,7 +218,7 @@ void ehci_dump_exfer(struct ehci_xfer *);
#define EHCI_INTR_ENDPT 1
-struct usbd_bus_methods ehci_bus_methods = {
+const struct usbd_bus_methods ehci_bus_methods = {
.open_pipe = ehci_open,
.dev_setaddr = ehci_setaddr,
.soft_intr = ehci_softintr,
@@ -227,7 +227,7 @@ struct usbd_bus_methods ehci_bus_methods = {
.freex = ehci_freex,
};
-struct usbd_pipe_methods ehci_root_ctrl_methods = {
+const struct usbd_pipe_methods ehci_root_ctrl_methods = {
.transfer = ehci_root_ctrl_transfer,
.start = ehci_root_ctrl_start,
.abort = ehci_root_ctrl_abort,
@@ -235,7 +235,7 @@ struct usbd_pipe_methods ehci_root_ctrl_methods = {
.done = ehci_root_ctrl_done,
};
-struct usbd_pipe_methods ehci_root_intr_methods = {
+const struct usbd_pipe_methods ehci_root_intr_methods = {
.transfer = ehci_root_intr_transfer,
.start = ehci_root_intr_start,
.abort = ehci_root_intr_abort,
@@ -243,7 +243,7 @@ struct usbd_pipe_methods ehci_root_intr_methods = {
.done = ehci_root_intr_done,
};
-struct usbd_pipe_methods ehci_device_ctrl_methods = {
+const struct usbd_pipe_methods ehci_device_ctrl_methods = {
.transfer = ehci_device_ctrl_transfer,
.start = ehci_device_ctrl_start,
.abort = ehci_device_ctrl_abort,
@@ -251,7 +251,7 @@ struct usbd_pipe_methods ehci_device_ctrl_methods = {
.done = ehci_device_ctrl_done,
};
-struct usbd_pipe_methods ehci_device_intr_methods = {
+const struct usbd_pipe_methods ehci_device_intr_methods = {
.transfer = ehci_device_intr_transfer,
.start = ehci_device_intr_start,
.abort = ehci_device_intr_abort,
@@ -260,7 +260,7 @@ struct usbd_pipe_methods ehci_device_intr_methods = {
.done = ehci_device_intr_done,
};
-struct usbd_pipe_methods ehci_device_bulk_methods = {
+const struct usbd_pipe_methods ehci_device_bulk_methods = {
.transfer = ehci_device_bulk_transfer,
.start = ehci_device_bulk_start,
.abort = ehci_device_bulk_abort,
@@ -269,7 +269,7 @@ struct usbd_pipe_methods ehci_device_bulk_methods = {
.done = ehci_device_bulk_done,
};
-struct usbd_pipe_methods ehci_device_isoc_methods = {
+const struct usbd_pipe_methods ehci_device_isoc_methods = {
.transfer = ehci_device_isoc_transfer,
.start = ehci_device_isoc_start,
.abort = ehci_device_isoc_abort,
@@ -1705,7 +1705,7 @@ ehci_free_itd_chain(struct ehci_softc *sc, struct ehci_xfer *ex)
/*
* Data structures and routines to emulate the root hub.
*/
-usb_device_descriptor_t ehci_devd = {
+const usb_device_descriptor_t ehci_devd = {
USB_DEVICE_DESCRIPTOR_SIZE,
UDESC_DEVICE, /* type */
{0x00, 0x02}, /* USB version */
@@ -1718,7 +1718,7 @@ usb_device_descriptor_t ehci_devd = {
1 /* # of configurations */
};
-usb_device_qualifier_t ehci_odevd = {
+const usb_device_qualifier_t ehci_odevd = {
USB_DEVICE_DESCRIPTOR_SIZE,
UDESC_DEVICE_QUALIFIER, /* type */
{0x00, 0x02}, /* USB version */
@@ -1730,7 +1730,7 @@ usb_device_qualifier_t ehci_odevd = {
0
};
-usb_config_descriptor_t ehci_confd = {
+const usb_config_descriptor_t ehci_confd = {
USB_CONFIG_DESCRIPTOR_SIZE,
UDESC_CONFIG,
{USB_CONFIG_DESCRIPTOR_SIZE +
@@ -1743,7 +1743,7 @@ usb_config_descriptor_t ehci_confd = {
0 /* max power */
};
-usb_interface_descriptor_t ehci_ifcd = {
+const usb_interface_descriptor_t ehci_ifcd = {
USB_INTERFACE_DESCRIPTOR_SIZE,
UDESC_INTERFACE,
0,
@@ -1755,7 +1755,7 @@ usb_interface_descriptor_t ehci_ifcd = {
0
};
-usb_endpoint_descriptor_t ehci_endpd = {
+const usb_endpoint_descriptor_t ehci_endpd = {
USB_ENDPOINT_DESCRIPTOR_SIZE,
UDESC_ENDPOINT,
UE_DIR_IN | EHCI_INTR_ENDPT,
@@ -1764,7 +1764,7 @@ usb_endpoint_descriptor_t ehci_endpd = {
12
};
-usb_hub_descriptor_t ehci_hubd = {
+const usb_hub_descriptor_t ehci_hubd = {
USB_HUB_DESCRIPTOR_SIZE,
UDESC_HUB,
0,
@@ -1800,6 +1800,7 @@ ehci_root_ctrl_start(struct usbd_xfer *xfer)
int port, i;
int s, len, value, index, l, totlen = 0;
usb_port_status_t ps;
+ usb_device_descriptor_t devd;
usb_hub_descriptor_t hubd;
usbd_status err;
u_int32_t v;
@@ -1848,9 +1849,10 @@ ehci_root_ctrl_start(struct usbd_xfer *xfer)
err = USBD_IOERROR;
goto ret;
}
+ devd = ehci_devd;
+ USETW(devd.idVendor, sc->sc_id_vendor);
totlen = l = min(len, USB_DEVICE_DESCRIPTOR_SIZE);
- USETW(ehci_devd.idVendor, sc->sc_id_vendor);
- memcpy(buf, &ehci_devd, l);
+ memcpy(buf, &devd, l);
break;
case UDESC_DEVICE_QUALIFIER:
if ((value & 0xff) != 0) {
diff --git a/sys/dev/usb/ohci.c b/sys/dev/usb/ohci.c
index 041e8328e9a..1411fb493ca 100644
--- a/sys/dev/usb/ohci.c
+++ b/sys/dev/usb/ohci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ohci.c,v 1.164 2022/01/09 05:43:00 jsg Exp $ */
+/* $OpenBSD: ohci.c,v 1.165 2022/04/12 19:41:11 naddy Exp $ */
/* $NetBSD: ohci.c,v 1.139 2003/02/22 05:24:16 tsutsui Exp $ */
/* $FreeBSD: src/sys/dev/usb/ohci.c,v 1.22 1999/11/17 22:33:40 n_hibma Exp $ */
@@ -197,7 +197,7 @@ OREAD4(struct ohci_softc *sc, bus_size_t r)
}
/* Reverse the bits in a value 0 .. 31 */
-u_int8_t revbits[OHCI_NO_INTRS] =
+const u_int8_t revbits[OHCI_NO_INTRS] =
{ 0x00, 0x10, 0x08, 0x18, 0x04, 0x14, 0x0c, 0x1c,
0x02, 0x12, 0x0a, 0x1a, 0x06, 0x16, 0x0e, 0x1e,
0x01, 0x11, 0x09, 0x19, 0x05, 0x15, 0x0d, 0x1d,
@@ -229,7 +229,7 @@ struct ohci_pipe {
#define OHCI_INTR_ENDPT 1
-struct usbd_bus_methods ohci_bus_methods = {
+const struct usbd_bus_methods ohci_bus_methods = {
.open_pipe = ohci_open,
.dev_setaddr = ohci_setaddr,
.soft_intr = ohci_softintr,
@@ -238,7 +238,7 @@ struct usbd_bus_methods ohci_bus_methods = {
.freex = ohci_freex,
};
-struct usbd_pipe_methods ohci_root_ctrl_methods = {
+const struct usbd_pipe_methods ohci_root_ctrl_methods = {
.transfer = ohci_root_ctrl_transfer,
.start = ohci_root_ctrl_start,
.abort = ohci_root_ctrl_abort,
@@ -246,7 +246,7 @@ struct usbd_pipe_methods ohci_root_ctrl_methods = {
.done = ohci_root_ctrl_done,
};
-struct usbd_pipe_methods ohci_root_intr_methods = {
+const struct usbd_pipe_methods ohci_root_intr_methods = {
.transfer = ohci_root_intr_transfer,
.start = ohci_root_intr_start,
.abort = ohci_root_intr_abort,
@@ -254,7 +254,7 @@ struct usbd_pipe_methods ohci_root_intr_methods = {
.done = ohci_root_intr_done,
};
-struct usbd_pipe_methods ohci_device_ctrl_methods = {
+const struct usbd_pipe_methods ohci_device_ctrl_methods = {
.transfer = ohci_device_ctrl_transfer,
.start = ohci_device_ctrl_start,
.abort = ohci_device_ctrl_abort,
@@ -262,7 +262,7 @@ struct usbd_pipe_methods ohci_device_ctrl_methods = {
.done = ohci_device_ctrl_done,
};
-struct usbd_pipe_methods ohci_device_intr_methods = {
+const struct usbd_pipe_methods ohci_device_intr_methods = {
.transfer = ohci_device_intr_transfer,
.start = ohci_device_intr_start,
.abort = ohci_device_intr_abort,
@@ -271,7 +271,7 @@ struct usbd_pipe_methods ohci_device_intr_methods = {
.done = ohci_device_intr_done,
};
-struct usbd_pipe_methods ohci_device_bulk_methods = {
+const struct usbd_pipe_methods ohci_device_bulk_methods = {
.transfer = ohci_device_bulk_transfer,
.start = ohci_device_bulk_start,
.abort = ohci_device_bulk_abort,
@@ -280,7 +280,7 @@ struct usbd_pipe_methods ohci_device_bulk_methods = {
.done = ohci_device_bulk_done,
};
-struct usbd_pipe_methods ohci_device_isoc_methods = {
+const struct usbd_pipe_methods ohci_device_isoc_methods = {
.transfer = ohci_device_isoc_transfer,
.start = ohci_device_isoc_start,
.abort = ohci_device_isoc_abort,
@@ -1153,7 +1153,7 @@ ohci_rhsc_enable(void *v_sc)
}
#ifdef OHCI_DEBUG
-char *ohci_cc_strs[] = {
+const char *ohci_cc_strs[] = {
"NO_ERROR",
"CRC",
"BIT_STUFFING",
@@ -2189,7 +2189,7 @@ ohci_abort_xfer(struct usbd_xfer *xfer, usbd_status status)
/*
* Data structures and routines to emulate the root hub.
*/
-usb_device_descriptor_t ohci_devd = {
+const usb_device_descriptor_t ohci_devd = {
USB_DEVICE_DESCRIPTOR_SIZE,
UDESC_DEVICE, /* type */
{0x00, 0x01}, /* USB version */
@@ -2202,7 +2202,7 @@ usb_device_descriptor_t ohci_devd = {
1 /* # of configurations */
};
-usb_config_descriptor_t ohci_confd = {
+const usb_config_descriptor_t ohci_confd = {
USB_CONFIG_DESCRIPTOR_SIZE,
UDESC_CONFIG,
{USB_CONFIG_DESCRIPTOR_SIZE +
@@ -2215,7 +2215,7 @@ usb_config_descriptor_t ohci_confd = {
0 /* max power */
};
-usb_interface_descriptor_t ohci_ifcd = {
+const usb_interface_descriptor_t ohci_ifcd = {
USB_INTERFACE_DESCRIPTOR_SIZE,
UDESC_INTERFACE,
0,
@@ -2227,7 +2227,7 @@ usb_interface_descriptor_t ohci_ifcd = {
0
};
-usb_endpoint_descriptor_t ohci_endpd = {
+const usb_endpoint_descriptor_t ohci_endpd = {
USB_ENDPOINT_DESCRIPTOR_SIZE,
UDESC_ENDPOINT,
UE_DIR_IN | OHCI_INTR_ENDPT,
@@ -2236,7 +2236,7 @@ usb_endpoint_descriptor_t ohci_endpd = {
255
};
-usb_hub_descriptor_t ohci_hubd = {
+const usb_hub_descriptor_t ohci_hubd = {
USB_HUB_DESCRIPTOR_SIZE,
UDESC_HUB,
0,
@@ -2272,6 +2272,7 @@ ohci_root_ctrl_start(struct usbd_xfer *xfer)
int port, i;
int s, len, value, index, l, totlen = 0;
usb_port_status_t ps;
+ usb_device_descriptor_t devd;
usb_hub_descriptor_t hubd;
usbd_status err;
u_int32_t v;
@@ -2320,9 +2321,10 @@ ohci_root_ctrl_start(struct usbd_xfer *xfer)
err = USBD_IOERROR;
goto ret;
}
+ devd = ohci_devd;
+ USETW(devd.idVendor, sc->sc_id_vendor);
totlen = l = min(len, USB_DEVICE_DESCRIPTOR_SIZE);
- USETW(ohci_devd.idVendor, sc->sc_id_vendor);
- memcpy(buf, &ohci_devd, l);
+ memcpy(buf, &devd, l);
break;
case UDESC_CONFIG:
if ((value & 0xff) != 0) {
diff --git a/sys/dev/usb/uhci.c b/sys/dev/usb/uhci.c
index 51fed2c9683..536c4010388 100644
--- a/sys/dev/usb/uhci.c
+++ b/sys/dev/usb/uhci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uhci.c,v 1.155 2022/01/09 05:43:00 jsg Exp $ */
+/* $OpenBSD: uhci.c,v 1.156 2022/04/12 19:41:11 naddy Exp $ */
/* $NetBSD: uhci.c,v 1.172 2003/02/23 04:19:26 simonb Exp $ */
/* $FreeBSD: src/sys/dev/usb/uhci.c,v 1.33 1999/11/17 22:33:41 n_hibma Exp $ */
@@ -246,7 +246,7 @@ UREAD4(struct uhci_softc *sc, bus_size_t r)
#define UHCI_INTR_ENDPT 1
-struct usbd_bus_methods uhci_bus_methods = {
+const struct usbd_bus_methods uhci_bus_methods = {
.open_pipe = uhci_open,
.dev_setaddr = usbd_set_address,
.soft_intr = uhci_softintr,
@@ -255,7 +255,7 @@ struct usbd_bus_methods uhci_bus_methods = {
.freex = uhci_freex,
};
-struct usbd_pipe_methods uhci_root_ctrl_methods = {
+const struct usbd_pipe_methods uhci_root_ctrl_methods = {
.transfer = uhci_root_ctrl_transfer,
.start = uhci_root_ctrl_start,
.abort = uhci_root_ctrl_abort,
@@ -263,7 +263,7 @@ struct usbd_pipe_methods uhci_root_ctrl_methods = {
.done = uhci_root_ctrl_done,
};
-struct usbd_pipe_methods uhci_root_intr_methods = {
+const struct usbd_pipe_methods uhci_root_intr_methods = {
.transfer = uhci_root_intr_transfer,
.start = uhci_root_intr_start,
.abort = uhci_root_intr_abort,
@@ -271,7 +271,7 @@ struct usbd_pipe_methods uhci_root_intr_methods = {
.done = uhci_root_intr_done,
};
-struct usbd_pipe_methods uhci_device_ctrl_methods = {
+const struct usbd_pipe_methods uhci_device_ctrl_methods = {
.transfer = uhci_device_ctrl_transfer,
.start = uhci_device_ctrl_start,
.abort = uhci_device_ctrl_abort,
@@ -279,7 +279,7 @@ struct usbd_pipe_methods uhci_device_ctrl_methods = {
.done = uhci_device_ctrl_done,
};
-struct usbd_pipe_methods uhci_device_intr_methods = {
+const struct usbd_pipe_methods uhci_device_intr_methods = {
.transfer = uhci_device_intr_transfer,
.start = uhci_device_intr_start,
.abort = uhci_device_intr_abort,
@@ -288,7 +288,7 @@ struct usbd_pipe_methods uhci_device_intr_methods = {
.done = uhci_device_intr_done,
};
-struct usbd_pipe_methods uhci_device_bulk_methods = {
+const struct usbd_pipe_methods uhci_device_bulk_methods = {
.transfer = uhci_device_bulk_transfer,
.start = uhci_device_bulk_start,
.abort = uhci_device_bulk_abort,
@@ -297,7 +297,7 @@ struct usbd_pipe_methods uhci_device_bulk_methods = {
.done = uhci_device_bulk_done,
};
-struct usbd_pipe_methods uhci_device_isoc_methods = {
+const struct usbd_pipe_methods uhci_device_isoc_methods = {
.transfer = uhci_device_isoc_transfer,
.start = uhci_device_isoc_start,
.abort = uhci_device_isoc_abort,
@@ -2702,7 +2702,7 @@ uhci_open(struct usbd_pipe *pipe)
/*
* Data structures and routines to emulate the root hub.
*/
-usb_device_descriptor_t uhci_devd = {
+const usb_device_descriptor_t uhci_devd = {
USB_DEVICE_DESCRIPTOR_SIZE,
UDESC_DEVICE, /* type */
{0x00, 0x01}, /* USB version */
@@ -2715,7 +2715,7 @@ usb_device_descriptor_t uhci_devd = {
1 /* # of configurations */
};
-usb_config_descriptor_t uhci_confd = {
+const usb_config_descriptor_t uhci_confd = {
USB_CONFIG_DESCRIPTOR_SIZE,
UDESC_CONFIG,
{USB_CONFIG_DESCRIPTOR_SIZE +
@@ -2728,7 +2728,7 @@ usb_config_descriptor_t uhci_confd = {
0 /* max power */
};
-usb_interface_descriptor_t uhci_ifcd = {
+const usb_interface_descriptor_t uhci_ifcd = {
USB_INTERFACE_DESCRIPTOR_SIZE,
UDESC_INTERFACE,
0,
@@ -2740,7 +2740,7 @@ usb_interface_descriptor_t uhci_ifcd = {
0
};
-usb_endpoint_descriptor_t uhci_endpd = {
+const usb_endpoint_descriptor_t uhci_endpd = {
USB_ENDPOINT_DESCRIPTOR_SIZE,
UDESC_ENDPOINT,
UE_DIR_IN | UHCI_INTR_ENDPT,
@@ -2749,7 +2749,7 @@ usb_endpoint_descriptor_t uhci_endpd = {
255
};
-usb_hub_descriptor_t uhci_hubd_piix = {
+const usb_hub_descriptor_t uhci_hubd_piix = {
USB_HUB_DESCRIPTOR_SIZE,
UDESC_HUB,
2,
@@ -2883,6 +2883,7 @@ uhci_root_ctrl_start(struct usbd_xfer *xfer)
int port, x;
int s, len, value, index, status, change, l, totlen = 0;
usb_port_status_t ps;
+ usb_device_descriptor_t devd;
usbd_status err;
if (sc->sc_bus.dying)
@@ -2928,9 +2929,10 @@ uhci_root_ctrl_start(struct usbd_xfer *xfer)
err = USBD_IOERROR;
goto ret;
}
+ devd = uhci_devd;
+ USETW(devd.idVendor, sc->sc_id_vendor);
totlen = l = min(len, USB_DEVICE_DESCRIPTOR_SIZE);
- USETW(uhci_devd.idVendor, sc->sc_id_vendor);
- memcpy(buf, &uhci_devd, l);
+ memcpy(buf, &devd, l);
break;
case UDESC_CONFIG:
if ((value & 0xff) != 0) {
diff --git a/sys/dev/usb/usbdivar.h b/sys/dev/usb/usbdivar.h
index 5aa207818f7..e84d8f79e13 100644
--- a/sys/dev/usb/usbdivar.h
+++ b/sys/dev/usb/usbdivar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: usbdivar.h,v 1.81 2020/03/21 12:08:31 patrick Exp $ */
+/* $OpenBSD: usbdivar.h,v 1.82 2022/04/12 19:41:11 naddy Exp $ */
/* $NetBSD: usbdivar.h,v 1.70 2002/07/11 21:14:36 augustss Exp $ */
/* $FreeBSD: src/sys/dev/usb/usbdivar.h,v 1.11 1999/11/17 22:33:51 n_hibma Exp $ */
@@ -105,7 +105,7 @@ struct usbd_hub {
struct usbd_bus {
/* Filled by HC driver */
struct device bdev; /* base device, host adapter */
- struct usbd_bus_methods *methods;
+ const struct usbd_bus_methods *methods;
#if NBPFILTER > 0
void *bpfif;
caddr_t bpf;
@@ -194,7 +194,7 @@ struct usbd_pipe {
int interval;
/* Filled by HC driver. */
- struct usbd_pipe_methods *methods;
+ const struct usbd_pipe_methods *methods;
};
struct usbd_xfer {
diff --git a/sys/dev/usb/xhci.c b/sys/dev/usb/xhci.c
index 71958b064a1..8f894cc0308 100644
--- a/sys/dev/usb/xhci.c
+++ b/sys/dev/usb/xhci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: xhci.c,v 1.124 2022/01/09 05:43:02 jsg Exp $ */
+/* $OpenBSD: xhci.c,v 1.125 2022/04/12 19:41:11 naddy Exp $ */
/*
* Copyright (c) 2014-2015 Martin Pieuchot
@@ -157,7 +157,7 @@ usbd_status xhci_device_isoc_start(struct usbd_xfer *);
#define XHCI_INTR_ENDPT 1
-struct usbd_bus_methods xhci_bus_methods = {
+const struct usbd_bus_methods xhci_bus_methods = {
.open_pipe = xhci_pipe_open,
.dev_setaddr = xhci_setaddr,
.soft_intr = xhci_softintr,
@@ -166,7 +166,7 @@ struct usbd_bus_methods xhci_bus_methods = {
.freex = xhci_freex,
};
-struct usbd_pipe_methods xhci_root_ctrl_methods = {
+const struct usbd_pipe_methods xhci_root_ctrl_methods = {
.transfer = xhci_root_ctrl_transfer,
.start = xhci_root_ctrl_start,
.abort = xhci_noop,
@@ -174,7 +174,7 @@ struct usbd_pipe_methods xhci_root_ctrl_methods = {
.done = xhci_noop,
};
-struct usbd_pipe_methods xhci_root_intr_methods = {
+const struct usbd_pipe_methods xhci_root_intr_methods = {
.transfer = xhci_root_intr_transfer,
.start = xhci_root_intr_start,
.abort = xhci_root_intr_abort,
@@ -182,7 +182,7 @@ struct usbd_pipe_methods xhci_root_intr_methods = {
.done = xhci_root_intr_done,
};
-struct usbd_pipe_methods xhci_device_ctrl_methods = {
+const struct usbd_pipe_methods xhci_device_ctrl_methods = {
.transfer = xhci_device_ctrl_transfer,
.start = xhci_device_ctrl_start,
.abort = xhci_device_ctrl_abort,
@@ -190,7 +190,7 @@ struct usbd_pipe_methods xhci_device_ctrl_methods = {
.done = xhci_noop,
};
-struct usbd_pipe_methods xhci_device_intr_methods = {
+const struct usbd_pipe_methods xhci_device_intr_methods = {
.transfer = xhci_device_generic_transfer,
.start = xhci_device_generic_start,
.abort = xhci_device_generic_abort,
@@ -198,7 +198,7 @@ struct usbd_pipe_methods xhci_device_intr_methods = {
.done = xhci_device_generic_done,
};
-struct usbd_pipe_methods xhci_device_bulk_methods = {
+const struct usbd_pipe_methods xhci_device_bulk_methods = {
.transfer = xhci_device_generic_transfer,
.start = xhci_device_generic_start,
.abort = xhci_device_generic_abort,
@@ -206,7 +206,7 @@ struct usbd_pipe_methods xhci_device_bulk_methods = {
.done = xhci_device_generic_done,
};
-struct usbd_pipe_methods xhci_device_isoc_methods = {
+const struct usbd_pipe_methods xhci_device_isoc_methods = {
.transfer = xhci_device_isoc_transfer,
.start = xhci_device_isoc_start,
.abort = xhci_device_generic_abort,
@@ -2165,7 +2165,7 @@ xhci_softdev_free(struct xhci_softc *sc, uint8_t slot)
}
/* Root hub descriptors. */
-usb_device_descriptor_t xhci_devd = {
+const usb_device_descriptor_t xhci_devd = {
USB_DEVICE_DESCRIPTOR_SIZE,
UDESC_DEVICE, /* type */
{0x00, 0x03}, /* USB version */
@@ -2348,6 +2348,7 @@ xhci_root_ctrl_start(struct usbd_xfer *xfer)
usb_port_status_t ps;
usb_device_request_t *req;
void *buf = NULL;
+ usb_device_descriptor_t devd;
usb_hub_descriptor_t hubd;
usbd_status err;
int s, len, value, index;
@@ -2396,9 +2397,10 @@ xhci_root_ctrl_start(struct usbd_xfer *xfer)
err = USBD_IOERROR;
goto ret;
}
+ devd = xhci_devd;
+ USETW(devd.idVendor, sc->sc_id_vendor);
totlen = l = min(len, USB_DEVICE_DESCRIPTOR_SIZE);
- USETW(xhci_devd.idVendor, sc->sc_id_vendor);
- memcpy(buf, &xhci_devd, l);
+ memcpy(buf, &devd, l);
break;
/*
* We can't really operate at another speed, but the spec says