From: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
To: Jonathan Cameron <jic23@kernel.org>,
Marcus Folkesson <marcus.folkesson@gmail.com>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Kent Gustavsson <kent@minoris.se>,
Lars-Peter Clausen <lars@metafoo.de>,
Rob Herring <robh+dt@kernel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
Conor Dooley <conor+dt@kernel.org>,
Cosmin Tanislav <demonsingur@gmail.com>,
Arnd Bergmann <arnd@arndb.de>,
ChiYuan Huang <cy_huang@richtek.com>,
Haibo Chen <haibo.chen@nxp.com>,
Ramona Bolboaca <ramona.bolboaca@analog.com>,
Ibrahim Tilki <Ibrahim.Tilki@analog.com>,
ChiaEn Wu <chiaen_wu@richtek.com>,
William Breathitt Gray <william.gray@linaro.org>,
linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 4/4] iio: adc: mcp3911: add support for the whole MCP39xx family
Date: Wed, 9 Aug 2023 20:14:54 +0200 [thread overview]
Message-ID: <3939bd56-d57d-173e-da78-297ce607f9bc@linaro.org> (raw)
In-Reply-To: <20230809190257.67602e55@jic23-huawei>
On 09/08/2023 20:02, Jonathan Cameron wrote:
> On Wed, 9 Aug 2023 08:41:05 +0200
> Marcus Folkesson <marcus.folkesson@gmail.com> wrote:
>
>>> ...
>>>
>>>> +#define MCP3910_OFFCAL(x) (MCP3910_REG_OFFCAL_CH0 + x * 6)
>>>
>>> Inconsistent macro implementation, i.e. you need to use (x).
>>
>> Sorry, I do not get you
>>
>>
>> [...]
>>
>>>> +static int mcp3910_get_osr(struct mcp3911 *adc, int *val)
>>>> +{
>>>> + int ret, osr;
>>>
>>> Strictly speaking osr can't be negative, otherwise it's a UB below.
>>>
>>> u32 osr = FIELD_GET(MCP3910_CONFIG0_OSR, *val);
>>> int ret;
>>>
>>> and why val is int?
>>
>> I will change val to u32 for *_get_osr(), *_set_osr() and *_set_scale().
>>
>> [...]
>>
>>>> + if (device_property_read_bool(&adc->spi->dev, "microchip,data-ready-hiz"))
>>>
>>> This also becomes shorter.
>>>
>>> One trick to make it even shorter:
>>>
>>> if (device_property_present(dev, "microchip,data-ready-hiz"))
>>
>> Thank you, I wasn't aware of device_property_present().
>
> I know the read_bool function is direct equivalent of this but where a property
> is a flag, it feels more natural to me to check it with that one.
> read_present() feels more appropriate for where you want to know a more
> complex property is present.
>
> Doesn't matter that much either way however so up to you.
For the OF, of_property_read_bool() is indeed preferred. Is there
device-xxx() equivalent?
Best regards,
Krzysztof
next prev parent reply other threads:[~2023-08-09 18:15 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-08 11:04 [PATCH v4 1/4] dt-bindings: iio: adc: mcp3911: add support for the whole MCP39xx family Marcus Folkesson
2023-08-08 11:04 ` [PATCH v4 2/4] iio: adc: mcp3911: simplify usage of spi->dev in probe function Marcus Folkesson
2023-08-08 14:08 ` Andy Shevchenko
2023-08-08 11:04 ` [PATCH v4 3/4] iio: adc: mcp3911: fix indentation Marcus Folkesson
2023-08-08 14:13 ` Andy Shevchenko
2023-08-08 11:04 ` [PATCH v4 4/4] iio: adc: mcp3911: add support for the whole MCP39xx family Marcus Folkesson
2023-08-08 14:23 ` Andy Shevchenko
2023-08-09 6:41 ` Marcus Folkesson
2023-08-09 18:02 ` Jonathan Cameron
2023-08-09 18:14 ` Krzysztof Kozlowski [this message]
2023-08-10 13:44 ` Andy Shevchenko
2023-08-10 14:31 ` Marcus Folkesson
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=3939bd56-d57d-173e-da78-297ce607f9bc@linaro.org \
--to=krzysztof.kozlowski@linaro.org \
--cc=Ibrahim.Tilki@analog.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=arnd@arndb.de \
--cc=chiaen_wu@richtek.com \
--cc=conor+dt@kernel.org \
--cc=cy_huang@richtek.com \
--cc=demonsingur@gmail.com \
--cc=devicetree@vger.kernel.org \
--cc=haibo.chen@nxp.com \
--cc=jic23@kernel.org \
--cc=kent@minoris.se \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marcus.folkesson@gmail.com \
--cc=ramona.bolboaca@analog.com \
--cc=robh+dt@kernel.org \
--cc=william.gray@linaro.org \
/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