drivers: net: xgene: optimizing the code
authorSaurabh Sengar <saurabh.truth@gmail.com>
Mon, 23 Nov 2015 13:32:15 +0000 (19:02 +0530)
committerDavid S. Miller <davem@davemloft.net>
Tue, 24 Nov 2015 19:34:41 +0000 (14:34 -0500)
this patch does the following:
1 .  remove unnecessary if, else condition
2 .  reduce one variable
3 .  change the return type of 2 functions to void as there return values
turn out to be 0 always after above changes

Signed-off-by: Saurabh Sengar <saurabh.truth@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/apm/xgene/xgene_enet_main.c

index 991412ce6f48fbbf6fdfd6255003a0aa90e67e01..6096d0242841f7a811789f1000cc3819ce5c1d1e 100644 (file)
@@ -1084,7 +1084,7 @@ static const struct net_device_ops xgene_ndev_ops = {
 };
 
 #ifdef CONFIG_ACPI
-static int xgene_get_port_id_acpi(struct device *dev,
+static void xgene_get_port_id_acpi(struct device *dev,
                                  struct xgene_enet_pdata *pdata)
 {
        acpi_status status;
@@ -1097,24 +1097,19 @@ static int xgene_get_port_id_acpi(struct device *dev,
                pdata->port_id = temp;
        }
 
-       return 0;
+       return;
 }
 #endif
 
-static int xgene_get_port_id_dt(struct device *dev, struct xgene_enet_pdata *pdata)
+static void xgene_get_port_id_dt(struct device *dev, struct xgene_enet_pdata *pdata)
 {
        u32 id = 0;
-       int ret;
 
-       ret = of_property_read_u32(dev->of_node, "port-id", &id);
-       if (ret) {
-               pdata->port_id = 0;
-               ret = 0;
-       } else {
-               pdata->port_id = id & BIT(0);
-       }
+       of_property_read_u32(dev->of_node, "port-id", &id);
 
-       return ret;
+       pdata->port_id = id & BIT(0);
+
+       return;
 }
 
 static int xgene_get_tx_delay(struct xgene_enet_pdata *pdata)
@@ -1209,13 +1204,11 @@ static int xgene_enet_get_resources(struct xgene_enet_pdata *pdata)
        }
 
        if (dev->of_node)
-               ret = xgene_get_port_id_dt(dev, pdata);
+               xgene_get_port_id_dt(dev, pdata);
 #ifdef CONFIG_ACPI
        else
-               ret = xgene_get_port_id_acpi(dev, pdata);
+               xgene_get_port_id_acpi(dev, pdata);
 #endif
-       if (ret)
-               return ret;
 
        if (!device_get_mac_address(dev, ndev->dev_addr, ETH_ALEN))
                eth_hw_addr_random(ndev);