From: Peter Ujfalusi <peter.ujfalusi@ti.com>
To: Andrzej Hajda <a.hajda@samsung.com>, <airlied@linux.ie>,
<daniel@ffwll.ch>, <robh+dt@kernel.org>, <mark.rutland@arm.com>,
<narmstrong@baylibre.com>
Cc: <tomi.valkeinen@ti.com>, <dri-devel@lists.freedesktop.org>,
<devicetree@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<Laurent.pinchart@ideasonboard.com>, <jonas@kwiboo.se>,
<jernej.skrabec@siol.net>
Subject: Re: [PATCH 2/2] drm/bridge: Add tc358768 driver
Date: Wed, 22 Jan 2020 11:16:00 +0200 [thread overview]
Message-ID: <e8774c16-c34c-adf8-fee5-17323dcd95bf@ti.com> (raw)
In-Reply-To: <cdc941c5-681f-962b-7f99-ebfda6aaaa91@samsung.com>
Hi Andrzej,
On 22/01/2020 10.46, Andrzej Hajda wrote:
>>>> +struct tc358768_priv {
>>>> + struct device *dev;
>>>> + struct regmap *regmap;
>>>> + struct gpio_desc *reset_gpio;
>>>> + struct regulator_bulk_data supplies[ARRAY_SIZE(tc358768_supplies)];
>>>> + struct clk *refclk;
>>>> +
>>>> + struct mipi_dsi_host dsi_host;
>>>> + struct drm_bridge bridge;
>>>> + struct tc358768_dsi_output output;
>>>
>>> Since tc358768_dsi_output is used only here, you can define it here as
>>> well, up to you.
>> I think I have done it like this to avoid thinking about prefixes for
>> what is under the tc358768_dsi_output.
>> I'll take a look if it will look better unpacked here.
>
> I though rather about in-place anonymous struct definition:
>
> + struct tc358768_dsi_output {
> + struct mipi_dsi_device *dev;
> + struct drm_panel *panel;
> + struct drm_bridge *bridge;
> + } output;
>
> But, as I said - up to you.
I see. I think I will keep how it was. They are in proximity, so easy to
check.
>>>> +
>>>> + refclk = clk_get_rate(priv->refclk);
>>>> +
>>>> + best_diff = UINT_MAX;
>>>> + best_pll = 0;
>>>> + best_prd = 0;
>>>> + best_fbd = 0;
>>>> +
>>>> + for (prd = 0; prd < 16; ++prd) {
>>>> + u32 divisor = (prd + 1) * (1 << frs);
>>>> + u32 fbd;
>>>> +
>>>> + for (fbd = 0; fbd < 512; ++fbd) {
>>>> + u32 pll, diff;
>>>> +
>>>> + pll = (u32)div_u64((u64)refclk * (fbd + 1), divisor);
>>>> +
>>>> + if (pll >= max_pll || pll < min_pll)
>>>> + continue;
>>>> +
>>>> + diff = max(pll, target_pll) - min(pll, target_pll);
>>>> +
>>>> + if (diff < best_diff) {
>>>> + best_diff = diff;
>>>> + best_pll = pll;
>>>> + best_prd = prd;
>>>> + best_fbd = fbd;
>>>> + }
>>>> +
>>>> + if (best_diff == 0)
>>>> + break;
>>>> + }
>>>> +
>>>> + if (best_diff == 0)
>>>> + break;
>>> why another check here?
>> To break out from the top for() loop also in case exact match has been
>> found.
>
>
> Ahh, OK. So maybe you should put "if (diff == 0) goto found" inside "if
> (diff < best_diff)" block, in such case goto is not considered harmful
> :), and is more readable.
Exactly my thoughts ;)
- Péter
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
prev parent reply other threads:[~2020-01-22 9:15 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-17 10:15 [PATCH 0/2] drm/bridge: Support for Toshiba tc358768 RGB to DSI bridge Peter Ujfalusi
2019-12-17 10:15 ` [PATCH 1/2] dt-bindings: display: bridge: Add documentation for Toshiba tc358768 Peter Ujfalusi
2019-12-26 22:24 ` Rob Herring
2020-01-14 11:55 ` Peter Ujfalusi
2019-12-17 10:15 ` [PATCH 2/2] drm/bridge: Add tc358768 driver Peter Ujfalusi
2020-01-16 14:35 ` Andrzej Hajda
2020-01-21 15:11 ` Peter Ujfalusi
2020-01-22 8:46 ` Andrzej Hajda
2020-01-22 9:16 ` Peter Ujfalusi [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=e8774c16-c34c-adf8-fee5-17323dcd95bf@ti.com \
--to=peter.ujfalusi@ti.com \
--cc=Laurent.pinchart@ideasonboard.com \
--cc=a.hajda@samsung.com \
--cc=airlied@linux.ie \
--cc=daniel@ffwll.ch \
--cc=devicetree@vger.kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=jernej.skrabec@siol.net \
--cc=jonas@kwiboo.se \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=narmstrong@baylibre.com \
--cc=robh+dt@kernel.org \
--cc=tomi.valkeinen@ti.com \
/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;
as well as URLs for NNTP newsgroup(s).