All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] [media] tc358743: validate lane count and order
@ 2017-09-21 15:31 Philipp Zabel
  2017-09-22  7:04 ` Sakari Ailus
  0 siblings, 1 reply; 2+ messages in thread
From: Philipp Zabel @ 2017-09-21 15:31 UTC (permalink / raw)
  To: linux-media
  Cc: Dave Stevenson, Hans Verkuil, Sakari Ailus,
	Mauro Carvalho Chehab, Mats Randgaard, Philipp Zabel

The TC358743 does not support reordering lanes, or more than 4 data
lanes.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
---
 drivers/media/i2c/tc358743.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/drivers/media/i2c/tc358743.c b/drivers/media/i2c/tc358743.c
index a35043cefe128..b7285e45b908a 100644
--- a/drivers/media/i2c/tc358743.c
+++ b/drivers/media/i2c/tc358743.c
@@ -1743,6 +1743,7 @@ static int tc358743_probe_of(struct tc358743_state *state)
 	struct clk *refclk;
 	u32 bps_pr_lane;
 	int ret = -EINVAL;
+	int i;
 
 	refclk = devm_clk_get(dev, "refclk");
 	if (IS_ERR(refclk)) {
@@ -1771,6 +1772,21 @@ static int tc358743_probe_of(struct tc358743_state *state)
 		goto free_endpoint;
 	}
 
+	if (endpoint->bus.mipi_csi2.num_data_lanes > 4) {
+		dev_err(dev, "invalid number of lanes\n");
+		goto free_endpoint;
+	}
+
+	for (i = 0; i < endpoint->bus.mipi_csi2.num_data_lanes; i++) {
+		if (endpoint->bus.mipi_csi2.data_lanes[i] != i + 1)
+			break;
+	}
+	if (i != endpoint->bus.mipi_csi2.num_data_lanes ||
+	    endpoint->bus.mipi_csi2.clock_lane != 0) {
+		dev_err(dev, "invalid lane order\n");
+		goto free_endpoint;
+	}
+
 	state->bus = endpoint->bus.mipi_csi2;
 
 	ret = clk_prepare_enable(refclk);
-- 
2.11.0

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

* Re: [PATCH] [media] tc358743: validate lane count and order
  2017-09-21 15:31 [PATCH] [media] tc358743: validate lane count and order Philipp Zabel
@ 2017-09-22  7:04 ` Sakari Ailus
  0 siblings, 0 replies; 2+ messages in thread
From: Sakari Ailus @ 2017-09-22  7:04 UTC (permalink / raw)
  To: Philipp Zabel
  Cc: linux-media, Dave Stevenson, Hans Verkuil, Sakari Ailus,
	Mauro Carvalho Chehab, Mats Randgaard

Hi Philipp,

On Thu, Sep 21, 2017 at 05:31:39PM +0200, Philipp Zabel wrote:
> The TC358743 does not support reordering lanes, or more than 4 data
> lanes.
> 
> Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
> ---
>  drivers/media/i2c/tc358743.c | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
> 
> diff --git a/drivers/media/i2c/tc358743.c b/drivers/media/i2c/tc358743.c
> index a35043cefe128..b7285e45b908a 100644
> --- a/drivers/media/i2c/tc358743.c
> +++ b/drivers/media/i2c/tc358743.c
> @@ -1743,6 +1743,7 @@ static int tc358743_probe_of(struct tc358743_state *state)
>  	struct clk *refclk;
>  	u32 bps_pr_lane;
>  	int ret = -EINVAL;
> +	int i;
>  
>  	refclk = devm_clk_get(dev, "refclk");
>  	if (IS_ERR(refclk)) {
> @@ -1771,6 +1772,21 @@ static int tc358743_probe_of(struct tc358743_state *state)
>  		goto free_endpoint;
>  	}
>  
> +	if (endpoint->bus.mipi_csi2.num_data_lanes > 4) {
> +		dev_err(dev, "invalid number of lanes\n");
> +		goto free_endpoint;
> +	}
> +
> +	for (i = 0; i < endpoint->bus.mipi_csi2.num_data_lanes; i++) {
> +		if (endpoint->bus.mipi_csi2.data_lanes[i] != i + 1)
> +			break;
> +	}

No other drivers perform such checks and if the hardware just doesn't
support it, then I'd just care about the number.

Checking that there are no more lanes configured than the hardware supports
makes definitely sense.

> +	if (i != endpoint->bus.mipi_csi2.num_data_lanes ||
> +	    endpoint->bus.mipi_csi2.clock_lane != 0) {
> +		dev_err(dev, "invalid lane order\n");
> +		goto free_endpoint;
> +	}
> +
>  	state->bus = endpoint->bus.mipi_csi2;
>  
>  	ret = clk_prepare_enable(refclk);

-- 
Regards,

Sakari Ailus
e-mail: sakari.ailus@iki.fi

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

end of thread, other threads:[~2017-09-22  7:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-21 15:31 [PATCH] [media] tc358743: validate lane count and order Philipp Zabel
2017-09-22  7:04 ` Sakari Ailus

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.