aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/layerscape/patches-4.4/7212-staging-fsl-dpaa2-mac-Use-of_property_read_32.patch
blob: 8ab6de9bf00e3faea3164656257d32c5bf8864aa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
From e554a03fe11719db373be3c54ce8f230a98dd5e4 Mon Sep 17 00:00:00 2001
From: Ioana Radulescu <ruxandra.radulescu@nxp.com>
Date: Wed, 6 Apr 2016 15:05:47 +0300
Subject: [PATCH 212/226] staging: fsl-dpaa2/mac: Use of_property_read_32()

Simplify reading of the dpmac id from device tree.

Signed-off-by: Ioana Radulescu <ruxandra.radulescu@nxp.com>
(cherry picked from commit b0562bda063f95923bcd8b78dea84a6e0587d3da)
---
 drivers/staging/fsl-dpaa2/mac/mac.c |   13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

--- a/drivers/staging/fsl-dpaa2/mac/mac.c
+++ b/drivers/staging/fsl-dpaa2/mac/mac.c
@@ -461,9 +461,8 @@ static struct device_node *lookup_node(s
 {
 	struct device_node *dpmacs, *dpmac = NULL;
 	struct device_node *mc_node = dev->of_node;
-	const void *id;
-	int lenp;
-	int dpmac_id_be32 = cpu_to_be32(dpmac_id);
+	u32 id;
+	int err;
 
 	dpmacs = of_find_node_by_name(mc_node, "dpmacs");
 	if (!dpmacs) {
@@ -472,12 +471,10 @@ static struct device_node *lookup_node(s
 	}
 
 	while ((dpmac = of_get_next_child(dpmacs, dpmac))) {
-		id = of_get_property(dpmac, "reg", &lenp);
-		if (!id || lenp != sizeof(int)) {
-			dev_warn(dev, "Unsuitable reg property in dpmac node\n");
+		err = of_property_read_u32(dpmac, "reg", &id);
+		if (err)
 			continue;
-		}
-		if (*(int *)id == dpmac_id_be32)
+		if (id == dpmac_id)
 			return dpmac;
 	}