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 Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9400AC433F5 for ; Fri, 22 Apr 2022 09:21:13 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id AD7C083AEB; Fri, 22 Apr 2022 11:21:10 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="Xi6MG4LF"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 474B383AEB; Fri, 22 Apr 2022 11:21:08 +0200 (CEST) Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 3E2A3839DF for ; Fri, 22 Apr 2022 11:21:04 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=pali@kernel.org Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 3D6ACCE2808; Fri, 22 Apr 2022 09:21:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 33209C385A0; Fri, 22 Apr 2022 09:20:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1650619259; bh=HqXveug4WvFVRGbQp/EYC+gRhvGi36Z1MVhrKTwbcNY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Xi6MG4LFYHXBlOm2xghu/PxYzid27cbKgQrhSmqQmlU/Ku4nu2QK4UX/YOL9Am0EU NE3wyZPlBiPG7C4LA976TBwM4bRN7sEr0m23ePry2AvAf9uzfaCF4IBojFFbFglb7v fRAG+U/XcrQ3R5aPRQdwL0ebnAHI1Z2Xm5G01Xjp6raNnFRYbG6VCuBayfSixGYxJy k/NYVImIXerbhBFok8FBwQ2U9VdUxcevjXU/KW7mHNSjnvODvo/qURniIbvs3xZAyY 4Oa6EwUx59F/yjq3S9IYcPU+xqobTBvfMTGoqUu5v81RYP7je1y99rsUKR7pq1NLJX 3/YAoRKBMXbTQ== Received: by pali.im (Postfix) id 028BDA09; Fri, 22 Apr 2022 11:20:55 +0200 (CEST) Date: Fri, 22 Apr 2022 11:20:55 +0200 From: Pali =?utf-8?B?Um9ow6Fy?= To: Marek =?utf-8?B?QmVow7pu?= Cc: Stefan Roese , u-boot@lists.denx.de Subject: Re: [PATCH u-boot-marvell 6/8] arm: mvebu: turris_omnia: Extract code for disabling sata/pcie Message-ID: <20220422092055.ahsbh7nwjvjmgfig@pali> References: <20220302114758.21787-1-pali@kernel.org> <20220302114758.21787-7-pali@kernel.org> <20220302133848.68999106@dellmb> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20220302133848.68999106@dellmb> User-Agent: NeoMutt/20180716 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean On Wednesday 02 March 2022 13:38:48 Marek Behún wrote: > On Wed, 2 Mar 2022 12:47:56 +0100 > Pali Rohár wrote: > > > Move code for disabling sata and pcie DT nodes to own functions, so this > > code can be called from other places in follow up patches. > > > > Signed-off-by: Pali Rohár > > --- > > board/CZ.NIC/turris_omnia/turris_omnia.c | 96 +++++++++++++----------- > > 1 file changed, 52 insertions(+), 44 deletions(-) > > > > diff --git a/board/CZ.NIC/turris_omnia/turris_omnia.c b/board/CZ.NIC/turris_omnia/turris_omnia.c > > index 6a057ea7dd70..57b797db4a8e 100644 > > --- a/board/CZ.NIC/turris_omnia/turris_omnia.c > > +++ b/board/CZ.NIC/turris_omnia/turris_omnia.c > > @@ -518,11 +518,54 @@ void spl_board_init(void) > > > > #if IS_ENABLED(CONFIG_OF_BOARD_FIXUP) || IS_ENABLED(CONFIG_OF_BOARD_SETUP) > > > > -static void fixup_serdes_0_nodes(void *blob) > > +static void disable_sata_node(void *blob) > > { > > - bool mode_sata; > > int node; > > > > + fdt_for_each_node_by_compatible(node, blob, -1, "marvell,armada-380-ahci") { > > + if (!fdtdec_get_is_enabled(blob, node)) > > + continue; > > + > > + if (fdt_status_disabled(blob, node) < 0) > > + printf("Cannot disable SATA DT node!\n"); > > + else > > + debug("Disabled SATA DT node\n"); > > + > > + break; > > + } > > +} > > + > > +static void disable_pcie_node(void *blob, int port) > > +{ > > + int node; > > + > > + fdt_for_each_node_by_compatible(node, blob, -1, "marvell,armada-370-pcie") { > > + int port_node; > > + > > + if (!fdtdec_get_is_enabled(blob, node)) > > + continue; > > + > > + fdt_for_each_subnode (port_node, blob, node) { > > + if (!fdtdec_get_is_enabled(blob, port_node)) > > + continue; > > + > > + if (fdtdec_get_int(blob, port_node, "marvell,pcie-port", -1) != port) > > + continue; > > + > > + if (fdt_status_disabled(blob, port_node) < 0) > > + printf("Cannot disable PCIe port %d DT node!\n", port); > > + else > > + debug("Disabled PCIe port %d DT node\n", port); > > + > > + return; > > + } > > + } > > +} > > + > > +static void fixup_msata_port_nodes(void *blob) > > +{ > > + bool mode_sata; > > + > > /* > > * Determine if SerDes 0 is configured to SATA mode. > > * We do this instead of calling omnia_detect_sata() to avoid another > > @@ -541,47 +584,12 @@ static void fixup_serdes_0_nodes(void *blob) > > return; > > } > > > > - /* If mSATA card is not present, disable SATA DT node */ > > if (!mode_sata) { > > - fdt_for_each_node_by_compatible(node, blob, -1, > > - "marvell,armada-380-ahci") { > > - if (!fdtdec_get_is_enabled(blob, node)) > > - continue; > > - > > - if (fdt_status_disabled(blob, node) < 0) > > - printf("Cannot disable SATA DT node!\n"); > > - else > > - debug("Disabled SATA DT node\n"); > > - > > - break; > > - } > > - > > - return; > > - } > > - > > - /* Otherwise disable PCIe port 0 DT node (MiniPCIe / mSATA port) */ > > - fdt_for_each_node_by_compatible(node, blob, -1, > > - "marvell,armada-370-pcie") { > > - int port; > > - > > - if (!fdtdec_get_is_enabled(blob, node)) > > - continue; > > - > > - fdt_for_each_subnode (port, blob, node) { > > - if (!fdtdec_get_is_enabled(blob, port)) > > - continue; > > - > > - if (fdtdec_get_int(blob, port, "marvell,pcie-port", > > - -1) != 0) > > - continue; > > - > > - if (fdt_status_disabled(blob, port) < 0) > > - printf("Cannot disable PCIe port 0 DT node!\n"); > > - else > > - debug("Disabled PCIe port 0 DT node\n"); > > - > > - return; > > - } > > + /* If mSATA card is not present, disable SATA DT node */ > > + disable_sata_node(blob); > > + } else { > > + /* Otherwise disable PCIe port 0 DT node (MiniPCIe / mSATA port) */ > > + disable_pcie_node(blob, 0); > > } > > If I am looking at this correctly, there is only one statement both in > if and in else clause. Can we drop the {} parentheses? > > Marek Due to comment above which belongs to the code, I put there {} parentheses.