From: Xin Ji <xji@analogixsemi.com>
To: Sam Ravnborg <sam@ravnborg.org>
Cc: Andrzej Hajda <andrzej.hajda@intel.com>,
Neil Armstrong <narmstrong@baylibre.com>,
Robert Foss <robert.foss@linaro.org>,
Laurent Pinchart <Laurent.pinchart@ideasonboard.com>,
Jonas Karlman <jonas@kwiboo.se>,
Jernej Skrabec <jernej.skrabec@gmail.com>,
David Airlie <airlied@linux.ie>, Daniel Vetter <daniel@ffwll.ch>,
qwen@analogixsemi.com, linux-kernel@vger.kernel.org,
dri-devel@lists.freedesktop.org, mliu@analogixsemi.com,
hsinyi@chromium.org, bliang@analogixsemi.com
Subject: Re: [PATCH v2] drm/bridge: anx7625: Fix not correct get property counts
Date: Mon, 14 Mar 2022 14:04:11 +0800 [thread overview]
Message-ID: <20220314060411.GA1456403@anxtwsw-Precision-3640-Tower> (raw)
In-Reply-To: <Yis0KXVqZokrkoP7@ravnborg.org>
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
prev parent reply other threads:[~2022-03-14 6:04 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-11 10:35 Xin Ji
2022-03-11 11:36 ` Sam Ravnborg
2022-03-14 6:04 ` Xin Ji [this message]
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=20220314060411.GA1456403@anxtwsw-Precision-3640-Tower \
--to=xji@analogixsemi.com \
--cc=Laurent.pinchart@ideasonboard.com \
--cc=airlied@linux.ie \
--cc=andrzej.hajda@intel.com \
--cc=bliang@analogixsemi.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=hsinyi@chromium.org \
--cc=jernej.skrabec@gmail.com \
--cc=jonas@kwiboo.se \
--cc=linux-kernel@vger.kernel.org \
--cc=mliu@analogixsemi.com \
--cc=narmstrong@baylibre.com \
--cc=qwen@analogixsemi.com \
--cc=robert.foss@linaro.org \
--cc=sam@ravnborg.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®