Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1275393 > unrolled thread

[PATCH] drivers: net: xgene: optimizing the code

Started bySaurabh Sengar <saurabh.truth@gmail.com>
First post2015-11-23 14:40 +0100
Last post2015-11-24 20:40 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] drivers: net: xgene: optimizing the code Saurabh Sengar <saurabh.truth@gmail.com> - 2015-11-23 14:40 +0100
    Re: [PATCH] drivers: net: xgene: optimizing the code David Miller <davem@davemloft.net> - 2015-11-24 20:40 +0100

#1275393 — [PATCH] drivers: net: xgene: optimizing the code

FromSaurabh Sengar <saurabh.truth@gmail.com>
Date2015-11-23 14:40 +0100
Subject[PATCH] drivers: net: xgene: optimizing the code
Message-ID<qxZvA-2lA-11@gated-at.bofh.it>
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>
---
 drivers/net/ethernet/apm/xgene/xgene_enet_main.c | 25 +++++++++---------------
 1 file changed, 9 insertions(+), 16 deletions(-)

diff --git a/drivers/net/ethernet/apm/xgene/xgene_enet_main.c b/drivers/net/ethernet/apm/xgene/xgene_enet_main.c
index 991412c..6096d02 100644
--- a/drivers/net/ethernet/apm/xgene/xgene_enet_main.c
+++ b/drivers/net/ethernet/apm/xgene/xgene_enet_main.c
@@ -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);
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1276727

FromDavid Miller <davem@davemloft.net>
Date2015-11-24 20:40 +0100
Message-ID<qyrBw-3WX-13@gated-at.bofh.it>
In reply to#1275393
From: Saurabh Sengar <saurabh.truth@gmail.com>
Date: Mon, 23 Nov 2015 19:02:15 +0530

> 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>

This looks fine, applied, thanks.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web