Deleted Added
full compact
66c66
< __FBSDID("$FreeBSD: head/sys/sparc64/sbus/dma_sbus.c 146392 2005-05-19 14:51:10Z marius $");
---
> __FBSDID("$FreeBSD: head/sys/sparc64/sbus/dma_sbus.c 152684 2005-11-22 16:39:44Z marius $");
76a77
> #include <dev/ofw/ofw_bus_subr.h>
90,95c91
< char *ddi_compat; /* PROM compatible */
< char *ddi_model; /* PROM model */
< char *ddi_name; /* PROM name */
< phandle_t ddi_node; /* PROM node */
< char *ddi_type; /* PROM device_type */
<
---
> struct ofw_bus_devinfo ddi_obdinfo;
115,119c111
< static ofw_bus_get_compat_t dma_get_compat;
< static ofw_bus_get_model_t dma_get_model;
< static ofw_bus_get_name_t dma_get_name;
< static ofw_bus_get_node_t dma_get_node;
< static ofw_bus_get_type_t dma_get_type;
---
> static ofw_bus_get_devinfo_t dma_get_devinfo;
121c113,114
< static struct dma_devinfo *dma_setup_dinfo(device_t, phandle_t, char *);
---
> static struct dma_devinfo *dma_setup_dinfo(device_t, struct dma_softc *,
> phandle_t);
122a116
> static int dma_print_res(struct dma_devinfo *);
146,150c140,145
< DEVMETHOD(ofw_bus_get_compat, dma_get_compat),
< DEVMETHOD(ofw_bus_get_model, dma_get_model),
< DEVMETHOD(ofw_bus_get_name, dma_get_name),
< DEVMETHOD(ofw_bus_get_node, dma_get_node),
< DEVMETHOD(ofw_bus_get_type, dma_get_type),
---
> DEVMETHOD(ofw_bus_get_devinfo, dma_get_devinfo),
> DEVMETHOD(ofw_bus_get_compat, ofw_bus_gen_get_compat),
> DEVMETHOD(ofw_bus_get_model, ofw_bus_gen_get_model),
> DEVMETHOD(ofw_bus_get_name, ofw_bus_gen_get_name),
> DEVMETHOD(ofw_bus_get_node, ofw_bus_gen_get_node),
> DEVMETHOD(ofw_bus_get_type, ofw_bus_gen_get_type),
185c180
< char *cabletype, *cname;
---
> char *cabletype;
191d185
< bzero(dsc, sizeof(struct dma_softc));
271c265
< if ((OF_getprop_alloc(child, "name", 1, (void **)&cname)) == -1)
---
> if ((ddi = dma_setup_dinfo(dev, dsc, child)) == NULL)
273,277d266
< if ((ddi = dma_setup_dinfo(dev, child, cname)) == NULL) {
< device_printf(dev, "<%s>: incomplete\n", cname);
< free(cname, M_OFWPROP);
< continue;
< }
279,280c268,270
< device_printf(dev, "<%s>: only one child per DMA "
< "channel supported\n", cname);
---
> device_printf(dev,
> "<%s>: only one child per DMA channel supported\n",
> ddi->ddi_obdinfo.obd_name);
282d271
< free(cname, M_OFWPROP);
287c276
< cname);
---
> ddi->ddi_obdinfo.obd_name);
289d277
< free(cname, M_OFWPROP);
295,299c283
< error = bus_generic_attach(dev);
< if (error != 0) {
< device_printf(dev, "bus_generic_attach failed\n");
< goto fail_lsi;
< }
---
> return (bus_generic_attach(dev));
301,304d284
< return (0);
<
< fail_lsi:
< lsi64854_detach(lsc);
313c293
< dma_setup_dinfo(device_t dev, phandle_t node, char *name)
---
> dma_setup_dinfo(device_t dev, struct dma_softc *dsc, phandle_t node)
315d294
< struct dma_softc *dsc;
321,322d299
< dsc = device_get_softc(dev);
<
324c301,302
< if (ddi == NULL)
---
> if (ofw_bus_gen_setup_devinfo(&ddi->ddi_obdinfo, node) != 0) {
> free(ddi, M_DEVBUF);
325a304
> }
327,331d305
< ddi->ddi_name = name;
< ddi->ddi_node = node;
< OF_getprop_alloc(node, "compatible", 1, (void **)&ddi->ddi_compat);
< OF_getprop_alloc(node, "device_type", 1, (void **)&ddi->ddi_type);
< OF_getprop_alloc(node, "model", 1, (void **)&ddi->ddi_model);
335,336c309,311
< dma_destroy_dinfo(ddi);
< return (NULL);
---
> device_printf(dev, "<%s>: incomplete\n",
> ddi->ddi_obdinfo.obd_name);
> goto fail;
346c321,322
< device_printf(dev, "<%s>: multiple slots\n", name);
---
> device_printf(dev, "<%s>: multiple slots\n",
> ddi->ddi_obdinfo.obd_name);
348,349c324
< dma_destroy_dinfo(ddi);
< return (NULL);
---
> goto fail;
359,361c334,335
< name);
< dma_destroy_dinfo(ddi);
< return (NULL);
---
> ddi->ddi_obdinfo.obd_name);
> goto fail;
385a360,363
>
> fail:
> dma_destroy_dinfo(ddi);
> return (NULL);
393,398c371
< if (dinfo->ddi_compat != NULL)
< free(dinfo->ddi_compat, M_OFWPROP);
< if (dinfo->ddi_model != NULL)
< free(dinfo->ddi_model, M_OFWPROP);
< if (dinfo->ddi_type != NULL)
< free(dinfo->ddi_type, M_OFWPROP);
---
> ofw_bus_gen_destroy_devinfo(&dinfo->ddi_obdinfo);
405,406d377
< struct dma_devinfo *ddi;
< struct resource_list *rl;
409,410d379
< ddi = device_get_ivars(child);
< rl = &ddi->ddi_rl;
412,413c381
< rv += resource_list_print_type(rl, "mem", SYS_RES_MEMORY, "%#lx");
< rv += resource_list_print_type(rl, "irq", SYS_RES_IRQ, "%ld");
---
> rv += dma_print_res(device_get_ivars(child));
421,422c389
< struct dma_devinfo *ddi;
< struct resource_list *rl;
---
> const char *type;
424,430c391,395
< ddi = device_get_ivars(child);
< rl = &ddi->ddi_rl;
< device_printf(dev, "<%s>", ddi->ddi_name);
< resource_list_print_type(rl, "mem", SYS_RES_MEMORY, "%#lx");
< resource_list_print_type(rl, "irq", SYS_RES_IRQ, "%ld");
< printf(" type %s (no driver attached)\n",
< ddi->ddi_type != NULL ? ddi->ddi_type : "unknown");
---
> device_printf(dev, "<%s>", ofw_bus_get_name(child));
> dma_print_res(device_get_ivars(child));
> type = ofw_bus_get_type(child);
> printf(" type %s (no driver attached)\n",
> type != NULL ? type : "unknown");
463,464c428,429
< static const char *
< dma_get_compat(device_t bus, device_t dev)
---
> static const struct ofw_bus_devinfo *
> dma_get_devinfo(device_t bus, device_t child)
466c431
< struct dma_devinfo *dinfo;
---
> struct dma_devinfo *ddi;
468,469c433,434
< dinfo = device_get_ivars(dev);
< return (dinfo->ddi_compat);
---
> ddi = device_get_ivars(child);
> return (&ddi->ddi_obdinfo);
472,473c437,438
< static const char *
< dma_get_model(device_t bus, device_t dev)
---
> static int
> dma_print_res(struct dma_devinfo *ddi)
475c440
< struct dma_devinfo *dinfo;
---
> int rv;
477,478c442,446
< dinfo = device_get_ivars(dev);
< return (dinfo->ddi_model);
---
> rv = 0;
> rv += resource_list_print_type(&ddi->ddi_rl, "mem", SYS_RES_MEMORY,
> "%#lx");
> rv += resource_list_print_type(&ddi->ddi_rl, "irq", SYS_RES_IRQ, "%ld");
> return (rv);
480,506d447
<
< static const char *
< dma_get_name(device_t bus, device_t dev)
< {
< struct dma_devinfo *dinfo;
<
< dinfo = device_get_ivars(dev);
< return (dinfo->ddi_name);
< }
<
< static phandle_t
< dma_get_node(device_t bus, device_t dev)
< {
< struct dma_devinfo *dinfo;
<
< dinfo = device_get_ivars(dev);
< return (dinfo->ddi_node);
< }
<
< static const char *
< dma_get_type(device_t bus, device_t dev)
< {
< struct dma_devinfo *dinfo;
<
< dinfo = device_get_ivars(dev);
< return (dinfo->ddi_type);
< }