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 |
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
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 --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_ */
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(+)