.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * Copyright (C) 2011 LAPIS Semiconductor Co., Ltd. |
---|
3 | | - * |
---|
4 | | - * This program is free software; you can redistribute it and/or modify |
---|
5 | | - * it under the terms of the GNU General Public License as published by |
---|
6 | | - * the Free Software Foundation; version 2 of the License. |
---|
7 | | - * |
---|
8 | | - * This program is distributed in the hope that it will be useful, |
---|
9 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
10 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
11 | | - * GNU General Public License for more details. |
---|
12 | 4 | */ |
---|
13 | 5 | |
---|
14 | 6 | #include <linux/module.h> |
---|
.. | .. |
---|
854 | 846 | kfree(adap_info); |
---|
855 | 847 | } |
---|
856 | 848 | |
---|
857 | | -#ifdef CONFIG_PM |
---|
858 | | -static int pch_i2c_suspend(struct pci_dev *pdev, pm_message_t state) |
---|
| 849 | +static int __maybe_unused pch_i2c_suspend(struct device *dev) |
---|
859 | 850 | { |
---|
860 | | - int ret; |
---|
861 | 851 | int i; |
---|
| 852 | + struct pci_dev *pdev = to_pci_dev(dev); |
---|
862 | 853 | struct adapter_info *adap_info = pci_get_drvdata(pdev); |
---|
863 | 854 | void __iomem *p = adap_info->pch_data[0].pch_base_address; |
---|
864 | 855 | |
---|
.. | .. |
---|
880 | 871 | ioread32(p + PCH_I2CSR), ioread32(p + PCH_I2CBUFSTA), |
---|
881 | 872 | ioread32(p + PCH_I2CESRSTA)); |
---|
882 | 873 | |
---|
883 | | - ret = pci_save_state(pdev); |
---|
884 | | - |
---|
885 | | - if (ret) { |
---|
886 | | - pch_pci_err(pdev, "pci_save_state\n"); |
---|
887 | | - return ret; |
---|
888 | | - } |
---|
889 | | - |
---|
890 | | - pci_enable_wake(pdev, PCI_D3hot, 0); |
---|
891 | | - pci_disable_device(pdev); |
---|
892 | | - pci_set_power_state(pdev, pci_choose_state(pdev, state)); |
---|
893 | | - |
---|
894 | 874 | return 0; |
---|
895 | 875 | } |
---|
896 | 876 | |
---|
897 | | -static int pch_i2c_resume(struct pci_dev *pdev) |
---|
| 877 | +static int __maybe_unused pch_i2c_resume(struct device *dev) |
---|
898 | 878 | { |
---|
899 | 879 | int i; |
---|
900 | | - struct adapter_info *adap_info = pci_get_drvdata(pdev); |
---|
901 | | - |
---|
902 | | - pci_set_power_state(pdev, PCI_D0); |
---|
903 | | - pci_restore_state(pdev); |
---|
904 | | - |
---|
905 | | - if (pci_enable_device(pdev) < 0) { |
---|
906 | | - pch_pci_err(pdev, "pch_i2c_resume:pci_enable_device FAILED\n"); |
---|
907 | | - return -EIO; |
---|
908 | | - } |
---|
909 | | - |
---|
910 | | - pci_enable_wake(pdev, PCI_D3hot, 0); |
---|
| 880 | + struct adapter_info *adap_info = dev_get_drvdata(dev); |
---|
911 | 881 | |
---|
912 | 882 | for (i = 0; i < adap_info->ch_num; i++) |
---|
913 | 883 | pch_i2c_init(&adap_info->pch_data[i]); |
---|
.. | .. |
---|
916 | 886 | |
---|
917 | 887 | return 0; |
---|
918 | 888 | } |
---|
919 | | -#else |
---|
920 | | -#define pch_i2c_suspend NULL |
---|
921 | | -#define pch_i2c_resume NULL |
---|
922 | | -#endif |
---|
| 889 | + |
---|
| 890 | +static SIMPLE_DEV_PM_OPS(pch_i2c_pm_ops, pch_i2c_suspend, pch_i2c_resume); |
---|
923 | 891 | |
---|
924 | 892 | static struct pci_driver pch_pcidriver = { |
---|
925 | 893 | .name = KBUILD_MODNAME, |
---|
926 | 894 | .id_table = pch_pcidev_id, |
---|
927 | 895 | .probe = pch_i2c_probe, |
---|
928 | 896 | .remove = pch_i2c_remove, |
---|
929 | | - .suspend = pch_i2c_suspend, |
---|
930 | | - .resume = pch_i2c_resume |
---|
| 897 | + .driver.pm = &pch_i2c_pm_ops, |
---|
931 | 898 | }; |
---|
932 | 899 | |
---|
933 | 900 | module_pci_driver(pch_pcidriver); |
---|