diff options
author | Rotariu Marian Cristian-B44860 <marian.rotariu@freescale.com> | 2014-10-06 16:37:28 (GMT) |
---|---|---|
committer | Madalin-Cristian Bucur <madalin.bucur@freescale.com> | 2015-03-11 13:19:11 (GMT) |
commit | 25c482d7b522fcee9d679625d46caca845d7f6e5 (patch) | |
tree | 39b404e6f4de33911fdf8c2d64db008c96b61222 /drivers | |
parent | d84b37eb3f1fa37f3a8243e6346d125c97bbda68 (diff) | |
download | linux-fsl-qoriq-25c482d7b522fcee9d679625d46caca845d7f6e5.tar.xz |
dpaa_eth: convert bp dts node in CPU endianess
The addresses used to parse the device tree contain BE data as the entire
device tree data. Because the CPU operates with bp data, conversion to CPU
endianess is needed.
Change-Id: I0f876bde5bbb9832f15289b6ecb192f6c3ba5f56
Signed-off-by: Rotariu Marian Cristian-B44860 <marian.rotariu@freescale.com>
Reviewed-on: http://git.am.freescale.net:8181/20933
Reviewed-by: Madalin-Cristian Bucur <madalin.bucur@freescale.com>
Reviewed-on: http://git.am.freescale.net:8181/32491
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/ethernet/freescale/dpa/dpaa_eth_base.c | 41 |
1 files changed, 17 insertions, 24 deletions
diff --git a/drivers/net/ethernet/freescale/dpa/dpaa_eth_base.c b/drivers/net/ethernet/freescale/dpa/dpaa_eth_base.c index 760718e..9c2204d 100644 --- a/drivers/net/ethernet/freescale/dpa/dpaa_eth_base.c +++ b/drivers/net/ethernet/freescale/dpa/dpaa_eth_base.c @@ -69,33 +69,24 @@ static int dpa_bp_cmp(const void *dpa_bp0, const void *dpa_bp1) struct dpa_bp * __cold __must_check /* __attribute__((nonnull)) */ dpa_bp_probe(struct platform_device *_of_dev, size_t *count) { - int i, lenp, na, ns; + int i, lenp, na, ns, err; struct device *dev; struct device_node *dev_node; - const phandle *phandle_prop; - const uint32_t *bpid; - const uint32_t *bpool_cfg; + const __be32 *bpool_cfg; struct dpa_bp *dpa_bp; + u32 bpid; dev = &_of_dev->dev; - /* The default is one, if there's no property */ - *count = 1; - - /* Get the buffer pools to be used */ - phandle_prop = of_get_property(dev->of_node, - "fsl,bman-buffer-pools", &lenp); - - if (phandle_prop) - *count = lenp / sizeof(phandle); - else { - dev_err(dev, - "missing fsl,bman-buffer-pools device tree entry\n"); + *count = of_count_phandle_with_args(dev->of_node, + "fsl,bman-buffer-pools", NULL); + if (*count < 1) { + dev_err(dev, "missing fsl,bman-buffer-pools device tree entry\n"); return ERR_PTR(-EINVAL); } dpa_bp = devm_kzalloc(dev, *count * sizeof(*dpa_bp), GFP_KERNEL); - if (unlikely(dpa_bp == NULL)) { + if (dpa_bp == NULL) { dev_err(dev, "devm_kzalloc() failed\n"); return ERR_PTR(-ENOMEM); } @@ -109,10 +100,12 @@ dpa_bp_probe(struct platform_device *_of_dev, size_t *count) na = of_n_addr_cells(dev_node); ns = of_n_size_cells(dev_node); - for (i = 0; i < *count && phandle_prop; i++) { + for (i = 0; i < *count; i++) { of_node_put(dev_node); - dev_node = of_find_node_by_phandle(phandle_prop[i]); - if (unlikely(dev_node == NULL)) { + + dev_node = of_parse_phandle(dev->of_node, + "fsl,bman-buffer-pools", i); + if (dev_node == NULL) { dev_err(dev, "of_find_node_by_phandle() failed\n"); return ERR_PTR(-EFAULT); } @@ -125,13 +118,13 @@ dpa_bp_probe(struct platform_device *_of_dev, size_t *count) goto _return_of_node_put; } - bpid = of_get_property(dev_node, "fsl,bpid", &lenp); - if ((bpid == NULL) || (lenp != sizeof(*bpid))) { - dev_err(dev, "fsl,bpid property not found.\n"); + err = of_property_read_u32(dev_node, "fsl,bpid", &bpid); + if (err) { + dev_err(dev, "Cannot find buffer pool ID in the device tree\n"); dpa_bp = ERR_PTR(-EINVAL); goto _return_of_node_put; } - dpa_bp[i].bpid = (uint8_t)*bpid; + dpa_bp[i].bpid = (uint8_t)bpid; bpool_cfg = of_get_property(dev_node, "fsl,bpool-ethernet-cfg", &lenp); |