All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andy.shevchenko@gmail.com>
To: David Lechner <dlechner@baylibre.com>
Cc: "Jonathan Cameron" <jic23@kernel.org>,
	"Michael Hennerich" <michael.hennerich@analog.com>,
	"Nuno Sá" <nuno.sa@analog.com>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] iio: adc: ad7944: simplify adi,spi-mode property parsing
Date: Tue, 19 Mar 2024 00:43:24 +0200	[thread overview]
Message-ID: <CAHp75VfKZy45RVJmAAOEPyUFTW7MhxJmOeQHj3YV7p-NPKpkvg@mail.gmail.com> (raw)
In-Reply-To: <20240318-ad7944-cleanups-v1-1-0cbb0349a14f@baylibre.com>

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

  reply	other threads:[~2024-03-18 22:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-18 21:56 [PATCH] iio: adc: ad7944: simplify adi,spi-mode property parsing David Lechner
2024-03-18 22:43 ` Andy Shevchenko [this message]
2024-03-18 22:48   ` David Lechner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAHp75VfKZy45RVJmAAOEPyUFTW7MhxJmOeQHj3YV7p-NPKpkvg@mail.gmail.com \
    --to=andy.shevchenko@gmail.com \
    --cc=dlechner@baylibre.com \
    --cc=jic23@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michael.hennerich@analog.com \
    --cc=nuno.sa@analog.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.