hc
2023-12-06 08f87f769b595151be1afeff53e144f543faa614
kernel/drivers/misc/cb710/core.c
....@@ -1,11 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * cb710/core.c
34 *
45 * Copyright by Michał Mirosław, 2008-2009
5
- *
6
- * This program is free software; you can redistribute it and/or modify
7
- * it under the terms of the GNU General Public License version 2 as
8
- * published by the Free Software Foundation.
96 */
107 #include <linux/kernel.h>
118 #include <linux/module.h>
....@@ -169,36 +166,23 @@
169166 }
170167 EXPORT_SYMBOL_GPL(cb710_set_irq_handler);
171168
172
-#ifdef CONFIG_PM
173
-
174
-static int cb710_suspend(struct pci_dev *pdev, pm_message_t state)
169
+static int __maybe_unused cb710_suspend(struct device *dev_d)
175170 {
171
+ struct pci_dev *pdev = to_pci_dev(dev_d);
176172 struct cb710_chip *chip = pci_get_drvdata(pdev);
177173
178174 devm_free_irq(&pdev->dev, pdev->irq, chip);
179
- pci_save_state(pdev);
180
- pci_disable_device(pdev);
181
- if (state.event & PM_EVENT_SLEEP)
182
- pci_set_power_state(pdev, PCI_D3hot);
183175 return 0;
184176 }
185177
186
-static int cb710_resume(struct pci_dev *pdev)
178
+static int __maybe_unused cb710_resume(struct device *dev_d)
187179 {
180
+ struct pci_dev *pdev = to_pci_dev(dev_d);
188181 struct cb710_chip *chip = pci_get_drvdata(pdev);
189
- int err;
190
-
191
- pci_set_power_state(pdev, PCI_D0);
192
- pci_restore_state(pdev);
193
- err = pcim_enable_device(pdev);
194
- if (err)
195
- return err;
196182
197183 return devm_request_irq(&pdev->dev, pdev->irq,
198184 cb710_irq_handler, IRQF_SHARED, KBUILD_MODNAME, chip);
199185 }
200
-
201
-#endif /* CONFIG_PM */
202186
203187 static int cb710_probe(struct pci_dev *pdev,
204188 const struct pci_device_id *ent)
....@@ -315,15 +299,14 @@
315299 { 0, }
316300 };
317301
302
+static SIMPLE_DEV_PM_OPS(cb710_pm_ops, cb710_suspend, cb710_resume);
303
+
318304 static struct pci_driver cb710_driver = {
319305 .name = KBUILD_MODNAME,
320306 .id_table = cb710_pci_tbl,
321307 .probe = cb710_probe,
322308 .remove = cb710_remove_one,
323
-#ifdef CONFIG_PM
324
- .suspend = cb710_suspend,
325
- .resume = cb710_resume,
326
-#endif
309
+ .driver.pm = &cb710_pm_ops,
327310 };
328311
329312 static int __init cb710_init_module(void)