PERFORCE change 96283 for review
Marcel Moolenaar
marcel at FreeBSD.org
Fri Apr 28 05:43:52 UTC 2006
http://perforce.freebsd.org/chv.cgi?CH=96283
Change 96283 by marcel at marcel_nfs on 2006/04/28 05:42:50
Improve the output of devinfo(8): put the device name and
number in the description of the resource managers. As for
the interrupt resources, since we numbered them from 1 to
the number of ports, give it a description that maps sub-
device to port number. Avoid using 'irq' or 'interrupt' as
that may actually cause confusion.
Multiple puc(4) devices won't confuse anyone this way.
Affected files ...
.. //depot/projects/uart/dev/puc/puc.c#39 edit
Differences ...
==== //depot/projects/uart/dev/puc/puc.c#39 (text+ko) ====
@@ -189,6 +189,7 @@
int
puc_bfe_attach(device_t dev)
{
+ char buffer[64];
struct puc_bar *bar;
struct puc_port *port;
struct puc_softc *sc;
@@ -205,26 +206,33 @@
for (idx = 0; idx < PUC_PCI_BARS; idx++)
sc->sc_bar[idx].b_rid = -1;
- sc->sc_ioport.rm_type = RMAN_ARRAY;
- sc->sc_ioport.rm_descr = "I/O port space";
- error = rman_init(&sc->sc_ioport);
- if (error)
+ do {
+ sc->sc_ioport.rm_type = RMAN_ARRAY;
+ error = rman_init(&sc->sc_ioport);
+ if (!error) {
+ sc->sc_iomem.rm_type = RMAN_ARRAY;
+ error = rman_init(&sc->sc_iomem);
+ if (!error) {
+ sc->sc_irq.rm_type = RMAN_ARRAY;
+ error = rman_init(&sc->sc_irq);
+ if (!error)
+ break;
+ rman_fini(&sc->sc_iomem);
+ }
+ rman_fini(&sc->sc_ioport);
+ }
return (error);
- sc->sc_iomem.rm_type = RMAN_ARRAY;
- sc->sc_iomem.rm_descr = "Memory mapped I/O space";
- error = rman_init(&sc->sc_iomem);
- if (error) {
- rman_fini(&sc->sc_ioport);
- return (error);
- }
- sc->sc_irq.rm_type = RMAN_ARRAY;
- sc->sc_irq.rm_descr = "Interrupt vector space";
- error = rman_init(&sc->sc_irq);
- if (error) {
- rman_fini(&sc->sc_iomem);
- rman_fini(&sc->sc_ioport);
- return (error);
- }
+ } while (0);
+
+ snprintf(buffer, sizeof(buffer), "%s I/O port mapping",
+ device_get_nameunit(dev));
+ sc->sc_ioport.rm_descr = strdup(buffer, M_PUC);
+ snprintf(buffer, sizeof(buffer), "%s I/O memory mapping",
+ device_get_nameunit(dev));
+ sc->sc_iomem.rm_descr = strdup(buffer, M_PUC);
+ snprintf(buffer, sizeof(buffer), "%s port numbers",
+ device_get_nameunit(dev));
+ sc->sc_irq.rm_descr = strdup(buffer, M_PUC);
error = puc_config(sc, PUC_CFG_GET_NPORTS, 0, &res);
KASSERT(error == 0, ("%s %d", __func__, __LINE__));
@@ -362,8 +370,11 @@
bar->b_rid, bar->b_res);
}
rman_fini(&sc->sc_irq);
+ free(__DECONST(void *, sc->sc_irq.rm_descr), M_PUC);
rman_fini(&sc->sc_iomem);
+ free(__DECONST(void *, sc->sc_iomem.rm_descr), M_PUC);
rman_fini(&sc->sc_ioport);
+ free(__DECONST(void *, sc->sc_ioport.rm_descr), M_PUC);
free(sc->sc_port, M_PUC);
return (error);
}
More information about the p4-projects
mailing list