From: "Marek Behún" <kabel@kernel.org>
To: Stefan Roese <sr@denx.de>
Cc: u-boot@lists.denx.de, "Pali Rohár" <pali@kernel.org>,
"Marek Behún" <marek.behun@nic.cz>
Subject: [PATCH u-boot-marvell 03/11] fdt_support: Remove fdt_alloc_phandle() in favor of fdt_generate_phandle()
Date: Wed, 3 Nov 2021 03:02:36 +0100 [thread overview]
Message-ID: <20211103020244.25428-4-kabel@kernel.org> (raw)
In-Reply-To: <20211103020244.25428-1-kabel@kernel.org>
From: Marek Behún <marek.behun@nic.cz>
Commit f0921f5098d ("fdt: Sync up to the latest libfdt") introduced
fdt_generate_phandle() in libfdt, making fdt_alloc_phandle() obsolete in
fdt_support.
Signed-off-by: Marek Behún <marek.behun@nic.cz>
---
board/freescale/lx2160a/eth_lx2160aqds.c | 8 +++++--
board/freescale/lx2160a/eth_lx2162aqds.c | 8 +++++--
common/fdt_support.c | 28 +++++++-----------------
include/fdt_support.h | 1 -
4 files changed, 20 insertions(+), 25 deletions(-)
diff --git a/board/freescale/lx2160a/eth_lx2160aqds.c b/board/freescale/lx2160a/eth_lx2160aqds.c
index a2b6442b54..1819b27561 100644
--- a/board/freescale/lx2160a/eth_lx2160aqds.c
+++ b/board/freescale/lx2160a/eth_lx2160aqds.c
@@ -775,10 +775,11 @@ int fdt_fixup_board_phy(void *fdt)
int fpga_offset, offset, subnodeoffset;
struct mii_dev *mii_dev;
struct list_head *mii_devs, *entry;
- int ret, dpmac_id, phandle, i;
+ int ret, dpmac_id, i;
struct phy_device *phy_dev;
char ethname[ETH_NAME_LEN];
phy_interface_t phy_iface;
+ uint32_t phandle;
ret = 0;
/* we know FPGA is connected to i2c0, therefore search path directly,
@@ -794,7 +795,10 @@ int fdt_fixup_board_phy(void *fdt)
return fpga_offset;
}
- phandle = fdt_alloc_phandle(fdt);
+ ret = fdt_generate_phandle(fdt, &phandle);
+ if (ret < 0)
+ return ret;
+
mii_devs = mdio_get_list_head();
list_for_each(entry, mii_devs) {
diff --git a/board/freescale/lx2160a/eth_lx2162aqds.c b/board/freescale/lx2160a/eth_lx2162aqds.c
index 3b04dea39c..ac6218ebe4 100644
--- a/board/freescale/lx2160a/eth_lx2162aqds.c
+++ b/board/freescale/lx2160a/eth_lx2162aqds.c
@@ -787,10 +787,11 @@ int fdt_fixup_board_phy(void *fdt)
int fpga_offset, offset, subnodeoffset;
struct mii_dev *mii_dev;
struct list_head *mii_devs, *entry;
- int ret, dpmac_id, phandle, i;
+ int ret, dpmac_id, i;
struct phy_device *phy_dev;
char ethname[ETH_NAME_LEN];
phy_interface_t phy_iface;
+ uint32_t phandle;
ret = 0;
/* we know FPGA is connected to i2c0, therefore search path directly,
@@ -806,7 +807,10 @@ int fdt_fixup_board_phy(void *fdt)
return fpga_offset;
}
- phandle = fdt_alloc_phandle(fdt);
+ ret = fdt_generate_phandle(fdt, &phandle);
+ if (ret < 0)
+ return ret;
+
mii_devs = mdio_get_list_head();
list_for_each(entry, mii_devs) {
diff --git a/common/fdt_support.c b/common/fdt_support.c
index 8992ac5d3f..be03a87d42 100644
--- a/common/fdt_support.c
+++ b/common/fdt_support.c
@@ -1463,24 +1463,6 @@ int fdt_node_offset_by_compat_reg(void *blob, const char *compat,
return -FDT_ERR_NOTFOUND;
}
-/**
- * fdt_alloc_phandle: Return next free phandle value
- *
- * @blob: ptr to device tree
- */
-int fdt_alloc_phandle(void *blob)
-{
- int offset;
- uint32_t phandle = 0;
-
- for (offset = fdt_next_node(blob, -1, NULL); offset >= 0;
- offset = fdt_next_node(blob, offset, NULL)) {
- phandle = max(phandle, fdt_get_phandle(blob, offset));
- }
-
- return phandle + 1;
-}
-
/*
* fdt_set_phandle: Create a phandle property for the given node
*
@@ -1530,13 +1512,19 @@ int fdt_set_phandle(void *fdt, int nodeoffset, uint32_t phandle)
unsigned int fdt_create_phandle(void *fdt, int nodeoffset)
{
/* see if there is a phandle already */
- int phandle = fdt_get_phandle(fdt, nodeoffset);
+ uint32_t phandle = fdt_get_phandle(fdt, nodeoffset);
/* if we got 0, means no phandle so create one */
if (phandle == 0) {
int ret;
- phandle = fdt_alloc_phandle(fdt);
+ ret = fdt_generate_phandle(fdt, &phandle);
+ if (ret < 0) {
+ printf("Can't generate phandle: %s\n",
+ fdt_strerror(ret));
+ return 0;
+ }
+
ret = fdt_set_phandle(fdt, nodeoffset, phandle);
if (ret < 0) {
printf("Can't set phandle %u: %s\n", phandle,
diff --git a/include/fdt_support.h b/include/fdt_support.h
index 88d129c803..90f5a4c28c 100644
--- a/include/fdt_support.h
+++ b/include/fdt_support.h
@@ -285,7 +285,6 @@ int fdt_get_dma_range(const void *blob, int node_offset, phys_addr_t *cpu,
int fdt_node_offset_by_compat_reg(void *blob, const char *compat,
phys_addr_t compat_off);
-int fdt_alloc_phandle(void *blob);
int fdt_set_phandle(void *fdt, int nodeoffset, uint32_t phandle);
unsigned int fdt_create_phandle(void *fdt, int nodeoffset);
int fdt_add_edid(void *blob, const char *compat, unsigned char *buf);
--
2.32.0
next prev parent reply other threads:[~2021-11-03 2:03 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-03 2:02 [PATCH u-boot-marvell 00/11] Some mvebu comphy + mox + fdt_support changes Marek Behún
2021-11-03 2:02 ` [PATCH u-boot-marvell 01/11] include/linux/byteorder: Fix compilation of __constant_cpu_to_be32() Marek Behún
2021-11-12 12:40 ` Stefan Roese
2021-11-03 2:02 ` [PATCH u-boot-marvell 02/11] treewide: Use fdt_create_phandle() where appropriate Marek Behún
2021-11-12 12:40 ` Stefan Roese
2021-11-03 2:02 ` Marek Behún [this message]
2021-11-12 12:42 ` [PATCH u-boot-marvell 03/11] fdt_support: Remove fdt_alloc_phandle() in favor of fdt_generate_phandle() Stefan Roese
2021-11-12 17:26 ` Marek Behún
2021-11-03 2:02 ` [PATCH u-boot-marvell 04/11] fdt_support: Remove FDT_STATUS_FAIL_ERROR_CODE Marek Behún
2021-11-12 12:43 ` Stefan Roese
2021-11-03 2:02 ` [PATCH u-boot-marvell 05/11] fdt_support: Fix comment for fdt_create_phandle() Marek Behún
2021-11-12 12:44 ` Stefan Roese
2021-11-03 2:02 ` [PATCH u-boot-marvell 06/11] fdt_support: Add some useful functions Marek Behún
2021-11-12 13:14 ` Stefan Roese
2021-11-03 2:02 ` [PATCH u-boot-marvell 07/11] arm: mvebu: turris_mox: Find DT nodes by compatible or alias instead of path Marek Behún
2021-11-12 13:15 ` Stefan Roese
2021-11-03 2:02 ` [PATCH u-boot-marvell 08/11] arm: mvebu: turris_mox: Enable eth1 in U-Boot if a network module is present Marek Behún
2021-11-12 13:16 ` Stefan Roese
2021-11-03 2:02 ` [PATCH u-boot-marvell 09/11] phy: marvell: a3700: Convert to official DT bindings in COMPHY driver Marek Behún
2021-11-12 13:29 ` Stefan Roese
2021-11-12 17:27 ` Marek Behún
2021-11-15 6:47 ` Stefan Roese
2021-11-03 2:02 ` [PATCH u-boot-marvell 10/11] arm: mvebu: turris_mox: Fix unstable board topology reading Marek Behún
2021-11-12 13:30 ` Stefan Roese
2021-11-03 2:02 ` [PATCH u-boot-marvell 11/11] fdt_support: Add fdt_delete_disabled_nodes() and use in Turris MOX Marek Behún
2021-11-12 13:31 ` Stefan Roese
2021-11-11 15:36 ` [PATCH u-boot-marvell 00/11] Some mvebu comphy + mox + fdt_support changes Marek Behún
2021-11-12 9:49 ` 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=20211103020244.25428-4-kabel@kernel.org \
--to=kabel@kernel.org \
--cc=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