From: Jonathan Cameron <jic23@kernel.org>
To: Nuno Sa via B4 Relay <devnull+nuno.sa.analog.com@kernel.org>
Cc: <nuno.sa@analog.com>,
linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
Lars-Peter Clausen <lars@metafoo.de>,
Michael Hennerich <Michael.Hennerich@analog.com>,
Rob Herring <robh+dt@kernel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
Conor Dooley <conor+dt@kernel.org>
Subject: Re: [PATCH v3 1/3] iio: temperature: ltc2983: convert to dev_err_probe()
Date: Sun, 3 Mar 2024 12:16:53 +0000 [thread overview]
Message-ID: <20240303121653.22f115c1@jic23-huawei> (raw)
In-Reply-To: <20240301-ltc2983-misc-improv-v3-1-c09516ac0efc@analog.com>
On Fri, 01 Mar 2024 18:14:50 +0100
Nuno Sa via B4 Relay <devnull+nuno.sa.analog.com@kernel.org> wrote:
> From: Nuno Sa <nuno.sa@analog.com>
>
> Use dev_err_probe() in the probe() path. While at it, made some simple
> improvements:
> * Declare a struct device *dev helper. This also makes the style more
> consistent (some places the helper was used and not in other places);
> * Explicitly included the err.h and errno.h headers;
> * Removed an useless else if();
> * Removed some unnecessary line breaks.
>
> Signed-off-by: Nuno Sa <nuno.sa@analog.com>
I'd rather see a proposal for dev_errp_probe() than a local solution.
We can fallback to local solution if it doesn't meet with approval!
Not that many uses in IIO so far, but seems some potential elsewhere.
There are already a few return ERR_PTR(dev_err_probe()) cases in tree
for low hanging fruit + looks like scmi_iio could benefit as another case
in IIO.
> ---
> drivers/iio/temperature/ltc2983.c | 262 ++++++++++++++++++--------------------
> 1 file changed, 122 insertions(+), 140 deletions(-)
>
> diff --git a/drivers/iio/temperature/ltc2983.c b/drivers/iio/temperature/ltc2983.c
> index 3c4524d57b8e..592887097117 100644
> --- a/drivers/iio/temperature/ltc2983.c
> +++ b/drivers/iio/temperature/ltc2983.c
> @@ -8,6 +8,8 @@
> #include <linux/bitfield.h>
> #include <linux/completion.h>
> #include <linux/device.h>
> +#include <linux/err.h>
> +#include <linux/errno.h>
> #include <linux/kernel.h>
> #include <linux/iio/iio.h>
> #include <linux/interrupt.h>
> @@ -206,6 +208,13 @@ enum {
> #define to_temp(_sensor) \
> container_of(_sensor, struct ltc2983_temp, sensor)
>
> +/* Helper macro for returning error pointers in probe() paths. */
> +#define ltc2983_errp_probe(dev, ret, fmt, ...) ({ \
> + int ___ret = dev_err_probe(dev, ret, fmt, ##__VA_ARGS__); \
> + \
> + ERR_PTR(___ret); \
Given it's all wrapped up in a macro, I'd avoid the need for the ___ to try
and prevent shadowing an existing variable by just going with
ERR_PTR(dev_err_probe(dev, ret, fmt, ##__VA_ARGS__))
and no ({ complexities.
If you really need to use a local variable, just through the hoops to make it unique
like the cleanup.h macros do.
> +})
> +
next prev parent reply other threads:[~2024-03-03 12:17 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-01 17:14 [PATCH v3 0/3] iio: temperature: ltc2983: small improvements Nuno Sa via B4 Relay
2024-03-01 17:14 ` [PATCH v3 1/3] iio: temperature: ltc2983: convert to dev_err_probe() Nuno Sa via B4 Relay
2024-03-03 12:16 ` Jonathan Cameron [this message]
2024-03-04 7:54 ` Nuno Sá
2024-03-01 17:14 ` [PATCH v3 2/3] dt-bindings: iio: temperature: ltc2983: document power supply Nuno Sa via B4 Relay
2024-03-04 10:22 ` Krzysztof Kozlowski
2024-03-01 17:14 ` [PATCH v3 3/3] iio: temperature: ltc2983: support vdd regulator Nuno Sa via B4 Relay
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=20240303121653.22f115c1@jic23-huawei \
--to=jic23@kernel.org \
--cc=Michael.Hennerich@analog.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=devnull+nuno.sa.analog.com@kernel.org \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=nuno.sa@analog.com \
--cc=robh+dt@kernel.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