Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev Random style in ehci, also KM_SLEEP does not fail.



details:   https://anonhg.NetBSD.org/src/rev/465504d0baa1
branches:  trunk
changeset: 842041:465504d0baa1
user:      maxv <maxv%NetBSD.org@localhost>
date:      Thu Jun 13 17:20:25 2019 +0000

description:
Random style in ehci, also KM_SLEEP does not fail.

diffstat:

 sys/dev/pci/ehci_pci.c |  44 +++++++++++++++++++-------------------------
 sys/dev/usb/ehci.c     |  38 ++++++++++++++------------------------
 2 files changed, 33 insertions(+), 49 deletions(-)

diffs (278 lines):

diff -r aefee7fd58ec -r 465504d0baa1 sys/dev/pci/ehci_pci.c
--- a/sys/dev/pci/ehci_pci.c    Thu Jun 13 15:10:27 2019 +0000
+++ b/sys/dev/pci/ehci_pci.c    Thu Jun 13 17:20:25 2019 +0000
@@ -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 @@
            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 @@
        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 @@
        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;
+       struct usb_pci *up;
+       int ncomp, quirk;
        pcireg_t csr;
-       int ncomp;
-       struct usb_pci *up;
-       int quirk;
-       char intrbuf[PCI_INTRSTR_LEN];
 
        sc->sc.sc_dev = self;
        sc->sc.sc_bus.ub_hcpriv = sc;
@@ -131,11 +127,11 @@
 
        /* 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 @@
        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 @@
        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 @@
        }
 
        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 @@
                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 @@
        /* 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 @@
        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;
diff -r aefee7fd58ec -r 465504d0baa1 sys/dev/usb/ehci.c
--- a/sys/dev/usb/ehci.c        Thu Jun 13 15:10:27 2019 +0000
+++ b/sys/dev/usb/ehci.c        Thu Jun 13 17:20:25 2019 +0000
@@ -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 @@
 #include <dev/usb/ehcivar.h>
 #include <dev/usb/usbroothub.h>
 
-
 #ifdef USB_DEBUG
 #ifndef EHCI_DEBUG
 #define ehcidebug 0
@@ -437,10 +436,10 @@
        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 @@
        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_idone(ex, cq);
 }
 
-
 Static void
 ehci_idone(struct ehci_xfer *ex, ex_completeq_t *cq)
 {
@@ -1338,11 +1334,11 @@
 
        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 @@
        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 @@
        return rv;
 }
 
-
 int
 ehci_activate(device_t self, enum devact act)
 {
@@ -4059,7 +4053,6 @@
        return USBD_NORMAL_COMPLETION;
 }
 
-
 Static int
 ehci_device_intr_init(struct usbd_xfer *xfer)
 {
@@ -4378,7 +4371,6 @@
        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 @@
            BUS_DMASYNC_POSTWRITE | BUS_DMASYNC_POSTREAD);
 }
 
-
-/************************/
-
+/* -------------------------------------------------------------------------- */
 
 Static int
 ehci_device_isoc_init(struct usbd_xfer *xfer)



Home | Main Index | Thread Index | Old Index