From patchwork Sun May 26 12:00:07 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lad, Prabhakar" X-Patchwork-Id: 2615151 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 14761DFB79 for ; Sun, 26 May 2013 12:04:21 +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 r4QC2iIK030452; Sun, 26 May 2013 07:02:44 -0500 Received: from DLEE71.ent.ti.com (dlee71.ent.ti.com [157.170.170.114]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id r4QC2hKg001654; Sun, 26 May 2013 07:02:43 -0500 Received: from dlelxv24.itg.ti.com (172.17.1.199) by DLEE71.ent.ti.com (157.170.170.114) with Microsoft SMTP Server id 14.2.342.3; Sun, 26 May 2013 07:02:43 -0500 Received: from linux.omap.com (dlelxs01.itg.ti.com [157.170.227.31]) by dlelxv24.itg.ti.com (8.13.8/8.13.8) with ESMTP id r4QC2hJE019116; Sun, 26 May 2013 07:02:43 -0500 Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id 79A2B8062E; Sun, 26 May 2013 07:02:43 -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 147CA80631 for ; Sun, 26 May 2013 07:02:38 -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 r4QC2bRZ003398 for ; Sun, 26 May 2013 07:02:37 -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 r4QC2brQ018471 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sun, 26 May 2013 07:02:37 -0500 Received: from [216.82.253.163:32942] by server-12.bemta-7.messagelabs.com id B2/E3-15214-DD9F1A15; Sun, 26 May 2013 12:02:37 +0000 X-Env-Sender: prabhakar.csengg@gmail.com X-Msg-Ref: server-2.tower-166.messagelabs.com!1369569756!10006820!1 X-Originating-IP: [209.85.220.54] 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 32428 invoked from network); 26 May 2013 12:02:36 -0000 Received: from mail-pa0-f54.google.com (HELO mail-pa0-f54.google.com) (209.85.220.54) by server-2.tower-166.messagelabs.com with RC4-SHA encrypted SMTP; 26 May 2013 12:02:36 -0000 Received: by mail-pa0-f54.google.com with SMTP id kx1so5898895pab.27 for ; Sun, 26 May 2013 05:02:36 -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=Kcr/FlNRFQcMlmJzlNvNxXdXRqtx2G7vpnsHpkD/Pi4=; b=VDocJR7BIy/hl7Uw1sMpnDdXj84yjdxdqr6zwDhoKoGmoSeij+iN7J7noinSTIHk4R q5IowxDR1TaJ3inT1LcwivBYq5u3yv0lomVF5m28ZzBJssmUJHXnQI7eFMKb511Yugk1 z/bSpIZYYqoMJn9KfD7X4Afb9IRtO8p8ZL1X8kM7PooaKrjZsYdjeA8+E2kPg8hnwifE cJlqy6762VhVbvc19MLA2OhfTB59aAWGGy5I+J00CLAqql87EV50bqew4Mwf6lneaOnk nXLatLkTTO90hJzd30e6wV3iorY+bZHKVdmiFDSRJphBV+1JeWpHvqlY2hfGY+Bbpalc Sr0A== X-Received: by 10.68.105.131 with SMTP id gm3mr25544037pbb.168.1369569756034; Sun, 26 May 2013 05:02:36 -0700 (PDT) Received: from localhost.localdomain ([112.79.41.196]) by mx.google.com with ESMTPSA id ri8sm24237417pbc.3.2013.05.26.05.02.26 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Sun, 26 May 2013 05:02:35 -0700 (PDT) From: Prabhakar Lad To: Hans Verkuil , Mauro Carvalho Chehab , LMML , Laurent Pinchart Subject: [PATCH v3 4/9] media: davinci: vpif_capture: move the freeing of irq and global variables to remove() Date: Sun, 26 May 2013 17:30:07 +0530 Message-ID: <1369569612-30915-5-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_capture.c | 31 ++++++++++-------------- 1 files changed, 13 insertions(+), 18 deletions(-) diff --git a/drivers/media/platform/davinci/vpif_capture.c b/drivers/media/platform/davinci/vpif_capture.c index caaf4fe..f8b7304 100644 --- a/drivers/media/platform/davinci/vpif_capture.c +++ b/drivers/media/platform/davinci/vpif_capture.c @@ -2225,17 +2225,29 @@ vpif_int_err: */ static int vpif_remove(struct platform_device *device) { - int i; + struct platform_device *pdev; struct channel_obj *ch; + struct resource *res; + int irq_num, 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_CAPTURE_MAX_DEVICES; i++) { /* Get the pointer to the channel object */ ch = vpif_obj.dev[i]; /* Unregister video device */ video_unregister_device(ch->video_dev); + kfree(vpif_obj.dev[i]); } return 0; } @@ -2347,24 +2359,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_CAPTURE_MAX_DEVICES; i++) - kfree(vpif_obj.dev[i]); } /* Function for module initialization and cleanup */