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/ines/ines_gpib.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/drivers/gpib/ines/ines_gpib.c b/drivers/gpib/ines/ines_gpib.c
index a3cf846fd0f9..4a87c79f218b 100644
--- a/drivers/gpib/ines/ines_gpib.c
+++ b/drivers/gpib/ines/ines_gpib.c
@@ -657,11 +657,10 @@ static int ines_allocate_private(struct gpib_board *board)
{
struct ines_priv *priv;
- board->private_data = kmalloc(sizeof(struct ines_priv), GFP_KERNEL);
+ board->private_data = kzalloc(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);
return 0;
}
@@ -676,11 +675,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