[PATCH v6 08/15] staging: gpib: gpio: Return error value from gpib_register_driver()

From: Nihar Chaithanya
Date: Mon Dec 30 2024 - 14:11:13 EST


The function gpib_register_driver() can fail and does not return an
error value if it fails.

Return the error value if gpib_register_driver() fails. Add pr_err()
statement indicating the fail and also the error value.

Signed-off-by: Nihar Chaithanya <niharchaithanya@xxxxxxxxx>
---
drivers/staging/gpib/gpio/gpib_bitbang.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/gpib/gpio/gpib_bitbang.c b/drivers/staging/gpib/gpio/gpib_bitbang.c
index a2d562cbd65b..057f9264de34 100644
--- a/drivers/staging/gpib/gpio/gpib_bitbang.c
+++ b/drivers/staging/gpib/gpio/gpib_bitbang.c
@@ -1341,7 +1341,12 @@ return_to_local : bb_return_to_local,

static int __init bb_init_module(void)
{
- gpib_register_driver(&bb_interface, THIS_MODULE);
+ int result = gpib_register_driver(&bb_interface, THIS_MODULE);
+
+ if (result) {
+ pr_err("gpib_bitbang: gpib_register_driver failed: error = %d\n", result);
+ return result;
+ }

dbg_printk(0, "module loaded with pin map \"%s\"%s\n",
pin_map, (sn7516x_used) ? " and SN7516x driver support" : "");
--
2.34.1