17
17
18
18
#include "vfio_ccw_private.h"
19
19
20
- static int vfio_ccw_mdev_reset (struct mdev_device * mdev )
20
+ static int vfio_ccw_mdev_reset (struct vfio_ccw_private * private )
21
21
{
22
- struct vfio_ccw_private * private ;
23
22
struct subchannel * sch ;
24
23
int ret ;
25
24
26
- private = dev_get_drvdata (mdev_parent_dev (mdev ));
27
25
sch = private -> sch ;
28
26
/*
29
27
* TODO:
@@ -61,7 +59,7 @@ static int vfio_ccw_mdev_notifier(struct notifier_block *nb,
61
59
if (!cp_iova_pinned (& private -> cp , unmap -> iova ))
62
60
return NOTIFY_OK ;
63
61
64
- if (vfio_ccw_mdev_reset (private -> mdev ))
62
+ if (vfio_ccw_mdev_reset (private ))
65
63
return NOTIFY_BAD ;
66
64
67
65
cp_free (& private -> cp );
@@ -201,7 +199,7 @@ static void vfio_ccw_mdev_close_device(struct mdev_device *mdev)
201
199
202
200
if ((private -> state != VFIO_CCW_STATE_NOT_OPER ) &&
203
201
(private -> state != VFIO_CCW_STATE_STANDBY )) {
204
- if (!vfio_ccw_mdev_reset (mdev ))
202
+ if (!vfio_ccw_mdev_reset (private ))
205
203
private -> state = VFIO_CCW_STATE_STANDBY ;
206
204
/* The state will be NOT_OPER on error. */
207
205
}
@@ -311,27 +309,22 @@ static ssize_t vfio_ccw_mdev_write(struct mdev_device *mdev,
311
309
return - EINVAL ;
312
310
}
313
311
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 )
316
314
{
317
- struct vfio_ccw_private * private ;
318
-
319
- private = dev_get_drvdata (mdev_parent_dev (mdev ));
320
315
info -> flags = VFIO_DEVICE_FLAGS_CCW | VFIO_DEVICE_FLAGS_RESET ;
321
316
info -> num_regions = VFIO_CCW_NUM_REGIONS + private -> num_regions ;
322
317
info -> num_irqs = VFIO_CCW_NUM_IRQS ;
323
318
324
319
return 0 ;
325
320
}
326
321
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 ,
329
324
unsigned long arg )
330
325
{
331
- struct vfio_ccw_private * private ;
332
326
int i ;
333
327
334
- private = dev_get_drvdata (mdev_parent_dev (mdev ));
335
328
switch (info -> index ) {
336
329
case VFIO_CCW_CONFIG_REGION_INDEX :
337
330
info -> offset = 0 ;
@@ -406,19 +399,16 @@ static int vfio_ccw_mdev_get_irq_info(struct vfio_irq_info *info)
406
399
return 0 ;
407
400
}
408
401
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 ,
410
403
uint32_t flags ,
411
404
uint32_t index ,
412
405
void __user * data )
413
406
{
414
- struct vfio_ccw_private * private ;
415
407
struct eventfd_ctx * * ctx ;
416
408
417
409
if (!(flags & VFIO_IRQ_SET_ACTION_TRIGGER ))
418
410
return - EINVAL ;
419
411
420
- private = dev_get_drvdata (mdev_parent_dev (mdev ));
421
-
422
412
switch (index ) {
423
413
case VFIO_CCW_IO_IRQ_INDEX :
424
414
ctx = & private -> io_trigger ;
@@ -524,6 +514,8 @@ static ssize_t vfio_ccw_mdev_ioctl(struct mdev_device *mdev,
524
514
unsigned int cmd ,
525
515
unsigned long arg )
526
516
{
517
+ struct vfio_ccw_private * private =
518
+ dev_get_drvdata (mdev_parent_dev (mdev ));
527
519
int ret = 0 ;
528
520
unsigned long minsz ;
529
521
@@ -540,7 +532,7 @@ static ssize_t vfio_ccw_mdev_ioctl(struct mdev_device *mdev,
540
532
if (info .argsz < minsz )
541
533
return - EINVAL ;
542
534
543
- ret = vfio_ccw_mdev_get_device_info (& info , mdev );
535
+ ret = vfio_ccw_mdev_get_device_info (private , & info );
544
536
if (ret )
545
537
return ret ;
546
538
@@ -558,7 +550,7 @@ static ssize_t vfio_ccw_mdev_ioctl(struct mdev_device *mdev,
558
550
if (info .argsz < minsz )
559
551
return - EINVAL ;
560
552
561
- ret = vfio_ccw_mdev_get_region_info (& info , mdev , arg );
553
+ ret = vfio_ccw_mdev_get_region_info (private , & info , arg );
562
554
if (ret )
563
555
return ret ;
564
556
@@ -603,10 +595,11 @@ static ssize_t vfio_ccw_mdev_ioctl(struct mdev_device *mdev,
603
595
return ret ;
604
596
605
597
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 );
607
600
}
608
601
case VFIO_DEVICE_RESET :
609
- return vfio_ccw_mdev_reset (mdev );
602
+ return vfio_ccw_mdev_reset (private );
610
603
default :
611
604
return - ENOTTY ;
612
605
}
0 commit comments