From 97389cb928ffca7d653c1f4ea018250eea64079b Mon Sep 17 00:00:00 2001 From: imp Date: Thu, 2 Oct 2008 07:06:59 +0000 Subject: Define and use MMC_SECTOR_SIZE. Make mmc_get_media_size now return an off_t and remove now useless cast. --- sys/dev/mmc/mmc.c | 4 ++-- sys/dev/mmc/mmcreg.h | 8 ++++++++ sys/dev/mmc/mmcsd.c | 2 +- sys/dev/mmc/mmcvar.h | 2 +- 4 files changed, 12 insertions(+), 4 deletions(-) (limited to 'sys') diff --git a/sys/dev/mmc/mmc.c b/sys/dev/mmc/mmc.c index 868ab01..e2357e7 100644 --- a/sys/dev/mmc/mmc.c +++ b/sys/dev/mmc/mmc.c @@ -760,13 +760,13 @@ mmc_read_ivar(device_t bus, device_t child, int which, u_char *result) *(int *)result = ivar->csd.dsr_imp; break; case MMC_IVAR_MEDIA_SIZE: - *(int *)result = ivar->csd.capacity / DEV_BSIZE; + *(off_t *)result = ivar->csd.capacity / MMC_SECTOR_SIZE; break; case MMC_IVAR_RCA: *(int *)result = ivar->rca; break; case MMC_IVAR_SECTOR_SIZE: - *(int *)result = 512; + *(int *)result = MMC_SECTOR_SIZE; break; case MMC_IVAR_TRAN_SPEED: *(int *)result = ivar->csd.tran_speed; diff --git a/sys/dev/mmc/mmcreg.h b/sys/dev/mmc/mmcreg.h index 6bd45fc..3aac296 100644 --- a/sys/dev/mmc/mmcreg.h +++ b/sys/dev/mmc/mmcreg.h @@ -351,4 +351,12 @@ struct mmc_csd wp_grp_enable:1; }; +/* + * Older versions of the MMC standard had a variable sector size. However, + * I've been able to find no old MMC or SD cards that have a non 512 + * byte sector size anywhere, so we assume that such cards are very rare + * and only note their existance in passing here... + */ +#define MMC_SECTOR_SIZE 512 + #endif /* DEV_MMCREG_H */ diff --git a/sys/dev/mmc/mmcsd.c b/sys/dev/mmc/mmcsd.c index 948df18..6fac90f 100644 --- a/sys/dev/mmc/mmcsd.c +++ b/sys/dev/mmc/mmcsd.c @@ -128,7 +128,7 @@ mmcsd_attach(device_t dev) sc->disk->d_drv1 = sc; sc->disk->d_maxsize = MAXPHYS; /* Maybe ask bridge? */ sc->disk->d_sectorsize = mmc_get_sector_size(dev); - sc->disk->d_mediasize = ((off_t)mmc_get_media_size(dev)) * + sc->disk->d_mediasize = mmc_get_media_size(dev) * mmc_get_sector_size(dev); sc->disk->d_unit = device_get_unit(dev); diff --git a/sys/dev/mmc/mmcvar.h b/sys/dev/mmc/mmcvar.h index c18a25f..971add1 100644 --- a/sys/dev/mmc/mmcvar.h +++ b/sys/dev/mmc/mmcvar.h @@ -72,7 +72,7 @@ enum mmc_device_ivars { __BUS_ACCESSOR(mmc, var, MMC, ivar, type) MMC_ACCESSOR(dsr_imp, DSR_IMP, int) -MMC_ACCESSOR(media_size, MEDIA_SIZE, int) +MMC_ACCESSOR(media_size, MEDIA_SIZE, off_t) MMC_ACCESSOR(rca, RCA, int) MMC_ACCESSOR(sector_size, SECTOR_SIZE, int) MMC_ACCESSOR(tran_speed, TRAN_SPEED, int) -- cgit v1.1