[PATCH] wan: wanxl: add pci_disable_device in case of error

2015-12-11 Thread Saurabh Sengar
If there is 'no suitable DMA available' error, device should be disabled
before returning

Signed-off-by: Saurabh Sengar 
---
 drivers/net/wan/wanxl.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/wan/wanxl.c b/drivers/net/wan/wanxl.c
index e73f138..a20d688 100644
--- a/drivers/net/wan/wanxl.c
+++ b/drivers/net/wan/wanxl.c
@@ -586,6 +586,7 @@ static int wanxl_pci_init_one(struct pci_dev *pdev,
if (pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(28)) ||
pci_set_dma_mask(pdev, DMA_BIT_MASK(28))) {
pr_err("No usable DMA configuration\n");
+   pci_disable_device(pdev);
return -EIO;
}
 
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] net: fec: no need to test for the return type of of_property_read_u32

2015-11-23 Thread Saurabh Sengar
in case of error no need to set num_tx and num_rx = 1, because in case of error
these variables will remain unchanged by of_property_read_u32 ie 1 only

Signed-off-by: Saurabh Sengar 
---
 drivers/net/ethernet/freescale/fec_main.c | 9 ++---
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/freescale/fec_main.c 
b/drivers/net/ethernet/freescale/fec_main.c
index b2a3220..d2328fc 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -3277,7 +3277,6 @@ static void
 fec_enet_get_queue_num(struct platform_device *pdev, int *num_tx, int *num_rx)
 {
struct device_node *np = pdev->dev.of_node;
-   int err;
 
*num_tx = *num_rx = 1;
 
@@ -3285,13 +3284,9 @@ fec_enet_get_queue_num(struct platform_device *pdev, int 
*num_tx, int *num_rx)
return;
 
/* parse the num of tx and rx queues */
-   err = of_property_read_u32(np, "fsl,num-tx-queues", num_tx);
-   if (err)
-   *num_tx = 1;
+   of_property_read_u32(np, "fsl,num-tx-queues", num_tx);
 
-   err = of_property_read_u32(np, "fsl,num-rx-queues", num_rx);
-   if (err)
-   *num_rx = 1;
+   of_property_read_u32(np, "fsl,num-rx-queues", num_rx);
 
if (*num_tx < 1 || *num_tx > FEC_ENET_MAX_TX_QS) {
dev_warn(&pdev->dev, "Invalid num_tx(=%d), fall back to 1\n",
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


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

2015-11-23 Thread Saurabh Sengar
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 
---
 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 netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] gianfar: use of_property_read_bool()

2015-11-20 Thread Saurabh Sengar
use of_property_read_bool() for testing bool property

Signed-off-by: Saurabh Sengar 
---
 drivers/net/ethernet/freescale/gianfar.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/freescale/gianfar.c 
b/drivers/net/ethernet/freescale/gianfar.c
index 3e6b9b4..ebeea5e 100644
--- a/drivers/net/ethernet/freescale/gianfar.c
+++ b/drivers/net/ethernet/freescale/gianfar.c
@@ -738,7 +738,6 @@ static int gfar_of_init(struct platform_device *ofdev, 
struct net_device **pdev)
struct gfar_private *priv = NULL;
struct device_node *np = ofdev->dev.of_node;
struct device_node *child = NULL;
-   struct property *stash;
u32 stash_len = 0;
u32 stash_idx = 0;
unsigned int num_tx_qs, num_rx_qs;
@@ -854,9 +853,7 @@ static int gfar_of_init(struct platform_device *ofdev, 
struct net_device **pdev)
goto err_grp_init;
}
 
-   stash = of_find_property(np, "bd-stash", NULL);
-
-   if (stash) {
+   if (of_property_read_bool(np, "bd-stash")) {
priv->device_flags |= FSL_GIANFAR_DEV_HAS_BD_STASHING;
priv->bd_stash_en = 1;
}
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2] net: rds: changing the return type from int to void

2015-10-30 Thread Saurabh Sengar
as result of function rds_iw_flush_mr_pool is nowhere checked,
changing its return type from int to void.
also removing the unused variable rc as there is nothing to return

Signed-off-by: Saurabh Sengar 
---
v2 :  modify patch description, as per the comments from Sergei Shtylyov

 net/rds/iw_rdma.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/net/rds/iw_rdma.c b/net/rds/iw_rdma.c
index 6a8fbd6..d3d4454f 100644
--- a/net/rds/iw_rdma.c
+++ b/net/rds/iw_rdma.c
@@ -75,7 +75,7 @@ struct rds_iw_mr_pool {
int max_pages;
 };
 
-static int rds_iw_flush_mr_pool(struct rds_iw_mr_pool *pool, int free_all);
+static void rds_iw_flush_mr_pool(struct rds_iw_mr_pool *pool, int free_all);
 static void rds_iw_mr_pool_flush_worker(struct work_struct *work);
 static int rds_iw_init_fastreg(struct rds_iw_mr_pool *pool, struct rds_iw_mr 
*ibmr);
 static int rds_iw_map_fastreg(struct rds_iw_mr_pool *pool,
@@ -479,14 +479,13 @@ void rds_iw_sync_mr(void *trans_private, int direction)
  * If the number of MRs allocated exceeds the limit, we also try
  * to free as many MRs as needed to get back to this limit.
  */
-static int rds_iw_flush_mr_pool(struct rds_iw_mr_pool *pool, int free_all)
+static void rds_iw_flush_mr_pool(struct rds_iw_mr_pool *pool, int free_all)
 {
struct rds_iw_mr *ibmr, *next;
LIST_HEAD(unmap_list);
LIST_HEAD(kill_list);
unsigned long flags;
unsigned int nfreed = 0, ncleaned = 0, unpinned = 0;
-   int ret = 0;
 
rds_iw_stats_inc(s_iw_rdma_mr_pool_flush);
 
@@ -538,7 +537,6 @@ static int rds_iw_flush_mr_pool(struct rds_iw_mr_pool 
*pool, int free_all)
atomic_sub(nfreed, &pool->item_count);
 
mutex_unlock(&pool->flush_lock);
-   return ret;
 }
 
 static void rds_iw_mr_pool_flush_worker(struct work_struct *work)
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] net: rds: chnaging the return type from int to void

2015-10-29 Thread Saurabh Sengar
as return type of function rds_iw_flush_mr_pool no where checked, chnaging its 
return type from int to void.
also removing the unused variable rc as there is nothing to return.

Signed-off-by: Saurabh Sengar 
---
 net/rds/iw_rdma.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/net/rds/iw_rdma.c b/net/rds/iw_rdma.c
index 6a8fbd6..d3d4454f 100644
--- a/net/rds/iw_rdma.c
+++ b/net/rds/iw_rdma.c
@@ -75,7 +75,7 @@ struct rds_iw_mr_pool {
int max_pages;
 };
 
-static int rds_iw_flush_mr_pool(struct rds_iw_mr_pool *pool, int free_all);
+static void rds_iw_flush_mr_pool(struct rds_iw_mr_pool *pool, int free_all);
 static void rds_iw_mr_pool_flush_worker(struct work_struct *work);
 static int rds_iw_init_fastreg(struct rds_iw_mr_pool *pool, struct rds_iw_mr 
*ibmr);
 static int rds_iw_map_fastreg(struct rds_iw_mr_pool *pool,
@@ -479,14 +479,13 @@ void rds_iw_sync_mr(void *trans_private, int direction)
  * If the number of MRs allocated exceeds the limit, we also try
  * to free as many MRs as needed to get back to this limit.
  */
-static int rds_iw_flush_mr_pool(struct rds_iw_mr_pool *pool, int free_all)
+static void rds_iw_flush_mr_pool(struct rds_iw_mr_pool *pool, int free_all)
 {
struct rds_iw_mr *ibmr, *next;
LIST_HEAD(unmap_list);
LIST_HEAD(kill_list);
unsigned long flags;
unsigned int nfreed = 0, ncleaned = 0, unpinned = 0;
-   int ret = 0;
 
rds_iw_stats_inc(s_iw_rdma_mr_pool_flush);
 
@@ -538,7 +537,6 @@ static int rds_iw_flush_mr_pool(struct rds_iw_mr_pool 
*pool, int free_all)
atomic_sub(nfreed, &pool->item_count);
 
mutex_unlock(&pool->flush_lock);
-   return ret;
 }
 
 static void rds_iw_mr_pool_flush_worker(struct work_struct *work)
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html