Debian Codegraph @

drivers/net/ethernet/stmicro/stmmac/stmmac_libpci.c

raw
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3 * PCI bus helpers for STMMAC driver
4 * Copyright (C) 2025 Yao Zi <[email protected]>
5 */
6
7 #include <linux/device.h>
8 #include <linux/pci.h>
9
10 #include "stmmac_libpci.h"
11
12 int stmmac_pci_plat_suspend(struct device *dev, void *bsp_priv)
13 {
14 struct pci_dev *pdev = to_pci_dev(dev);
15 int ret;
16
17 ret = pci_save_state(pdev);
18 if (ret)
19 return ret;
20
21 pci_disable_device(pdev);
22 pci_wake_from_d3(pdev, true);
23
24 return 0;
25 }
26 EXPORT_SYMBOL_GPL(stmmac_pci_plat_suspend);
27
28 int stmmac_pci_plat_resume(struct device *dev, void *bsp_priv)
29 {
30 struct pci_dev *pdev = to_pci_dev(dev);
31 int ret;
32
33 pci_restore_state(pdev);
34 pci_set_power_state(pdev, PCI_D0);
35
36 ret = pci_enable_device(pdev);
37 if (ret)
38 return ret;
39
40 pci_set_master(pdev);
41
42 return 0;
43 }
44 EXPORT_SYMBOL_GPL(stmmac_pci_plat_resume);
45
46 MODULE_DESCRIPTION("STMMAC PCI helper library");
47 MODULE_AUTHOR("Yao Zi <[email protected]>");
48 MODULE_LICENSE("GPL");