From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 567AAC32751 for ; Sat, 10 Aug 2019 23:06:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 21E0D208C3 for ; Sat, 10 Aug 2019 23:06:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565478396; bh=SI2d4Y4hZcsrt7ve7CrzNd1JjWMC3yyXOT2RxwbjXqE=; h=References:In-Reply-To:From:Date:Subject:To:Cc:List-ID:From; b=VS6J1mTENZXugIGctbzxSSwYehfjlNvw7pafJYZn3jljM6ZIhII+xa/lkdBlPz668 2eRJKv3+l/aT3UhRn4nN+8d5YybcMQm73QZwQ7HFzW3DZMmtWN1+5HJO37wSCYFA+D ooO0bgAa1mBuyduDkwYz6iK7Q9YeC9U8CL211HTU= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726177AbfHJXGf (ORCPT ); Sat, 10 Aug 2019 19:06:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:41714 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725788AbfHJXGf (ORCPT ); Sat, 10 Aug 2019 19:06:35 -0400 Received: from mail-qk1-f180.google.com (mail-qk1-f180.google.com [209.85.222.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E905B208C4; Sat, 10 Aug 2019 23:06:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565478394; bh=SI2d4Y4hZcsrt7ve7CrzNd1JjWMC3yyXOT2RxwbjXqE=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=qojn2EIuU0YQdoMtEZa0fsyEnVUqcQtKuMbGD7jqJUsatW8elNX+GjFPGrY/MTLLQ ReD1q5nafCpn0ZJl0SSx2G11jm+nQvtiIXSPuI3hsZ6QGrqF7PrMi496Xmm00XSz7o ozHQ64LKOaSrsy5wYU9cV5+1vFkGFiKD/oTPKNjs= Received: by mail-qk1-f180.google.com with SMTP id g17so3787759qkk.8; Sat, 10 Aug 2019 16:06:33 -0700 (PDT) X-Gm-Message-State: APjAAAXBHQvZgfiayn9V/neIeNV5ZeAksWAZehsc4aKSgtwo8cHvUiho t+yMcpowYsr/WN28LqXLLoFNzJ+UpXgdlsFpwg== X-Google-Smtp-Source: APXvYqzMoxSMzmfJnWNfgvCIgM0nuiBjcGotb8rUssRzaeUgirt9md2wJ5YyJkMUroVAciLVRbrAOptmfLb33d7v8Vs= X-Received: by 2002:a37:a44a:: with SMTP id n71mr24174784qke.393.1565478393051; Sat, 10 Aug 2019 16:06:33 -0700 (PDT) MIME-Version: 1.0 References: <20190809173321.19944-1-marek.vasut@gmail.com> <10818888-6476-f4b1-1a2e-e10c3159327f@gmail.com> In-Reply-To: <10818888-6476-f4b1-1a2e-e10c3159327f@gmail.com> From: Rob Herring Date: Sat, 10 Aug 2019 17:06:21 -0600 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] of: Fix of_empty_ranges_quirk() To: Marek Vasut Cc: devicetree@vger.kernel.org, Marek Vasut , Frank Rowand , "open list:MEDIA DRIVERS FOR RENESAS - FCP" Content-Type: text/plain; charset="UTF-8" Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org On Sat, Aug 10, 2019 at 7:39 AM Marek Vasut wrote: > > On 8/10/19 12:34 AM, Rob Herring wrote: > > On Fri, Aug 9, 2019 at 11:33 AM wrote: > >> > >> From: Marek Vasut > >> > >> 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. I'm really only interested in touching this code if it is too remove it. But some reason people still run 1990s Macs. > >> Replace that with boolean only and fix > >> usage logic in of_translate_one() -- the check should trigger when the > >> ranges are NULL and the quirk is applicable on the hardware. > >> > >> Signed-off-by: Marek Vasut > >> Cc: Rob Herring > >> Cc: Frank Rowand > >> Cc: linux-renesas-soc@vger.kernel.org > >> To: devicetree@vger.kernel.org > >> --- > >> drivers/of/address.c | 9 +++++---- > >> 1 file changed, 5 insertions(+), 4 deletions(-) > >> > >> diff --git a/drivers/of/address.c b/drivers/of/address.c > >> index b492176c0572..ae2819e148b8 100644 > >> --- a/drivers/of/address.c > >> +++ b/drivers/of/address.c > >> @@ -616,7 +616,7 @@ static struct of_bus *of_match_bus(struct device_node *np) > >> return NULL; > >> } > >> > >> -static int of_empty_ranges_quirk(struct device_node *np) > >> +static bool of_empty_ranges_quirk(struct device_node *np) > >> { > >> if (IS_ENABLED(CONFIG_PPC)) { > >> /* To save cycles, we cache the result for global "Mac" setting */ > >> @@ -631,7 +631,8 @@ static int of_empty_ranges_quirk(struct device_node *np) > >> quirk_state = > >> of_machine_is_compatible("Power Macintosh") || > >> of_machine_is_compatible("MacRISC"); > >> - return quirk_state; > >> + if (quirk_state > 0) > >> + return true; > >> } > >> return false; > >> } > >> @@ -662,8 +663,8 @@ static int of_translate_one(struct device_node *parent, struct of_bus *bus, > >> * This code is only enabled on powerpc. --gcl > >> */ > >> ranges = of_get_property(parent, rprop, &rlen); > >> - if (ranges == NULL && !of_empty_ranges_quirk(parent)) { > >> - pr_debug("no ranges; cannot translate\n"); > >> + if (ranges == NULL && of_empty_ranges_quirk(parent)) { > >> + pr_err("no ranges; cannot translate\n"); > > > > This is wrong. If you have NULL ranges and not the quirk, then no > > ranges is an error. IOW, if you are getting an error here, you have an > > error in your DT (because I assume you are not working on a PASemi or > > Apple system). > > The way I understand the code is that > if (you have no ranges in the DT) AND (the quirk is applicable) then > print the message. Which is what this patch does. Your understanding is wrong. > Am I missing something ? The normal case is you must have ranges to translate addresses. If you don't have ranges (say for I2C addresses), then you shouldn't be in this code. The quirk is for when there is not a ranges property but should be. IOW, if the quirk is true, then pretend there is an empty ranges (1:1 translation) property and continue to translate the address. Rob