Skip to contentSkip to conversation

drivers: dma: altera-msgdma: add OF support

PATCH Superseded Olivier Dautricourt 2 participants 2 messages Apr 29, 2021

Subsystems (2)

v3 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 2/2 drivers: dma: altera-msgdma: add OF support

This driver had no device tree support.

- add compatible field "altr,msgdma"
- define msgdma_of_xlate, with no argument
- register dma controller with of_dma_controller_register

---

Notes:
Changes in v2:
none

Changes from v2 to v3:
Removed CONFIG_OF #ifdef's and use if (IS_ENABLED(CONFIG_OF)) only once.

 drivers/dma/altera-msgdma.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
drivers/dma/altera-msgdma.c +27 -0
index 9a841ce5f0c5..5a6eb5b501ad 100644
@@ -19,6 +19,7 @@
 #include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/slab.h>
+#include <linux/of_dma.h>
 
 #include "dmaengine.h"
 
@@ -784,6 +785,14 @@ static int request_and_map(struct platform_device *pdev, const char *name,
 	return 0;
 }
 
+static struct dma_chan *msgdma_of_xlate(struct of_phandle_args *dma_spec,
+					struct of_dma *ofdma)
+{
+	struct msgdma_device *d = ofdma->of_dma_data;
+
+	return dma_get_any_slave_channel(&d->dmadev);
+}
+
 /**
  * msgdma_probe - Driver probe function
  * @pdev: Pointer to the platform_device structure
@@ -888,6 +897,16 @@ static int msgdma_probe(struct platform_device *pdev)
 	if (ret)
 		goto fail;
 
+	if (IS_ENABLED(CONFIG_OF)) {
+		ret = of_dma_controller_register(pdev->dev.of_node,
+						 msgdma_of_xlate, mdev);
+		if (ret) {
+			dev_err(&pdev->dev,
+				"failed to register dma controller");
+			goto fail;
+		}
+	}
+
 	dev_notice(&pdev->dev, "Altera mSGDMA driver probe success\n");
 
 	return 0;
@@ -916,9 +935,17 @@ static int msgdma_remove(struct platform_device *pdev)
 	return 0;
 }
 
+static const struct of_device_id msgdma_match[] = {
+	{ .compatible = "altr,msgdma",},
+	{ }
+};
+
+MODULE_DEVICE_TABLE(of, msgdma_match);
+
 static struct platform_driver msgdma_driver = {
 	.driver = {
 		.name = "altera-msgdma",
+		.of_match_table = of_match_ptr(msgdma_match),
 	},
 	.probe = msgdma_probe,
 	.remove = msgdma_remove,

--
2.31.0.rc2

#1 lore raw
I love your patch! Perhaps something to improve:

Hi Olivier,

I love your patch! Perhaps something to improve:

[auto build test WARNING on robh/for-next]
[also build test WARNING on vkoul-dmaengine/next linux/master linus/master v5.12 next-20210429] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Olivier-Dautricourt/dt-bindings-dma-add-schema-for-altr-msgdma/20210429-153100
base:   https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git for-next
config: x86_64-randconfig-a014-20210429 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 9131a078901b00e68248a27a4f8c4b11bb1db1ae)

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# install x86_64 cross compiling tool for clang build
# apt-get install binutils-x86-64-linux-gnu
# https://github.com/0day-ci/linux/commit/d236d651cdf2990a9bcba2230405a3c9e7553bd7
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Olivier-Dautricourt/dt-bindings-dma-add-schema-for-altr-msgdma/20210429-153100 git checkout d236d651cdf2990a9bcba2230405a3c9e7553bd7
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 ARCH=x86_64

If you fix the issue, kindly add following tag as appropriate

All warnings (new ones prefixed by >>):

>> drivers/dma/altera-msgdma.c:938:34: warning: unused variable 'msgdma_match' [-Wunused-const-variable]
   static const struct of_device_id msgdma_match[] = {
                                    ^

1 warning generated.

vim +/msgdma_match +938 drivers/dma/altera-msgdma.c

937

 > 938	static const struct of_device_id msgdma_match[] = {

939 { .compatible = "altr,msgdma",},
940 { }
941 };
942

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org