* [PATCH v2 1/2] dmaengine: add a new helper dmaenginem_async_device_register
@ 2018-07-26 6:45 Huang Shijie
2018-07-26 6:45 ` [PATCH v2 2/2] dmaengine: mic_x100_dma: use the new helper to simplify the code Huang Shijie
2018-07-30 5:20 ` [PATCH v2 1/2] dmaengine: add a new helper dmaenginem_async_device_register Vinod
0 siblings, 2 replies; 3+ messages in thread
From: Huang Shijie @ 2018-07-26 6:45 UTC (permalink / raw)
To: vkoul
Cc: corbet, dan.j.williams, robh, linux-doc, dmaengine, linux-kernel,
ashutosh.dixit, Huang Shijie
This patch adds the dmaenginem_async_device_register for DMA code.
Use the Devres to call the release for the DMA engine driver.
Signed-off-by: Huang Shijie <sjhuang@iluvatar.ai>
---
v1 --> v2:
change the name to dmaenginem_async_device_register().
---
Documentation/driver-model/devres.txt | 1 +
drivers/dma/dmaengine.c | 35 +++++++++++++++++++++++++++
include/linux/dmaengine.h | 1 +
3 files changed, 37 insertions(+)
diff --git a/Documentation/driver-model/devres.txt b/Documentation/driver-model/devres.txt
index a3e8bceb5f19..15720cd17958 100644
--- a/Documentation/driver-model/devres.txt
+++ b/Documentation/driver-model/devres.txt
@@ -240,6 +240,7 @@ CLOCK
devm_of_clk_add_hw_provider()
DMA
+ dmaenginem_async_device_register()
dmam_alloc_coherent()
dmam_alloc_attrs()
dmam_declare_coherent_memory()
diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c
index 84ac38dbdb65..fa6fdc5f2a04 100644
--- a/drivers/dma/dmaengine.c
+++ b/drivers/dma/dmaengine.c
@@ -1135,6 +1135,41 @@ void dma_async_device_unregister(struct dma_device *device)
}
EXPORT_SYMBOL(dma_async_device_unregister);
+static void dmam_device_release(struct device *dev, void *res)
+{
+ struct dma_device *device;
+
+ device = *(struct dma_device **)res;
+ dma_async_device_unregister(device);
+}
+
+/**
+ * dmaenginem_async_device_register - registers DMA devices found
+ * @device: &dma_device
+ *
+ * The operation is managed and will be undone on driver detach.
+ */
+int dmaenginem_async_device_register(struct dma_device *device)
+{
+ void *p;
+ int ret;
+
+ p = devres_alloc(dmam_device_release, sizeof(void *), GFP_KERNEL);
+ if (!p)
+ return -ENOMEM;
+
+ ret = dma_async_device_register(device);
+ if (!ret) {
+ *(struct dma_device **)p = device;
+ devres_add(device->dev, p);
+ } else {
+ devres_free(p);
+ }
+
+ return ret;
+}
+EXPORT_SYMBOL(dmaenginem_async_device_register);
+
struct dmaengine_unmap_pool {
struct kmem_cache *cache;
const char *name;
diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
index c8c3a7a93802..d49ec5c31944 100644
--- a/include/linux/dmaengine.h
+++ b/include/linux/dmaengine.h
@@ -1406,6 +1406,7 @@ static inline int dmaengine_desc_free(struct dma_async_tx_descriptor *desc)
/* --- DMA device --- */
int dma_async_device_register(struct dma_device *device);
+int dmaenginem_async_device_register(struct dma_device *device);
void dma_async_device_unregister(struct dma_device *device);
void dma_run_dependencies(struct dma_async_tx_descriptor *tx);
struct dma_chan *dma_get_slave_channel(struct dma_chan *chan);
--
2.17.1
--
To unsubscribe from this list: send the line "unsubscribe linux-doc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH v2 2/2] dmaengine: mic_x100_dma: use the new helper to simplify the code
2018-07-26 6:45 [PATCH v2 1/2] dmaengine: add a new helper dmaenginem_async_device_register Huang Shijie
@ 2018-07-26 6:45 ` Huang Shijie
2018-07-30 5:20 ` [PATCH v2 1/2] dmaengine: add a new helper dmaenginem_async_device_register Vinod
1 sibling, 0 replies; 3+ messages in thread
From: Huang Shijie @ 2018-07-26 6:45 UTC (permalink / raw)
To: vkoul
Cc: corbet, dan.j.williams, robh, linux-doc, dmaengine, linux-kernel,
ashutosh.dixit, Huang Shijie
Use dmaenginem_async_device_register() to simplify the code:
remove the mic_dma_unregister_dma_device()
Signed-off-by: Huang Shijie <sjhuang@iluvatar.ai>
---
Just add a user for the new helper.
---
drivers/dma/mic_x100_dma.c | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/drivers/dma/mic_x100_dma.c b/drivers/dma/mic_x100_dma.c
index 68dd79783b54..b76cb17d879c 100644
--- a/drivers/dma/mic_x100_dma.c
+++ b/drivers/dma/mic_x100_dma.c
@@ -470,11 +470,6 @@ static void mic_dma_chan_destroy(struct mic_dma_chan *ch)
mic_dma_chan_mask_intr(ch);
}
-static void mic_dma_unregister_dma_device(struct mic_dma_device *mic_dma_dev)
-{
- dma_async_device_unregister(&mic_dma_dev->dma_dev);
-}
-
static int mic_dma_setup_irq(struct mic_dma_chan *ch)
{
ch->cookie =
@@ -630,7 +625,7 @@ static int mic_dma_register_dma_device(struct mic_dma_device *mic_dma_dev,
list_add_tail(&mic_dma_dev->mic_ch[i].api_ch.device_node,
&mic_dma_dev->dma_dev.channels);
}
- return dma_async_device_register(&mic_dma_dev->dma_dev);
+ return dmaenginem_async_device_register(&mic_dma_dev->dma_dev);
}
/*
@@ -678,7 +673,6 @@ static struct mic_dma_device *mic_dma_dev_reg(struct mbus_device *mbdev,
static void mic_dma_dev_unreg(struct mic_dma_device *mic_dma_dev)
{
- mic_dma_unregister_dma_device(mic_dma_dev);
mic_dma_uninit(mic_dma_dev);
kfree(mic_dma_dev);
}
--
2.17.1
--
To unsubscribe from this list: send the line "unsubscribe linux-doc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2 1/2] dmaengine: add a new helper dmaenginem_async_device_register
2018-07-26 6:45 [PATCH v2 1/2] dmaengine: add a new helper dmaenginem_async_device_register Huang Shijie
2018-07-26 6:45 ` [PATCH v2 2/2] dmaengine: mic_x100_dma: use the new helper to simplify the code Huang Shijie
@ 2018-07-30 5:20 ` Vinod
1 sibling, 0 replies; 3+ messages in thread
From: Vinod @ 2018-07-30 5:20 UTC (permalink / raw)
To: Huang Shijie
Cc: corbet, dan.j.williams, robh, linux-doc, dmaengine, linux-kernel,
ashutosh.dixit
On 26-07-18, 14:45, Huang Shijie wrote:
> This patch adds the dmaenginem_async_device_register for DMA code.
> Use the Devres to call the release for the DMA engine driver.
Applied both, thanks
--
~Vinod
--
To unsubscribe from this list: send the line "unsubscribe linux-doc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-07-30 5:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-07-26 6:45 [PATCH v2 1/2] dmaengine: add a new helper dmaenginem_async_device_register Huang Shijie
2018-07-26 6:45 ` [PATCH v2 2/2] dmaengine: mic_x100_dma: use the new helper to simplify the code Huang Shijie
2018-07-30 5:20 ` [PATCH v2 1/2] dmaengine: add a new helper dmaenginem_async_device_register Vinod
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox