From: Emil Velikov <emil.l.velikov@gmail.com>
To: kernel@collabora.com, Ezequiel Garcia <ezequiel@collabora.com>,
Philipp Zabel <p.zabel@pengutronix.de>,
Rob Herring <robh+dt@kernel.org>,
devicetree@vger.kernel.org, linux-media@vger.kernel.org,
linux-rockchip@lists.infradead.org
Cc: emil.l.velikov@gmail.com
Subject: [PATCH v4 6/9] media: hantro: add fallback handling for single irq/clk
Date: Thu, 1 Apr 2021 15:43:33 +0100 [thread overview]
Message-ID: <20210401144336.2495479-7-emil.l.velikov@gmail.com> (raw)
In-Reply-To: <20210401144336.2495479-1-emil.l.velikov@gmail.com>
From: Emil Velikov <emil.velikov@collabora.com>
Currently the driver expects that each irq/clk will have a name
specified.
A valid point was raised by the DT maintainers - when there is a single
interrupt line or clock - the names are not needed.
Keep the names within the drivers themselves, but don't use them when
only a single entry exists. Instead use:
- num_clk == 1 - devm_clk_get(..., NULL)
- num_irq == 1 - platform_get_irq(..., 0)
Suggested-by: Ezequiel Garcia <ezequiel@collabora.com>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
---
v3
- New patch
v4
- Drop WARN_ON, guard on num_{irq,clk} instead (Eze)
- Drop Nicolas ack (Eze)
---
drivers/staging/media/hantro/hantro_drv.c | 37 ++++++++++++++++++-----
1 file changed, 29 insertions(+), 8 deletions(-)
diff --git a/drivers/staging/media/hantro/hantro_drv.c b/drivers/staging/media/hantro/hantro_drv.c
index e5f200e64993..a51700a9e3b7 100644
--- a/drivers/staging/media/hantro/hantro_drv.c
+++ b/drivers/staging/media/hantro/hantro_drv.c
@@ -752,12 +752,23 @@ static int hantro_probe(struct platform_device *pdev)
if (!vpu->clocks)
return -ENOMEM;
- for (i = 0; i < vpu->variant->num_clocks; i++)
- vpu->clocks[i].id = vpu->variant->clk_names[i];
- ret = devm_clk_bulk_get(&pdev->dev, vpu->variant->num_clocks,
- vpu->clocks);
- if (ret)
- return ret;
+ if (vpu->variant->num_clocks > 1) {
+ for (i = 0; i < vpu->variant->num_clocks; i++)
+ vpu->clocks[i].id = vpu->variant->clk_names[i];
+
+ ret = devm_clk_bulk_get(&pdev->dev, vpu->variant->num_clocks,
+ vpu->clocks);
+ if (ret)
+ return ret;
+ } else {
+ /*
+ * If the driver has a single clk, chances are there will be no
+ * actual name in the DT bindings.
+ */
+ vpu->clocks[0].clk = devm_clk_get(&pdev->dev, NULL);
+ if (IS_ERR(vpu->clocks))
+ return PTR_ERR(vpu->clocks);
+ }
num_bases = vpu->variant->num_regs ?: 1;
vpu->reg_bases = devm_kcalloc(&pdev->dev, num_bases,
@@ -785,13 +796,23 @@ static int hantro_probe(struct platform_device *pdev)
vb2_dma_contig_set_max_seg_size(&pdev->dev, DMA_BIT_MASK(32));
for (i = 0; i < vpu->variant->num_irqs; i++) {
- const char *irq_name = vpu->variant->irqs[i].name;
+ const char *irq_name;
int irq;
if (!vpu->variant->irqs[i].handler)
continue;
- irq = platform_get_irq_byname(vpu->pdev, irq_name);
+ if (vpu->variant->num_clocks > 1) {
+ irq_name = vpu->variant->irqs[i].name;
+ irq = platform_get_irq_byname(vpu->pdev, irq_name);
+ } else {
+ /*
+ * If the driver has a single IRQ, chances are there
+ * will be no actual name in the DT bindings.
+ */
+ irq_name = "default";
+ irq = platform_get_irq(vpu->pdev, 0);
+ }
if (irq <= 0)
return -ENXIO;
--
2.31.1
next prev parent reply other threads:[~2021-04-01 17:52 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-01 14:43 [PATCH v4 0/9] Microchip SAMA5D4 VPU support et al Emil Velikov
2021-04-01 14:43 ` [PATCH v4 1/9] media: hantro: use G1_REG_INTERRUPT directly for the mpeg2 Emil Velikov
2021-04-01 14:43 ` [PATCH v4 2/9] media: hantro: imx: reuse MB_DIM define Emil Velikov
2021-04-01 14:43 ` [PATCH v4 3/9] media: hantro: imx: remove duplicate dec_base init Emil Velikov
2021-04-01 14:43 ` [PATCH v4 4/9] media: hantro: imx: remove unused include Emil Velikov
2021-04-01 14:43 ` [PATCH v4 5/9] media: hantro: introduce hantro_g1.c for common API Emil Velikov
2021-04-01 14:43 ` Emil Velikov [this message]
2021-04-01 14:43 ` [PATCH v4 7/9] media: dt-bindings: Document SAMA5D4 VDEC bindings Emil Velikov
2021-04-08 16:00 ` Rob Herring
2021-04-01 14:43 ` [PATCH v4 8/9] media: hantro: add initial SAMA5D4 support Emil Velikov
2021-04-01 14:43 ` [PATCH v4 9/9] ARM: dts: sama5d4: enable Hantro G1 VDEC Emil Velikov
2021-05-05 14:31 ` Hans Verkuil
2021-05-06 12:31 ` Emil Velikov
2021-05-06 12:35 ` Hans Verkuil
2021-04-14 10:32 ` [PATCH v4 0/9] Microchip SAMA5D4 VPU support et al Emil Velikov
2021-05-04 12:03 ` Emil Velikov
2021-05-04 12:49 ` Hans Verkuil
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=20210401144336.2495479-7-emil.l.velikov@gmail.com \
--to=emil.l.velikov@gmail.com \
--cc=devicetree@vger.kernel.org \
--cc=ezequiel@collabora.com \
--cc=kernel@collabora.com \
--cc=linux-media@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=p.zabel@pengutronix.de \
--cc=robh+dt@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;
as well as URLs for NNTP newsgroup(s).