提交 15e6a319 编写于 作者: H Hans de Goede 提交者: Zheng Zengkai

iio: core: Allow drivers to specify a label without it coming from of

mainline inclusion
from mainline-v5.13-rc1
commit 6f71bf19
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: NHans de Goede <hdegoede@redhat.com>
Reviewed-by: NAlexandru Ardelean <alexandru.ardelean@analog.com>
Link: https://lore.kernel.org/r/20210207160901.110643-2-hdegoede@redhat.comSigned-off-by: NJonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Ntanghui <tanghui20@huawei.com>
Reviewed-by: NZhang Qiao <zhangqiao22@huawei.com>
Reviewed-by: NChen Hui <judy.chenhui@huawei.com>
Signed-off-by: NChen Jun <chenjun102@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 38e79e67
...@@ -1720,6 +1720,7 @@ static const struct iio_buffer_setup_ops noop_ring_setup_ops; ...@@ -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) int __iio_device_register(struct iio_dev *indio_dev, struct module *this_mod)
{ {
const char *label;
int ret; int ret;
if (!indio_dev->info) if (!indio_dev->info)
...@@ -1730,8 +1731,9 @@ int __iio_device_register(struct iio_dev *indio_dev, struct module *this_mod) ...@@ -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) if (!indio_dev->dev.of_node && indio_dev->dev.parent)
indio_dev->dev.of_node = indio_dev->dev.parent->of_node; indio_dev->dev.of_node = indio_dev->dev.parent->of_node;
indio_dev->label = of_get_property(indio_dev->dev.of_node, "label", label = of_get_property(indio_dev->dev.of_node, "label", NULL);
NULL); if (label)
indio_dev->label = label;
ret = iio_check_unique_scan_index(indio_dev); ret = iio_check_unique_scan_index(indio_dev);
if (ret < 0) if (ret < 0)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册