Commit 15d9ce9d authored by David Kershner's avatar David Kershner Committed by Greg Kroah-Hartman

staging: unisys: visorbus: add error handling to initiate_chipset_device_pause_resume

Clean up the function to remove some if statments that should be done
in the calling function.
Signed-off-by: default avatarDavid Kershner <david.kershner@unisys.com>
Reviewed-by: default avatarReviewed-by: Tim Sell <timothy.sell@unisys.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 293deb2c
...@@ -1199,62 +1199,38 @@ resume_state_change_complete(struct visor_device *dev, int status) ...@@ -1199,62 +1199,38 @@ resume_state_change_complete(struct visor_device *dev, int status)
* via a callback function; see pause_state_change_complete() and * via a callback function; see pause_state_change_complete() and
* resume_state_change_complete(). * resume_state_change_complete().
*/ */
static void static int
initiate_chipset_device_pause_resume(struct visor_device *dev, bool is_pause) initiate_chipset_device_pause_resume(struct visor_device *dev, bool is_pause)
{ {
int rc; int err;
struct visor_driver *drv = NULL; struct visor_driver *drv = NULL;
void (*notify_func)(struct visor_device *dev, int response) = NULL;
if (is_pause)
notify_func = device_pause_response;
else
notify_func = device_resume_response;
if (!notify_func)
return;
drv = to_visor_driver(dev->device.driver); drv = to_visor_driver(dev->device.driver);
if (!drv) { if (!drv)
(*notify_func)(dev, -ENODEV); return -ENODEV;
return;
}
if (dev->pausing || dev->resuming) { if (dev->pausing || dev->resuming)
(*notify_func)(dev, -EBUSY); return -EBUSY;
return;
}
if (is_pause) { if (is_pause) {
if (!drv->pause) { if (!drv->pause)
(*notify_func)(dev, -EINVAL); return -EINVAL;
return;
}
dev->pausing = true; dev->pausing = true;
rc = drv->pause(dev, pause_state_change_complete); err = drv->pause(dev, pause_state_change_complete);
} else { } else {
/* This should be done at BUS resume time, but an /* The vbus_dev_info structure in the channel was been
* existing problem prevents us from ever getting a bus * cleared, make sure it is valid.
* resume... This hack would fail to work should we
* ever have a bus that contains NO devices, since we
* would never even get here in that case.
*/ */
fix_vbus_dev_info(dev); fix_vbus_dev_info(dev);
if (!drv->resume) { if (!drv->resume)
(*notify_func)(dev, -EINVAL); return -EINVAL;
return;
}
dev->resuming = true; dev->resuming = true;
rc = drv->resume(dev, resume_state_change_complete); err = drv->resume(dev, resume_state_change_complete);
}
if (rc < 0) {
if (is_pause)
dev->pausing = false;
else
dev->resuming = false;
(*notify_func)(dev, -EINVAL);
} }
return err;
} }
/** /**
...@@ -1268,7 +1244,14 @@ initiate_chipset_device_pause_resume(struct visor_device *dev, bool is_pause) ...@@ -1268,7 +1244,14 @@ initiate_chipset_device_pause_resume(struct visor_device *dev, bool is_pause)
void void
chipset_device_pause(struct visor_device *dev_info) chipset_device_pause(struct visor_device *dev_info)
{ {
initiate_chipset_device_pause_resume(dev_info, true); int err;
err = initiate_chipset_device_pause_resume(dev_info, true);
if (err < 0) {
dev_info->pausing = false;
device_pause_response(dev_info, err);
}
} }
/** /**
...@@ -1282,7 +1265,14 @@ chipset_device_pause(struct visor_device *dev_info) ...@@ -1282,7 +1265,14 @@ chipset_device_pause(struct visor_device *dev_info)
void void
chipset_device_resume(struct visor_device *dev_info) chipset_device_resume(struct visor_device *dev_info)
{ {
initiate_chipset_device_pause_resume(dev_info, false); int err;
err = initiate_chipset_device_pause_resume(dev_info, false);
if (err < 0) {
device_resume_response(dev_info, err);
dev_info->resuming = false;
}
} }
int int
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment