bus: Pass intsrerupt description to setup_intr bus method
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Thu, 19 Jan 2012 07:49:17 +0000 (15:49 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Thu, 19 Jan 2012 07:49:17 +0000 (15:49 +0800)
If no interrupt description is supplied, then the device's name
will be used.

Add bus_setup_intr_descr(), which allow device drivers to pass
interrupt description.  Reimplement bus_setup_intr() using
bus_setup_intr_descr().

28 files changed:
sys/bus/iicbus/pcf/pcf.c
sys/bus/isa/i386/isa.c
sys/bus/isa/i386/isa_compat.c
sys/bus/isa/x86_64/isa.c
sys/bus/pccard/pccard.c
sys/bus/pci/pci.c
sys/bus/pci/pci_compat.c
sys/bus/pci/pci_private.h
sys/bus/ppbus/ppbconf.c
sys/dev/disk/nata/ata-pci.c
sys/dev/misc/atkbd/atkbd_isa.c
sys/dev/misc/lpt/lpt.c
sys/dev/misc/ppc/ppc.c
sys/dev/misc/ppi/ppi.c
sys/dev/misc/pps/pps.c
sys/dev/misc/psm/psm.c
sys/dev/netif/ar/if_ar.c
sys/dev/netif/plip/if_plip.c
sys/dev/netif/sr/if_sr.c
sys/dev/pccard/pccbb/pccbb.c
sys/dev/pccard/pccbb/pccbbvar.h
sys/dev/serial/sio/sio.c
sys/kern/bus_if.m
sys/kern/subr_bus.c
sys/platform/pc32/i386/nexus.c
sys/platform/pc32/isa/npx.c
sys/platform/pc64/x86_64/nexus.c
sys/sys/bus.h

index 6c0524c..03f8b70 100644 (file)
@@ -192,7 +192,7 @@ pcf_attach(device_t pcfdev)
                /* default to the tty mask for registration */  /* XXX */
                error = BUS_SETUP_INTR(parent, pcfdev, pcf->res_irq,
                                        0, pcfintr, pcfdev,
-                                       &pcf->intr_cookie, NULL);
+                                       &pcf->intr_cookie, NULL, NULL);
                if (error)
                        return (error);
        }
index 326acf4..ab5a4c5 100644 (file)
@@ -156,7 +156,7 @@ isa_setup_intr(device_t bus, device_t child, struct resource *r, int flags,
               void **cookiep, lwkt_serialize_t serializer)
 {
        return (BUS_SETUP_INTR(device_get_parent(bus), child, r, flags,
-                              ihand, arg, cookiep, serializer));
+                              ihand, arg, cookiep, serializer, NULL));
 }
 
 int
index 3055542..11086e6 100644 (file)
@@ -260,7 +260,7 @@ isa_compat_attach(device_t dev)
                                       res.irq, op->type,
                                       dvp->id_intr,
                                       (void *)(uintptr_t)dvp->id_unit,
-                                      &ih, NULL);
+                                      &ih, NULL, NULL);
                if (error)
                        kprintf("isa_compat_attach: failed to setup intr: %d\n",
                               error);
index 12f1441..4e38377 100644 (file)
@@ -150,7 +150,7 @@ isa_setup_intr(device_t bus, device_t child, struct resource *r, int flags,
               void **cookiep, lwkt_serialize_t serializer)
 {
        return (BUS_SETUP_INTR(device_get_parent(bus), child, r, flags,
-                              ihand, arg, cookiep, serializer));
+                              ihand, arg, cookiep, serializer, NULL));
 }
 
 int
index 2c21936..d8491a6 100644 (file)
@@ -120,7 +120,8 @@ static void pccard_child_detached(device_t parent, device_t dev);
 static void    pccard_intr(void *arg);
 static int     pccard_setup_intr(device_t dev, device_t child,
                    struct resource *irq, int flags, driver_intr_t *intr,
-                   void *arg, void **cookiep, lwkt_serialize_t serializer);
+                   void *arg, void **cookiep, lwkt_serialize_t serializer,
+                   const char *desc);
 static int     pccard_teardown_intr(device_t dev, device_t child,
                    struct resource *r, void *cookie);
 
@@ -1233,7 +1234,7 @@ pccard_intr(void *arg)
 static int
 pccard_setup_intr(device_t dev, device_t child, struct resource *irq,
     int flags, driver_intr_t *intr, void *arg,
-    void **cookiep, lwkt_serialize_t serializer)
+    void **cookiep, lwkt_serialize_t serializer, const char *desc)
 {
        struct pccard_softc *sc = PCCARD_SOFTC(dev);
        struct pccard_ivar *ivar = PCCARD_IVAR(child);
@@ -1243,7 +1244,7 @@ pccard_setup_intr(device_t dev, device_t child, struct resource *irq,
        if (pf->intr_handler != NULL)
                panic("Only one interrupt handler per function allowed");
        err = bus_generic_setup_intr(dev, child, irq, flags, pccard_intr,
-                                    pf, cookiep, serializer);
+                                    pf, cookiep, serializer, desc);
        if (err != 0)
                return (err);
        pf->intr_handler = intr;
index 063f169..62768d2 100644 (file)
@@ -2986,13 +2986,14 @@ pci_child_detached(device_t parent __unused, device_t child)
 
 int
 pci_setup_intr(device_t dev, device_t child, struct resource *irq, int flags,
-    driver_intr_t *intr, void *arg, void **cookiep, lwkt_serialize_t serializer)
+    driver_intr_t *intr, void *arg, void **cookiep,
+    lwkt_serialize_t serializer, const char *desc)
 {
        int rid, error;
        void *cookie;
 
        error = bus_generic_setup_intr(dev, child, irq, flags, intr,
-           arg, &cookie, serializer);
+           arg, &cookie, serializer, desc);
        if (error)
                return (error);
 
index 6cc24eb..ded00e2 100644 (file)
@@ -144,7 +144,8 @@ pci_map_int_right(pcici_t cfg, pci_inthand_t *handler, void *arg, u_int intflags
                 */
 
                error = BUS_SETUP_INTR(device_get_parent(cfg->dev), cfg->dev,
-                                      res, flags, handler, arg, &ih, NULL);
+                                      res, flags, handler, arg, &ih,
+                                      NULL, NULL);
                if (error != 0)
                        return 0;
 
index c229b6a..449d1e4 100644 (file)
@@ -52,7 +52,8 @@ int           pci_write_ivar(device_t dev, device_t child, int which,
                    uintptr_t value);
 int            pci_setup_intr(device_t dev, device_t child,
                    struct resource *irq, int flags,
-                   driver_intr_t *intr, void *arg, void **cookiep, lwkt_serialize_t serializer);
+                   driver_intr_t *intr, void *arg, void **cookiep,
+                   lwkt_serialize_t serializer, const char *desc);
 int            pci_teardown_intr(device_t dev, device_t child,
                    struct resource *irq, void *cookie);
 int            pci_get_vpd_ident_method(device_t dev, device_t child,
index cab1a02..b6b8991 100644 (file)
@@ -417,7 +417,7 @@ ppbus_setup_intr(device_t bus, device_t child, struct resource *r, int flags,
                return (EINVAL);
 
        if ((error = BUS_SETUP_INTR(device_get_parent(bus), child, r, flags,
-                                       ihand, arg, cookiep, serializer)))
+                                       ihand, arg, cookiep, serializer, NULL)))
                return (error);
 
        /* store the resource and the cookie for eventually forcing
index 5d21648..697c42a 100644 (file)
@@ -388,7 +388,7 @@ ata_pci_setup_intr(device_t dev, device_t child, struct resource *irq,
 
     if (controller->legacy) {
        return BUS_SETUP_INTR(device_get_parent(dev), child, irq,
-                             flags, function, argument, cookiep, NULL);
+                             flags, function, argument, cookiep, NULL, NULL);
     }
     else {
        struct ata_pci_controller *controller = device_get_softc(dev);
index baf9a6d..afede14 100644 (file)
@@ -119,7 +119,7 @@ atkbdattach(device_t dev)
        rid = 0;
        sc->intr = bus_alloc_legacy_irq_resource(dev, &rid, irq, RF_ACTIVE);
        BUS_SETUP_INTR(device_get_parent(dev), dev, sc->intr, INTR_MPSAFE,
-                      atkbd_isa_intr, kbd, &sc->ih, NULL);
+                      atkbd_isa_intr, kbd, &sc->ih, NULL, NULL);
 
        return 0;
 }
index 45168ca..4cba5df 100644 (file)
@@ -752,7 +752,7 @@ lptwrite(struct dev_write_args *ap)
                /* register our interrupt handler */
                err = BUS_SETUP_INTR(ppbus, lptdev, sc->intr_resource,
                               0, lpt_intr, lptdev,
-                              &sc->intr_cookie, NULL);
+                              &sc->intr_cookie, NULL, NULL);
                if (err) {
                        device_printf(lptdev, "handler registration failed, polled mode.\n");
                        sc->sc_irq &= ~LP_USE_IRQ;
index b81734f..0ac5fc0 100644 (file)
@@ -1990,7 +1990,7 @@ ppc_attach(device_t dev)
                /* default to the tty mask for registration */  /* XXX */
                if (BUS_SETUP_INTR(parent, dev, ppc->res_irq, 0,
                                   ppcintr, dev,
-                                  &ppc->intr_cookie, NULL) == 0) {
+                                  &ppc->intr_cookie, NULL, NULL) == 0) {
                        /* remember the ppcintr is registered */
                        ppc->ppc_registered = 1;
                }
@@ -2120,7 +2120,8 @@ ppc_setup_intr(device_t bus, device_t child, struct resource *r, int flags,
 
        /* pass registration to the upper layer, ignore the incoming resource */
        return (BUS_SETUP_INTR(device_get_parent(bus), child,
-                              r, flags, ihand, arg, cookiep, serializer));
+                              r, flags, ihand, arg, cookiep,
+                              serializer, NULL));
 }
 
 /*
@@ -2142,7 +2143,7 @@ ppc_teardown_intr(device_t bus, device_t child, struct resource *r, void *ih)
        if (ppc->ppc_irq &&
                !(error = BUS_SETUP_INTR(parent, bus, ppc->res_irq,
                                         0, ppcintr, bus,
-                                        &ppc->intr_cookie, NULL))
+                                        &ppc->intr_cookie, NULL, NULL))
        ) {
                /* remember the ppcintr is registered */
                ppc->ppc_registered = 1;
index df955dc..f1b5aa2 100644 (file)
@@ -266,7 +266,7 @@ ppiopen(struct dev_open_args *ap)
                        BUS_SETUP_INTR(device_get_parent(ppidev), ppidev,
                                       ppi->intr_resource, 0,
                                       ppiintr, dev, 
-                                      &ppi->intr_cookie, NULL);
+                                      &ppi->intr_cookie, NULL, NULL);
                }
 #endif /* PERIPH_1284 */
        }
index a9ee5ad..7233b3f 100644 (file)
@@ -122,7 +122,7 @@ ppsopen(struct dev_open_args *ap)
                /* attach the interrupt handler */
                if ((error = BUS_SETUP_INTR(ppbus, ppsdev, sc->intr_resource,
                               0, ppsintr, ppsdev,
-                              &sc->intr_cookie, NULL))) {
+                              &sc->intr_cookie, NULL, NULL))) {
                        ppb_release_bus(ppbus, ppsdev);
                        return (error);
                }
index 152349d..bc85b86 100644 (file)
@@ -1437,7 +1437,7 @@ psmattach(device_t dev)
        if (sc->intr == NULL)
                return (ENXIO);
        error = BUS_SETUP_INTR(device_get_parent(dev), dev, sc->intr,
-                       INTR_NOPOLL, psmintr, sc, &sc->ih, NULL);
+                       INTR_NOPOLL, psmintr, sc, &sc->ih, NULL, NULL);
        if (error) {
                bus_release_resource(dev, SYS_RES_IRQ, rid, sc->intr);
                return (error);
index 331acfb..eb52b7d 100644 (file)
@@ -270,7 +270,7 @@ ar_attach(device_t device)
 
        error = BUS_SETUP_INTR(device_get_parent(device), device, hc->res_irq,
                               0, arintr, hc,
-                              &hc->intr_cookie, &ar_serializer);
+                              &hc->intr_cookie, &ar_serializer, NULL);
        if (error)
                return (1);
 
index 085c17a..026e968 100644 (file)
@@ -334,7 +334,7 @@ lpioctl (struct ifnet *ifp, u_long cmd, caddr_t data, struct ucred *cr)
 
            /* attach our interrupt handler, later detached when the bus is released */
            error = BUS_SETUP_INTR(ppbus, dev, sc->res_irq, 0,
-                                  lp_intr, dev, &ih, NULL);
+                                  lp_intr, dev, &ih, NULL, NULL);
            if (error) {
                ppb_release_bus(ppbus, dev);
                return (error);
index 73f82dc..1999147 100644 (file)
@@ -394,7 +394,7 @@ sr_attach(device_t device)
 
        if (BUS_SETUP_INTR(device_get_parent(device), device, hc->res_irq,
                           0, srintr, hc,
-                          &hc->intr_cookie, NULL) != 0)
+                          &hc->intr_cookie, NULL, NULL) != 0)
                goto errexit;
 
        /*
index ab9eb72..14202fe 100644 (file)
@@ -346,7 +346,7 @@ cbb_shutdown(device_t brdev)
 int
 cbb_setup_intr(device_t dev, device_t child, struct resource *irq,
               int flags, driver_intr_t *intr, void *arg,
-              void **cookiep, lwkt_serialize_t serializer)
+              void **cookiep, lwkt_serialize_t serializer, const char *desc)
 {
        struct cbb_intrhand *ih;
        struct cbb_softc *sc = device_get_softc(dev);
@@ -365,7 +365,7 @@ cbb_setup_intr(device_t dev, device_t child, struct resource *irq,
         * XXX for now that's all we need to do.
         */
        err = BUS_SETUP_INTR(device_get_parent(dev), child, irq, flags,
-           cbb_func_intr, ih, &ih->cookie, NULL);
+           cbb_func_intr, ih, &ih->cookie, NULL, desc);
        if (err != 0) {
                kfree(ih, M_DEVBUF);
                return (err);
index b4a5446..ddc86ff 100644 (file)
@@ -144,7 +144,7 @@ int cbb_release_resource(device_t brdev, device_t child,
 int    cbb_resume(device_t self);
 int    cbb_setup_intr(device_t dev, device_t child, struct resource *irq,
            int flags, driver_intr_t *intr, void *arg, void **cookiep,
-           lwkt_serialize_t serializer);
+           lwkt_serialize_t serializer, const char *desc);
 int    cbb_shutdown(device_t brdev);
 int    cbb_suspend(device_t self);
 int    cbb_teardown_intr(device_t dev, device_t child, struct resource *irq,
index 250bdeb..5e205bd 100644 (file)
@@ -1218,7 +1218,7 @@ determined_type: ;
        if (com->irqres) {
                ret = BUS_SETUP_INTR(device_get_parent(dev), dev,
                                     com->irqres, INTR_MPSAFE, siointr, com,
-                                    &com->cookie, NULL);
+                                    &com->cookie, NULL, NULL);
                if (ret)
                        device_printf(dev, "could not activate interrupt\n");
 #if defined(DDB) && (defined(BREAK_TO_DEBUGGER) || \
index 1f92cf1..5042c09 100644 (file)
@@ -198,6 +198,7 @@ METHOD int setup_intr {
        void            *arg;
        void            **cookiep;
        lwkt_serialize_t serializer;
+       const char      *desc;
 };
 
 METHOD int teardown_intr {
index 60e0429..c9e1800 100644 (file)
@@ -2576,16 +2576,17 @@ bus_generic_driver_added(device_t dev, driver_t *driver)
 }
 
 int
-bus_generic_setup_intr(device_t dev, device_t child, struct resource *irq, 
-                      int flags, driver_intr_t *intr, void *arg,
-                      void **cookiep, lwkt_serialize_t serializer)
+bus_generic_setup_intr(device_t dev, device_t child, struct resource *irq,
+    int flags, driver_intr_t *intr, void *arg, void **cookiep,
+    lwkt_serialize_t serializer, const char *desc)
 {
        /* Propagate up the bus hierarchy until someone handles it. */
-       if (dev->parent)
-               return(BUS_SETUP_INTR(dev->parent, child, irq, flags,
-                                     intr, arg, cookiep, serializer));
-       else
-               return(EINVAL);
+       if (dev->parent) {
+               return BUS_SETUP_INTR(dev->parent, child, irq, flags,
+                   intr, arg, cookiep, serializer, desc);
+       } else {
+               return EINVAL;
+       }
 }
 
 int
@@ -2876,14 +2877,23 @@ bus_release_resource(device_t dev, int type, int rid, struct resource *r)
 }
 
 int
-bus_setup_intr(device_t dev, struct resource *r, int flags,
-              driver_intr_t handler, void *arg,
-              void **cookiep, lwkt_serialize_t serializer)
+bus_setup_intr_descr(device_t dev, struct resource *r, int flags,
+    driver_intr_t handler, void *arg, void **cookiep,
+    lwkt_serialize_t serializer, const char *desc)
 {
        if (dev->parent == 0)
-               return(EINVAL);
-       return(BUS_SETUP_INTR(dev->parent, dev, r, flags, handler, arg,
-                             cookiep, serializer));
+               return EINVAL;
+       return BUS_SETUP_INTR(dev->parent, dev, r, flags, handler, arg,
+           cookiep, serializer, desc);
+}
+
+int
+bus_setup_intr(device_t dev, struct resource *r, int flags,
+    driver_intr_t handler, void *arg, void **cookiep,
+    lwkt_serialize_t serializer)
+{
+       return bus_setup_intr_descr(dev, r, flags, handler, arg, cookiep,
+           serializer, NULL);
 }
 
 int
@@ -2998,7 +3008,7 @@ root_print_child(device_t dev, device_t child)
 
 static int
 root_setup_intr(device_t dev, device_t child, driver_intr_t *intr, void *arg,
-               void **cookiep, lwkt_serialize_t serializer)
+               void **cookiep, lwkt_serialize_t serializer, const char *desc)
 {
        /*
         * If an interrupt mapping gets to here something bad has happened.
index 829e045..f763ed8 100644 (file)
@@ -98,8 +98,8 @@ static        int nexus_release_resource(device_t, device_t, int, int,
 static int nexus_config_intr(device_t, device_t, int, enum intr_trigger,
                              enum intr_polarity);
 static int nexus_setup_intr(device_t, device_t, struct resource *, int flags,
-                            void (*)(void *), void *, 
-                            void **, lwkt_serialize_t);
+               void (*)(void *), void *, void **, lwkt_serialize_t,
+               const char *);
 static int nexus_teardown_intr(device_t, device_t, struct resource *,
                                void *);
 static int nexus_set_resource(device_t, device_t, int, int, u_long, u_long,
@@ -486,8 +486,8 @@ nexus_config_intr(device_t bus, device_t chile, int irq,
  */
 static int
 nexus_setup_intr(device_t bus, device_t child, struct resource *irq,
-                int flags, void (*ihand)(void *), void *arg,
-                void **cookiep, lwkt_serialize_t serializer)
+    int flags, void (*ihand)(void *), void *arg, void **cookiep,
+    lwkt_serialize_t serializer, const char *desc)
 {
        int     error, icflags;
 
@@ -507,14 +507,17 @@ nexus_setup_intr(device_t bus, device_t child, struct resource *irq,
        if (error)
                return (error);
 
+       /* Use device name, if description is not specified */
+       if (desc == NULL)
+               desc = device_get_nameunit(child);
+
        /*
         * XXX cast the interrupt handler function to an inthand2_t.  The
         * difference is that an additional frame argument is passed which
         * we do not currently want to expose the BUS subsystem to.
         */
        *cookiep = register_int(irq->r_start, (inthand2_t *)ihand, arg,
-                               device_get_nameunit(child), serializer,
-                               icflags, rman_get_cpuid(irq));
+                               desc, serializer, icflags, rman_get_cpuid(irq));
        if (*cookiep == NULL)
                error = EINVAL;
        return (error);
index dee11bc..449fcfc 100644 (file)
@@ -385,7 +385,7 @@ npx_probe1(device_t dev)
                                        panic("npx: can't get IRQ");
                                BUS_SETUP_INTR(device_get_parent(dev),
                                               dev, r, 0,
-                                              npx_intr, 0, &intr, NULL);
+                                              npx_intr, 0, &intr, NULL, NULL);
                                if (intr == NULL)
                                        panic("npx: can't create intr");
 
index ed55d53..fb6a078 100644 (file)
@@ -96,8 +96,8 @@ static        int nexus_release_resource(device_t, device_t, int, int,
 static int nexus_config_intr(device_t, device_t, int, enum intr_trigger,
                              enum intr_polarity);
 static int nexus_setup_intr(device_t, device_t, struct resource *, int flags,
-                            void (*)(void *), void *, 
-                            void **, lwkt_serialize_t);
+               void (*)(void *), void *, void **, lwkt_serialize_t,
+               const char *);
 static int nexus_teardown_intr(device_t, device_t, struct resource *,
                                void *);
 static int nexus_set_resource(device_t, device_t, int, int, u_long, u_long,
@@ -488,8 +488,8 @@ nexus_config_intr(device_t bus, device_t chile, int irq,
  */
 static int
 nexus_setup_intr(device_t bus, device_t child, struct resource *irq,
-                int flags, void (*ihand)(void *), void *arg,
-                void **cookiep, lwkt_serialize_t serializer)
+    int flags, void (*ihand)(void *), void *arg, void **cookiep,
+    lwkt_serialize_t serializer, const char *desc)
 {
        int     error, icflags;
 
@@ -509,14 +509,17 @@ nexus_setup_intr(device_t bus, device_t child, struct resource *irq,
        if (error)
                return (error);
 
+       /* Use device name, if description is not specified */
+       if (desc == NULL)
+               desc = device_get_nameunit(child);
+
        /*
         * XXX cast the interrupt handler function to an inthand2_t.  The
         * difference is that an additional frame argument is passed which
         * we do not currently want to expose the BUS subsystem to.
         */
        *cookiep = register_int(irq->r_start, (inthand2_t *)ihand, arg,
-                               device_get_nameunit(child), serializer,
-                               icflags, rman_get_cpuid(irq));
+                               desc, serializer, icflags, rman_get_cpuid(irq));
        if (*cookiep == NULL)
                error = EINVAL;
        return (error);
index 8ac4c72..fb9632f 100644 (file)
@@ -271,9 +271,8 @@ void        bus_generic_delete_resource(device_t dev, device_t child,
                                     int type, int rid);
 int    bus_generic_resume(device_t dev);
 int    bus_generic_setup_intr(device_t dev, device_t child,
-                              struct resource *irq, int flags,
-                              driver_intr_t *intr, void *arg,
-                              void **cookiep, lwkt_serialize_t serializer);
+           struct resource *irq, int flags, driver_intr_t *intr, void *arg,
+           void **cookiep, lwkt_serialize_t serializer, const char *desc);
 int    bus_generic_shutdown(device_t dev);
 int    bus_generic_suspend(device_t dev);
 int    bus_generic_teardown_intr(device_t dev, device_t child,
@@ -323,6 +322,9 @@ int bus_release_resource(device_t dev, int type, int rid,
 int    bus_setup_intr(device_t dev, struct resource *r, int flags,
                       driver_intr_t handler, void *arg,
                       void **cookiep, lwkt_serialize_t serializer);
+int    bus_setup_intr_descr(device_t dev, struct resource *r, int flags,
+           driver_intr_t handler, void *arg, void **cookiep,
+           lwkt_serialize_t serializer, const char *desc);
 int    bus_teardown_intr(device_t dev, struct resource *r, void *cookie);
 int    bus_set_resource(device_t dev, int type, int rid,
                         u_long start, u_long count, int cpuid);