From 03b93f08f8d0579a8bac4d9ab7792893e983f213 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Tue, 23 Feb 2016 10:01:54 -0500 Subject: [PATCH] staging: unisys: clean up initiate_chipset_device_pause_resume() Simplify this function by removing the goto in favor of handling errors immediately. Eliminate the vaguely-named variable x, and remove the unneeded initialization of rc. Lastly, provide meaningful error values to the callback function instead of just passing back a -1 for failure. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../staging/unisys/visorbus/visorbus_main.c | 42 ++++++++++--------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c index bf04df3c98ff..4f7d74326e59 100644 --- a/drivers/staging/unisys/visorbus/visorbus_main.c +++ b/drivers/staging/unisys/visorbus/visorbus_main.c @@ -1397,7 +1397,7 @@ resume_state_change_complete(struct visor_device *dev, int status) static void initiate_chipset_device_pause_resume(struct visor_device *dev, bool is_pause) { - int rc = -1, x; + int rc; struct visor_driver *drv = NULL; void (*notify_func)(struct visor_device *dev, int response) = NULL; @@ -1406,14 +1406,18 @@ initiate_chipset_device_pause_resume(struct visor_device *dev, bool is_pause) else notify_func = chipset_responders.device_resume; if (!notify_func) - goto away; + return; drv = to_visor_driver(dev->device.driver); - if (!drv) - goto away; + if (!drv) { + (*notify_func)(dev, -ENODEV); + return; + } - if (dev->pausing || dev->resuming) - goto away; + if (dev->pausing || dev->resuming) { + (*notify_func)(dev, -EBUSY); + return; + } /* Note that even though both drv->pause() and drv->resume * specify a callback function, it is NOT necessary for us to @@ -1423,11 +1427,13 @@ initiate_chipset_device_pause_resume(struct visor_device *dev, bool is_pause) * visorbus while child function drivers are still running. */ if (is_pause) { - if (!drv->pause) - goto away; + if (!drv->pause) { + (*notify_func)(dev, -EINVAL); + return; + } dev->pausing = true; - x = drv->pause(dev, pause_state_change_complete); + rc = drv->pause(dev, pause_state_change_complete); } else { /* This should be done at BUS resume time, but an * existing problem prevents us from ever getting a bus @@ -1436,24 +1442,20 @@ initiate_chipset_device_pause_resume(struct visor_device *dev, bool is_pause) * would never even get here in that case. */ fix_vbus_dev_info(dev); - if (!drv->resume) - goto away; + if (!drv->resume) { + (*notify_func)(dev, -EINVAL); + return; + } dev->resuming = true; - x = drv->resume(dev, resume_state_change_complete); + rc = drv->resume(dev, resume_state_change_complete); } - if (x < 0) { + if (rc < 0) { if (is_pause) dev->pausing = false; else dev->resuming = false; - goto away; - } - rc = 0; -away: - if (rc < 0) { - if (notify_func) - (*notify_func)(dev, rc); + (*notify_func)(dev, -EINVAL); } } -- 2.39.5