.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * tw68-core.c |
---|
3 | 4 | * Core functions for the Techwell 68xx driver |
---|
.. | .. |
---|
14 | 15 | * Refactored and updated to the latest v4l core frameworks: |
---|
15 | 16 | * |
---|
16 | 17 | * Copyright (C) 2014 Hans Verkuil <hverkuil@xs4all.nl> |
---|
17 | | - * |
---|
18 | | - * This program is free software; you can redistribute it and/or modify |
---|
19 | | - * it under the terms of the GNU General Public License as published by |
---|
20 | | - * the Free Software Foundation; either version 2 of the License, or |
---|
21 | | - * (at your option) any later version. |
---|
22 | | - * |
---|
23 | | - * This program is distributed in the hope that it will be useful, |
---|
24 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
25 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
26 | | - * GNU General Public License for more details. |
---|
27 | 18 | */ |
---|
28 | 19 | |
---|
29 | 20 | #include <linux/init.h> |
---|
.. | .. |
---|
66 | 57 | /* ------------------------------------------------------------------ */ |
---|
67 | 58 | |
---|
68 | 59 | /* |
---|
69 | | - * Please add any new PCI IDs to: http://pci-ids.ucw.cz. This keeps |
---|
| 60 | + * Please add any new PCI IDs to: https://pci-ids.ucw.cz. This keeps |
---|
70 | 61 | * the PCI ID database up to date. Note that the entries must be |
---|
71 | 62 | * added under vendor 0x1797 (Techwell Inc.) as subsystem IDs. |
---|
72 | 63 | */ |
---|
.. | .. |
---|
368 | 359 | v4l2_device_unregister(&dev->v4l2_dev); |
---|
369 | 360 | } |
---|
370 | 361 | |
---|
371 | | -#ifdef CONFIG_PM |
---|
372 | | - |
---|
373 | | -static int tw68_suspend(struct pci_dev *pci_dev , pm_message_t state) |
---|
| 362 | +static int __maybe_unused tw68_suspend(struct device *dev_d) |
---|
374 | 363 | { |
---|
| 364 | + struct pci_dev *pci_dev = to_pci_dev(dev_d); |
---|
375 | 365 | struct v4l2_device *v4l2_dev = pci_get_drvdata(pci_dev); |
---|
376 | 366 | struct tw68_dev *dev = container_of(v4l2_dev, |
---|
377 | 367 | struct tw68_dev, v4l2_dev); |
---|
.. | .. |
---|
382 | 372 | |
---|
383 | 373 | synchronize_irq(pci_dev->irq); |
---|
384 | 374 | |
---|
385 | | - pci_save_state(pci_dev); |
---|
386 | | - pci_set_power_state(pci_dev, pci_choose_state(pci_dev, state)); |
---|
387 | 375 | vb2_discard_done(&dev->vidq); |
---|
388 | 376 | |
---|
389 | 377 | return 0; |
---|
390 | 378 | } |
---|
391 | 379 | |
---|
392 | | -static int tw68_resume(struct pci_dev *pci_dev) |
---|
| 380 | +static int __maybe_unused tw68_resume(struct device *dev_d) |
---|
393 | 381 | { |
---|
394 | | - struct v4l2_device *v4l2_dev = pci_get_drvdata(pci_dev); |
---|
| 382 | + struct v4l2_device *v4l2_dev = dev_get_drvdata(dev_d); |
---|
395 | 383 | struct tw68_dev *dev = container_of(v4l2_dev, |
---|
396 | 384 | struct tw68_dev, v4l2_dev); |
---|
397 | 385 | struct tw68_buf *buf; |
---|
398 | 386 | unsigned long flags; |
---|
399 | | - |
---|
400 | | - pci_set_power_state(pci_dev, PCI_D0); |
---|
401 | | - pci_restore_state(pci_dev); |
---|
402 | 387 | |
---|
403 | 388 | /* Do things that are done in tw68_initdev , |
---|
404 | 389 | except of initializing memory structures.*/ |
---|
.. | .. |
---|
417 | 402 | |
---|
418 | 403 | return 0; |
---|
419 | 404 | } |
---|
420 | | -#endif |
---|
421 | 405 | |
---|
422 | 406 | /* ----------------------------------------------------------- */ |
---|
423 | 407 | |
---|
| 408 | +static SIMPLE_DEV_PM_OPS(tw68_pm_ops, tw68_suspend, tw68_resume); |
---|
| 409 | + |
---|
424 | 410 | static struct pci_driver tw68_pci_driver = { |
---|
425 | | - .name = "tw68", |
---|
426 | | - .id_table = tw68_pci_tbl, |
---|
427 | | - .probe = tw68_initdev, |
---|
428 | | - .remove = tw68_finidev, |
---|
429 | | -#ifdef CONFIG_PM |
---|
430 | | - .suspend = tw68_suspend, |
---|
431 | | - .resume = tw68_resume |
---|
432 | | -#endif |
---|
| 411 | + .name = "tw68", |
---|
| 412 | + .id_table = tw68_pci_tbl, |
---|
| 413 | + .probe = tw68_initdev, |
---|
| 414 | + .remove = tw68_finidev, |
---|
| 415 | + .driver.pm = &tw68_pm_ops, |
---|
433 | 416 | }; |
---|
434 | 417 | |
---|
435 | 418 | module_pci_driver(tw68_pci_driver); |
---|