lkml.org 
[lkml]   [2009]   [Aug]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] nftl: fix offset alignments
On Wed, 19 Aug 2009 00:06:28 +0200 (CEST) dimitri.gorokhovik@free.fr wrote:

> Arithmetic conversion in the mask computation makes the upper word
> of the second argument passed down to mtd->read_oob(), be always 0
> (assuming 'offs' being a 64-bit signed long long type, and
> 'mtd->writesize' being a 32-bit unsigned int type).
>
> This patch applies over the other one adding masking in nftl_write,
> "nftl: write support is broken".
>
> Signed-off-by: <dimitri.gorokhovik@free.fr>
> ---
>
> diff --git a/drivers/mtd/nftlcore.c b/drivers/mtd/nftlcore.c
> index 665d3eb..d2fd066 100644
> --- a/drivers/mtd/nftlcore.c
> +++ b/drivers/mtd/nftlcore.c
> @@ -135,16 +135,17 @@ static void nftl_remove_dev(struct mtd_blktrans_dev *dev)
> int nftl_read_oob(struct mtd_info *mtd, loff_t offs, size_t len,
> size_t *retlen, uint8_t *buf)
> {
> + typeof(offs) mask = mtd->writesize - 1;

I see no reason to use typeof here. Plain old

loff_t mask = mtd->writesize - 1;

would be more conventional.

> struct mtd_oob_ops ops;
> int res;
>
> ops.mode = MTD_OOB_PLACE;
> - ops.ooboffs = offs & (mtd->writesize - 1);
> + ops.ooboffs = offs & mask;
> ops.ooblen = len;
> ops.oobbuf = buf;
> ops.datbuf = NULL;
>
> - res = mtd->read_oob(mtd, offs & ~(mtd->writesize - 1), &ops);
> + res = mtd->read_oob(mtd, offs & ~mask, &ops);

yup.



\
 
 \ /
  Last update: 2009-08-20 01:39    [W:0.045 / U:0.416 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site