[U-Boot] [PATCH] sata: fix sata command not being executed bug

Simon Glass sjg at chromium.org
Fri Nov 11 17:18:14 CET 2016


Hi Tang,

On 9 November 2016 at 02:37,  <yuantian.tang at nxp.com> wrote:
> From: Tang Yuantian <Yuantian.Tang at nxp.com>
>
> Variable sata_curr_device is used to indicate if
> there is a available sata disk on board.
>
> Previously, sata_curr_device is set in sata_initialize().
> Now, sata_initialize() is separated from other sata commands.
> Accordingly, sata_curr_device is removed from sata_initialize() too.
> This caused sata_curr_device never gets a chance to be set.
> If it can't be set a proper value, other sata command will never get
> a change to execute.
>
> This patch sets variable sata_curr_device properly.
>
> Signed-off-by: Tang Yuantian <yuantian.tang at nxp.com>
> ---
>  cmd/sata.c | 13 ++++++++++---
>  1 file changed, 10 insertions(+), 3 deletions(-)

Does this fix commit d97dc8a0 - if so can you please add a 'Fixes:' tag?

>
> diff --git a/cmd/sata.c b/cmd/sata.c
> index d18b523..71c785f 100644
> --- a/cmd/sata.c
> +++ b/cmd/sata.c
> @@ -20,6 +20,7 @@ static int sata_curr_device = -1;
>  static int do_sata(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
>  {
>         int rc = 0;
> +       int i;
>
>         if (argc == 2 && strcmp(argv[1], "stop") == 0)
>                 return sata_stop();
> @@ -32,9 +33,15 @@ static int do_sata(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
>         }
>
>         /* If the user has not yet run `sata init`, do it now */
> -       if (sata_curr_device == -1)
> -               if (sata_initialize())
> -                       return 1;
> +       if (sata_curr_device == -1) {
> +               rc = sata_initialize();
> +               for (i = 0; i < CONFIG_SYS_SATA_MAX_DEVICE; i++) {
> +                       if (sata_dev_desc[i].lba > 0)
> +                               sata_curr_device = i;
> +               }
> +               if (sata_curr_device == -1)
> +                       return -1;

Can this code go in its own function?

> +       }
>
>         switch (argc) {
>         case 0:
> --
> 2.1.0.27.g96db324
>

Regards,
Simon


More information about the U-Boot mailing list