[PATCH v2 3/7] staging: unisys: cleanup goto in create_visor_device()

2016-02-23 Thread Benjamin Romer
Get rid of the rc = -1 initialization. Return a meaningful error on
failure in the function, or, the rc from a called function if it fails.

Signed-off-by: Benjamin Romer 

---

v2: Put the goto back in.
---
 drivers/staging/unisys/visorbus/visorbus_main.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c 
b/drivers/staging/unisys/visorbus/visorbus_main.c
index 0add9ffe..d407f45 100644
--- a/drivers/staging/unisys/visorbus/visorbus_main.c
+++ b/drivers/staging/unisys/visorbus/visorbus_main.c
@@ -973,7 +973,7 @@ EXPORT_SYMBOL_GPL(visorbus_disable_channel_interrupts);
 static int
 create_visor_device(struct visor_device *dev)
 {
-   int rc = -1;
+   int rc;
u32 chipset_bus_no = dev->chipset_bus_no;
u32 chipset_dev_no = dev->chipset_dev_no;
 
@@ -995,6 +995,7 @@ create_visor_device(struct visor_device *dev)
if (!dev->periodic_work) {
POSTCODE_LINUX_3(DEVICE_CREATE_FAILURE_PC, chipset_dev_no,
 DIAG_SEVERITY_ERR);
+   rc = -EINVAL;
goto away;
}
 
@@ -1032,15 +1033,16 @@ create_visor_device(struct visor_device *dev)
if (rc < 0) {
POSTCODE_LINUX_3(DEVICE_REGISTER_FAILURE_PC, chipset_dev_no,
 DIAG_SEVERITY_ERR);
-   goto away_register;
+   goto away_unregister;
}
 
list_add_tail(&dev->list_all, &list_all_device_instances);
return 0;
 
-away_register:
+   away_unregister:
device_unregister(&dev->device);
-away:
+
+   away:
put_device(&dev->device);
return rc;
 }
-- 
2.5.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2 3/7] staging: unisys: cleanup goto in create_visor_device()

2016-02-23 Thread Ben Romer
disregard this patch, I sent the wrong file. v3 coming.

-- Ben
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2 3/7] staging: unisys: cleanup goto in create_visor_device()

2016-02-23 Thread Dan Carpenter
On Tue, Feb 23, 2016 at 12:05:22PM -0500, Benjamin Romer wrote:
> -away_register:
> + away_unregister:
>   device_unregister(&dev->device);
> -away:
> +
> + away:
>   put_device(&dev->device);

These cause checkpatch.pl errors.  Also "away" is too generic a name.
When I see "goto away;" I have no idea if it does everything or nothing
so I have to scroll down.  If it's call "away_put:" then that's clear to
me without scrolling down.

regards,
dan carpenter

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel