mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Dominik Karol Piątkowski" <dominik.karol.piatkowski@protonmail.com>
To: Dave Penkler <dpenkler@gmail.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Michael Rubin <matchstick@neverthere.org>,
	Dan Carpenter <dan.carpenter@linaro.org>
Cc: linux-kernel@vger.kernel.org,
	"Dominik Karol Piątkowski"
	<dominik.karol.piatkowski@protonmail.com>
Subject: [PATCH v2 06/12] gpib: gpio: Unify *allocate_private
Date: Thu, 15 Jan 2026 19:20:34 +0000	[thread overview]
Message-ID: <20260115191925.52268-7-dominik.karol.piatkowski@protonmail.com> (raw)
In-Reply-To: <20260115191925.52268-1-dominik.karol.piatkowski@protonmail.com>

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



  parent reply	other threads:[~2026-01-15 19:20 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-15 19:20 [PATCH v2 00/12] gpib: " Dominik Karol Piątkowski
2026-01-15 19:20 ` [PATCH v2 01/12] gpib: agilent_82350b: " Dominik Karol Piątkowski
2026-01-16  7:34   ` Greg Kroah-Hartman
2026-01-16  7:35   ` Greg Kroah-Hartman
2026-01-15 19:20 ` [PATCH v2 02/12] gpib: cb7210: " Dominik Karol Piątkowski
2026-01-15 19:20 ` [PATCH v2 03/12] gpib: cec: " Dominik Karol Piątkowski
2026-01-15 19:20 ` [PATCH v2 04/12] gpib: eastwood: " Dominik Karol Piątkowski
2026-01-15 19:20 ` [PATCH v2 05/12] gpib: fmh_gpib: " Dominik Karol Piątkowski
2026-01-15 19:20 ` Dominik Karol Piątkowski [this message]
2026-01-15 19:20 ` [PATCH v2 07/12] gpib: hp_82335: " Dominik Karol Piątkowski
2026-01-15 19:20 ` [PATCH v2 08/12] gpib: hp_82341: " Dominik Karol Piątkowski
2026-01-15 19:20 ` [PATCH v2 09/12] gpib: ines: " Dominik Karol Piątkowski
2026-01-15 19:20 ` [PATCH v2 10/12] gpib: ni_usb: " Dominik Karol Piątkowski
2026-01-15 19:21 ` [PATCH v2 11/12] gpib: pc2: " Dominik Karol Piątkowski
2026-01-15 19:21 ` [PATCH v2 12/12] gpib: tnt4882: " Dominik Karol Piątkowski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260115191925.52268-7-dominik.karol.piatkowski@protonmail.com \
    --to=dominik.karol.piatkowski@protonmail.com \
    --cc=dan.carpenter@linaro.org \
    --cc=dpenkler@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matchstick@neverthere.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®