summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Kicinski <jakub.kicinski@netronome.com>2017-05-26 11:03:31 +0300
committerDavid S. Miller <davem@davemloft.net>2017-05-26 18:01:48 +0300
commit346cfe8482bf491f6e3e88ea89bc0d6be2b02efd (patch)
treefebe12f6b1086e9e09ca7f425510fa67e523c085
parentc067598aceba9c5ff221cf5e215b86b9686dd009 (diff)
downloadlinux-346cfe8482bf491f6e3e88ea89bc0d6be2b02efd.tar.xz
nfp: move mutex init out of net code
Move mutex init to main file close to structure allocation. This will allow mutex to be taken before net code runs (e.g. from devlink callbacks). While at it remember to destroy the mutex. Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/netronome/nfp/nfp_main.c4
-rw-r--r--drivers/net/ethernet/netronome/nfp/nfp_net_main.c1
2 files changed, 4 insertions, 1 deletions
diff --git a/drivers/net/ethernet/netronome/nfp/nfp_main.c b/drivers/net/ethernet/netronome/nfp/nfp_main.c
index bb586ce1ea06..3a131559153a 100644
--- a/drivers/net/ethernet/netronome/nfp/nfp_main.c
+++ b/drivers/net/ethernet/netronome/nfp/nfp_main.c
@@ -41,6 +41,7 @@
#include <linux/kernel.h>
#include <linux/module.h>
+#include <linux/mutex.h>
#include <linux/pci.h>
#include <linux/firmware.h>
#include <linux/vermagic.h>
@@ -342,6 +343,7 @@ static int nfp_pci_probe(struct pci_dev *pdev,
}
INIT_LIST_HEAD(&pf->vnics);
INIT_LIST_HEAD(&pf->ports);
+ mutex_init(&pf->lock);
pci_set_drvdata(pdev, pf);
pf->pdev = pdev;
@@ -380,6 +382,7 @@ err_cpp_free:
nfp_cpp_free(pf->cpp);
err_disable_msix:
pci_set_drvdata(pdev, NULL);
+ mutex_destroy(&pf->lock);
kfree(pf);
err_rel_regions:
pci_release_regions(pdev);
@@ -404,6 +407,7 @@ static void nfp_pci_remove(struct pci_dev *pdev)
nfp_cpp_free(pf->cpp);
kfree(pf->eth_tbl);
+ mutex_destroy(&pf->lock);
kfree(pf);
pci_release_regions(pdev);
pci_disable_device(pdev);
diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_main.c b/drivers/net/ethernet/netronome/nfp/nfp_net_main.c
index dd1118c7e1a4..5139c13b6e53 100644
--- a/drivers/net/ethernet/netronome/nfp/nfp_net_main.c
+++ b/drivers/net/ethernet/netronome/nfp/nfp_net_main.c
@@ -641,7 +641,6 @@ int nfp_net_pci_probe(struct nfp_pf *pf)
int err;
INIT_WORK(&pf->port_refresh_work, nfp_net_refresh_vnics);
- mutex_init(&pf->lock);
/* Verify that the board has completed initialization */
if (!nfp_is_ready(pf->cpp)) {