Skip to content

Commit 40c1b1e

Browse files
VARoDeKdavem330
authored andcommitted
natsemi: use generic power management
With legacy PM, drivers themselves were responsible for managing the device's power states and takes care of register states. After upgrading to the generic structure, PCI core will take care of required tasks and drivers should do only device-specific operations. Thus, there is no need to call the PCI helper functions like pci_enable_device, which is not recommended. Hence, removed. Compile-tested only. Signed-off-by: Vaibhav Gupta <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 4c2ad12 commit 40c1b1e

File tree

1 file changed

+7
-19
lines changed

1 file changed

+7
-19
lines changed

drivers/net/ethernet/natsemi/natsemi.c

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3247,8 +3247,6 @@ static void natsemi_remove1(struct pci_dev *pdev)
32473247
free_netdev (dev);
32483248
}
32493249

3250-
#ifdef CONFIG_PM
3251-
32523250
/*
32533251
* The ns83815 chip doesn't have explicit RxStop bits.
32543252
* Kicking the Rx or Tx process for a new packet reenables the Rx process
@@ -3275,9 +3273,9 @@ static void natsemi_remove1(struct pci_dev *pdev)
32753273
* Interrupts must be disabled, otherwise hands_off can cause irq storms.
32763274
*/
32773275

3278-
static int natsemi_suspend (struct pci_dev *pdev, pm_message_t state)
3276+
static int __maybe_unused natsemi_suspend(struct device *dev_d)
32793277
{
3280-
struct net_device *dev = pci_get_drvdata (pdev);
3278+
struct net_device *dev = dev_get_drvdata(dev_d);
32813279
struct netdev_private *np = netdev_priv(dev);
32823280
void __iomem * ioaddr = ns_ioaddr(dev);
32833281

@@ -3326,11 +3324,10 @@ static int natsemi_suspend (struct pci_dev *pdev, pm_message_t state)
33263324
}
33273325

33283326

3329-
static int natsemi_resume (struct pci_dev *pdev)
3327+
static int __maybe_unused natsemi_resume(struct device *dev_d)
33303328
{
3331-
struct net_device *dev = pci_get_drvdata (pdev);
3329+
struct net_device *dev = dev_get_drvdata(dev_d);
33323330
struct netdev_private *np = netdev_priv(dev);
3333-
int ret = 0;
33343331

33353332
rtnl_lock();
33363333
if (netif_device_present(dev))
@@ -3339,12 +3336,6 @@ static int natsemi_resume (struct pci_dev *pdev)
33393336
const int irq = np->pci_dev->irq;
33403337

33413338
BUG_ON(!np->hands_off);
3342-
ret = pci_enable_device(pdev);
3343-
if (ret < 0) {
3344-
dev_err(&pdev->dev,
3345-
"pci_enable_device() failed: %d\n", ret);
3346-
goto out;
3347-
}
33483339
/* pci_power_on(pdev); */
33493340

33503341
napi_enable(&np->napi);
@@ -3364,20 +3355,17 @@ static int natsemi_resume (struct pci_dev *pdev)
33643355
netif_device_attach(dev);
33653356
out:
33663357
rtnl_unlock();
3367-
return ret;
3358+
return 0;
33683359
}
33693360

3370-
#endif /* CONFIG_PM */
3361+
static SIMPLE_DEV_PM_OPS(natsemi_pm_ops, natsemi_suspend, natsemi_resume);
33713362

33723363
static struct pci_driver natsemi_driver = {
33733364
.name = DRV_NAME,
33743365
.id_table = natsemi_pci_tbl,
33753366
.probe = natsemi_probe1,
33763367
.remove = natsemi_remove1,
3377-
#ifdef CONFIG_PM
3378-
.suspend = natsemi_suspend,
3379-
.resume = natsemi_resume,
3380-
#endif
3368+
.driver.pm = &natsemi_pm_ops,
33813369
};
33823370

33833371
static int __init natsemi_init_mod (void)

0 commit comments

Comments
 (0)