diff mbox series

[v3,04/13] software node: simplify property_get_pointer()

Message ID 20190909081557.93766-5-dmitry.torokhov@gmail.com (mailing list archive)
State Deferred, archived
Headers show
Series software node: add support for reference properties | expand

Commit Message

Dmitry Torokhov Sept. 9, 2019, 8:15 a.m. UTC
We do not need to handle each data type separately, we can simply return either
the raw pointer or pointer to values union.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 drivers/base/swnode.c | 29 ++++++-----------------------
 1 file changed, 6 insertions(+), 23 deletions(-)
diff mbox series

Patch

diff --git a/drivers/base/swnode.c b/drivers/base/swnode.c
index a8d12046105e..bedc26189bed 100644
--- a/drivers/base/swnode.c
+++ b/drivers/base/swnode.c
@@ -105,30 +105,13 @@  property_entry_get(const struct property_entry *prop, const char *name)
 
 static const void *property_get_pointer(const struct property_entry *prop)
 {
-	switch (prop->type) {
-	case DEV_PROP_U8:
-		if (prop->is_array)
-			return prop->pointer.u8_data;
-		return &prop->value.u8_data;
-	case DEV_PROP_U16:
-		if (prop->is_array)
-			return prop->pointer.u16_data;
-		return &prop->value.u16_data;
-	case DEV_PROP_U32:
-		if (prop->is_array)
-			return prop->pointer.u32_data;
-		return &prop->value.u32_data;
-	case DEV_PROP_U64:
-		if (prop->is_array)
-			return prop->pointer.u64_data;
-		return &prop->value.u64_data;
-	case DEV_PROP_STRING:
-		if (prop->is_array)
-			return prop->pointer.str;
-		return &prop->value.str;
-	default:
+	if (!prop->length)
 		return NULL;
-	}
+
+	if (prop->is_array)
+		return prop->pointer.raw;
+
+	return &prop->value;
 }
 
 static const void *property_entry_find(const struct property_entry *props,