Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Christophe JAILLET and committed by
Hans Verkuil
266b44ec fe61b290

+35 -35
+35 -35
drivers/media/pci/intel/ipu6/ipu6-isys.c
··· 925 925 .resume = isys_resume, 926 926 }; 927 927 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 - 963 928 static int alloc_fw_msg_bufs(struct ipu6_isys *isys, int amount) 964 929 { 965 930 struct device *dev = &isys->adev->auxdev.dev; ··· 1130 1165 ipu6_mmu_hw_cleanup(adev->mmu); 1131 1166 1132 1167 return ret; 1168 + } 1169 + 1170 + static void isys_remove(struct auxiliary_device *auxdev) 1171 + { 1172 + struct ipu6_bus_device *adev = auxdev_to_adev(auxdev); 1173 + struct ipu6_isys *isys = dev_get_drvdata(&auxdev->dev); 1174 + struct ipu6_device *isp = adev->isp; 1175 + struct isys_fw_msgs *fwmsg, *safe; 1176 + unsigned int i; 1177 + 1178 + list_for_each_entry_safe(fwmsg, safe, &isys->framebuflist, head) 1179 + dma_free_attrs(&auxdev->dev, sizeof(struct isys_fw_msgs), 1180 + fwmsg, fwmsg->dma_addr, 0); 1181 + 1182 + list_for_each_entry_safe(fwmsg, safe, &isys->framebuflist_fw, head) 1183 + dma_free_attrs(&auxdev->dev, sizeof(struct isys_fw_msgs), 1184 + fwmsg, fwmsg->dma_addr, 0); 1185 + 1186 + isys_unregister_devices(isys); 1187 + isys_notifier_cleanup(isys); 1188 + 1189 + cpu_latency_qos_remove_request(&isys->pm_qos); 1190 + 1191 + if (!isp->secure_mode) { 1192 + ipu6_cpd_free_pkg_dir(adev); 1193 + ipu6_buttress_unmap_fw_image(adev, &adev->fw_sgt); 1194 + release_firmware(adev->fw); 1195 + } 1196 + 1197 + for (i = 0; i < IPU6_ISYS_MAX_STREAMS; i++) 1198 + mutex_destroy(&isys->streams[i].mutex); 1199 + 1200 + isys_iwake_watermark_cleanup(isys); 1201 + mutex_destroy(&isys->stream_mutex); 1202 + mutex_destroy(&isys->mutex); 1133 1203 } 1134 1204 1135 1205 struct fwmsg {