Commit 8495659b authored by Srikanth Thokala's avatar Srikanth Thokala Committed by David S. Miller

net: axienet: Use of_property_* calls

Use of_property_* calls
Signed-off-by: default avatarSrikanth Thokala <sthokal@xilinx.com>
Signed-off-by: default avatarMichal Simek <michal.simek@xilinx.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 46aa27df
...@@ -1493,13 +1493,13 @@ static void axienet_dma_err_handler(unsigned long data) ...@@ -1493,13 +1493,13 @@ static void axienet_dma_err_handler(unsigned long data)
*/ */
static int axienet_of_probe(struct platform_device *pdev) static int axienet_of_probe(struct platform_device *pdev)
{ {
__be32 *p; int ret;
int size, ret = 0;
struct device_node *np; struct device_node *np;
struct axienet_local *lp; struct axienet_local *lp;
struct net_device *ndev; struct net_device *ndev;
const void *addr; u8 mac_addr[6];
struct resource *ethres, dmares; struct resource *ethres, dmares;
u32 value;
ndev = alloc_etherdev(sizeof(*lp)); ndev = alloc_etherdev(sizeof(*lp));
if (!ndev) if (!ndev)
...@@ -1529,9 +1529,9 @@ static int axienet_of_probe(struct platform_device *pdev) ...@@ -1529,9 +1529,9 @@ static int axienet_of_probe(struct platform_device *pdev)
/* Setup checksum offload, but default to off if not specified */ /* Setup checksum offload, but default to off if not specified */
lp->features = 0; lp->features = 0;
p = (__be32 *)of_get_property(pdev->dev.of_node, "xlnx,txcsum", NULL); ret = of_property_read_u32(pdev->dev.of_node, "xlnx,txcsum", &value);
if (p) { if (!ret) {
switch (be32_to_cpup(p)) { switch (value) {
case 1: case 1:
lp->csum_offload_on_tx_path = lp->csum_offload_on_tx_path =
XAE_FEATURE_PARTIAL_TX_CSUM; XAE_FEATURE_PARTIAL_TX_CSUM;
...@@ -1550,9 +1550,9 @@ static int axienet_of_probe(struct platform_device *pdev) ...@@ -1550,9 +1550,9 @@ static int axienet_of_probe(struct platform_device *pdev)
lp->csum_offload_on_tx_path = XAE_NO_CSUM_OFFLOAD; lp->csum_offload_on_tx_path = XAE_NO_CSUM_OFFLOAD;
} }
} }
p = (__be32 *)of_get_property(pdev->dev.of_node, "xlnx,rxcsum", NULL); ret = of_property_read_u32(pdev->dev.of_node, "xlnx,rxcsum", &value);
if (p) { if (!ret) {
switch (be32_to_cpup(p)) { switch (value) {
case 1: case 1:
lp->csum_offload_on_rx_path = lp->csum_offload_on_rx_path =
XAE_FEATURE_PARTIAL_RX_CSUM; XAE_FEATURE_PARTIAL_RX_CSUM;
...@@ -1573,13 +1573,8 @@ static int axienet_of_probe(struct platform_device *pdev) ...@@ -1573,13 +1573,8 @@ static int axienet_of_probe(struct platform_device *pdev)
* Here we check for memory allocated for Rx/Tx in the hardware from * Here we check for memory allocated for Rx/Tx in the hardware from
* the device-tree and accordingly set flags. * the device-tree and accordingly set flags.
*/ */
p = (__be32 *)of_get_property(pdev->dev.of_node, "xlnx,rxmem", NULL); of_property_read_u32(pdev->dev.of_node, "xlnx,rxmem", &lp->rxmem);
if (p) of_property_read_u32(pdev->dev.of_node, "xlnx,phy-type", &lp->phy_type);
lp->rxmem = be32_to_cpup(p);
p = (__be32 *)of_get_property(pdev->dev.of_node,
"xlnx,phy-type", NULL);
if (p)
lp->phy_type = be32_to_cpup(p);
/* Find the DMA node, map the DMA registers, and decode the DMA IRQs */ /* Find the DMA node, map the DMA registers, and decode the DMA IRQs */
np = of_parse_phandle(pdev->dev.of_node, "axistream-connected", 0); np = of_parse_phandle(pdev->dev.of_node, "axistream-connected", 0);
...@@ -1609,13 +1604,13 @@ static int axienet_of_probe(struct platform_device *pdev) ...@@ -1609,13 +1604,13 @@ static int axienet_of_probe(struct platform_device *pdev)
} }
/* Retrieve the MAC address */ /* Retrieve the MAC address */
addr = of_get_property(pdev->dev.of_node, "local-mac-address", &size); ret = of_property_read_u8_array(pdev->dev.of_node,
if ((!addr) || (size != 6)) { "local-mac-address", mac_addr, 6);
if (ret) {
dev_err(&pdev->dev, "could not find MAC address\n"); dev_err(&pdev->dev, "could not find MAC address\n");
ret = -ENODEV;
goto free_netdev; goto free_netdev;
} }
axienet_set_mac_address(ndev, (void *) addr); axienet_set_mac_address(ndev, (void *)mac_addr);
lp->coalesce_count_rx = XAXIDMA_DFT_RX_THRESHOLD; lp->coalesce_count_rx = XAXIDMA_DFT_RX_THRESHOLD;
lp->coalesce_count_tx = XAXIDMA_DFT_TX_THRESHOLD; lp->coalesce_count_tx = XAXIDMA_DFT_TX_THRESHOLD;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment