aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/vfio/platform/vfio_platform_common.c30
1 files changed, 14 insertions, 16 deletions
diff --git a/drivers/vfio/platform/vfio_platform_common.c b/drivers/vfio/platform/vfio_platform_common.c
index 170479399cde..de419df768e1 100644
--- a/drivers/vfio/platform/vfio_platform_common.c
+++ b/drivers/vfio/platform/vfio_platform_common.c
@@ -134,6 +134,17 @@ static void vfio_platform_regions_cleanup(struct vfio_platform_device *vdev)
134 kfree(vdev->regions); 134 kfree(vdev->regions);
135} 135}
136 136
137static int vfio_platform_call_reset(struct vfio_platform_device *vdev)
138{
139 if (vdev->of_reset) {
140 dev_info(vdev->device, "reset\n");
141 return vdev->of_reset(vdev);
142 }
143
144 dev_warn(vdev->device, "no reset function found!\n");
145 return -EINVAL;
146}
147
137static void vfio_platform_release(void *device_data) 148static void vfio_platform_release(void *device_data)
138{ 149{
139 struct vfio_platform_device *vdev = device_data; 150 struct vfio_platform_device *vdev = device_data;
@@ -141,12 +152,7 @@ static void vfio_platform_release(void *device_data)
141 mutex_lock(&driver_lock); 152 mutex_lock(&driver_lock);
142 153
143 if (!(--vdev->refcnt)) { 154 if (!(--vdev->refcnt)) {
144 if (vdev->of_reset) { 155 vfio_platform_call_reset(vdev);
145 dev_info(vdev->device, "reset\n");
146 vdev->of_reset(vdev);
147 } else {
148 dev_warn(vdev->device, "no reset function found!\n");
149 }
150 vfio_platform_regions_cleanup(vdev); 156 vfio_platform_regions_cleanup(vdev);
151 vfio_platform_irq_cleanup(vdev); 157 vfio_platform_irq_cleanup(vdev);
152 } 158 }
@@ -175,12 +181,7 @@ static int vfio_platform_open(void *device_data)
175 if (ret) 181 if (ret)
176 goto err_irq; 182 goto err_irq;
177 183
178 if (vdev->of_reset) { 184 vfio_platform_call_reset(vdev);
179 dev_info(vdev->device, "reset\n");
180 vdev->of_reset(vdev);
181 } else {
182 dev_warn(vdev->device, "no reset function found!\n");
183 }
184 } 185 }
185 186
186 vdev->refcnt++; 187 vdev->refcnt++;
@@ -312,10 +313,7 @@ static long vfio_platform_ioctl(void *device_data,
312 return ret; 313 return ret;
313 314
314 } else if (cmd == VFIO_DEVICE_RESET) { 315 } else if (cmd == VFIO_DEVICE_RESET) {
315 if (vdev->of_reset) 316 return vfio_platform_call_reset(vdev);
316 return vdev->of_reset(vdev);
317 else
318 return -EINVAL;
319 } 317 }
320 318
321 return -ENOTTY; 319 return -ENOTTY;