Re: [PATCH 4/4] of/pci: Add of_pci_parse_bus_range() function

From: Thierry Reding
Date: Thu Feb 14 2013 - 01:52:35 EST


On Wed, Feb 13, 2013 at 10:58:44PM +0000, Grant Likely wrote:
> On Mon, 11 Feb 2013 09:22:20 +0100, Thierry Reding <thierry.reding@xxxxxxxxxxxxxxxxx> wrote:
> > This function can be used to parse a bus-range property as specified by
> > device nodes representing PCI bridges.
> >
> > Signed-off-by: Thierry Reding <thierry.reding@xxxxxxxxxxxxxxxxx>
>
> Ditto for this one. We can wait on it until there is a user.

This is used by the Tegra driver and as I've explained the reason for
sending these patches separately was to get them merged beforehand to
reduce the number of dependencies that need to be tracked once the
driver is merged (possibly in 3.10, maybe later given the amount of
extra work you want done).

The patch used to be part of the Tegra series, but since Thomas started
using them for his Marvell work I thought it might be a good idea to
make them available separately.

But I can take it back into the Tegra series since that's where we seem
to be headed.

> > +/**
> > + * of_pci_parse_bus_range() - parse the bus-range property of a PCI device
> > + * @node: device node
> > + * @res: address to a struct resource to return the bus-range
> > + *
> > + * Returns 0 on success or a negative error-code on failure.
> > + */
> > +int of_pci_parse_bus_range(struct device_node *node, struct resource *res)
> > +{
> > + const __be32 *values;
> > + int len;
> > +
> > + values = of_get_property(node, "bus-range", &len);
> > + if (!values || len < sizeof(*values) * 2)
> > + return -EINVAL;
> > +
> > + res->name = node->name;
> > + res->start = be32_to_cpup(values++);
> > + res->end = be32_to_cpup(values);
> > + res->flags = IORESOURCE_BUS;
>
> Is there precedence for using struct resource for passing around the PCI
> bus range values? Who will be the user of this function?

The PCI core code actually keeps track of bus-ranges this way. See
drivers/pci/probe.c for instance which uses the global the busn_resource
variable and keeps a list of struct resource:s for each domain as well.

Thierry

Attachment: pgp00000.pgp
Description: PGP signature