Skip to content

Commit 39b6ee0

Browse files
jgunthorpeawilliam
authored andcommitted
vfio/ccw: Pass vfio_ccw_private not mdev_device to various functions
mdev_device should only be used in functions assigned to ops callbacks, interior functions should use the struct vfio_ccw_private instead of repeatedly trying to get it from the mdev. Reviewed-by: Christoph Hellwig <[email protected]> Reviewed-by: Cornelia Huck <[email protected]> Reviewed-by: Eric Farman <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alex Williamson <[email protected]>
1 parent 0972c7d commit 39b6ee0

File tree

1 file changed

+15
-22
lines changed

1 file changed

+15
-22
lines changed

drivers/s390/cio/vfio_ccw_ops.c

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,11 @@
1717

1818
#include "vfio_ccw_private.h"
1919

20-
static int vfio_ccw_mdev_reset(struct mdev_device *mdev)
20+
static int vfio_ccw_mdev_reset(struct vfio_ccw_private *private)
2121
{
22-
struct vfio_ccw_private *private;
2322
struct subchannel *sch;
2423
int ret;
2524

26-
private = dev_get_drvdata(mdev_parent_dev(mdev));
2725
sch = private->sch;
2826
/*
2927
* TODO:
@@ -61,7 +59,7 @@ static int vfio_ccw_mdev_notifier(struct notifier_block *nb,
6159
if (!cp_iova_pinned(&private->cp, unmap->iova))
6260
return NOTIFY_OK;
6361

64-
if (vfio_ccw_mdev_reset(private->mdev))
62+
if (vfio_ccw_mdev_reset(private))
6563
return NOTIFY_BAD;
6664

6765
cp_free(&private->cp);
@@ -201,7 +199,7 @@ static void vfio_ccw_mdev_close_device(struct mdev_device *mdev)
201199

202200
if ((private->state != VFIO_CCW_STATE_NOT_OPER) &&
203201
(private->state != VFIO_CCW_STATE_STANDBY)) {
204-
if (!vfio_ccw_mdev_reset(mdev))
202+
if (!vfio_ccw_mdev_reset(private))
205203
private->state = VFIO_CCW_STATE_STANDBY;
206204
/* The state will be NOT_OPER on error. */
207205
}
@@ -311,27 +309,22 @@ static ssize_t vfio_ccw_mdev_write(struct mdev_device *mdev,
311309
return -EINVAL;
312310
}
313311

314-
static int vfio_ccw_mdev_get_device_info(struct vfio_device_info *info,
315-
struct mdev_device *mdev)
312+
static int vfio_ccw_mdev_get_device_info(struct vfio_ccw_private *private,
313+
struct vfio_device_info *info)
316314
{
317-
struct vfio_ccw_private *private;
318-
319-
private = dev_get_drvdata(mdev_parent_dev(mdev));
320315
info->flags = VFIO_DEVICE_FLAGS_CCW | VFIO_DEVICE_FLAGS_RESET;
321316
info->num_regions = VFIO_CCW_NUM_REGIONS + private->num_regions;
322317
info->num_irqs = VFIO_CCW_NUM_IRQS;
323318

324319
return 0;
325320
}
326321

327-
static int vfio_ccw_mdev_get_region_info(struct vfio_region_info *info,
328-
struct mdev_device *mdev,
322+
static int vfio_ccw_mdev_get_region_info(struct vfio_ccw_private *private,
323+
struct vfio_region_info *info,
329324
unsigned long arg)
330325
{
331-
struct vfio_ccw_private *private;
332326
int i;
333327

334-
private = dev_get_drvdata(mdev_parent_dev(mdev));
335328
switch (info->index) {
336329
case VFIO_CCW_CONFIG_REGION_INDEX:
337330
info->offset = 0;
@@ -406,19 +399,16 @@ static int vfio_ccw_mdev_get_irq_info(struct vfio_irq_info *info)
406399
return 0;
407400
}
408401

409-
static int vfio_ccw_mdev_set_irqs(struct mdev_device *mdev,
402+
static int vfio_ccw_mdev_set_irqs(struct vfio_ccw_private *private,
410403
uint32_t flags,
411404
uint32_t index,
412405
void __user *data)
413406
{
414-
struct vfio_ccw_private *private;
415407
struct eventfd_ctx **ctx;
416408

417409
if (!(flags & VFIO_IRQ_SET_ACTION_TRIGGER))
418410
return -EINVAL;
419411

420-
private = dev_get_drvdata(mdev_parent_dev(mdev));
421-
422412
switch (index) {
423413
case VFIO_CCW_IO_IRQ_INDEX:
424414
ctx = &private->io_trigger;
@@ -524,6 +514,8 @@ static ssize_t vfio_ccw_mdev_ioctl(struct mdev_device *mdev,
524514
unsigned int cmd,
525515
unsigned long arg)
526516
{
517+
struct vfio_ccw_private *private =
518+
dev_get_drvdata(mdev_parent_dev(mdev));
527519
int ret = 0;
528520
unsigned long minsz;
529521

@@ -540,7 +532,7 @@ static ssize_t vfio_ccw_mdev_ioctl(struct mdev_device *mdev,
540532
if (info.argsz < minsz)
541533
return -EINVAL;
542534

543-
ret = vfio_ccw_mdev_get_device_info(&info, mdev);
535+
ret = vfio_ccw_mdev_get_device_info(private, &info);
544536
if (ret)
545537
return ret;
546538

@@ -558,7 +550,7 @@ static ssize_t vfio_ccw_mdev_ioctl(struct mdev_device *mdev,
558550
if (info.argsz < minsz)
559551
return -EINVAL;
560552

561-
ret = vfio_ccw_mdev_get_region_info(&info, mdev, arg);
553+
ret = vfio_ccw_mdev_get_region_info(private, &info, arg);
562554
if (ret)
563555
return ret;
564556

@@ -603,10 +595,11 @@ static ssize_t vfio_ccw_mdev_ioctl(struct mdev_device *mdev,
603595
return ret;
604596

605597
data = (void __user *)(arg + minsz);
606-
return vfio_ccw_mdev_set_irqs(mdev, hdr.flags, hdr.index, data);
598+
return vfio_ccw_mdev_set_irqs(private, hdr.flags, hdr.index,
599+
data);
607600
}
608601
case VFIO_DEVICE_RESET:
609-
return vfio_ccw_mdev_reset(mdev);
602+
return vfio_ccw_mdev_reset(private);
610603
default:
611604
return -ENOTTY;
612605
}

0 commit comments

Comments
 (0)