Commit 906e86b2 authored by Aaron Sierra's avatar Aaron Sierra Committed by Jon Mason

ntb_netdev: Simplify remove with client device drvdata

Replace the elaborate private structure global linked-list used in
ntb_netdev_probe() and ntb_netdev_remove() by stashing our private
data in the NTB transport client device.
Signed-off-by: default avatarAaron Sierra <asierra@xes-inc.com>
Reviewed-by: default avatarLogan Gunthorpe <logang@deltatee.com>
Signed-off-by: default avatarJon Mason <jdmason@kudzu.us>
parent fc5d1829
...@@ -71,7 +71,6 @@ static unsigned int tx_start = 10; ...@@ -71,7 +71,6 @@ static unsigned int tx_start = 10;
static unsigned int tx_stop = 5; static unsigned int tx_stop = 5;
struct ntb_netdev { struct ntb_netdev {
struct list_head list;
struct pci_dev *pdev; struct pci_dev *pdev;
struct net_device *ndev; struct net_device *ndev;
struct ntb_transport_qp *qp; struct ntb_transport_qp *qp;
...@@ -81,8 +80,6 @@ struct ntb_netdev { ...@@ -81,8 +80,6 @@ struct ntb_netdev {
#define NTB_TX_TIMEOUT_MS 1000 #define NTB_TX_TIMEOUT_MS 1000
#define NTB_RXQ_SIZE 100 #define NTB_RXQ_SIZE 100
static LIST_HEAD(dev_list);
static void ntb_netdev_event_handler(void *data, int link_is_up) static void ntb_netdev_event_handler(void *data, int link_is_up)
{ {
struct net_device *ndev = data; struct net_device *ndev = data;
...@@ -452,7 +449,7 @@ static int ntb_netdev_probe(struct device *client_dev) ...@@ -452,7 +449,7 @@ static int ntb_netdev_probe(struct device *client_dev)
if (rc) if (rc)
goto err1; goto err1;
list_add(&dev->list, &dev_list); dev_set_drvdata(client_dev, ndev);
dev_info(&pdev->dev, "%s created\n", ndev->name); dev_info(&pdev->dev, "%s created\n", ndev->name);
return 0; return 0;
...@@ -465,27 +462,8 @@ static int ntb_netdev_probe(struct device *client_dev) ...@@ -465,27 +462,8 @@ static int ntb_netdev_probe(struct device *client_dev)
static void ntb_netdev_remove(struct device *client_dev) static void ntb_netdev_remove(struct device *client_dev)
{ {
struct ntb_dev *ntb; struct net_device *ndev = dev_get_drvdata(client_dev);
struct net_device *ndev; struct ntb_netdev *dev = netdev_priv(ndev);
struct pci_dev *pdev;
struct ntb_netdev *dev;
bool found = false;
ntb = dev_ntb(client_dev->parent);
pdev = ntb->pdev;
list_for_each_entry(dev, &dev_list, list) {
if (dev->pdev == pdev) {
found = true;
break;
}
}
if (!found)
return;
list_del(&dev->list);
ndev = dev->ndev;
unregister_netdev(ndev); unregister_netdev(ndev);
ntb_transport_free_queue(dev->qp); ntb_transport_free_queue(dev->qp);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment