From: Bjorn Helgaas <bhelgaas@google.com>
Previously pci_parse_request_of_pci_ranges() supplied the default bus range
to devm_of_pci_get_host_bridge_resources(), but that function is static and
has no other callers, so there's no reason to complicate its interface by
passing the default bus range.
Drop the busno and bus_max parameters and use 0x0 and 0xff directly in
devm_of_pci_get_host_bridge_resources().
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
drivers/pci/of.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/drivers/pci/of.c b/drivers/pci/of.c
index 48b9274b846e..a2acfc52caf4 100644
--- a/drivers/pci/of.c
+++ b/drivers/pci/of.c
@@ -302,8 +302,6 @@ EXPORT_SYMBOL_GPL(of_pci_check_probe_only);
* devm_of_pci_get_host_bridge_resources() - Resource-managed parsing of PCI
* host bridge resources from DT
* @dev: host bridge device
- * @busno: bus number associated with the bridge root bus
- * @bus_max: maximum number of buses for this bridge
* @resources: list where the range of resources will be added after DT parsing
* @ib_resources: list where the range of inbound resources (with addresses
* from 'dma-ranges') will be added after DT parsing
@@ -319,7 +317,6 @@ EXPORT_SYMBOL_GPL(of_pci_check_probe_only);
* value if it failed.
*/
static int devm_of_pci_get_host_bridge_resources(struct device *dev,
- unsigned char busno, unsigned char bus_max,
struct list_head *resources,
struct list_head *ib_resources,
resource_size_t *io_base)
@@ -343,12 +340,15 @@ static int devm_of_pci_get_host_bridge_resources(struct device *dev,
err = of_pci_parse_bus_range(dev_node, bus_range);
if (err) {
- bus_range->start = busno;
- bus_range->end = bus_max;
+ bus_range->start = 0;
+ bus_range->end = 0xff;
bus_range->flags = IORESOURCE_BUS;
} else {
- if (bus_range->end > bus_range->start + bus_max)
- bus_range->end = bus_range->start + bus_max;
+ if (bus_range->end > 0xff) {
+ dev_info(dev, " Invalid end bus number in %pR, defaulting to 0xff\n",
+ bus_range);
+ bus_range->end = 0xff;
+ }
}
pci_add_resource(resources, bus_range);
@@ -595,7 +595,7 @@ static int pci_parse_request_of_pci_ranges(struct device *dev,
INIT_LIST_HEAD(&bridge->windows);
INIT_LIST_HEAD(&bridge->dma_ranges);
- err = devm_of_pci_get_host_bridge_resources(dev, 0, 0xff, &bridge->windows,
+ err = devm_of_pci_get_host_bridge_resources(dev, &bridge->windows,
&bridge->dma_ranges, &iobase);
if (err)
return err;
--
2.34.1
Hi Bjorn,
On 1/13/25 3:15 PM, Bjorn Helgaas wrote:
> From: Bjorn Helgaas <bhelgaas@google.com>
>
> Previously pci_parse_request_of_pci_ranges() supplied the default bus range
> to devm_of_pci_get_host_bridge_resources(), but that function is static and
> has no other callers, so there's no reason to complicate its interface by
> passing the default bus range.
>
> Drop the busno and bus_max parameters and use 0x0 and 0xff directly in
> devm_of_pci_get_host_bridge_resources().
>
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
> drivers/pci/of.c | 16 ++++++++--------
> 1 file changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/pci/of.c b/drivers/pci/of.c
> index 48b9274b846e..a2acfc52caf4 100644
> --- a/drivers/pci/of.c
> +++ b/drivers/pci/of.c
> @@ -302,8 +302,6 @@ EXPORT_SYMBOL_GPL(of_pci_check_probe_only);
> * devm_of_pci_get_host_bridge_resources() - Resource-managed parsing of PCI
> * host bridge resources from DT
> * @dev: host bridge device
> - * @busno: bus number associated with the bridge root bus
> - * @bus_max: maximum number of buses for this bridge
> * @resources: list where the range of resources will be added after DT parsing
> * @ib_resources: list where the range of inbound resources (with addresses
> * from 'dma-ranges') will be added after DT parsing
> @@ -319,7 +317,6 @@ EXPORT_SYMBOL_GPL(of_pci_check_probe_only);
> * value if it failed.
> */
> static int devm_of_pci_get_host_bridge_resources(struct device *dev,
> - unsigned char busno, unsigned char bus_max,
> struct list_head *resources,
> struct list_head *ib_resources,
> resource_size_t *io_base)
> @@ -343,12 +340,15 @@ static int devm_of_pci_get_host_bridge_resources(struct device *dev,
>
> err = of_pci_parse_bus_range(dev_node, bus_range);
> if (err) {
> - bus_range->start = busno;
> - bus_range->end = bus_max;
> + bus_range->start = 0;
> + bus_range->end = 0xff;
> bus_range->flags = IORESOURCE_BUS;
> } else {
> - if (bus_range->end > bus_range->start + bus_max)
> - bus_range->end = bus_range->start + bus_max;
> + if (bus_range->end > 0xff) {
> + dev_info(dev, " Invalid end bus number in %pR, defaulting to 0xff\n",
> + bus_range);
Use dev_warn() ? I noticed that dev_info() is used in place of
warning/errors in this file.
Probably it needs to be cleaned?
> + bus_range->end = 0xff;
> + }
> }
> pci_add_resource(resources, bus_range);
>
> @@ -595,7 +595,7 @@ static int pci_parse_request_of_pci_ranges(struct device *dev,
> INIT_LIST_HEAD(&bridge->windows);
> INIT_LIST_HEAD(&bridge->dma_ranges);
>
> - err = devm_of_pci_get_host_bridge_resources(dev, 0, 0xff, &bridge->windows,
> + err = devm_of_pci_get_host_bridge_resources(dev, &bridge->windows,
> &bridge->dma_ranges, &iobase);
> if (err)
> return err;
--
Sathyanarayanan Kuppuswamy
Linux Kernel Developer
On Tue, Jan 14, 2025 at 04:21:15PM -0800, Sathyanarayanan Kuppuswamy wrote:
> On 1/13/25 3:15 PM, Bjorn Helgaas wrote:
> > From: Bjorn Helgaas <bhelgaas@google.com>
> >
> > Previously pci_parse_request_of_pci_ranges() supplied the default bus range
> > to devm_of_pci_get_host_bridge_resources(), but that function is static and
> > has no other callers, so there's no reason to complicate its interface by
> > passing the default bus range.
> >
> > Drop the busno and bus_max parameters and use 0x0 and 0xff directly in
> > devm_of_pci_get_host_bridge_resources().
> > } else {
> > - if (bus_range->end > bus_range->start + bus_max)
> > - bus_range->end = bus_range->start + bus_max;
> > + if (bus_range->end > 0xff) {
> > + dev_info(dev, " Invalid end bus number in %pR, defaulting to 0xff\n",
> > + bus_range);
>
> Use dev_warn() ? I noticed that dev_info() is used in place of
> warning/errors in this file.
Good point, changed.
> Probably it needs to be cleaned?
>
> > + bus_range->end = 0xff;
© 2016 - 2025 Red Hat, Inc.