[PATCH] separate routine to check jffs2_flash_read

Jörn Engel joern at wohnheim.fh-wedel.de
Mon Oct 31 09:33:45 EST 2005


On Mon, 31 October 2005 11:12:06 +0100, pierre.ricadat at utbm.fr wrote:
> 
> I made the two changes you proposed:
> - new function (jffs2_flash_read_safe) who calls jffs2_flash_read and checks it
> - better return code
> 
> So i attach the new patch.

Better.  There's one bit that actually concerns me, though:

> diff -u ./mtd/fs/jffs2/nodelist.c ./mtd_pierre/fs/jffs2/nodelist.c
> --- ./mtd/fs/jffs2/nodelist.c   2005-09-21 22:28:35.000000000 +0900
> +++ ./mtd_pierre/fs/jffs2/nodelist.c    2005-10-31 18:27:34.000000000 +0900
> @@ -451,19 +451,8 @@
>                 if (unlikely(!buffer))
>                         return -ENOMEM;
> 
> -               /* TODO: this is very frequent pattern, make it a separate
> -                * routine */
> -               err = jffs2_flash_read(c, ofs, len, &retlen, buffer);
> -               if (err) {
> -                       JFFS2_ERROR("can not read %d bytes from 0x%08x, error code: %d.\n", len, ofs, err);
> -                       goto free_out;
> -               }
> -
> -               if (retlen != len) {
> -                       JFFS2_ERROR("short read at %#08x: %d instead of %d.\n", ofs, retlen, len);
> -                       err = -EIO;
> -                       goto free_out;
> -               }
> +               if (jffs2_flash_read_safe(c, ofs, len, buffer))
> +                       return -EIO;
>         }
> 
>         /* Continue calculating CRC */
> @@ -498,14 +487,6 @@
> 
>         return 0;
> 
> -free_out:
> -       if(!pointed)
> -               kfree(buffer);
> -#ifndef __ECOS
> -       else
> -               c->mtd->unpoint(c->mtd, buffer, ofs, len);
> -#endif
> -       return err;
>  }

Nowhere in jffs2_flash_read_safe() do you call c->mtd->unpoint.  So
obviously your code is not equivalent to the existing.  Can you look
into it and see what needs to be don?


Jörn

-- 
When you close your hand, you own nothing. When you open it up, you
own the whole world.
-- Li Mu Bai in Tiger & Dragon




More information about the linux-mtd mailing list