aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLad, Prabhakar <prabhakar.csengg@gmail.com>2013-06-17 10:20:44 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2013-06-21 10:26:05 -0400
commit410ca6053e3c216b8ca0b05f45d6cd76b334a459 (patch)
treedb9878caf7da0fb1aa44c479367f79be3cc13d47
parent079b3852b76a186b7c4e858420eee165c9837178 (diff)
[media] media: davinci: vpif_capture: move the freeing of irq and global variables to remove()
Ideally the freeing of irq's and the global variables needs to be done in the remove() rather than module_exit(), this patch moves the freeing up of irq's and freeing the memory allocated to channel objects to remove() callback of struct platform_driver. Signed-off-by: Lad, Prabhakar <prabhakar.csengg@gmail.com> Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r--drivers/media/platform/davinci/vpif_capture.c29
1 files changed, 11 insertions, 18 deletions
diff --git a/drivers/media/platform/davinci/vpif_capture.c b/drivers/media/platform/davinci/vpif_capture.c
index d004531e740d..7d3c449d9d7d 100644
--- a/drivers/media/platform/davinci/vpif_capture.c
+++ b/drivers/media/platform/davinci/vpif_capture.c
@@ -2159,17 +2159,27 @@ vpif_int_err:
2159 */ 2159 */
2160static int vpif_remove(struct platform_device *device) 2160static int vpif_remove(struct platform_device *device)
2161{ 2161{
2162 int i;
2163 struct channel_obj *ch; 2162 struct channel_obj *ch;
2163 struct resource *res;
2164 int irq_num, i = 0;
2165
2166 while ((res = platform_get_resource(device, IORESOURCE_IRQ, i))) {
2167 for (irq_num = res->start; irq_num <= res->end; irq_num++)
2168 free_irq(irq_num,
2169 (void *)(&vpif_obj.dev[i]->channel_id));
2170 i++;
2171 }
2164 2172
2165 v4l2_device_unregister(&vpif_obj.v4l2_dev); 2173 v4l2_device_unregister(&vpif_obj.v4l2_dev);
2166 2174
2175 kfree(vpif_obj.sd);
2167 /* un-register device */ 2176 /* un-register device */
2168 for (i = 0; i < VPIF_CAPTURE_MAX_DEVICES; i++) { 2177 for (i = 0; i < VPIF_CAPTURE_MAX_DEVICES; i++) {
2169 /* Get the pointer to the channel object */ 2178 /* Get the pointer to the channel object */
2170 ch = vpif_obj.dev[i]; 2179 ch = vpif_obj.dev[i];
2171 /* Unregister video device */ 2180 /* Unregister video device */
2172 video_unregister_device(ch->video_dev); 2181 video_unregister_device(ch->video_dev);
2182 kfree(vpif_obj.dev[i]);
2173 } 2183 }
2174 return 0; 2184 return 0;
2175} 2185}
@@ -2281,24 +2291,7 @@ static __init int vpif_init(void)
2281 */ 2291 */
2282static void vpif_cleanup(void) 2292static void vpif_cleanup(void)
2283{ 2293{
2284 struct platform_device *pdev;
2285 struct resource *res;
2286 int irq_num;
2287 int i = 0;
2288
2289 pdev = container_of(vpif_dev, struct platform_device, dev);
2290 while ((res = platform_get_resource(pdev, IORESOURCE_IRQ, i))) {
2291 for (irq_num = res->start; irq_num <= res->end; irq_num++)
2292 free_irq(irq_num,
2293 (void *)(&vpif_obj.dev[i]->channel_id));
2294 i++;
2295 }
2296
2297 platform_driver_unregister(&vpif_driver); 2294 platform_driver_unregister(&vpif_driver);
2298
2299 kfree(vpif_obj.sd);
2300 for (i = 0; i < VPIF_CAPTURE_MAX_DEVICES; i++)
2301 kfree(vpif_obj.dev[i]);
2302} 2295}
2303 2296
2304/* Function for module initialization and cleanup */ 2297/* Function for module initialization and cleanup */