linux-renesas-soc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marek Vasut <marek.vasut@gmail.com>
To: Frank Rowand <frowand.list@gmail.com>, Rob Herring <robh+dt@kernel.org>
Cc: devicetree@vger.kernel.org,
	Marek Vasut <marek.vasut+renesas@gmail.com>,
	"open list:MEDIA DRIVERS FOR RENESAS - FCP" 
	<linux-renesas-soc@vger.kernel.org>
Subject: Re: [PATCH] of: Fix of_empty_ranges_quirk()
Date: Sat, 7 Sep 2019 17:15:58 +0200	[thread overview]
Message-ID: <1fef7c3e-0a87-aec7-ee24-3bfc85041cd9@gmail.com> (raw)
In-Reply-To: <5d393d4b-b8dc-39e1-991e-de367649cf58@gmail.com>

On 8/10/19 9:47 PM, Frank Rowand wrote:
> On 8/10/19 6:39 AM, Marek Vasut wrote:
>> On 8/10/19 12:34 AM, Rob Herring wrote:
>>> On Fri, Aug 9, 2019 at 11:33 AM <marek.vasut@gmail.com> wrote:
>>>>
>>>> From: Marek Vasut <marek.vasut+renesas@gmail.com>
>>>>
>>>> The of_empty_ranges_quirk() returns a mix of boolean and signed integer
>>>> types, which cannot work well.
>>>
>>> It never returns a negative. The negative is used as an uninitialized
>>> flag. Note quirk_state is static.
>>
>> It's still mixing boolean and signed int types though, which isn't right.
> 
> From a code readability aspect, Marek is correct.
> 
> The code author used "stupid (or clever) coding tricks" (tm) to save a
> little bit of memory.  A more readable implementation would be:
> 
> 
> static bool of_empty_ranges_quirk(struct device_node *np)
> {
>         /*
>          * As far as we know, the missing "ranges" problem only exists on Apple
> 	 * machines, so only enable the exception on powerpc. --gcl
>          */
> 
>         if (IS_ENABLED(CONFIG_PPC)) {
>                 /* Cache the result for global "Mac" setting */
>                 static int quirk_state_initialized = 0;
>                 static bool quirk_state;
> 
>                 /* PA-SEMI sdc DT bug */
>                 if (of_device_is_compatible(np, "1682m-sdc"))
>                         return true;
> 
>                 if (!quirk_state_initialized)
> 			quirk_state_initialized = 1;
>                         quirk_state =
>                                 of_machine_is_compatible("Power Macintosh") ||
>                                 of_machine_is_compatible("MacRISC");
>                 return quirk_state;
>         }
>         return false;
> }
> 
> 
> I would also rename of_empty_ranges_quirk() to something like
> of_missing_ranges_is_ok() or of_missing_ranges_allowed().
> "quirk" does not convey any useful information while my proposed rename
> describes what the function is actually checking for.
> 
> The comment that I added is currently in the caller of of_empty_ranges_quirk(),
> but instead belongs in of_empty_ranges_quirk().  When I read that comment in
> of_translate_one(), my reaction was to look for the check for powerpc in
> of_translate_one() and to be puzzled when I could not find it.  I also
> modified the comment for the changed context.  Thus the "--gcl" portion
> of the comment should also be removed from of_translate_one().
> 
> The more readable implementation (IMNSHO) uses slightly more memory and
> slightly more code, but it is more direct about what it is doing and thus
> more readable.

Thanks for the input, sorry for the delay, let me send a V2.

-- 
Best regards,
Marek Vasut

  reply	other threads:[~2019-09-07 16:39 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-09 17:33 [PATCH] of: Fix of_empty_ranges_quirk() marek.vasut
2019-08-09 20:41 ` Simon Horman
2019-08-09 22:34 ` Rob Herring
2019-08-10 13:39   ` Marek Vasut
2019-08-10 19:47     ` Frank Rowand
2019-09-07 15:15       ` Marek Vasut [this message]
2019-08-10 23:06     ` Rob Herring

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=1fef7c3e-0a87-aec7-ee24-3bfc85041cd9@gmail.com \
    --to=marek.vasut@gmail.com \
    --cc=devicetree@vger.kernel.org \
    --cc=frowand.list@gmail.com \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=marek.vasut+renesas@gmail.com \
    --cc=robh+dt@kernel.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;
as well as URLs for NNTP newsgroup(s).