1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-01-20 15:43:16 +00:00

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
This commit is contained in:
Matthew N. Dodd 1999-12-03 08:41:24 +00:00
parent b06e7af6dd
commit fe0d408987
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=54073
71 changed files with 189 additions and 118 deletions

View File

@ -177,7 +177,7 @@ configure(void *dummy)
{
configure_start();
device_add_child(root_bus, platform.iobus, 0, 0);
device_add_child(root_bus, platform.iobus, 0);
root_bus_configure();

View File

@ -574,7 +574,7 @@ apecs_probe(device_t dev)
isa_init_intr();
apecs_init_sgmap();
device_add_child(dev, "pcib", 0, 0);
device_add_child(dev, "pcib", 0);
return 0;
}

View File

@ -42,7 +42,7 @@ apecs_pcib_probe(device_t dev)
{
device_set_desc(dev, "2107x PCI host bus adapter");
device_add_child(dev, "pci", 0, 0);
device_add_child(dev, "pci", 0);
return 0;
}

View File

@ -897,7 +897,7 @@ cia_probe(device_t dev)
isa_init_intr();
cia_init_sgmap();
device_add_child(dev, "pcib", 0, 0);
device_add_child(dev, "pcib", 0);
return 0;
}

View File

@ -42,7 +42,7 @@ cia_pcib_probe(device_t dev)
{
device_set_desc(dev, "2117x PCI host bus adapter");
device_add_child(dev, "pci", 0, 0);
device_add_child(dev, "pci", 0);
return 0;
}

View File

@ -460,7 +460,7 @@ lca_probe(device_t dev)
isa_init_intr();
lca_init_sgmap();
device_add_child(dev, "pcib", 0, 0);
device_add_child(dev, "pcib", 0);
return 0;
}

View File

@ -42,7 +42,7 @@ lca_pcib_probe(device_t dev)
{
device_set_desc(dev, "21066 PCI host bus adapter");
device_add_child(dev, "pci", 0, 0);
device_add_child(dev, "pci", 0);
return 0;
}

View File

@ -538,6 +538,7 @@ tsunami_init()
static int
tsunami_probe(device_t dev)
{
device_t child;
int *hose;
int i;
if (tsunami0)
@ -555,7 +556,8 @@ tsunami_probe(device_t dev)
for(i = 0; i < num_pchips; i++) {
hose = malloc(sizeof(int), M_DEVBUF, M_NOWAIT);
*hose = i;
device_add_child(dev, "pcib", i, hose);
child = device_add_child(dev, "pcib", i);
device_set_ivars(child, hose);
pchip_init(pchip[i], i);
}

View File

@ -70,7 +70,7 @@ tsunami_pcib_probe(device_t dev)
device_set_desc(dev, "21271 PCI host bus adapter");
child = device_add_child(dev, "pci", -1, 0);
child = device_add_child(dev, "pci", -1);
if(hoseno)
tsunami_hoses[hoseno] = device_get_unit(child);

View File

@ -173,6 +173,7 @@ ioasic_probe(device_t dev)
static int
ioasic_attach(device_t dev)
{
device_t child;
struct ioasic_softc* sc = IOASIC_SOFTC(dev);
struct tc_attach_args *ta = device_get_ivars(dev);
device_t parent = device_get_parent(dev);
@ -226,7 +227,10 @@ ioasic_attach(device_t dev)
for (i = 0; i < ioasic_ndevs; i++) {
ioasic_devs[i].iada_addr = sc->sc_base + ioasic_devs[i].iad_offset;
device_probe_and_attach(device_add_child(dev, ioasic_devs[i].iad_modname, -1, &ioasic_devs[i]));
child = device_add_child(dev, ioasic_devs[i].iad_modname, -1);
device_set_ivars(child, &ioasic_devs[i]);
device_probe_and_attach(child);
}
return 0;
}

View File

@ -612,7 +612,8 @@ tc_attach(device_t dev)
ta->ta_cookie = builtin->tcb_cookie;
ta->ta_busspeed = sc->sc_speed;
child = device_add_child(dev, builtin->tcb_modname, 0, ta);
child = device_add_child(dev, builtin->tcb_modname, 0);
device_set_ivars(child, ta);
device_probe_and_attach(child);
}

View File

@ -82,7 +82,7 @@ tcasic_probe(device_t dev)
return ENXIO;
tcasic0 = dev;
device_set_desc(dev, "Turbochannel Host Bus Adapter");
tc0 = device_add_child(dev, "tc", 0, 0);
tc0 = device_add_child(dev, "tc", 0);
return 0;
}

View File

@ -150,6 +150,7 @@ tcds_attach(device_t dev)
struct tcds_softc* sc = TCDS_SOFTC(dev);
struct tc_attach_args *ta = device_get_ivars(dev);
device_t parent = device_get_parent(dev);
device_t child;
vm_offset_t regs,va;
u_long i;
struct tcds_slotconfig *slotc;
@ -229,7 +230,9 @@ tcds_attach(device_t dev)
tcdsdev->tcdsda_freq = 25000000; /* XXX */
tcds_scsi_reset(tcdsdev->tcdsda_sc);
device_probe_and_attach(device_add_child(dev, "esp", -1, tcdsdev));
child = device_add_child(dev, "esp", -1);
device_set_ivars(child, tcdsdev);
device_probe_and_attach(child);
}
/* the second SCSI chip isn't present on the 3000/300 series. */
@ -248,7 +251,9 @@ tcds_attach(device_t dev)
tcdsdev->tcdsda_id = 7; /* XXX */
tcdsdev->tcdsda_freq = 25000000; /* XXX */
tcds_scsi_reset(tcdsdev->tcdsda_sc);
device_probe_and_attach(device_add_child(dev, "esp", -1, tcdsdev));
child = device_add_child(dev, "esp", -1);
device_set_ivars(child, tcdsdev);
device_probe_and_attach(child);
}
}
return 0;

View File

@ -112,6 +112,7 @@ static driver_t gbus_driver = {
static int
gbus_probe(device_t dev)
{
device_t child;
struct gbus_device *gdev;
/*
@ -122,8 +123,10 @@ gbus_probe(device_t dev)
if (!TLDEV_ISCPU(tlsb_get_dtype(dev)))
return ENXIO;
for (gdev = gbus_children; gdev->gd_name; gdev++)
device_add_child(dev, gdev->gd_name, -1, gdev);
for (gdev = gbus_children; gdev->gd_name; gdev++) {
child = device_add_child(dev, gdev->gd_name, -1);
device_set_ivars(child, gdev);
}
return 0;
}

View File

@ -104,6 +104,7 @@ static driver_t kft_driver = {
static int
kft_probe(device_t dev)
{
device_t child;
struct kft_softc *sc = (struct kft_softc *) device_get_softc(dev);
struct kft_device* kd;
int hoseno;
@ -145,7 +146,8 @@ kft_probe(device_t dev)
kd->kd_node = sc->sc_node;
kd->kd_dtype = sc->sc_dtype;
kd->kd_hosenum = hoseno;
device_add_child(dev, kd->kd_name, -1, kd);
child = device_add_child(dev, kd->kd_name, -1);
device_set_ivars(child, kd);
}
return 0;

View File

@ -206,7 +206,8 @@ tlsb_probe(device_t dev)
tdev->td_swrev = TLDEV_SWREV(tldev);
tdev->td_hwrev = TLDEV_HWREV(tldev);
child = device_add_child(dev, NULL, -1, tdev);
child = device_add_child(dev, NULL, -1);
device_set_ivars(child, tdev);
device_set_desc(child, tlsb_node_type_str(tdev->td_dtype));
/*

View File

@ -430,8 +430,8 @@ zsc_tlsb_probe(device_t dev)
/*
* Add channel A and channel B
*/
device_add_child(dev, "zs", 0, (void*) 0);
device_add_child(dev, "zs", 1, (void*) 0);
device_add_child(dev, "zs", 0);
device_add_child(dev, "zs", 1);
return 0;
}

View File

@ -136,7 +136,7 @@ configure(dummy)
#endif /* APIC_IO */
/* nexus0 is the top of the i386 device tree */
device_add_child(root_bus, "nexus", 0, 0);
device_add_child(root_bus, "nexus", 0);
/* initialize new bus architecture */
root_bus_configure();

View File

@ -202,25 +202,26 @@ nexus_attach(device_t dev)
* connection points now so they show up "on motherboard".
*/
if (!devclass_get_device(devclass_find("eisa"), 0)) {
child = device_add_child(dev, "eisa", 0, 0);
child = device_add_child(dev, "eisa", 0);
if (child == NULL)
panic("nexus_attach eisa");
device_probe_and_attach(child);
}
#if NMCA > 0
if (!devclass_get_device(devclass_find("mca"), 0)) {
child = device_add_child(dev, "mca", 0, 0);
child = device_add_child(dev, "mca", 0);
if (child == 0)
panic("nexus_probe mca");
device_probe_and_attach(child);
}
#endif
if (!devclass_get_device(devclass_find("isa"), 0)) {
child = device_add_child(dev, "isa", 0, 0);
child = device_add_child(dev, "isa", 0);
if (child == NULL)
panic("nexus_attach isa");
device_probe_and_attach(child);
}
return 0;
}
@ -238,7 +239,7 @@ nexus_print_child(device_t bus, device_t child)
static device_t
nexus_add_child(device_t bus, int order, const char *name, int unit)
{
return device_add_child_ordered(bus, order, name, unit, 0);
return device_add_child_ordered(bus, order, name, unit);
}
/*

View File

@ -202,25 +202,26 @@ nexus_attach(device_t dev)
* connection points now so they show up "on motherboard".
*/
if (!devclass_get_device(devclass_find("eisa"), 0)) {
child = device_add_child(dev, "eisa", 0, 0);
child = device_add_child(dev, "eisa", 0);
if (child == NULL)
panic("nexus_attach eisa");
device_probe_and_attach(child);
}
#if NMCA > 0
if (!devclass_get_device(devclass_find("mca"), 0)) {
child = device_add_child(dev, "mca", 0, 0);
child = device_add_child(dev, "mca", 0);
if (child == 0)
panic("nexus_probe mca");
device_probe_and_attach(child);
}
#endif
if (!devclass_get_device(devclass_find("isa"), 0)) {
child = device_add_child(dev, "isa", 0, 0);
child = device_add_child(dev, "isa", 0);
if (child == NULL)
panic("nexus_attach isa");
device_probe_and_attach(child);
}
return 0;
}
@ -238,7 +239,7 @@ nexus_print_child(device_t bus, device_t child)
static device_t
nexus_add_child(device_t bus, int order, const char *name, int unit)
{
return device_add_child_ordered(bus, order, name, unit, 0);
return device_add_child_ordered(bus, order, name, unit);
}
/*

View File

@ -478,7 +478,7 @@ static int
nexus_pcib_probe(device_t dev)
{
if (pci_cfgopen() != 0) {
device_add_child(dev, "pci", device_get_unit(dev), 0);
device_add_child(dev, "pci", device_get_unit(dev));
return 0;
}
return ENXIO;

View File

@ -478,7 +478,7 @@ static int
nexus_pcib_probe(device_t dev)
{
if (pci_cfgopen() != 0) {
device_add_child(dev, "pci", device_get_unit(dev), 0);
device_add_child(dev, "pci", device_get_unit(dev));
return 0;
}
return ENXIO;

View File

@ -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);
}
}

View File

@ -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

View File

@ -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

View File

@ -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 */

View File

@ -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);
}
/*

View File

@ -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

View File

@ -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);

View File

@ -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);
}
}

View File

@ -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);
}

View File

@ -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;
}

View File

@ -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);

View File

@ -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);

View File

@ -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;
}

View File

@ -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;

View File

@ -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);
}
}

View File

@ -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);

View File

@ -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);
}

View File

@ -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",

View File

@ -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;

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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));

View File

@ -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);
}
/*

View File

@ -136,7 +136,7 @@ configure(dummy)
#endif /* APIC_IO */
/* nexus0 is the top of the i386 device tree */
device_add_child(root_bus, "nexus", 0, 0);
device_add_child(root_bus, "nexus", 0);
/* initialize new bus architecture */
root_bus_configure();

View File

@ -202,25 +202,26 @@ nexus_attach(device_t dev)
* connection points now so they show up "on motherboard".
*/
if (!devclass_get_device(devclass_find("eisa"), 0)) {
child = device_add_child(dev, "eisa", 0, 0);
child = device_add_child(dev, "eisa", 0);
if (child == NULL)
panic("nexus_attach eisa");
device_probe_and_attach(child);
}
#if NMCA > 0
if (!devclass_get_device(devclass_find("mca"), 0)) {
child = device_add_child(dev, "mca", 0, 0);
child = device_add_child(dev, "mca", 0);
if (child == 0)
panic("nexus_probe mca");
device_probe_and_attach(child);
}
#endif
if (!devclass_get_device(devclass_find("isa"), 0)) {
child = device_add_child(dev, "isa", 0, 0);
child = device_add_child(dev, "isa", 0);
if (child == NULL)
panic("nexus_attach isa");
device_probe_and_attach(child);
}
return 0;
}
@ -238,7 +239,7 @@ nexus_print_child(device_t bus, device_t child)
static device_t
nexus_add_child(device_t bus, int order, const char *name, int unit)
{
return device_add_child_ordered(bus, order, name, unit, 0);
return device_add_child_ordered(bus, order, name, unit);
}
/*

View File

@ -202,25 +202,26 @@ nexus_attach(device_t dev)
* connection points now so they show up "on motherboard".
*/
if (!devclass_get_device(devclass_find("eisa"), 0)) {
child = device_add_child(dev, "eisa", 0, 0);
child = device_add_child(dev, "eisa", 0);
if (child == NULL)
panic("nexus_attach eisa");
device_probe_and_attach(child);
}
#if NMCA > 0
if (!devclass_get_device(devclass_find("mca"), 0)) {
child = device_add_child(dev, "mca", 0, 0);
child = device_add_child(dev, "mca", 0);
if (child == 0)
panic("nexus_probe mca");
device_probe_and_attach(child);
}
#endif
if (!devclass_get_device(devclass_find("isa"), 0)) {
child = device_add_child(dev, "isa", 0, 0);
child = device_add_child(dev, "isa", 0);
if (child == NULL)
panic("nexus_attach isa");
device_probe_and_attach(child);
}
return 0;
}
@ -238,7 +239,7 @@ nexus_print_child(device_t bus, device_t child)
static device_t
nexus_add_child(device_t bus, int order, const char *name, int unit)
{
return device_add_child_ordered(bus, order, name, unit, 0);
return device_add_child_ordered(bus, order, name, unit);
}
/*

View File

@ -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;

View File

@ -478,7 +478,7 @@ static int
nexus_pcib_probe(device_t dev)
{
if (pci_cfgopen() != 0) {
device_add_child(dev, "pci", device_get_unit(dev), 0);
device_add_child(dev, "pci", device_get_unit(dev));
return 0;
}
return ENXIO;

View File

@ -478,7 +478,7 @@ static int
nexus_pcib_probe(device_t dev)
{
if (pci_cfgopen() != 0) {
device_add_child(dev, "pci", device_get_unit(dev), 0);
device_add_child(dev, "pci", device_get_unit(dev));
return 0;
}
return ENXIO;

View File

@ -478,7 +478,7 @@ static int
nexus_pcib_probe(device_t dev)
{
if (pci_cfgopen() != 0) {
device_add_child(dev, "pci", device_get_unit(dev), 0);
device_add_child(dev, "pci", device_get_unit(dev));
return 0;
}
return ENXIO;

View File

@ -478,7 +478,7 @@ static int
nexus_pcib_probe(device_t dev)
{
if (pci_cfgopen() != 0) {
device_add_child(dev, "pci", device_get_unit(dev), 0);
device_add_child(dev, "pci", device_get_unit(dev));
return 0;
}
return ENXIO;

View File

@ -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

View File

@ -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

View File

@ -519,6 +519,7 @@ isa_probe_children(device_t dev)
static device_t
isa_add_child(device_t dev, int order, const char *name, int unit)
{
device_t child;
struct isa_device *idev;
idev = malloc(sizeof(struct isa_device), M_ISADEV, M_NOWAIT);
@ -529,7 +530,10 @@ isa_add_child(device_t dev, int order, const char *name, int unit)
resource_list_init(&idev->id_resources);
TAILQ_INIT(&idev->id_configs);
return device_add_child_ordered(dev, order, name, unit, idev);
child = device_add_child_ordered(dev, order, name, unit);
device_set_ivars(child, idev);
return child;
}
static void

View File

@ -173,7 +173,7 @@ isavga_attach(device_t dev)
(*vidsw[sc->adp->va_index]->diag)(sc->adp, bootverbose);
#if experimental
device_add_child(dev, "fb", -1, NULL);
device_add_child(dev, "fb", -1);
bus_generic_attach(dev);
#endif

View File

@ -581,14 +581,12 @@ devclass_delete_device(devclass_t dc, device_t dev)
}
static device_t
make_device(device_t parent, const char *name,
int unit, void *ivars)
make_device(device_t parent, const char *name, int unit)
{
device_t dev;
devclass_t dc;
PDEBUG(("%s at %s as unit %d with%s ivars",
name, DEVICENAME(parent), unit, (ivars? "":"out")));
PDEBUG(("%s at %s as unit %d", name, DEVICENAME(parent), unit));
if (name) {
dc = devclass_find_internal(name, TRUE);
@ -622,7 +620,7 @@ make_device(device_t parent, const char *name,
dev->flags |= DF_FIXEDCLASS;
devclass_add_device(dc, dev);
}
dev->ivars = ivars;
dev->ivars = NULL;
dev->softc = NULL;
dev->state = DS_NOTPRESENT;
@ -644,22 +642,21 @@ device_print_child(device_t dev, device_t child)
}
device_t
device_add_child(device_t dev, const char *name, int unit, void *ivars)
device_add_child(device_t dev, const char *name, int unit)
{
return device_add_child_ordered(dev, 0, name, unit, ivars);
return device_add_child_ordered(dev, 0, name, unit);
}
device_t
device_add_child_ordered(device_t dev, int order,
const char *name, int unit, void *ivars)
device_add_child_ordered(device_t dev, int order, const char *name, int unit)
{
device_t child;
device_t place;
PDEBUG(("%s at %s with order %d as unit %d with%s ivars",
name, DEVICENAME(dev), order, unit, (ivars? "":"out")));
PDEBUG(("%s at %s with order %d as unit %d",
name, DEVICENAME(dev), order, unit));
child = make_device(dev, name, unit, ivars);
child = make_device(dev, name, unit);
if (child == NULL)
return child;
child->order = order;
@ -984,6 +981,17 @@ device_get_ivars(device_t dev)
return dev->ivars;
}
void
device_set_ivars(device_t dev, void * ivars)
{
if (!dev)
return;
dev->ivars = ivars;
return;
}
device_state_t
device_get_state(device_t dev)
{

View File

@ -964,7 +964,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

View File

@ -964,7 +964,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

View File

@ -366,8 +366,9 @@ allocate_driver(struct slot *slt, struct dev_desc *desc)
bcopy(desc->misc, devi->misc, sizeof(desc->misc));
resource_list_init(&devi->resources);
child = devi->isahd.id_device = device_add_child(pccarddev, devi->name,
desc->unit, devi);
desc->unit);
device_set_flags(child, desc->flags);
device_set_ivars(child, devi);
err = bus_set_resource(child, SYS_RES_IOPORT, 0, desc->iobase,
desc->iosize);
if (err)

View File

@ -512,7 +512,7 @@ pcic_probe(device_t dev)
pcictimeout_ch = timeout(pcictimeout, 0, hz/2);
if (validslots) {
for (i = 0; i < validslots; i++) {
device_add_child(dev, NULL, -1, NULL);
device_add_child(dev, NULL, -1);
}
}
return(validslots ? 0 : ENXIO);

View File

@ -281,7 +281,7 @@ alpm_pci_attach(pcici_t tag, int unit)
printf(" at 0x%x\n", alpm->smbsh);
/* XXX add the I2C interface to the root_bus until pcibus is ready */
device_add_child(root_bus, "alsmb", unit, NULL);
device_add_child(root_bus, "alsmb", unit);
return;
}

View File

@ -711,7 +711,7 @@ intpm_attach(device_t dev)
device_printf(dev,"Failed to map intr\n");
return error;
}
smbinterface=device_add_child(dev,"intsmb",unit,NULL);
smbinterface=device_add_child(dev,"intsmb",unit);
if(!smbinterface){
printf("intsmb%d:could not add SMBus device\n",unit);
}

View File

@ -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;

View File

@ -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);
}
}

View File

@ -779,7 +779,7 @@ static int pcib_attach(device_t dev)
secondary = pci_get_secondarybus(dev);
if (secondary) {
device_add_child(dev, "pci", secondary, 0);
device_add_child(dev, "pci", secondary);
return bus_generic_attach(dev);
} else
return 0;
@ -926,10 +926,10 @@ isab_probe(device_t dev)
*/
device_set_desc_copy(dev, desc);
if (is_eisa && !devclass_get_device(devclass_find("eisa"), 0))
device_add_child(dev, "eisa", -1, 0);
device_add_child(dev, "eisa", -1);
if (!devclass_get_device(devclass_find("isa"), 0))
device_add_child(dev, "isa", -1, 0);
device_add_child(dev, "isa", -1);
return 0;
}
return ENXIO;

View File

@ -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;

View File

@ -222,11 +222,9 @@ void bus_delete_resource(device_t dev, int type, int rid);
/*
* Access functions for device.
*/
device_t device_add_child(device_t dev, const char *name, int unit,
void *ivp);
device_t device_add_child(device_t dev, const char *name, int unit);
device_t device_add_child_ordered(device_t dev, int order,
const char *name, int unit,
void *ivp);
const char *name, int unit);
void device_busy(device_t dev);
int device_delete_child(device_t dev, device_t child);
int device_detach(device_t dev);
@ -241,6 +239,7 @@ u_int32_t device_get_flags(device_t dev);
device_t device_get_parent(device_t dev);
int device_get_children(device_t dev, device_t **listp, int *countp);
void *device_get_ivars(device_t dev);
void device_set_ivars(device_t dev, void *ivars);
const char *device_get_name(device_t dev);
const char *device_get_nameunit(device_t dev);
void *device_get_softc(device_t dev);