diff mbox series

[v3,1/4] dev_printk: add new dev_err_probe() helpers

Message ID 20240606-dev-add_dev_errp_probe-v3-1-51bb229edd79@analog.com (mailing list archive)
State Accepted
Headers show
Series dev_printk: add dev_errp_probe() helper | expand

Commit Message

Nuno Sá June 6, 2024, 7:22 a.m. UTC
This is similar to dev_err_probe() but for cases where an ERR_PTR() or
ERR_CAST() is to be returned simplifying patterns like:

	dev_err_probe(dev, ret, ...);
	return ERR_PTR(ret)
or
	dev_err_probe(dev, PTR_ERR(ptr), ...);
	return ERR_CAST(ptr)

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

Comments

Jonathan Cameron June 8, 2024, 6:07 p.m. UTC | #1
On Thu, 6 Jun 2024 09:22:37 +0200
Nuno Sa <nuno.sa@analog.com> wrote:

> This is similar to dev_err_probe() but for cases where an ERR_PTR() or
> ERR_CAST() is to be returned simplifying patterns like:
> 
> 	dev_err_probe(dev, ret, ...);
> 	return ERR_PTR(ret)
> or
> 	dev_err_probe(dev, PTR_ERR(ptr), ...);
> 	return ERR_CAST(ptr)
> 
> Signed-off-by: Nuno Sa <nuno.sa@analog.com>

I'm convinced this is worth doing but would like inputs from others
before I pick this series up.

Jonathan

> ---
>  include/linux/dev_printk.h | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/include/linux/dev_printk.h b/include/linux/dev_printk.h
> index ae80a303c216..ca32b5bb28eb 100644
> --- a/include/linux/dev_printk.h
> +++ b/include/linux/dev_printk.h
> @@ -277,4 +277,12 @@ 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_err_ptr_probe(dev, ___err, fmt, ...) \
> +	ERR_PTR(dev_err_probe(dev, ___err, fmt, ##__VA_ARGS__))
> +
> +/* Simple helper for dev_err_probe() when ERR_CAST() is to be returned. */
> +#define dev_err_cast_probe(dev, ___err_ptr, fmt, ...) \
> +	ERR_PTR(dev_err_probe(dev, PTR_ERR(___err_ptr), fmt, ##__VA_ARGS__))
> +
>  #endif /* _DEVICE_PRINTK_H_ */
>
Jonathan Cameron June 17, 2024, 7:41 p.m. UTC | #2
On Sat, 8 Jun 2024 19:07:48 +0100
Jonathan Cameron <jic23@kernel.org> wrote:

> On Thu, 6 Jun 2024 09:22:37 +0200
> Nuno Sa <nuno.sa@analog.com> wrote:
> 
> > This is similar to dev_err_probe() but for cases where an ERR_PTR() or
> > ERR_CAST() is to be returned simplifying patterns like:
> > 
> > 	dev_err_probe(dev, ret, ...);
> > 	return ERR_PTR(ret)
> > or
> > 	dev_err_probe(dev, PTR_ERR(ptr), ...);
> > 	return ERR_CAST(ptr)
> > 
> > Signed-off-by: Nuno Sa <nuno.sa@analog.com>  
> 
> I'm convinced this is worth doing but would like inputs from others
> before I pick this series up.

Andi and Andy,

You both commented on earlier versions.  Do you think this is a good
change set?

I've +CC a few more based on a quick look at the original
dev_err_probe() series. Whilst this isn't adding a bunch of new stuff
around deferred probing (like that series did), maybe some of those
reviewers will give opinions here?

Jonathan



> 
> Jonathan
> 
> > ---
> >  include/linux/dev_printk.h | 8 ++++++++
> >  1 file changed, 8 insertions(+)
> > 
> > diff --git a/include/linux/dev_printk.h b/include/linux/dev_printk.h
> > index ae80a303c216..ca32b5bb28eb 100644
> > --- a/include/linux/dev_printk.h
> > +++ b/include/linux/dev_printk.h
> > @@ -277,4 +277,12 @@ 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_err_ptr_probe(dev, ___err, fmt, ...) \
> > +	ERR_PTR(dev_err_probe(dev, ___err, fmt, ##__VA_ARGS__))
> > +
> > +/* Simple helper for dev_err_probe() when ERR_CAST() is to be returned. */
> > +#define dev_err_cast_probe(dev, ___err_ptr, fmt, ...) \
> > +	ERR_PTR(dev_err_probe(dev, PTR_ERR(___err_ptr), fmt, ##__VA_ARGS__))
> > +
> >  #endif /* _DEVICE_PRINTK_H_ */
> >   
> 
>
Nuno Sá June 26, 2024, 3:01 p.m. UTC | #3
On Mon, 2024-06-17 at 20:41 +0100, Jonathan Cameron wrote:
> On Sat, 8 Jun 2024 19:07:48 +0100
> Jonathan Cameron <jic23@kernel.org> wrote:
> 
> > On Thu, 6 Jun 2024 09:22:37 +0200
> > Nuno Sa <nuno.sa@analog.com> wrote:
> > 
> > > This is similar to dev_err_probe() but for cases where an ERR_PTR() or
> > > ERR_CAST() is to be returned simplifying patterns like:
> > > 
> > > 	dev_err_probe(dev, ret, ...);
> > > 	return ERR_PTR(ret)
> > > or
> > > 	dev_err_probe(dev, PTR_ERR(ptr), ...);
> > > 	return ERR_CAST(ptr)
> > > 
> > > Signed-off-by: Nuno Sa <nuno.sa@analog.com>  
> > 
> > I'm convinced this is worth doing but would like inputs from others
> > before I pick this series up.
> 
> Andi and Andy,
> 
> You both commented on earlier versions.  Do you think this is a good
> change set?
> 
> I've +CC a few more based on a quick look at the original
> dev_err_probe() series. Whilst this isn't adding a bunch of new stuff
> around deferred probing (like that series did), maybe some of those
> reviewers will give opinions here?
> 

Hi,

I there something else needed from my side? Would be nice to have some
feedback...

- Nuno Sá
Jonathan Cameron June 30, 2024, 11:29 a.m. UTC | #4
On Wed, 26 Jun 2024 17:01:03 +0200
Nuno Sá <noname.nuno@gmail.com> wrote:

> On Mon, 2024-06-17 at 20:41 +0100, Jonathan Cameron wrote:
> > On Sat, 8 Jun 2024 19:07:48 +0100
> > Jonathan Cameron <jic23@kernel.org> wrote:
> >   
> > > On Thu, 6 Jun 2024 09:22:37 +0200
> > > Nuno Sa <nuno.sa@analog.com> wrote:
> > >   
> > > > This is similar to dev_err_probe() but for cases where an ERR_PTR() or
> > > > ERR_CAST() is to be returned simplifying patterns like:
> > > > 
> > > > 	dev_err_probe(dev, ret, ...);
> > > > 	return ERR_PTR(ret)
> > > > or
> > > > 	dev_err_probe(dev, PTR_ERR(ptr), ...);
> > > > 	return ERR_CAST(ptr)
> > > > 
> > > > Signed-off-by: Nuno Sa <nuno.sa@analog.com>    
> > > 
> > > I'm convinced this is worth doing but would like inputs from others
> > > before I pick this series up.  
> > 
> > Andi and Andy,
> > 
> > You both commented on earlier versions.  Do you think this is a good
> > change set?
> > 
> > I've +CC a few more based on a quick look at the original
> > dev_err_probe() series. Whilst this isn't adding a bunch of new stuff
> > around deferred probing (like that series did), maybe some of those
> > reviewers will give opinions here?
> >   
> 
> Hi,
> 
> I there something else needed from my side? Would be nice to have some
> feedback...
I guess no one has strong opinions they haven't expressed already.

Applied to the togreg branch of iio.git and pushed out as testing for
all the normal reasons.  Still time for last minute feedback of course.

Basically I decided that even if people decide later they don't like this
for now it has few users and we can rip it out again if needed.
Hopefully that won't happen.

Jonathan

> 
> - Nuno Sá
> 
>
diff mbox series

Patch

diff --git a/include/linux/dev_printk.h b/include/linux/dev_printk.h
index ae80a303c216..ca32b5bb28eb 100644
--- a/include/linux/dev_printk.h
+++ b/include/linux/dev_printk.h
@@ -277,4 +277,12 @@  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_err_ptr_probe(dev, ___err, fmt, ...) \
+	ERR_PTR(dev_err_probe(dev, ___err, fmt, ##__VA_ARGS__))
+
+/* Simple helper for dev_err_probe() when ERR_CAST() is to be returned. */
+#define dev_err_cast_probe(dev, ___err_ptr, fmt, ...) \
+	ERR_PTR(dev_err_probe(dev, PTR_ERR(___err_ptr), fmt, ##__VA_ARGS__))
+
 #endif /* _DEVICE_PRINTK_H_ */