summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorimp <imp@FreeBSD.org>2008-09-28 22:40:11 +0000
committerimp <imp@FreeBSD.org>2008-09-28 22:40:11 +0000
commit0de91f430bf941d9f61c958e040420c3b7e3cab0 (patch)
treedbe56b7b3b48488f07d956e2fbe0ebc488f9250f
parentdb3715c928cd7dc3811372e9f8c03d03f1c044ee (diff)
downloadFreeBSD-src-0de91f430bf941d9f61c958e040420c3b7e3cab0.zip
FreeBSD-src-0de91f430bf941d9f61c958e040420c3b7e3cab0.tar.gz
Propigate read-only status of cards. Right now it is read only at
device attach time. We may need to read this more often in the future, but for now simplicity of implementation wins. Submitted by: mav@
-rw-r--r--sys/dev/mmc/mmc.c7
-rw-r--r--sys/dev/mmc/mmcbrvar.h6
-rw-r--r--sys/dev/mmc/mmcvar.h2
3 files changed, 14 insertions, 1 deletions
diff --git a/sys/dev/mmc/mmc.c b/sys/dev/mmc/mmc.c
index c3f96c9..cc0db3f 100644
--- a/sys/dev/mmc/mmc.c
+++ b/sys/dev/mmc/mmc.c
@@ -86,6 +86,7 @@ struct mmc_ivars {
enum mmc_card_mode mode;
struct mmc_cid cid; /* cid decoded */
struct mmc_csd csd; /* csd decoded */
+ u_char read_only; /* True when the device is read-only */
};
#define CMD_RETRIES 3
@@ -613,7 +614,8 @@ mmc_discover_cards(struct mmc_softc *sc)
mmc_decode_cid(1, ivar->raw_cid, &ivar->cid);
mmc_send_relative_addr(sc, &resp);
ivar->rca = resp >> 16;
- // RO check
+ if (mmcbr_get_ro(sc->dev))
+ ivar->read_only = 1;
mmc_send_csd(sc, ivar->rca, ivar->raw_csd);
mmc_decode_csd(1, ivar->raw_csd, &ivar->csd);
printf("SD CARD: %lld bytes\n", (long long)
@@ -738,6 +740,9 @@ mmc_read_ivar(device_t bus, device_t child, int which, u_char *result)
case MMC_IVAR_TRAN_SPEED:
*(int *)result = ivar->csd.tran_speed;
break;
+ case MMC_IVAR_READ_ONLY:
+ *(int *)result = ivar->read_only;
+ break;
}
return (0);
}
diff --git a/sys/dev/mmc/mmcbrvar.h b/sys/dev/mmc/mmcbrvar.h
index 0f8a9cf..9a8bb47 100644
--- a/sys/dev/mmc/mmcbrvar.h
+++ b/sys/dev/mmc/mmcbrvar.h
@@ -97,4 +97,10 @@ mmcbr_update_ios(device_t dev)
return (MMCBR_UPDATE_IOS(device_get_parent(dev), dev));
}
+static int __inline
+mmcbr_get_ro(device_t dev)
+{
+ return (MMCBR_GET_RO(device_get_parent(dev), dev));
+}
+
#endif /* DEV_MMC_MMCBRVAR_H */
diff --git a/sys/dev/mmc/mmcvar.h b/sys/dev/mmc/mmcvar.h
index b5c7c09..c18a25f 100644
--- a/sys/dev/mmc/mmcvar.h
+++ b/sys/dev/mmc/mmcvar.h
@@ -61,6 +61,7 @@ enum mmc_device_ivars {
MMC_IVAR_RCA,
MMC_IVAR_SECTOR_SIZE,
MMC_IVAR_TRAN_SPEED,
+ MMC_IVAR_READ_ONLY,
// MMC_IVAR_,
};
@@ -75,5 +76,6 @@ MMC_ACCESSOR(media_size, MEDIA_SIZE, int)
MMC_ACCESSOR(rca, RCA, int)
MMC_ACCESSOR(sector_size, SECTOR_SIZE, int)
MMC_ACCESSOR(tran_speed, TRAN_SPEED, int)
+MMC_ACCESSOR(read_only, READ_ONLY, int)
#endif /* DEV_MMC_MMCVAR_H */
OpenPOWER on IntegriCloud