From 15e6a319c990872ded77f5297e607fe01bf39857 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Mon, 15 Nov 2021 19:52:29 +0800 Subject: [PATCH] iio: core: Allow drivers to specify a label without it coming from of mainline inclusion from mainline-v5.13-rc1 commit 6f71bf1991b6f04dc87a4f5b9d6823535f51a50d category: bugfix bugzilla: 185695 https://gitee.com/openeuler/kernel/issues/I4DDEL Only set indio_dev->label from of/dt if there actually is a label specified in of. This allows drivers to set a label without this being overwritten with NULL when there is no label specified in of. This is esp. useful on devices where of is not used at all, such as your typical x86/ACPI device. Signed-off-by: Hans de Goede Reviewed-by: Alexandru Ardelean Link: https://lore.kernel.org/r/20210207160901.110643-2-hdegoede@redhat.com Signed-off-by: Jonathan Cameron Signed-off-by: tanghui Reviewed-by: Zhang Qiao Reviewed-by: Chen Hui Signed-off-by: Chen Jun Signed-off-by: Zheng Zengkai --- drivers/iio/industrialio-core.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c index 261d3b17edc9..ea98aad9fb81 100644 --- a/drivers/iio/industrialio-core.c +++ b/drivers/iio/industrialio-core.c @@ -1720,6 +1720,7 @@ static const struct iio_buffer_setup_ops noop_ring_setup_ops; int __iio_device_register(struct iio_dev *indio_dev, struct module *this_mod) { + const char *label; int ret; if (!indio_dev->info) @@ -1730,8 +1731,9 @@ int __iio_device_register(struct iio_dev *indio_dev, struct module *this_mod) if (!indio_dev->dev.of_node && indio_dev->dev.parent) indio_dev->dev.of_node = indio_dev->dev.parent->of_node; - indio_dev->label = of_get_property(indio_dev->dev.of_node, "label", - NULL); + label = of_get_property(indio_dev->dev.of_node, "label", NULL); + if (label) + indio_dev->label = label; ret = iio_check_unique_scan_index(indio_dev); if (ret < 0) -- GitLab