| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Topcliff PCH DMA controller driver |
|---|
| 3 | 4 | * Copyright (c) 2010 Intel Corporation |
|---|
| 4 | 5 | * Copyright (C) 2011 LAPIS Semiconductor Co., Ltd. |
|---|
| 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 | | - * |
|---|
| 10 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 11 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 12 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 13 | | - * GNU General Public License for more details. |
|---|
| 14 | 6 | */ |
|---|
| 15 | 7 | |
|---|
| 16 | 8 | #include <linux/dmaengine.h> |
|---|
| .. | .. |
|---|
| 678 | 670 | return 0; |
|---|
| 679 | 671 | } |
|---|
| 680 | 672 | |
|---|
| 681 | | -static void pdc_tasklet(unsigned long data) |
|---|
| 673 | +static void pdc_tasklet(struct tasklet_struct *t) |
|---|
| 682 | 674 | { |
|---|
| 683 | | - struct pch_dma_chan *pd_chan = (struct pch_dma_chan *)data; |
|---|
| 675 | + struct pch_dma_chan *pd_chan = from_tasklet(pd_chan, t, tasklet); |
|---|
| 684 | 676 | unsigned long flags; |
|---|
| 685 | 677 | |
|---|
| 686 | 678 | if (!pdc_is_idle(pd_chan)) { |
|---|
| .. | .. |
|---|
| 743 | 735 | return ret0 | ret2; |
|---|
| 744 | 736 | } |
|---|
| 745 | 737 | |
|---|
| 746 | | -#ifdef CONFIG_PM |
|---|
| 747 | | -static void pch_dma_save_regs(struct pch_dma *pd) |
|---|
| 738 | +static void __maybe_unused pch_dma_save_regs(struct pch_dma *pd) |
|---|
| 748 | 739 | { |
|---|
| 749 | 740 | struct pch_dma_chan *pd_chan; |
|---|
| 750 | 741 | struct dma_chan *chan, *_c; |
|---|
| .. | .. |
|---|
| 767 | 758 | } |
|---|
| 768 | 759 | } |
|---|
| 769 | 760 | |
|---|
| 770 | | -static void pch_dma_restore_regs(struct pch_dma *pd) |
|---|
| 761 | +static void __maybe_unused pch_dma_restore_regs(struct pch_dma *pd) |
|---|
| 771 | 762 | { |
|---|
| 772 | 763 | struct pch_dma_chan *pd_chan; |
|---|
| 773 | 764 | struct dma_chan *chan, *_c; |
|---|
| .. | .. |
|---|
| 790 | 781 | } |
|---|
| 791 | 782 | } |
|---|
| 792 | 783 | |
|---|
| 793 | | -static int pch_dma_suspend(struct pci_dev *pdev, pm_message_t state) |
|---|
| 784 | +static int __maybe_unused pch_dma_suspend(struct device *dev) |
|---|
| 794 | 785 | { |
|---|
| 795 | | - struct pch_dma *pd = pci_get_drvdata(pdev); |
|---|
| 786 | + struct pch_dma *pd = dev_get_drvdata(dev); |
|---|
| 796 | 787 | |
|---|
| 797 | 788 | if (pd) |
|---|
| 798 | 789 | pch_dma_save_regs(pd); |
|---|
| 799 | 790 | |
|---|
| 800 | | - pci_save_state(pdev); |
|---|
| 801 | | - pci_disable_device(pdev); |
|---|
| 802 | | - pci_set_power_state(pdev, pci_choose_state(pdev, state)); |
|---|
| 803 | | - |
|---|
| 804 | 791 | return 0; |
|---|
| 805 | 792 | } |
|---|
| 806 | 793 | |
|---|
| 807 | | -static int pch_dma_resume(struct pci_dev *pdev) |
|---|
| 794 | +static int __maybe_unused pch_dma_resume(struct device *dev) |
|---|
| 808 | 795 | { |
|---|
| 809 | | - struct pch_dma *pd = pci_get_drvdata(pdev); |
|---|
| 810 | | - int err; |
|---|
| 811 | | - |
|---|
| 812 | | - pci_set_power_state(pdev, PCI_D0); |
|---|
| 813 | | - pci_restore_state(pdev); |
|---|
| 814 | | - |
|---|
| 815 | | - err = pci_enable_device(pdev); |
|---|
| 816 | | - if (err) { |
|---|
| 817 | | - dev_dbg(&pdev->dev, "failed to enable device\n"); |
|---|
| 818 | | - return err; |
|---|
| 819 | | - } |
|---|
| 796 | + struct pch_dma *pd = dev_get_drvdata(dev); |
|---|
| 820 | 797 | |
|---|
| 821 | 798 | if (pd) |
|---|
| 822 | 799 | pch_dma_restore_regs(pd); |
|---|
| 823 | 800 | |
|---|
| 824 | 801 | return 0; |
|---|
| 825 | 802 | } |
|---|
| 826 | | -#endif |
|---|
| 827 | 803 | |
|---|
| 828 | 804 | static int pch_dma_probe(struct pci_dev *pdev, |
|---|
| 829 | 805 | const struct pci_device_id *id) |
|---|
| .. | .. |
|---|
| 906 | 882 | INIT_LIST_HEAD(&pd_chan->queue); |
|---|
| 907 | 883 | INIT_LIST_HEAD(&pd_chan->free_list); |
|---|
| 908 | 884 | |
|---|
| 909 | | - tasklet_init(&pd_chan->tasklet, pdc_tasklet, |
|---|
| 910 | | - (unsigned long)pd_chan); |
|---|
| 885 | + tasklet_setup(&pd_chan->tasklet, pdc_tasklet); |
|---|
| 911 | 886 | list_add_tail(&pd_chan->chan.device_node, &pd->dma.channels); |
|---|
| 912 | 887 | } |
|---|
| 913 | 888 | |
|---|
| .. | .. |
|---|
| 1001 | 976 | { 0, }, |
|---|
| 1002 | 977 | }; |
|---|
| 1003 | 978 | |
|---|
| 979 | +static SIMPLE_DEV_PM_OPS(pch_dma_pm_ops, pch_dma_suspend, pch_dma_resume); |
|---|
| 980 | + |
|---|
| 1004 | 981 | static struct pci_driver pch_dma_driver = { |
|---|
| 1005 | 982 | .name = DRV_NAME, |
|---|
| 1006 | 983 | .id_table = pch_dma_id_table, |
|---|
| 1007 | 984 | .probe = pch_dma_probe, |
|---|
| 1008 | 985 | .remove = pch_dma_remove, |
|---|
| 1009 | | -#ifdef CONFIG_PM |
|---|
| 1010 | | - .suspend = pch_dma_suspend, |
|---|
| 1011 | | - .resume = pch_dma_resume, |
|---|
| 1012 | | -#endif |
|---|
| 986 | + .driver.pm = &pch_dma_pm_ops, |
|---|
| 1013 | 987 | }; |
|---|
| 1014 | 988 | |
|---|
| 1015 | 989 | module_pci_driver(pch_dma_driver); |
|---|