Message ID | 1455502619-16093-3-git-send-email-sjg@chromium.org |
---|---|
State | Superseded |
Delegated to: | Simon Glass |
Headers | show |
Hi Simon, On Mon, Feb 15, 2016 at 10:16 AM, Simon Glass <sjg@chromium.org> wrote: > Each region is displayed in almost the same way. Break out this common code > into its own function. > > Signed-off-by: Simon Glass <sjg@chromium.org> > --- > > drivers/pci/pci_auto_common.c | 51 +++++++++++++++---------------------------- > 1 file changed, 17 insertions(+), 34 deletions(-) > > diff --git a/drivers/pci/pci_auto_common.c b/drivers/pci/pci_auto_common.c > index 85c419e..a5c16b9 100644 > --- a/drivers/pci/pci_auto_common.c > +++ b/drivers/pci/pci_auto_common.c > @@ -62,6 +62,17 @@ int pciauto_region_allocate(struct pci_region *res, pci_size_t size, > return -1; > } > > +static void pciauto_show_region(const char *name, struct pci_region *region) > +{ > + pciauto_region_init(region); > + debug("PCI Autoconfig: Bus %s region: [0x%llx-0x%llx],\n" > + "\t\tPhysical Memory [%llx-%llxx]\n", name, While we are here, can we add '0x' prefix to Physical Memory output? > + (unsigned long long)region->bus_start, > + (unsigned long long)(region->bus_start + region->size - 1), > + (unsigned long long)region->phys_start, > + (unsigned long long)(region->phys_start + region->size - 1)); Why changing previous (u64) to (unsigned long long)? > +} > + > void pciauto_config_init(struct pci_controller *hose) > { > int i; > @@ -91,38 +102,10 @@ void pciauto_config_init(struct pci_controller *hose) > } > > > - if (hose->pci_mem) { > - pciauto_region_init(hose->pci_mem); > - > - debug("PCI Autoconfig: Bus Memory region: [0x%llx-0x%llx],\n" > - "\t\tPhysical Memory [%llx-%llxx]\n", > - (u64)hose->pci_mem->bus_start, > - (u64)(hose->pci_mem->bus_start + hose->pci_mem->size - 1), > - (u64)hose->pci_mem->phys_start, > - (u64)(hose->pci_mem->phys_start + hose->pci_mem->size - 1)); > - } > - > - if (hose->pci_prefetch) { > - pciauto_region_init(hose->pci_prefetch); > - > - debug("PCI Autoconfig: Bus Prefetchable Mem: [0x%llx-0x%llx],\n" > - "\t\tPhysical Memory [%llx-%llx]\n", > - (u64)hose->pci_prefetch->bus_start, > - (u64)(hose->pci_prefetch->bus_start + > - hose->pci_prefetch->size - 1), > - (u64)hose->pci_prefetch->phys_start, > - (u64)(hose->pci_prefetch->phys_start + > - hose->pci_prefetch->size - 1)); > - } > - > - if (hose->pci_io) { > - pciauto_region_init(hose->pci_io); > - > - debug("PCI Autoconfig: Bus I/O region: [0x%llx-0x%llx],\n" > - "\t\tPhysical Memory: [%llx-%llx]\n", > - (u64)hose->pci_io->bus_start, > - (u64)(hose->pci_io->bus_start + hose->pci_io->size - 1), > - (u64)hose->pci_io->phys_start, > - (u64)(hose->pci_io->phys_start + hose->pci_io->size - 1)); > - } > + if (hose->pci_mem) > + pciauto_show_region("Memory", hose->pci_mem); > + if (hose->pci_prefetch) > + pciauto_show_region("Prefetchable Mem", hose->pci_mem); > + if (hose->pci_io) > + pciauto_show_region("I/O", hose->pci_io); > } > -- Regards, Bin
On 02/14/2016 07:16 PM, Simon Glass wrote: > Each region is displayed in almost the same way. Break out this common code > into its own function. > diff --git a/drivers/pci/pci_auto_common.c b/drivers/pci/pci_auto_common.c > + if (hose->pci_mem) > + pciauto_show_region("Memory", hose->pci_mem); > + if (hose->pci_prefetch) > + pciauto_show_region("Prefetchable Mem", hose->pci_mem); That parameter should be hose->pci_prefetch > + if (hose->pci_io) > + pciauto_show_region("I/O", hose->pci_io); With that fixed, the "dhcp" failure I mentioned earlier is fixed (the system in question uses PCIe Ethernet).
Hi Bin, On 16 February 2016 at 03:09, Bin Meng <bmeng.cn@gmail.com> wrote: > Hi Simon, > > On Mon, Feb 15, 2016 at 10:16 AM, Simon Glass <sjg@chromium.org> wrote: >> Each region is displayed in almost the same way. Break out this common code >> into its own function. >> >> Signed-off-by: Simon Glass <sjg@chromium.org> >> --- >> >> drivers/pci/pci_auto_common.c | 51 +++++++++++++++---------------------------- >> 1 file changed, 17 insertions(+), 34 deletions(-) >> >> diff --git a/drivers/pci/pci_auto_common.c b/drivers/pci/pci_auto_common.c >> index 85c419e..a5c16b9 100644 >> --- a/drivers/pci/pci_auto_common.c >> +++ b/drivers/pci/pci_auto_common.c >> @@ -62,6 +62,17 @@ int pciauto_region_allocate(struct pci_region *res, pci_size_t size, >> return -1; >> } >> >> +static void pciauto_show_region(const char *name, struct pci_region *region) >> +{ >> + pciauto_region_init(region); >> + debug("PCI Autoconfig: Bus %s region: [0x%llx-0x%llx],\n" >> + "\t\tPhysical Memory [%llx-%llxx]\n", name, > > While we are here, can we add '0x' prefix to Physical Memory output? We shouldn't really do that - in fact the 0x should probably be removed, since hex is U-Boot's default display base. > >> + (unsigned long long)region->bus_start, >> + (unsigned long long)(region->bus_start + region->size - 1), >> + (unsigned long long)region->phys_start, >> + (unsigned long long)(region->phys_start + region->size - 1)); > > Why changing previous (u64) to (unsigned long long)? It fixes a compiler warning on sandbox for me using stdint.h. Not a big deal but I thought I'd do it at the same time. > >> +} >> + >> void pciauto_config_init(struct pci_controller *hose) >> { >> int i; >> @@ -91,38 +102,10 @@ void pciauto_config_init(struct pci_controller *hose) >> } >> >> >> - if (hose->pci_mem) { >> - pciauto_region_init(hose->pci_mem); >> - >> - debug("PCI Autoconfig: Bus Memory region: [0x%llx-0x%llx],\n" >> - "\t\tPhysical Memory [%llx-%llxx]\n", >> - (u64)hose->pci_mem->bus_start, >> - (u64)(hose->pci_mem->bus_start + hose->pci_mem->size - 1), >> - (u64)hose->pci_mem->phys_start, >> - (u64)(hose->pci_mem->phys_start + hose->pci_mem->size - 1)); >> - } >> - >> - if (hose->pci_prefetch) { >> - pciauto_region_init(hose->pci_prefetch); >> - >> - debug("PCI Autoconfig: Bus Prefetchable Mem: [0x%llx-0x%llx],\n" >> - "\t\tPhysical Memory [%llx-%llx]\n", >> - (u64)hose->pci_prefetch->bus_start, >> - (u64)(hose->pci_prefetch->bus_start + >> - hose->pci_prefetch->size - 1), >> - (u64)hose->pci_prefetch->phys_start, >> - (u64)(hose->pci_prefetch->phys_start + >> - hose->pci_prefetch->size - 1)); >> - } >> - >> - if (hose->pci_io) { >> - pciauto_region_init(hose->pci_io); >> - >> - debug("PCI Autoconfig: Bus I/O region: [0x%llx-0x%llx],\n" >> - "\t\tPhysical Memory: [%llx-%llx]\n", >> - (u64)hose->pci_io->bus_start, >> - (u64)(hose->pci_io->bus_start + hose->pci_io->size - 1), >> - (u64)hose->pci_io->phys_start, >> - (u64)(hose->pci_io->phys_start + hose->pci_io->size - 1)); >> - } >> + if (hose->pci_mem) >> + pciauto_show_region("Memory", hose->pci_mem); >> + if (hose->pci_prefetch) >> + pciauto_show_region("Prefetchable Mem", hose->pci_mem); >> + if (hose->pci_io) >> + pciauto_show_region("I/O", hose->pci_io); >> } >> -- > > Regards, > Bin Regards, Simon
diff --git a/drivers/pci/pci_auto_common.c b/drivers/pci/pci_auto_common.c index 85c419e..a5c16b9 100644 --- a/drivers/pci/pci_auto_common.c +++ b/drivers/pci/pci_auto_common.c @@ -62,6 +62,17 @@ int pciauto_region_allocate(struct pci_region *res, pci_size_t size, return -1; } +static void pciauto_show_region(const char *name, struct pci_region *region) +{ + pciauto_region_init(region); + debug("PCI Autoconfig: Bus %s region: [0x%llx-0x%llx],\n" + "\t\tPhysical Memory [%llx-%llxx]\n", name, + (unsigned long long)region->bus_start, + (unsigned long long)(region->bus_start + region->size - 1), + (unsigned long long)region->phys_start, + (unsigned long long)(region->phys_start + region->size - 1)); +} + void pciauto_config_init(struct pci_controller *hose) { int i; @@ -91,38 +102,10 @@ void pciauto_config_init(struct pci_controller *hose) } - if (hose->pci_mem) { - pciauto_region_init(hose->pci_mem); - - debug("PCI Autoconfig: Bus Memory region: [0x%llx-0x%llx],\n" - "\t\tPhysical Memory [%llx-%llxx]\n", - (u64)hose->pci_mem->bus_start, - (u64)(hose->pci_mem->bus_start + hose->pci_mem->size - 1), - (u64)hose->pci_mem->phys_start, - (u64)(hose->pci_mem->phys_start + hose->pci_mem->size - 1)); - } - - if (hose->pci_prefetch) { - pciauto_region_init(hose->pci_prefetch); - - debug("PCI Autoconfig: Bus Prefetchable Mem: [0x%llx-0x%llx],\n" - "\t\tPhysical Memory [%llx-%llx]\n", - (u64)hose->pci_prefetch->bus_start, - (u64)(hose->pci_prefetch->bus_start + - hose->pci_prefetch->size - 1), - (u64)hose->pci_prefetch->phys_start, - (u64)(hose->pci_prefetch->phys_start + - hose->pci_prefetch->size - 1)); - } - - if (hose->pci_io) { - pciauto_region_init(hose->pci_io); - - debug("PCI Autoconfig: Bus I/O region: [0x%llx-0x%llx],\n" - "\t\tPhysical Memory: [%llx-%llx]\n", - (u64)hose->pci_io->bus_start, - (u64)(hose->pci_io->bus_start + hose->pci_io->size - 1), - (u64)hose->pci_io->phys_start, - (u64)(hose->pci_io->phys_start + hose->pci_io->size - 1)); - } + if (hose->pci_mem) + pciauto_show_region("Memory", hose->pci_mem); + if (hose->pci_prefetch) + pciauto_show_region("Prefetchable Mem", hose->pci_mem); + if (hose->pci_io) + pciauto_show_region("I/O", hose->pci_io); }
Each region is displayed in almost the same way. Break out this common code into its own function. Signed-off-by: Simon Glass <sjg@chromium.org> --- drivers/pci/pci_auto_common.c | 51 +++++++++++++++---------------------------- 1 file changed, 17 insertions(+), 34 deletions(-)