Linux-IIO Archive mirror
 help / color / mirror / Atom feed
From: David Lechner <dlechner@baylibre.com>
To: Andy Shevchenko <andy.shevchenko@gmail.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: Mon, 18 Mar 2024 17:48:39 -0500	[thread overview]
Message-ID: <3eeda38b-0bfa-4b46-8088-303f78b5f340@baylibre.com> (raw)
In-Reply-To: <CAHp75VfKZy45RVJmAAOEPyUFTW7MhxJmOeQHj3YV7p-NPKpkvg@mail.gmail.com>

On 3/18/24 5:43 PM, Andy Shevchenko wrote:
> 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;
>>         }
> 

I agree it is better that way. Will send a v2.

      reply	other threads:[~2024-03-18 22:48 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
2024-03-18 22:48   ` David Lechner [this message]

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=3eeda38b-0bfa-4b46-8088-303f78b5f340@baylibre.com \
    --to=dlechner@baylibre.com \
    --cc=andy.shevchenko@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).