linux-renesas-soc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] media: v4l2-fwnode: Return -EINVAL for invalid bus-type
@ 2020-09-17 16:08 Lad Prabhakar
  2020-09-17 16:51 ` Sakari Ailus
  0 siblings, 1 reply; 2+ messages in thread
From: Lad Prabhakar @ 2020-09-17 16:08 UTC (permalink / raw)
  To: Sakari Ailus, Hans Verkuil, Laurent Pinchart,
	Mauro Carvalho Chehab, Jacopo Mondi
  Cc: linux-media, linux-kernel, linux-renesas-soc, Lad Prabhakar, Prabhakar

Return -EINVAL if invalid bus-type is detected while parsing endpoints.

Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
---
v1->v2
* Updated commit description
* Fixed nit pointed by Sakari

v1 - https://patchwork.kernel.org/patch/11777127/
---
 drivers/media/v4l2-core/v4l2-fwnode.c | 6 +++++-
 include/media/v4l2-mediabus.h         | 2 ++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/media/v4l2-core/v4l2-fwnode.c b/drivers/media/v4l2-core/v4l2-fwnode.c
index d7bbe33840cb..dfc53d11053f 100644
--- a/drivers/media/v4l2-core/v4l2-fwnode.c
+++ b/drivers/media/v4l2-core/v4l2-fwnode.c
@@ -93,7 +93,7 @@ v4l2_fwnode_bus_type_to_mbus(enum v4l2_fwnode_bus_type type)
 	const struct v4l2_fwnode_bus_conv *conv =
 		get_v4l2_fwnode_bus_conv_by_fwnode_bus(type);
 
-	return conv ? conv->mbus_type : V4L2_MBUS_UNKNOWN;
+	return conv ? conv->mbus_type : V4L2_MBUS_INVALID;
 }
 
 static const char *
@@ -436,6 +436,10 @@ static int __v4l2_fwnode_endpoint_parse(struct fwnode_handle *fwnode,
 		 v4l2_fwnode_mbus_type_to_string(vep->bus_type),
 		 vep->bus_type);
 	mbus_type = v4l2_fwnode_bus_type_to_mbus(bus_type);
+	if (mbus_type == V4L2_MBUS_INVALID) {
+		pr_debug("unsupported bus type %u\n", bus_type);
+		return -EINVAL;
+	}
 
 	if (vep->bus_type != V4L2_MBUS_UNKNOWN) {
 		if (mbus_type != V4L2_MBUS_UNKNOWN &&
diff --git a/include/media/v4l2-mediabus.h b/include/media/v4l2-mediabus.h
index 59b1de197114..c20e2dc6d432 100644
--- a/include/media/v4l2-mediabus.h
+++ b/include/media/v4l2-mediabus.h
@@ -103,6 +103,7 @@
  * @V4L2_MBUS_CCP2:	CCP2 (Compact Camera Port 2)
  * @V4L2_MBUS_CSI2_DPHY: MIPI CSI-2 serial interface, with D-PHY
  * @V4L2_MBUS_CSI2_CPHY: MIPI CSI-2 serial interface, with C-PHY
+ * @V4L2_MBUS_INVALID:	invalid bus type (keep as last)
  */
 enum v4l2_mbus_type {
 	V4L2_MBUS_UNKNOWN,
@@ -112,6 +113,7 @@ enum v4l2_mbus_type {
 	V4L2_MBUS_CCP2,
 	V4L2_MBUS_CSI2_DPHY,
 	V4L2_MBUS_CSI2_CPHY,
+	V4L2_MBUS_INVALID,
 };
 
 /**
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] media: v4l2-fwnode: Return -EINVAL for invalid bus-type
  2020-09-17 16:08 [PATCH v2] media: v4l2-fwnode: Return -EINVAL for invalid bus-type Lad Prabhakar
@ 2020-09-17 16:51 ` Sakari Ailus
  0 siblings, 0 replies; 2+ messages in thread
From: Sakari Ailus @ 2020-09-17 16:51 UTC (permalink / raw)
  To: Lad Prabhakar
  Cc: Hans Verkuil, Laurent Pinchart, Mauro Carvalho Chehab,
	Jacopo Mondi, linux-media, linux-kernel, linux-renesas-soc,
	Prabhakar

On Thu, Sep 17, 2020 at 05:08:47PM +0100, Lad Prabhakar wrote:
> Return -EINVAL if invalid bus-type is detected while parsing endpoints.
> 
> Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>

Thanks!

I'm adding:

Fixes: 26c1126c9b56 ("media: v4l: fwnode: Use media bus type for bus parser selection")

-- 
Sakari Ailus

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-09-17 17:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-17 16:08 [PATCH v2] media: v4l2-fwnode: Return -EINVAL for invalid bus-type Lad Prabhakar
2020-09-17 16:51 ` Sakari Ailus

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).