From: Stefan Roese <sr@denx.de>
To: Olivier Dautricourt <olivier.dautricourt@orolia.com>,
Rob Herring <robh+dt@kernel.org>, Vinod Koul <vkoul@kernel.org>
Cc: dmaengine@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/2] drivers: dma: altera-msgdma: add OF support
Date: Thu, 29 Apr 2021 07:02:48 +0200 [thread overview]
Message-ID: <ce40085b-1956-63eb-c339-3020e710863a@denx.de> (raw)
In-Reply-To: <YIn02rUOMrDoBTHx@orolia.com>
On 29.04.21 01:50, Olivier Dautricourt wrote:
> 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
>
> Signed-off-by: Olivier Dautricourt <olivier.dautricourt@orolia.com>
> ---
> drivers/dma/altera-msgdma.c | 29 +++++++++++++++++++++++++++++
> 1 file changed, 29 insertions(+)
>
> diff --git a/drivers/dma/altera-msgdma.c b/drivers/dma/altera-msgdma.c
> index 9a841ce5f0c5..2b062d5aa636 100644
> --- a/drivers/dma/altera-msgdma.c
> +++ b/drivers/dma/altera-msgdma.c
> @@ -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,16 @@ static int request_and_map(struct platform_device *pdev, const char *name,
> return 0;
> }
>
> +#ifdef CONFIG_OF
> +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);
> +}
> +#endif
To avoid the ugly #ifdef's, could you add this function unconditionally
and ...
> +
> /**
> * msgdma_probe - Driver probe function
> * @pdev: Pointer to the platform_device structure
> @@ -888,6 +899,14 @@ static int msgdma_probe(struct platform_device *pdev)
> if (ret)
> goto fail;
>
> +#ifdef 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;
> + }
> +#endif
... use:
if (IS_ENABLED(CONFIG_OF)) {
ret = of_dma_controller_register(pdev->dev.of_node,
...
here?
> dev_notice(&pdev->dev, "Altera mSGDMA driver probe success\n");
>
> return 0;
> @@ -916,9 +935,19 @@ static int msgdma_remove(struct platform_device *pdev)
> return 0;
> }
>
> +#ifdef CONFIG_OF
> +static const struct of_device_id msgdma_match[] = {
> + { .compatible = "altr,msgdma",},
> + { }
> +};
> +
> +MODULE_DEVICE_TABLE(of, msgdma_match);
> +#endif
> +
I think this also can be included unconditionally.
Thanks,
Stefan
> 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
>
prev parent reply other threads:[~2021-04-29 5:02 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-28 23:50 [PATCH v2 2/2] drivers: dma: altera-msgdma: add OF support Olivier Dautricourt
2021-04-29 5:02 ` Stefan Roese [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ce40085b-1956-63eb-c339-3020e710863a@denx.de \
--to=sr@denx.de \
--cc=devicetree@vger.kernel.org \
--cc=dmaengine@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=olivier.dautricourt@orolia.com \
--cc=robh+dt@kernel.org \
--cc=vkoul@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox