* [PATCH 0/8] Staging: gpib: Update return types and error handling for request_system_control
@ 2025-05-01 21:30 Thomas Andreatta
2025-05-01 21:30 ` [PATCH 1/8] Staging: gpib: agilent_82357a: changing return type void in int Thomas Andreatta
` (7 more replies)
0 siblings, 8 replies; 13+ messages in thread
From: Thomas Andreatta @ 2025-05-01 21:30 UTC (permalink / raw)
To: dpenkler; +Cc: gregkh, linux-kernel, linux-staging, Thomas Andreatta
This patch series improves error propagation in the gpib driver by changing
the return type of `request_system_control` and related functions from void to
int, allowing proper error handling.
The changes follow these steps:
* Fix the FIXME comment in agilent_82357a.c by changing the return type
from void to int
* Update the function prototype in gpib_types.h
* Update all implementations of the function across drivers to return int
* Implement proper error checking for the new signatures in the resume function
* Improves the mutex unlocking path process in the resume function
All functions that used to be void and didn't had any intended return code are
now returning success (0), and the resume code is refactored to ensure mutex
unlocking in all execution paths.
Thomas Andreatta (8):
Staging: gpib: agilent_82357a: changing return type void in int
Staging: gpib: Updated return type `request_system_control`
Staging: gpib: Updated return type for `request_system_control`
Staging: gpib: Updated return type `ines_request_system_control`
Staging: gpib: Updated return type for `ines_request_system_control`
Staging: gpib: Updated return type for `request_system_control`
Staging: gpib: `request_system_control` error handling in resume
Staging: gpib: Optimize error handling in agilent_82357a_driver_resume
.../gpib/agilent_82350b/agilent_82350b.c | 3 ++-
.../gpib/agilent_82357a/agilent_82357a.c | 27 ++++++++++---------
drivers/staging/gpib/cb7210/cb7210.c | 3 ++-
drivers/staging/gpib/cec/cec_gpib.c | 3 ++-
drivers/staging/gpib/hp_82335/hp82335.c | 3 ++-
drivers/staging/gpib/hp_82341/hp_82341.c | 3 ++-
drivers/staging/gpib/include/gpib_types.h | 2 +-
drivers/staging/gpib/ines/ines.h | 2 +-
drivers/staging/gpib/ines/ines_gpib.c | 3 ++-
.../gpib/lpvo_usb_gpib/lpvo_usb_gpib.c | 3 ++-
drivers/staging/gpib/ni_usb/ni_usb_gpib.c | 8 +++---
drivers/staging/gpib/pc2/pc2_gpib.c | 3 ++-
drivers/staging/gpib/tnt4882/tnt4882_gpib.c | 3 ++-
13 files changed, 38 insertions(+), 28 deletions(-)
--
Best regards,
Thomas
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 1/8] Staging: gpib: agilent_82357a: changing return type void in int
2025-05-01 21:30 [PATCH 0/8] Staging: gpib: Update return types and error handling for request_system_control Thomas Andreatta
@ 2025-05-01 21:30 ` Thomas Andreatta
2025-05-02 7:16 ` Dan Carpenter
2025-05-01 21:30 ` [PATCH 2/8] Staging: gpib: Updated return type `request_system_control` Thomas Andreatta
` (6 subsequent siblings)
7 siblings, 1 reply; 13+ messages in thread
From: Thomas Andreatta @ 2025-05-01 21:30 UTC (permalink / raw)
To: dpenkler; +Cc: gregkh, linux-kernel, linux-staging, Thomas Andreatta
Patched FIXME request moving the return type from a void to int.
Signed-off-by: Thomas Andreatta <thomas.andreatta2000@gmail.com>
---
drivers/staging/gpib/agilent_82357a/agilent_82357a.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/staging/gpib/agilent_82357a/agilent_82357a.c b/drivers/staging/gpib/agilent_82357a/agilent_82357a.c
index da229965d98e..ce2d3850ba31 100644
--- a/drivers/staging/gpib/agilent_82357a/agilent_82357a.c
+++ b/drivers/staging/gpib/agilent_82357a/agilent_82357a.c
@@ -754,8 +754,7 @@ static int agilent_82357a_go_to_standby(struct gpib_board *board)
return 0;
}
-//FIXME should change prototype to return int
-static void agilent_82357a_request_system_control(struct gpib_board *board,
+static int agilent_82357a_request_system_control(struct gpib_board *board,
int request_control)
{
struct agilent_82357a_priv *a_priv = board->private_data;
@@ -765,7 +764,7 @@ static void agilent_82357a_request_system_control(struct gpib_board *board,
int i = 0;
if (!a_priv->bus_interface)
- return; // -ENODEV;
+ return -ENODEV;
usb_dev = interface_to_usbdev(a_priv->bus_interface);
/* 82357B needs bit to be set in 9914 AUXCR register */
@@ -785,7 +784,7 @@ static void agilent_82357a_request_system_control(struct gpib_board *board,
retval = agilent_82357a_write_registers(a_priv, writes, i);
if (retval)
dev_err(&usb_dev->dev, "write_registers() returned error\n");
- return;// retval;
+ return retval;
}
static void agilent_82357a_interface_clear(struct gpib_board *board, int assert)
--
2.34.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 2/8] Staging: gpib: Updated return type `request_system_control`
2025-05-01 21:30 [PATCH 0/8] Staging: gpib: Update return types and error handling for request_system_control Thomas Andreatta
2025-05-01 21:30 ` [PATCH 1/8] Staging: gpib: agilent_82357a: changing return type void in int Thomas Andreatta
@ 2025-05-01 21:30 ` Thomas Andreatta
2025-05-02 8:33 ` kernel test robot
2025-05-02 9:25 ` kernel test robot
2025-05-01 21:30 ` [PATCH 3/8] Staging: gpib: Updated return type for `request_system_control` Thomas Andreatta
` (5 subsequent siblings)
7 siblings, 2 replies; 13+ messages in thread
From: Thomas Andreatta @ 2025-05-01 21:30 UTC (permalink / raw)
To: dpenkler; +Cc: gregkh, linux-kernel, linux-staging, Thomas Andreatta
Update `request_system_control` type from void to int.
Signed-off-by: Thomas Andreatta <thomas.andreatta2000@gmail.com>
---
drivers/staging/gpib/include/gpib_types.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/staging/gpib/include/gpib_types.h b/drivers/staging/gpib/include/gpib_types.h
index 2d9b9be683f8..4c28f35606ef 100644
--- a/drivers/staging/gpib/include/gpib_types.h
+++ b/drivers/staging/gpib/include/gpib_types.h
@@ -93,7 +93,7 @@ struct gpib_interface_struct {
*/
int (*go_to_standby)(struct gpib_board *board);
/* request/release control of the IFC and REN lines (system controller) */
- void (*request_system_control)(struct gpib_board *board, int request_control);
+ int (*request_system_control)(struct gpib_board *board, int request_control);
/* Asserts or de-asserts 'interface clear' (IFC) depending on
* boolean value of 'assert'
*/
--
2.34.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 3/8] Staging: gpib: Updated return type for `request_system_control`
2025-05-01 21:30 [PATCH 0/8] Staging: gpib: Update return types and error handling for request_system_control Thomas Andreatta
2025-05-01 21:30 ` [PATCH 1/8] Staging: gpib: agilent_82357a: changing return type void in int Thomas Andreatta
2025-05-01 21:30 ` [PATCH 2/8] Staging: gpib: Updated return type `request_system_control` Thomas Andreatta
@ 2025-05-01 21:30 ` Thomas Andreatta
2025-05-01 21:30 ` [PATCH 4/8] Staging: gpib: Updated return type `ines_request_system_control` Thomas Andreatta
` (4 subsequent siblings)
7 siblings, 0 replies; 13+ messages in thread
From: Thomas Andreatta @ 2025-05-01 21:30 UTC (permalink / raw)
To: dpenkler; +Cc: gregkh, linux-kernel, linux-staging, Thomas Andreatta
Updated the functions used by request_system_control to return int.
Currently there's no possible return errors in the functions due to them
being former void function, for this reason they all return success (0).
Signed-off-by: Thomas Andreatta <thomas.andreatta2000@gmail.com>
---
drivers/staging/gpib/agilent_82350b/agilent_82350b.c | 3 ++-
drivers/staging/gpib/cb7210/cb7210.c | 3 ++-
drivers/staging/gpib/cec/cec_gpib.c | 3 ++-
drivers/staging/gpib/hp_82335/hp82335.c | 3 ++-
drivers/staging/gpib/hp_82341/hp_82341.c | 3 ++-
drivers/staging/gpib/lpvo_usb_gpib/lpvo_usb_gpib.c | 3 ++-
drivers/staging/gpib/pc2/pc2_gpib.c | 3 ++-
drivers/staging/gpib/tnt4882/tnt4882_gpib.c | 3 ++-
8 files changed, 16 insertions(+), 8 deletions(-)
diff --git a/drivers/staging/gpib/agilent_82350b/agilent_82350b.c b/drivers/staging/gpib/agilent_82350b/agilent_82350b.c
index 445b9380ff98..ae60bc674a85 100644
--- a/drivers/staging/gpib/agilent_82350b/agilent_82350b.c
+++ b/drivers/staging/gpib/agilent_82350b/agilent_82350b.c
@@ -339,7 +339,7 @@ static int agilent_82350b_go_to_standby(struct gpib_board *board)
return tms9914_go_to_standby(board, &priv->tms9914_priv);
}
-static void agilent_82350b_request_system_control(struct gpib_board *board,
+static int agilent_82350b_request_system_control(struct gpib_board *board,
int request_control)
{
@@ -356,6 +356,7 @@ static void agilent_82350b_request_system_control(struct gpib_board *board,
}
writeb(a_priv->card_mode_bits, a_priv->gpib_base + CARD_MODE_REG);
tms9914_request_system_control(board, &a_priv->tms9914_priv, request_control);
+ return 0;
}
static void agilent_82350b_interface_clear(struct gpib_board *board, int assert)
diff --git a/drivers/staging/gpib/cb7210/cb7210.c b/drivers/staging/gpib/cb7210/cb7210.c
index 6b22a33a8c4f..367b70fbb52c 100644
--- a/drivers/staging/gpib/cb7210/cb7210.c
+++ b/drivers/staging/gpib/cb7210/cb7210.c
@@ -578,7 +578,7 @@ static int cb7210_go_to_standby(struct gpib_board *board)
return nec7210_go_to_standby(board, &priv->nec7210_priv);
}
-static void cb7210_request_system_control(struct gpib_board *board, int request_control)
+static int cb7210_request_system_control(struct gpib_board *board, int request_control)
{
struct cb7210_priv *priv = board->private_data;
struct nec7210_priv *nec_priv = &priv->nec7210_priv;
@@ -590,6 +590,7 @@ static void cb7210_request_system_control(struct gpib_board *board, int request_
cb7210_write_byte(priv, priv->hs_mode_bits, HS_MODE);
nec7210_request_system_control(board, nec_priv, request_control);
+ return 0;
}
static void cb7210_interface_clear(struct gpib_board *board, int assert)
diff --git a/drivers/staging/gpib/cec/cec_gpib.c b/drivers/staging/gpib/cec/cec_gpib.c
index a822fa428cd0..ae05f5205b2f 100644
--- a/drivers/staging/gpib/cec/cec_gpib.c
+++ b/drivers/staging/gpib/cec/cec_gpib.c
@@ -83,11 +83,12 @@ static int cec_go_to_standby(struct gpib_board *board)
return nec7210_go_to_standby(board, &priv->nec7210_priv);
}
-static void cec_request_system_control(struct gpib_board *board, int request_control)
+static int cec_request_system_control(struct gpib_board *board, int request_control)
{
struct cec_priv *priv = board->private_data;
nec7210_request_system_control(board, &priv->nec7210_priv, request_control);
+ return 0;
}
static void cec_interface_clear(struct gpib_board *board, int assert)
diff --git a/drivers/staging/gpib/hp_82335/hp82335.c b/drivers/staging/gpib/hp_82335/hp82335.c
index fd23b1cb80f9..7a47d61cdb2a 100644
--- a/drivers/staging/gpib/hp_82335/hp82335.c
+++ b/drivers/staging/gpib/hp_82335/hp82335.c
@@ -67,11 +67,12 @@ static int hp82335_go_to_standby(struct gpib_board *board)
return tms9914_go_to_standby(board, &priv->tms9914_priv);
}
-static void hp82335_request_system_control(struct gpib_board *board, int request_control)
+static int hp82335_request_system_control(struct gpib_board *board, int request_control)
{
struct hp82335_priv *priv = board->private_data;
tms9914_request_system_control(board, &priv->tms9914_priv, request_control);
+ return 0;
}
static void hp82335_interface_clear(struct gpib_board *board, int assert)
diff --git a/drivers/staging/gpib/hp_82341/hp_82341.c b/drivers/staging/gpib/hp_82341/hp_82341.c
index f52e673dc869..fad5cca5238a 100644
--- a/drivers/staging/gpib/hp_82341/hp_82341.c
+++ b/drivers/staging/gpib/hp_82341/hp_82341.c
@@ -293,7 +293,7 @@ static int hp_82341_go_to_standby(struct gpib_board *board)
return tms9914_go_to_standby(board, &priv->tms9914_priv);
}
-static void hp_82341_request_system_control(struct gpib_board *board, int request_control)
+static int hp_82341_request_system_control(struct gpib_board *board, int request_control)
{
struct hp_82341_priv *priv = board->private_data;
@@ -303,6 +303,7 @@ static void hp_82341_request_system_control(struct gpib_board *board, int reques
priv->mode_control_bits &= ~SYSTEM_CONTROLLER_BIT;
outb(priv->mode_control_bits, priv->iobase[0] + MODE_CONTROL_STATUS_REG);
tms9914_request_system_control(board, &priv->tms9914_priv, request_control);
+ return 0;
}
static void hp_82341_interface_clear(struct gpib_board *board, int assert)
diff --git a/drivers/staging/gpib/lpvo_usb_gpib/lpvo_usb_gpib.c b/drivers/staging/gpib/lpvo_usb_gpib/lpvo_usb_gpib.c
index faf96e9cc4a1..233dcf40be39 100644
--- a/drivers/staging/gpib/lpvo_usb_gpib/lpvo_usb_gpib.c
+++ b/drivers/staging/gpib/lpvo_usb_gpib/lpvo_usb_gpib.c
@@ -909,7 +909,7 @@ static void usb_gpib_remote_enable(struct gpib_board *board, int enable)
/* request_system_control */
-static void usb_gpib_request_system_control(struct gpib_board *board,
+static int usb_gpib_request_system_control(struct gpib_board *board,
int request_control)
{
if (request_control)
@@ -918,6 +918,7 @@ static void usb_gpib_request_system_control(struct gpib_board *board,
clear_bit(CIC_NUM, &board->status);
DIA_LOG(1, "done with %d -> %lx\n", request_control, board->status);
+ return 0;
}
/* take_control */
diff --git a/drivers/staging/gpib/pc2/pc2_gpib.c b/drivers/staging/gpib/pc2/pc2_gpib.c
index 96d3c09f2273..324d323b4240 100644
--- a/drivers/staging/gpib/pc2/pc2_gpib.c
+++ b/drivers/staging/gpib/pc2/pc2_gpib.c
@@ -127,11 +127,12 @@ static int pc2_go_to_standby(struct gpib_board *board)
return nec7210_go_to_standby(board, &priv->nec7210_priv);
}
-static void pc2_request_system_control(struct gpib_board *board, int request_control)
+static int pc2_request_system_control(struct gpib_board *board, int request_control)
{
struct pc2_priv *priv = board->private_data;
nec7210_request_system_control(board, &priv->nec7210_priv, request_control);
+ return 0;
}
static void pc2_interface_clear(struct gpib_board *board, int assert)
diff --git a/drivers/staging/gpib/tnt4882/tnt4882_gpib.c b/drivers/staging/gpib/tnt4882/tnt4882_gpib.c
index c35b084b6fd0..62950518fe49 100644
--- a/drivers/staging/gpib/tnt4882/tnt4882_gpib.c
+++ b/drivers/staging/gpib/tnt4882/tnt4882_gpib.c
@@ -642,7 +642,7 @@ static int tnt4882_go_to_standby(struct gpib_board *board)
return nec7210_go_to_standby(board, &priv->nec7210_priv);
}
-static void tnt4882_request_system_control(struct gpib_board *board, int request_control)
+static int tnt4882_request_system_control(struct gpib_board *board, int request_control)
{
struct tnt4882_priv *priv = board->private_data;
@@ -655,6 +655,7 @@ static void tnt4882_request_system_control(struct gpib_board *board, int request
tnt_writeb(priv, CLRSC, CMDR);
udelay(1);
}
+ return 0;
}
static void tnt4882_interface_clear(struct gpib_board *board, int assert)
--
2.34.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 4/8] Staging: gpib: Updated return type `ines_request_system_control`
2025-05-01 21:30 [PATCH 0/8] Staging: gpib: Update return types and error handling for request_system_control Thomas Andreatta
` (2 preceding siblings ...)
2025-05-01 21:30 ` [PATCH 3/8] Staging: gpib: Updated return type for `request_system_control` Thomas Andreatta
@ 2025-05-01 21:30 ` Thomas Andreatta
2025-05-01 21:30 ` [PATCH 5/8] Staging: gpib: Updated return type for `ines_request_system_control` Thomas Andreatta
` (3 subsequent siblings)
7 siblings, 0 replies; 13+ messages in thread
From: Thomas Andreatta @ 2025-05-01 21:30 UTC (permalink / raw)
To: dpenkler; +Cc: gregkh, linux-kernel, linux-staging, Thomas Andreatta
Update `ines_request_system_control` type from void to int.
Signed-off-by: Thomas Andreatta <thomas.andreatta2000@gmail.com>
---
drivers/staging/gpib/ines/ines.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/staging/gpib/ines/ines.h b/drivers/staging/gpib/ines/ines.h
index ff27f055a0ff..a82b9cd93129 100644
--- a/drivers/staging/gpib/ines/ines.h
+++ b/drivers/staging/gpib/ines/ines.h
@@ -46,7 +46,7 @@ int ines_accel_write(struct gpib_board *board, uint8_t *buffer, size_t length,
int ines_command(struct gpib_board *board, uint8_t *buffer, size_t length, size_t *bytes_written);
int ines_take_control(struct gpib_board *board, int synchronous);
int ines_go_to_standby(struct gpib_board *board);
-void ines_request_system_control(struct gpib_board *board, int request_control);
+int ines_request_system_control(struct gpib_board *board, int request_control);
void ines_interface_clear(struct gpib_board *board, int assert);
void ines_remote_enable(struct gpib_board *board, int enable);
int ines_enable_eos(struct gpib_board *board, uint8_t eos_byte, int compare_8_bits);
--
2.34.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 5/8] Staging: gpib: Updated return type for `ines_request_system_control`
2025-05-01 21:30 [PATCH 0/8] Staging: gpib: Update return types and error handling for request_system_control Thomas Andreatta
` (3 preceding siblings ...)
2025-05-01 21:30 ` [PATCH 4/8] Staging: gpib: Updated return type `ines_request_system_control` Thomas Andreatta
@ 2025-05-01 21:30 ` Thomas Andreatta
2025-05-01 21:30 ` [PATCH 6/8] Staging: gpib: Updated return type for `request_system_control` Thomas Andreatta
` (2 subsequent siblings)
7 siblings, 0 replies; 13+ messages in thread
From: Thomas Andreatta @ 2025-05-01 21:30 UTC (permalink / raw)
To: dpenkler; +Cc: gregkh, linux-kernel, linux-staging, Thomas Andreatta
Updated the functions used by ines_request_system_control to return int.
Currently there's no possible return errors in the functions due to them
being former void function, for this reason they all return success (0).
Signed-off-by: Thomas Andreatta <thomas.andreatta2000@gmail.com>
---
drivers/staging/gpib/ines/ines_gpib.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/staging/gpib/ines/ines_gpib.c b/drivers/staging/gpib/ines/ines_gpib.c
index d93eb05dab90..2ca1b8659ab4 100644
--- a/drivers/staging/gpib/ines/ines_gpib.c
+++ b/drivers/staging/gpib/ines/ines_gpib.c
@@ -441,11 +441,12 @@ int ines_go_to_standby(struct gpib_board *board)
return nec7210_go_to_standby(board, &priv->nec7210_priv);
}
-void ines_request_system_control(struct gpib_board *board, int request_control)
+int ines_request_system_control(struct gpib_board *board, int request_control)
{
struct ines_priv *priv = board->private_data;
nec7210_request_system_control(board, &priv->nec7210_priv, request_control);
+ return 0;
}
void ines_interface_clear(struct gpib_board *board, int assert)
--
2.34.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 6/8] Staging: gpib: Updated return type for `request_system_control`
2025-05-01 21:30 [PATCH 0/8] Staging: gpib: Update return types and error handling for request_system_control Thomas Andreatta
` (4 preceding siblings ...)
2025-05-01 21:30 ` [PATCH 5/8] Staging: gpib: Updated return type for `ines_request_system_control` Thomas Andreatta
@ 2025-05-01 21:30 ` Thomas Andreatta
2025-05-01 21:30 ` [PATCH 7/8] Staging: gpib: `request_system_control` error handling in resume Thomas Andreatta
2025-05-01 21:30 ` [PATCH 8/8] Staging: gpib: Optimize error handling in agilent_82357a_driver_resume Thomas Andreatta
7 siblings, 0 replies; 13+ messages in thread
From: Thomas Andreatta @ 2025-05-01 21:30 UTC (permalink / raw)
To: dpenkler; +Cc: gregkh, linux-kernel, linux-staging, Thomas Andreatta
Function `ni_usb_request_system_control` used by
`request_system_control` now returns int.
Reinstated return values by removing comments from previously
commented-out return statements.
Signed-off-by: Thomas Andreatta <thomas.andreatta2000@gmail.com>
---
drivers/staging/gpib/ni_usb/ni_usb_gpib.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/staging/gpib/ni_usb/ni_usb_gpib.c b/drivers/staging/gpib/ni_usb/ni_usb_gpib.c
index 9f1b9927f025..a41e4f472d89 100644
--- a/drivers/staging/gpib/ni_usb/ni_usb_gpib.c
+++ b/drivers/staging/gpib/ni_usb/ni_usb_gpib.c
@@ -1049,7 +1049,7 @@ static int ni_usb_go_to_standby(struct gpib_board *board)
return 0;
}
-static void ni_usb_request_system_control(struct gpib_board *board, int request_control)
+static int ni_usb_request_system_control(struct gpib_board *board, int request_control)
{
int retval;
struct ni_usb_priv *ni_priv = board->private_data;
@@ -1059,7 +1059,7 @@ static void ni_usb_request_system_control(struct gpib_board *board, int request_
unsigned int ibsta;
if (!ni_priv->bus_interface)
- return; // -ENODEV;
+ return -ENODEV;
usb_dev = interface_to_usbdev(ni_priv->bus_interface);
if (request_control) {
writes[i].device = NIUSB_SUBDEV_TNT4882;
@@ -1091,12 +1091,12 @@ static void ni_usb_request_system_control(struct gpib_board *board, int request_
retval = ni_usb_write_registers(ni_priv, writes, i, &ibsta);
if (retval < 0) {
dev_err(&usb_dev->dev, "register write failed, retval=%i\n", retval);
- return; // retval;
+ return retval;
}
if (!request_control)
ni_priv->ren_state = 0;
ni_usb_soft_update_status(board, ibsta, 0);
- return; // 0;
+ return 0;
}
//FIXME maybe the interface should have a "pulse interface clear" function that can return an error?
--
2.34.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 7/8] Staging: gpib: `request_system_control` error handling in resume
2025-05-01 21:30 [PATCH 0/8] Staging: gpib: Update return types and error handling for request_system_control Thomas Andreatta
` (5 preceding siblings ...)
2025-05-01 21:30 ` [PATCH 6/8] Staging: gpib: Updated return type for `request_system_control` Thomas Andreatta
@ 2025-05-01 21:30 ` Thomas Andreatta
2025-05-01 21:30 ` [PATCH 8/8] Staging: gpib: Optimize error handling in agilent_82357a_driver_resume Thomas Andreatta
7 siblings, 0 replies; 13+ messages in thread
From: Thomas Andreatta @ 2025-05-01 21:30 UTC (permalink / raw)
To: dpenkler; +Cc: gregkh, linux-kernel, linux-staging, Thomas Andreatta
Function `agilent_82357a_driver_resume` now handles the return value of
`agilent_82357a_request_system_control` unlocking and returning error in case
of failure.
Signed-off-by: Thomas Andreatta <thomas.andreatta2000@gmail.com>
---
drivers/staging/gpib/agilent_82357a/agilent_82357a.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/staging/gpib/agilent_82357a/agilent_82357a.c b/drivers/staging/gpib/agilent_82357a/agilent_82357a.c
index ce2d3850ba31..4fdf6d42f63e 100644
--- a/drivers/staging/gpib/agilent_82357a/agilent_82357a.c
+++ b/drivers/staging/gpib/agilent_82357a/agilent_82357a.c
@@ -1625,7 +1625,13 @@ static int agilent_82357a_driver_resume(struct usb_interface *interface)
return retval;
}
// set/unset system controller
- agilent_82357a_request_system_control(board, board->master);
+ retval = agilent_82357a_request_system_control(board, board->master);
+ if (retval) {
+ dev_err(&usb_dev->dev, "failed to request system control in resume, retval=%i\n",
+ retval);
+ mutex_unlock(&agilent_82357a_hotplug_lock);
+ return retval;
+ }
// toggle ifc if master
if (board->master) {
agilent_82357a_interface_clear(board, 1);
--
2.34.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 8/8] Staging: gpib: Optimize error handling in agilent_82357a_driver_resume
2025-05-01 21:30 [PATCH 0/8] Staging: gpib: Update return types and error handling for request_system_control Thomas Andreatta
` (6 preceding siblings ...)
2025-05-01 21:30 ` [PATCH 7/8] Staging: gpib: `request_system_control` error handling in resume Thomas Andreatta
@ 2025-05-01 21:30 ` Thomas Andreatta
7 siblings, 0 replies; 13+ messages in thread
From: Thomas Andreatta @ 2025-05-01 21:30 UTC (permalink / raw)
To: dpenkler; +Cc: gregkh, linux-kernel, linux-staging, Thomas Andreatta
Refactor the agilent_82357a_driver_resume function to consistently use
the resume_exit label for all error paths. Initialize retval to 0 at the
beginning of the function and return it at the end, ensuring the mutex is
always properly unlocked regardless of the execution path.
Simplifies error handling and fixes potential mutex lock leaks by
ensuring all code paths go through the same cleanup code.
Signed-off-by: Thomas Andreatta <thomas.andreatta2000@gmail.com>
---
.../staging/gpib/agilent_82357a/agilent_82357a.c | 16 ++++++----------
1 file changed, 6 insertions(+), 10 deletions(-)
diff --git a/drivers/staging/gpib/agilent_82357a/agilent_82357a.c b/drivers/staging/gpib/agilent_82357a/agilent_82357a.c
index 4fdf6d42f63e..92bbdd57083f 100644
--- a/drivers/staging/gpib/agilent_82357a/agilent_82357a.c
+++ b/drivers/staging/gpib/agilent_82357a/agilent_82357a.c
@@ -1590,7 +1590,7 @@ static int agilent_82357a_driver_resume(struct usb_interface *interface)
{
struct usb_device *usb_dev = interface_to_usbdev(interface);
struct gpib_board *board;
- int i, retval;
+ int i, retval = 0;
mutex_lock(&agilent_82357a_hotplug_lock);
@@ -1614,23 +1614,19 @@ static int agilent_82357a_driver_resume(struct usb_interface *interface)
dev_err(&usb_dev->dev, "failed to resubmit interrupt urb in resume, retval=%i\n",
retval);
mutex_unlock(&a_priv->interrupt_alloc_lock);
- mutex_unlock(&agilent_82357a_hotplug_lock);
- return retval;
+ goto resume_exit;
}
mutex_unlock(&a_priv->interrupt_alloc_lock);
}
retval = agilent_82357a_init(board);
- if (retval < 0) {
- mutex_unlock(&agilent_82357a_hotplug_lock);
- return retval;
- }
+ if (retval < 0)
+ goto resume_exit;
// set/unset system controller
retval = agilent_82357a_request_system_control(board, board->master);
if (retval) {
dev_err(&usb_dev->dev, "failed to request system control in resume, retval=%i\n",
retval);
- mutex_unlock(&agilent_82357a_hotplug_lock);
- return retval;
+ goto resume_exit;
}
// toggle ifc if master
if (board->master) {
@@ -1649,7 +1645,7 @@ static int agilent_82357a_driver_resume(struct usb_interface *interface)
resume_exit:
mutex_unlock(&agilent_82357a_hotplug_lock);
- return 0;
+ return retval;
}
static struct usb_driver agilent_82357a_bus_driver = {
--
2.34.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH 1/8] Staging: gpib: agilent_82357a: changing return type void in int
2025-05-01 21:30 ` [PATCH 1/8] Staging: gpib: agilent_82357a: changing return type void in int Thomas Andreatta
@ 2025-05-02 7:16 ` Dan Carpenter
2025-05-02 7:35 ` Thomas Andreatta
0 siblings, 1 reply; 13+ messages in thread
From: Dan Carpenter @ 2025-05-02 7:16 UTC (permalink / raw)
To: Thomas Andreatta
Cc: dpenkler, gregkh, linux-kernel, linux-staging, Thomas Andreatta
This patch will break the build. Also you need to work against
linux-next. Dave Penkler already did this work.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 1/8] Staging: gpib: agilent_82357a: changing return type void in int
2025-05-02 7:16 ` Dan Carpenter
@ 2025-05-02 7:35 ` Thomas Andreatta
0 siblings, 0 replies; 13+ messages in thread
From: Thomas Andreatta @ 2025-05-02 7:35 UTC (permalink / raw)
To: dan.carpenter
Cc: dpenkler, gregkh, linux-kernel, linux-staging,
thomas.andreatta2000, thomasandreatta2000
My bad.
Thanks for the nudge!
Best,
Thomas
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 2/8] Staging: gpib: Updated return type `request_system_control`
2025-05-01 21:30 ` [PATCH 2/8] Staging: gpib: Updated return type `request_system_control` Thomas Andreatta
@ 2025-05-02 8:33 ` kernel test robot
2025-05-02 9:25 ` kernel test robot
1 sibling, 0 replies; 13+ messages in thread
From: kernel test robot @ 2025-05-02 8:33 UTC (permalink / raw)
To: Thomas Andreatta, dpenkler
Cc: oe-kbuild-all, gregkh, linux-kernel, linux-staging,
Thomas Andreatta
Hi Thomas,
kernel test robot noticed the following build errors:
[auto build test ERROR on staging/staging-linus]
[also build test ERROR on linus/master v6.15-rc4]
[cannot apply to staging/staging-testing staging/staging-next next-20250501]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Thomas-Andreatta/Staging-gpib-agilent_82357a-changing-return-type-void-in-int/20250502-053306
base: staging/staging-linus
patch link: https://lore.kernel.org/r/28632a0bf5275553e929e8699830377069e921fa.1746133676.git.thomas.andreatta2000%40gmail.com
patch subject: [PATCH 2/8] Staging: gpib: Updated return type `request_system_control`
config: arm64-randconfig-003-20250502 (https://download.01.org/0day-ci/archive/20250502/202505021518.8HGGOavD-lkp@intel.com/config)
compiler: aarch64-linux-gcc (GCC) 8.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250502/202505021518.8HGGOavD-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202505021518.8HGGOavD-lkp@intel.com/
All errors (new ones prefixed by >>):
>> drivers/staging/gpib/eastwood/fluke_gpib.c:710:28: error: initialization of 'int (*)(struct gpib_board *, int)' from incompatible pointer type 'void (*)(struct gpib_board *, int)' [-Werror=incompatible-pointer-types]
.request_system_control = fluke_request_system_control,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/staging/gpib/eastwood/fluke_gpib.c:710:28: note: (near initialization for 'fluke_unaccel_interface.request_system_control')
drivers/staging/gpib/eastwood/fluke_gpib.c:745:28: error: initialization of 'int (*)(struct gpib_board *, int)' from incompatible pointer type 'void (*)(struct gpib_board *, int)' [-Werror=incompatible-pointer-types]
.request_system_control = fluke_request_system_control,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/staging/gpib/eastwood/fluke_gpib.c:745:28: note: (near initialization for 'fluke_hybrid_interface.request_system_control')
drivers/staging/gpib/eastwood/fluke_gpib.c:772:28: error: initialization of 'int (*)(struct gpib_board *, int)' from incompatible pointer type 'void (*)(struct gpib_board *, int)' [-Werror=incompatible-pointer-types]
.request_system_control = fluke_request_system_control,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/staging/gpib/eastwood/fluke_gpib.c:772:28: note: (near initialization for 'fluke_interface.request_system_control')
cc1: some warnings being treated as errors
--
>> drivers/staging/gpib/fmh_gpib/fmh_gpib.c:1023:28: error: initialization of 'int (*)(struct gpib_board *, int)' from incompatible pointer type 'void (*)(struct gpib_board *, int)' [-Werror=incompatible-pointer-types]
.request_system_control = fmh_gpib_request_system_control,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/staging/gpib/fmh_gpib/fmh_gpib.c:1023:28: note: (near initialization for 'fmh_gpib_unaccel_interface.request_system_control')
drivers/staging/gpib/fmh_gpib/fmh_gpib.c:1051:28: error: initialization of 'int (*)(struct gpib_board *, int)' from incompatible pointer type 'void (*)(struct gpib_board *, int)' [-Werror=incompatible-pointer-types]
.request_system_control = fmh_gpib_request_system_control,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/staging/gpib/fmh_gpib/fmh_gpib.c:1051:28: note: (near initialization for 'fmh_gpib_interface.request_system_control')
drivers/staging/gpib/fmh_gpib/fmh_gpib.c:1079:28: error: initialization of 'int (*)(struct gpib_board *, int)' from incompatible pointer type 'void (*)(struct gpib_board *, int)' [-Werror=incompatible-pointer-types]
.request_system_control = fmh_gpib_request_system_control,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/staging/gpib/fmh_gpib/fmh_gpib.c:1079:28: note: (near initialization for 'fmh_gpib_pci_interface.request_system_control')
drivers/staging/gpib/fmh_gpib/fmh_gpib.c:1107:28: error: initialization of 'int (*)(struct gpib_board *, int)' from incompatible pointer type 'void (*)(struct gpib_board *, int)' [-Werror=incompatible-pointer-types]
.request_system_control = fmh_gpib_request_system_control,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/staging/gpib/fmh_gpib/fmh_gpib.c:1107:28: note: (near initialization for 'fmh_gpib_pci_unaccel_interface.request_system_control')
cc1: some warnings being treated as errors
vim +710 drivers/staging/gpib/eastwood/fluke_gpib.c
55936779f49612 Dave Penkler 2024-09-18 700
95cfc75234534b Dave Penkler 2025-01-11 701 static gpib_interface_t fluke_unaccel_interface = {
95cfc75234534b Dave Penkler 2025-01-11 702 .name = "fluke_unaccel",
95cfc75234534b Dave Penkler 2025-01-11 703 .attach = fluke_attach_holdoff_all,
95cfc75234534b Dave Penkler 2025-01-11 704 .detach = fluke_detach,
95cfc75234534b Dave Penkler 2025-01-11 705 .read = fluke_read,
95cfc75234534b Dave Penkler 2025-01-11 706 .write = fluke_write,
95cfc75234534b Dave Penkler 2025-01-11 707 .command = fluke_command,
95cfc75234534b Dave Penkler 2025-01-11 708 .take_control = fluke_take_control,
95cfc75234534b Dave Penkler 2025-01-11 709 .go_to_standby = fluke_go_to_standby,
95cfc75234534b Dave Penkler 2025-01-11 @710 .request_system_control = fluke_request_system_control,
95cfc75234534b Dave Penkler 2025-01-11 711 .interface_clear = fluke_interface_clear,
95cfc75234534b Dave Penkler 2025-01-11 712 .remote_enable = fluke_remote_enable,
95cfc75234534b Dave Penkler 2025-01-11 713 .enable_eos = fluke_enable_eos,
95cfc75234534b Dave Penkler 2025-01-11 714 .disable_eos = fluke_disable_eos,
95cfc75234534b Dave Penkler 2025-01-11 715 .parallel_poll = fluke_parallel_poll,
95cfc75234534b Dave Penkler 2025-01-11 716 .parallel_poll_configure = fluke_parallel_poll_configure,
95cfc75234534b Dave Penkler 2025-01-11 717 .parallel_poll_response = fluke_parallel_poll_response,
95cfc75234534b Dave Penkler 2025-01-11 718 .line_status = fluke_line_status,
95cfc75234534b Dave Penkler 2025-01-11 719 .update_status = fluke_update_status,
95cfc75234534b Dave Penkler 2025-01-11 720 .primary_address = fluke_primary_address,
95cfc75234534b Dave Penkler 2025-01-11 721 .secondary_address = fluke_secondary_address,
95cfc75234534b Dave Penkler 2025-01-11 722 .serial_poll_response = fluke_serial_poll_response,
95cfc75234534b Dave Penkler 2025-01-11 723 .serial_poll_status = fluke_serial_poll_status,
95cfc75234534b Dave Penkler 2025-01-11 724 .t1_delay = fluke_t1_delay,
95cfc75234534b Dave Penkler 2025-01-11 725 .return_to_local = fluke_return_to_local,
55936779f49612 Dave Penkler 2024-09-18 726 };
55936779f49612 Dave Penkler 2024-09-18 727
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 2/8] Staging: gpib: Updated return type `request_system_control`
2025-05-01 21:30 ` [PATCH 2/8] Staging: gpib: Updated return type `request_system_control` Thomas Andreatta
2025-05-02 8:33 ` kernel test robot
@ 2025-05-02 9:25 ` kernel test robot
1 sibling, 0 replies; 13+ messages in thread
From: kernel test robot @ 2025-05-02 9:25 UTC (permalink / raw)
To: Thomas Andreatta, dpenkler
Cc: llvm, oe-kbuild-all, gregkh, linux-kernel, linux-staging,
Thomas Andreatta
Hi Thomas,
kernel test robot noticed the following build errors:
[auto build test ERROR on staging/staging-linus]
[also build test ERROR on linus/master v6.15-rc4]
[cannot apply to staging/staging-testing staging/staging-next next-20250501]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Thomas-Andreatta/Staging-gpib-agilent_82357a-changing-return-type-void-in-int/20250502-053306
base: staging/staging-linus
patch link: https://lore.kernel.org/r/28632a0bf5275553e929e8699830377069e921fa.1746133676.git.thomas.andreatta2000%40gmail.com
patch subject: [PATCH 2/8] Staging: gpib: Updated return type `request_system_control`
config: arm-randconfig-004-20250502 (https://download.01.org/0day-ci/archive/20250502/202505021632.3PmPalr1-lkp@intel.com/config)
compiler: clang version 20.1.2 (https://github.com/llvm/llvm-project 58df0ef89dd64126512e4ee27b4ac3fd8ddf6247)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250502/202505021632.3PmPalr1-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202505021632.3PmPalr1-lkp@intel.com/
All errors (new ones prefixed by >>):
>> drivers/staging/gpib/eastwood/fluke_gpib.c:710:28: error: incompatible function pointer types initializing 'int (*)(struct gpib_board *, int)' with an expression of type 'void (struct gpib_board *, int)' [-Wincompatible-function-pointer-types]
710 | .request_system_control = fluke_request_system_control,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/staging/gpib/eastwood/fluke_gpib.c:745:28: error: incompatible function pointer types initializing 'int (*)(struct gpib_board *, int)' with an expression of type 'void (struct gpib_board *, int)' [-Wincompatible-function-pointer-types]
745 | .request_system_control = fluke_request_system_control,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/staging/gpib/eastwood/fluke_gpib.c:772:28: error: incompatible function pointer types initializing 'int (*)(struct gpib_board *, int)' with an expression of type 'void (struct gpib_board *, int)' [-Wincompatible-function-pointer-types]
772 | .request_system_control = fluke_request_system_control,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
3 errors generated.
vim +710 drivers/staging/gpib/eastwood/fluke_gpib.c
55936779f49612 Dave Penkler 2024-09-18 700
95cfc75234534b Dave Penkler 2025-01-11 701 static gpib_interface_t fluke_unaccel_interface = {
95cfc75234534b Dave Penkler 2025-01-11 702 .name = "fluke_unaccel",
95cfc75234534b Dave Penkler 2025-01-11 703 .attach = fluke_attach_holdoff_all,
95cfc75234534b Dave Penkler 2025-01-11 704 .detach = fluke_detach,
95cfc75234534b Dave Penkler 2025-01-11 705 .read = fluke_read,
95cfc75234534b Dave Penkler 2025-01-11 706 .write = fluke_write,
95cfc75234534b Dave Penkler 2025-01-11 707 .command = fluke_command,
95cfc75234534b Dave Penkler 2025-01-11 708 .take_control = fluke_take_control,
95cfc75234534b Dave Penkler 2025-01-11 709 .go_to_standby = fluke_go_to_standby,
95cfc75234534b Dave Penkler 2025-01-11 @710 .request_system_control = fluke_request_system_control,
95cfc75234534b Dave Penkler 2025-01-11 711 .interface_clear = fluke_interface_clear,
95cfc75234534b Dave Penkler 2025-01-11 712 .remote_enable = fluke_remote_enable,
95cfc75234534b Dave Penkler 2025-01-11 713 .enable_eos = fluke_enable_eos,
95cfc75234534b Dave Penkler 2025-01-11 714 .disable_eos = fluke_disable_eos,
95cfc75234534b Dave Penkler 2025-01-11 715 .parallel_poll = fluke_parallel_poll,
95cfc75234534b Dave Penkler 2025-01-11 716 .parallel_poll_configure = fluke_parallel_poll_configure,
95cfc75234534b Dave Penkler 2025-01-11 717 .parallel_poll_response = fluke_parallel_poll_response,
95cfc75234534b Dave Penkler 2025-01-11 718 .line_status = fluke_line_status,
95cfc75234534b Dave Penkler 2025-01-11 719 .update_status = fluke_update_status,
95cfc75234534b Dave Penkler 2025-01-11 720 .primary_address = fluke_primary_address,
95cfc75234534b Dave Penkler 2025-01-11 721 .secondary_address = fluke_secondary_address,
95cfc75234534b Dave Penkler 2025-01-11 722 .serial_poll_response = fluke_serial_poll_response,
95cfc75234534b Dave Penkler 2025-01-11 723 .serial_poll_status = fluke_serial_poll_status,
95cfc75234534b Dave Penkler 2025-01-11 724 .t1_delay = fluke_t1_delay,
95cfc75234534b Dave Penkler 2025-01-11 725 .return_to_local = fluke_return_to_local,
55936779f49612 Dave Penkler 2024-09-18 726 };
55936779f49612 Dave Penkler 2024-09-18 727
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2025-05-02 9:26 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-01 21:30 [PATCH 0/8] Staging: gpib: Update return types and error handling for request_system_control Thomas Andreatta
2025-05-01 21:30 ` [PATCH 1/8] Staging: gpib: agilent_82357a: changing return type void in int Thomas Andreatta
2025-05-02 7:16 ` Dan Carpenter
2025-05-02 7:35 ` Thomas Andreatta
2025-05-01 21:30 ` [PATCH 2/8] Staging: gpib: Updated return type `request_system_control` Thomas Andreatta
2025-05-02 8:33 ` kernel test robot
2025-05-02 9:25 ` kernel test robot
2025-05-01 21:30 ` [PATCH 3/8] Staging: gpib: Updated return type for `request_system_control` Thomas Andreatta
2025-05-01 21:30 ` [PATCH 4/8] Staging: gpib: Updated return type `ines_request_system_control` Thomas Andreatta
2025-05-01 21:30 ` [PATCH 5/8] Staging: gpib: Updated return type for `ines_request_system_control` Thomas Andreatta
2025-05-01 21:30 ` [PATCH 6/8] Staging: gpib: Updated return type for `request_system_control` Thomas Andreatta
2025-05-01 21:30 ` [PATCH 7/8] Staging: gpib: `request_system_control` error handling in resume Thomas Andreatta
2025-05-01 21:30 ` [PATCH 8/8] Staging: gpib: Optimize error handling in agilent_82357a_driver_resume Thomas Andreatta
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox