diff mbox series

[1/4] dev_printk: add new dev_errp_probe() helper

Message ID 20240404-dev-add_dev_errp_probe-v1-1-d18e3eb7ec3f@analog.com (mailing list archive)
State Changes Requested
Headers show
Series dev_printk: add dev_errp_probe() helper | expand

Commit Message

Nuno Sa April 4, 2024, 11:06 a.m. UTC
This is similar to dev_err_probe() but for cases where an ERR_PTR() is
to be returned simplifying patterns like:

	dev_err_probe(dev, ret, ...);
	return ERR_PTR(ret)

Signed-off-by: Nuno Sa <nuno.sa@analog.com>
---
 include/linux/dev_printk.h | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Andi Shyti April 6, 2024, 6:35 p.m. UTC | #1
Hi Nuno,

...

> +/* Simple helper for dev_err_probe() when ERR_PTR() is to be returned. */
> +#define dev_errp_probe(dev, ___err, fmt, ...)	({		\
> +	ERR_PTR(dev_err_probe(dev, ___err, fmt, ##__VA_ARGS__));	\
> +})

I have a whole series adding a set of error oriente printk's. But
for the time being this looks OK.

I just don't like the name, the 'p' is an important detail, but
a bit hidden... how about dev_err_ptr_probe(...)?

Andi
Nuno Sá April 8, 2024, 8:57 a.m. UTC | #2
On Sat, 2024-04-06 at 20:35 +0200, Andi Shyti wrote:
> Hi Nuno,
> 
> ...
> 
> > +/* Simple helper for dev_err_probe() when ERR_PTR() is to be returned. */
> > +#define dev_errp_probe(dev, ___err, fmt, ...)	({		\
> > +	ERR_PTR(dev_err_probe(dev, ___err, fmt, ##__VA_ARGS__));	\
> > +})
> 
> I have a whole series adding a set of error oriente printk's. But
> for the time being this looks OK.
> 
> I just don't like the name, the 'p' is an important detail, but
> a bit hidden... how about dev_err_ptr_probe(...)?
> 

Agreed, not a very good name indeed.

- Nuno Sá
diff mbox series

Patch

diff --git a/include/linux/dev_printk.h b/include/linux/dev_printk.h
index ae80a303c216..790144f6f99c 100644
--- a/include/linux/dev_printk.h
+++ b/include/linux/dev_printk.h
@@ -277,4 +277,9 @@  do {									\
 
 __printf(3, 4) int dev_err_probe(const struct device *dev, int err, const char *fmt, ...);
 
+/* Simple helper for dev_err_probe() when ERR_PTR() is to be returned. */
+#define dev_errp_probe(dev, ___err, fmt, ...)	({		\
+	ERR_PTR(dev_err_probe(dev, ___err, fmt, ##__VA_ARGS__));	\
+})
+
 #endif /* _DEVICE_PRINTK_H_ */