hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/dma/pch_dma.c
....@@ -1,16 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Topcliff PCH DMA controller driver
34 * Copyright (c) 2010 Intel Corporation
45 * 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.
146 */
157
168 #include <linux/dmaengine.h>
....@@ -678,9 +670,9 @@
678670 return 0;
679671 }
680672
681
-static void pdc_tasklet(unsigned long data)
673
+static void pdc_tasklet(struct tasklet_struct *t)
682674 {
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);
684676 unsigned long flags;
685677
686678 if (!pdc_is_idle(pd_chan)) {
....@@ -743,8 +735,7 @@
743735 return ret0 | ret2;
744736 }
745737
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)
748739 {
749740 struct pch_dma_chan *pd_chan;
750741 struct dma_chan *chan, *_c;
....@@ -767,7 +758,7 @@
767758 }
768759 }
769760
770
-static void pch_dma_restore_regs(struct pch_dma *pd)
761
+static void __maybe_unused pch_dma_restore_regs(struct pch_dma *pd)
771762 {
772763 struct pch_dma_chan *pd_chan;
773764 struct dma_chan *chan, *_c;
....@@ -790,40 +781,25 @@
790781 }
791782 }
792783
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)
794785 {
795
- struct pch_dma *pd = pci_get_drvdata(pdev);
786
+ struct pch_dma *pd = dev_get_drvdata(dev);
796787
797788 if (pd)
798789 pch_dma_save_regs(pd);
799790
800
- pci_save_state(pdev);
801
- pci_disable_device(pdev);
802
- pci_set_power_state(pdev, pci_choose_state(pdev, state));
803
-
804791 return 0;
805792 }
806793
807
-static int pch_dma_resume(struct pci_dev *pdev)
794
+static int __maybe_unused pch_dma_resume(struct device *dev)
808795 {
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);
820797
821798 if (pd)
822799 pch_dma_restore_regs(pd);
823800
824801 return 0;
825802 }
826
-#endif
827803
828804 static int pch_dma_probe(struct pci_dev *pdev,
829805 const struct pci_device_id *id)
....@@ -906,8 +882,7 @@
906882 INIT_LIST_HEAD(&pd_chan->queue);
907883 INIT_LIST_HEAD(&pd_chan->free_list);
908884
909
- tasklet_init(&pd_chan->tasklet, pdc_tasklet,
910
- (unsigned long)pd_chan);
885
+ tasklet_setup(&pd_chan->tasklet, pdc_tasklet);
911886 list_add_tail(&pd_chan->chan.device_node, &pd->dma.channels);
912887 }
913888
....@@ -1001,15 +976,14 @@
1001976 { 0, },
1002977 };
1003978
979
+static SIMPLE_DEV_PM_OPS(pch_dma_pm_ops, pch_dma_suspend, pch_dma_resume);
980
+
1004981 static struct pci_driver pch_dma_driver = {
1005982 .name = DRV_NAME,
1006983 .id_table = pch_dma_id_table,
1007984 .probe = pch_dma_probe,
1008985 .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,
1013987 };
1014988
1015989 module_pci_driver(pch_dma_driver);