Module Name: src Committed By: maxv Date: Thu Jun 13 17:20:25 UTC 2019
Modified Files: src/sys/dev/pci: ehci_pci.c src/sys/dev/usb: ehci.c Log Message: Random style in ehci, also KM_SLEEP does not fail. To generate a diff of this commit: cvs rdiff -u -r1.68 -r1.69 src/sys/dev/pci/ehci_pci.c cvs rdiff -u -r1.266 -r1.267 src/sys/dev/usb/ehci.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/pci/ehci_pci.c diff -u src/sys/dev/pci/ehci_pci.c:1.68 src/sys/dev/pci/ehci_pci.c:1.69 --- src/sys/dev/pci/ehci_pci.c:1.68 Thu Oct 25 21:07:58 2018 +++ src/sys/dev/pci/ehci_pci.c Thu Jun 13 17:20:25 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: ehci_pci.c,v 1.68 2018/10/25 21:07:58 jdolecek Exp $ */ +/* $NetBSD: ehci_pci.c,v 1.69 2019/06/13 17:20:25 maxv Exp $ */ /* * Copyright (c) 2001, 2002 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ehci_pci.c,v 1.68 2018/10/25 21:07:58 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ehci_pci.c,v 1.69 2019/06/13 17:20:25 maxv Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -72,10 +72,8 @@ static const struct pci_quirkdata ehci_p EHCI_PCI_QUIRK_AMD_SB700 }, }; -static void ehci_release_ownership(ehci_softc_t *sc, pci_chipset_tag_t pc, - pcitag_t tag); -static void ehci_get_ownership(ehci_softc_t *sc, pci_chipset_tag_t pc, - pcitag_t tag); +static void ehci_release_ownership(ehci_softc_t *, pci_chipset_tag_t, pcitag_t); +static void ehci_get_ownership(ehci_softc_t *, pci_chipset_tag_t, pcitag_t); static bool ehci_pci_suspend(device_t, const pmf_qual_t *); static bool ehci_pci_resume(device_t, const pmf_qual_t *); @@ -87,16 +85,15 @@ struct ehci_pci_softc { void *sc_ih; /* interrupt vectoring */ }; -static int ehci_sb700_match(const struct pci_attach_args *pa); -static int ehci_apply_amd_quirks(struct ehci_pci_softc *sc); -enum ehci_pci_quirk_flags ehci_pci_lookup_quirkdata(pci_vendor_id_t, - pci_product_id_t); +static int ehci_sb700_match(const struct pci_attach_args *); +static int ehci_apply_amd_quirks(struct ehci_pci_softc *); +static enum ehci_pci_quirk_flags ehci_pci_lookup_quirkdata(pci_vendor_id_t, + pci_product_id_t); #define EHCI_MAX_BIOS_WAIT 100 /* ms*10 */ #define EHCI_SBx00_WORKAROUND_REG 0x50 #define EHCI_SBx00_WORKAROUND_ENABLE __BIT(27) - static int ehci_pci_match(device_t parent, cfdata_t match, void *aux) { @@ -117,12 +114,11 @@ ehci_pci_attach(device_t parent, device_ struct pci_attach_args *pa = (struct pci_attach_args *)aux; pci_chipset_tag_t pc = pa->pa_pc; pcitag_t tag = pa->pa_tag; + char intrbuf[PCI_INTRSTR_LEN]; char const *intrstr; - pcireg_t csr; - int ncomp; struct usb_pci *up; - int quirk; - char intrbuf[PCI_INTRSTR_LEN]; + int ncomp, quirk; + pcireg_t csr; sc->sc.sc_dev = self; sc->sc.sc_bus.ub_hcpriv = sc; @@ -131,11 +127,11 @@ ehci_pci_attach(device_t parent, device_ /* Check for quirks */ quirk = ehci_pci_lookup_quirkdata(PCI_VENDOR(pa->pa_id), - PCI_PRODUCT(pa->pa_id)); + PCI_PRODUCT(pa->pa_id)); /* Map I/O registers */ if (pci_mapreg_map(pa, PCI_CBMEM, PCI_MAPREG_TYPE_MEM, 0, - &sc->sc.iot, &sc->sc.ioh, NULL, &sc->sc.sc_size)) { + &sc->sc.iot, &sc->sc.ioh, NULL, &sc->sc.sc_size)) { sc->sc.sc_size = 0; aprint_error_dev(self, "can't map memory space\n"); return; @@ -199,7 +195,7 @@ ehci_pci_attach(device_t parent, device_ case PCI_USBREV_1_0: case PCI_USBREV_1_1: sc->sc.sc_bus.ub_revision = USBREV_UNKNOWN; - aprint_verbose_dev(self, "pre-2.0 USB rev\n"); + aprint_verbose_dev(self, "pre-2.0 USB rev, device ignored\n"); goto fail; case PCI_USBREV_2_0: sc->sc.sc_bus.ub_revision = USBREV_2_0; @@ -228,10 +224,10 @@ ehci_pci_attach(device_t parent, device_ KASSERT(maxncomp <= EHCI_COMPANION_MAX); ncomp = 0; TAILQ_FOREACH(up, &ehci_pci_alldevs, next) { - if (up->bus == pa->pa_bus && up->device == pa->pa_device - && !up->claimed) { + if (up->bus == pa->pa_bus && up->device == pa->pa_device && + !up->claimed) { DPRINTF(("ehci_pci_attach: companion %s\n", - device_xname(up->usb))); + device_xname(up->usb))); sc->sc.sc_comps[ncomp++] = up->usb; up->claimed = true; if (ncomp == maxncomp) @@ -249,7 +245,7 @@ ehci_pci_attach(device_t parent, device_ } if (!pmf_device_register1(self, ehci_pci_suspend, ehci_pci_resume, - ehci_shutdown)) + ehci_shutdown)) aprint_error_dev(self, "couldn't establish power handler\n"); /* Attach usb device. */ @@ -266,7 +262,6 @@ fail: bus_space_unmap(sc->sc.iot, sc->sc.ioh, sc->sc.sc_size); sc->sc.sc_size = 0; } - return; } static int @@ -307,7 +302,6 @@ ehci_pci_detach(device_t self, int flags /* XXX created in ehci.c */ mutex_destroy(&sc->sc.sc_lock); mutex_destroy(&sc->sc.sc_intr_lock); - softint_disestablish(sc->sc.sc_doorbell_si); softint_disestablish(sc->sc.sc_pcd_si); #endif @@ -482,7 +476,7 @@ ehci_apply_amd_quirks(struct ehci_pci_so return 0; } -enum ehci_pci_quirk_flags +static enum ehci_pci_quirk_flags ehci_pci_lookup_quirkdata(pci_vendor_id_t vendor, pci_product_id_t product) { int i; Index: src/sys/dev/usb/ehci.c diff -u src/sys/dev/usb/ehci.c:1.266 src/sys/dev/usb/ehci.c:1.267 --- src/sys/dev/usb/ehci.c:1.266 Sun Feb 17 04:17:52 2019 +++ src/sys/dev/usb/ehci.c Thu Jun 13 17:20:25 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: ehci.c,v 1.266 2019/02/17 04:17:52 rin Exp $ */ +/* $NetBSD: ehci.c,v 1.267 2019/06/13 17:20:25 maxv Exp $ */ /* * Copyright (c) 2004-2012 The NetBSD Foundation, Inc. @@ -53,7 +53,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.266 2019/02/17 04:17:52 rin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.267 2019/06/13 17:20:25 maxv Exp $"); #include "ohci.h" #include "uhci.h" @@ -90,7 +90,6 @@ __KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.2 #include <dev/usb/ehcivar.h> #include <dev/usb/usbroothub.h> - #ifdef USB_DEBUG #ifndef EHCI_DEBUG #define ehcidebug 0 @@ -437,10 +436,10 @@ ehci_init(ehci_softc_t *sc) ncomp = EHCI_HCS_N_CC(sparams); if (ncomp != sc->sc_ncomp) { aprint_verbose("%s: wrong number of companions (%d != %d)\n", - device_xname(sc->sc_dev), ncomp, sc->sc_ncomp); + device_xname(sc->sc_dev), ncomp, sc->sc_ncomp); #if NOHCI == 0 || NUHCI == 0 aprint_error("%s: ohci or uhci probably not configured\n", - device_xname(sc->sc_dev)); + device_xname(sc->sc_dev)); #endif if (ncomp < sc->sc_ncomp) sc->sc_ncomp = ncomp; @@ -530,16 +529,14 @@ ehci_init(ehci_softc_t *sc) EOWRITE4(sc, EHCI_PERIODICLISTBASE, DMAADDR(&sc->sc_fldma, 0)); sc->sc_softitds = kmem_zalloc(sc->sc_flsize * sizeof(ehci_soft_itd_t *), - KM_SLEEP); - if (sc->sc_softitds == NULL) - return ENOMEM; + KM_SLEEP); LIST_INIT(&sc->sc_freeitds); LIST_INIT(&sc->sc_freesitds); TAILQ_INIT(&sc->sc_intrhead); /* Set up the bus struct. */ sc->sc_bus.ub_methods = &ehci_bus_methods; - sc->sc_bus.ub_pipesize= sizeof(struct ehci_pipe); + sc->sc_bus.ub_pipesize = sizeof(struct ehci_pipe); sc->sc_eintrs = EHCI_NORMAL_INTRS; @@ -1033,7 +1030,6 @@ ehci_check_sitd_intr(ehci_softc_t *sc, s ehci_idone(ex, cq); } - Static void ehci_idone(struct ehci_xfer *ex, ex_completeq_t *cq) { @@ -1338,11 +1334,11 @@ ehci_detach(struct ehci_softc *sc, int f EHCIHIST_FUNC(); EHCIHIST_CALLED(); - if (sc->sc_child != NULL) + if (sc->sc_child != NULL) { rv = config_detach(sc->sc_child, flags); - - if (rv != 0) - return rv; + if (rv != 0) + return rv; + } if (sc->sc_ncomp > 0) { mutex_enter(&sc->sc_complock); @@ -1360,18 +1356,17 @@ ehci_detach(struct ehci_softc *sc, int f callout_halt(&sc->sc_tmo_intrlist, NULL); callout_destroy(&sc->sc_tmo_intrlist); - /* XXX free other data structures XXX */ - if (sc->sc_softitds) + /* XXX free other data structures */ + if (sc->sc_softitds) { kmem_free(sc->sc_softitds, sc->sc_flsize * sizeof(ehci_soft_itd_t *)); + } cv_destroy(&sc->sc_doorbell); #if 0 /* XXX destroyed in ehci_pci.c as it controls ehci_intr access */ - softint_disestablish(sc->sc_doorbell_si); softint_disestablish(sc->sc_pcd_si); - mutex_destroy(&sc->sc_lock); mutex_destroy(&sc->sc_intr_lock); #endif @@ -1383,7 +1378,6 @@ ehci_detach(struct ehci_softc *sc, int f return rv; } - int ehci_activate(device_t self, enum devact act) { @@ -4059,7 +4053,6 @@ ehci_device_setintr(ehci_softc_t *sc, eh return USBD_NORMAL_COMPLETION; } - Static int ehci_device_intr_init(struct usbd_xfer *xfer) { @@ -4378,7 +4371,6 @@ ehci_device_fs_isoc_transfer(struct usbd sitd = NULL; total_length = 0; - DPRINTF("xfer %#jx len %jd flags %jd", (uintptr_t)xfer, xfer->ux_length, xfer->ux_flags, 0); @@ -4613,9 +4605,7 @@ ehci_device_fs_isoc_done(struct usbd_xfe BUS_DMASYNC_POSTWRITE | BUS_DMASYNC_POSTREAD); } - -/************************/ - +/* -------------------------------------------------------------------------- */ Static int ehci_device_isoc_init(struct usbd_xfer *xfer)