From patchwork Sun May 26 12:00:10 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prabhakar X-Patchwork-Id: 2615221 Return-Path: X-Original-To: patchwork-davinci@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from comal.ext.ti.com (comal.ext.ti.com [198.47.26.152]) by patchwork2.kernel.org (Postfix) with ESMTP id 37C90DFB79 for ; Sun, 26 May 2013 12:07:00 +0000 (UTC) Received: from dflxv15.itg.ti.com ([128.247.5.124]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id r4QC5UtD031845; Sun, 26 May 2013 07:05:30 -0500 Received: from DLEE70.ent.ti.com (dlee70.ent.ti.com [157.170.170.113]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id r4QC5UZ2008262; Sun, 26 May 2013 07:05:30 -0500 Received: from dlelxv23.itg.ti.com (172.17.1.198) by DLEE70.ent.ti.com (157.170.170.113) with Microsoft SMTP Server id 14.2.342.3; Sun, 26 May 2013 07:05:30 -0500 Received: from linux.omap.com (dlelxs01.itg.ti.com [157.170.227.31]) by dlelxv23.itg.ti.com (8.13.8/8.13.8) with ESMTP id r4QC5U0v021292; Sun, 26 May 2013 07:05:30 -0500 Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id 28CF88062C; Sun, 26 May 2013 07:05:30 -0500 (CDT) X-Original-To: davinci-linux-open-source@linux.davincidsp.com Delivered-To: davinci-linux-open-source@linux.davincidsp.com Received: from dflp52.itg.ti.com (dflp52.itg.ti.com [128.247.22.96]) by linux.omap.com (Postfix) with ESMTP id 1238680627 for ; Sun, 26 May 2013 07:03:13 -0500 (CDT) Received: from medina.ext.ti.com (medina.ext.ti.com [192.91.81.31]) by dflp52.itg.ti.com (8.13.7/8.13.8) with ESMTP id r4QC3Cip003620 for ; Sun, 26 May 2013 07:03:12 -0500 (CDT) Received: from mail6.bemta7.messagelabs.com (mail6.bemta7.messagelabs.com [216.82.255.55]) by medina.ext.ti.com (8.13.7/8.13.7) with ESMTP id r4QC3C5Q018558 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sun, 26 May 2013 07:03:12 -0500 Received: from [216.82.253.163:10829] by server-5.bemta-7.messagelabs.com id 57/93-11504-00AF1A15; Sun, 26 May 2013 12:03:12 +0000 X-Env-Sender: prabhakar.csengg@gmail.com X-Msg-Ref: server-15.tower-166.messagelabs.com!1369569790!13347696!1 X-Originating-IP: [209.85.192.177] X-SpamReason: No, hits=0.0 required=7.0 tests=ML_RADAR_SPEW_LINKS_14, spamassassin: X-StarScan-Received: X-StarScan-Version: 6.9.6; banners=-,-,- X-VirusChecked: Checked Received: (qmail 15228 invoked from network); 26 May 2013 12:03:11 -0000 Received: from mail-pd0-f177.google.com (HELO mail-pd0-f177.google.com) (209.85.192.177) by server-15.tower-166.messagelabs.com with RC4-SHA encrypted SMTP; 26 May 2013 12:03:11 -0000 Received: by mail-pd0-f177.google.com with SMTP id u11so5704143pdi.36 for ; Sun, 26 May 2013 05:03:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=ECL8XSy0fEJR0ChLTGLslQXieITH5YrefmFIqLkdXcQ=; b=zy9lpjkBlDlEuPBcLr3xqEuVlgoTq3SZSTd7PJrGXsJ5px4VEobvWzrXzEsYkmaXfA h6E3l0V+SHIAH2SwLkpTHlQtyerWdsQm+YDYIBkmO3H1w56lEiPUV1sHUNtlk1+3dyg/ /opyo7EJIgtamD5LnIlOQY/vIrOrUU6W852YvCTc0eTB8sGIM4hAEPCd3pAfafj2vDd0 2XyaXerR5iSIHWT315zZz30kZ/rco8Dh8RoVTljOnvXojb+V7lnJgYDZDeO+Nf+t0sM9 fsBnvOaRG/xy3sKfnmR3cV8oLCpGeGacU5h9om2REyUgl8GGtfGLirn2JqT9aFkgsTNo 7Z+w== X-Received: by 10.66.50.4 with SMTP id y4mr25963058pan.216.1369569790713; Sun, 26 May 2013 05:03:10 -0700 (PDT) Received: from localhost.localdomain ([112.79.41.196]) by mx.google.com with ESMTPSA id ri8sm24237417pbc.3.2013.05.26.05.02.56 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Sun, 26 May 2013 05:03:09 -0700 (PDT) From: Prabhakar Lad To: Hans Verkuil , Mauro Carvalho Chehab , LMML , Laurent Pinchart Subject: [PATCH v3 7/9] media: davinci: vpif_display: move the freeing of irq and global variables to remove() Date: Sun, 26 May 2013 17:30:10 +0530 Message-ID: <1369569612-30915-8-git-send-email-prabhakar.csengg@gmail.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1369569612-30915-1-git-send-email-prabhakar.csengg@gmail.com> References: <1369569612-30915-1-git-send-email-prabhakar.csengg@gmail.com> CC: DLOS , LKML X-BeenThere: davinci-linux-open-source@linux.davincidsp.com X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: Errors-To: davinci-linux-open-source-bounces@linux.davincidsp.com From: Lad, Prabhakar 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 --- drivers/media/platform/davinci/vpif_display.c | 32 +++++++++++-------------- 1 files changed, 14 insertions(+), 18 deletions(-) diff --git a/drivers/media/platform/davinci/vpif_display.c b/drivers/media/platform/davinci/vpif_display.c index 5b6f906..9c308e7 100644 --- a/drivers/media/platform/davinci/vpif_display.c +++ b/drivers/media/platform/davinci/vpif_display.c @@ -1894,11 +1894,23 @@ vpif_int_err: */ static int vpif_remove(struct platform_device *device) { + struct platform_device *pdev; struct channel_obj *ch; - int i; + struct resource *res; + int irq_num; + int i = 0; + + pdev = container_of(vpif_dev, struct platform_device, dev); + while ((res = platform_get_resource(pdev, IORESOURCE_IRQ, i))) { + for (irq_num = res->start; irq_num <= res->end; irq_num++) + free_irq(irq_num, + (void *)(&vpif_obj.dev[i]->channel_id)); + i++; + } v4l2_device_unregister(&vpif_obj.v4l2_dev); + kfree(vpif_obj.sd); /* un-register device */ for (i = 0; i < VPIF_DISPLAY_MAX_DEVICES; i++) { /* Get the pointer to the channel object */ @@ -1907,6 +1919,7 @@ static int vpif_remove(struct platform_device *device) video_unregister_device(ch->video_dev); ch->video_dev = NULL; + kfree(vpif_obj.dev[i]); } return 0; @@ -2004,24 +2017,7 @@ static __init int vpif_init(void) */ static void vpif_cleanup(void) { - struct platform_device *pdev; - struct resource *res; - int irq_num; - int i = 0; - - pdev = container_of(vpif_dev, struct platform_device, dev); - - while ((res = platform_get_resource(pdev, IORESOURCE_IRQ, i))) { - for (irq_num = res->start; irq_num <= res->end; irq_num++) - free_irq(irq_num, - (void *)(&vpif_obj.dev[i]->channel_id)); - i++; - } - platform_driver_unregister(&vpif_driver); - kfree(vpif_obj.sd); - for (i = 0; i < VPIF_DISPLAY_MAX_DEVICES; i++) - kfree(vpif_obj.dev[i]); } module_init(vpif_init);