[PATCH v2 07/12] gpib: hp_82335: Unify *allocate_private

Dominik Karol Piątkowski posted 12 patches 3 weeks, 3 days ago
There is a newer version of this series
[PATCH v2 07/12] gpib: hp_82335: Unify *allocate_private
Posted by Dominik Karol Piątkowski 3 weeks, 3 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. 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/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