mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: "Leif Middelschulte" <leif.middelschulte@klsmartin.com>,
	uol@pengutronix.de, ore@pengutronix.de,
	"Søren Andersen" <san@skov.dk>,
	"Ahmad Fatoum" <a.fatoum@pengutronix.de>
Subject: [PATCH 3/6] ARM: i.MX6: skov: refactor LVDS/parallel device tree fixups
Date: Thu, 22 Dec 2022 15:11:58 +0100	[thread overview]
Message-ID: <20221222141201.3087192-4-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20221222141201.3087192-1-a.fatoum@pengutronix.de>

In preparation for a fix in a follow-up commit, refactor the code, so
each fixup is done in its own function. This enables easy early exists
without increasing indentation level. No functional change

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 arch/arm/boards/skov-imx6/board.c | 59 +++++++++++++++++++------------
 1 file changed, 37 insertions(+), 22 deletions(-)

diff --git a/arch/arm/boards/skov-imx6/board.c b/arch/arm/boards/skov-imx6/board.c
index d5d229ae81ac..7ddc6e937b0b 100644
--- a/arch/arm/boards/skov-imx6/board.c
+++ b/arch/arm/boards/skov-imx6/board.c
@@ -451,6 +451,39 @@ static int skov_imx6_fixup(struct device_node *root, void *unused)
 	return 0;
 }
 
+static void skov_init_parallel_lcd(void)
+{
+	struct device_node *lcd;
+
+	lcd = of_find_compatible_node(NULL, NULL, "fsl,imx-parallel-display");
+	if (!lcd) {
+		dev_err(skov_priv->dev, "Cannot find \"fsl,imx-parallel-display\" node\n");
+		return;
+	}
+
+	of_device_enable_and_register(lcd);
+}
+
+static void skov_init_ldb(void)
+{
+	struct device_node *ldb, *chan;
+
+	ldb = of_find_compatible_node(NULL, NULL, "fsl,imx6q-ldb");
+	if (!ldb) {
+		dev_err(skov_priv->dev, "Cannot find \"fsl,imx6q-ldb\" node\n");
+		return;
+	}
+
+	of_device_enable_and_register(ldb);
+
+	/* ... as well as its channel 0 */
+	chan = of_find_node_by_name_address(ldb, "lvds-channel@0");
+	if (chan)
+		of_device_enable(chan);
+	else
+		dev_err(skov_priv->dev, "Cannot find \"lvds-channel@0\" node\n");
+}
+
 /*
  * Some variants need tweaks to make them work
  *
@@ -461,7 +494,6 @@ static int skov_imx6_fixup(struct device_node *root, void *unused)
 static void skov_init_board(const struct board_description *variant)
 {
 	struct device_node *gpio_np = NULL;
-	struct device_node *np;
 	char *environment_path, *envdev;
 	int ret;
 
@@ -524,28 +556,11 @@ static void skov_init_board(const struct board_description *variant)
 		gpio_free(200);
 	}
 
-	if (variant->flags & SKOV_DISPLAY_PARALLEL) {
-		np = of_find_compatible_node(NULL, NULL, "fsl,imx-parallel-display");
-		if (np)
-			of_device_enable_and_register(np);
-		else
-			dev_err(skov_priv->dev, "Cannot find \"fsl,imx-parallel-display\" node\n");
-	}
+	if (variant->flags & SKOV_DISPLAY_PARALLEL)
+		skov_init_parallel_lcd();
 
-	if (variant->flags & SKOV_DISPLAY_LVDS) {
-		np = of_find_compatible_node(NULL, NULL, "fsl,imx6q-ldb");
-		if (np)
-			of_device_enable_and_register(np);
-		else
-			dev_err(skov_priv->dev, "Cannot find \"fsl,imx6q-ldb\" node\n");
-
-		/* ... as well as its channel 0 */
-		np = of_find_node_by_name_address(np, "lvds-channel@0");
-		if (np)
-			of_device_enable(np);
-		else
-			dev_err(skov_priv->dev, "Cannot find \"lvds-channel@0\" node\n");
-	}
+	if (variant->flags & SKOV_DISPLAY_LVDS)
+		skov_init_ldb();
 }
 
 static int skov_set_switch_lan2_mac(struct skov_imx6_priv *priv)
-- 
2.30.2




  parent reply	other threads:[~2022-12-22 14:34 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-22 14:11 [PATCH 0/6] ARM: i.MX6: Fix LVDS splash on skov and some others Ahmad Fatoum
2022-12-22 14:11 ` [PATCH 1/6] clk: imx: set CLK_SET_RATE_NO_REPARENT for all muxes Ahmad Fatoum
2022-12-23  9:11   ` Marco Felsch
2022-12-22 14:11 ` [PATCH 2/6] clk: mux: forward round/set rate to parent if CLK_SET_RATE_PARENT Ahmad Fatoum
2022-12-22 14:11 ` Ahmad Fatoum [this message]
2022-12-23  9:14   ` [PATCH 3/6] ARM: i.MX6: skov: refactor LVDS/parallel device tree fixups Marco Felsch
2022-12-22 14:11 ` [PATCH 4/6] ARM: i.MX6: skov: fix LVDS deep probe Ahmad Fatoum
2022-12-23  9:08   ` Marco Felsch
2022-12-22 14:12 ` [PATCH 5/6] video: edid: print debug message on EDID read out error Ahmad Fatoum
2022-12-23  9:06   ` Marco Felsch
2022-12-22 14:12 ` [PATCH 6/6] ARM: configs: imx_v7_defconfig: enable some useful options Ahmad Fatoum
2022-12-23  9:10   ` Marco Felsch
2023-01-04 12:01     ` Sascha Hauer
2023-01-04 12:04       ` Ahmad Fatoum
2023-01-04 12:07         ` Sascha Hauer

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=20221222141201.3087192-4-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=leif.middelschulte@klsmartin.com \
    --cc=ore@pengutronix.de \
    --cc=san@skov.dk \
    --cc=uol@pengutronix.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