diff mbox series

[3/4] hdata/memory: Remove find_shared()

Message ID 20190219075339.14226-3-oohall@gmail.com
State Accepted
Headers show
Series [1/4] hdata/test: Fix up linux,sml-base property | expand

Checks

Context Check Description
snowpatch_ozlabs/apply_patch success master/apply_patch Successfully applied
snowpatch_ozlabs/snowpatch_job_snowpatch-skiboot fail Test snowpatch/job/snowpatch-skiboot on branch master

Commit Message

Oliver O'Halloran Feb. 19, 2019, 7:53 a.m. UTC
This helper function is used to check if the node we are about to create
already exists. There's no real need for this considering we already
have perfectly functional methods for searching the device-tree, so drop
it in favour of the more standard dt_find_name_addr().

Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
---
 hdata/memory.c | 43 +++----------------------------------------
 1 file changed, 3 insertions(+), 40 deletions(-)

Comments

Vasant Hegde Feb. 22, 2019, 6:55 a.m. UTC | #1
On 02/19/2019 01:23 PM, Oliver O'Halloran wrote:
> This helper function is used to check if the node we are about to create
> already exists. There's no real need for this considering we already
> have perfectly functional methods for searching the device-tree, so drop
> it in favour of the more standard dt_find_name_addr().
> 
> Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
> ---
>   hdata/memory.c | 43 +++----------------------------------------
>   1 file changed, 3 insertions(+), 40 deletions(-)
>

.../...

>   	chip_id = pcid_to_chip_id(be32_to_cpu(arange->chip));
> 
> @@ -144,18 +113,14 @@ static bool add_address_range(struct dt_node *root,
>   	reg[1] = cleanup_addr(be64_to_cpu(arange->end)) - reg[0];
> 
>   	if (be16_to_cpu(id->flags) & MS_AREA_SHARED) {
> -		/* Only enter shared nodes once. */
> -		mem = find_shared(root, be16_to_cpu(id->share_id),
> -				  reg[0], reg[1]);
> +		mem = dt_find_by_name_addr("memory", reg[0]);


This breaks the compilation.. Of course next patch fixes this issue. But this 
hurts during
git-bisect.

-Vasant
diff mbox series

Patch

diff --git a/hdata/memory.c b/hdata/memory.c
index a36337b20e3b..3e6271444ce6 100644
--- a/hdata/memory.c
+++ b/hdata/memory.c
@@ -68,32 +68,6 @@  struct HDIF_ms_area_id {
 	__be16 share_id;
 } __packed;
 
-static struct dt_node *find_shared(struct dt_node *root, u16 id, u64 start, u64 len)
-{
-	struct dt_node *i;
-
-	for (i = dt_first(root); i; i = dt_next(root, i)) {
-		__be64 reg[2];
-		const struct dt_property *shared, *type, *region;
-
-		type = dt_find_property(i, "device_type");
-		if (!type || strcmp(type->prop, "memory") != 0)
-			continue;
-
-		shared = dt_find_property(i, DT_PRIVATE "share-id");
-		if (!shared || fdt32_to_cpu(*(u32 *)shared->prop) != id)
-			continue;
-
-		region = dt_find_property(i, "reg");
-		if (!region)
-			continue;
-		memcpy(reg, region->prop, sizeof(reg));
-		if (be64_to_cpu(reg[0]) == start && be64_to_cpu(reg[1]) == len)
-			break;
-	}
-	return i;
-}
-
 static void append_chip_id(struct dt_node *mem, u32 id)
 {
 	struct dt_property *prop;
@@ -123,13 +97,8 @@  static bool add_address_range(struct dt_node *root,
 			      const struct HDIF_ms_area_address_range *arange)
 {
 	struct dt_node *mem;
+	u32 chip_id, type;
 	u64 reg[2];
-	char *name;
-	u32 chip_id;
-	size_t namesz = sizeof("memory@") + STR_MAX_CHARS(reg[0]);
-
-	name = (char*)malloc(namesz);
-	assert(name);
 
 	chip_id = pcid_to_chip_id(be32_to_cpu(arange->chip));
 
@@ -144,18 +113,14 @@  static bool add_address_range(struct dt_node *root,
 	reg[1] = cleanup_addr(be64_to_cpu(arange->end)) - reg[0];
 
 	if (be16_to_cpu(id->flags) & MS_AREA_SHARED) {
-		/* Only enter shared nodes once. */ 
-		mem = find_shared(root, be16_to_cpu(id->share_id),
-				  reg[0], reg[1]);
+		mem = dt_find_by_name_addr("memory", reg[0]);
 		if (mem) {
 			append_chip_id(mem, chip_id);
-			free(name);
 			return true;
 		}
 	}
-	snprintf(name, namesz, "memory@%llx", (long long)reg[0]);
 
-	mem = dt_new(root, name);
+	mem = dt_new_addr(root, name, reg[0]);
 	dt_add_property_string(mem, "device_type", "memory");
 	dt_add_property_cells(mem, "ibm,chip-id", chip_id);
 	dt_add_property_u64s(mem, "reg", reg[0], reg[1]);
@@ -163,8 +128,6 @@  static bool add_address_range(struct dt_node *root,
 		dt_add_property_cells(mem, DT_PRIVATE "share-id",
 				      be16_to_cpu(id->share_id));
 
-	free(name);
-
 	return true;
 }