[PATCH v8 8/9] pci: Add support for creating a generic host_bridge from device tree

Jingoo Han
2014-07-11T07:43:21Z

On Wednesday, July 02, 2014 3:44 AM, Liviu Dudau wrote:
>
> Several platforms use a rather generic version of parsing
> the device tree to find the host bridge ranges. Move the common code
> into the generic PCI code and use it to create a pci_host_bridge
> structure that can be used by arch code.
>
> Based on early attempts by Andrew Murray to unify the code.
> Used powerpc and microblaze PCI code as starting point.
>
> Signed-off-by: Liviu Dudau <Liviu.Dudau@arm.com>
> Tested-by: Tanmay Inamdar <tinamdar@apm.com>
> ---
> drivers/of/of_pci.c | 135 ++++++++++++++++++++++++++++++++++++++++++++++
> drivers/pci/host-bridge.c | 18 +++++++
> include/linux/of_pci.h | 10 ++++
> include/linux/pci.h | 8 +++
> 4 files changed, 171 insertions(+)
>
> diff --git a/drivers/of/of_pci.c b/drivers/of/of_pci.c
> index 8481996..55d8320 100644
> --- a/drivers/of/of_pci.c
> +++ b/drivers/of/of_pci.c

[.....]

> +struct pci_host_bridge *
> +of_create_pci_host_bridge(struct device *parent, struct pci_ops *ops, void *host_data)
> +{
> + int err, domain, busno;
> + struct resource *bus_range;
> + struct pci_bus *root_bus;
> + struct pci_host_bridge *bridge;
> + resource_size_t io_base;
> + LIST_HEAD(res);
> +
> + bus_range = kzalloc(sizeof(*bus_range), GFP_KERNEL);
> + if (!bus_range)
> + return ERR_PTR(-ENOMEM);
> +
> + domain = of_alias_get_id(parent->of_node, "pci-domain");
> + if (domain == -ENODEV)
> + domain = atomic_inc_return(&domain_nr);
> +
> + err = of_pci_parse_bus_range(parent->of_node, bus_range);
> + if (err) {
> + dev_info(parent, "No bus range for %s, using default [0-255]\n",
> + parent->of_node->full_name);
> + bus_range->start = 0;
> + bus_range->end = 255;
> + bus_range->flags = IORESOURCE_BUS;
> + }
> + busno = bus_range->start;
> + pci_add_resource(&res, bus_range);
> +
> + /* now parse the rest of host bridge bus ranges */
> + err = pci_host_bridge_of_get_ranges(parent->of_node, &res, &io_base);
> + if (err)
> + goto err_create;
> +
> + /* then create the root bus */
> + root_bus = pci_create_root_bus_in_domain(parent, domain, busno,
> + ops, host_data, &res);
> + if (IS_ERR(root_bus)) {
> + err = PTR_ERR(root_bus);
> + goto err_create;
> + }
> +
> + bridge = to_pci_host_bridge(root_bus->bridge);
> + bridge->io_base = io_base;

Hi Liviu Dudau,

Would you fix the following warning?

drivers/of/of_pci.c: In function 'of_create_pci_host_bridge'
drivers/of/of_pci.c:218:18: warning: 'of_base' may be used uninitialized in this function [-Wmaybe-uninitialized]
bridge->io_base = io_base;

Best regards,
Jingoo Han

[.....]