diff options
author | Martin Pieuchot <mpi@cvs.openbsd.org> | 2015-12-11 16:07:03 +0000 |
---|---|---|
committer | Martin Pieuchot <mpi@cvs.openbsd.org> | 2015-12-11 16:07:03 +0000 |
commit | ca6d8af89a72201986473d8cb000d091063097ca (patch) | |
tree | 637cf0fda218c2cec40e1323667040f1761432bc /sys | |
parent | adaf58bdb03df7ca0d5ca5d5f4ff6f89cc946cae (diff) |
Replace mountroothook_establish(9) by config_mountroot(9) a narrower API
similar to config_defer(9).
ok mikeb@, deraadt@
Diffstat (limited to 'sys')
39 files changed, 229 insertions, 254 deletions
diff --git a/sys/arch/hppa/dev/lcd.c b/sys/arch/hppa/dev/lcd.c index ccedccf6363..c8d744b3c30 100644 --- a/sys/arch/hppa/dev/lcd.c +++ b/sys/arch/hppa/dev/lcd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lcd.c,v 1.3 2011/01/23 09:39:15 jsing Exp $ */ +/* $OpenBSD: lcd.c,v 1.4 2015/12/11 16:07:01 mpi Exp $ */ /* * Copyright (c) 2007 Mark Kettenis @@ -56,7 +56,7 @@ struct cfdriver lcd_cd = { NULL, "lcd", DV_DULL }; -void lcd_mountroot(void *); +void lcd_mountroot(struct device *); void lcd_write(struct lcd_softc *, const char *); void lcd_blink(void *, int); void lcd_blink_finish(void *); @@ -86,7 +86,7 @@ lcd_attach(struct device *parent, struct device *self, void *aux) printf(": cannot map cmd register\n"); return; } - + if (bus_space_map(sc->sc_iot, pdc_lcd->data_addr, 1, 0, &sc->sc_datah)) { printf(": cannot map data register\n"); @@ -106,13 +106,13 @@ lcd_attach(struct device *parent, struct device *self, void *aux) sc->sc_blink.bl_arg = sc; blink_led_register(&sc->sc_blink); - mountroothook_establish(lcd_mountroot, sc); + config_mountroot(self, lcd_mountroot); } void -lcd_mountroot(void *arg) +lcd_mountroot(struct device *self) { - struct lcd_softc *sc = arg; + struct lcd_softc *sc = (struct lcd_softc *)self; bus_space_write_1(sc->sc_iot, sc->sc_cmdh, 0, LCD_CLS); delay(100 * sc->sc_delay); diff --git a/sys/arch/sparc64/dev/creator.c b/sys/arch/sparc64/dev/creator.c index f8ec0530d81..633a9f0c3a6 100644 --- a/sys/arch/sparc64/dev/creator.c +++ b/sys/arch/sparc64/dev/creator.c @@ -1,4 +1,4 @@ -/* $OpenBSD: creator.c,v 1.49 2015/01/26 20:25:38 miod Exp $ */ +/* $OpenBSD: creator.c,v 1.50 2015/12/11 16:07:01 mpi Exp $ */ /* * Copyright (c) 2002 Jason L. Wright (jason@thought.net) @@ -65,7 +65,7 @@ int creator_updatecursor(struct creator_softc *, u_int); void creator_curs_enable(struct creator_softc *, u_int); #ifndef SMALL_KERNEL -void creator_load_firmware(void *); +void creator_load_firmware(struct device *); #endif /* SMALL_KERNEL */ void creator_load_sram(struct creator_softc *, u_int32_t *, u_int32_t); @@ -200,8 +200,8 @@ creator_attach(parent, self, aux) * without it though, so doing this late should be * fine. */ - if (sc->sc_type == FFB_AFB) - mountroothook_establish(creator_load_firmware, sc); + if (sc->sc_type == FFB_AFB) + config_mountroot(self, creator_load_firmware); #endif /* SMALL_KERNEL */ } @@ -744,9 +744,9 @@ struct creator_firmware { #define CREATOR_FIRMWARE_REV 0x101 void -creator_load_firmware(void *vsc) +creator_load_firmware(struct device *self) { - struct creator_softc *sc = vsc; + struct creator_softc *sc = (struct creator_softc *)self; struct creator_firmware *fw; u_int32_t ascr; size_t buflen; diff --git a/sys/dev/cardbus/if_pgt_cardbus.c b/sys/dev/cardbus/if_pgt_cardbus.c index 653f9ce6c43..5c8d4ca0885 100644 --- a/sys/dev/cardbus/if_pgt_cardbus.c +++ b/sys/dev/cardbus/if_pgt_cardbus.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_pgt_cardbus.c,v 1.17 2015/11/24 17:11:39 mpi Exp $ */ +/* $OpenBSD: if_pgt_cardbus.c,v 1.18 2015/12/11 16:07:01 mpi Exp $ */ /* * Copyright (c) 2006 Marcus Glocker <mglocker@openbsd.org> @@ -136,10 +136,7 @@ pgt_cardbus_attach(struct device *parent, struct device *self, void *aux) printf(": irq %d\n", csc->sc_intrline); - if (rootvp == NULL) - mountroothook_establish(pgt_attach, sc); - else - pgt_attach(sc); + config_mountroot(self, pgt_attach); } int diff --git a/sys/dev/ic/pgt.c b/sys/dev/ic/pgt.c index 2460c2643af..26fcc9474c7 100644 --- a/sys/dev/ic/pgt.c +++ b/sys/dev/ic/pgt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pgt.c,v 1.84 2015/11/25 03:09:58 dlg Exp $ */ +/* $OpenBSD: pgt.c,v 1.85 2015/12/11 16:07:01 mpi Exp $ */ /* * Copyright (c) 2006 Claudio Jeker <claudio@openbsd.org> @@ -554,9 +554,9 @@ trying_again: } void -pgt_attach(void *xsc) +pgt_attach(struct device *self) { - struct pgt_softc *sc = xsc; + struct pgt_softc *sc = (struct pgt_softc *)self; int error; /* debug flags */ diff --git a/sys/dev/ic/pgtvar.h b/sys/dev/ic/pgtvar.h index e598c363d49..d20923afc8b 100644 --- a/sys/dev/ic/pgtvar.h +++ b/sys/dev/ic/pgtvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pgtvar.h,v 1.16 2013/12/06 21:03:03 deraadt Exp $ */ +/* $OpenBSD: pgtvar.h,v 1.17 2015/12/11 16:07:01 mpi Exp $ */ /* * Copyright (c) 2006 Claudio Jeker <claudio@openbsd.org> @@ -211,7 +211,7 @@ struct pgt_softc { }; int pgt_intr(void *); -void pgt_attach(void *); +void pgt_attach(struct device *); int pgt_detach(struct pgt_softc *); int pgt_activate(struct device *, int); diff --git a/sys/dev/ic/rt2661.c b/sys/dev/ic/rt2661.c index 15656768762..1444e492418 100644 --- a/sys/dev/ic/rt2661.c +++ b/sys/dev/ic/rt2661.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rt2661.c,v 1.88 2015/11/25 03:09:58 dlg Exp $ */ +/* $OpenBSD: rt2661.c,v 1.89 2015/12/11 16:07:01 mpi Exp $ */ /*- * Copyright (c) 2006 @@ -69,7 +69,7 @@ int rt2661_debug = 1; #define DPRINTFN(n, x) #endif -void rt2661_attachhook(void *); +void rt2661_attachhook(struct device *); int rt2661_alloc_tx_ring(struct rt2661_softc *, struct rt2661_tx_ring *, int); void rt2661_reset_tx_ring(struct rt2661_softc *, @@ -248,10 +248,7 @@ rt2661_attach(void *xsc, int id) goto fail2; } - if (rootvp == NULL) - mountroothook_establish(rt2661_attachhook, sc); - else - rt2661_attachhook(sc); + config_mountroot(xsc, rt2661_attachhook); return 0; @@ -262,9 +259,9 @@ fail1: while (--ac >= 0) } void -rt2661_attachhook(void *xsc) +rt2661_attachhook(struct device *self) { - struct rt2661_softc *sc = xsc; + struct rt2661_softc *sc = (struct rt2661_softc *)self; struct ieee80211com *ic = &sc->sc_ic; struct ifnet *ifp = &ic->ic_if; const char *name = NULL; diff --git a/sys/dev/ic/rt2860.c b/sys/dev/ic/rt2860.c index 2d16c80e4de..71f79efa6f4 100644 --- a/sys/dev/ic/rt2860.c +++ b/sys/dev/ic/rt2860.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rt2860.c,v 1.85 2015/11/25 03:09:58 dlg Exp $ */ +/* $OpenBSD: rt2860.c,v 1.86 2015/12/11 16:07:01 mpi Exp $ */ /*- * Copyright (c) 2007-2010 Damien Bergamini <damien.bergamini@free.fr> @@ -67,7 +67,7 @@ int rt2860_debug = 0; #define DPRINTFN(n, x) #endif -void rt2860_attachhook(void *); +void rt2860_attachhook(struct device *); int rt2860_alloc_tx_ring(struct rt2860_softc *, struct rt2860_tx_ring *); void rt2860_reset_tx_ring(struct rt2860_softc *, @@ -258,10 +258,7 @@ rt2860_attach(void *xsc, int id) sc->mgtqid = (sc->mac_ver == 0x2860 && sc->mac_rev == 0x0100) ? EDCA_AC_VO : 5; - if (rootvp == NULL) - mountroothook_establish(rt2860_attachhook, sc); - else - rt2860_attachhook(sc); + config_mountroot(xsc, rt2860_attachhook); return 0; @@ -272,9 +269,9 @@ fail1: while (--qid >= 0) } void -rt2860_attachhook(void *xsc) +rt2860_attachhook(struct device *self) { - struct rt2860_softc *sc = xsc; + struct rt2860_softc *sc = (struct rt2860_softc *)self; struct ieee80211com *ic = &sc->sc_ic; struct ifnet *ifp = &ic->ic_if; int i, error; diff --git a/sys/dev/pci/auixp.c b/sys/dev/pci/auixp.c index 299d260e4c8..4207cac6cef 100644 --- a/sys/dev/pci/auixp.c +++ b/sys/dev/pci/auixp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: auixp.c,v 1.35 2015/05/11 06:46:21 ratchov Exp $ */ +/* $OpenBSD: auixp.c,v 1.36 2015/12/11 16:07:01 mpi Exp $ */ /* $NetBSD: auixp.c,v 1.9 2005/06/27 21:13:09 thorpej Exp $ */ /* @@ -139,7 +139,7 @@ void auixp_get_default_params(void *, int, struct audio_params *); /* Supporting subroutines */ int auixp_init(struct auixp_softc *); void auixp_autodetect_codecs(struct auixp_softc *); -void auixp_post_config(void *); +void auixp_post_config(struct device *); void auixp_reset_aclink(struct auixp_softc *); int auixp_attach_codec(void *, struct ac97_codec_if *); @@ -1114,16 +1114,15 @@ auixp_attach(struct device *parent, struct device *self, void *aux) * delay further configuration of codecs and audio after interrupts * are enabled. */ - mountroothook_establish(auixp_post_config, self); + config_mountroot(self, auixp_post_config); } /* called from autoconfigure system when interrupts are enabled */ void -auixp_post_config(void *self) +auixp_post_config(struct device *self) { - struct auixp_softc *sc; + struct auixp_softc *sc = (struct auixp_softc *)self; - sc = (struct auixp_softc *)self; /* detect the AC97 codecs */ auixp_autodetect_codecs(sc); diff --git a/sys/dev/pci/cs4280.c b/sys/dev/pci/cs4280.c index 8a4cf871614..8f6e6cf688b 100644 --- a/sys/dev/pci/cs4280.c +++ b/sys/dev/pci/cs4280.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cs4280.c,v 1.47 2015/05/11 06:46:22 ratchov Exp $ */ +/* $OpenBSD: cs4280.c,v 1.48 2015/12/11 16:07:01 mpi Exp $ */ /* $NetBSD: cs4280.c,v 1.5 2000/06/26 04:56:23 simonb Exp $ */ /* @@ -165,7 +165,7 @@ struct cs4280_softc { int cs4280_match(struct device *, void *, void *); void cs4280_attach(struct device *, struct device *, void *); int cs4280_activate(struct device *, int); -void cs4280_attachhook(void *xsc); +void cs4280_attachhook(struct device *); int cs4280_intr(void *); void cs4280_reset(void *); int cs4280_download_image(struct cs4280_softc *); @@ -539,9 +539,9 @@ cs4280_set_dac_rate(struct cs4280_softc *sc, int rate) } void -cs4280_attachhook(void *xsc) +cs4280_attachhook(struct device *self) { - struct cs4280_softc *sc = xsc; + struct cs4280_softc *sc = (struct cs4280_softc *)self; mixer_ctrl_t ctl; /* Initialization */ @@ -565,7 +565,7 @@ cs4280_attachhook(void *xsc) ctl.dev = cs4280_get_portnum_by_name(sc, AudioCinputs, AudioNcd, AudioNmute); cs4280_mixer_set_port(sc, &ctl); - + audio_attach_mi(&cs4280_hw_if, sc, &sc->sc_dev); #if NMIDI > 0 @@ -632,7 +632,7 @@ cs4280_attach(struct device *parent, struct device *self, void *aux) if (cs4280_init(sc, 1) != 0) return; - mountroothook_establish(cs4280_attachhook, sc); + config_mountroot(self, cs4280_attachhook); /* AC 97 attachement */ sc->host_if.arg = sc; diff --git a/sys/dev/pci/drm/radeon/radeon_kms.c b/sys/dev/pci/drm/radeon/radeon_kms.c index 4737c19754a..890e75956fa 100644 --- a/sys/dev/pci/drm/radeon/radeon_kms.c +++ b/sys/dev/pci/drm/radeon/radeon_kms.c @@ -1,4 +1,4 @@ -/* $OpenBSD: radeon_kms.c,v 1.44 2015/11/22 15:35:49 kettenis Exp $ */ +/* $OpenBSD: radeon_kms.c,v 1.45 2015/12/11 16:07:02 mpi Exp $ */ /* * Copyright 2008 Advanced Micro Devices, Inc. * Copyright 2008 Red Hat Inc. @@ -106,7 +106,7 @@ int radeondrm_probe(struct device *, void *, void *); void radeondrm_attach_kms(struct device *, struct device *, void *); int radeondrm_detach_kms(struct device *, int); int radeondrm_activate_kms(struct device *, int); -void radeondrm_attachhook(void *); +void radeondrm_attachhook(struct device *); int radeondrm_forcedetach(struct radeon_device *); extern struct drm_ioctl_desc radeon_ioctls_kms[]; @@ -646,10 +646,7 @@ radeondrm_attach_kms(struct device *parent, struct device *self, void *aux) #endif rdev->shutdown = true; - if (rootvp == NULL) - mountroothook_establish(radeondrm_attachhook, rdev); - else - radeondrm_attachhook(rdev); + config_mountroot(self, radeondrm_attachhook); } int @@ -668,9 +665,9 @@ radeondrm_forcedetach(struct radeon_device *rdev) } void -radeondrm_attachhook(void *xsc) +radeondrm_attachhook(struct device *self) { - struct radeon_device *rdev = xsc; + struct radeon_device *rdev = (struct radeon_device *)self; int r, acpi_status; /* radeon_device_init should report only fatal error diff --git a/sys/dev/pci/if_bnx.c b/sys/dev/pci/if_bnx.c index 8250c9b10b5..52e2efe2473 100644 --- a/sys/dev/pci/if_bnx.c +++ b/sys/dev/pci/if_bnx.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_bnx.c,v 1.119 2015/12/10 12:24:27 dlg Exp $ */ +/* $OpenBSD: if_bnx.c,v 1.120 2015/12/11 16:07:01 mpi Exp $ */ /*- * Copyright (c) 2006 Broadcom Corporation @@ -274,7 +274,7 @@ static struct flash_spec flash_5709 = { /****************************************************************************/ int bnx_probe(struct device *, void *, void *); void bnx_attach(struct device *, struct device *, void *); -void bnx_attachhook(void *); +void bnx_attachhook(struct device *); int bnx_read_firmware(struct bnx_softc *sc, int); int bnx_read_rv2p(struct bnx_softc *sc, int); #if 0 @@ -753,7 +753,7 @@ bnx_attach(struct device *parent, struct device *self, void *aux) printf(": %s\n", intrstr); - mountroothook_establish(bnx_attachhook, sc); + config_mountroot(self, bnx_attachhook); return; bnx_attach_fail: @@ -762,9 +762,9 @@ bnx_attach_fail: } void -bnx_attachhook(void *xsc) +bnx_attachhook(struct device *self) { - struct bnx_softc *sc = xsc; + struct bnx_softc *sc = (struct bnx_softc *)self; struct pci_attach_args *pa = &sc->bnx_pa; struct ifnet *ifp; int error, mii_flags = 0; diff --git a/sys/dev/pci/if_iwm.c b/sys/dev/pci/if_iwm.c index fcfc69a13ec..0511da53828 100644 --- a/sys/dev/pci/if_iwm.c +++ b/sys/dev/pci/if_iwm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_iwm.c,v 1.69 2015/12/08 17:10:02 stsp Exp $ */ +/* $OpenBSD: if_iwm.c,v 1.70 2015/12/11 16:07:02 mpi Exp $ */ /* * Copyright (c) 2014 genua mbh <info@genua.de> @@ -410,7 +410,7 @@ void iwm_notif_intr(struct iwm_softc *); int iwm_intr(void *); int iwm_match(struct device *, void *, void *); int iwm_preinit(struct iwm_softc *); -void iwm_attach_hook(void *); +void iwm_attach_hook(struct device *); void iwm_attach(struct device *, struct device *, void *); void iwm_init_task(void *); int iwm_activate(struct device *, int); @@ -6340,9 +6340,9 @@ iwm_preinit(struct iwm_softc *sc) } void -iwm_attach_hook(void *arg) +iwm_attach_hook(struct device *self) { - struct iwm_softc *sc = arg; + struct iwm_softc *sc = (void *)self; KASSERT(!cold); @@ -6560,10 +6560,7 @@ iwm_attach(struct device *parent, struct device *self, void *aux) * We cannot read the MAC address without loading the * firmware from disk. Postpone until mountroot is done. */ - if (rootvp == NULL) - mountroothook_establish(iwm_attach_hook, sc); - else - iwm_attach_hook(sc); + config_mountroot(self, iwm_attach_hook); return; diff --git a/sys/dev/pci/if_myx.c b/sys/dev/pci/if_myx.c index 56239c5c30f..d88dbfb47ba 100644 --- a/sys/dev/pci/if_myx.c +++ b/sys/dev/pci/if_myx.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_myx.c,v 1.91 2015/12/09 03:22:39 dlg Exp $ */ +/* $OpenBSD: if_myx.c,v 1.92 2015/12/11 16:07:02 mpi Exp $ */ /* * Copyright (c) 2007 Reyk Floeter <reyk@openbsd.org> @@ -166,7 +166,7 @@ void myx_attach(struct device *, struct device *, void *); int myx_pcie_dc(struct myx_softc *, struct pci_attach_args *); int myx_query(struct myx_softc *sc, char *, size_t); u_int myx_ether_aton(char *, u_int8_t *, u_int); -void myx_attachhook(void *); +void myx_attachhook(struct device *); int myx_loadfirmware(struct myx_softc *, const char *); int myx_probe_firmware(struct myx_softc *); @@ -311,10 +311,7 @@ myx_attach(struct device *parent, struct device *self, void *aux) if (myx_pcie_dc(sc, pa) != 0) printf("%s: unable to configure PCI Express\n", DEVNAME(sc)); - if (mountroothook_establish(myx_attachhook, sc) == NULL) { - printf("%s: unable to establish mountroot hook\n", DEVNAME(sc)); - goto unmap; - } + config_mountroot(self, myx_attachhook); return; @@ -468,9 +465,9 @@ err: } void -myx_attachhook(void *arg) +myx_attachhook(struct device *self) { - struct myx_softc *sc = (struct myx_softc *)arg; + struct myx_softc *sc = (struct myx_softc *)self; struct ifnet *ifp = &sc->sc_ac.ac_if; struct myx_cmd mc; diff --git a/sys/dev/pci/if_nxe.c b/sys/dev/pci/if_nxe.c index 63c4b3ea385..cf7c7c5bcf6 100644 --- a/sys/dev/pci/if_nxe.c +++ b/sys/dev/pci/if_nxe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_nxe.c,v 1.71 2015/11/25 03:09:59 dlg Exp $ */ +/* $OpenBSD: if_nxe.c,v 1.72 2015/12/11 16:07:02 mpi Exp $ */ /* * Copyright (c) 2007 David Gwynne <dlg@openbsd.org> @@ -750,7 +750,7 @@ int nxe_board_info(struct nxe_softc *); int nxe_user_info(struct nxe_softc *); int nxe_init(struct nxe_softc *); void nxe_uninit(struct nxe_softc *); -void nxe_mountroot(void *); +void nxe_mountroot(struct device *); /* chip state */ void nxe_tick(void *); @@ -972,7 +972,7 @@ nxe_pci_map(struct nxe_softc *sc, struct pci_attach_args *pa) goto unmap_mem; } - mountroothook_establish(nxe_mountroot, sc); + config_mountroot(&sc->sc_dev, nxe_mountroot); return (0); unmap_mem: @@ -1765,9 +1765,9 @@ nxe_uninit(struct nxe_softc *sc) } void -nxe_mountroot(void *arg) +nxe_mountroot(struct device *self) { - struct nxe_softc *sc = arg; + struct nxe_softc *sc = (struct nxe_softc *)self; DASSERT(sc->sc_window == 1); diff --git a/sys/dev/pci/if_oce.c b/sys/dev/pci/if_oce.c index bff7f2b6d33..edaca26e61d 100644 --- a/sys/dev/pci/if_oce.c +++ b/sys/dev/pci/if_oce.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_oce.c,v 1.90 2015/11/25 03:09:59 dlg Exp $ */ +/* $OpenBSD: if_oce.c,v 1.91 2015/12/11 16:07:02 mpi Exp $ */ /* * Copyright (c) 2012 Mike Belopuhov @@ -365,7 +365,7 @@ struct oce_softc { int oce_match(struct device *, void *, void *); void oce_attach(struct device *, struct device *, void *); int oce_pci_alloc(struct oce_softc *, struct pci_attach_args *); -void oce_attachhook(void *); +void oce_attachhook(struct device *); void oce_attach_ifp(struct oce_softc *); int oce_ioctl(struct ifnet *, u_long, caddr_t); int oce_rxrinfo(struct oce_softc *, struct if_rxrinfo *); @@ -621,7 +621,7 @@ oce_attach(struct device *parent, struct device *self, void *aux) timeout_set(&sc->sc_tick, oce_tick, sc); timeout_set(&sc->sc_rxrefill, oce_refill_rx, sc); - mountroothook_establish(oce_attachhook, sc); + config_mountroot(self, oce_attachhook); printf(", address %s\n", ether_sprintf(sc->sc_ac.ac_enaddr)); @@ -779,9 +779,9 @@ oce_intr_disable(struct oce_softc *sc) } void -oce_attachhook(void *arg) +oce_attachhook(struct device *self) { - struct oce_softc *sc = arg; + struct oce_softc *sc = (struct oce_softc *)self; oce_get_link_status(sc); diff --git a/sys/dev/pci/if_pgt_pci.c b/sys/dev/pci/if_pgt_pci.c index 8c6f71f2f1c..de05789deae 100644 --- a/sys/dev/pci/if_pgt_pci.c +++ b/sys/dev/pci/if_pgt_pci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_pgt_pci.c,v 1.17 2015/11/24 17:11:39 mpi Exp $ */ +/* $OpenBSD: if_pgt_pci.c,v 1.18 2015/12/11 16:07:02 mpi Exp $ */ /* * Copyright (c) 2006 Marcus Glocker <mglocker@openbsd.org> @@ -133,10 +133,7 @@ pgt_pci_attach(struct device *parent, struct device *self, void *aux) } printf(": %s\n", intrstr); - if (rootvp == NULL) - mountroothook_establish(pgt_attach, sc); - else - pgt_attach(sc); + config_mountroot(self, pgt_attach); } int diff --git a/sys/dev/pci/if_tht.c b/sys/dev/pci/if_tht.c index e2473a2735e..6f42954cd01 100644 --- a/sys/dev/pci/if_tht.c +++ b/sys/dev/pci/if_tht.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_tht.c,v 1.137 2015/11/25 03:09:59 dlg Exp $ */ +/* $OpenBSD: if_tht.c,v 1.138 2015/12/11 16:07:02 mpi Exp $ */ /* * Copyright (c) 2007 David Gwynne <dlg@openbsd.org> @@ -498,7 +498,7 @@ struct tht_softc { int tht_match(struct device *, void *, void *); void tht_attach(struct device *, struct device *, void *); -void tht_mountroot(void *); +void tht_mountroot(struct device *); int tht_intr(void *); struct cfattach tht_ca = { @@ -794,13 +794,13 @@ tht_attach(struct device *parent, struct device *self, void *aux) printf(": address %s\n", ether_sprintf(sc->sc_ac.ac_enaddr)); - mountroothook_establish(tht_mountroot, sc); + config_mountroot(self, tht_mountroot); } void -tht_mountroot(void *arg) +tht_mountroot(struct device *self) { - struct tht_softc *sc = arg; + struct tht_softc *sc = (struct tht_softc *)self; if (tht_fifo_alloc(sc, &sc->sc_txt, &tht_txt_desc) != 0) return; diff --git a/sys/dev/pci/if_txp.c b/sys/dev/pci/if_txp.c index 6f9584b5726..bfd1d6e5a36 100644 --- a/sys/dev/pci/if_txp.c +++ b/sys/dev/pci/if_txp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_txp.c,v 1.122 2015/11/25 03:09:59 dlg Exp $ */ +/* $OpenBSD: if_txp.c,v 1.123 2015/12/11 16:07:02 mpi Exp $ */ /* * Copyright (c) 2001 @@ -73,7 +73,7 @@ int txp_probe(struct device *, void *, void *); void txp_attach(struct device *, struct device *, void *); -void txp_attachhook(void *vsc); +void txp_attachhook(struct device *); int txp_intr(void *); void txp_tick(void *); int txp_ioctl(struct ifnet *, u_long, caddr_t); @@ -142,9 +142,9 @@ txp_probe(struct device *parent, void *match, void *aux) } void -txp_attachhook(void *vsc) +txp_attachhook(struct device *self) { - struct txp_softc *sc = vsc; + struct txp_softc *sc = (struct txp_softc *)self; struct ifnet *ifp = &sc->sc_arpcom.ac_if; u_int16_t p1; u_int32_t p2; @@ -270,10 +270,7 @@ txp_attach(struct device *parent, struct device *self, void *aux) } printf(": %s\n", intrstr); - if (rootvp == NULL) - mountroothook_establish(txp_attachhook, sc); - else - txp_attachhook(sc); + config_mountroot(self, txp_attachhook); } diff --git a/sys/dev/pci/yds.c b/sys/dev/pci/yds.c index 212d917bb8b..04f763beb3f 100644 --- a/sys/dev/pci/yds.c +++ b/sys/dev/pci/yds.c @@ -1,4 +1,4 @@ -/* $OpenBSD: yds.c,v 1.51 2015/09/10 18:10:34 deraadt Exp $ */ +/* $OpenBSD: yds.c,v 1.52 2015/12/11 16:07:02 mpi Exp $ */ /* $NetBSD: yds.c,v 1.5 2001/05/21 23:55:04 minoura Exp $ */ /* @@ -193,7 +193,7 @@ static u_int32_t yds_get_lpfk(u_int); static struct yds_dma *yds_find_dma(struct yds_softc *, void *); int yds_init(struct yds_softc *, int); -void yds_attachhook(void *); +void yds_attachhook(struct device *); #ifdef AUDIO_DEBUG static void yds_dump_play_slot(struct yds_softc *, int); @@ -720,17 +720,17 @@ yds_attach(struct device *parent, struct device *self, void *aux) YWRITE2(sc, i, 0); sc->sc_legacy_iot = pa->pa_iot; - mountroothook_establish(yds_attachhook, sc); + config_mountroot(self, yds_attachhook); } void -yds_attachhook(void *xsc) +yds_attachhook(struct device *self) { - struct yds_softc *sc = xsc; + struct yds_softc *sc = (struct yds_softc *)self; struct yds_codec_softc *codec; mixer_ctrl_t ctl; int r, i; - + /* Initialize the device */ if (yds_init(sc, 0) == -1) return; diff --git a/sys/dev/pcmcia/if_malo.c b/sys/dev/pcmcia/if_malo.c index 1223001a4ad..42f66c59579 100644 --- a/sys/dev/pcmcia/if_malo.c +++ b/sys/dev/pcmcia/if_malo.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_malo.c,v 1.89 2015/11/25 03:09:59 dlg Exp $ */ +/* $OpenBSD: if_malo.c,v 1.90 2015/12/11 16:07:02 mpi Exp $ */ /* * Copyright (c) 2007 Marcus Glocker <mglocker@openbsd.org> @@ -70,7 +70,7 @@ int malo_pcmcia_detach(struct device *, int); int malo_pcmcia_activate(struct device *, int); void malo_pcmcia_wakeup(struct malo_softc *); -void cmalo_attach(void *); +void cmalo_attach(struct device *); int cmalo_ioctl(struct ifnet *, u_long, caddr_t); int cmalo_fw_alloc(struct malo_softc *); void cmalo_fw_free(struct malo_softc *); @@ -206,11 +206,7 @@ malo_pcmcia_attach(struct device *parent, struct device *self, void *aux) } printf("\n"); - /* attach device */ - if (rootvp == NULL) - mountroothook_establish(cmalo_attach, sc); - else - cmalo_attach(sc); + config_mountroot(self, cmalo_attach); } int @@ -289,9 +285,9 @@ malo_pcmcia_wakeup(struct malo_softc *sc) * Driver. */ void -cmalo_attach(void *arg) +cmalo_attach(struct device *self) { - struct malo_softc *sc = arg; + struct malo_softc *sc = (struct malo_softc *)self; struct ieee80211com *ic = &sc->sc_ic; struct ifnet *ifp = &sc->sc_ic.ic_if; int i; diff --git a/sys/dev/pv/vmt.c b/sys/dev/pv/vmt.c index bf51cb1e39d..da383ae185e 100644 --- a/sys/dev/pv/vmt.c +++ b/sys/dev/pv/vmt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vmt.c,v 1.5 2015/08/27 19:51:36 deraadt Exp $ */ +/* $OpenBSD: vmt.c,v 1.6 2015/12/11 16:07:01 mpi Exp $ */ /* * Copyright (c) 2007 David Crawshaw <david@zentus.com> @@ -365,7 +365,7 @@ vmt_attach(struct device *parent, struct device *self, void *aux) sensordev_install(&sc->sc_sensordev); timeout_set(&sc->sc_tick, vmt_tick, sc); - if (mountroothook_establish(vmt_tick, sc) == NULL) + if (startuphook_establish(vmt_tick, sc) == NULL) DPRINTF("%s: unable to establish tick\n", DEVNAME(sc)); timeout_set(&sc->sc_tclo_tick, vmt_tclo_tick, sc); diff --git a/sys/dev/pv/xen.c b/sys/dev/pv/xen.c index 1819d0b707d..5806ba36725 100644 --- a/sys/dev/pv/xen.c +++ b/sys/dev/pv/xen.c @@ -45,7 +45,7 @@ void xen_disable_emulated_devices(struct xen_softc *); int xen_match(struct device *, void *, void *); void xen_attach(struct device *, struct device *, void *); -void xen_deferred(void *); +void xen_deferred(struct device *); void xen_resume(struct device *); int xen_activate(struct device *, int); int xen_probe_devices(struct xen_softc *); @@ -109,13 +109,13 @@ xen_attach(struct device *parent, struct device *self, void *aux) xen_probe_devices(sc); - mountroothook_establish(xen_deferred, sc); + config_mountroot(self, xen_deferred); } void -xen_deferred(void *arg) +xen_deferred(struct device *self) { - struct xen_softc *sc = arg; + struct xen_softc *sc = (struct xen_softc *)self; if (!sc->sc_cbvec) { DPRINTF("%s: callback vector hasn't been established\n", diff --git a/sys/dev/usb/if_athn_usb.c b/sys/dev/usb/if_athn_usb.c index e099cf3fd02..987095a7017 100644 --- a/sys/dev/usb/if_athn_usb.c +++ b/sys/dev/usb/if_athn_usb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_athn_usb.c,v 1.41 2015/11/25 03:09:59 dlg Exp $ */ +/* $OpenBSD: if_athn_usb.c,v 1.42 2015/12/11 16:07:02 mpi Exp $ */ /*- * Copyright (c) 2011 Damien Bergamini <damien.bergamini@free.fr> @@ -96,7 +96,7 @@ static const struct athn_usb_type { int athn_usb_match(struct device *, void *, void *); void athn_usb_attach(struct device *, struct device *, void *); int athn_usb_detach(struct device *, int); -void athn_usb_attachhook(void *); +void athn_usb_attachhook(struct device *); int athn_usb_open_pipes(struct athn_usb_softc *); void athn_usb_close_pipes(struct athn_usb_softc *); int athn_usb_alloc_rx_list(struct athn_usb_softc *); @@ -256,10 +256,7 @@ athn_usb_attach(struct device *parent, struct device *self, void *aux) if (athn_usb_alloc_tx_cmd(usc) != 0) return; - if (rootvp == NULL) - mountroothook_establish(athn_usb_attachhook, usc); - else - athn_usb_attachhook(usc); + config_mountroot(self, athn_usb_attachhook); } int @@ -288,9 +285,9 @@ athn_usb_detach(struct device *self, int flags) } void -athn_usb_attachhook(void *xsc) +athn_usb_attachhook(struct device *self) { - struct athn_usb_softc *usc = xsc; + struct athn_usb_softc *usc = (struct athn_usb_softc *)self; struct athn_softc *sc = &usc->sc_sc; struct athn_ops *ops = &sc->ops; struct ieee80211com *ic = &sc->sc_ic; diff --git a/sys/dev/usb/if_atu.c b/sys/dev/usb/if_atu.c index dcd6d754264..9f02c0426d8 100644 --- a/sys/dev/usb/if_atu.c +++ b/sys/dev/usb/if_atu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_atu.c,v 1.116 2015/11/25 03:09:59 dlg Exp $ */ +/* $OpenBSD: if_atu.c,v 1.117 2015/12/11 16:07:02 mpi Exp $ */ /* * Copyright (c) 2003, 2004 * Daan Vreeken <Danovitsch@Vitsch.net>. All rights reserved. @@ -267,8 +267,8 @@ int atu_initial_config(struct atu_softc *sc); int atu_join(struct atu_softc *sc, struct ieee80211_node *node); int8_t atu_get_dfu_state(struct atu_softc *sc); u_int8_t atu_get_opmode(struct atu_softc *sc, u_int8_t *mode); -void atu_internal_firmware(void *); -void atu_external_firmware(void *); +void atu_internal_firmware(struct device *); +void atu_external_firmware(struct device *); int atu_get_card_config(struct atu_softc *sc); int atu_media_change(struct ifnet *ifp); void atu_media_status(struct ifnet *ifp, struct ifmediareq *req); @@ -852,9 +852,9 @@ atu_get_opmode(struct atu_softc *sc, u_int8_t *mode) * Upload the internal firmware into the device */ void -atu_internal_firmware(void *arg) +atu_internal_firmware(struct device *self) { - struct atu_softc *sc = arg; + struct atu_softc *sc = (struct atu_softc *)self; u_char state, *ptr = NULL, *firm = NULL, status[6]; int block_size, block = 0, err, i; size_t bytes_left = 0; @@ -983,9 +983,9 @@ fail: } void -atu_external_firmware(void *arg) +atu_external_firmware(struct device *self) { - struct atu_softc *sc = arg; + struct atu_softc *sc = (struct atu_softc *)self; u_char *ptr = NULL, *firm = NULL; int block_size, block = 0, err, i; size_t bytes_left = 0; @@ -1297,10 +1297,7 @@ atu_attach(struct device *parent, struct device *self, void *aux) DPRINTF(("%s: starting internal firmware download\n", sc->atu_dev.dv_xname)); - if (rootvp == NULL) - mountroothook_establish(atu_internal_firmware, sc); - else - atu_internal_firmware(sc); + config_mountroot(self, atu_internal_firmware); /* * atu_internal_firmware will cause a reset of the device * so we don't want to do any more configuration after this @@ -1337,10 +1334,7 @@ atu_attach(struct device *parent, struct device *self, void *aux) } } - if (rootvp == NULL) - mountroothook_establish(atu_external_firmware, sc); - else - atu_external_firmware(sc); + config_mountroot(self, atu_external_firmware); /* * atu_external_firmware will call atu_complete_attach after diff --git a/sys/dev/usb/if_kue.c b/sys/dev/usb/if_kue.c index abed32c9652..ead3fa4bc67 100644 --- a/sys/dev/usb/if_kue.c +++ b/sys/dev/usb/if_kue.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_kue.c,v 1.83 2015/11/25 03:10:00 dlg Exp $ */ +/* $OpenBSD: if_kue.c,v 1.84 2015/12/11 16:07:02 mpi Exp $ */ /* $NetBSD: if_kue.c,v 1.50 2002/07/16 22:00:31 augustss Exp $ */ /* * Copyright (c) 1997, 1998, 1999, 2000 @@ -178,7 +178,7 @@ usbd_status kue_ctl(struct kue_softc *, int, u_int8_t, u_int16_t, void *, u_int32_t); usbd_status kue_setword(struct kue_softc *, u_int8_t, u_int16_t); int kue_load_fw(struct kue_softc *); -void kue_attachhook(void *); +void kue_attachhook(struct device *); usbd_status kue_setword(struct kue_softc *sc, u_int8_t breq, u_int16_t word) @@ -399,9 +399,9 @@ kue_match(struct device *parent, void *match, void *aux) } void -kue_attachhook(void *xsc) +kue_attachhook(struct device *self) { - struct kue_softc *sc = xsc; + struct kue_softc *sc = (struct kue_softc *)self; int s; struct ifnet *ifp; struct usbd_device *dev = sc->kue_udev; @@ -526,10 +526,7 @@ kue_attach(struct device *parent, struct device *self, void *aux) sc->kue_product = uaa->product; sc->kue_vendor = uaa->vendor; - if (rootvp == NULL) - mountroothook_establish(kue_attachhook, sc); - else - kue_attachhook(sc); + config_mountroot(self, kue_attachhook); } int diff --git a/sys/dev/usb/if_otus.c b/sys/dev/usb/if_otus.c index d978d70f520..eb96fdc0048 100644 --- a/sys/dev/usb/if_otus.c +++ b/sys/dev/usb/if_otus.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_otus.c,v 1.51 2015/11/25 03:10:00 dlg Exp $ */ +/* $OpenBSD: if_otus.c,v 1.52 2015/12/11 16:07:02 mpi Exp $ */ /*- * Copyright (c) 2009 Damien Bergamini <damien.bergamini@free.fr> @@ -94,7 +94,7 @@ static const struct usb_devno otus_devs[] = { int otus_match(struct device *, void *, void *); void otus_attach(struct device *, struct device *, void *); int otus_detach(struct device *, int); -void otus_attachhook(void *); +void otus_attachhook(struct device *); void otus_get_chanlist(struct otus_softc *); int otus_load_firmware(struct otus_softc *, const char *, uint32_t); @@ -218,10 +218,7 @@ otus_attach(struct device *parent, struct device *self, void *aux) return; } - if (rootvp == NULL) - mountroothook_establish(otus_attachhook, sc); - else - otus_attachhook(sc); + config_mountroot(self, otus_attachhook); } int @@ -258,9 +255,9 @@ otus_detach(struct device *self, int flags) } void -otus_attachhook(void *xsc) +otus_attachhook(struct device *self) { - struct otus_softc *sc = xsc; + struct otus_softc *sc = (struct otus_softc *)self; struct ieee80211com *ic = &sc->sc_ic; struct ifnet *ifp = &ic->ic_if; usb_device_request_t req; diff --git a/sys/dev/usb/if_rum.c b/sys/dev/usb/if_rum.c index 9e970597a40..304948cfdd7 100644 --- a/sys/dev/usb/if_rum.c +++ b/sys/dev/usb/if_rum.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_rum.c,v 1.117 2015/11/25 03:10:00 dlg Exp $ */ +/* $OpenBSD: if_rum.c,v 1.118 2015/12/11 16:07:02 mpi Exp $ */ /*- * Copyright (c) 2005-2007 Damien Bergamini <damien.bergamini@free.fr> @@ -127,7 +127,7 @@ static const struct usb_devno rum_devs[] = { { USB_VENDOR_ZYXEL, USB_PRODUCT_ZYXEL_RT2573 } }; -void rum_attachhook(void *); +void rum_attachhook(struct device *); int rum_alloc_tx_list(struct rum_softc *); void rum_free_tx_list(struct rum_softc *); int rum_alloc_rx_list(struct rum_softc *); @@ -235,9 +235,9 @@ rum_match(struct device *parent, void *match, void *aux) } void -rum_attachhook(void *xsc) +rum_attachhook(struct device *self) { - struct rum_softc *sc = xsc; + struct rum_softc *sc = (struct rum_softc *)self; const char *name = "rum-rt2573"; u_char *ucode; size_t size; @@ -324,10 +324,7 @@ rum_attach(struct device *parent, struct device *self, void *aux) sc->sc_dev.dv_xname, sc->macbbp_rev, tmp, rum_get_rf(sc->rf_rev), ether_sprintf(ic->ic_myaddr)); - if (rootvp == NULL) - mountroothook_establish(rum_attachhook, sc); - else - rum_attachhook(sc); + config_mountroot(self, rum_attachhook); ic->ic_phytype = IEEE80211_T_OFDM; /* not only, but not used */ ic->ic_opmode = IEEE80211_M_STA; /* default to BSS mode */ diff --git a/sys/dev/usb/if_uath.c b/sys/dev/usb/if_uath.c index b55474ab1cc..e1183db414b 100644 --- a/sys/dev/usb/if_uath.c +++ b/sys/dev/usb/if_uath.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_uath.c,v 1.75 2015/11/25 03:10:00 dlg Exp $ */ +/* $OpenBSD: if_uath.c,v 1.76 2015/12/11 16:07:02 mpi Exp $ */ /*- * Copyright (c) 2006 @@ -122,7 +122,7 @@ static const struct uath_type { #define uath_lookup(v, p) \ ((const struct uath_type *)usb_lookup(uath_devs, v, p)) -void uath_attachhook(void *); +void uath_attachhook(struct device *); int uath_open_pipes(struct uath_softc *); void uath_close_pipes(struct uath_softc *); int uath_alloc_tx_data_list(struct uath_softc *); @@ -199,9 +199,9 @@ uath_match(struct device *parent, void *match, void *aux) } void -uath_attachhook(void *xsc) +uath_attachhook(struct device *self) { - struct uath_softc *sc = xsc; + struct uath_softc *sc = (struct uath_softc *)self; u_char *fw; size_t size; int error; @@ -270,10 +270,7 @@ uath_attach(struct device *parent, struct device *self, void *aux) } if (sc->sc_flags & UATH_FLAG_PRE_FIRMWARE) { - if (rootvp == NULL) - mountroothook_establish(uath_attachhook, sc); - else - uath_attachhook(sc); + config_mountroot(self, uath_attachhook); return; } diff --git a/sys/dev/usb/if_upgt.c b/sys/dev/usb/if_upgt.c index ab65a4dbe06..cefdfde5bd0 100644 --- a/sys/dev/usb/if_upgt.c +++ b/sys/dev/usb/if_upgt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_upgt.c,v 1.75 2015/11/25 03:10:00 dlg Exp $ */ +/* $OpenBSD: if_upgt.c,v 1.76 2015/12/11 16:07:02 mpi Exp $ */ /* * Copyright (c) 2007 Marcus Glocker <mglocker@openbsd.org> @@ -80,7 +80,7 @@ int upgt_debug = 2; */ int upgt_match(struct device *, void *, void *); void upgt_attach(struct device *, struct device *, void *); -void upgt_attach_hook(void *); +void upgt_attach_hook(struct device *); int upgt_detach(struct device *, int); int upgt_device_type(struct upgt_softc *, uint16_t, uint16_t); @@ -299,10 +299,7 @@ upgt_attach(struct device *parent, struct device *self, void *aux) /* * We need the firmware loaded to complete the attach. */ - if (rootvp == NULL) - mountroothook_establish(upgt_attach_hook, sc); - else - upgt_attach_hook(sc); + config_mountroot(self, upgt_attach_hook); return; fail: @@ -310,9 +307,9 @@ fail: } void -upgt_attach_hook(void *arg) +upgt_attach_hook(struct device *self) { - struct upgt_softc *sc = arg; + struct upgt_softc *sc = (struct upgt_softc *)self; struct ieee80211com *ic = &sc->sc_ic; struct ifnet *ifp = &ic->ic_if; usbd_status error; diff --git a/sys/dev/usb/if_zyd.c b/sys/dev/usb/if_zyd.c index 5d81a64e619..31f2c1d235b 100644 --- a/sys/dev/usb/if_zyd.c +++ b/sys/dev/usb/if_zyd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_zyd.c,v 1.113 2015/11/25 03:10:00 dlg Exp $ */ +/* $OpenBSD: if_zyd.c,v 1.114 2015/12/11 16:07:02 mpi Exp $ */ /*- * Copyright (c) 2006 by Damien Bergamini <damien.bergamini@free.fr> @@ -159,7 +159,7 @@ const struct cfattach zyd_ca = { sizeof(struct zyd_softc), zyd_match, zyd_attach, zyd_detach }; -void zyd_attachhook(void *); +void zyd_attachhook(struct device *); int zyd_complete_attach(struct zyd_softc *); int zyd_open_pipes(struct zyd_softc *); void zyd_close_pipes(struct zyd_softc *); @@ -246,9 +246,9 @@ zyd_match(struct device *parent, void *match, void *aux) } void -zyd_attachhook(void *xsc) +zyd_attachhook(struct device *self) { - struct zyd_softc *sc = xsc; + struct zyd_softc *sc = (struct zyd_softc *)self; const char *fwname; u_char *fw; size_t size; @@ -293,10 +293,7 @@ zyd_attach(struct device *parent, struct device *self, void *aux) return; } - if (rootvp == NULL) - mountroothook_establish(zyd_attachhook, sc); - else - zyd_attachhook(sc); + config_mountroot(self, zyd_attachhook); } int diff --git a/sys/dev/usb/udl.c b/sys/dev/usb/udl.c index 0ca8f119b20..b353aa27304 100644 --- a/sys/dev/usb/udl.c +++ b/sys/dev/usb/udl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: udl.c,v 1.83 2015/05/02 10:44:29 jsg Exp $ */ +/* $OpenBSD: udl.c,v 1.84 2015/12/11 16:07:02 mpi Exp $ */ /* * Copyright (c) 2009 Marcus Glocker <mglocker@openbsd.org> @@ -72,7 +72,7 @@ int udl_debug = 1; */ int udl_match(struct device *, void *, void *); void udl_attach(struct device *, struct device *, void *); -void udl_attach_hook(void *); +void udl_attach_hook(struct device *); int udl_detach(struct device *, int); int udl_activate(struct device *, int); @@ -393,16 +393,13 @@ udl_attach(struct device *parent, struct device *self, void *aux) /* * Load Huffman table. */ - if (rootvp == NULL) - mountroothook_establish(udl_attach_hook, sc); - else - udl_attach_hook(sc); + config_mountroot(self, udl_attach_hook); } void -udl_attach_hook(void *arg) +udl_attach_hook(struct device *self) { - struct udl_softc *sc = arg; + struct udl_softc *sc = (struct udl_softc *)self; if (udl_load_huffman(sc) != 0) { /* compression not possible */ diff --git a/sys/dev/usb/ulpt.c b/sys/dev/usb/ulpt.c index f083ca26dfc..cbf9d5e1d9b 100644 --- a/sys/dev/usb/ulpt.c +++ b/sys/dev/usb/ulpt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ulpt.c,v 1.51 2015/07/09 12:23:17 mpi Exp $ */ +/* $OpenBSD: ulpt.c,v 1.52 2015/12/11 16:07:02 mpi Exp $ */ /* $NetBSD: ulpt.c,v 1.57 2003/01/05 10:19:42 scw Exp $ */ /* $FreeBSD: src/sys/dev/usb/ulpt.c,v 1.24 1999/11/17 22:33:44 n_hibma Exp $ */ @@ -117,7 +117,7 @@ int ulpt_statusmsg(u_char, struct ulpt_softc *); /* * Printers which need firmware uploads. */ -void ulpt_load_firmware(void *); +void ulpt_load_firmware(struct device *); usbd_status ulpt_ucode_loader_hp(struct ulpt_softc *); struct ulpt_fwdev { struct usb_devno uv_dev; @@ -187,9 +187,9 @@ ulpt_match(struct device *parent, void *match, void *aux) } void -ulpt_load_firmware(void *arg) +ulpt_load_firmware(struct device *self) { - struct ulpt_softc *sc = (struct ulpt_softc *)arg; + struct ulpt_softc *sc = (struct ulpt_softc *)self; usbd_status err; err = (sc->sc_fwdev->ucode_loader)(sc); @@ -310,12 +310,8 @@ ulpt_attach(struct device *parent, struct device *self, void *aux) /* maybe the device needs firmware */ sc->sc_fwdev = ulpt_lookup(uaa->vendor, uaa->product); - if (sc->sc_fwdev) { - if (rootvp == NULL) - mountroothook_establish(ulpt_load_firmware, sc); - else - ulpt_load_firmware(sc); - } + if (sc->sc_fwdev) + config_mountroot(self, ulpt_load_firmware); #if 0 /* @@ -473,7 +469,7 @@ ulptopen(dev_t dev, int flag, int mode, struct proc *p) /* If a previous attempt to load firmware failed, retry. */ if (sc->sc_flags & ULPT_EFIRMWARE) { - ulpt_load_firmware(sc); + ulpt_load_firmware(&sc->sc_dev); if (sc->sc_flags & ULPT_EFIRMWARE) return (EIO); } diff --git a/sys/dev/usb/uticom.c b/sys/dev/usb/uticom.c index f2a97897361..b0858bbaf30 100644 --- a/sys/dev/usb/uticom.c +++ b/sys/dev/usb/uticom.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uticom.c,v 1.27 2015/03/14 03:38:50 jsg Exp $ */ +/* $OpenBSD: uticom.c,v 1.28 2015/12/11 16:07:02 mpi Exp $ */ /* * Copyright (c) 2005 Dmitry Komissaroff <dxi@mail.ru>. * @@ -155,7 +155,7 @@ static int uticom_param(void *, int, struct termios *); static int uticom_open(void *, int); static void uticom_close(void *, int); -void uticom_attach_hook(void *arg); +void uticom_attach_hook(struct device *); static int uticom_download_fw(struct uticom_softc *sc, int pipeno, struct usbd_device *dev); @@ -213,16 +213,13 @@ uticom_attach(struct device *parent, struct device *self, void *aux) sc->sc_udev = dev; sc->sc_iface = uaa->iface; - if (rootvp == NULL) - mountroothook_establish(uticom_attach_hook, sc); - else - uticom_attach_hook(sc); + config_mountroot(self, uticom_attach_hook); } void -uticom_attach_hook(void *arg) +uticom_attach_hook(struct device *self) { - struct uticom_softc *sc = arg; + struct uticom_softc *sc = (struct uticom_softc *)self; usb_config_descriptor_t *cdesc; usb_interface_descriptor_t *id; usb_endpoint_descriptor_t *ed; diff --git a/sys/dev/usb/uvideo.c b/sys/dev/usb/uvideo.c index e773d43182e..67077e9586c 100644 --- a/sys/dev/usb/uvideo.c +++ b/sys/dev/usb/uvideo.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvideo.c,v 1.181 2015/07/09 14:58:32 mpi Exp $ */ +/* $OpenBSD: uvideo.c,v 1.182 2015/12/11 16:07:02 mpi Exp $ */ /* * Copyright (c) 2008 Robert Nagy <robert@openbsd.org> @@ -120,7 +120,7 @@ int uvideo_open(void *, int, int *, uint8_t *, void (*)(void *), int uvideo_close(void *); int uvideo_match(struct device *, void *, void *); void uvideo_attach(struct device *, struct device *, void *); -void uvideo_attach_hook(void *); +void uvideo_attach_hook(struct device *); int uvideo_detach(struct device *, int); int uvideo_activate(struct device *, int); @@ -526,17 +526,13 @@ uvideo_attach(struct device *parent, struct device *self, void *aux) /* maybe the device has quirks */ sc->sc_quirk = uvideo_lookup(uaa->vendor, uaa->product); - /* if the device needs ucode do mountroothook */ - if ((sc->sc_quirk && sc->sc_quirk->ucode_name) && rootvp == NULL) - mountroothook_establish(uvideo_attach_hook, sc); - else - uvideo_attach_hook(sc); + config_mountroot(self, uvideo_attach_hook); } void -uvideo_attach_hook(void *arg) +uvideo_attach_hook(struct device *self) { - struct uvideo_softc *sc = arg; + struct uvideo_softc *sc = (struct uvideo_softc *)self; usb_config_descriptor_t *cdesc; usbd_status error; diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c index 9de115cb56c..94b65a6630e 100644 --- a/sys/kern/init_main.c +++ b/sys/kern/init_main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: init_main.c,v 1.246 2015/11/08 20:45:57 naddy Exp $ */ +/* $OpenBSD: init_main.c,v 1.247 2015/12/11 16:07:02 mpi Exp $ */ /* $NetBSD: init_main.c,v 1.84.4.1 1996/06/02 09:08:06 mrg Exp $ */ /* @@ -536,7 +536,7 @@ main(void *framep) cpu_boot_secondary_processors(); #endif - domountroothooks(); + config_process_deferred_mountroot(); /* * Okay, now we can let init(8) exec! It's off to userland! diff --git a/sys/kern/kern_subr.c b/sys/kern/kern_subr.c index c236b9fb4ca..8e0b5dfcde4 100644 --- a/sys/kern/kern_subr.c +++ b/sys/kern/kern_subr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_subr.c,v 1.44 2015/03/14 03:38:50 jsg Exp $ */ +/* $OpenBSD: kern_subr.c,v 1.45 2015/12/11 16:07:02 mpi Exp $ */ /* $NetBSD: kern_subr.c,v 1.15 1996/04/09 17:21:56 ragge Exp $ */ /* @@ -184,13 +184,11 @@ hashinit(int elements, int type, int flags, u_long *hashmask) } /* - * "Mountroot/startup hook" types, functions, and variables. + * "startup hook" types, functions, and variables. */ struct hook_desc_head startuphook_list = TAILQ_HEAD_INITIALIZER(startuphook_list); -struct hook_desc_head mountroothook_list = - TAILQ_HEAD_INITIALIZER(mountroothook_list); void * hook_establish(struct hook_desc_head *head, int tail, void (*fn)(void *), diff --git a/sys/kern/subr_autoconf.c b/sys/kern/subr_autoconf.c index bb6041b34b3..ebf8aaec540 100644 --- a/sys/kern/subr_autoconf.c +++ b/sys/kern/subr_autoconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: subr_autoconf.c,v 1.89 2015/09/11 20:43:23 dlg Exp $ */ +/* $OpenBSD: subr_autoconf.c,v 1.90 2015/12/11 16:07:02 mpi Exp $ */ /* $NetBSD: subr_autoconf.c,v 1.21 1996/04/04 06:06:18 cgd Exp $ */ /* @@ -88,7 +88,9 @@ struct deferred_config { }; TAILQ_HEAD(, deferred_config) deferred_config_queue; +TAILQ_HEAD(, deferred_config) mountroot_config_queue; +void *config_rootsearch(cfmatch_t, char *, void *); void config_process_deferred_children(struct device *); struct devicelist alldevs; /* list of all devices */ @@ -112,6 +114,7 @@ void config_init(void) { TAILQ_INIT(&deferred_config_queue); + TAILQ_INIT(&mountroot_config_queue); TAILQ_INIT(&alldevs); } @@ -676,6 +679,39 @@ config_defer(struct device *dev, void (*func)(struct device *)) } /* + * Defer the configuration of the specified device until after + * root file system is mounted. + */ +void +config_mountroot(struct device *dev, void (*func)(struct device *)) +{ + struct deferred_config *dc; + + /* + * No need to defer if root file system is already mounted. + */ + if (rootvp != NULL) { + (*func)(dev); + return; + } + +#ifdef DIAGNOSTIC + for (dc = TAILQ_FIRST(&mountroot_config_queue); dc != NULL; + dc = TAILQ_NEXT(dc, dc_queue)) { + if (dc->dc_dev == dev) + panic("config_mountroot: deferred twice"); + } +#endif + + if ((dc = malloc(sizeof(*dc), M_DEVBUF, M_NOWAIT)) == NULL) + panic("config_mountroot: can't allocate defer structure"); + + dc->dc_dev = dev; + dc->dc_func = func; + TAILQ_INSERT_TAIL(&mountroot_config_queue, dc, dc_queue); +} + +/* * Process the deferred configuration queue for a device. */ void @@ -696,6 +732,22 @@ config_process_deferred_children(struct device *parent) } /* + * Process the deferred configuration queue after the root file + * system is mounted . + */ +void +config_process_deferred_mountroot(void) +{ + struct deferred_config *dc; + + while ((dc = TAILQ_FIRST(&mountroot_config_queue)) != NULL) { + TAILQ_REMOVE(&mountroot_config_queue, dc, dc_queue); + (*dc->dc_func)(dc->dc_dev); + free(dc, M_DEVBUF, 0); + } +} + +/* * Manipulate the config_pending semaphore. */ void @@ -874,7 +926,7 @@ device_lookup(struct cfdriver *cd, int unit) if (unit >= 0 && unit < cd->cd_ndevs) dv = (struct device *)(cd->cd_devs[unit]); - + if (!dv) return (NULL); @@ -906,7 +958,7 @@ device_mpath(void) if (mpath_cd.cd_ndevs < 1) return (NULL); - + return (mpath_cd.cd_devs[0]); #else return (NULL); diff --git a/sys/sys/device.h b/sys/sys/device.h index 00af29f9ed1..00a1f6ad2a6 100644 --- a/sys/sys/device.h +++ b/sys/sys/device.h @@ -1,4 +1,4 @@ -/* $OpenBSD: device.h,v 1.53 2015/09/11 20:43:23 dlg Exp $ */ +/* $OpenBSD: device.h,v 1.54 2015/12/11 16:07:02 mpi Exp $ */ /* $NetBSD: device.h,v 1.15 1996/04/09 20:55:24 cgd Exp $ */ /* @@ -171,7 +171,6 @@ extern volatile int config_pending; /* semaphore for mountroot */ void config_init(void); void *config_search(cfmatch_t, struct device *, void *); -void *config_rootsearch(cfmatch_t, char *, void *); struct device *config_found_sm(struct device *, void *, cfprint_t, cfmatch_t); struct device *config_rootfound(char *, void *); @@ -188,6 +187,8 @@ struct device *config_make_softc(struct device *parent, void config_defer(struct device *, void (*)(struct device *)); void config_pending_incr(void); void config_pending_decr(void); +void config_mountroot(struct device *, void (*)(struct device *)); +void config_process_deferred_mountroot(void); struct device *device_mainbus(void); struct device *device_mpath(void); diff --git a/sys/sys/systm.h b/sys/sys/systm.h index eef9a71568a..f246f7f4bfa 100644 --- a/sys/sys/systm.h +++ b/sys/sys/systm.h @@ -1,4 +1,4 @@ -/* $OpenBSD: systm.h,v 1.108 2015/06/11 16:03:04 mikeb Exp $ */ +/* $OpenBSD: systm.h,v 1.109 2015/12/11 16:07:02 mpi Exp $ */ /* $NetBSD: systm.h,v 1.50 1996/06/09 04:55:09 briggs Exp $ */ /*- @@ -273,7 +273,7 @@ struct hook_desc { }; TAILQ_HEAD(hook_desc_head, hook_desc); -extern struct hook_desc_head startuphook_list, mountroothook_list; +extern struct hook_desc_head startuphook_list; void *hook_establish(struct hook_desc_head *, int, void (*)(void *), void *); void hook_disestablish(struct hook_desc_head *, void *); @@ -288,12 +288,6 @@ void dohooks(struct hook_desc_head *, int); hook_disestablish(&startuphook_list, (vhook)) #define dostartuphooks() dohooks(&startuphook_list, HOOK_REMOVE|HOOK_FREE) -#define mountroothook_establish(fn, arg) \ - hook_establish(&mountroothook_list, 1, (fn), (arg)) -#define mountroothook_disestablish(vhook) \ - hook_disestablish(&mountroothook_list, (vhook)) -#define domountroothooks() dohooks(&mountroothook_list, HOOK_REMOVE|HOOK_FREE) - struct uio; int uiomove(void *, size_t, struct uio *); int uiomovei(void *, int, struct uio *); |