lkml.org 
[lkml]   [2024]   [Mar]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH] iio: adc: ad7944: simplify adi,spi-mode property parsing
On Mon, Mar 18, 2024 at 11:57 PM David Lechner <dlechner@baylibre.com> wrote:
>
> This simplifies the adi,spi-mode property parsing by using
> device_property_match_property_string() instead of two separate
> functions. Also, the error return value is now more informative
> in cases where there was problem parsing the property.

a problem

..

> + ret = device_property_match_property_string(dev, "adi,spi-mode",
> + ad7944_spi_modes,
> + ARRAY_SIZE(ad7944_spi_modes));
> + if (ret < 0) {
> /* absence of adi,spi-mode property means default mode */
> - adc->spi_mode = AD7944_SPI_MODE_DEFAULT;
> + if (ret == -EINVAL)
> + adc->spi_mode = AD7944_SPI_MODE_DEFAULT;
> + else
> + return dev_err_probe(dev, ret,
> + "getting adi,spi-mode property failed\n");

No need to have 'else'

if (ret != -EINVAL)
return dev_err_probe(dev, ret, "getting
adi,spi-mode property failed\n");

/* absence of adi,spi-mode property means default mode */
adc->spi_mode = AD7944_SPI_MODE_DEFAULT;

> + } else {
> + adc->spi_mode = ret;
> }

--
With Best Regards,
Andy Shevchenko

\
 
 \ /
  Last update: 2024-05-27 15:53    [W:0.035 / U:2.308 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site