[U-Boot] [PATCH] mmc and fat bug fixes

Andy Fleming afleming at gmail.com
Thu May 16 00:14:37 CEST 2013


On Wed, May 15, 2013 at 9:23 AM, Ruud Commandeur <RCommandeur at clb.nl> wrote:

> This patch fixes a number of mmc and fat-related bugs:
>
> > Added a check for blkcnt > 0 in mmc_write_blocks (drivers/mmc.c) to
> prevent a hangup for further mmc commands.
>


You need more information than that. Why is some code requesting 0-byte
data commands?

As others mentioned, you need to break up patches so each change is one
patch.



> Index: drivers/mmc/mmc.c
> ===================================================================
> --- drivers/mmc/mmc.c   (revision 9)
> +++ drivers/mmc/mmc.c   (working copy)
> @@ -282,8 +282,9 @@
>
>         if (blkcnt > 1)
>                 cmd.cmdidx = MMC_CMD_WRITE_MULTIPLE_BLOCK;
> -       else
> +       else if (blkcnt > 0)
>                 cmd.cmdidx = MMC_CMD_WRITE_SINGLE_BLOCK;
> +       else return 0;          //Called with blkcnt = 0
>


Assuming this is necessary, I think it then might be time to reorder this:

if (!blkcnt) <-- possibly at the very start of the function.
  return 0;

if (blkcnt == 1)
  cmd.cmdidx = MMC_CMD_WRITE_SINGLE_BLOCK;
else
  cmd.cmdidx = MMC_CMD_WRITE_MULTIPLE_BLOCK;

While technically correct, checking >1, then >0 creates an odd dissonance
in my mind, and makes me have to think about when that if clause will
evaluate to true, and I hate having to think. :)

Andy


More information about the U-Boot mailing list