Commit 4296151d authored by Eric Farman's avatar Eric Farman Committed by Cornelia Huck

vfio-ccw: Refactor IRQ handlers

To simplify future expansion.
Signed-off-by: default avatarEric Farman <farman@linux.ibm.com>
Reviewed-by: default avatarCornelia Huck <cohuck@redhat.com>
Message-Id: <20200505122745.53208-6-farman@linux.ibm.com>
Signed-off-by: default avatarCornelia Huck <cohuck@redhat.com>
parent 24c98674
...@@ -387,17 +387,21 @@ static int vfio_ccw_mdev_get_region_info(struct vfio_region_info *info, ...@@ -387,17 +387,21 @@ static int vfio_ccw_mdev_get_region_info(struct vfio_region_info *info,
static int vfio_ccw_mdev_get_irq_info(struct vfio_irq_info *info) static int vfio_ccw_mdev_get_irq_info(struct vfio_irq_info *info)
{ {
if (info->index != VFIO_CCW_IO_IRQ_INDEX) switch (info->index) {
return -EINVAL; case VFIO_CCW_IO_IRQ_INDEX:
info->count = 1; info->count = 1;
info->flags = VFIO_IRQ_INFO_EVENTFD; info->flags = VFIO_IRQ_INFO_EVENTFD;
break;
default:
return -EINVAL;
}
return 0; return 0;
} }
static int vfio_ccw_mdev_set_irqs(struct mdev_device *mdev, static int vfio_ccw_mdev_set_irqs(struct mdev_device *mdev,
uint32_t flags, uint32_t flags,
uint32_t index,
void __user *data) void __user *data)
{ {
struct vfio_ccw_private *private; struct vfio_ccw_private *private;
...@@ -407,7 +411,14 @@ static int vfio_ccw_mdev_set_irqs(struct mdev_device *mdev, ...@@ -407,7 +411,14 @@ static int vfio_ccw_mdev_set_irqs(struct mdev_device *mdev,
return -EINVAL; return -EINVAL;
private = dev_get_drvdata(mdev_parent_dev(mdev)); private = dev_get_drvdata(mdev_parent_dev(mdev));
switch (index) {
case VFIO_CCW_IO_IRQ_INDEX:
ctx = &private->io_trigger; ctx = &private->io_trigger;
break;
default:
return -EINVAL;
}
switch (flags & VFIO_IRQ_SET_DATA_TYPE_MASK) { switch (flags & VFIO_IRQ_SET_DATA_TYPE_MASK) {
case VFIO_IRQ_SET_DATA_NONE: case VFIO_IRQ_SET_DATA_NONE:
...@@ -579,7 +590,7 @@ static ssize_t vfio_ccw_mdev_ioctl(struct mdev_device *mdev, ...@@ -579,7 +590,7 @@ static ssize_t vfio_ccw_mdev_ioctl(struct mdev_device *mdev,
return ret; return ret;
data = (void __user *)(arg + minsz); data = (void __user *)(arg + minsz);
return vfio_ccw_mdev_set_irqs(mdev, hdr.flags, data); return vfio_ccw_mdev_set_irqs(mdev, hdr.flags, hdr.index, data);
} }
case VFIO_DEVICE_RESET: case VFIO_DEVICE_RESET:
return vfio_ccw_mdev_reset(mdev); return vfio_ccw_mdev_reset(mdev);
......
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