Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/jmcneill-usbmp]: src/sys/dev/usb - convert usbd_bus_methods{} and usbd_p...
details: https://anonhg.NetBSD.org/src/rev/77b118da4970
branches: jmcneill-usbmp
changeset: 771785:77b118da4970
user: mrg <mrg%NetBSD.org@localhost>
date: Thu Dec 08 02:51:07 2011 +0000
description:
- convert usbd_bus_methods{} and usbd_pipe_methods{} to use
c99 struct initialisers
- move the locks from the pipe to the bus, since we'll need
access to them from bus-level ops
- remove dead-for-years SPLUSBCHECK and replaced it with
asserts that the thread lock is held
- begin to document the locking scheme
- convert usbd_*lock_pipe() into real function-like macros
diffstat:
sys/dev/usb/ehci.c | 109 +++++++++++++++++++++++----------------------
sys/dev/usb/ohci.c | 117 +++++++++++++++++++++++++-----------------------
sys/dev/usb/uhci.c | 104 +++++++++++++++++++++---------------------
sys/dev/usb/usb.c | 11 +++-
sys/dev/usb/usb_subr.c | 9 +--
sys/dev/usb/usbdi.c | 58 ++++++++++++-----------
sys/dev/usb/usbdivar.h | 73 ++++++++++++++++++++++--------
7 files changed, 262 insertions(+), 219 deletions(-)
diffs (truncated from 928 to 300 lines):
diff -r 43e5aa09f9b2 -r 77b118da4970 sys/dev/usb/ehci.c
--- a/sys/dev/usb/ehci.c Wed Dec 07 22:52:17 2011 +0000
+++ b/sys/dev/usb/ehci.c Thu Dec 08 02:51:07 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ehci.c,v 1.181.6.3 2011/12/06 02:10:01 mrg Exp $ */
+/* $NetBSD: ehci.c,v 1.181.6.4 2011/12/08 02:51:07 mrg Exp $ */
/*
* Copyright (c) 2004-2011 The NetBSD Foundation, Inc.
@@ -53,7 +53,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.181.6.3 2011/12/06 02:10:01 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.181.6.4 2011/12/08 02:51:07 mrg Exp $");
#include "ohci.h"
#include "uhci.h"
@@ -220,7 +220,8 @@
Static usbd_status ehci_device_setintr(ehci_softc_t *, ehci_soft_qh_t *,
int ival);
-Static void ehci_add_qh(ehci_soft_qh_t *, ehci_soft_qh_t *);
+Static void ehci_add_qh(ehci_softc_t *, ehci_soft_qh_t *,
+ ehci_soft_qh_t *);
Static void ehci_rem_qh(ehci_softc_t *, ehci_soft_qh_t *,
ehci_soft_qh_t *);
Static void ehci_set_qh_qtd(ehci_soft_qh_t *, ehci_soft_qtd_t *);
@@ -261,68 +262,68 @@
#define ehci_active_intr_list(ex) ((ex)->inext.tqe_prev != NULL)
Static const struct usbd_bus_methods ehci_bus_methods = {
- ehci_open,
- ehci_softintr,
- ehci_poll,
- ehci_allocm,
- ehci_freem,
- ehci_allocx,
- ehci_freex,
- ehci_get_locks,
+ .open_pipe = ehci_open,
+ .soft_intr = ehci_softintr,
+ .do_poll = ehci_poll,
+ .allocm = ehci_allocm,
+ .freem = ehci_freem,
+ .allocx = ehci_allocx,
+ .freex = ehci_freex,
+ .get_locks = ehci_get_locks,
};
Static const struct usbd_pipe_methods ehci_root_ctrl_methods = {
- ehci_root_ctrl_transfer,
- ehci_root_ctrl_start,
- ehci_root_ctrl_abort,
- ehci_root_ctrl_close,
- ehci_noop,
- ehci_root_ctrl_done,
+ .transfer = ehci_root_ctrl_transfer,
+ .start = ehci_root_ctrl_start,
+ .abort = ehci_root_ctrl_abort,
+ .close = ehci_root_ctrl_close,
+ .cleartoggle = ehci_noop,
+ .done = ehci_root_ctrl_done,
};
Static const struct usbd_pipe_methods ehci_root_intr_methods = {
- ehci_root_intr_transfer,
- ehci_root_intr_start,
- ehci_root_intr_abort,
- ehci_root_intr_close,
- ehci_noop,
- ehci_root_intr_done,
+ .transfer = ehci_root_intr_transfer,
+ .start = ehci_root_intr_start,
+ .abort = ehci_root_intr_abort,
+ .close = ehci_root_intr_close,
+ .cleartoggle = ehci_noop,
+ .done = ehci_root_intr_done,
};
Static const struct usbd_pipe_methods ehci_device_ctrl_methods = {
- ehci_device_ctrl_transfer,
- ehci_device_ctrl_start,
- ehci_device_ctrl_abort,
- ehci_device_ctrl_close,
- ehci_noop,
- ehci_device_ctrl_done,
+ .transfer = ehci_device_ctrl_transfer,
+ .start = ehci_device_ctrl_start,
+ .abort = ehci_device_ctrl_abort,
+ .close = ehci_device_ctrl_close,
+ .cleartoggle = ehci_noop,
+ .done = ehci_device_ctrl_done,
};
Static const struct usbd_pipe_methods ehci_device_intr_methods = {
- ehci_device_intr_transfer,
- ehci_device_intr_start,
- ehci_device_intr_abort,
- ehci_device_intr_close,
- ehci_device_clear_toggle,
- ehci_device_intr_done,
+ .transfer = ehci_device_intr_transfer,
+ .start = ehci_device_intr_start,
+ .abort = ehci_device_intr_abort,
+ .close = ehci_device_intr_close,
+ .cleartoggle = ehci_device_clear_toggle,
+ .done = ehci_device_intr_done,
};
Static const struct usbd_pipe_methods ehci_device_bulk_methods = {
- ehci_device_bulk_transfer,
- ehci_device_bulk_start,
- ehci_device_bulk_abort,
- ehci_device_bulk_close,
- ehci_device_clear_toggle,
- ehci_device_bulk_done,
+ .transfer = ehci_device_bulk_transfer,
+ .start = ehci_device_bulk_start,
+ .abort = ehci_device_bulk_abort,
+ .close = ehci_device_bulk_close,
+ .cleartoggle = ehci_device_clear_toggle,
+ .done = ehci_device_bulk_done,
};
Static const struct usbd_pipe_methods ehci_device_isoc_methods = {
- ehci_device_isoc_transfer,
- ehci_device_isoc_start,
- ehci_device_isoc_abort,
- ehci_device_isoc_close,
- ehci_noop,
- ehci_device_isoc_done,
+ .transfer = ehci_device_isoc_transfer,
+ .start = ehci_device_isoc_start,
+ .abort = ehci_device_isoc_abort,
+ .close = ehci_device_isoc_close,
+ .cleartoggle = ehci_noop,
+ .done = ehci_device_isoc_done,
};
static const uint8_t revbits[EHCI_MAX_POLLRATE] = {
@@ -1753,13 +1754,13 @@
goto bad;
pipe->methods = &ehci_device_ctrl_methods;
mutex_enter(&sc->sc_lock);
- ehci_add_qh(sqh, sc->sc_async_head);
+ ehci_add_qh(sc, sqh, sc->sc_async_head);
mutex_exit(&sc->sc_lock);
break;
case UE_BULK:
pipe->methods = &ehci_device_bulk_methods;
mutex_enter(&sc->sc_lock);
- ehci_add_qh(sqh, sc->sc_async_head);
+ ehci_add_qh(sc, sqh, sc->sc_async_head);
mutex_exit(&sc->sc_lock);
break;
case UE_INTERRUPT:
@@ -1815,9 +1816,10 @@
* Add an ED to the schedule. Called at splusb().
*/
Static void
-ehci_add_qh(ehci_soft_qh_t *sqh, ehci_soft_qh_t *head)
+ehci_add_qh(ehci_softc_t *sc, ehci_soft_qh_t *sqh, ehci_soft_qh_t *head)
{
- SPLUSBCHECK;
+
+ KASSERT(mutex_owned(&sc->sc_lock));
usb_syncmem(&head->dma, head->offs + offsetof(ehci_qh_t, qh_link),
sizeof(head->qh.qh_link), BUS_DMASYNC_POSTWRITE);
@@ -1846,7 +1848,8 @@
{
ehci_soft_qh_t *p;
- SPLUSBCHECK;
+ KASSERT(mutex_owned(&sc->sc_lock));
+
/* XXX */
for (p = head; p != NULL && p->next != sqh; p = p->next)
;
@@ -3711,7 +3714,7 @@
sqh->islot = islot;
isp = &sc->sc_islots[islot];
- ehci_add_qh(sqh, isp->sqh);
+ ehci_add_qh(sc, sqh, isp->sqh);
return (USBD_NORMAL_COMPLETION);
}
diff -r 43e5aa09f9b2 -r 77b118da4970 sys/dev/usb/ohci.c
--- a/sys/dev/usb/ohci.c Wed Dec 07 22:52:17 2011 +0000
+++ b/sys/dev/usb/ohci.c Thu Dec 08 02:51:07 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ohci.c,v 1.218.6.5 2011/12/07 05:41:53 macallan Exp $ */
+/* $NetBSD: ohci.c,v 1.218.6.6 2011/12/08 02:51:07 mrg Exp $ */
/* $FreeBSD: src/sys/dev/usb/ohci.c,v 1.22 1999/11/17 22:33:40 n_hibma Exp $ */
/*
@@ -42,7 +42,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.218.6.5 2011/12/07 05:41:53 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.218.6.6 2011/12/08 02:51:07 mrg Exp $");
#include "opt_usb.h"
@@ -120,7 +120,8 @@
Static void ohci_add_ed(ohci_softc_t *, ohci_soft_ed_t *,
ohci_soft_ed_t *);
-Static void ohci_rem_ed(ohci_soft_ed_t *, ohci_soft_ed_t *);
+Static void ohci_rem_ed(ohci_softc_t *, ohci_soft_ed_t *,
+ ohci_soft_ed_t *);
Static void ohci_hash_add_td(ohci_softc_t *, ohci_soft_td_t *);
Static void ohci_hash_rem_td(ohci_softc_t *, ohci_soft_td_t *);
Static ohci_soft_td_t *ohci_hash_find_td(ohci_softc_t *, ohci_physaddr_t);
@@ -271,68 +272,68 @@
#define OHCI_INTR_ENDPT 1
Static const struct usbd_bus_methods ohci_bus_methods = {
- ohci_open,
- ohci_softintr,
- ohci_poll,
- ohci_allocm,
- ohci_freem,
- ohci_allocx,
- ohci_freex,
- ohci_get_locks,
+ .open_pipe = ohci_open,
+ .soft_intr = ohci_softintr,
+ .do_poll = ohci_poll,
+ .allocm = ohci_allocm,
+ .freem = ohci_freem,
+ .allocx = ohci_allocx,
+ .freex = ohci_freex,
+ .get_locks = ohci_get_locks,
};
Static const struct usbd_pipe_methods ohci_root_ctrl_methods = {
- ohci_root_ctrl_transfer,
- ohci_root_ctrl_start,
- ohci_root_ctrl_abort,
- ohci_root_ctrl_close,
- ohci_noop,
- ohci_root_ctrl_done,
+ .transfer = ohci_root_ctrl_transfer,
+ .start = ohci_root_ctrl_start,
+ .abort = ohci_root_ctrl_abort,
+ .close = ohci_root_ctrl_close,
+ .cleartoggle = ohci_noop,
+ .done = ohci_root_ctrl_done,
};
Static const struct usbd_pipe_methods ohci_root_intr_methods = {
- ohci_root_intr_transfer,
- ohci_root_intr_start,
- ohci_root_intr_abort,
- ohci_root_intr_close,
- ohci_noop,
- ohci_root_intr_done,
+ .transfer = ohci_root_intr_transfer,
+ .start = ohci_root_intr_start,
+ .abort = ohci_root_intr_abort,
+ .close = ohci_root_intr_close,
+ .cleartoggle = ohci_noop,
+ .done = ohci_root_intr_done,
};
Static const struct usbd_pipe_methods ohci_device_ctrl_methods = {
- ohci_device_ctrl_transfer,
- ohci_device_ctrl_start,
- ohci_device_ctrl_abort,
- ohci_device_ctrl_close,
- ohci_noop,
- ohci_device_ctrl_done,
+ .transfer = ohci_device_ctrl_transfer,
+ .start = ohci_device_ctrl_start,
+ .abort = ohci_device_ctrl_abort,
+ .close = ohci_device_ctrl_close,
+ .cleartoggle = ohci_noop,
+ .done = ohci_device_ctrl_done,
};
Static const struct usbd_pipe_methods ohci_device_intr_methods = {
- ohci_device_intr_transfer,
- ohci_device_intr_start,
- ohci_device_intr_abort,
- ohci_device_intr_close,
- ohci_device_clear_toggle,
- ohci_device_intr_done,
+ .transfer = ohci_device_intr_transfer,
+ .start = ohci_device_intr_start,
+ .abort = ohci_device_intr_abort,
+ .close = ohci_device_intr_close,
+ .cleartoggle = ohci_device_clear_toggle,
+ .done = ohci_device_intr_done,
};
Static const struct usbd_pipe_methods ohci_device_bulk_methods = {
Home |
Main Index |
Thread Index |
Old Index