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@xxxxxxxxx> --- drivers/base/swnode.c | 29 ++++++----------------------- 1 file changed, 6 insertions(+), 23 deletions(-) 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, -- 2.23.0.187.g17f5b7556c-goog