aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLad, Prabhakar <prabhakar.csengg@gmail.com>2013-06-17 10:20:48 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2013-06-21 10:27:34 -0400
commit0b361583a5e15bcf4b686cf02bd2cc3925e4005d (patch)
tree9be09d6d290f4b222bfc235c50fe77af1def3a73
parenta76a0b338112580593af0f68327e3cc204d4d8e7 (diff)
[media] media: davinci: vpif_display: 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_display.c30
1 files changed, 12 insertions, 18 deletions
diff --git a/drivers/media/platform/davinci/vpif_display.c b/drivers/media/platform/davinci/vpif_display.c
index 6c521f23e40e..371af34a71be 100644
--- a/drivers/media/platform/davinci/vpif_display.c
+++ b/drivers/media/platform/davinci/vpif_display.c
@@ -1829,10 +1829,20 @@ vpif_int_err:
1829static int vpif_remove(struct platform_device *device) 1829static int vpif_remove(struct platform_device *device)
1830{ 1830{
1831 struct channel_obj *ch; 1831 struct channel_obj *ch;
1832 int i; 1832 struct resource *res;
1833 int irq_num;
1834 int i = 0;
1835
1836 while ((res = platform_get_resource(device, IORESOURCE_IRQ, i))) {
1837 for (irq_num = res->start; irq_num <= res->end; irq_num++)
1838 free_irq(irq_num,
1839 (void *)(&vpif_obj.dev[i]->channel_id));
1840 i++;
1841 }
1833 1842
1834 v4l2_device_unregister(&vpif_obj.v4l2_dev); 1843 v4l2_device_unregister(&vpif_obj.v4l2_dev);
1835 1844
1845 kfree(vpif_obj.sd);
1836 /* un-register device */ 1846 /* un-register device */
1837 for (i = 0; i < VPIF_DISPLAY_MAX_DEVICES; i++) { 1847 for (i = 0; i < VPIF_DISPLAY_MAX_DEVICES; i++) {
1838 /* Get the pointer to the channel object */ 1848 /* Get the pointer to the channel object */
@@ -1841,6 +1851,7 @@ static int vpif_remove(struct platform_device *device)
1841 video_unregister_device(ch->video_dev); 1851 video_unregister_device(ch->video_dev);
1842 1852
1843 ch->video_dev = NULL; 1853 ch->video_dev = NULL;
1854 kfree(vpif_obj.dev[i]);
1844 } 1855 }
1845 1856
1846 return 0; 1857 return 0;
@@ -1938,24 +1949,7 @@ static __init int vpif_init(void)
1938 */ 1949 */
1939static void vpif_cleanup(void) 1950static void vpif_cleanup(void)
1940{ 1951{
1941 struct platform_device *pdev;
1942 struct resource *res;
1943 int irq_num;
1944 int i = 0;
1945
1946 pdev = container_of(vpif_dev, struct platform_device, dev);
1947
1948 while ((res = platform_get_resource(pdev, IORESOURCE_IRQ, i))) {
1949 for (irq_num = res->start; irq_num <= res->end; irq_num++)
1950 free_irq(irq_num,
1951 (void *)(&vpif_obj.dev[i]->channel_id));
1952 i++;
1953 }
1954
1955 platform_driver_unregister(&vpif_driver); 1952 platform_driver_unregister(&vpif_driver);
1956 kfree(vpif_obj.sd);
1957 for (i = 0; i < VPIF_DISPLAY_MAX_DEVICES; i++)
1958 kfree(vpif_obj.dev[i]);
1959} 1953}
1960 1954
1961module_init(vpif_init); 1955module_init(vpif_init);