[PATCH kvm-unit-tests 01/15] devicetree: improve dt_get_bootargs interface

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Don't lie to callers when bootargs wasn't found, they can check
for themselves. Also document that when a failure occurs @bootargs
will be NULL.

Signed-off-by: Andrew Jones <drjones@xxxxxxxxxx>
---
 lib/devicetree.h    | 5 +++--
 lib/arm/setup.c     | 2 +-
 lib/devicetree.c    | 5 ++---
 lib/powerpc/setup.c | 2 +-
 4 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/lib/devicetree.h b/lib/devicetree.h
index 0083587633d4..9a4d910b6450 100644
--- a/lib/devicetree.h
+++ b/lib/devicetree.h
@@ -202,10 +202,11 @@ extern int dt_get_reg(int fdtnode, int regidx, struct dt_reg *reg);
  **********************************************************************/
 
 /*
- * dt_get_bootargs gets a pointer to /chosen/bootargs
+ * dt_get_bootargs gets the string pointer from /chosen/bootargs
  * returns
  *  - zero on success
- *  - a negative FDT_ERR_* value on failure
+ *  - a negative FDT_ERR_* value on failure, and @bootargs
+ *    will be set to NULL
  */
 extern int dt_get_bootargs(const char **bootargs);
 
diff --git a/lib/arm/setup.c b/lib/arm/setup.c
index 68eae91286d6..dc94d312b262 100644
--- a/lib/arm/setup.c
+++ b/lib/arm/setup.c
@@ -138,6 +138,6 @@ void setup(const void *fdt)
 	io_init();
 
 	ret = dt_get_bootargs(&bootargs);
-	assert(ret == 0);
+	assert(ret == 0 || ret == -FDT_ERR_NOTFOUND);
 	setup_args_progname(bootargs);
 }
diff --git a/lib/devicetree.c b/lib/devicetree.c
index 671c64a2ca51..509649b917cf 100644
--- a/lib/devicetree.c
+++ b/lib/devicetree.c
@@ -256,11 +256,10 @@ int dt_get_bootargs(const char **bootargs)
 		return node;
 
 	prop = fdt_get_property(fdt, node, "bootargs", &len);
-	if (prop)
-		*bootargs = prop->data;
-	else if (len < 0 && len != -FDT_ERR_NOTFOUND)
+	if (!prop)
 		return len;
 
+	*bootargs = prop->data;
 	return 0;
 }
 
diff --git a/lib/powerpc/setup.c b/lib/powerpc/setup.c
index d56de36410c7..00969da8f12c 100644
--- a/lib/powerpc/setup.c
+++ b/lib/powerpc/setup.c
@@ -176,6 +176,6 @@ void setup(const void *fdt)
 	io_init();
 
 	ret = dt_get_bootargs(&bootargs);
-	assert(ret == 0);
+	assert(ret == 0 || ret == -FDT_ERR_NOTFOUND);
 	setup_args_progname(bootargs);
 }
-- 
2.9.3

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux