From patchwork Sun Mar 19 15:00:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rob Herring (Arm)" X-Patchwork-Id: 13180400 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 89CADC6FD1F for ; Sun, 19 Mar 2023 15:02:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=gnEZqwAzgl07Nlqu0S5vsxz18ioFJ+UQg0x3O4eiLWM=; b=wf3tijFiQRYD9F ZfbKP49g8YRjRzwP/eScFULNPJJJGKlOibjyOnGf0q7SkZbzIAusCnjKPjshKAzaLkLY9LYQiJPps J1affS4UckbiH0nrHjaicTEjL/otkXGXaWmvZYgvaepRqvmpn/4Cwe67gxJqTMdxDoAfqHlmcD2p1 9LgxSMnPpsaqoRAT8GapkE3Lmued4tjtglkHDKUxF0ugOnx4HIWAygGbndtC0yZUlCWokUa63xkY5 fVxdEWZwoIHIF/4rPoIHfCnpIEuN+3maXbpb4f9TMqB3DSSq4qVElgs7O6/psnGAmn3SatsoD621y cuGOB55aGOlsEDO3OHgA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pduWZ-006tWv-2U; Sun, 19 Mar 2023 15:00:43 +0000 Received: from mail-io1-f41.google.com ([209.85.166.41]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pduWW-006tVK-16 for linux-arm-kernel@lists.infradead.org; Sun, 19 Mar 2023 15:00:42 +0000 Received: by mail-io1-f41.google.com with SMTP id p17so2666680ioj.10 for ; Sun, 19 Mar 2023 08:00:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679238038; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=4+yh1Iwz6GpGxVzG6CeG24b3aBWigOqdkkBWntDGMZY=; b=7ImBZ8AQw6MYfVuEqo4VLtyl9FHR4g/EdfWCHve2ff506ugXwE4+qeztzBJu1dqeXW txiK5gb9RQgGYnM+lUN5qfnKhYv+OfFTqh3wfrgnnWhE+RekW32igTF9nGrd43Cf0yuT wSc2cbFx/D1VuvCze88clL7ZwD4p2jgnS9F+vKwJ8LBHDV04f7r9BKnWwj0GEhYc6p8q 9tAqPif3wgFelqExF76knKVidQ1uLeyU7ikwImoWTrQdMn4nuBx2pZCEhR3jq0i7RLNO Vwnb8opcVnjF1OWihMN3sR34He2SRyagQ9DKUVasqe/v7uXqWAhug75zo/Zfg/4Z+tLW wCpA== X-Gm-Message-State: AO0yUKXY46qDKI9Uv1nzcmqmdMycE3tgk+UnTZUiarB/hySbJ7iVwX31 1yWXqRJTgAfKgswD7T192w== X-Google-Smtp-Source: AK7set82e+A0Ra5xDg3iEg6mu505pJCKDywkfHvsolgYRYnvyKJbL7mZG6I7riL0gg+UZolbTIBVyQ== X-Received: by 2002:a5d:8616:0:b0:755:7b0c:604a with SMTP id f22-20020a5d8616000000b007557b0c604amr3278553iol.2.1679238038667; Sun, 19 Mar 2023 08:00:38 -0700 (PDT) Received: from robh_at_kernel.org ([2605:ef80:80c4:7b93:58f2:478b:84fd:941e]) by smtp.gmail.com with ESMTPSA id w29-20020a056638379d00b0040630f8625asm2486356jal.13.2023.03.19.08.00.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Mar 2023 08:00:38 -0700 (PDT) Received: (nullmailer pid 66655 invoked by uid 1000); Sun, 19 Mar 2023 15:00:36 -0000 From: Rob Herring To: Geert Uytterhoeven , Magnus Damm , Russell King Cc: linux-arm-kernel@lists.infradead.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] ARM: sh-mobile: Use of_cpu_node_to_id() to read CPU node 'reg' Date: Sun, 19 Mar 2023 10:00:27 -0500 Message-Id: <20230319150027.66475-1-robh@kernel.org> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230319_080040_376126_51A62960 X-CRM114-Status: GOOD ( 14.11 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Replace open coded CPU nodes reading of "reg" and translation to logical ID with of_cpu_node_to_id(). Signed-off-by: Rob Herring --- arch/arm/mach-shmobile/platsmp-apmu.c | 34 +++++++++++---------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/arch/arm/mach-shmobile/platsmp-apmu.c b/arch/arm/mach-shmobile/platsmp-apmu.c index e771ce70e132..27cfe753c467 100644 --- a/arch/arm/mach-shmobile/platsmp-apmu.c +++ b/arch/arm/mach-shmobile/platsmp-apmu.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -210,7 +211,6 @@ static void apmu_parse_dt(void (*fn)(struct resource *res, int cpu, int bit)) struct device_node *np_apmu, *np_cpu; struct resource res; int bit, index; - u32 id; for_each_matching_node(np_apmu, apmu_ids) { /* only enable the cluster that includes the boot CPU */ @@ -218,33 +218,27 @@ static void apmu_parse_dt(void (*fn)(struct resource *res, int cpu, int bit)) for (bit = 0; bit < CONFIG_NR_CPUS; bit++) { np_cpu = of_parse_phandle(np_apmu, "cpus", bit); - if (np_cpu) { - if (!of_property_read_u32(np_cpu, "reg", &id)) { - if (id == cpu_logical_map(0)) { - is_allowed = true; - of_node_put(np_cpu); - break; - } - - } + if (np_cpu && of_cpu_node_to_id(np_cpu) == 0) { + is_allowed = true; of_node_put(np_cpu); + break; } + of_node_put(np_cpu); } if (!is_allowed) continue; for (bit = 0; bit < CONFIG_NR_CPUS; bit++) { np_cpu = of_parse_phandle(np_apmu, "cpus", bit); - if (np_cpu) { - if (!of_property_read_u32(np_cpu, "reg", &id)) { - index = get_logical_index(id); - if ((index >= 0) && - !of_address_to_resource(np_apmu, - 0, &res)) - fn(&res, index, bit); - } - of_node_put(np_cpu); - } + if (!np_cpu) + continue; + + index = of_cpu_node_to_id(np_cpu); + if ((index >= 0) && + !of_address_to_resource(np_apmu, 0, &res)) + fn(&res, index, bit); + + of_node_put(np_cpu); } } }