Commit 145155e7 authored by Kalesh Purayil's avatar Kalesh Purayil Committed by David S. Miller

be2net: remove duplicate code in be_setup_wol()

This change will make be_setup_wol() routine more compact and readable
by removing some duplicate code.
Signed-off-by: default avatarKalesh AP <kalesh.purayil@avagotech.com>
Signed-off-by: default avatarSathya Perla <sathya.perla@avagotech.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 9131f3de
...@@ -3529,15 +3529,15 @@ static int be_open(struct net_device *netdev) ...@@ -3529,15 +3529,15 @@ static int be_open(struct net_device *netdev)
static int be_setup_wol(struct be_adapter *adapter, bool enable) static int be_setup_wol(struct be_adapter *adapter, bool enable)
{ {
struct device *dev = &adapter->pdev->dev;
struct be_dma_mem cmd; struct be_dma_mem cmd;
int status = 0;
u8 mac[ETH_ALEN]; u8 mac[ETH_ALEN];
int status;
eth_zero_addr(mac); eth_zero_addr(mac);
cmd.size = sizeof(struct be_cmd_req_acpi_wol_magic_config); cmd.size = sizeof(struct be_cmd_req_acpi_wol_magic_config);
cmd.va = dma_zalloc_coherent(&adapter->pdev->dev, cmd.size, &cmd.dma, cmd.va = dma_zalloc_coherent(dev, cmd.size, &cmd.dma, GFP_KERNEL);
GFP_KERNEL);
if (!cmd.va) if (!cmd.va)
return -ENOMEM; return -ENOMEM;
...@@ -3546,24 +3546,18 @@ static int be_setup_wol(struct be_adapter *adapter, bool enable) ...@@ -3546,24 +3546,18 @@ static int be_setup_wol(struct be_adapter *adapter, bool enable)
PCICFG_PM_CONTROL_OFFSET, PCICFG_PM_CONTROL_OFFSET,
PCICFG_PM_CONTROL_MASK); PCICFG_PM_CONTROL_MASK);
if (status) { if (status) {
dev_err(&adapter->pdev->dev, dev_err(dev, "Could not enable Wake-on-lan\n");
"Could not enable Wake-on-lan\n"); goto err;
dma_free_coherent(&adapter->pdev->dev, cmd.size, cmd.va,
cmd.dma);
return status;
} }
status = be_cmd_enable_magic_wol(adapter,
adapter->netdev->dev_addr,
&cmd);
pci_enable_wake(adapter->pdev, PCI_D3hot, 1);
pci_enable_wake(adapter->pdev, PCI_D3cold, 1);
} else { } else {
status = be_cmd_enable_magic_wol(adapter, mac, &cmd); ether_addr_copy(mac, adapter->netdev->dev_addr);
pci_enable_wake(adapter->pdev, PCI_D3hot, 0);
pci_enable_wake(adapter->pdev, PCI_D3cold, 0);
} }
dma_free_coherent(&adapter->pdev->dev, cmd.size, cmd.va, cmd.dma); status = be_cmd_enable_magic_wol(adapter, mac, &cmd);
pci_enable_wake(adapter->pdev, PCI_D3hot, enable);
pci_enable_wake(adapter->pdev, PCI_D3cold, enable);
err:
dma_free_coherent(dev, cmd.size, cmd.va, cmd.dma);
return status; return status;
} }
......
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