| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * cb710/core.c |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * 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. |
|---|
| 9 | 6 | */ |
|---|
| 10 | 7 | #include <linux/kernel.h> |
|---|
| 11 | 8 | #include <linux/module.h> |
|---|
| .. | .. |
|---|
| 169 | 166 | } |
|---|
| 170 | 167 | EXPORT_SYMBOL_GPL(cb710_set_irq_handler); |
|---|
| 171 | 168 | |
|---|
| 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) |
|---|
| 175 | 170 | { |
|---|
| 171 | + struct pci_dev *pdev = to_pci_dev(dev_d); |
|---|
| 176 | 172 | struct cb710_chip *chip = pci_get_drvdata(pdev); |
|---|
| 177 | 173 | |
|---|
| 178 | 174 | 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); |
|---|
| 183 | 175 | return 0; |
|---|
| 184 | 176 | } |
|---|
| 185 | 177 | |
|---|
| 186 | | -static int cb710_resume(struct pci_dev *pdev) |
|---|
| 178 | +static int __maybe_unused cb710_resume(struct device *dev_d) |
|---|
| 187 | 179 | { |
|---|
| 180 | + struct pci_dev *pdev = to_pci_dev(dev_d); |
|---|
| 188 | 181 | 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; |
|---|
| 196 | 182 | |
|---|
| 197 | 183 | return devm_request_irq(&pdev->dev, pdev->irq, |
|---|
| 198 | 184 | cb710_irq_handler, IRQF_SHARED, KBUILD_MODNAME, chip); |
|---|
| 199 | 185 | } |
|---|
| 200 | | - |
|---|
| 201 | | -#endif /* CONFIG_PM */ |
|---|
| 202 | 186 | |
|---|
| 203 | 187 | static int cb710_probe(struct pci_dev *pdev, |
|---|
| 204 | 188 | const struct pci_device_id *ent) |
|---|
| .. | .. |
|---|
| 315 | 299 | { 0, } |
|---|
| 316 | 300 | }; |
|---|
| 317 | 301 | |
|---|
| 302 | +static SIMPLE_DEV_PM_OPS(cb710_pm_ops, cb710_suspend, cb710_resume); |
|---|
| 303 | + |
|---|
| 318 | 304 | static struct pci_driver cb710_driver = { |
|---|
| 319 | 305 | .name = KBUILD_MODNAME, |
|---|
| 320 | 306 | .id_table = cb710_pci_tbl, |
|---|
| 321 | 307 | .probe = cb710_probe, |
|---|
| 322 | 308 | .remove = cb710_remove_one, |
|---|
| 323 | | -#ifdef CONFIG_PM |
|---|
| 324 | | - .suspend = cb710_suspend, |
|---|
| 325 | | - .resume = cb710_resume, |
|---|
| 326 | | -#endif |
|---|
| 309 | + .driver.pm = &cb710_pm_ops, |
|---|
| 327 | 310 | }; |
|---|
| 328 | 311 | |
|---|
| 329 | 312 | static int __init cb710_init_module(void) |
|---|