public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: "Marek Behún" <marek.behun@nic.cz>
To: "Pali Rohár" <pali@kernel.org>
Cc: Stefan Roese <sr@denx.de>, u-boot@lists.denx.de
Subject: Re: [PATCH u-boot-marvell 6/8] arm: mvebu: turris_omnia: Extract code for disabling sata/pcie
Date: Wed, 2 Mar 2022 13:38:48 +0100	[thread overview]
Message-ID: <20220302133848.68999106@dellmb> (raw)
In-Reply-To: <20220302114758.21787-7-pali@kernel.org>

On Wed,  2 Mar 2022 12:47:56 +0100
Pali Rohár <pali@kernel.org> 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 <pali@kernel.org>
> ---
>  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

  reply	other threads:[~2022-03-02 12:39 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-02 11:47 [PATCH u-boot-marvell 0/8] Turris Omnia: Add support for configuring mSATA and WWAN slots via env variables Pali Rohár
2022-03-02 11:47 ` [PATCH u-boot-marvell 1/8] env: sf: Allow to use env_sf_init_addr() at any stage Pali Rohár
2022-03-02 11:47 ` [PATCH u-boot-marvell 2/8] arm: mvebu: turris_omnia: Provide env_sf_get_env_addr() function Pali Rohár
2022-03-02 12:37   ` Marek Behún
2022-04-22 11:49     ` Pali Rohár
2022-04-22 12:21       ` Marek Behún
2022-03-02 11:47 ` [PATCH u-boot-marvell 3/8] arm: mvebu: turris_omnia: Enable ENV support in SPL Pali Rohár
2022-03-02 11:47 ` [PATCH u-boot-marvell 4/8] arm: mvebu: turris_omnia: Define only one serdes map variable Pali Rohár
2022-03-02 11:47 ` [PATCH u-boot-marvell 5/8] arm: mvebu: turris_omnia: Allow to configure mSATA slot via env variable Pali Rohár
2022-03-02 12:36   ` Marek Behún
2022-03-02 11:47 ` [PATCH u-boot-marvell 6/8] arm: mvebu: turris_omnia: Extract code for disabling sata/pcie Pali Rohár
2022-03-02 12:38   ` Marek Behún [this message]
2022-04-22  9:20     ` Pali Rohár
2022-04-22  9:23       ` Stefan Roese
2022-03-02 11:47 ` [PATCH u-boot-marvell 7/8] arm: mvebu: turris_omnia: Signal error when sata/pcie DT mode Pali Rohár
2022-03-02 11:47 ` [PATCH u-boot-marvell 8/8] arm: mvebu: turris_omnia: Add support for USB3.0 mode in WWAN MiniPCIe slot Pali Rohár
2022-03-02 12:46   ` Marek Behún
2022-04-22 11:47     ` Pali Rohár
2022-04-22 12:20       ` Marek Behún
2022-05-01 14:57 ` [PATCH u-boot-marvell 0/8] Turris Omnia: Add support for configuring mSATA and WWAN slots via env variables Pali Rohár
2022-05-02 15:39 ` Stefan Roese

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=20220302133848.68999106@dellmb \
    --to=marek.behun@nic.cz \
    --cc=pali@kernel.org \
    --cc=sr@denx.de \
    --cc=u-boot@lists.denx.de \
    /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