All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] drm/bridge: anx7625: Fix not correct get property counts
@ 2022-03-11 10:35 ` Xin Ji
  0 siblings, 0 replies; 6+ messages in thread
From: Xin Ji @ 2022-03-11 10:35 UTC (permalink / raw)
  To: Andrzej Hajda, Neil Armstrong, Robert Foss, Laurent Pinchart,
	Jonas Karlman, Jernej Skrabec, David Airlie, Daniel Vetter,
	Xin Ji
  Cc: bliang, qwen, hsinyi, mliu, dri-devel, linux-kernel

The property length which returns from "of_get_property", it means array
bytes count if the property has prefix as "/bits/ 8". The driver should
call function "of_property_read_u8_array" to get correct array value.

Fixes: fd0310b6fe7d ("drm/bridge: anx7625: add MIPI DPI input feature")
Signed-off-by: Xin Ji <xji@analogixsemi.com>

---
V1 -> V2: Fix Sam comment, use of_property_read_u8_array to get array
value
---
 drivers/gpu/drm/bridge/analogix/anx7625.c | 8 ++++----
 drivers/gpu/drm/bridge/analogix/anx7625.h | 4 ++--
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c b/drivers/gpu/drm/bridge/analogix/anx7625.c
index c6a9a02ed762..628cbf769141 100644
--- a/drivers/gpu/drm/bridge/analogix/anx7625.c
+++ b/drivers/gpu/drm/bridge/analogix/anx7625.c
@@ -1598,8 +1598,8 @@ static int anx7625_get_swing_setting(struct device *dev,
 			num_regs = DP_TX_SWING_REG_CNT;
 
 		pdata->dp_lane0_swing_reg_cnt = num_regs;
-		of_property_read_u32_array(dev->of_node, "analogix,lane0-swing",
-					   pdata->lane0_reg_data, num_regs);
+		of_property_read_u8_array(dev->of_node, "analogix,lane0-swing",
+					  pdata->lane0_reg_data, num_regs);
 	}
 
 	if (of_get_property(dev->of_node,
@@ -1608,8 +1608,8 @@ static int anx7625_get_swing_setting(struct device *dev,
 			num_regs = DP_TX_SWING_REG_CNT;
 
 		pdata->dp_lane1_swing_reg_cnt = num_regs;
-		of_property_read_u32_array(dev->of_node, "analogix,lane1-swing",
-					   pdata->lane1_reg_data, num_regs);
+		of_property_read_u8_array(dev->of_node, "analogix,lane1-swing",
+					  pdata->lane1_reg_data, num_regs);
 	}
 
 	return 0;
diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.h b/drivers/gpu/drm/bridge/analogix/anx7625.h
index edbbfe410a56..2c340f16f2c3 100644
--- a/drivers/gpu/drm/bridge/analogix/anx7625.h
+++ b/drivers/gpu/drm/bridge/analogix/anx7625.h
@@ -426,9 +426,9 @@ struct anx7625_platform_data {
 	int mipi_lanes;
 	int audio_en;
 	int dp_lane0_swing_reg_cnt;
-	int lane0_reg_data[DP_TX_SWING_REG_CNT];
 	int dp_lane1_swing_reg_cnt;
-	int lane1_reg_data[DP_TX_SWING_REG_CNT];
+	u8 lane0_reg_data[DP_TX_SWING_REG_CNT];
+	u8 lane1_reg_data[DP_TX_SWING_REG_CNT];
 	u32 low_power_mode;
 	struct device_node *mipi_host_node;
 };
-- 
2.25.1


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

* [PATCH v2] drm/bridge: anx7625: Fix not correct get property counts
@ 2022-03-11 10:35 ` Xin Ji
  0 siblings, 0 replies; 6+ messages in thread
From: Xin Ji @ 2022-03-11 10:35 UTC (permalink / raw)
  To: Andrzej Hajda, Neil Armstrong, Robert Foss, Laurent Pinchart,
	Jonas Karlman, Jernej Skrabec, David Airlie, Daniel Vetter,
	Xin Ji
  Cc: qwen, linux-kernel, dri-devel, mliu, hsinyi, bliang

The property length which returns from "of_get_property", it means array
bytes count if the property has prefix as "/bits/ 8". The driver should
call function "of_property_read_u8_array" to get correct array value.

Fixes: fd0310b6fe7d ("drm/bridge: anx7625: add MIPI DPI input feature")
Signed-off-by: Xin Ji <xji@analogixsemi.com>

---
V1 -> V2: Fix Sam comment, use of_property_read_u8_array to get array
value
---
 drivers/gpu/drm/bridge/analogix/anx7625.c | 8 ++++----
 drivers/gpu/drm/bridge/analogix/anx7625.h | 4 ++--
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c b/drivers/gpu/drm/bridge/analogix/anx7625.c
index c6a9a02ed762..628cbf769141 100644
--- a/drivers/gpu/drm/bridge/analogix/anx7625.c
+++ b/drivers/gpu/drm/bridge/analogix/anx7625.c
@@ -1598,8 +1598,8 @@ static int anx7625_get_swing_setting(struct device *dev,
 			num_regs = DP_TX_SWING_REG_CNT;
 
 		pdata->dp_lane0_swing_reg_cnt = num_regs;
-		of_property_read_u32_array(dev->of_node, "analogix,lane0-swing",
-					   pdata->lane0_reg_data, num_regs);
+		of_property_read_u8_array(dev->of_node, "analogix,lane0-swing",
+					  pdata->lane0_reg_data, num_regs);
 	}
 
 	if (of_get_property(dev->of_node,
@@ -1608,8 +1608,8 @@ static int anx7625_get_swing_setting(struct device *dev,
 			num_regs = DP_TX_SWING_REG_CNT;
 
 		pdata->dp_lane1_swing_reg_cnt = num_regs;
-		of_property_read_u32_array(dev->of_node, "analogix,lane1-swing",
-					   pdata->lane1_reg_data, num_regs);
+		of_property_read_u8_array(dev->of_node, "analogix,lane1-swing",
+					  pdata->lane1_reg_data, num_regs);
 	}
 
 	return 0;
diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.h b/drivers/gpu/drm/bridge/analogix/anx7625.h
index edbbfe410a56..2c340f16f2c3 100644
--- a/drivers/gpu/drm/bridge/analogix/anx7625.h
+++ b/drivers/gpu/drm/bridge/analogix/anx7625.h
@@ -426,9 +426,9 @@ struct anx7625_platform_data {
 	int mipi_lanes;
 	int audio_en;
 	int dp_lane0_swing_reg_cnt;
-	int lane0_reg_data[DP_TX_SWING_REG_CNT];
 	int dp_lane1_swing_reg_cnt;
-	int lane1_reg_data[DP_TX_SWING_REG_CNT];
+	u8 lane0_reg_data[DP_TX_SWING_REG_CNT];
+	u8 lane1_reg_data[DP_TX_SWING_REG_CNT];
 	u32 low_power_mode;
 	struct device_node *mipi_host_node;
 };
-- 
2.25.1


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

* Re: [PATCH v2] drm/bridge: anx7625: Fix not correct get property counts
  2022-03-11 10:35 ` Xin Ji
@ 2022-03-11 11:36   ` Sam Ravnborg
  -1 siblings, 0 replies; 6+ messages in thread
From: Sam Ravnborg @ 2022-03-11 11:36 UTC (permalink / raw)
  To: Xin Ji
  Cc: Andrzej Hajda, Neil Armstrong, Robert Foss, Laurent Pinchart,
	Jonas Karlman, Jernej Skrabec, David Airlie, Daniel Vetter, qwen,
	linux-kernel, dri-devel, mliu, hsinyi, bliang

Hi Xin.

On Fri, Mar 11, 2022 at 06:35:25PM +0800, Xin Ji wrote:
> The property length which returns from "of_get_property", it means array
> bytes count if the property has prefix as "/bits/ 8". The driver should
> call function "of_property_read_u8_array" to get correct array value.
> 
> Fixes: fd0310b6fe7d ("drm/bridge: anx7625: add MIPI DPI input feature")
> Signed-off-by: Xin Ji <xji@analogixsemi.com>
> 
> ---
> V1 -> V2: Fix Sam comment, use of_property_read_u8_array to get array
> value
> ---
>  drivers/gpu/drm/bridge/analogix/anx7625.c | 8 ++++----
>  drivers/gpu/drm/bridge/analogix/anx7625.h | 4 ++--
>  2 files changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c b/drivers/gpu/drm/bridge/analogix/anx7625.c
> index c6a9a02ed762..628cbf769141 100644
> --- a/drivers/gpu/drm/bridge/analogix/anx7625.c
> +++ b/drivers/gpu/drm/bridge/analogix/anx7625.c
> @@ -1598,8 +1598,8 @@ static int anx7625_get_swing_setting(struct device *dev,
>  			num_regs = DP_TX_SWING_REG_CNT;
>  
>  		pdata->dp_lane0_swing_reg_cnt = num_regs;
> -		of_property_read_u32_array(dev->of_node, "analogix,lane0-swing",
> -					   pdata->lane0_reg_data, num_regs);
> +		of_property_read_u8_array(dev->of_node, "analogix,lane0-swing",
> +					  pdata->lane0_reg_data, num_regs);

The current implementation do a two step approach. First is find the
number of elements and then read the elements.
The number of elements is only used to limit what is read.

I suggest to use:

of_property_read_u8_array(dev->of_node, "analogix,lane0-swing",
			  pdata->lane0_reg_data, DP_TX_SWING_REG_CNT);

Then you a guaranteed to read at maximum DP_TX_SWING_REG_CNT entries.
And as the number of elements is not stored anywhere that should be fine.

This looks simpler and matches what we for example do in
drivers/gpu/drm/arm/malidp_drv.c - the only user in gpu/ of
of_property_read_u8_array().


	Sam

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

* Re: [PATCH v2] drm/bridge: anx7625: Fix not correct get property counts
@ 2022-03-11 11:36   ` Sam Ravnborg
  0 siblings, 0 replies; 6+ messages in thread
From: Sam Ravnborg @ 2022-03-11 11:36 UTC (permalink / raw)
  To: Xin Ji
  Cc: dri-devel, Jonas Karlman, David Airlie, Robert Foss, qwen,
	Neil Armstrong, linux-kernel, Jernej Skrabec, mliu,
	Laurent Pinchart, Andrzej Hajda, hsinyi, bliang

Hi Xin.

On Fri, Mar 11, 2022 at 06:35:25PM +0800, Xin Ji wrote:
> The property length which returns from "of_get_property", it means array
> bytes count if the property has prefix as "/bits/ 8". The driver should
> call function "of_property_read_u8_array" to get correct array value.
> 
> Fixes: fd0310b6fe7d ("drm/bridge: anx7625: add MIPI DPI input feature")
> Signed-off-by: Xin Ji <xji@analogixsemi.com>
> 
> ---
> V1 -> V2: Fix Sam comment, use of_property_read_u8_array to get array
> value
> ---
>  drivers/gpu/drm/bridge/analogix/anx7625.c | 8 ++++----
>  drivers/gpu/drm/bridge/analogix/anx7625.h | 4 ++--
>  2 files changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c b/drivers/gpu/drm/bridge/analogix/anx7625.c
> index c6a9a02ed762..628cbf769141 100644
> --- a/drivers/gpu/drm/bridge/analogix/anx7625.c
> +++ b/drivers/gpu/drm/bridge/analogix/anx7625.c
> @@ -1598,8 +1598,8 @@ static int anx7625_get_swing_setting(struct device *dev,
>  			num_regs = DP_TX_SWING_REG_CNT;
>  
>  		pdata->dp_lane0_swing_reg_cnt = num_regs;
> -		of_property_read_u32_array(dev->of_node, "analogix,lane0-swing",
> -					   pdata->lane0_reg_data, num_regs);
> +		of_property_read_u8_array(dev->of_node, "analogix,lane0-swing",
> +					  pdata->lane0_reg_data, num_regs);

The current implementation do a two step approach. First is find the
number of elements and then read the elements.
The number of elements is only used to limit what is read.

I suggest to use:

of_property_read_u8_array(dev->of_node, "analogix,lane0-swing",
			  pdata->lane0_reg_data, DP_TX_SWING_REG_CNT);

Then you a guaranteed to read at maximum DP_TX_SWING_REG_CNT entries.
And as the number of elements is not stored anywhere that should be fine.

This looks simpler and matches what we for example do in
drivers/gpu/drm/arm/malidp_drv.c - the only user in gpu/ of
of_property_read_u8_array().


	Sam

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

* Re: [PATCH v2] drm/bridge: anx7625: Fix not correct get property counts
  2022-03-11 11:36   ` Sam Ravnborg
@ 2022-03-14  6:04     ` Xin Ji
  -1 siblings, 0 replies; 6+ messages in thread
From: Xin Ji @ 2022-03-14  6:04 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: Andrzej Hajda, Neil Armstrong, Robert Foss, Laurent Pinchart,
	Jonas Karlman, Jernej Skrabec, David Airlie, Daniel Vetter, qwen,
	linux-kernel, dri-devel, mliu, hsinyi, bliang

On Fri, Mar 11, 2022 at 12:36:09PM +0100, Sam Ravnborg wrote:
> Hi Xin.
> 
> On Fri, Mar 11, 2022 at 06:35:25PM +0800, Xin Ji wrote:
> > The property length which returns from "of_get_property", it means array
> > bytes count if the property has prefix as "/bits/ 8". The driver should
> > call function "of_property_read_u8_array" to get correct array value.
> > 
> > Fixes: fd0310b6fe7d ("drm/bridge: anx7625: add MIPI DPI input feature")
> > Signed-off-by: Xin Ji <xji@analogixsemi.com>
> > 
> > ---
> > V1 -> V2: Fix Sam comment, use of_property_read_u8_array to get array
> > value
> > ---
> >  drivers/gpu/drm/bridge/analogix/anx7625.c | 8 ++++----
> >  drivers/gpu/drm/bridge/analogix/anx7625.h | 4 ++--
> >  2 files changed, 6 insertions(+), 6 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c b/drivers/gpu/drm/bridge/analogix/anx7625.c
> > index c6a9a02ed762..628cbf769141 100644
> > --- a/drivers/gpu/drm/bridge/analogix/anx7625.c
> > +++ b/drivers/gpu/drm/bridge/analogix/anx7625.c
> > @@ -1598,8 +1598,8 @@ static int anx7625_get_swing_setting(struct device *dev,
> >  			num_regs = DP_TX_SWING_REG_CNT;
> >  
> >  		pdata->dp_lane0_swing_reg_cnt = num_regs;
> > -		of_property_read_u32_array(dev->of_node, "analogix,lane0-swing",
> > -					   pdata->lane0_reg_data, num_regs);
> > +		of_property_read_u8_array(dev->of_node, "analogix,lane0-swing",
> > +					  pdata->lane0_reg_data, num_regs);
> 
> The current implementation do a two step approach. First is find the
> number of elements and then read the elements.
> The number of elements is only used to limit what is read.
> 
> I suggest to use:
> 
> of_property_read_u8_array(dev->of_node, "analogix,lane0-swing",
> 			  pdata->lane0_reg_data, DP_TX_SWING_REG_CNT);
> 
> Then you a guaranteed to read at maximum DP_TX_SWING_REG_CNT entries.
> And as the number of elements is not stored anywhere that should be fine.
> 
> This looks simpler and matches what we for example do in
> drivers/gpu/drm/arm/malidp_drv.c - the only user in gpu/ of
> of_property_read_u8_array().
Hi Sam, the property is variable, so need two steps to approach, first
to get the property length, then to read the elements (the property
length may between 1 to DP_TX_SWING_REG_CNT). If directly to read the
element, I cannot exactly know how many registers need by configred.

Thanks,
Xin
> 
> 
> 	Sam

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

* Re: [PATCH v2] drm/bridge: anx7625: Fix not correct get property counts
@ 2022-03-14  6:04     ` Xin Ji
  0 siblings, 0 replies; 6+ messages in thread
From: Xin Ji @ 2022-03-14  6:04 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: dri-devel, Jonas Karlman, David Airlie, Robert Foss, qwen,
	Neil Armstrong, linux-kernel, Jernej Skrabec, mliu,
	Laurent Pinchart, Andrzej Hajda, hsinyi, bliang

On Fri, Mar 11, 2022 at 12:36:09PM +0100, Sam Ravnborg wrote:
> Hi Xin.
> 
> On Fri, Mar 11, 2022 at 06:35:25PM +0800, Xin Ji wrote:
> > The property length which returns from "of_get_property", it means array
> > bytes count if the property has prefix as "/bits/ 8". The driver should
> > call function "of_property_read_u8_array" to get correct array value.
> > 
> > Fixes: fd0310b6fe7d ("drm/bridge: anx7625: add MIPI DPI input feature")
> > Signed-off-by: Xin Ji <xji@analogixsemi.com>
> > 
> > ---
> > V1 -> V2: Fix Sam comment, use of_property_read_u8_array to get array
> > value
> > ---
> >  drivers/gpu/drm/bridge/analogix/anx7625.c | 8 ++++----
> >  drivers/gpu/drm/bridge/analogix/anx7625.h | 4 ++--
> >  2 files changed, 6 insertions(+), 6 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c b/drivers/gpu/drm/bridge/analogix/anx7625.c
> > index c6a9a02ed762..628cbf769141 100644
> > --- a/drivers/gpu/drm/bridge/analogix/anx7625.c
> > +++ b/drivers/gpu/drm/bridge/analogix/anx7625.c
> > @@ -1598,8 +1598,8 @@ static int anx7625_get_swing_setting(struct device *dev,
> >  			num_regs = DP_TX_SWING_REG_CNT;
> >  
> >  		pdata->dp_lane0_swing_reg_cnt = num_regs;
> > -		of_property_read_u32_array(dev->of_node, "analogix,lane0-swing",
> > -					   pdata->lane0_reg_data, num_regs);
> > +		of_property_read_u8_array(dev->of_node, "analogix,lane0-swing",
> > +					  pdata->lane0_reg_data, num_regs);
> 
> The current implementation do a two step approach. First is find the
> number of elements and then read the elements.
> The number of elements is only used to limit what is read.
> 
> I suggest to use:
> 
> of_property_read_u8_array(dev->of_node, "analogix,lane0-swing",
> 			  pdata->lane0_reg_data, DP_TX_SWING_REG_CNT);
> 
> Then you a guaranteed to read at maximum DP_TX_SWING_REG_CNT entries.
> And as the number of elements is not stored anywhere that should be fine.
> 
> This looks simpler and matches what we for example do in
> drivers/gpu/drm/arm/malidp_drv.c - the only user in gpu/ of
> of_property_read_u8_array().
Hi Sam, the property is variable, so need two steps to approach, first
to get the property length, then to read the elements (the property
length may between 1 to DP_TX_SWING_REG_CNT). If directly to read the
element, I cannot exactly know how many registers need by configred.

Thanks,
Xin
> 
> 
> 	Sam

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

end of thread, other threads:[~2022-03-14  6:04 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-11 10:35 [PATCH v2] drm/bridge: anx7625: Fix not correct get property counts Xin Ji
2022-03-11 10:35 ` Xin Ji
2022-03-11 11:36 ` Sam Ravnborg
2022-03-11 11:36   ` Sam Ravnborg
2022-03-14  6:04   ` Xin Ji
2022-03-14  6:04     ` Xin Ji

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.