From patchwork Mon Jun 17 15:20:44 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lad, Prabhakar" X-Patchwork-Id: 2734401 Return-Path: X-Original-To: patchwork-davinci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 3CE7C9F39E for ; Mon, 17 Jun 2013 15:22:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DADF52016E for ; Mon, 17 Jun 2013 15:22:11 +0000 (UTC) Received: from comal.ext.ti.com (comal.ext.ti.com [198.47.26.152]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 165532039E for ; Mon, 17 Jun 2013 15:22:05 +0000 (UTC) Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id r5HFM4ix019384 for ; Mon, 17 Jun 2013 10:22:04 -0500 Received: from DLEE70.ent.ti.com (dlee70.ent.ti.com [157.170.170.113]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id r5HFM41j009073 for ; Mon, 17 Jun 2013 10:22:04 -0500 Received: from dlelxv24.itg.ti.com (172.17.1.199) by DLEE70.ent.ti.com (157.170.170.113) with Microsoft SMTP Server id 14.2.342.3; Mon, 17 Jun 2013 10:22:04 -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 r5HFM4uA023252 for ; Mon, 17 Jun 2013 10:22:04 -0500 Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id 2CBBC8062A for ; Mon, 17 Jun 2013 10:22:04 -0500 (CDT) X-Original-To: davinci-linux-open-source@linux.davincidsp.com Delivered-To: davinci-linux-open-source@linux.davincidsp.com Received: from dflp51.itg.ti.com (dflp51.itg.ti.com [128.247.22.94]) by linux.omap.com (Postfix) with ESMTP id 43F8680627 for ; Mon, 17 Jun 2013 10:21:41 -0500 (CDT) Received: from red.ext.ti.com (red.ext.ti.com [192.94.93.37]) by dflp51.itg.ti.com (8.13.7/8.13.8) with ESMTP id r5HFLfPH006674 for ; Mon, 17 Jun 2013 10:21:41 -0500 (CDT) Received: from mail6.bemta7.messagelabs.com (mail6.bemta7.messagelabs.com [216.82.255.55]) by red.ext.ti.com (8.13.7/8.13.7) with ESMTP id r5HFLeZI006274 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 17 Jun 2013 10:21:40 -0500 Received: from [216.82.253.163:5168] by server-1.bemta-7.messagelabs.com id 6A/EC-06516-4892FB15; Mon, 17 Jun 2013 15:21:40 +0000 X-Env-Sender: prabhakar.csengg@gmail.com X-Msg-Ref: server-6.tower-166.messagelabs.com!1371482499!18139733!1 X-Originating-IP: [209.85.160.44] X-SpamReason: No, hits=0.2 required=7.0 tests=ML_RADAR_SPEW_LINKS_14, RCVD_ILLEGAL_IP,spamassassin: X-StarScan-Received: X-StarScan-Version: 6.9.6; banners=-,-,- X-VirusChecked: Checked Received: (qmail 6647 invoked from network); 17 Jun 2013 15:21:39 -0000 Received: from mail-pb0-f44.google.com (HELO mail-pb0-f44.google.com) (209.85.160.44) by server-6.tower-166.messagelabs.com with RC4-SHA encrypted SMTP; 17 Jun 2013 15:21:39 -0000 Received: by mail-pb0-f44.google.com with SMTP id uo1so2884275pbc.31 for ; Mon, 17 Jun 2013 08:21:39 -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=F39/RVj+3T2sIK/uHuo6J1kEnJC3s4v79ePeW7PBIHQ=; b=QRy6Hf2CqWtA4lxEzUv/nEbkPuhrNFEXAxqDnudTsFo6BbTfbTcpGdlRCKe7nVjewS 6o5yjbFwTxDa/QBZAE8XJk9s3npLqHzyzdy12xTAy5OqBG6ogcmvqlAWBR7Uf6vsxQD0 o2fdFgQ7Hjua3k8Y50c6Oq69Lir92vNMeba0Gae4Y/K1Fj+U5vQJoaASHOU+4dCulOEi yvd2PsGJK1DOR5lzBK0xqilZM0D3vHNa+EqYus/GhAp8VAJWjunELilH6DNWy3gMNRGR rTVRiJpARv8PWV0WetBCMsPYkbvFJMf7kAXt103HVLBSBpJ9YfSaRG0rHs44/rcZv/zQ dfAQ== X-Received: by 10.66.19.234 with SMTP id i10mr13435083pae.152.1371482499275; Mon, 17 Jun 2013 08:21:39 -0700 (PDT) Received: from localhost.localdomain ([1.23.210.59]) by mx.google.com with ESMTPSA id fp2sm14187573pbb.36.2013.06.17.08.21.35 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 17 Jun 2013 08:21:38 -0700 (PDT) From: Prabhakar Lad To: Mauro Carvalho Chehab , LMML , DLOS , Hans Verkuil , Laurent Pinchart Subject: [PATCH v4 04/11] media: davinci: vpif_capture: move the freeing of irq and global variables to remove() Date: Mon, 17 Jun 2013 20:50:44 +0530 Message-ID: <1371482451-18314-5-git-send-email-prabhakar.csengg@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1371482451-18314-1-git-send-email-prabhakar.csengg@gmail.com> References: <1371482451-18314-1-git-send-email-prabhakar.csengg@gmail.com> CC: 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+patchwork-davinci=patchwork.kernel.org@linux.davincidsp.com X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 | 29 ++++++++++--------------- 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/drivers/media/platform/davinci/vpif_capture.c b/drivers/media/platform/davinci/vpif_capture.c index d004531..7d3c449 100644 --- a/drivers/media/platform/davinci/vpif_capture.c +++ b/drivers/media/platform/davinci/vpif_capture.c @@ -2159,17 +2159,27 @@ vpif_int_err: */ static int vpif_remove(struct platform_device *device) { - int i; struct channel_obj *ch; + struct resource *res; + int irq_num, i = 0; + + while ((res = platform_get_resource(device, 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; } @@ -2281,24 +2291,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 */