Skip to contentSkip to conversation

of_pci: use of_property_read_u32()

PATCH In review Sergei Shtylyov 1 participant 1 message Jul 23, 2017 Device tree

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 of_pci: use of_property_read_u32()

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...

---
 drivers/of/of_pci.c |   15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)
drivers/of/of_pci.c +6 -9
Index: linux/drivers/of/of_pci.c
===================================================================
@@ -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;
+	u32 domain;
+	int error;
 
-	value = of_get_property(node, "linux,pci-domain", &len);
-	if (!value || len < sizeof(*value))
-		return -EINVAL;
+	error = of_property_read_u32(node, "linux,pci-domain", &domain);
+	if (error)
+		return error;
 
-	domain = (u16)be32_to_cpup(value);
-
-	return domain;
+	return (u16)domain;
 }
 EXPORT_SYMBOL_GPL(of_get_pci_domain_nr);
 

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html