[PATCH v2] staging: gpib: cb7210: Add error handling

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The if condition in cb7210_init_module() would always fail as
the value of err is constantly 0. The function
cb_pcmcia_init_module() can be refactored into a single line,
and can be replaced entirely with pcmcia_register_driver().

Replace redundant cb_pcmcia_init_module() with
pcmcia_register_driver() which returns appropriate error code if
it fails. Handle the error if it fails and print the debug message.

This issue was reported by Coverity Scan.
Report:
CID 1635894: (#1 of 1): 'Constant' variable guards dead code (DEADCODE)
dead_error_line: Execution cannot reach this statement: return -1;.

Signed-off-by: Nihar Chaithanya <niharchaithanya@xxxxxxxxx>
---
v1 --> v2: Replaced the redundant cb_pcmcia_init_module() with
	   pcmcia_register_driver().

 drivers/staging/gpib/cb7210/cb7210.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/gpib/cb7210/cb7210.c b/drivers/staging/gpib/cb7210/cb7210.c
index 63df7f3eb3f3..abd6632d8448 100644
--- a/drivers/staging/gpib/cb7210/cb7210.c
+++ b/drivers/staging/gpib/cb7210/cb7210.c
@@ -1351,12 +1351,6 @@ static struct pcmcia_driver cb_gpib_cs_driver = {
 	.resume		= cb_gpib_resume,
 };
 
-int cb_pcmcia_init_module(void)
-{
-	pcmcia_register_driver(&cb_gpib_cs_driver);
-	return 0;
-}
-
 void cb_pcmcia_cleanup_module(void)
 {
 	DEBUG(0, "cb_gpib_cs: unloading\n");
@@ -1526,11 +1520,12 @@ static int __init cb7210_init_module(void)
 	gpib_register_driver(&cb_pcmcia_interface, THIS_MODULE);
 	gpib_register_driver(&cb_pcmcia_accel_interface, THIS_MODULE);
 	gpib_register_driver(&cb_pcmcia_unaccel_interface, THIS_MODULE);
-	err += cb_pcmcia_init_module();
+	err = pcmcia_register_driver(&cb_gpib_cs_driver);
 #endif
-	if (err)
+	if (err) {
+		pr_err("cb7210: registering PCMCIA driver with the bus core failed\n");
 		return -1;
-
+	}
 	return 0;
 }
 
-- 
2.34.1





[Index of Archives]     [Linux Driver Development]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux