Skip to content

Commit 69b4bf2

Browse files
VARoDeKgregkh
authored andcommitted
cb710/core.c: use generic power management
Drivers should not use legacy power management as they have to manage power states and related operations, for the device, themselves. This driver was handling them with the help of PCI helper functions like pci_save/restore_state(), pci_enable/disable_device(), etc. With generic PM, all essentials will be handled by the PCI core. Driver needs to do only device-specific operations. Compile-tested only. Signed-off-by: Vaibhav Gupta <vaibhavgupta40@gmail.com> Link: https://lore.kernel.org/r/20200629081531.214734-2-vaibhavgupta40@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent ae56942 commit 69b4bf2

1 file changed

Lines changed: 7 additions & 21 deletions

File tree

‎drivers/misc/cb710/core.c‎

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -166,37 +166,24 @@ void cb710_set_irq_handler(struct cb710_slot *slot,
166166
}
167167
EXPORT_SYMBOL_GPL(cb710_set_irq_handler);
168168

169-
#ifdef CONFIG_PM
170-
171-
static int cb710_suspend(struct pci_dev *pdev, pm_message_t state)
169+
static int __maybe_unused cb710_suspend(struct device *dev_d)
172170
{
171+
struct pci_dev *pdev = to_pci_dev(dev_d);
173172
struct cb710_chip *chip = pci_get_drvdata(pdev);
174173

175174
devm_free_irq(&pdev->dev, pdev->irq, chip);
176-
pci_save_state(pdev);
177-
pci_disable_device(pdev);
178-
if (state.event & PM_EVENT_SLEEP)
179-
pci_set_power_state(pdev, PCI_D3hot);
180175
return 0;
181176
}
182177

183-
static int cb710_resume(struct pci_dev *pdev)
178+
static int __maybe_unused cb710_resume(struct device *dev_d)
184179
{
180+
struct pci_dev *pdev = to_pci_dev(dev_d);
185181
struct cb710_chip *chip = pci_get_drvdata(pdev);
186-
int err;
187-
188-
pci_set_power_state(pdev, PCI_D0);
189-
pci_restore_state(pdev);
190-
err = pcim_enable_device(pdev);
191-
if (err)
192-
return err;
193182

194183
return devm_request_irq(&pdev->dev, pdev->irq,
195184
cb710_irq_handler, IRQF_SHARED, KBUILD_MODNAME, chip);
196185
}
197186

198-
#endif /* CONFIG_PM */
199-
200187
static int cb710_probe(struct pci_dev *pdev,
201188
const struct pci_device_id *ent)
202189
{
@@ -312,15 +299,14 @@ static const struct pci_device_id cb710_pci_tbl[] = {
312299
{ 0, }
313300
};
314301

302+
static SIMPLE_DEV_PM_OPS(cb710_pm_ops, cb710_suspend, cb710_resume);
303+
315304
static struct pci_driver cb710_driver = {
316305
.name = KBUILD_MODNAME,
317306
.id_table = cb710_pci_tbl,
318307
.probe = cb710_probe,
319308
.remove = cb710_remove_one,
320-
#ifdef CONFIG_PM
321-
.suspend = cb710_suspend,
322-
.resume = cb710_resume,
323-
#endif
309+
.driver.pm = &cb710_pm_ops,
324310
};
325311

326312
static int __init cb710_init_module(void)

0 commit comments

Comments
 (0)