summaryrefslogtreecommitdiff
path: root/drivers/net
diff options
context:
space:
mode:
authorNathan Fontenot <nfont@linux.vnet.ibm.com>2017-03-30 02:49:29 -0400
committerDavid S. Miller <davem@davemloft.net>2017-03-30 15:58:43 -0700
commit1b8955ee5f6c1575c09b44c8253883394c78bef7 (patch)
treebe622d0e5ef5809297d279f6c12e1a11b6fc0c16 /drivers/net
parent7bbc27a4961a7d5f8e4294929ce64d6c6e81e90c (diff)
ibmvnic: Cleanup failure path in ibmvnic_open
Now that ibmvnic_release_resources will clean up all of our resources properly, even if they were not allocated, we can just call this for failues in ibmvnic_open. This patch also moves the ibmvnic_release_resources() routine up in the file to avoid creating a forward declaration ad re-names it to drop the ibmvnic prefix. Signed-off-by: Nathan Fontenot <nfont@linux.vnet.ibm.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/ethernet/ibm/ibmvnic.c51
1 files changed, 19 insertions, 32 deletions
diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
index a2f972d72e34..7ba43cfadf3a 100644
--- a/drivers/net/ethernet/ibm/ibmvnic.c
+++ b/drivers/net/ethernet/ibm/ibmvnic.c
@@ -578,13 +578,23 @@ static int ibmvnic_login(struct net_device *netdev)
return 0;
}
+static void release_resources(struct ibmvnic_adapter *adapter)
+{
+ release_bounce_buffer(adapter);
+ release_tx_pools(adapter);
+ release_rx_pools(adapter);
+
+ release_sub_crqs(adapter);
+ release_crq_queue(adapter);
+
+ release_stats_token(adapter);
+}
+
static int ibmvnic_open(struct net_device *netdev)
{
struct ibmvnic_adapter *adapter = netdev_priv(netdev);
struct device *dev = &adapter->vdev->dev;
union ibmvnic_crq crq;
- int rxadd_subcrqs;
- int tx_subcrqs;
int rc = 0;
int i;
@@ -610,16 +620,11 @@ static int ibmvnic_open(struct net_device *netdev)
return -1;
}
- rxadd_subcrqs =
- be32_to_cpu(adapter->login_rsp_buf->num_rxadd_subcrqs);
- tx_subcrqs =
- be32_to_cpu(adapter->login_rsp_buf->num_txsubm_subcrqs);
-
adapter->map_id = 1;
adapter->napi = kcalloc(adapter->req_rx_queues,
sizeof(struct napi_struct), GFP_KERNEL);
if (!adapter->napi)
- goto alloc_napi_failed;
+ goto ibmvnic_open_fail;
for (i = 0; i < adapter->req_rx_queues; i++) {
netif_napi_add(netdev, &adapter->napi[i], ibmvnic_poll,
NAPI_POLL_WEIGHT);
@@ -630,15 +635,15 @@ static int ibmvnic_open(struct net_device *netdev)
rc = init_rx_pools(netdev);
if (rc)
- goto rx_pool_failed;
+ goto ibmvnic_open_fail;
rc = init_tx_pools(netdev);
if (rc)
- goto tx_pool_failed;
+ goto ibmvnic_open_fail;
rc = init_bounce_buffer(netdev);
if (rc)
- goto bounce_init_failed;
+ goto ibmvnic_open_fail;
replenish_pools(adapter);
@@ -662,31 +667,13 @@ static int ibmvnic_open(struct net_device *netdev)
return 0;
-bounce_init_failed:
- i = tx_subcrqs - 1;
- kfree(adapter->tx_pool[i].free_map);
-tx_pool_failed:
- i = rxadd_subcrqs;
-rx_pool_failed:
+ibmvnic_open_fail:
for (i = 0; i < adapter->req_rx_queues; i++)
napi_disable(&adapter->napi[i]);
-alloc_napi_failed:
- release_sub_crqs(adapter);
+ release_resources(adapter);
return -ENOMEM;
}
-static void ibmvnic_release_resources(struct ibmvnic_adapter *adapter)
-{
- release_bounce_buffer(adapter);
- release_tx_pools(adapter);
- release_rx_pools(adapter);
-
- release_sub_crqs(adapter);
- release_crq_queue(adapter);
-
- release_stats_token(adapter);
-}
-
static int ibmvnic_close(struct net_device *netdev)
{
struct ibmvnic_adapter *adapter = netdev_priv(netdev);
@@ -707,7 +694,7 @@ static int ibmvnic_close(struct net_device *netdev)
crq.logical_link_state.link_state = IBMVNIC_LOGICAL_LNK_DN;
ibmvnic_send_crq(adapter, &crq);
- ibmvnic_release_resources(adapter);
+ release_resources(adapter);
adapter->is_closed = true;
adapter->closing = false;