@@ -37,7 +37,7 @@ debug_info_t *vfio_ccw_debug_trace_id;
*/
int vfio_ccw_sch_quiesce(struct subchannel *sch)
{
- struct vfio_ccw_private *private = dev_get_drvdata(&sch->dev);
+ struct vfio_ccw_private *private = vfio_ccw_get_private(sch);
DECLARE_COMPLETION_ONSTACK(completion);
int iretry, ret = 0;
@@ -124,7 +124,7 @@ static void vfio_ccw_crw_todo(struct work_struct *work)
*/
static void vfio_ccw_sch_irq(struct subchannel *sch)
{
- struct vfio_ccw_private *private = dev_get_drvdata(&sch->dev);
+ struct vfio_ccw_private *private = vfio_ccw_get_private(sch);
if (WARN_ON(!private))
return;
@@ -245,7 +245,7 @@ static void vfio_ccw_sch_remove(struct subchannel *sch)
static void vfio_ccw_sch_shutdown(struct subchannel *sch)
{
- struct vfio_ccw_private *private = dev_get_drvdata(&sch->dev);
+ struct vfio_ccw_private *private = vfio_ccw_get_private(sch);
if (!private)
return;
@@ -266,7 +266,7 @@ static void vfio_ccw_sch_shutdown(struct subchannel *sch)
*/
static int vfio_ccw_sch_event(struct subchannel *sch, int process)
{
- struct vfio_ccw_private *private = dev_get_drvdata(&sch->dev);
+ struct vfio_ccw_private *private = vfio_ccw_get_private(sch);
unsigned long flags;
int rc = -EAGAIN;
@@ -321,7 +321,7 @@ static void vfio_ccw_queue_crw(struct vfio_ccw_private *private,
static int vfio_ccw_chp_event(struct subchannel *sch,
struct chp_link *link, int event)
{
- struct vfio_ccw_private *private = dev_get_drvdata(&sch->dev);
+ struct vfio_ccw_private *private = vfio_ccw_get_private(sch);
int mask = chp_ssd_get_mask(&sch->ssd_info, link);
int retry = 255;
@@ -24,6 +24,8 @@
#include "css.h"
#include "vfio_ccw_cp.h"
+struct mdev_device;
+
#define VFIO_CCW_OFFSET_SHIFT 10
#define VFIO_CCW_OFFSET_TO_INDEX(off) (off >> VFIO_CCW_OFFSET_SHIFT)
#define VFIO_CCW_INDEX_TO_OFFSET(index) ((u64)(index) << VFIO_CCW_OFFSET_SHIFT)
@@ -125,6 +127,18 @@ extern struct mdev_driver vfio_ccw_mdev_driver;
extern const struct mdev_parent_ops vfio_ccw_mdev_ops;
extern const struct vfio_device_ops vfio_ccw_dev_ops;
+static inline struct vfio_ccw_private *vfio_ccw_get_private(struct subchannel *sch)
+{
+ struct vfio_ccw_private *private;
+
+ if (!sch)
+ return NULL;
+
+ private = dev_get_drvdata(&sch->dev);
+
+ return private;
+}
+
/*
* States of the device statemachine.
*/
Refactor out the logic of getting the vfio_ccw_private struct from the subchannel, so that it can be synchronized with vfio better. Suggested-by: Jason Gunthorpe <jgg@nvidia.com> Signed-off-by: Eric Farman <farman@linux.ibm.com> --- drivers/s390/cio/vfio_ccw_drv.c | 10 +++++----- drivers/s390/cio/vfio_ccw_private.h | 14 ++++++++++++++ 2 files changed, 19 insertions(+), 5 deletions(-)