[U-Boot] [PATCH 02/14] pci: Use a common return in command processing

Bin Meng bmeng.cn at gmail.com
Fri Nov 13 05:26:18 CET 2015


On Fri, Nov 13, 2015 at 5:45 AM, Simon Glass <sjg at chromium.org> wrote:
> Adjust the commands to return from the same place.
>
> Signed-off-by: Simon Glass <sjg at chromium.org>
> ---
>
>  common/cmd_pci.c | 21 ++++++++++++++-------
>  1 file changed, 14 insertions(+), 7 deletions(-)
>
> diff --git a/common/cmd_pci.c b/common/cmd_pci.c
> index 4f4c341..5762769 100644
> --- a/common/cmd_pci.c
> +++ b/common/cmd_pci.c
> @@ -409,6 +409,7 @@ static int do_pci(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
>         ulong addr = 0, value = 0, size = 0;
>         pci_dev_t bdf = 0;
>         char cmd = 's';
> +       int ret = 0;
>
>         if (argc > 1)
>                 cmd = argv[1][0];
> @@ -452,7 +453,7 @@ static int do_pci(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
>         switch (cmd) {
>         case 'h':               /* header */
>                 pci_header_show(bdf);
> -               return 0;
> +               break;
>         case 'd':               /* display */
>                 return pci_cfg_display(bdf, addr, size, value);
>  #ifdef CONFIG_CMD_PCI_ENUM
> @@ -462,26 +463,32 @@ static int do_pci(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
>  # else
>                 pci_init();
>  # endif
> -               return 0;
> +               break;
>  #endif
>         case 'n':               /* next */
>                 if (argc < 4)
>                         goto usage;
> -               return pci_cfg_modify(bdf, addr, size, value, 0);
> +               ret = pci_cfg_modify(bdf, addr, size, value, 0);
> +               break;
>         case 'm':               /* modify */
>                 if (argc < 4)
>                         goto usage;
> -               return pci_cfg_modify(bdf, addr, size, value, 1);
> +               ret = pci_cfg_modify(bdf, addr, size, value, 1);
> +               break;
>         case 's':
>                 pciinfo(bdf, value);
> -               return 0;
> +               break;
>         case 'w':               /* write */
>                 if (argc < 5)
>                         goto usage;
> -               return pci_cfg_write(bdf, addr, size, value);
> +               ret = pci_cfg_write(bdf, addr, size, value);
> +               break;
> +       default:
> +               ret = CMD_RET_USAGE;
> +               break;
>         }
>
> -       return 1;
> +       return ret;
>   usage:
>         return CMD_RET_USAGE;
>  }
> --

Reviewed-by: Bin Meng <bmeng.cn at gmail.com>


More information about the U-Boot mailing list