From fe0d408987b42b531420ff2de76d534dbe7ecee7 Mon Sep 17 00:00:00 2001 From: "Matthew N. Dodd" Date: Fri, 3 Dec 1999 08:41:24 +0000 Subject: Remove the 'ivars' arguement to device_add_child() and device_add_child_ordered(). 'ivars' may now be set using the device_set_ivars() function. This makes it easier for us to change how arbitrary data structures are associated with a device_t. Eventually we won't be modifying device_t to add additional pointers for ivars, softc data etc. Despite my best efforts I've probably forgotten something so let me know if this breaks anything. I've been running with this change for months and its been quite involved actually isolating all the changes from the rest of the local changes in my tree. Reviewed by: peter, dfr --- sys/dev/amr/amr.c | 3 ++- sys/dev/atkbdc/atkbdc_isa.c | 3 ++- sys/dev/atkbdc/atkbdc_subr.c | 3 ++- sys/dev/bktr/bktr_i2c.c | 4 ++-- sys/dev/eisa/eisaconf.c | 4 +++- sys/dev/fdc/fdc.c | 3 ++- sys/dev/ida/ida.c | 2 +- sys/dev/iicbus/iicbus.c | 4 ++-- sys/dev/iicbus/iiconf.c | 2 +- sys/dev/mca/mca_bus.c | 4 +++- sys/dev/mii/mii.c | 6 ++++-- sys/dev/mlx/mlx.c | 3 ++- sys/dev/pccard/pccard.c | 2 +- sys/dev/pcf/pcf.c | 2 +- sys/dev/pci/pci.c | 4 ++-- sys/dev/ppbus/lpbb.c | 4 ++-- sys/dev/smbus/smbconf.c | 2 +- sys/dev/smbus/smbus.c | 4 ++-- sys/dev/sound/isa/gusc.c | 17 ++++++++++++----- sys/dev/sound/isa/sbc.c | 10 +++++++--- sys/dev/sound/pci/csa.c | 7 +++++-- sys/dev/usb/ohci_pci.c | 3 ++- sys/dev/usb/uhci_pci.c | 3 ++- sys/dev/usb/usb_subr.c | 8 +++++--- 24 files changed, 68 insertions(+), 39 deletions(-) (limited to 'sys/dev') diff --git a/sys/dev/amr/amr.c b/sys/dev/amr/amr.c index bdb3c0238487..d32057b42238 100644 --- a/sys/dev/amr/amr.c +++ b/sys/dev/amr/amr.c @@ -439,9 +439,10 @@ amr_startup(struct amr_softc *sc) } dr->al_cylinders = dr->al_size / (dr->al_heads * dr->al_sectors); - dr->al_disk = device_add_child(sc->amr_dev, NULL, -1, dr); + dr->al_disk = device_add_child(sc->amr_dev, NULL, -1); if (dr->al_disk == 0) device_printf(sc->amr_dev, "device_add_child failed\n"); + device_set_ivars(dr->al_disk, dr); } } diff --git a/sys/dev/atkbdc/atkbdc_isa.c b/sys/dev/atkbdc/atkbdc_isa.c index eae6e14fec84..9829f2be80b3 100644 --- a/sys/dev/atkbdc/atkbdc_isa.c +++ b/sys/dev/atkbdc/atkbdc_isa.c @@ -137,7 +137,8 @@ atkbdc_add_device(device_t dev, const char *name, int unit) else kdev->flags = 0; - child = device_add_child(dev, name, unit, kdev); + child = device_add_child(dev, name, unit); + device_set_ivars(child, kdev); } static int diff --git a/sys/dev/atkbdc/atkbdc_subr.c b/sys/dev/atkbdc/atkbdc_subr.c index eae6e14fec84..9829f2be80b3 100644 --- a/sys/dev/atkbdc/atkbdc_subr.c +++ b/sys/dev/atkbdc/atkbdc_subr.c @@ -137,7 +137,8 @@ atkbdc_add_device(device_t dev, const char *name, int unit) else kdev->flags = 0; - child = device_add_child(dev, name, unit, kdev); + child = device_add_child(dev, name, unit); + device_set_ivars(child, kdev); } static int diff --git a/sys/dev/bktr/bktr_i2c.c b/sys/dev/bktr/bktr_i2c.c index 7cd0ba040bae..43a5f35a24e9 100644 --- a/sys/dev/bktr/bktr_i2c.c +++ b/sys/dev/bktr/bktr_i2c.c @@ -159,10 +159,10 @@ bt848_i2c_attach(int unit, bt848_ptr_t base, struct bktr_i2c_softc *i2c_sc) btdata[unit].base = base; /* XXX add the I2C interface to the root_bus until pcibus is ready */ - interface = device_add_child(root_bus, "bti2c", unit, NULL); + interface = device_add_child(root_bus, "bti2c", unit); /* add bit-banging generic code onto bti2c interface */ - bitbang = device_add_child(interface, "iicbb", -1, NULL); + bitbang = device_add_child(interface, "iicbb", -1); /* probe and attach the interface, we need it NOW * bit-banging code is also probed and attached */ diff --git a/sys/dev/eisa/eisaconf.c b/sys/dev/eisa/eisaconf.c index d6023052d26a..59f553a1170f 100644 --- a/sys/dev/eisa/eisaconf.c +++ b/sys/dev/eisa/eisaconf.c @@ -152,6 +152,7 @@ eisa_probe(device_t dev) { int i,slot; struct eisa_device *e_dev; + device_t child; int eisaBase = 0xc80; eisa_id_t eisa_id; int devices_found = 0; @@ -188,7 +189,8 @@ eisa_probe(device_t dev) LIST_INIT(&(e_dev->ioconf.maddrs)); TAILQ_INIT(&(e_dev->ioconf.irqs)); - device_add_child(dev, NULL, -1, e_dev); + child = device_add_child(dev, NULL, -1); + device_set_ivars(child, e_dev); } /* diff --git a/sys/dev/fdc/fdc.c b/sys/dev/fdc/fdc.c index da131e1da708..69e9795fc7bd 100644 --- a/sys/dev/fdc/fdc.c +++ b/sys/dev/fdc/fdc.c @@ -772,7 +772,8 @@ fdc_add_device(device_t dev, const char *name, int unit) return; if (resource_int_value(name, unit, "drive", ivar) != 0) *ivar = 0; - child = device_add_child(dev, name, unit, ivar); + child = device_add_child(dev, name, unit); + device_set_ivars(child, ivar); if (child == 0) return; if (resource_int_value(name, unit, "disabled", &disabled) == 0 diff --git a/sys/dev/ida/ida.c b/sys/dev/ida/ida.c index 769205f2f363..ae253918ad6b 100644 --- a/sys/dev/ida/ida.c +++ b/sys/dev/ida/ida.c @@ -252,7 +252,7 @@ ida_attach(struct ida_softc *ida) ida->num_drives = cinfo.num_drvs; for (i = 0; i < ida->num_drives; i++) - device_add_child(ida->dev, "id", i, NULL); + device_add_child(ida->dev, "id", i); bus_generic_attach(ida->dev); diff --git a/sys/dev/iicbus/iicbus.c b/sys/dev/iicbus/iicbus.c index 26912fc0a87b..45a32d4d1a3b 100644 --- a/sys/dev/iicbus/iicbus.c +++ b/sys/dev/iicbus/iicbus.c @@ -203,8 +203,8 @@ iicbus_attach(device_t dev) } if (iicdev->iicd_alive) { - child = device_add_child(dev, iicdev->iicd_name, - -1, iicdev); + child = device_add_child(dev, iicdev->iicd_name, -1); + device_set_ivars(child, iicdev); device_set_desc(child, iicdev->iicd_desc); } } diff --git a/sys/dev/iicbus/iiconf.c b/sys/dev/iicbus/iiconf.c index 52e92f74344d..1fc07bf3b3f7 100644 --- a/sys/dev/iicbus/iiconf.c +++ b/sys/dev/iicbus/iiconf.c @@ -63,7 +63,7 @@ iicbus_alloc_bus(device_t parent) device_t child; /* add the bus to the parent */ - child = device_add_child(parent, "iicbus", -1, NULL); + child = device_add_child(parent, "iicbus", -1); return (child); } diff --git a/sys/dev/mca/mca_bus.c b/sys/dev/mca/mca_bus.c index f105ea17c6fe..a2dd456295cb 100644 --- a/sys/dev/mca/mca_bus.c +++ b/sys/dev/mca/mca_bus.c @@ -245,6 +245,7 @@ mca_add_iospace (dev, iobase, iosize) static int mca_probe (device_t dev) { + device_t child; struct mca_device * m_dev = NULL; int devices_found = 0; u_int8_t slot; @@ -307,7 +308,8 @@ mca_probe (device_t dev) resource_list_init(&(m_dev->rl)); - device_add_child(dev, NULL, -1, m_dev); + child = device_add_child(dev, NULL, -1); + device_set_ivars(child, m_dev); m_dev = NULL; } diff --git a/sys/dev/mii/mii.c b/sys/dev/mii/mii.c index 46cdc22d56d8..b3f40e29ddca 100644 --- a/sys/dev/mii/mii.c +++ b/sys/dev/mii/mii.c @@ -142,7 +142,8 @@ int miibus_probe(dev) args = malloc(sizeof(struct mii_attach_args), M_DEVBUF, M_NOWAIT); bcopy((char *)&ma, (char *)args, sizeof(ma)); - child = device_add_child(dev, NULL, -1, args); + child = device_add_child(dev, NULL, -1); + device_set_ivars(child, args); } if (child == NULL) @@ -250,7 +251,8 @@ int mii_phy_probe(dev, child, ifmedia_upd, ifmedia_sts) v = malloc(sizeof(vm_offset_t) * 2, M_DEVBUF, M_NOWAIT); v[0] = ifmedia_upd; v[1] = ifmedia_sts; - *child = device_add_child(dev, "miibus", -1, v); + *child = device_add_child(dev, "miibus", -1); + device_set_ivars(*child, v); for (i = 0; i < MII_NPHY; i++) { bmsr = MIIBUS_READREG(dev, i, MII_BMSR); diff --git a/sys/dev/mlx/mlx.c b/sys/dev/mlx/mlx.c index eccb788d078e..ee099d244d8b 100644 --- a/sys/dev/mlx/mlx.c +++ b/sys/dev/mlx/mlx.c @@ -480,9 +480,10 @@ mlx_startup(struct mlx_softc *sc) dr->ms_sectors = 63; dr->ms_cylinders = dr->ms_size / (255 * 63); } - dr->ms_disk = device_add_child(sc->mlx_dev, /*"mlxd"*/NULL, -1, dr); + dr->ms_disk = device_add_child(sc->mlx_dev, /*"mlxd"*/NULL, -1); if (dr->ms_disk == 0) device_printf(sc->mlx_dev, "device_add_child failed\n"); + device_set_ivars(dr->ms_disk, dr); } } free(mes, M_DEVBUF); diff --git a/sys/dev/pccard/pccard.c b/sys/dev/pccard/pccard.c index ca1748dc130a..39c939cb2fee 100644 --- a/sys/dev/pccard/pccard.c +++ b/sys/dev/pccard/pccard.c @@ -839,7 +839,7 @@ pccard_card_intrdebug(arg) static int pccard_add_children(device_t dev, int busno) { - device_add_child(dev, NULL, -1, NULL); + device_add_child(dev, NULL, -1); return 0; } diff --git a/sys/dev/pcf/pcf.c b/sys/dev/pcf/pcf.c index 3cb86f7a8067..1aeb7e650c85 100644 --- a/sys/dev/pcf/pcf.c +++ b/sys/dev/pcf/pcf.c @@ -164,7 +164,7 @@ pcfprobe_isa(struct isa_device *dvp) pcfdata[npcf++] = pcf; /* XXX add the pcf device to the root_bus until isa bus exists */ - pcfdev = device_add_child(root_bus, "pcf", pcf->pcf_unit, NULL); + pcfdev = device_add_child(root_bus, "pcf", pcf->pcf_unit); if (!pcfdev) goto error; diff --git a/sys/dev/pci/pci.c b/sys/dev/pci/pci.c index efb98d271e74..b4dd70b0642e 100644 --- a/sys/dev/pci/pci.c +++ b/sys/dev/pci/pci.c @@ -1115,8 +1115,8 @@ pci_add_children(device_t dev, int busno) pcifunchigh = 7; pci_print_verbose(dinfo); - dinfo->cfg.dev = - device_add_child(dev, NULL, -1, dinfo); + dinfo->cfg.dev = device_add_child(dev, NULL, -1); + device_set_ivars(dinfo->cfg.dev, dinfo); pci_add_resources(dinfo->cfg.dev, &dinfo->cfg); } } diff --git a/sys/dev/ppbus/lpbb.c b/sys/dev/ppbus/lpbb.c index bf2880798ebe..7d4ba59f4a2b 100644 --- a/sys/dev/ppbus/lpbb.c +++ b/sys/dev/ppbus/lpbb.c @@ -134,7 +134,7 @@ lpbb_attach(device_t dev) device_t bitbang, iicbus; /* add generic bit-banging code */ - bitbang = device_add_child(dev, "iicbb", -1, NULL); + bitbang = device_add_child(dev, "iicbb", -1); /* add the iicbus to the tree */ iicbus = iicbus_alloc_bus(bitbang); @@ -191,7 +191,7 @@ static int lpbb_ppb_attach(struct ppb_device *dev) { /* add the parallel port I2C interface to the bus tree */ - if (!device_add_child(root_bus, "lpbb", dev->id_unit, NULL)) + if (!device_add_child(root_bus, "lpbb", dev->id_unit)) return (0); return (1); diff --git a/sys/dev/smbus/smbconf.c b/sys/dev/smbus/smbconf.c index 1d44ef354202..1afb7e9f2219 100644 --- a/sys/dev/smbus/smbconf.c +++ b/sys/dev/smbus/smbconf.c @@ -91,7 +91,7 @@ smbus_alloc_bus(device_t parent) device_t child; /* add the bus to the parent */ - child = device_add_child(parent, "smbus", -1, NULL); + child = device_add_child(parent, "smbus", -1); return (child); } diff --git a/sys/dev/smbus/smbus.c b/sys/dev/smbus/smbus.c index 1107992f467b..a1d3634aa7f0 100644 --- a/sys/dev/smbus/smbus.c +++ b/sys/dev/smbus/smbus.c @@ -113,8 +113,8 @@ smbus_attach(device_t dev) device_t child; if (devclass_find(smbdev->smbd_name)) { - child = device_add_child(dev, smbdev->smbd_name, - -1, smbdev); + child = device_add_child(dev, smbdev->smbd_name, -1); + device_set_ivars(child, smbdev); device_set_desc(child, smbdev->smbd_desc); } else if (bootverbose) printf("smbus: %s devclass not found\n", diff --git a/sys/dev/sound/isa/gusc.c b/sys/dev/sound/isa/gusc.c index 93fa2501a695..b6de776c504b 100644 --- a/sys/dev/sound/isa/gusc.c +++ b/sys/dev/sound/isa/gusc.c @@ -112,6 +112,7 @@ static devclass_t gusc_devclass; static int gusc_probe(device_t dev) { + device_t child; u_int32_t vend_id, logical_id; char *s; struct sndcard_func *func; @@ -133,7 +134,8 @@ gusc_probe(device_t dev) return (ENOMEM); bzero(func, sizeof(*func)); func->func = SCF_PCM; - device_add_child(dev, "pcm", -1, func); + child = device_add_child(dev, "pcm", -1); + device_set_ivars(child, func); break; #if notyet case LOGICALID_OPL: @@ -143,7 +145,8 @@ gusc_probe(device_t dev) return (ENOMEM); bzero(func, sizeof(*func)); func->func = SCF_SYNTH; - device_add_child(dev, "midi", -1, func); + child = device_add_child(dev, "midi", -1); + device_set_ivars(child, func); break; case LOGICALID_MIDI: s = "Gravis UltraSound Plug & Play MIDI"; @@ -152,7 +155,8 @@ gusc_probe(device_t dev) return (ENOMEM); bzero(func, sizeof(*func)); func->func = SCF_MIDI; - device_add_child(dev, "midi", -1, func); + child = device_add_child(dev, "midi", -1); + device_set_ivars(child, func); break; #endif /* notyet */ } @@ -186,6 +190,7 @@ port_rd(struct resource *r, int i) static int gusisa_probe(device_t dev) { + device_t child; struct resource *res, *res2; int base, rid, rid2, s, flags; unsigned char val; @@ -283,7 +288,8 @@ gusisa_probe(device_t dev) return ENOMEM; bzero(func, sizeof *func); func->func = SCF_MIDI; - device_add_child(dev, "midi", -1, func); + child = device_add_child(dev, "midi", -1); + device_set_ivars(child, func); #endif /* notyet */ func = malloc(sizeof(struct sndcard_func), M_DEVBUF, M_NOWAIT); @@ -292,7 +298,8 @@ gusisa_probe(device_t dev) else { bzero(func, sizeof *func); func->func = SCF_PCM; - device_add_child(dev, "pcm", -1, func); + child = device_add_child(dev, "pcm", -1); + device_set_ivars(child, func); } device_set_desc(dev, "Gravis UltraSound MAX"); return 0; diff --git a/sys/dev/sound/isa/sbc.c b/sys/dev/sound/isa/sbc.c index 8f3a4eeb95b0..7e9080ec8229 100644 --- a/sys/dev/sound/isa/sbc.c +++ b/sys/dev/sound/isa/sbc.c @@ -86,6 +86,7 @@ static devclass_t sbc_devclass; static int sbc_probe(device_t dev) { + device_t child; u_int32_t vend_id, logical_id, vend_id2; char *s; struct sndcard_func *func; @@ -177,7 +178,8 @@ sbc_probe(device_t dev) return (ENOMEM); bzero(func, sizeof(*func)); func->func = SCF_PCM; - device_add_child(dev, "pcm", -1, func); + child = device_add_child(dev, "pcm", -1); + device_set_ivars(child, func); #if notyet /* Midi Interface */ @@ -186,7 +188,8 @@ sbc_probe(device_t dev) return (ENOMEM); bzero(func, sizeof(*func)); func->func = SCF_MIDI; - device_add_child(dev, "midi", -1, func); + child = device_add_child(dev, "midi", -1); + device_set_ivars(child, func); /* OPL FM Synthesizer */ func = malloc(sizeof(struct sndcard_func), M_DEVBUF, M_NOWAIT); @@ -194,7 +197,8 @@ sbc_probe(device_t dev) return (ENOMEM); bzero(func, sizeof(*func)); func->func = SCF_SYNTH; - device_add_child(dev, "midi", -1, func); + child = device_add_child(dev, "midi", -1); + device_set_ivars(child, func); #endif /* notyet */ return (0); diff --git a/sys/dev/sound/pci/csa.c b/sys/dev/sound/pci/csa.c index 1637143eafb0..eebeda6ad5be 100644 --- a/sys/dev/sound/pci/csa.c +++ b/sys/dev/sound/pci/csa.c @@ -91,6 +91,7 @@ static devclass_t csa_devclass; static int csa_probe(device_t dev) { + device_t child; char *s; struct sndcard_func *func; @@ -119,7 +120,8 @@ csa_probe(device_t dev) return (ENOMEM); bzero(func, sizeof(*func)); func->func = SCF_PCM; - device_add_child(dev, "pcm", -1, func); + child = device_add_child(dev, "pcm", -1); + device_set_ivars(child, func); #if notyet /* Midi Interface */ @@ -128,7 +130,8 @@ csa_probe(device_t dev) return (ENOMEM); bzero(func, sizeof(*func)); func->func = SCF_MIDI; - device_add_child(dev, "midi", -1, func); + child = device_add_child(dev, "midi", -1); + device_set_ivars(child, func); #endif /* notyet */ return (0); diff --git a/sys/dev/usb/ohci_pci.c b/sys/dev/usb/ohci_pci.c index 8e1378b813e5..f8c49641efcf 100644 --- a/sys/dev/usb/ohci_pci.c +++ b/sys/dev/usb/ohci_pci.c @@ -168,7 +168,8 @@ ohci_pci_attach(device_t self) return ENOMEM; } - usbus = device_add_child(self, "usb", -1, sc); + usbus = device_add_child(self, "usb", -1); + device_set_ivars(usbus, sc); if (!usbus) { device_printf(self, "could not add USB device\n"); return ENOMEM; diff --git a/sys/dev/usb/uhci_pci.c b/sys/dev/usb/uhci_pci.c index 9285174b07c8..0857f1683fcd 100644 --- a/sys/dev/usb/uhci_pci.c +++ b/sys/dev/usb/uhci_pci.c @@ -181,7 +181,8 @@ uhci_pci_attach(device_t self) return ENOMEM; } - usbus = device_add_child(self, "usb", -1, sc); + usbus = device_add_child(self, "usb", -1); + device_set_ivars(usbus, sc); if (!usbus) { device_printf(self, "could not add USB device\n"); return ENOMEM; diff --git a/sys/dev/usb/usb_subr.c b/sys/dev/usb/usb_subr.c index 0aedc6238645..46c2e8b0ac99 100644 --- a/sys/dev/usb/usb_subr.c +++ b/sys/dev/usb/usb_subr.c @@ -747,7 +747,8 @@ usbd_probe_and_attach(parent, dev, port, addr) * during probe and attach. Should be changed however. */ device_t bdev; - bdev = device_add_child(parent, NULL, -1, &uaa); + bdev = device_add_child(parent, NULL, -1); + device_set_ivars(bdev, &uaa); if (!bdev) { printf("%s: Device creation failed\n", USBDEVNAME(dev->bus->bdev)); return (USBD_INVAL); @@ -828,8 +829,9 @@ usbd_probe_and_attach(parent, dev, port, addr) ifaces[i] = 0; /* consumed */ #if defined(__FreeBSD__) - /* create another child for the next iface */ - bdev = device_add_child(parent, NULL, -1,&uaa); + /* create another device for the next iface */ + bdev = device_add_child(parent, NULL, -1); + device_set_ivars(bdev, &uaa); if (!bdev) { printf("%s: Device creation failed\n", USBDEVNAME(dev->bus->bdev)); -- cgit v1.3