aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/s390
diff options
context:
space:
mode:
authorDong Jia Shi <bjsdjshi@linux.vnet.ibm.com>2017-04-12 11:08:16 +0200
committerCornelia Huck <cornelia.huck@de.ibm.com>2017-04-12 12:34:17 +0200
commit129cc19a94513081e9250323cd57e12ed48b3613 (patch)
treedaccaeb012b298ebeec12ba54ea53cc0254e9ce1 /drivers/s390
parentvfio: ccw: remove unnecessary NULL checks of a pointer (diff)
downloadlinux-dev-129cc19a94513081e9250323cd57e12ed48b3613.tar.xz
linux-dev-129cc19a94513081e9250323cd57e12ed48b3613.zip
vfio: ccw: improve error handling for vfio_ccw_mdev_remove
When vfio_ccw_mdev_reset fails during the remove process of the mdev, the current implementation simply returns. The failure indicates that the subchannel device is in a NOT_OPER state, thus the right thing to do should be removing the mdev. While we are at here, reverse the condition check to make the code more concise and readable. Signed-off-by: Dong Jia Shi <bjsdjshi@linux.vnet.ibm.com> Message-Id: <20170412090816.79108-3-bjsdjshi@linux.vnet.ibm.com> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Diffstat (limited to 'drivers/s390')
-rw-r--r--drivers/s390/cio/vfio_ccw_ops.c17
1 files changed, 6 insertions, 11 deletions
diff --git a/drivers/s390/cio/vfio_ccw_ops.c b/drivers/s390/cio/vfio_ccw_ops.c
index 55d0c87e73c3..e72abbc18ee3 100644
--- a/drivers/s390/cio/vfio_ccw_ops.c
+++ b/drivers/s390/cio/vfio_ccw_ops.c
@@ -126,19 +126,14 @@ static int vfio_ccw_mdev_remove(struct mdev_device *mdev)
{
struct vfio_ccw_private *private =
dev_get_drvdata(mdev_parent_dev(mdev));
- int ret;
-
- if ((private->state == VFIO_CCW_STATE_NOT_OPER) ||
- (private->state == VFIO_CCW_STATE_STANDBY))
- goto out;
-
- ret = vfio_ccw_mdev_reset(mdev);
- if (ret)
- return ret;
- private->state = VFIO_CCW_STATE_STANDBY;
+ if ((private->state != VFIO_CCW_STATE_NOT_OPER) &&
+ (private->state != VFIO_CCW_STATE_STANDBY)) {
+ if (!vfio_ccw_mdev_reset(mdev))
+ private->state = VFIO_CCW_STATE_STANDBY;
+ /* The state will be NOT_OPER on error. */
+ }
-out:
private->mdev = NULL;
atomic_inc(&private->avail);