devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hugo Villeneuve <hugo@hugovil.com>
To: gregkh@linuxfoundation.org, jirislaby@kernel.org,
	robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org,
	conor+dt@kernel.org, hvilleneuve@dimonoff.com
Cc: linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org,
	devicetree@vger.kernel.org, hugo@hugovil.com
Subject: [PATCH 1/4] serial: sc16is7xx: use device_property APIs when configuring irda mode
Date: Wed, 20 Sep 2023 11:20:12 -0400	[thread overview]
Message-ID: <20230920152015.1376838-2-hugo@hugovil.com> (raw)
In-Reply-To: <20230920152015.1376838-1-hugo@hugovil.com>

From: Hugo Villeneuve <hvilleneuve@dimonoff.com>

Convert driver to be property provider agnostic and allow it to be
used on non-OF platforms.

Signed-off-by: Hugo Villeneuve <hvilleneuve@dimonoff.com>
---
 drivers/tty/serial/sc16is7xx.c | 34 ++++++++++++++++++++++++----------
 1 file changed, 24 insertions(+), 10 deletions(-)

diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c
index 1fe2c3e08a35..db2bb1c0d36c 100644
--- a/drivers/tty/serial/sc16is7xx.c
+++ b/drivers/tty/serial/sc16is7xx.c
@@ -1408,6 +1408,29 @@ static int sc16is7xx_setup_gpio_chip(struct sc16is7xx_port *s)
 }
 #endif
 
+static void sc16is7xx_setup_irda_ports(struct sc16is7xx_port *s)
+{
+	int i;
+	int ret;
+	int count;
+	u32 irda_port[2];
+	struct device *dev = s->p[0].port.dev;
+
+	count = device_property_count_u32(dev, "irda-mode-ports");
+	if (count < 0 || count > ARRAY_SIZE(irda_port))
+		return;
+
+	ret = device_property_read_u32_array(dev, "irda-mode-ports",
+					     irda_port, count);
+	if (ret)
+		return;
+
+	for (i = 0; i < count; i++) {
+		if (irda_port[i] < s->devtype->nr_uart)
+			s->p[irda_port[i]].irda_mode = true;
+	}
+}
+
 /*
  * Configure ports designated to operate as modem control lines.
  */
@@ -1590,16 +1613,7 @@ static int sc16is7xx_probe(struct device *dev,
 		sc16is7xx_power(&s->p[i].port, 0);
 	}
 
-	if (dev->of_node) {
-		struct property *prop;
-		const __be32 *p;
-		u32 u;
-
-		of_property_for_each_u32(dev->of_node, "irda-mode-ports",
-					 prop, p, u)
-			if (u < devtype->nr_uart)
-				s->p[u].irda_mode = true;
-	}
+	sc16is7xx_setup_irda_ports(s);
 
 	ret = sc16is7xx_setup_mctrl_ports(s);
 	if (ret)
-- 
2.30.2


  reply	other threads:[~2023-09-20 15:20 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-20 15:20 [PATCH 0/4] serial: sc16is7xx: device tree improvements Hugo Villeneuve
2023-09-20 15:20 ` Hugo Villeneuve [this message]
2023-09-20 15:20 ` [PATCH 2/4] serial: sc16is7xx: recognize "nxp,irda-mode-ports" DT property Hugo Villeneuve
2023-09-20 15:20 ` [PATCH 3/4] dt-bindings: sc16is7xx: add vendor prefix to irda-mode-ports property Hugo Villeneuve
2023-09-21 10:29   ` m.brock
2023-09-21 13:37     ` Hugo Villeneuve
2023-09-21 13:47   ` Conor Dooley
2023-09-21 16:24   ` Rob Herring
2023-09-21 16:32     ` Hugo Villeneuve
2023-09-22 19:52       ` Rob Herring
2023-09-27 14:28         ` Hugo Villeneuve
2023-09-20 15:20 ` [PATCH 4/4] dt-bindings: sc16is7xx: convert to YAML Hugo Villeneuve
2023-09-20 23:13   ` Rob Herring
2023-09-21 16:22     ` Hugo Villeneuve
2023-09-21 13:45   ` Conor Dooley
2023-09-21 15:30     ` Hugo Villeneuve
2023-09-22 11:35       ` Conor Dooley
2023-09-22 13:08         ` Hugo Villeneuve
2023-09-21 15:33   ` Rob Herring
2023-09-21 16:27     ` Hugo Villeneuve

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=20230920152015.1376838-2-hugo@hugovil.com \
    --to=hugo@hugovil.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=hvilleneuve@dimonoff.com \
    --cc=jirislaby@kernel.org \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=robh+dt@kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).