hc
2024-10-12 a5969cabbb4660eab42b6ef0412cbbd1200cf14d
kernel/drivers/i2c/busses/i2c-eg20t.c
....@@ -1,14 +1,6 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * 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.
124 */
135
146 #include <linux/module.h>
....@@ -854,11 +846,10 @@
854846 kfree(adap_info);
855847 }
856848
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)
859850 {
860
- int ret;
861851 int i;
852
+ struct pci_dev *pdev = to_pci_dev(dev);
862853 struct adapter_info *adap_info = pci_get_drvdata(pdev);
863854 void __iomem *p = adap_info->pch_data[0].pch_base_address;
864855
....@@ -880,34 +871,13 @@
880871 ioread32(p + PCH_I2CSR), ioread32(p + PCH_I2CBUFSTA),
881872 ioread32(p + PCH_I2CESRSTA));
882873
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
-
894874 return 0;
895875 }
896876
897
-static int pch_i2c_resume(struct pci_dev *pdev)
877
+static int __maybe_unused pch_i2c_resume(struct device *dev)
898878 {
899879 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);
911881
912882 for (i = 0; i < adap_info->ch_num; i++)
913883 pch_i2c_init(&adap_info->pch_data[i]);
....@@ -916,18 +886,15 @@
916886
917887 return 0;
918888 }
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);
923891
924892 static struct pci_driver pch_pcidriver = {
925893 .name = KBUILD_MODNAME,
926894 .id_table = pch_pcidev_id,
927895 .probe = pch_i2c_probe,
928896 .remove = pch_i2c_remove,
929
- .suspend = pch_i2c_suspend,
930
- .resume = pch_i2c_resume
897
+ .driver.pm = &pch_i2c_pm_ops,
931898 };
932899
933900 module_pci_driver(pch_pcidriver);