Skip to content

Commit 266b44e

Browse files
tititiou36Hans Verkuil
authored andcommitted
media: intel/ipu6: Move isys_remove() close to isys_probe()
In preparation to fixing a leak in isys_probe(), move isys_remove(). The fix will introduce a new function that will also be called from isys_remove(). The code needs to be rearranged to avoid a forward declaration. Having the .remove function close to the .probe function is also more standard. Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
1 parent fe61b29 commit 266b44e

File tree

1 file changed

+35
-35
lines changed

1 file changed

+35
-35
lines changed

drivers/media/pci/intel/ipu6/ipu6-isys.c

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -925,41 +925,6 @@ static const struct dev_pm_ops isys_pm_ops = {
925925
.resume = isys_resume,
926926
};
927927

928-
static void isys_remove(struct auxiliary_device *auxdev)
929-
{
930-
struct ipu6_bus_device *adev = auxdev_to_adev(auxdev);
931-
struct ipu6_isys *isys = dev_get_drvdata(&auxdev->dev);
932-
struct ipu6_device *isp = adev->isp;
933-
struct isys_fw_msgs *fwmsg, *safe;
934-
unsigned int i;
935-
936-
list_for_each_entry_safe(fwmsg, safe, &isys->framebuflist, head)
937-
dma_free_attrs(&auxdev->dev, sizeof(struct isys_fw_msgs),
938-
fwmsg, fwmsg->dma_addr, 0);
939-
940-
list_for_each_entry_safe(fwmsg, safe, &isys->framebuflist_fw, head)
941-
dma_free_attrs(&auxdev->dev, sizeof(struct isys_fw_msgs),
942-
fwmsg, fwmsg->dma_addr, 0);
943-
944-
isys_unregister_devices(isys);
945-
isys_notifier_cleanup(isys);
946-
947-
cpu_latency_qos_remove_request(&isys->pm_qos);
948-
949-
if (!isp->secure_mode) {
950-
ipu6_cpd_free_pkg_dir(adev);
951-
ipu6_buttress_unmap_fw_image(adev, &adev->fw_sgt);
952-
release_firmware(adev->fw);
953-
}
954-
955-
for (i = 0; i < IPU6_ISYS_MAX_STREAMS; i++)
956-
mutex_destroy(&isys->streams[i].mutex);
957-
958-
isys_iwake_watermark_cleanup(isys);
959-
mutex_destroy(&isys->stream_mutex);
960-
mutex_destroy(&isys->mutex);
961-
}
962-
963928
static int alloc_fw_msg_bufs(struct ipu6_isys *isys, int amount)
964929
{
965930
struct device *dev = &isys->adev->auxdev.dev;
@@ -1167,6 +1132,41 @@ static int isys_probe(struct auxiliary_device *auxdev,
11671132
return ret;
11681133
}
11691134

1135+
static void isys_remove(struct auxiliary_device *auxdev)
1136+
{
1137+
struct ipu6_bus_device *adev = auxdev_to_adev(auxdev);
1138+
struct ipu6_isys *isys = dev_get_drvdata(&auxdev->dev);
1139+
struct ipu6_device *isp = adev->isp;
1140+
struct isys_fw_msgs *fwmsg, *safe;
1141+
unsigned int i;
1142+
1143+
list_for_each_entry_safe(fwmsg, safe, &isys->framebuflist, head)
1144+
dma_free_attrs(&auxdev->dev, sizeof(struct isys_fw_msgs),
1145+
fwmsg, fwmsg->dma_addr, 0);
1146+
1147+
list_for_each_entry_safe(fwmsg, safe, &isys->framebuflist_fw, head)
1148+
dma_free_attrs(&auxdev->dev, sizeof(struct isys_fw_msgs),
1149+
fwmsg, fwmsg->dma_addr, 0);
1150+
1151+
isys_unregister_devices(isys);
1152+
isys_notifier_cleanup(isys);
1153+
1154+
cpu_latency_qos_remove_request(&isys->pm_qos);
1155+
1156+
if (!isp->secure_mode) {
1157+
ipu6_cpd_free_pkg_dir(adev);
1158+
ipu6_buttress_unmap_fw_image(adev, &adev->fw_sgt);
1159+
release_firmware(adev->fw);
1160+
}
1161+
1162+
for (i = 0; i < IPU6_ISYS_MAX_STREAMS; i++)
1163+
mutex_destroy(&isys->streams[i].mutex);
1164+
1165+
isys_iwake_watermark_cleanup(isys);
1166+
mutex_destroy(&isys->stream_mutex);
1167+
mutex_destroy(&isys->mutex);
1168+
}
1169+
11701170
struct fwmsg {
11711171
int type;
11721172
char *msg;

0 commit comments

Comments
 (0)