mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-23 16:01:42 +00:00
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@
This commit is contained in:
parent
8aaa15e202
commit
40fab6e7c7
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=183447
@ -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);
|
||||
}
|
||||
|
@ -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 */
|
||||
|
@ -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 */
|
||||
|
Loading…
Reference in New Issue
Block a user