hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/misc/pch_phub.c
....@@ -1,18 +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.
12
- *
13
- * You should have received a copy of the GNU General Public License
14
- * along with this program; if not, write to the Free Software
15
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
164 */
175
186 #include <linux/module.h>
....@@ -147,6 +135,7 @@
147135
148136 /**
149137 * pch_phub_read_modify_write_reg() - Reading modifying and writing register
138
+ * @chip: Pointer to the PHUB register structure
150139 * @reg_addr_offset: Register offset address value.
151140 * @data: Writing value.
152141 * @mask: Mask value.
....@@ -159,9 +148,8 @@
159148 iowrite32(((ioread32(reg_addr) & ~mask)) | data, reg_addr);
160149 }
161150
162
-#ifdef CONFIG_PM
163151 /* pch_phub_save_reg_conf - saves register configuration */
164
-static void pch_phub_save_reg_conf(struct pci_dev *pdev)
152
+static void __maybe_unused pch_phub_save_reg_conf(struct pci_dev *pdev)
165153 {
166154 unsigned int i;
167155 struct pch_phub_reg *chip = pci_get_drvdata(pdev);
....@@ -222,7 +210,7 @@
222210 }
223211
224212 /* pch_phub_restore_reg_conf - restore register configuration */
225
-static void pch_phub_restore_reg_conf(struct pci_dev *pdev)
213
+static void __maybe_unused pch_phub_restore_reg_conf(struct pci_dev *pdev)
226214 {
227215 unsigned int i;
228216 struct pch_phub_reg *chip = pci_get_drvdata(pdev);
....@@ -282,10 +270,10 @@
282270 if ((chip->ioh_type == 2) || (chip->ioh_type == 4))
283271 iowrite32(chip->funcsel_reg, p + FUNCSEL_REG_OFFSET);
284272 }
285
-#endif
286273
287274 /**
288275 * pch_phub_read_serial_rom() - Reading Serial ROM
276
+ * @chip: Pointer to the PHUB register structure
289277 * @offset_address: Serial ROM offset address to read.
290278 * @data: Read buffer for specified Serial ROM value.
291279 */
....@@ -300,6 +288,7 @@
300288
301289 /**
302290 * pch_phub_write_serial_rom() - Writing Serial ROM
291
+ * @chip: Pointer to the PHUB register structure
303292 * @offset_address: Serial ROM offset address.
304293 * @data: Serial ROM value to write.
305294 */
....@@ -338,6 +327,7 @@
338327
339328 /**
340329 * pch_phub_read_serial_rom_val() - Read Serial ROM value
330
+ * @chip: Pointer to the PHUB register structure
341331 * @offset_address: Serial ROM address offset value.
342332 * @data: Serial ROM value to read.
343333 */
....@@ -354,6 +344,7 @@
354344
355345 /**
356346 * pch_phub_write_serial_rom_val() - writing Serial ROM value
347
+ * @chip: Pointer to the PHUB register structure
357348 * @offset_address: Serial ROM address offset value.
358349 * @data: Serial ROM value.
359350 */
....@@ -455,7 +446,7 @@
455446
456447 /**
457448 * pch_phub_read_gbe_mac_addr() - Read Gigabit Ethernet MAC address
458
- * @offset_address: Gigabit Ethernet MAC address offset value.
449
+ * @chip: Pointer to the PHUB register structure
459450 * @data: Buffer of the Gigabit Ethernet MAC address value.
460451 */
461452 static void pch_phub_read_gbe_mac_addr(struct pch_phub_reg *chip, u8 *data)
....@@ -467,7 +458,7 @@
467458
468459 /**
469460 * pch_phub_write_gbe_mac_addr() - Write MAC address
470
- * @offset_address: Gigabit Ethernet MAC address offset value.
461
+ * @chip: Pointer to the PHUB register structure
471462 * @data: Gigabit Ethernet MAC address value.
472463 */
473464 static int pch_phub_write_gbe_mac_addr(struct pch_phub_reg *chip, u8 *data)
....@@ -847,48 +838,19 @@
847838 kfree(chip);
848839 }
849840
850
-#ifdef CONFIG_PM
851
-
852
-static int pch_phub_suspend(struct pci_dev *pdev, pm_message_t state)
841
+static int __maybe_unused pch_phub_suspend(struct device *dev_d)
853842 {
854
- int ret;
855
-
856
- pch_phub_save_reg_conf(pdev);
857
- ret = pci_save_state(pdev);
858
- if (ret) {
859
- dev_err(&pdev->dev,
860
- " %s -pci_save_state returns %d\n", __func__, ret);
861
- return ret;
862
- }
863
- pci_enable_wake(pdev, PCI_D3hot, 0);
864
- pci_disable_device(pdev);
865
- pci_set_power_state(pdev, pci_choose_state(pdev, state));
843
+ device_wakeup_disable(dev_d);
866844
867845 return 0;
868846 }
869847
870
-static int pch_phub_resume(struct pci_dev *pdev)
848
+static int __maybe_unused pch_phub_resume(struct device *dev_d)
871849 {
872
- int ret;
873
-
874
- pci_set_power_state(pdev, PCI_D0);
875
- pci_restore_state(pdev);
876
- ret = pci_enable_device(pdev);
877
- if (ret) {
878
- dev_err(&pdev->dev,
879
- "%s-pci_enable_device failed(ret=%d) ", __func__, ret);
880
- return ret;
881
- }
882
-
883
- pci_enable_wake(pdev, PCI_D3hot, 0);
884
- pch_phub_restore_reg_conf(pdev);
850
+ device_wakeup_disable(dev_d);
885851
886852 return 0;
887853 }
888
-#else
889
-#define pch_phub_suspend NULL
890
-#define pch_phub_resume NULL
891
-#endif /* CONFIG_PM */
892854
893855 static const struct pci_device_id pch_phub_pcidev_id[] = {
894856 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_PCH1_PHUB), 1, },
....@@ -900,13 +862,14 @@
900862 };
901863 MODULE_DEVICE_TABLE(pci, pch_phub_pcidev_id);
902864
865
+static SIMPLE_DEV_PM_OPS(pch_phub_pm_ops, pch_phub_suspend, pch_phub_resume);
866
+
903867 static struct pci_driver pch_phub_driver = {
904868 .name = "pch_phub",
905869 .id_table = pch_phub_pcidev_id,
906870 .probe = pch_phub_probe,
907871 .remove = pch_phub_remove,
908
- .suspend = pch_phub_suspend,
909
- .resume = pch_phub_resume
872
+ .driver.pm = &pch_phub_pm_ops,
910873 };
911874
912875 module_pci_driver(pch_phub_driver);