diff mbox

[U-Boot,v3,10/13] pci: Use a separate 'dev' variable for the PCI device

Message ID 1448592690-14911-11-git-send-email-sjg@chromium.org
State Accepted
Headers show

Commit Message

Simon Glass Nov. 27, 2015, 2:51 a.m. UTC
In the 'pci' command, add a separate variable to hold the PCI device. When
this code is converted to driver model, this variable will be used to hold a
struct udevice instead.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

Changes in v3:
- Fix 'switch (cmd)' merge error

Changes in v2:
- Refactor the patch based on dropping the earlier refactor patch

 common/cmd_pci.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

Comments

Bin Meng Nov. 27, 2015, 7:38 a.m. UTC | #1
On Fri, Nov 27, 2015 at 10:51 AM, Simon Glass <sjg@chromium.org> wrote:
> In the 'pci' command, add a separate variable to hold the PCI device. When
> this code is converted to driver model, this variable will be used to hold a
> struct udevice instead.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
> Changes in v3:
> - Fix 'switch (cmd)' merge error
>
> Changes in v2:
> - Refactor the patch based on dropping the earlier refactor patch
>
>  common/cmd_pci.c | 13 ++++++++-----
>  1 file changed, 8 insertions(+), 5 deletions(-)
>
> diff --git a/common/cmd_pci.c b/common/cmd_pci.c
> index 4874033..857e3e5 100644
> --- a/common/cmd_pci.c
> +++ b/common/cmd_pci.c
> @@ -444,6 +444,7 @@ static int do_pci(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
>  {
>         ulong addr = 0, value = 0, cmd_size = 0;
>         enum pci_size_t size = PCI_SIZE_32;
> +       pci_dev_t dev;
>         int busnum = 0;
>         pci_dev_t bdf = 0;
>         char cmd = 's';
> @@ -488,12 +489,14 @@ static int do_pci(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
>                 return 0;
>         }
>
> +       dev = bdf;
> +
>         switch (argv[1][0]) {
>         case 'h':               /* header */
> -               pci_header_show(bdf);
> +               pci_header_show(dev);
>                 break;
>         case 'd':               /* display */
> -               return pci_cfg_display(bdf, addr, size, value);
> +               return pci_cfg_display(dev, addr, size, value);
>  #ifdef CONFIG_CMD_PCI_ENUM
>         case 'e':
>  # ifdef CONFIG_DM_PCI
> @@ -506,17 +509,17 @@ static int do_pci(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
>         case 'n':               /* next */
>                 if (argc < 4)
>                         goto usage;
> -               ret = pci_cfg_modify(bdf, addr, size, value, 0);
> +               ret = pci_cfg_modify(dev, addr, size, value, 0);
>                 break;
>         case 'm':               /* modify */
>                 if (argc < 4)
>                         goto usage;
> -               ret = pci_cfg_modify(bdf, addr, size, value, 1);
> +               ret = pci_cfg_modify(dev, addr, size, value, 1);
>                 break;
>         case 'w':               /* write */
>                 if (argc < 5)
>                         goto usage;
> -               ret = pci_cfg_write(bdf, addr, size, value);
> +               ret = pci_cfg_write(dev, addr, size, value);
>                 break;
>         default:
>                 ret = CMD_RET_USAGE;
> --

Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Simon Glass Nov. 28, 2015, 4:55 p.m. UTC | #2
On 26 November 2015 at 23:38, Bin Meng <bmeng.cn@gmail.com> wrote:
> On Fri, Nov 27, 2015 at 10:51 AM, Simon Glass <sjg@chromium.org> wrote:
>> In the 'pci' command, add a separate variable to hold the PCI device. When
>> this code is converted to driver model, this variable will be used to hold a
>> struct udevice instead.
>>
>> Signed-off-by: Simon Glass <sjg@chromium.org>
>> ---
>>
>> Changes in v3:
>> - Fix 'switch (cmd)' merge error
>>
>> Changes in v2:
>> - Refactor the patch based on dropping the earlier refactor patch
>>
>>  common/cmd_pci.c | 13 ++++++++-----
>>  1 file changed, 8 insertions(+), 5 deletions(-)

[snip]

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

Thanks for the review.

Applied to u-boot-dm.
diff mbox

Patch

diff --git a/common/cmd_pci.c b/common/cmd_pci.c
index 4874033..857e3e5 100644
--- a/common/cmd_pci.c
+++ b/common/cmd_pci.c
@@ -444,6 +444,7 @@  static int do_pci(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	ulong addr = 0, value = 0, cmd_size = 0;
 	enum pci_size_t size = PCI_SIZE_32;
+	pci_dev_t dev;
 	int busnum = 0;
 	pci_dev_t bdf = 0;
 	char cmd = 's';
@@ -488,12 +489,14 @@  static int do_pci(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 		return 0;
 	}
 
+	dev = bdf;
+
 	switch (argv[1][0]) {
 	case 'h':		/* header */
-		pci_header_show(bdf);
+		pci_header_show(dev);
 		break;
 	case 'd':		/* display */
-		return pci_cfg_display(bdf, addr, size, value);
+		return pci_cfg_display(dev, addr, size, value);
 #ifdef CONFIG_CMD_PCI_ENUM
 	case 'e':
 # ifdef CONFIG_DM_PCI
@@ -506,17 +509,17 @@  static int do_pci(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	case 'n':		/* next */
 		if (argc < 4)
 			goto usage;
-		ret = pci_cfg_modify(bdf, addr, size, value, 0);
+		ret = pci_cfg_modify(dev, addr, size, value, 0);
 		break;
 	case 'm':		/* modify */
 		if (argc < 4)
 			goto usage;
-		ret = pci_cfg_modify(bdf, addr, size, value, 1);
+		ret = pci_cfg_modify(dev, addr, size, value, 1);
 		break;
 	case 'w':		/* write */
 		if (argc < 5)
 			goto usage;
-		ret = pci_cfg_write(bdf, addr, size, value);
+		ret = pci_cfg_write(dev, addr, size, value);
 		break;
 	default:
 		ret = CMD_RET_USAGE;