Re: [PATCH 1/3] iio: core: Allow drivers to specify a label without it coming from of

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

 



On Sun, Feb 7, 2021 at 6:11 PM Hans de Goede <hdegoede@xxxxxxxxxx> wrote:
>
> 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.

Reviewed-by: Alexandru Ardelean <alexandru.ardelean@xxxxxxxxxx>


>
> Signed-off-by: Hans de Goede <hdegoede@xxxxxxxxxx>
> ---
>  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 e9ee9363fed0..b409e076818b 100644
> --- a/drivers/iio/industrialio-core.c
> +++ b/drivers/iio/industrialio-core.c
> @@ -1755,6 +1755,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)
> @@ -1765,8 +1766,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)
> --
> 2.30.0
>



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux