[PATCH 1/9] gpib: agilent_82350b: Unify *allocate_private

Dominik Karol Piątkowski posted 9 patches 3 weeks, 5 days ago
There is a newer version of this series
[PATCH 1/9] gpib: agilent_82350b: Unify *allocate_private
Posted by Dominik Karol Piątkowski 3 weeks, 5 days ago
Return values for *allocate_private functions as well as calling code in
gpib driver are all over the place. Unify them by returning -errno if
something fails, zero otherwise. Use the returned value as early return
value in case of error.

Signed-off-by: Dominik Karol Piątkowski <dominik.karol.piatkowski@protonmail.com>
---
 drivers/gpib/agilent_82350b/agilent_82350b.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/gpib/agilent_82350b/agilent_82350b.c b/drivers/gpib/agilent_82350b/agilent_82350b.c
index 01a5bb43cd2d..f5f102863e47 100644
--- a/drivers/gpib/agilent_82350b/agilent_82350b.c
+++ b/drivers/gpib/agilent_82350b/agilent_82350b.c
@@ -599,8 +599,9 @@ static int agilent_82350b_generic_attach(struct gpib_board *board,
 
 	board->status = 0;
 
-	if (agilent_82350b_allocate_private(board))
-		return -ENOMEM;
+	retval = agilent_82350b_allocate_private(board);
+	if (retval < 0)
+		return retval;
 	a_priv = board->private_data;
 	a_priv->using_fifos = use_fifos;
 	tms_priv = &a_priv->tms9914_priv;
-- 
2.43.0
Re: [PATCH 1/9] gpib: agilent_82350b: Unify *allocate_private
Posted by Greg Kroah-Hartman 3 weeks, 3 days ago
On Tue, Jan 13, 2026 at 07:08:43PM +0000, Dominik Karol Piątkowski wrote:
> Return values for *allocate_private functions as well as calling code in
> gpib driver are all over the place. Unify them by returning -errno if
> something fails, zero otherwise. Use the returned value as early return
> value in case of error.
> 
> Signed-off-by: Dominik Karol Piątkowski <dominik.karol.piatkowski@protonmail.com>
> ---
>  drivers/gpib/agilent_82350b/agilent_82350b.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpib/agilent_82350b/agilent_82350b.c b/drivers/gpib/agilent_82350b/agilent_82350b.c
> index 01a5bb43cd2d..f5f102863e47 100644
> --- a/drivers/gpib/agilent_82350b/agilent_82350b.c
> +++ b/drivers/gpib/agilent_82350b/agilent_82350b.c
> @@ -599,8 +599,9 @@ static int agilent_82350b_generic_attach(struct gpib_board *board,
>  
>  	board->status = 0;
>  
> -	if (agilent_82350b_allocate_private(board))
> -		return -ENOMEM;
> +	retval = agilent_82350b_allocate_private(board);
> +	if (retval < 0)
> +		return retval;

This should be:
	if (retval)
		return retval;

right?

And the function only returns either 0 or -ENOMEM, so your changelog
text is not correct.

thanks,

greg k-h
Re: [PATCH 1/9] gpib: agilent_82350b: Unify *allocate_private
Posted by Dominik Karol Piątkowski 3 weeks, 3 days ago
Hi Greg,


On Friday, January 16th, 2026 at 08:36, Greg Kroah-Hartman <gregkh@linuxfoundation.org> wrote:

> 
> 
> On Tue, Jan 13, 2026 at 07:08:43PM +0000, Dominik Karol Piątkowski wrote:
> 
> > Return values for *allocate_private functions as well as calling code in
> > gpib driver are all over the place. Unify them by returning -errno if
> > something fails, zero otherwise. Use the returned value as early return
> > value in case of error.
> > 
> > Signed-off-by: Dominik Karol Piątkowski dominik.karol.piatkowski@protonmail.com
> > ---
> > drivers/gpib/agilent_82350b/agilent_82350b.c | 5 +++--
> > 1 file changed, 3 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/gpib/agilent_82350b/agilent_82350b.c b/drivers/gpib/agilent_82350b/agilent_82350b.c
> > index 01a5bb43cd2d..f5f102863e47 100644
> > --- a/drivers/gpib/agilent_82350b/agilent_82350b.c
> > +++ b/drivers/gpib/agilent_82350b/agilent_82350b.c
> > @@ -599,8 +599,9 @@ static int agilent_82350b_generic_attach(struct gpib_board *board,
> > 
> > board->status = 0;
> > 
> > - if (agilent_82350b_allocate_private(board))
> > - return -ENOMEM;
> > + retval = agilent_82350b_allocate_private(board);
> > + if (retval < 0)
> > + return retval;
> 
> 
> This should be:
> if (retval)
> return retval;
> 
> right?

This is even better, thank you!

> 
> And the function only returns either 0 or -ENOMEM, so your changelog
> text is not correct.

Right, I will differentiate the changelog based on actual per-patch changes
instead of describing overall unification effort, which I admit wasn't the
best idea. Thank you for pointing that out!

I will also break the patches into smaller pieces as advised in another
mail, as there are indeed some patches that do more than one logical thing
(for example, v2 11/12).

Thanks,
Dominik Karol

> 
> thanks,
> 
> greg k-h