generic: mtd: backport SPI_NOR_HAS_LOCK
[openwrt/openwrt.git] / target / linux / layerscape / patches-4.4 / 7212-staging-fsl-dpaa2-mac-Use-of_property_read_32.patch
1 From e554a03fe11719db373be3c54ce8f230a98dd5e4 Mon Sep 17 00:00:00 2001
2 From: Ioana Radulescu <ruxandra.radulescu@nxp.com>
3 Date: Wed, 6 Apr 2016 15:05:47 +0300
4 Subject: [PATCH 212/226] staging: fsl-dpaa2/mac: Use of_property_read_32()
5
6 Simplify reading of the dpmac id from device tree.
7
8 Signed-off-by: Ioana Radulescu <ruxandra.radulescu@nxp.com>
9 (cherry picked from commit b0562bda063f95923bcd8b78dea84a6e0587d3da)
10 ---
11 drivers/staging/fsl-dpaa2/mac/mac.c | 13 +++++--------
12 1 file changed, 5 insertions(+), 8 deletions(-)
13
14 --- a/drivers/staging/fsl-dpaa2/mac/mac.c
15 +++ b/drivers/staging/fsl-dpaa2/mac/mac.c
16 @@ -461,9 +461,8 @@ static struct device_node *lookup_node(s
17 {
18 struct device_node *dpmacs, *dpmac = NULL;
19 struct device_node *mc_node = dev->of_node;
20 - const void *id;
21 - int lenp;
22 - int dpmac_id_be32 = cpu_to_be32(dpmac_id);
23 + u32 id;
24 + int err;
25
26 dpmacs = of_find_node_by_name(mc_node, "dpmacs");
27 if (!dpmacs) {
28 @@ -472,12 +471,10 @@ static struct device_node *lookup_node(s
29 }
30
31 while ((dpmac = of_get_next_child(dpmacs, dpmac))) {
32 - id = of_get_property(dpmac, "reg", &lenp);
33 - if (!id || lenp != sizeof(int)) {
34 - dev_warn(dev, "Unsuitable reg property in dpmac node\n");
35 + err = of_property_read_u32(dpmac, "reg", &id);
36 + if (err)
37 continue;
38 - }
39 - if (*(int *)id == dpmac_id_be32)
40 + if (id == dpmac_id)
41 return dpmac;
42 }
43