mirror of
https://github.com/corundum/corundum.git
synced 2025-01-30 08:32:52 +08:00
Normalize create/destroy methods
This commit is contained in:
parent
ed36f169f9
commit
32a82929c6
@ -331,8 +331,9 @@ extern const struct file_operations mqnic_fops;
|
||||
|
||||
// mqnic_netdev.c
|
||||
void mqnic_update_stats(struct net_device *ndev);
|
||||
int mqnic_init_netdev(struct mqnic_dev *mdev, int index, u8 __iomem *hw_addr);
|
||||
void mqnic_destroy_netdev(struct net_device *ndev);
|
||||
int mqnic_create_netdev(struct mqnic_dev *mdev, struct net_device **ndev_ptr,
|
||||
int index, u8 __iomem *hw_addr);
|
||||
void mqnic_destroy_netdev(struct net_device **ndev_ptr);
|
||||
|
||||
// mqnic_port.c
|
||||
int mqnic_create_port(struct mqnic_priv *priv, struct mqnic_port **port_ptr,
|
||||
|
@ -322,7 +322,7 @@ static int mqnic_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent
|
||||
|
||||
for (k = 0; k < mqnic->if_count; k++) {
|
||||
dev_info(dev, "Creating interface %d", k);
|
||||
ret = mqnic_init_netdev(mqnic, k, mqnic->hw_addr + k * mqnic->if_stride);
|
||||
ret = mqnic_create_netdev(mqnic, &mqnic->ndev[k], k, mqnic->hw_addr + k * mqnic->if_stride);
|
||||
if (ret) {
|
||||
dev_err(dev, "Failed to create net_device");
|
||||
goto fail_init_netdev;
|
||||
@ -360,7 +360,7 @@ fail_miscdev:
|
||||
fail_init_netdev:
|
||||
for (k = 0; k < ARRAY_SIZE(mqnic->ndev); k++)
|
||||
if (mqnic->ndev[k])
|
||||
mqnic_destroy_netdev(mqnic->ndev[k]);
|
||||
mqnic_destroy_netdev(&mqnic->ndev[k]);
|
||||
mqnic_unregister_phc(mqnic);
|
||||
pci_clear_master(pdev);
|
||||
fail_board:
|
||||
@ -402,7 +402,7 @@ static void mqnic_pci_remove(struct pci_dev *pdev)
|
||||
|
||||
for (k = 0; k < ARRAY_SIZE(mqnic->ndev); k++)
|
||||
if (mqnic->ndev[k])
|
||||
mqnic_destroy_netdev(mqnic->ndev[k]);
|
||||
mqnic_destroy_netdev(&mqnic->ndev[k]);
|
||||
|
||||
mqnic_unregister_phc(mqnic);
|
||||
|
||||
|
@ -366,7 +366,8 @@ static const struct net_device_ops mqnic_netdev_ops = {
|
||||
.ndo_do_ioctl = mqnic_ioctl,
|
||||
};
|
||||
|
||||
int mqnic_init_netdev(struct mqnic_dev *mdev, int index, u8 __iomem *hw_addr)
|
||||
int mqnic_create_netdev(struct mqnic_dev *mdev, struct net_device **ndev_ptr,
|
||||
int index, u8 __iomem *hw_addr)
|
||||
{
|
||||
struct device *dev = mdev->dev;
|
||||
struct net_device *ndev;
|
||||
@ -556,25 +557,25 @@ int mqnic_init_netdev(struct mqnic_dev *mdev, int index, u8 __iomem *hw_addr)
|
||||
|
||||
priv->registered = 1;
|
||||
|
||||
mdev->ndev[index] = ndev;
|
||||
*ndev_ptr = ndev;
|
||||
|
||||
return 0;
|
||||
|
||||
fail:
|
||||
mqnic_destroy_netdev(ndev);
|
||||
mqnic_destroy_netdev(ndev_ptr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void mqnic_destroy_netdev(struct net_device *ndev)
|
||||
void mqnic_destroy_netdev(struct net_device **ndev_ptr)
|
||||
{
|
||||
struct net_device *ndev = *ndev_ptr;
|
||||
struct mqnic_priv *priv = netdev_priv(ndev);
|
||||
struct mqnic_dev *mdev = priv->mdev;
|
||||
int k;
|
||||
|
||||
if (priv->registered)
|
||||
unregister_netdev(ndev);
|
||||
|
||||
mdev->ndev[priv->index] = NULL;
|
||||
*ndev_ptr = NULL;
|
||||
|
||||
// free rings
|
||||
for (k = 0; k < ARRAY_SIZE(priv->event_ring); k++)
|
||||
|
Loading…
x
Reference in New Issue
Block a user