All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCHv2] v4l: of: check for unique lanes in data-lanes and clock-lanes
@ 2017-01-31 12:08 Niklas Söderlund
  2017-01-31 12:12   ` Sakari Ailus
  2017-02-01 12:31 ` Laurent Pinchart
  0 siblings, 2 replies; 4+ messages in thread
From: Niklas Söderlund @ 2017-01-31 12:08 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, Laurent Pinchart
  Cc: Geert Uytterhoeven, linux-media, linux-renesas-soc,
	Niklas Söderlund

All lanes in data-lanes and clock-lanes properties should be unique. Add
a check for this in v4l2_of_parse_csi_bus() and print a warning if
duplicated lanes are found.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
---

Changes since v1:

- Do not return -EINVAL if a duplicate is found. Sakari pointed out 
  there are drivers where the number of lanes matter but not the actual 
  lane numbers. Updated commit message to highlight that only a warning 
  is printed.
- Switched to a bitmask to track lanes used instead of a nested loop, 
  thanks Laurent for the suggestion.


 drivers/media/v4l2-core/v4l2-of.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/media/v4l2-core/v4l2-of.c b/drivers/media/v4l2-core/v4l2-of.c
index 93b33681776ca427..4f59f442dd0a64c9 100644
--- a/drivers/media/v4l2-core/v4l2-of.c
+++ b/drivers/media/v4l2-core/v4l2-of.c
@@ -26,7 +26,7 @@ static int v4l2_of_parse_csi_bus(const struct device_node *node,
 	struct v4l2_of_bus_mipi_csi2 *bus = &endpoint->bus.mipi_csi2;
 	struct property *prop;
 	bool have_clk_lane = false;
-	unsigned int flags = 0;
+	unsigned int flags = 0, lanes_used = 0;
 	u32 v;
 
 	prop = of_find_property(node, "data-lanes", NULL);
@@ -38,6 +38,12 @@ static int v4l2_of_parse_csi_bus(const struct device_node *node,
 			lane = of_prop_next_u32(prop, lane, &v);
 			if (!lane)
 				break;
+
+			if (lanes_used & BIT(v))
+				pr_warn("%s: duplicated lane %u in data-lanes\n",
+					node->full_name, v);
+			lanes_used |= BIT(v);
+
 			bus->data_lanes[i] = v;
 		}
 		bus->num_data_lanes = i;
@@ -63,6 +69,11 @@ static int v4l2_of_parse_csi_bus(const struct device_node *node,
 	}
 
 	if (!of_property_read_u32(node, "clock-lanes", &v)) {
+		if (lanes_used & BIT(v))
+			pr_warn("%s: duplicated lane %u in clock-lanes\n",
+				node->full_name, v);
+		lanes_used |= BIT(v);
+
 		bus->clock_lane = v;
 		have_clk_lane = true;
 	}
-- 
2.11.0


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

* Re: [PATCHv2] v4l: of: check for unique lanes in data-lanes and clock-lanes
  2017-01-31 12:08 [PATCHv2] v4l: of: check for unique lanes in data-lanes and clock-lanes Niklas Söderlund
@ 2017-01-31 12:12   ` Sakari Ailus
  2017-02-01 12:31 ` Laurent Pinchart
  1 sibling, 0 replies; 4+ messages in thread
From: Sakari Ailus @ 2017-01-31 12:12 UTC (permalink / raw)
  To: Niklas Söderlund
  Cc: Mauro Carvalho Chehab, Laurent Pinchart, Geert Uytterhoeven,
	linux-media, linux-renesas-soc

On Tue, Jan 31, 2017 at 01:08:31PM +0100, Niklas Söderlund wrote:
> All lanes in data-lanes and clock-lanes properties should be unique. Add
> a check for this in v4l2_of_parse_csi_bus() and print a warning if
> duplicated lanes are found.
> 
> Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>

Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>

-- 
Sakari Ailus
e-mail: sakari.ailus@iki.fi	XMPP: sailus@retiisi.org.uk

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

* Re: [PATCHv2] v4l: of: check for unique lanes in data-lanes and clock-lanes
@ 2017-01-31 12:12   ` Sakari Ailus
  0 siblings, 0 replies; 4+ messages in thread
From: Sakari Ailus @ 2017-01-31 12:12 UTC (permalink / raw)
  To: Niklas Söderlund
  Cc: Mauro Carvalho Chehab, Laurent Pinchart, Geert Uytterhoeven,
	linux-media, linux-renesas-soc

On Tue, Jan 31, 2017 at 01:08:31PM +0100, Niklas S�derlund wrote:
> All lanes in data-lanes and clock-lanes properties should be unique. Add
> a check for this in v4l2_of_parse_csi_bus() and print a warning if
> duplicated lanes are found.
> 
> Signed-off-by: Niklas S�derlund <niklas.soderlund+renesas@ragnatech.se>

Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>

-- 
Sakari Ailus
e-mail: sakari.ailus@iki.fi	XMPP: sailus@retiisi.org.uk

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

* Re: [PATCHv2] v4l: of: check for unique lanes in data-lanes and clock-lanes
  2017-01-31 12:08 [PATCHv2] v4l: of: check for unique lanes in data-lanes and clock-lanes Niklas Söderlund
  2017-01-31 12:12   ` Sakari Ailus
@ 2017-02-01 12:31 ` Laurent Pinchart
  1 sibling, 0 replies; 4+ messages in thread
From: Laurent Pinchart @ 2017-02-01 12:31 UTC (permalink / raw)
  To: Niklas Söderlund
  Cc: Mauro Carvalho Chehab, Geert Uytterhoeven, linux-media,
	linux-renesas-soc

Hi Niklas,

Thank you for the patch.

By the way, you can use

git format-patch -v2

to automatically add "v2" to the subject line.

On Tuesday 31 Jan 2017 13:08:31 Niklas Söderlund wrote:
> All lanes in data-lanes and clock-lanes properties should be unique. Add
> a check for this in v4l2_of_parse_csi_bus() and print a warning if
> duplicated lanes are found.
> 
> Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
> 
> Changes since v1:
> 
> - Do not return -EINVAL if a duplicate is found. Sakari pointed out
>   there are drivers where the number of lanes matter but not the actual
>   lane numbers. Updated commit message to highlight that only a warning
>   is printed.
> - Switched to a bitmask to track lanes used instead of a nested loop,
>   thanks Laurent for the suggestion.
> 
> 
>  drivers/media/v4l2-core/v4l2-of.c | 13 ++++++++++++-
>  1 file changed, 12 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/media/v4l2-core/v4l2-of.c
> b/drivers/media/v4l2-core/v4l2-of.c index
> 93b33681776ca427..4f59f442dd0a64c9 100644
> --- a/drivers/media/v4l2-core/v4l2-of.c
> +++ b/drivers/media/v4l2-core/v4l2-of.c
> @@ -26,7 +26,7 @@ static int v4l2_of_parse_csi_bus(const struct device_node
> *node, struct v4l2_of_bus_mipi_csi2 *bus = &endpoint->bus.mipi_csi2;
>  	struct property *prop;
>  	bool have_clk_lane = false;
> -	unsigned int flags = 0;
> +	unsigned int flags = 0, lanes_used = 0;
>  	u32 v;
> 
>  	prop = of_find_property(node, "data-lanes", NULL);
> @@ -38,6 +38,12 @@ static int v4l2_of_parse_csi_bus(const struct device_node
> *node, lane = of_prop_next_u32(prop, lane, &v);
>  			if (!lane)
>  				break;
> +
> +			if (lanes_used & BIT(v))
> +				pr_warn("%s: duplicated lane %u in data-
lanes\n",
> +					node->full_name, v);
> +			lanes_used |= BIT(v);
> +
>  			bus->data_lanes[i] = v;
>  		}
>  		bus->num_data_lanes = i;
> @@ -63,6 +69,11 @@ static int v4l2_of_parse_csi_bus(const struct device_node
> *node, }
> 
>  	if (!of_property_read_u32(node, "clock-lanes", &v)) {
> +		if (lanes_used & BIT(v))
> +			pr_warn("%s: duplicated lane %u in clock-lanes\n",
> +				node->full_name, v);
> +		lanes_used |= BIT(v);
> +
>  		bus->clock_lane = v;
>  		have_clk_lane = true;
>  	}

-- 
Regards,

Laurent Pinchart


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

end of thread, other threads:[~2017-02-01 12:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-31 12:08 [PATCHv2] v4l: of: check for unique lanes in data-lanes and clock-lanes Niklas Söderlund
2017-01-31 12:12 ` Sakari Ailus
2017-01-31 12:12   ` Sakari Ailus
2017-02-01 12:31 ` Laurent Pinchart

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.