diff options
Diffstat (limited to 'common/env_mmc.c')
-rw-r--r-- | common/env_mmc.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/common/env_mmc.c b/common/env_mmc.c index 5742db0..8c98ad2 100644 --- a/common/env_mmc.c +++ b/common/env_mmc.c @@ -101,8 +101,10 @@ inline int write_env(struct mmc *mmc, unsigned long size, { uint blk_start = 0, blk_cnt = 0, n = 0; - blk_start = (offset % 512) ? ((offset / 512) + 1) : (offset / 512); - blk_cnt = (size % 512) ? ((size / 512) + 1) : (size / 512); + blk_start = (offset & (0x200 - 1)) \ + ? ((offset >> 9) + 1) : (offset >> 9); + blk_cnt = (size & (0x200 - 1)) \ + ? ((size >> 9) + 1) : (size >> 9); n = mmc->block_dev.block_write(0, blk_start , blk_cnt, (u_char *)buffer); return (n == blk_cnt) ? 0 : -1; @@ -132,8 +134,10 @@ inline int read_env(struct mmc *mmc, unsigned long size, { uint blk_start = 0, blk_cnt = 0, n = 0; - blk_start = (offset % 512) ? ((offset / 512) + 1) : (offset / 512); - blk_cnt = (size % 512) ? ((size / 512) + 1) : (size / 512); + blk_start = (offset & (0x200 - 1)) ? \ + ((offset >> 9) + 1) : (offset >> 9); + blk_cnt = (size & (0x200 - 1)) ? \ + ((size >> 9) + 1) : (size >> 9); n = mmc->block_dev.block_read(0, blk_start, blk_cnt, (uchar *)buffer); |