summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHeiner Kallweit <hkallweit1@gmail.com>2017-03-22 21:59:29 +0100
committerUlf Hansson <ulf.hansson@linaro.org>2017-04-24 21:41:42 +0200
commit7aceaf566e1d6f7bf29516d680ee883697909cc7 (patch)
tree60dbce529a8f938934a1180c207af0bbbdbf57ea
parentmmc: sh_mmcif: Document r7s72100 DT bindings (diff)
downloadlinux-7aceaf566e1d6f7bf29516d680ee883697909cc7.tar.xz
linux-7aceaf566e1d6f7bf29516d680ee883697909cc7.zip
mmc: sdio: improve mmc_io_rw_extended
Improve mmc_io_rw_extended a little: - using DIV_ROUND_UP achieves the same but is better readable - simplify code by using sg_set_buf - simplify one statement by using -= operator Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
-rw-r--r--drivers/mmc/core/sdio_ops.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/drivers/mmc/core/sdio_ops.c b/drivers/mmc/core/sdio_ops.c
index 3c0d3ab4324c..abaaba38514f 100644
--- a/drivers/mmc/core/sdio_ops.c
+++ b/drivers/mmc/core/sdio_ops.c
@@ -152,7 +152,7 @@ int mmc_io_rw_extended(struct mmc_card *card, int write, unsigned fn,
data.flags = write ? MMC_DATA_WRITE : MMC_DATA_READ;
left_size = data.blksz * data.blocks;
- nents = (left_size - 1) / seg_size + 1;
+ nents = DIV_ROUND_UP(left_size, seg_size);
if (nents > 1) {
if (sg_alloc_table(&sgtable, nents, GFP_KERNEL))
return -ENOMEM;
@@ -161,10 +161,9 @@ int mmc_io_rw_extended(struct mmc_card *card, int write, unsigned fn,
data.sg_len = nents;
for_each_sg(data.sg, sg_ptr, data.sg_len, i) {
- sg_set_page(sg_ptr, virt_to_page(buf + (i * seg_size)),
- min(seg_size, left_size),
- offset_in_page(buf + (i * seg_size)));
- left_size = left_size - seg_size;
+ sg_set_buf(sg_ptr, buf + i * seg_size,
+ min(seg_size, left_size));
+ left_size -= seg_size;
}
} else {
data.sg = &sg;