public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/9] gpib: Unify *allocate_private
@ 2026-01-13 19:08 Dominik Karol Piątkowski
  2026-01-13 19:08 ` [PATCH 1/9] gpib: agilent_82350b: " Dominik Karol Piątkowski
                   ` (9 more replies)
  0 siblings, 10 replies; 17+ messages in thread
From: Dominik Karol Piątkowski @ 2026-01-13 19:08 UTC (permalink / raw)
  To: Dave Penkler, Greg Kroah-Hartman, Michael Rubin, Dan Carpenter
  Cc: linux-kernel, Dominik Karol Piątkowski

Recently, gpib driver got out of staging area. There is still a bit of work that
can be done to improve it.

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.

Untouched gpib files already use the proposed convention.

Signed-off-by: Dominik Karol Piątkowski <dominik.karol.piatkowski@protonmail.com>

Dominik Karol Piątkowski (9):
  gpib: agilent_82350b: Unify *allocate_private
  gpib: cb7210: Unify *allocate_private
  gpib: cec: Unify *allocate_private
  gpib: gpio: Unify *allocate_private
  gpib: hp_82335: Unify *allocate_private
  gpib: hp_82341: Unify *allocate_private
  gpib: ines: Unify *allocate_private
  gpib: pc2: Unify *allocate_private
  gpib: tnt4882: Unify *allocate_private

 drivers/gpib/agilent_82350b/agilent_82350b.c |  5 +++--
 drivers/gpib/cb7210/cb7210.c                 |  6 ++++--
 drivers/gpib/cec/cec_gpib.c                  |  8 +++++---
 drivers/gpib/gpio/gpib_bitbang.c             |  9 +++++----
 drivers/gpib/hp_82335/hp82335.c              |  7 ++++---
 drivers/gpib/hp_82341/hp_82341.c             |  5 +++--
 drivers/gpib/ines/ines_gpib.c                |  8 +++++---
 drivers/gpib/pc2/pc2_gpib.c                  |  8 +++++---
 drivers/gpib/tnt4882/tnt4882_gpib.c          | 17 ++++++++++-------
 9 files changed, 44 insertions(+), 29 deletions(-)

-- 
2.43.0



^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 1/9] gpib: agilent_82350b: Unify *allocate_private
  2026-01-13 19:08 [PATCH 0/9] gpib: Unify *allocate_private Dominik Karol Piątkowski
@ 2026-01-13 19:08 ` Dominik Karol Piątkowski
  2026-01-16  7:36   ` Greg Kroah-Hartman
  2026-01-13 19:08 ` [PATCH 2/9] gpib: cb7210: " Dominik Karol Piątkowski
                   ` (8 subsequent siblings)
  9 siblings, 1 reply; 17+ messages in thread
From: Dominik Karol Piątkowski @ 2026-01-13 19:08 UTC (permalink / raw)
  To: Dave Penkler, Greg Kroah-Hartman, Michael Rubin, Dan Carpenter
  Cc: linux-kernel, Dominik Karol Piątkowski

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



^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 2/9] gpib: cb7210: Unify *allocate_private
  2026-01-13 19:08 [PATCH 0/9] gpib: Unify *allocate_private Dominik Karol Piątkowski
  2026-01-13 19:08 ` [PATCH 1/9] gpib: agilent_82350b: " Dominik Karol Piątkowski
@ 2026-01-13 19:08 ` Dominik Karol Piątkowski
  2026-01-13 19:08 ` [PATCH 3/9] gpib: cec: " Dominik Karol Piątkowski
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 17+ messages in thread
From: Dominik Karol Piątkowski @ 2026-01-13 19:08 UTC (permalink / raw)
  To: Dave Penkler, Greg Kroah-Hartman, Michael Rubin, Dan Carpenter
  Cc: linux-kernel, Dominik Karol Piątkowski

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/cb7210/cb7210.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/gpib/cb7210/cb7210.c b/drivers/gpib/cb7210/cb7210.c
index 24c61b151071..e0ce2ac494c4 100644
--- a/drivers/gpib/cb7210/cb7210.c
+++ b/drivers/gpib/cb7210/cb7210.c
@@ -876,11 +876,13 @@ static int cb7210_generic_attach(struct gpib_board *board)
 {
 	struct cb7210_priv *cb_priv;
 	struct nec7210_priv *nec_priv;
+	int retval;
 
 	board->status = 0;
 
-	if (cb7210_allocate_private(board))
-		return -ENOMEM;
+	retval = cb7210_allocate_private(board);
+	if (retval < 0)
+		return retval;
 	cb_priv = board->private_data;
 	nec_priv = &cb_priv->nec7210_priv;
 	nec_priv->read_byte = nec7210_locking_ioport_read_byte;
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 3/9] gpib: cec: Unify *allocate_private
  2026-01-13 19:08 [PATCH 0/9] gpib: Unify *allocate_private Dominik Karol Piątkowski
  2026-01-13 19:08 ` [PATCH 1/9] gpib: agilent_82350b: " Dominik Karol Piątkowski
  2026-01-13 19:08 ` [PATCH 2/9] gpib: cb7210: " Dominik Karol Piątkowski
@ 2026-01-13 19:08 ` Dominik Karol Piątkowski
  2026-01-15 16:29   ` Dave Penkler
  2026-01-13 19:09 ` [PATCH 4/9] gpib: gpio: " Dominik Karol Piątkowski
                   ` (6 subsequent siblings)
  9 siblings, 1 reply; 17+ messages in thread
From: Dominik Karol Piątkowski @ 2026-01-13 19:08 UTC (permalink / raw)
  To: Dave Penkler, Greg Kroah-Hartman, Michael Rubin, Dan Carpenter
  Cc: linux-kernel, Dominik Karol Piątkowski

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/cec/cec_gpib.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/gpib/cec/cec_gpib.c b/drivers/gpib/cec/cec_gpib.c
index dbf9b95baabc..6d04becd1058 100644
--- a/drivers/gpib/cec/cec_gpib.c
+++ b/drivers/gpib/cec/cec_gpib.c
@@ -222,7 +222,7 @@ static int cec_allocate_private(struct gpib_board *board)
 
 	board->private_data = kmalloc(sizeof(struct cec_priv), GFP_KERNEL);
 	if (!board->private_data)
-		return -1;
+		return -ENOMEM;
 	priv = board->private_data;
 	memset(priv, 0, sizeof(struct cec_priv));
 	init_nec7210_private(&priv->nec7210_priv);
@@ -239,11 +239,13 @@ static int cec_generic_attach(struct gpib_board *board)
 {
 	struct cec_priv *cec_priv;
 	struct nec7210_priv *nec_priv;
+	int retval;
 
 	board->status = 0;
 
-	if (cec_allocate_private(board))
-		return -ENOMEM;
+	retval = cec_allocate_private(board);
+	if (retval < 0)
+		return retval;
 	cec_priv = board->private_data;
 	nec_priv = &cec_priv->nec7210_priv;
 	nec_priv->read_byte = nec7210_ioport_read_byte;
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 4/9] gpib: gpio: Unify *allocate_private
  2026-01-13 19:08 [PATCH 0/9] gpib: Unify *allocate_private Dominik Karol Piątkowski
                   ` (2 preceding siblings ...)
  2026-01-13 19:08 ` [PATCH 3/9] gpib: cec: " Dominik Karol Piątkowski
@ 2026-01-13 19:09 ` Dominik Karol Piątkowski
  2026-01-13 19:09 ` [PATCH 5/9] gpib: hp_82335: " Dominik Karol Piątkowski
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 17+ messages in thread
From: Dominik Karol Piątkowski @ 2026-01-13 19:09 UTC (permalink / raw)
  To: Dave Penkler, Greg Kroah-Hartman, Michael Rubin, Dan Carpenter
  Cc: linux-kernel, Dominik Karol Piątkowski

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/gpio/gpib_bitbang.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/gpib/gpio/gpib_bitbang.c b/drivers/gpib/gpio/gpib_bitbang.c
index 374cd61355e9..3b8bd34f2f3d 100644
--- a/drivers/gpib/gpio/gpib_bitbang.c
+++ b/drivers/gpib/gpio/gpib_bitbang.c
@@ -1068,7 +1068,7 @@ static int allocate_private(struct gpib_board *board)
 {
 	board->private_data = kzalloc(sizeof(struct bb_priv), GFP_KERNEL);
 	if (!board->private_data)
-		return -1;
+		return -ENOMEM;
 	return 0;
 }
 
@@ -1205,14 +1205,15 @@ static void bb_detach(struct gpib_board *board)
 static int bb_attach(struct gpib_board *board, const struct gpib_board_config *config)
 {
 	struct bb_priv *priv;
-	int retval = 0;
+	int retval;
 
 	dbg_printk(2, "%s\n", "Enter ...");
 
 	board->status = 0;
 
-	if (allocate_private(board))
-		return -ENOMEM;
+	retval = allocate_private(board);
+	if (retval < 0)
+		return retval;
 	priv = board->private_data;
 	priv->direction = -1;
 	priv->t1_delay = 2000;
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 5/9] gpib: hp_82335: Unify *allocate_private
  2026-01-13 19:08 [PATCH 0/9] gpib: Unify *allocate_private Dominik Karol Piątkowski
                   ` (3 preceding siblings ...)
  2026-01-13 19:09 ` [PATCH 4/9] gpib: gpio: " Dominik Karol Piątkowski
@ 2026-01-13 19:09 ` Dominik Karol Piątkowski
  2026-01-13 19:09 ` [PATCH 6/9] gpib: hp_82341: " Dominik Karol Piątkowski
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 17+ messages in thread
From: Dominik Karol Piątkowski @ 2026-01-13 19:09 UTC (permalink / raw)
  To: Dave Penkler, Greg Kroah-Hartman, Michael Rubin, Dan Carpenter
  Cc: linux-kernel, Dominik Karol Piątkowski

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/hp_82335/hp82335.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/gpib/hp_82335/hp82335.c b/drivers/gpib/hp_82335/hp82335.c
index d0e47ef77c87..871079dd1088 100644
--- a/drivers/gpib/hp_82335/hp82335.c
+++ b/drivers/gpib/hp_82335/hp82335.c
@@ -212,7 +212,7 @@ static int hp82335_allocate_private(struct gpib_board *board)
 {
 	board->private_data = kzalloc(sizeof(struct hp82335_priv), GFP_KERNEL);
 	if (!board->private_data)
-		return -1;
+		return -ENOMEM;
 	return 0;
 }
 
@@ -253,8 +253,9 @@ static int hp82335_attach(struct gpib_board *board, const struct gpib_board_conf
 
 	board->status = 0;
 
-	if (hp82335_allocate_private(board))
-		return -ENOMEM;
+	retval = hp82335_allocate_private(board);
+	if (retval < 0)
+		return retval;
 	hp_priv = board->private_data;
 	tms_priv = &hp_priv->tms9914_priv;
 	tms_priv->read_byte = hp82335_read_byte;
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 6/9] gpib: hp_82341: Unify *allocate_private
  2026-01-13 19:08 [PATCH 0/9] gpib: Unify *allocate_private Dominik Karol Piątkowski
                   ` (4 preceding siblings ...)
  2026-01-13 19:09 ` [PATCH 5/9] gpib: hp_82335: " Dominik Karol Piątkowski
@ 2026-01-13 19:09 ` Dominik Karol Piątkowski
  2026-01-13 19:09 ` [PATCH 7/9] gpib: ines: " Dominik Karol Piątkowski
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 17+ messages in thread
From: Dominik Karol Piątkowski @ 2026-01-13 19:09 UTC (permalink / raw)
  To: Dave Penkler, Greg Kroah-Hartman, Michael Rubin, Dan Carpenter
  Cc: linux-kernel, Dominik Karol Piątkowski

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/hp_82341/hp_82341.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/gpib/hp_82341/hp_82341.c b/drivers/gpib/hp_82341/hp_82341.c
index 1a2ad0560e14..4a2440fe160f 100644
--- a/drivers/gpib/hp_82341/hp_82341.c
+++ b/drivers/gpib/hp_82341/hp_82341.c
@@ -693,8 +693,9 @@ static int hp_82341_attach(struct gpib_board *board, const struct gpib_board_con
 	int retval;
 
 	board->status = 0;
-	if (hp_82341_allocate_private(board))
-		return -ENOMEM;
+	retval = hp_82341_allocate_private(board);
+	if (retval < 0)
+		return retval;
 	hp_priv = board->private_data;
 	tms_priv = &hp_priv->tms9914_priv;
 	tms_priv->read_byte = hp_82341_read_byte;
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 7/9] gpib: ines: Unify *allocate_private
  2026-01-13 19:08 [PATCH 0/9] gpib: Unify *allocate_private Dominik Karol Piątkowski
                   ` (5 preceding siblings ...)
  2026-01-13 19:09 ` [PATCH 6/9] gpib: hp_82341: " Dominik Karol Piątkowski
@ 2026-01-13 19:09 ` Dominik Karol Piątkowski
  2026-01-13 19:09 ` [PATCH 8/9] gpib: pc2: " Dominik Karol Piątkowski
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 17+ messages in thread
From: Dominik Karol Piątkowski @ 2026-01-13 19:09 UTC (permalink / raw)
  To: Dave Penkler, Greg Kroah-Hartman, Michael Rubin, Dan Carpenter
  Cc: linux-kernel, Dominik Karol Piątkowski

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/ines/ines_gpib.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/gpib/ines/ines_gpib.c b/drivers/gpib/ines/ines_gpib.c
index a3cf846fd0f9..98f311f64d40 100644
--- a/drivers/gpib/ines/ines_gpib.c
+++ b/drivers/gpib/ines/ines_gpib.c
@@ -659,7 +659,7 @@ static int ines_allocate_private(struct gpib_board *board)
 
 	board->private_data = kmalloc(sizeof(struct ines_priv), GFP_KERNEL);
 	if (!board->private_data)
-		return -1;
+		return -ENOMEM;
 	priv = board->private_data;
 	memset(priv, 0, sizeof(struct ines_priv));
 	init_nec7210_private(&priv->nec7210_priv);
@@ -676,11 +676,13 @@ static int ines_generic_attach(struct gpib_board *board)
 {
 	struct ines_priv *ines_priv;
 	struct nec7210_priv *nec_priv;
+	int retval;
 
 	board->status = 0;
 
-	if (ines_allocate_private(board))
-		return -ENOMEM;
+	retval = ines_allocate_private(board);
+	if (retval < 0)
+		return retval;
 	ines_priv = board->private_data;
 	nec_priv = &ines_priv->nec7210_priv;
 	nec_priv->read_byte = nec7210_ioport_read_byte;
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 8/9] gpib: pc2: Unify *allocate_private
  2026-01-13 19:08 [PATCH 0/9] gpib: Unify *allocate_private Dominik Karol Piątkowski
                   ` (6 preceding siblings ...)
  2026-01-13 19:09 ` [PATCH 7/9] gpib: ines: " Dominik Karol Piątkowski
@ 2026-01-13 19:09 ` Dominik Karol Piątkowski
  2026-01-13 19:09 ` [PATCH 9/9] gpib: tnt4882: " Dominik Karol Piątkowski
  2026-01-19  7:34 ` [PATCH 0/9] gpib: " Dan Carpenter
  9 siblings, 0 replies; 17+ messages in thread
From: Dominik Karol Piątkowski @ 2026-01-13 19:09 UTC (permalink / raw)
  To: Dave Penkler, Greg Kroah-Hartman, Michael Rubin, Dan Carpenter
  Cc: linux-kernel, Dominik Karol Piątkowski

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/pc2/pc2_gpib.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/gpib/pc2/pc2_gpib.c b/drivers/gpib/pc2/pc2_gpib.c
index 9f3943d1df66..93248b28982b 100644
--- a/drivers/gpib/pc2/pc2_gpib.c
+++ b/drivers/gpib/pc2/pc2_gpib.c
@@ -239,7 +239,7 @@ static int allocate_private(struct gpib_board *board)
 
 	board->private_data = kmalloc(sizeof(struct pc2_priv), GFP_KERNEL);
 	if (!board->private_data)
-		return -1;
+		return -ENOMEM;
 	priv = board->private_data;
 	memset(priv, 0, sizeof(struct pc2_priv));
 	init_nec7210_private(&priv->nec7210_priv);
@@ -257,10 +257,12 @@ static int pc2_generic_attach(struct gpib_board *board, const struct gpib_board_
 {
 	struct pc2_priv *pc2_priv;
 	struct nec7210_priv *nec_priv;
+	int retval;
 
 	board->status = 0;
-	if (allocate_private(board))
-		return -ENOMEM;
+	retval = allocate_private(board);
+	if (retval < 0)
+		return retval;
 	pc2_priv = board->private_data;
 	nec_priv = &pc2_priv->nec7210_priv;
 	nec_priv->read_byte = nec7210_ioport_read_byte;
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 9/9] gpib: tnt4882: Unify *allocate_private
  2026-01-13 19:08 [PATCH 0/9] gpib: Unify *allocate_private Dominik Karol Piątkowski
                   ` (7 preceding siblings ...)
  2026-01-13 19:09 ` [PATCH 8/9] gpib: pc2: " Dominik Karol Piątkowski
@ 2026-01-13 19:09 ` Dominik Karol Piątkowski
  2026-01-19  7:34 ` [PATCH 0/9] gpib: " Dan Carpenter
  9 siblings, 0 replies; 17+ messages in thread
From: Dominik Karol Piątkowski @ 2026-01-13 19:09 UTC (permalink / raw)
  To: Dave Penkler, Greg Kroah-Hartman, Michael Rubin, Dan Carpenter
  Cc: linux-kernel, Dominik Karol Piątkowski

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/tnt4882/tnt4882_gpib.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/drivers/gpib/tnt4882/tnt4882_gpib.c b/drivers/gpib/tnt4882/tnt4882_gpib.c
index c03a976b7380..e12002c0e982 100644
--- a/drivers/gpib/tnt4882/tnt4882_gpib.c
+++ b/drivers/gpib/tnt4882/tnt4882_gpib.c
@@ -845,7 +845,7 @@ static int tnt4882_allocate_private(struct gpib_board *board)
 
 	board->private_data = kmalloc(sizeof(struct tnt4882_priv), GFP_KERNEL);
 	if (!board->private_data)
-		return -1;
+		return -ENOMEM;
 	tnt_priv = board->private_data;
 	memset(tnt_priv, 0, sizeof(struct tnt4882_priv));
 	init_nec7210_private(&tnt_priv->nec7210_priv);
@@ -916,8 +916,9 @@ static int ni_pci_attach(struct gpib_board *board, const struct gpib_board_confi
 
 	board->status = 0;
 
-	if (tnt4882_allocate_private(board))
-		return -ENOMEM;
+	retval = tnt4882_allocate_private(board);
+	if (retval < 0)
+		return retval;
 	tnt_priv = board->private_data;
 	nec_priv = &tnt_priv->nec7210_priv;
 	nec_priv->type = TNT4882;
@@ -1039,8 +1040,9 @@ static int ni_isa_attach_common(struct gpib_board *board, const struct gpib_boar
 
 	board->status = 0;
 
-	if (tnt4882_allocate_private(board))
-		return -ENOMEM;
+	retval = tnt4882_allocate_private(board);
+	if (retval < 0)
+		return retval;
 	tnt_priv = board->private_data;
 	nec_priv = &tnt_priv->nec7210_priv;
 	nec_priv->type = chipset;
@@ -1725,8 +1727,9 @@ static int ni_pcmcia_attach(struct gpib_board *board, const struct gpib_board_co
 
 	board->status = 0;
 
-	if (tnt4882_allocate_private(board))
-		return -ENOMEM;
+	retval = tnt4882_allocate_private(board);
+	if (retval < 0)
+		return retval;
 
 	tnt_priv = board->private_data;
 	nec_priv = &tnt_priv->nec7210_priv;
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 17+ messages in thread

* Re: [PATCH 3/9] gpib: cec: Unify *allocate_private
  2026-01-13 19:08 ` [PATCH 3/9] gpib: cec: " Dominik Karol Piątkowski
@ 2026-01-15 16:29   ` Dave Penkler
  2026-01-15 18:11     ` Dominik Karol Piątkowski
  2026-01-16  7:50     ` Greg Kroah-Hartman
  0 siblings, 2 replies; 17+ messages in thread
From: Dave Penkler @ 2026-01-15 16:29 UTC (permalink / raw)
  To: Dominik Karol Pi??tkowski
  Cc: Greg Kroah-Hartman, Michael Rubin, Dan Carpenter, linux-kernel

On Tue, Jan 13, 2026 at 07:08:56PM +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/cec/cec_gpib.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpib/cec/cec_gpib.c b/drivers/gpib/cec/cec_gpib.c
> index dbf9b95baabc..6d04becd1058 100644
> --- a/drivers/gpib/cec/cec_gpib.c
> +++ b/drivers/gpib/cec/cec_gpib.c
> @@ -222,7 +222,7 @@ static int cec_allocate_private(struct gpib_board *board)
>  
>  	board->private_data = kmalloc(sizeof(struct cec_priv), GFP_KERNEL);

Maybe you could change all the remaining kmalloc/memset pairs to kzalloc at the same time ?

>  	if (!board->private_data)
> -		return -1;
> +		return -ENOMEM;
>  	priv = board->private_data;
>  	memset(priv, 0, sizeof(struct cec_priv));
>  	init_nec7210_private(&priv->nec7210_priv);
> @@ -239,11 +239,13 @@ static int cec_generic_attach(struct gpib_board *board)
>  {
>  	struct cec_priv *cec_priv;
>  	struct nec7210_priv *nec_priv;
> +	int retval;
>  
>  	board->status = 0;
>  
> -	if (cec_allocate_private(board))
> -		return -ENOMEM;
> +	retval = cec_allocate_private(board);
> +	if (retval < 0)
> +		return retval;
>  	cec_priv = board->private_data;
>  	nec_priv = &cec_priv->nec7210_priv;
>  	nec_priv->read_byte = nec7210_ioport_read_byte;
> -- 
> 2.43.0
> 
> 

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 3/9] gpib: cec: Unify *allocate_private
  2026-01-15 16:29   ` Dave Penkler
@ 2026-01-15 18:11     ` Dominik Karol Piątkowski
  2026-01-16  7:50     ` Greg Kroah-Hartman
  1 sibling, 0 replies; 17+ messages in thread
From: Dominik Karol Piątkowski @ 2026-01-15 18:11 UTC (permalink / raw)
  To: Dave Penkler
  Cc: Greg Kroah-Hartman, Michael Rubin, Dan Carpenter, linux-kernel

Hi Dave,

On Thursday, January 15th, 2026 at 17:29, Dave Penkler <dpenkler@gmail.com> wrote:

> 
> 
> On Tue, Jan 13, 2026 at 07:08:56PM +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/cec/cec_gpib.c | 8 +++++---
> > 1 file changed, 5 insertions(+), 3 deletions(-)
> > 
> > diff --git a/drivers/gpib/cec/cec_gpib.c b/drivers/gpib/cec/cec_gpib.c
> > index dbf9b95baabc..6d04becd1058 100644
> > --- a/drivers/gpib/cec/cec_gpib.c
> > +++ b/drivers/gpib/cec/cec_gpib.c
> > @@ -222,7 +222,7 @@ static int cec_allocate_private(struct gpib_board *board)
> > 
> > board->private_data = kmalloc(sizeof(struct cec_priv), GFP_KERNEL);
> 
> 
> Maybe you could change all the remaining kmalloc/memset pairs to kzalloc at the same time ?

Sure, thanks for the suggestion!

Dominik Karol

> 
> > if (!board->private_data)
> > - return -1;
> > + return -ENOMEM;
> > priv = board->private_data;
> > memset(priv, 0, sizeof(struct cec_priv));
> > init_nec7210_private(&priv->nec7210_priv);
> > @@ -239,11 +239,13 @@ static int cec_generic_attach(struct gpib_board *board)
> > {
> > struct cec_priv *cec_priv;
> > struct nec7210_priv *nec_priv;
> > + int retval;
> > 
> > board->status = 0;
> > 
> > - if (cec_allocate_private(board))
> > - return -ENOMEM;
> > + retval = cec_allocate_private(board);
> > + if (retval < 0)
> > + return retval;
> > cec_priv = board->private_data;
> > nec_priv = &cec_priv->nec7210_priv;
> > nec_priv->read_byte = nec7210_ioport_read_byte;
> > --
> > 2.43.0

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 1/9] gpib: agilent_82350b: Unify *allocate_private
  2026-01-13 19:08 ` [PATCH 1/9] gpib: agilent_82350b: " Dominik Karol Piątkowski
@ 2026-01-16  7:36   ` Greg Kroah-Hartman
  2026-01-16 14:45     ` Dominik Karol Piątkowski
  0 siblings, 1 reply; 17+ messages in thread
From: Greg Kroah-Hartman @ 2026-01-16  7:36 UTC (permalink / raw)
  To: Dominik Karol Piątkowski
  Cc: Dave Penkler, Michael Rubin, Dan Carpenter, linux-kernel

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

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 3/9] gpib: cec: Unify *allocate_private
  2026-01-15 16:29   ` Dave Penkler
  2026-01-15 18:11     ` Dominik Karol Piątkowski
@ 2026-01-16  7:50     ` Greg Kroah-Hartman
  1 sibling, 0 replies; 17+ messages in thread
From: Greg Kroah-Hartman @ 2026-01-16  7:50 UTC (permalink / raw)
  To: Dave Penkler
  Cc: Dominik Karol Pi??tkowski, Michael Rubin, Dan Carpenter,
	linux-kernel

On Thu, Jan 15, 2026 at 05:29:44PM +0100, Dave Penkler wrote:
> On Tue, Jan 13, 2026 at 07:08:56PM +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/cec/cec_gpib.c | 8 +++++---
> >  1 file changed, 5 insertions(+), 3 deletions(-)
> > 
> > diff --git a/drivers/gpib/cec/cec_gpib.c b/drivers/gpib/cec/cec_gpib.c
> > index dbf9b95baabc..6d04becd1058 100644
> > --- a/drivers/gpib/cec/cec_gpib.c
> > +++ b/drivers/gpib/cec/cec_gpib.c
> > @@ -222,7 +222,7 @@ static int cec_allocate_private(struct gpib_board *board)
> >  
> >  	board->private_data = kmalloc(sizeof(struct cec_priv), GFP_KERNEL);
> 
> Maybe you could change all the remaining kmalloc/memset pairs to kzalloc at the same time ?

That's a different logical change, and should be in a different patch,
just to ensure that it is easier to review and roll back if something
went wrong.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 1/9] gpib: agilent_82350b: Unify *allocate_private
  2026-01-16  7:36   ` Greg Kroah-Hartman
@ 2026-01-16 14:45     ` Dominik Karol Piątkowski
  0 siblings, 0 replies; 17+ messages in thread
From: Dominik Karol Piątkowski @ 2026-01-16 14:45 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Dave Penkler, Michael Rubin, Dan Carpenter, linux-kernel

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

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 0/9] gpib: Unify *allocate_private
  2026-01-13 19:08 [PATCH 0/9] gpib: Unify *allocate_private Dominik Karol Piątkowski
                   ` (8 preceding siblings ...)
  2026-01-13 19:09 ` [PATCH 9/9] gpib: tnt4882: " Dominik Karol Piątkowski
@ 2026-01-19  7:34 ` Dan Carpenter
  2026-01-20 16:12   ` Dominik Karol Piątkowski
  9 siblings, 1 reply; 17+ messages in thread
From: Dan Carpenter @ 2026-01-19  7:34 UTC (permalink / raw)
  To: Dominik Karol Piątkowski
  Cc: Dave Penkler, Greg Kroah-Hartman, Michael Rubin, linux-kernel

On Tue, Jan 13, 2026 at 07:08:37PM +0000, Dominik Karol Piątkowski wrote:
> Recently, gpib driver got out of staging area. There is still a bit of work that
> can be done to improve it.
> 
> 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.
> 
> Untouched gpib files already use the proposed convention.
> 
> Signed-off-by: Dominik Karol Piątkowski <dominik.karol.piatkowski@protonmail.com>

I don't see the point of the allocate_private() functions.  Why not
just open code it?

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 0/9] gpib: Unify *allocate_private
  2026-01-19  7:34 ` [PATCH 0/9] gpib: " Dan Carpenter
@ 2026-01-20 16:12   ` Dominik Karol Piątkowski
  0 siblings, 0 replies; 17+ messages in thread
From: Dominik Karol Piątkowski @ 2026-01-20 16:12 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Dave Penkler, Greg Kroah-Hartman, Michael Rubin, linux-kernel

Hi Dan,


On Monday, January 19th, 2026 at 08:34, Dan Carpenter <dan.carpenter@linaro.org> wrote:

> 
> 
> On Tue, Jan 13, 2026 at 07:08:37PM +0000, Dominik Karol Piątkowski wrote:
> 
> > Recently, gpib driver got out of staging area. There is still a bit of work that
> > can be done to improve it.
> > 
> > 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.
> > 
> > Untouched gpib files already use the proposed convention.
> > 
> > Signed-off-by: Dominik Karol Piątkowski dominik.karol.piatkowski@protonmail.com
> 
> 
> I don't see the point of the allocate_private() functions. Why not
> just open code it?

In most cases, *allocate_private() functions are used just once, in the
*attach() functions. The exception is tnt4882_gpib.c, that has 3 *attach()
functions, so it makes sense to keep it at least there. From what I noticed,
*allocate_private sometimes just allocates memory for private_data (for example,
in agilent_82350b.c), but sometimes it also does a bit of other stuff (like
initializing private_data mutexes in agilent_82357a.c).

And tnt4882_gpib.c falls into the "also does a bit of other stuff" category.

If I were to open code it, I would have to leave tnt4882_gpib.c as-is, drop the
`Unify *allocate_private usage` patches and introduce patches that move the
*allocate_private() to *attach() functions. I think v3 has a cleaner approach.

What do you think about that?

Thanks,
Dominik Karol

> 
> regards,
> dan carpenter

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2026-01-20 16:13 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-13 19:08 [PATCH 0/9] gpib: Unify *allocate_private Dominik Karol Piątkowski
2026-01-13 19:08 ` [PATCH 1/9] gpib: agilent_82350b: " Dominik Karol Piątkowski
2026-01-16  7:36   ` Greg Kroah-Hartman
2026-01-16 14:45     ` Dominik Karol Piątkowski
2026-01-13 19:08 ` [PATCH 2/9] gpib: cb7210: " Dominik Karol Piątkowski
2026-01-13 19:08 ` [PATCH 3/9] gpib: cec: " Dominik Karol Piątkowski
2026-01-15 16:29   ` Dave Penkler
2026-01-15 18:11     ` Dominik Karol Piątkowski
2026-01-16  7:50     ` Greg Kroah-Hartman
2026-01-13 19:09 ` [PATCH 4/9] gpib: gpio: " Dominik Karol Piątkowski
2026-01-13 19:09 ` [PATCH 5/9] gpib: hp_82335: " Dominik Karol Piątkowski
2026-01-13 19:09 ` [PATCH 6/9] gpib: hp_82341: " Dominik Karol Piątkowski
2026-01-13 19:09 ` [PATCH 7/9] gpib: ines: " Dominik Karol Piątkowski
2026-01-13 19:09 ` [PATCH 8/9] gpib: pc2: " Dominik Karol Piątkowski
2026-01-13 19:09 ` [PATCH 9/9] gpib: tnt4882: " Dominik Karol Piątkowski
2026-01-19  7:34 ` [PATCH 0/9] gpib: " Dan Carpenter
2026-01-20 16:12   ` Dominik Karol Piątkowski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox