Skip to content

Commit c98e16b

Browse files
efarmancohuck
authored andcommitted
s390/cio: Convert ccw_io_region to pointer
In the event that we want to change the layout of the ccw_io_region in the future[1], it might be easier to work with it as a pointer within the vfio_ccw_private struct rather than an embedded struct. [1] https://patchwork.kernel.org/comment/22228541/ Signed-off-by: Eric Farman <[email protected]> Message-Id: <[email protected]> Signed-off-by: Cornelia Huck <[email protected]>
1 parent 55a5542 commit c98e16b

File tree

4 files changed

+17
-7
lines changed

4 files changed

+17
-7
lines changed

drivers/s390/cio/vfio_ccw_drv.c

+11-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ static void vfio_ccw_sch_io_todo(struct work_struct *work)
7979
cp_update_scsw(&private->cp, &irb->scsw);
8080
cp_free(&private->cp);
8181
}
82-
memcpy(private->io_region.irb_area, irb, sizeof(*irb));
82+
memcpy(private->io_region->irb_area, irb, sizeof(*irb));
8383

8484
if (private->io_trigger)
8585
eventfd_signal(private->io_trigger, 1);
@@ -114,6 +114,14 @@ static int vfio_ccw_sch_probe(struct subchannel *sch)
114114
private = kzalloc(sizeof(*private), GFP_KERNEL | GFP_DMA);
115115
if (!private)
116116
return -ENOMEM;
117+
118+
private->io_region = kzalloc(sizeof(*private->io_region),
119+
GFP_KERNEL | GFP_DMA);
120+
if (!private->io_region) {
121+
kfree(private);
122+
return -ENOMEM;
123+
}
124+
117125
private->sch = sch;
118126
dev_set_drvdata(&sch->dev, private);
119127

@@ -139,6 +147,7 @@ static int vfio_ccw_sch_probe(struct subchannel *sch)
139147
cio_disable_subchannel(sch);
140148
out_free:
141149
dev_set_drvdata(&sch->dev, NULL);
150+
kfree(private->io_region);
142151
kfree(private);
143152
return ret;
144153
}
@@ -153,6 +162,7 @@ static int vfio_ccw_sch_remove(struct subchannel *sch)
153162

154163
dev_set_drvdata(&sch->dev, NULL);
155164

165+
kfree(private->io_region);
156166
kfree(private);
157167

158168
return 0;

drivers/s390/cio/vfio_ccw_fsm.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,13 @@ static void fsm_io_error(struct vfio_ccw_private *private,
9393
enum vfio_ccw_event event)
9494
{
9595
pr_err("vfio-ccw: FSM: I/O request from state:%d\n", private->state);
96-
private->io_region.ret_code = -EIO;
96+
private->io_region->ret_code = -EIO;
9797
}
9898

9999
static void fsm_io_busy(struct vfio_ccw_private *private,
100100
enum vfio_ccw_event event)
101101
{
102-
private->io_region.ret_code = -EBUSY;
102+
private->io_region->ret_code = -EBUSY;
103103
}
104104

105105
static void fsm_disabled_irq(struct vfio_ccw_private *private,
@@ -126,7 +126,7 @@ static void fsm_io_request(struct vfio_ccw_private *private,
126126
{
127127
union orb *orb;
128128
union scsw *scsw = &private->scsw;
129-
struct ccw_io_region *io_region = &private->io_region;
129+
struct ccw_io_region *io_region = private->io_region;
130130
struct mdev_device *mdev = private->mdev;
131131
char *errstr = "request";
132132

drivers/s390/cio/vfio_ccw_ops.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ static ssize_t vfio_ccw_mdev_read(struct mdev_device *mdev,
174174
return -EINVAL;
175175

176176
private = dev_get_drvdata(mdev_parent_dev(mdev));
177-
region = &private->io_region;
177+
region = private->io_region;
178178
if (copy_to_user(buf, (void *)region + *ppos, count))
179179
return -EFAULT;
180180

@@ -196,7 +196,7 @@ static ssize_t vfio_ccw_mdev_write(struct mdev_device *mdev,
196196
if (private->state != VFIO_CCW_STATE_IDLE)
197197
return -EACCES;
198198

199-
region = &private->io_region;
199+
region = private->io_region;
200200
if (copy_from_user((void *)region + *ppos, buf, count))
201201
return -EFAULT;
202202

drivers/s390/cio/vfio_ccw_private.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ struct vfio_ccw_private {
4141
atomic_t avail;
4242
struct mdev_device *mdev;
4343
struct notifier_block nb;
44-
struct ccw_io_region io_region;
44+
struct ccw_io_region *io_region;
4545

4646
struct channel_program cp;
4747
struct irb irb;

0 commit comments

Comments
 (0)