diff --git a/share/man/man9/Makefile b/share/man/man9/Makefile --- a/share/man/man9/Makefile +++ b/share/man/man9/Makefile @@ -454,6 +454,7 @@ VOP_REVOKE.9 \ VOP_SETACL.9 \ VOP_SETEXTATTR.9 \ + VOP_SETLABEL.9 \ VOP_STRATEGY.9 \ VOP_VPTOCNP.9 \ VOP_VPTOFH.9 \ diff --git a/sys/dev/sdhci/sdhci.c b/sys/dev/sdhci/sdhci.c --- a/sys/dev/sdhci/sdhci.c +++ b/sys/dev/sdhci/sdhci.c @@ -677,66 +677,74 @@ } } +#ifdef MMCCAM static void sdhci_card_task(void *arg, int pending __unused) { struct sdhci_slot *slot = arg; -#ifndef MMCCAM - device_t d; -#endif + bool present; SDHCI_LOCK(slot); - if (SDHCI_GET_CARD_PRESENT(slot->bus, slot)) { -#ifdef MMCCAM - if (slot->card_present == 0) { -#else - if (slot->dev == NULL) { -#endif - /* If card is present - attach mmc bus. */ - if (bootverbose || sdhci_debug) - slot_printf(slot, "Card inserted\n"); -#ifdef MMCCAM - slot->card_present = 1; - mmccam_start_discovery(slot->sim); - SDHCI_UNLOCK(slot); -#else - d = slot->dev = device_add_child(slot->bus, "mmc", DEVICE_UNIT_ANY); - SDHCI_UNLOCK(slot); - if (d) { - device_set_ivars(d, slot); - (void)device_probe_and_attach(d); - } -#endif - } else - SDHCI_UNLOCK(slot); - } else { -#ifdef MMCCAM - if (slot->card_present == 1) { -#else - if (slot->dev != NULL) { - d = slot->dev; -#endif - /* If no card present - detach mmc bus. */ - if (bootverbose || sdhci_debug) - slot_printf(slot, "Card removed\n"); - slot->dev = NULL; -#ifdef MMCCAM - slot->card_present = 0; - mmccam_start_discovery(slot->sim); - SDHCI_UNLOCK(slot); -#else - slot->intmask &= ~sdhci_tuning_intmask(slot); - WR4(slot, SDHCI_INT_ENABLE, slot->intmask); - WR4(slot, SDHCI_SIGNAL_ENABLE, slot->intmask); - slot->opt &= ~SDHCI_TUNING_ENABLED; - SDHCI_UNLOCK(slot); - callout_drain(&slot->retune_callout); - device_delete_child(slot->bus, d); -#endif - } else - SDHCI_UNLOCK(slot); + present = SDHCI_GET_CARD_PRESENT(slot->bus, slot); + if (present && slot->card_present == 0) { + /* If card is present - attach mmc bus. */ + if (bootverbose || sdhci_debug) + slot_printf(slot, "Card inserted\n"); + + slot->card_present = 1; + mmccam_start_discovery(slot->sim); + } else if (!present && slot->card_present == 1) { + /* If no card present - detach mmc bus. */ + if (bootverbose || sdhci_debug) + slot_printf(slot, "Card removed\n"); + slot->dev = NULL; + slot->card_present = 0; + mmccam_start_discovery(slot->sim); } + SDHCI_UNLOCK(slot); +} + +#else /* !MMCCAM */ + +static void +sdhci_card_task(void *arg, int pending __unused) +{ + struct sdhci_slot *slot = arg; + device_t d; + bool present; + + SDHCI_LOCK(slot); + present = SDHCI_GET_CARD_PRESENT(slot->bus, slot); + if (present && slot->dev == NULL) { + /* If card is present - attach mmc bus. */ + if (bootverbose || sdhci_debug) + slot_printf(slot, "Card inserted\n"); + + d = slot->dev = device_add_child(slot->bus, "mmc", + DEVICE_UNIT_ANY); + SDHCI_UNLOCK(slot); + if (d) { + device_set_ivars(d, slot); + (void)device_probe_and_attach(d); + } + } else if (!present && slot->dev != NULL) { + d = slot->dev; + /* If no card present - detach mmc bus. */ + if (bootverbose || sdhci_debug) + slot_printf(slot, "Card removed\n"); + + slot->dev = NULL; + slot->intmask &= ~sdhci_tuning_intmask(slot); + WR4(slot, SDHCI_INT_ENABLE, slot->intmask); + WR4(slot, SDHCI_SIGNAL_ENABLE, slot->intmask); + slot->opt &= ~SDHCI_TUNING_ENABLED; + SDHCI_UNLOCK(slot); + callout_drain(&slot->retune_callout); + device_delete_child(slot->bus, d); + } else + SDHCI_UNLOCK(slot); } +#endif /* MMCCAM */ static void sdhci_handle_card_present_locked(struct sdhci_slot *slot, bool is_present)