Skip to content

Commit b685fe2

Browse files
andy-shevvinodkoul
authored andcommitted
dmaengine: dw: platform: Split ACPI helpers to separate module
For better maintenance split ACPI helpers to the separate module. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20190820131546.75744-10-andriy.shevchenko@linux.intel.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
1 parent 84da042 commit b685fe2

4 files changed

Lines changed: 63 additions & 53 deletions

File tree

‎drivers/dma/dw/Makefile‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ obj-$(CONFIG_DW_DMAC_CORE) += dw_dmac_core.o
33
dw_dmac_core-objs := core.o dw.o idma32.o
44

55
obj-$(CONFIG_DW_DMAC) += dw_dmac.o
6-
dw_dmac-objs := platform.o
6+
dw_dmac-y := platform.o
7+
dw_dmac-$(CONFIG_ACPI) += acpi.o
78

89
obj-$(CONFIG_DW_DMAC_PCI) += dw_dmac_pci.o
910
dw_dmac_pci-objs := pci.o

‎drivers/dma/dw/acpi.c‎

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
// Copyright (C) 2013,2019 Intel Corporation
3+
4+
#include <linux/acpi.h>
5+
#include <linux/acpi_dma.h>
6+
7+
#include "internal.h"
8+
9+
static bool dw_dma_acpi_filter(struct dma_chan *chan, void *param)
10+
{
11+
struct acpi_dma_spec *dma_spec = param;
12+
struct dw_dma_slave slave = {
13+
.dma_dev = dma_spec->dev,
14+
.src_id = dma_spec->slave_id,
15+
.dst_id = dma_spec->slave_id,
16+
.m_master = 0,
17+
.p_master = 1,
18+
};
19+
20+
return dw_dma_filter(chan, &slave);
21+
}
22+
23+
void dw_dma_acpi_controller_register(struct dw_dma *dw)
24+
{
25+
struct device *dev = dw->dma.dev;
26+
struct acpi_dma_filter_info *info;
27+
int ret;
28+
29+
if (!has_acpi_companion(dev))
30+
return;
31+
32+
info = devm_kzalloc(dev, sizeof(*info), GFP_KERNEL);
33+
if (!info)
34+
return;
35+
36+
dma_cap_zero(info->dma_cap);
37+
dma_cap_set(DMA_SLAVE, info->dma_cap);
38+
info->filter_fn = dw_dma_acpi_filter;
39+
40+
ret = acpi_dma_controller_register(dev, acpi_dma_simple_xlate, info);
41+
if (ret)
42+
dev_err(dev, "could not register acpi_dma_controller\n");
43+
}
44+
45+
void dw_dma_acpi_controller_free(struct dw_dma *dw)
46+
{
47+
struct device *dev = dw->dma.dev;
48+
49+
if (!has_acpi_companion(dev))
50+
return;
51+
52+
acpi_dma_controller_free(dev);
53+
}

‎drivers/dma/dw/internal.h‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ int do_dw_dma_enable(struct dw_dma_chip *chip);
2323

2424
extern bool dw_dma_filter(struct dma_chan *chan, void *param);
2525

26+
#ifdef CONFIG_ACPI
27+
void dw_dma_acpi_controller_register(struct dw_dma *dw);
28+
void dw_dma_acpi_controller_free(struct dw_dma *dw);
29+
#else /* !CONFIG_ACPI */
30+
static inline void dw_dma_acpi_controller_register(struct dw_dma *dw) {}
31+
static inline void dw_dma_acpi_controller_free(struct dw_dma *dw) {}
32+
#endif /* !CONFIG_ACPI */
33+
2634
struct dw_dma_chip_pdata {
2735
const struct dw_dma_platform_data *pdata;
2836
int (*probe)(struct dw_dma_chip *chip);

‎drivers/dma/dw/platform.c‎

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#include <linux/of.h>
2020
#include <linux/of_dma.h>
2121
#include <linux/acpi.h>
22-
#include <linux/acpi_dma.h>
2322

2423
#include "internal.h"
2524

@@ -55,57 +54,6 @@ static struct dma_chan *dw_dma_of_xlate(struct of_phandle_args *dma_spec,
5554
return dma_request_channel(cap, dw_dma_filter, &slave);
5655
}
5756

58-
#ifdef CONFIG_ACPI
59-
static bool dw_dma_acpi_filter(struct dma_chan *chan, void *param)
60-
{
61-
struct acpi_dma_spec *dma_spec = param;
62-
struct dw_dma_slave slave = {
63-
.dma_dev = dma_spec->dev,
64-
.src_id = dma_spec->slave_id,
65-
.dst_id = dma_spec->slave_id,
66-
.m_master = 0,
67-
.p_master = 1,
68-
};
69-
70-
return dw_dma_filter(chan, &slave);
71-
}
72-
73-
static void dw_dma_acpi_controller_register(struct dw_dma *dw)
74-
{
75-
struct device *dev = dw->dma.dev;
76-
struct acpi_dma_filter_info *info;
77-
int ret;
78-
79-
if (!has_acpi_companion(dev))
80-
return;
81-
82-
info = devm_kzalloc(dev, sizeof(*info), GFP_KERNEL);
83-
if (!info)
84-
return;
85-
86-
dma_cap_zero(info->dma_cap);
87-
dma_cap_set(DMA_SLAVE, info->dma_cap);
88-
info->filter_fn = dw_dma_acpi_filter;
89-
90-
ret = acpi_dma_controller_register(dev, acpi_dma_simple_xlate, info);
91-
if (ret)
92-
dev_err(dev, "could not register acpi_dma_controller\n");
93-
}
94-
95-
static void dw_dma_acpi_controller_free(struct dw_dma *dw)
96-
{
97-
struct device *dev = dw->dma.dev;
98-
99-
if (!has_acpi_companion(dev))
100-
return;
101-
102-
acpi_dma_controller_free(dev);
103-
}
104-
#else /* !CONFIG_ACPI */
105-
static inline void dw_dma_acpi_controller_register(struct dw_dma *dw) {}
106-
static inline void dw_dma_acpi_controller_free(struct dw_dma *dw) {}
107-
#endif /* !CONFIG_ACPI */
108-
10957
#ifdef CONFIG_OF
11058
static struct dw_dma_platform_data *
11159
dw_dma_parse_dt(struct platform_device *pdev)

0 commit comments

Comments
 (0)