of_pci: use of_property_read_u32()
authorSergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Sun, 23 Jul 2017 19:41:45 +0000 (22:41 +0300)
committerRob Herring <robh@kernel.org>
Mon, 24 Jul 2017 15:00:34 +0000 (10:00 -0500)
of_get_pci_domain_nr() somehow didn't use of_property_read_u32() though it
was long available, basically open-coding it. Using the modern DT API saves
several LoCs/bytes and also adds some prop sanity checks as a bonus...

Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: Rob Herring <robh@kernel.org>
drivers/of/of_pci.c

index 3d4cb709087837538ae2f7fc9636cd8740793812..0162e4ba30e2c5ec678e3080186b38c4ac435130 100644 (file)
@@ -105,17 +105,14 @@ EXPORT_SYMBOL_GPL(of_pci_parse_bus_range);
  */
 int of_get_pci_domain_nr(struct device_node *node)
 {
-       const __be32 *value;
-       int len;
-       u16 domain;
-
-       value = of_get_property(node, "linux,pci-domain", &len);
-       if (!value || len < sizeof(*value))
-               return -EINVAL;
+       u32 domain;
+       int error;
 
-       domain = (u16)be32_to_cpup(value);
+       error = of_property_read_u32(node, "linux,pci-domain", &domain);
+       if (error)
+               return error;
 
-       return domain;
+       return (u16)domain;
 }
 EXPORT_SYMBOL_GPL(of_get_pci_domain_nr);