Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F163405080
D48848.id150679.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D48848.id150679.diff
View Options
diff --git a/sys/arm/allwinner/aw_mmc.c b/sys/arm/allwinner/aw_mmc.c
--- a/sys/arm/allwinner/aw_mmc.c
+++ b/sys/arm/allwinner/aw_mmc.c
@@ -317,36 +317,41 @@
aw_mmc_helper_cd_handler(device_t dev, bool present)
{
struct aw_mmc_softc *sc;
+#ifndef MMCCAM
+ device_t child;
+#endif
sc = device_get_softc(dev);
#ifdef MMCCAM
mmc_cam_sim_discover(&sc->mmc_sim);
#else
AW_MMC_LOCK(sc);
- if (present) {
- if (sc->child == NULL) {
- if (__predict_false(aw_mmc_debug & AW_MMC_DEBUG_CARD))
- device_printf(sc->aw_dev, "Card inserted\n");
+ child = sc->child;
+ AW_MMC_UNLOCK(sc);
- sc->child = device_add_child(sc->aw_dev, "mmc", DEVICE_UNIT_ANY);
- AW_MMC_UNLOCK(sc);
- if (sc->child) {
- device_set_ivars(sc->child, sc);
- (void)device_probe_and_attach(sc->child);
- }
- } else
- AW_MMC_UNLOCK(sc);
- } else {
- /* Card isn't present, detach if necessary */
- if (sc->child != NULL) {
- if (__predict_false(aw_mmc_debug & AW_MMC_DEBUG_CARD))
- device_printf(sc->aw_dev, "Card removed\n");
+ if (present && child == NULL) {
+ if (__predict_false(aw_mmc_debug & AW_MMC_DEBUG_CARD))
+ device_printf(sc->aw_dev, "Card inserted\n");
- AW_MMC_UNLOCK(sc);
- device_delete_child(sc->aw_dev, sc->child);
- sc->child = NULL;
- } else
- AW_MMC_UNLOCK(sc);
+ child = device_add_child(sc->aw_dev, "mmc", DEVICE_UNIT_ANY);
+ if (child != NULL) {
+ device_set_ivars(child, sc);
+ (void)device_probe_and_attach(child);
+ }
+
+ AW_MMC_LOCK(sc);
+ sc->child = child;
+ AW_MMC_UNLOCK(sc);
+ } else if (!present && child != NULL) {
+ /* Card isn't present, detach. */
+ if (__predict_false(aw_mmc_debug & AW_MMC_DEBUG_CARD))
+ device_printf(sc->aw_dev, "Card removed\n");
+
+ AW_MMC_LOCK(sc);
+ sc->child = NULL;
+ AW_MMC_UNLOCK(sc);
+
+ device_delete_child(sc->aw_dev, child);
}
#endif /* MMCCAM */
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Jul 23, 10:16 PM (20 h, 26 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
35417583
Default Alt Text
D48848.id150679.diff (1 KB)
Attached To
Mode
D48848: aw_mmc: refine locking in aw_mmc_helper_cd_handler()
Attached
Detach File
Event Timeline
Log In to Comment