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. Replace kmalloc/memset pairs to kzalloc.
Signed-off-by: Dominik Karol Piątkowski <dominik.karol.piatkowski@protonmail.com>
---
v2: Replace kmalloc/memset pairs to kzalloc.
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