-/* $OpenBSD: sdmmc.c,v 1.59 2022/04/06 18:59:30 naddy Exp $ */
+/* $OpenBSD: sdmmc.c,v 1.60 2022/09/03 15:29:43 kettenis Exp $ */
/*
* Copyright (c) 2006 Uwe Stuehler <uwe@openbsd.org>
int sdmmc_detach(struct device *, int);
int sdmmc_activate(struct device *, int);
+int sdmmc_holds_root_device(struct sdmmc_softc *);
void sdmmc_create_thread(void *);
void sdmmc_task_thread(void *);
void sdmmc_discover_task(void *);
rv = config_activate_children(self, act);
/* If card in slot, cause a detach/re-attach */
if (ISSET(sc->sc_flags, SMF_CARD_PRESENT) &&
- !ISSET(sc->sc_caps, SMC_CAPS_NONREMOVABLE))
+ !ISSET(sc->sc_caps, SMC_CAPS_NONREMOVABLE) &&
+ !sdmmc_holds_root_device(sc))
sc->sc_dying = -1;
break;
case DVACT_RESUME:
return (rv);
}
+int
+sdmmc_holds_root_device(struct sdmmc_softc *sc)
+{
+ if (rootdv && rootdv->dv_parent &&
+ rootdv->dv_parent->dv_parent == &sc->sc_dev)
+ return 1;
+
+ return 0;
+}
+
void
sdmmc_create_thread(void *arg)
{
-/* $OpenBSD: subr_disk.c,v 1.259 2022/09/02 20:06:56 miod Exp $ */
+/* $OpenBSD: subr_disk.c,v 1.260 2022/09/03 15:29:43 kettenis Exp $ */
/* $NetBSD: subr_disk.c,v 1.17 1996/03/16 23:17:08 christos Exp $ */
/*
u_char bootduid[DUID_SIZE]; /* DUID of boot disk. */
u_char rootduid[DUID_SIZE]; /* DUID of root disk. */
+struct device *rootdv;
+
/* softraid callback, do not use! */
void (*softraid_disk_attach)(struct disk *, int);
{
int majdev, unit, len, s, slept = 0;
struct swdevt *swp;
- struct device *rootdv, *dv;
+ struct device *dv;
dev_t nrootdev, nswapdev = NODEV, temp = NODEV;
struct ifnet *ifp = NULL;
struct disk *dk;
-/* $OpenBSD: systm.h,v 1.158 2022/08/06 15:57:59 bluhm Exp $ */
+/* $OpenBSD: systm.h,v 1.159 2022/09/03 15:29:44 kettenis Exp $ */
/* $NetBSD: systm.h,v 1.50 1996/06/09 04:55:09 briggs Exp $ */
/*-
extern u_char bootduid[8]; /* boot device disklabel uid */
extern u_char rootduid[8]; /* root device disklabel uid */
extern struct vnode *rootvp; /* vnode equivalent to above */
+extern struct device *rootdv; /* device equivalent to above */
extern dev_t swapdev; /* swapping device */
extern struct vnode *swapdev_vp;/* vnode equivalent to above */