[PATCH 7/7] pinctrl: exynos: Convert to use livetree API for fdt access

Sam Protsenko semen.protsenko at linaro.org
Thu Nov 30 21:13:52 CET 2023


Use counterpart dev_read_* functions instead of fdt* ones. It fixes
checkpatch warnings like this:

    WARNING: Use the livetree API (dev_read_...)
    #54: FILE: drivers/pinctrl/exynos/pinctrl-exynos.c:137:
        pinvals[idx] = fdtdec_get_int(fdt, node,

and also makes it possible to avoid using the global data pointer in the
driver.

No functional change.

Signed-off-by: Sam Protsenko <semen.protsenko at linaro.org>
---
 drivers/pinctrl/exynos/pinctrl-exynos.c | 20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)

diff --git a/drivers/pinctrl/exynos/pinctrl-exynos.c b/drivers/pinctrl/exynos/pinctrl-exynos.c
index b6af3befbf9b..8a045cdf7aa8 100644
--- a/drivers/pinctrl/exynos/pinctrl-exynos.c
+++ b/drivers/pinctrl/exynos/pinctrl-exynos.c
@@ -9,12 +9,9 @@
 #include <common.h>
 #include <dm.h>
 #include <errno.h>
-#include <asm/global_data.h>
 #include <asm/io.h>
 #include "pinctrl-exynos.h"
 
-DECLARE_GLOBAL_DATA_PTR;
-
 /* CON, DAT, PUD, DRV */
 const struct samsung_pin_bank_type bank_type_alive = {
 	.fld_width = { 4, 1, 2, 2, },
@@ -118,8 +115,6 @@ static void exynos_pinctrl_set_pincfg(unsigned long reg_base, u32 pin_num,
 int exynos_pinctrl_set_state(struct udevice *dev, struct udevice *config)
 {
 	struct exynos_pinctrl_priv *priv = dev_get_priv(dev);
-	const void *fdt = gd->fdt_blob;
-	int node = dev_of_offset(config);
 	unsigned int count, idx;
 	unsigned int pinvals[PINCFG_TYPE_NUM];
 
@@ -127,13 +122,13 @@ int exynos_pinctrl_set_state(struct udevice *dev, struct udevice *config)
 	 * refer to the following document for the pinctrl bindings
 	 * linux/Documentation/devicetree/bindings/pinctrl/samsung-pinctrl.txt
 	 */
-	count = fdt_stringlist_count(fdt, node, "samsung,pins");
+	count = dev_read_string_count(config, "samsung,pins");
 	if (count <= 0)
 		return -EINVAL;
 
 	for (idx = 0; idx < PINCFG_TYPE_NUM; ++idx) {
-		pinvals[idx] = fdtdec_get_int(fdt, node,
-					      exynos_pinctrl_props[idx], -1);
+		pinvals[idx] = dev_read_u32_default(config,
+						exynos_pinctrl_props[idx], -1);
 	}
 	pinvals[PINCFG_TYPE_DAT] = -1; /* ignore GPIO data register */
 
@@ -142,12 +137,13 @@ int exynos_pinctrl_set_state(struct udevice *dev, struct udevice *config)
 		unsigned int pin_num;
 		char bank_name[10];
 		unsigned long reg;
-		const char *name;
-		int pincfg;
+		const char *name = NULL;
+		int pincfg, err;
 
-		name = fdt_stringlist_get(fdt, node, "samsung,pins", idx, NULL);
-		if (!name)
+		err = dev_read_string_index(config, "samsung,pins", idx, &name);
+		if (err || !name)
 			continue;
+
 		parse_pin(name, &pin_num, bank_name);
 		bank = get_bank(dev, bank_name);
 		reg = priv->base + bank->offset;
-- 
2.39.2



More information about the U-Boot mailing list