summaryrefslogtreecommitdiffstats
path: root/sys/dev
diff options
context:
space:
mode:
authormdodd <mdodd@FreeBSD.org>1999-12-03 08:41:24 +0000
committermdodd <mdodd@FreeBSD.org>1999-12-03 08:41:24 +0000
commit87e31f4b90cff07f3812e55d1980e47ac53a3904 (patch)
tree45f3bb4d1df765c421992403379a9575229036d0 /sys/dev
parentd7c9e9ad5f8564f402794c5a8175fffea1a5376e (diff)
downloadFreeBSD-src-87e31f4b90cff07f3812e55d1980e47ac53a3904.zip
FreeBSD-src-87e31f4b90cff07f3812e55d1980e47ac53a3904.tar.gz
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
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/amr/amr.c3
-rw-r--r--sys/dev/atkbdc/atkbdc_isa.c3
-rw-r--r--sys/dev/atkbdc/atkbdc_subr.c3
-rw-r--r--sys/dev/bktr/bktr_i2c.c4
-rw-r--r--sys/dev/eisa/eisaconf.c4
-rw-r--r--sys/dev/fdc/fdc.c3
-rw-r--r--sys/dev/ida/ida.c2
-rw-r--r--sys/dev/iicbus/iicbus.c4
-rw-r--r--sys/dev/iicbus/iiconf.c2
-rw-r--r--sys/dev/mca/mca_bus.c4
-rw-r--r--sys/dev/mii/mii.c6
-rw-r--r--sys/dev/mlx/mlx.c3
-rw-r--r--sys/dev/pccard/pccard.c2
-rw-r--r--sys/dev/pcf/pcf.c2
-rw-r--r--sys/dev/pci/pci.c4
-rw-r--r--sys/dev/ppbus/lpbb.c4
-rw-r--r--sys/dev/smbus/smbconf.c2
-rw-r--r--sys/dev/smbus/smbus.c4
-rw-r--r--sys/dev/sound/isa/gusc.c17
-rw-r--r--sys/dev/sound/isa/sbc.c10
-rw-r--r--sys/dev/sound/pci/csa.c7
-rw-r--r--sys/dev/usb/ohci_pci.c3
-rw-r--r--sys/dev/usb/uhci_pci.c3
-rw-r--r--sys/dev/usb/usb_subr.c8
24 files changed, 68 insertions, 39 deletions
diff --git a/sys/dev/amr/amr.c b/sys/dev/amr/amr.c
index bdb3c02..d32057b 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 eae6e14..9829f2b 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 eae6e14..9829f2b 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 7cd0ba0..43a5f35 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 d602305..59f553a 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 da131e1..69e9795 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 769205f..ae25391 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 26912fc..45a32d4d 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 52e92f7..1fc07bf 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 f105ea1..a2dd456 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 46cdc22..b3f40e2 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 eccb788..ee099d2 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 ca1748d..39c939c 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 3cb86f7..1aeb7e6 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 efb98d2..b4dd70b 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 bf28807..7d4ba59 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 1d44ef3..1afb7e9 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 1107992..a1d3634 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 93fa250..b6de776 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 8f3a4ee..7e9080e 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 1637143..eebeda6 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 8e1378b..f8c4964 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 9285174..0857f16 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 0aedc62..46c2e8b 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));
OpenPOWER on IntegriCloud