On Wed, Mar 23, 2016 at 07:40:21PM -0500, Rob Herring wrote: > PCI device unit addresses are in the form DD or DD,F where DD is the > device 0-0x1f and F is the function 0-7. Add checks that the unit > address matches this form. Hmm.. we ought to be able to do a bit better than this, again by constructing the expected unit address from reg. While we're at it, it probably makes sense to have that dependent on a check which makes sure the first entry in a pci device's 'reg' is the config address. Hmm.. I wonder if what might make sense is to have two whole (possible) sublists of tests within the bus_type structure - one, a list of checks to apply to bridge nodes and the other a list of checks to apply to bus device nodes. > Signed-off-by: Rob Herring <robh@xxxxxxxxxx> > --- > checks.c | 20 ++++++++++++++++++++ > 1 file changed, 20 insertions(+) > > diff --git a/checks.c b/checks.c > index 82a7f38..1d0fcfb 100644 > --- a/checks.c > +++ b/checks.c > @@ -549,10 +549,30 @@ static bool is_pci_bridge(struct node *node) > return false; > } > > +static void pci_unit_addr(struct check *c, struct node *dt, struct node *node) > +{ > + const char *unitname = get_unitname(node); > + unsigned int dev, func; > + int ret; > + > + ret = sscanf(unitname, "%2x,%1x", &dev, &func); > + if (ret >= 1) { > + if (dev > 0x1f) > + FAIL(c, "Node %s PCI device number out of range", > + node->fullpath); > + } > + if (ret == 2) { > + if (func > 7) > + FAIL(c, "Node %s PCI function number out of range", > + node->fullpath); > + } > +} > + > struct bus_type pci_bus_type = { > .expected_addr_cells = 3, > .expected_size_cells = 2, > .is_type = is_pci_bridge, > + .check_unit_addr = pci_unit_addr, > }; > > static bool is_simple_bridge(struct node *node) -- David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Attachment:
signature.asc
Description: PGP signature