* [PATCH] mtd: Use DIV_ROUND_UP()
@ 2018-03-25 15:37 Arushi Singhal
2018-03-29 20:25 ` Boris Brezillon
0 siblings, 1 reply; 2+ messages in thread
From: Arushi Singhal @ 2018-03-25 15:37 UTC (permalink / raw)
To: dwmw2
Cc: Brian Norris, Boris Brezillon, Marek Vasut, Richard Weinberger,
Cyrille Pitchen, linux-mtd, linux-kernel
The kernel.h macro DIV_ROUND_UP performs the computation
(((n) + (d) - 1) / (d)) but is perhaps more readable.
Signed-off-by: Arushi Singhal <arushisinghal19971997@gmail.com>
---
drivers/mtd/ftl.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/mtd/ftl.c b/drivers/mtd/ftl.c
index a048429..61d5cf8 100644
--- a/drivers/mtd/ftl.c
+++ b/drivers/mtd/ftl.c
@@ -425,8 +425,8 @@ static int prepare_xfer(partition_t *part, int i)
}
/* Write the BAM stub */
- nbam = (part->BlocksPerUnit * sizeof(uint32_t) +
- le32_to_cpu(part->header.BAMOffset) + SECTOR_SIZE - 1) / SECTOR_SIZE;
+ nbam = DIV_ROUND_UP(part->BlocksPerUnit * sizeof(uint32_t) +
+ le32_to_cpu(part->header.BAMOffset), SECTOR_SIZE);
offset = xfer->Offset + le32_to_cpu(part->header.BAMOffset);
ctl = cpu_to_le32(BLOCK_CONTROL);
--
2.7.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] mtd: Use DIV_ROUND_UP()
2018-03-25 15:37 [PATCH] mtd: Use DIV_ROUND_UP() Arushi Singhal
@ 2018-03-29 20:25 ` Boris Brezillon
0 siblings, 0 replies; 2+ messages in thread
From: Boris Brezillon @ 2018-03-29 20:25 UTC (permalink / raw)
To: Arushi Singhal
Cc: dwmw2, Boris Brezillon, Richard Weinberger, linux-kernel,
Marek Vasut, linux-mtd, Cyrille Pitchen, Brian Norris
On Sun, 25 Mar 2018 21:07:43 +0530
Arushi Singhal <arushisinghal19971997@gmail.com> wrote:
> The kernel.h macro DIV_ROUND_UP performs the computation
> (((n) + (d) - 1) / (d)) but is perhaps more readable.
>
> Signed-off-by: Arushi Singhal <arushisinghal19971997@gmail.com>
Applied.
Thanks,
Boris
> ---
> drivers/mtd/ftl.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/mtd/ftl.c b/drivers/mtd/ftl.c
> index a048429..61d5cf8 100644
> --- a/drivers/mtd/ftl.c
> +++ b/drivers/mtd/ftl.c
> @@ -425,8 +425,8 @@ static int prepare_xfer(partition_t *part, int i)
> }
>
> /* Write the BAM stub */
> - nbam = (part->BlocksPerUnit * sizeof(uint32_t) +
> - le32_to_cpu(part->header.BAMOffset) + SECTOR_SIZE - 1) / SECTOR_SIZE;
> + nbam = DIV_ROUND_UP(part->BlocksPerUnit * sizeof(uint32_t) +
> + le32_to_cpu(part->header.BAMOffset), SECTOR_SIZE);
>
> offset = xfer->Offset + le32_to_cpu(part->header.BAMOffset);
> ctl = cpu_to_le32(BLOCK_CONTROL);
--
Boris Brezillon, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-03-29 20:25 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-25 15:37 [PATCH] mtd: Use DIV_ROUND_UP() Arushi Singhal
2018-03-29 20:25 ` Boris Brezillon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).