1
0
mirror of https://github.com/corundum/corundum.git synced 2025-01-16 08:12:53 +08:00

Add state_lock

This commit is contained in:
Alex Forencich 2019-11-18 16:17:27 -08:00
parent 489506e4c0
commit af434c8eba
3 changed files with 44 additions and 2 deletions

View File

@ -73,6 +73,8 @@ struct mqnic_dev {
u8 __iomem *hw_addr;
u8 __iomem *phc_hw_addr;
struct mutex state_lock;
u8 base_mac[ETH_ALEN];
char name[16];

View File

@ -313,6 +313,8 @@ static int mqnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
pci_save_state(pdev);
mutex_init(&mqnic->state_lock);
// probe complete
return 0;

View File

@ -33,7 +33,7 @@ either expressed or implied, of The Regents of the University of California.
#include "mqnic.h"
static int mqnic_open(struct net_device *ndev)
static int mqnic_start_port(struct net_device *ndev)
{
struct mqnic_priv *priv = netdev_priv(ndev);
struct mqnic_dev *mdev = priv->mdev;
@ -102,7 +102,7 @@ static int mqnic_open(struct net_device *ndev)
return 0;
}
static int mqnic_close(struct net_device *ndev)
static int mqnic_stop_port(struct net_device *ndev)
{
struct mqnic_priv *priv = netdev_priv(ndev);
struct mqnic_dev *mdev = priv->mdev;
@ -183,6 +183,44 @@ static int mqnic_close(struct net_device *ndev)
return 0;
}
static int mqnic_open(struct net_device *ndev)
{
struct mqnic_priv *priv = netdev_priv(ndev);
struct mqnic_dev *mdev = priv->mdev;
int ret = 0;
mutex_lock(&mdev->state_lock);
ret = mqnic_start_port(ndev);
if (ret)
{
dev_err(&mdev->pdev->dev, "Failed to start port: %d", priv->port);
}
mutex_unlock(&mdev->state_lock);
return ret;
}
static int mqnic_close(struct net_device *ndev)
{
struct mqnic_priv *priv = netdev_priv(ndev);
struct mqnic_dev *mdev = priv->mdev;
int ret = 0;
mutex_lock(&mdev->state_lock);
ret = mqnic_stop_port(ndev);
if (ret)
{
dev_err(&mdev->pdev->dev, "Failed to stop port: %d", priv->port);
}
mutex_unlock(&mdev->state_lock);
return ret;
}
void mqnic_update_stats(struct net_device *ndev)
{
struct mqnic_priv *priv = netdev_priv(ndev);