[PATCH] mtd mtdraw: Fix partial page read

Robert Jarzmik robert.jarzmik at free.fr
Sun Sep 16 04:46:54 EDT 2012


Sascha Hauer <s.hauer at pengutronix.de> writes:

> When reading parts of a page we have to limit the maximum bytes copied
> the the remaining bytes of a page.
>
> Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
> Cc: Robert Jarzmik <robert.jarzmik at free.fr>
> ---
>  drivers/mtd/mtdraw.c |    1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/drivers/mtd/mtdraw.c b/drivers/mtd/mtdraw.c
> index d28ae07..29f6a8c 100644
> --- a/drivers/mtd/mtdraw.c
> +++ b/drivers/mtd/mtdraw.c
> @@ -129,6 +129,7 @@ static ssize_t mtdraw_read(struct cdev *cdev, void *buf, size_t count,
>  
>  	while (ret > 0 && count > 0) {
>  		toread = min_t(int, count, mtd->writesize + mtd->oobsize);
> +		toread = min_t(int, toread, mtd->writesize + mtd->oobsize -
>  		skip);
Hi Sasha,

Why the 2 lines of min_t() instead of a single:
toread = min_t(int, count, mtd->writesize + mtd->oobsize - skip)

Cheers.

--
Robert



More information about the barebox mailing list