All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
To: linux-media@vger.kernel.org, "Lad,
	Prabhakar" <prabhakar.csengg@gmail.com>,
	Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: Hans Verkuil <hverkuil-cisco@xs4all.nl>,
	Rob Herring <robh+dt@kernel.org>,
	linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org,
	Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Subject: [PATCH 06/13] media: davinci: vpif: Use platform_get_irq_optional() to get the interrupt
Date: Thu, 23 Dec 2021 17:30:07 +0000	[thread overview]
Message-ID: <20211223173015.22251-7-prabhakar.mahadev-lad.rj@bp.renesas.com> (raw)
In-Reply-To: <20211223173015.22251-1-prabhakar.mahadev-lad.rj@bp.renesas.com>

platform_get_resource(pdev, IORESOURCE_IRQ, ..) relies on static
allocation of IRQ resources in DT core code, this causes an issue
when using hierarchical interrupt domains using "interrupts" property
in the node as this bypasses the hierarchical setup and messes up the
irq chaining.

In preparation for removal of static setup of IRQ resource from DT core
code use platform_get_irq_optional().

Also this patch propagates error code in case devm_request_irq()
fails instead of returing -EINVAL.

Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
---
 drivers/media/platform/davinci/vpif.c         | 17 ++++++++++++++---
 drivers/media/platform/davinci/vpif_capture.c | 16 +++++++---------
 drivers/media/platform/davinci/vpif_display.c | 13 ++++++-------
 3 files changed, 27 insertions(+), 19 deletions(-)

diff --git a/drivers/media/platform/davinci/vpif.c b/drivers/media/platform/davinci/vpif.c
index 5a89d885d0e3..c3c78e1afdda 100644
--- a/drivers/media/platform/davinci/vpif.c
+++ b/drivers/media/platform/davinci/vpif.c
@@ -20,8 +20,10 @@
 #include <linux/err.h>
 #include <linux/init.h>
 #include <linux/io.h>
+#include <linux/irq.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/of.h>
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
 #include <linux/spinlock.h>
@@ -428,6 +430,7 @@ static int vpif_probe(struct platform_device *pdev)
 	static struct resource *res_irq;
 	struct platform_device *pdev_capture, *pdev_display;
 	struct device_node *endpoint = NULL;
+	int irq;
 
 	vpif_base = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(vpif_base))
@@ -453,12 +456,20 @@ static int vpif_probe(struct platform_device *pdev)
 	 * For DT platforms, manually create platform_devices for
 	 * capture/display drivers.
 	 */
-	res_irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
+	irq = platform_get_irq(pdev, 0);
+	if (irq < 0) {
+		pm_runtime_put(&pdev->dev);
+		return irq;
+	}
+	res_irq = devm_kzalloc(&pdev->dev, sizeof(*res_irq), GFP_KERNEL);
 	if (!res_irq) {
-		dev_warn(&pdev->dev, "Missing IRQ resource.\n");
 		pm_runtime_put(&pdev->dev);
-		return -EINVAL;
+		return -ENOMEM;
 	}
+	res_irq->flags = IORESOURCE_IRQ | irq_get_trigger_type(irq);
+	res_irq->start = irq;
+	res_irq->end = irq;
+	res_irq->name = dev_of_node(&pdev->dev) ? of_node_full_name(pdev->dev.of_node) : NULL;
 
 	pdev_capture = devm_kzalloc(&pdev->dev, sizeof(*pdev_capture),
 				    GFP_KERNEL);
diff --git a/drivers/media/platform/davinci/vpif_capture.c b/drivers/media/platform/davinci/vpif_capture.c
index 8fe55374c5a3..c1a67a221743 100644
--- a/drivers/media/platform/davinci/vpif_capture.c
+++ b/drivers/media/platform/davinci/vpif_capture.c
@@ -1607,7 +1607,6 @@ static __init int vpif_probe(struct platform_device *pdev)
 {
 	struct vpif_subdev_info *subdevdata;
 	struct i2c_adapter *i2c_adap;
-	struct resource *res;
 	int subdev_count;
 	int res_idx = 0;
 	int i, err;
@@ -1632,15 +1631,14 @@ static __init int vpif_probe(struct platform_device *pdev)
 		goto vpif_free;
 	}
 
-	while ((res = platform_get_resource(pdev, IORESOURCE_IRQ, res_idx))) {
-		err = devm_request_irq(&pdev->dev, res->start, vpif_channel_isr,
-					IRQF_SHARED, VPIF_DRIVER_NAME,
-					(void *)(&vpif_obj.dev[res_idx]->
-					channel_id));
-		if (err) {
-			err = -EINVAL;
+	while ((err = platform_get_irq_optional(pdev, res_idx)) != -ENXIO) {
+		if (err < 0)
+			goto vpif_unregister;
+		err = devm_request_irq(&pdev->dev, err, vpif_channel_isr,
+				       IRQF_SHARED, VPIF_DRIVER_NAME,
+				       (void *)(&vpif_obj.dev[res_idx]->channel_id));
+		if (err)
 			goto vpif_unregister;
-		}
 		res_idx++;
 	}
 
diff --git a/drivers/media/platform/davinci/vpif_display.c b/drivers/media/platform/davinci/vpif_display.c
index 59f6b782e104..9c552ea3787e 100644
--- a/drivers/media/platform/davinci/vpif_display.c
+++ b/drivers/media/platform/davinci/vpif_display.c
@@ -1221,7 +1221,6 @@ static __init int vpif_probe(struct platform_device *pdev)
 {
 	struct vpif_subdev_info *subdevdata;
 	struct i2c_adapter *i2c_adap;
-	struct resource *res;
 	int subdev_count;
 	int res_idx = 0;
 	int i, err;
@@ -1245,13 +1244,13 @@ static __init int vpif_probe(struct platform_device *pdev)
 		goto vpif_free;
 	}
 
-	while ((res = platform_get_resource(pdev, IORESOURCE_IRQ, res_idx))) {
-		err = devm_request_irq(&pdev->dev, res->start, vpif_channel_isr,
-					IRQF_SHARED, VPIF_DRIVER_NAME,
-					(void *)(&vpif_obj.dev[res_idx]->
-					channel_id));
+	while ((err = platform_get_irq_optional(pdev, res_idx)) != -ENXIO) {
+		if (err < 0)
+			goto vpif_unregister;
+		err = devm_request_irq(&pdev->dev, err, vpif_channel_isr,
+				       IRQF_SHARED, VPIF_DRIVER_NAME,
+				       (void *)(&vpif_obj.dev[res_idx]->channel_id));
 		if (err) {
-			err = -EINVAL;
 			vpif_err("VPIF IRQ request failed\n");
 			goto vpif_unregister;
 		}
-- 
2.17.1


  parent reply	other threads:[~2021-12-23 17:30 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-23 17:30 [PATCH 00/13] media: Use platform_get_irq*() variants to fetch IRQ's Lad Prabhakar
2021-12-23 17:30 ` [PATCH 01/13] media: vsp1: Use platform_get_irq() to get the interrupt Lad Prabhakar
2021-12-30  0:06   ` Laurent Pinchart
2021-12-30 12:32     ` Lad, Prabhakar
2021-12-23 17:30 ` [PATCH 02/13] media: camss: Use platform_get_irq_byname() " Lad Prabhakar
2021-12-23 18:06   ` Bjorn Andersson
2021-12-23 17:30 ` [PATCH 03/13] media: bdisp: Use platform_get_irq() " Lad Prabhakar
2021-12-23 17:30 ` [PATCH 04/13] media: s5p-mfc: " Lad Prabhakar
2021-12-23 17:30   ` Lad Prabhakar
2021-12-28  8:42   ` Andrzej Hajda
2021-12-28  8:42     ` Andrzej Hajda
2021-12-23 17:30 ` [PATCH 05/13] media: stm32-dma2d: " Lad Prabhakar
2021-12-23 17:30   ` Lad Prabhakar
2021-12-23 17:30 ` Lad Prabhakar [this message]
2021-12-25 17:32   ` [PATCH 06/13] media: davinci: vpif: Use platform_get_irq_optional() " Andy Shevchenko
2022-01-04 17:22     ` Lad, Prabhakar
2022-01-05  9:42       ` Andy Shevchenko
2022-01-05 17:41         ` Lad, Prabhakar
2022-01-06 13:43           ` Andy Shevchenko
2022-01-06 14:14             ` Andy Shevchenko
2022-01-06 15:27               ` Lad, Prabhakar
2022-01-06 16:01                 ` Andy Shevchenko
2022-01-06 16:10                   ` Lad, Prabhakar
2022-01-06 16:28                     ` Andy Shevchenko
2022-01-06 16:46                       ` Lad, Prabhakar
2021-12-23 17:30 ` [PATCH 07/13] media: exynos-gsc: Use platform_get_irq() " Lad Prabhakar
2021-12-23 17:30   ` Lad Prabhakar
2021-12-23 17:30 ` [PATCH 08/13] media: marvell-ccic: " Lad Prabhakar
2021-12-23 17:30 ` [PATCH 09/13] media: mtk-vcodec: Drop unnecessary call to platform_get_resource() Lad Prabhakar
2021-12-23 17:30   ` Lad Prabhakar
2021-12-23 17:30   ` Lad Prabhakar
2021-12-23 17:30 ` [PATCH 10/13] media: exynos4-is: Use platform_get_irq() to get the interrupt Lad Prabhakar
2021-12-23 17:30   ` Lad Prabhakar
2021-12-23 17:30 ` [PATCH 11/13] media: s5p-g2d: " Lad Prabhakar
2021-12-23 17:30   ` Lad Prabhakar
2021-12-23 17:30 ` [PATCH 12/13] media: mtk-vpu: Drop unnecessary call to platform_get_resource() Lad Prabhakar
2021-12-23 17:30   ` Lad Prabhakar
2021-12-23 17:30   ` Lad Prabhakar
2021-12-23 17:30 ` [PATCH 13/13] media: coda: Use platform_get_irq() to get the interrupt Lad Prabhakar
2021-12-23 17:30   ` Lad Prabhakar

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=20211223173015.22251-7-prabhakar.mahadev-lad.rj@bp.renesas.com \
    --to=prabhakar.mahadev-lad.rj@bp.renesas.com \
    --cc=hverkuil-cisco@xs4all.nl \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=prabhakar.csengg@gmail.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.