mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] mtd mtdraw: Fix partial page read
@ 2012-09-15 14:56 Sascha Hauer
  2012-09-16  8:46 ` Robert Jarzmik
  0 siblings, 1 reply; 4+ messages in thread
From: Sascha Hauer @ 2012-09-15 14:56 UTC (permalink / raw)
  To: barebox

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@pengutronix.de>
Cc: Robert Jarzmik <robert.jarzmik@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);
 		ret = mtdraw_read_unaligned(mtd, buf, toread,
 					    skip, numpage++ * mtd->writesize);
 		buf += ret;
-- 
1.7.10.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mtd mtdraw: Fix partial page read
  2012-09-15 14:56 [PATCH] mtd mtdraw: Fix partial page read Sascha Hauer
@ 2012-09-16  8:46 ` Robert Jarzmik
  2012-09-16  8:58   ` Sascha Hauer
  0 siblings, 1 reply; 4+ messages in thread
From: Robert Jarzmik @ 2012-09-16  8:46 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

Sascha Hauer <s.hauer@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@pengutronix.de>
> Cc: Robert Jarzmik <robert.jarzmik@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

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mtd mtdraw: Fix partial page read
  2012-09-16  8:46 ` Robert Jarzmik
@ 2012-09-16  8:58   ` Sascha Hauer
  2012-09-16 19:44     ` Robert Jarzmik
  0 siblings, 1 reply; 4+ messages in thread
From: Sascha Hauer @ 2012-09-16  8:58 UTC (permalink / raw)
  To: Robert Jarzmik; +Cc: barebox

On Sun, Sep 16, 2012 at 10:46:54AM +0200, Robert Jarzmik wrote:
> Sascha Hauer <s.hauer@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@pengutronix.de>
> > Cc: Robert Jarzmik <robert.jarzmik@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)

Yeah, this doubles the efficiency ;) Will do that instead.

Thanks
 Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mtd mtdraw: Fix partial page read
  2012-09-16  8:58   ` Sascha Hauer
@ 2012-09-16 19:44     ` Robert Jarzmik
  0 siblings, 0 replies; 4+ messages in thread
From: Robert Jarzmik @ 2012-09-16 19:44 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

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

> On Sun, Sep 16, 2012 at 10:46:54AM +0200, Robert Jarzmik wrote:
>> Sascha Hauer <s.hauer@pengutronix.de> writes:
> Yeah, this doubles the efficiency ;) Will do that instead.
Excellent :) Then please add my:
Acked-by: Robert Jarzmik <robert.jarzmik@free.fr>

Cheers.

-- 
Robert

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-09-16 19:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-09-15 14:56 [PATCH] mtd mtdraw: Fix partial page read Sascha Hauer
2012-09-16  8:46 ` Robert Jarzmik
2012-09-16  8:58   ` Sascha Hauer
2012-09-16 19:44     ` Robert Jarzmik

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox