From patchwork Thu May 16 12:58:20 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lad, Prabhakar" X-Patchwork-Id: 2578021 Return-Path: X-Original-To: patchwork-davinci@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from arroyo.ext.ti.com (arroyo.ext.ti.com [192.94.94.40]) by patchwork1.kernel.org (Postfix) with ESMTP id 03B1E3FE1F for ; Thu, 16 May 2013 13:02:08 +0000 (UTC) Received: from dflxv15.itg.ti.com ([128.247.5.124]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id r4GD0XLl013255; Thu, 16 May 2013 08:00:33 -0500 Received: from DFLE73.ent.ti.com (dfle73.ent.ti.com [128.247.5.110]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id r4GD0Xug009880; Thu, 16 May 2013 08:00:33 -0500 Received: from dlelxv24.itg.ti.com (172.17.1.199) by DFLE73.ent.ti.com (128.247.5.110) with Microsoft SMTP Server id 14.2.342.3; Thu, 16 May 2013 08:00:32 -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 r4GD0Wen010993; Thu, 16 May 2013 08:00:32 -0500 Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id 840708062F; Thu, 16 May 2013 08:00:32 -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 9241B806A2 for ; Thu, 16 May 2013 08:00:04 -0500 (CDT) Received: from white.ext.ti.com (white.ext.ti.com [192.94.93.38]) by dflp51.itg.ti.com (8.13.7/8.13.8) with ESMTP id r4GD04IA014892 for ; Thu, 16 May 2013 08:00:04 -0500 (CDT) Received: from mail6.bemta7.messagelabs.com (mail6.bemta7.messagelabs.com [216.82.255.55]) by white.ext.ti.com (8.13.7/8.13.7) with ESMTP id r4GD04Ig027077 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 16 May 2013 08:00:04 -0500 Received: from [216.82.253.147:23607] by server-16.bemta-7.messagelabs.com id 18/02-22461-458D4915; Thu, 16 May 2013 13:00:04 +0000 X-Env-Sender: prabhakar.csengg@gmail.com X-Msg-Ref: server-12.tower-165.messagelabs.com!1368709202!10657041!1 X-Originating-IP: [209.85.192.179] X-SpamReason: No, hits=0.5 required=7.0 tests=BODY_RANDOM_LONG, ML_RADAR_SPEW_LINKS_14,spamassassin: X-StarScan-Received: X-StarScan-Version: 6.9.6; banners=-,-,- X-VirusChecked: Checked Received: (qmail 22210 invoked from network); 16 May 2013 13:00:02 -0000 Received: from mail-pd0-f179.google.com (HELO mail-pd0-f179.google.com) (209.85.192.179) by server-12.tower-165.messagelabs.com with RC4-SHA encrypted SMTP; 16 May 2013 13:00:02 -0000 Received: by mail-pd0-f179.google.com with SMTP id q10so2312118pdj.10 for ; Thu, 16 May 2013 06:00:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=RVL6T44NeAntbqNLQI1x9ddFP+mntRHaJdBzPG3/9yA=; b=bvSZccknLtE2NBbM6o7efto9V7blfVxV8krPjM20r4DGdfPcmr/YlLWbnlMl89CQ+d 47sFEXo7otFP0qriafMRN6E5SCxUhz/q/HcYDyY3Pmqc9LiZD+Nd5zJ/h6Ux7Cqz6D0i HKzzX8YFGvFIn5a3/jNoDMT0caFFAnKwNdMw50DGTR6SENc+ttt8c/ARY9ZEjSvRJETa 540nORqsjq4nYzs5hTfEORgWWOqRuXpXcPfNRZy8sA5jrODXNawiNuh9mxS2J4fjLsOF DsZJ6F+WDA/SavOF11CTUAE+NODMYkQB4eAdC0kCv4BdBjoJaF9M/wnWufPaDiOr3oFp tXFQ== X-Received: by 10.66.248.68 with SMTP id yk4mr44387856pac.137.1368709201949; Thu, 16 May 2013 06:00:01 -0700 (PDT) Received: from localhost.localdomain ([122.166.13.141]) by mx.google.com with ESMTPSA id v7sm6705907pbq.32.2013.05.16.05.59.58 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 16 May 2013 06:00:01 -0700 (PDT) From: Lad Prabhakar To: DLOS , LMML Subject: [PATCH 5/7] media: davinci: vpif_capture: Convert to devm_* api Date: Thu, 16 May 2013 18:28:20 +0530 Message-ID: <1368709102-2854-6-git-send-email-prabhakar.csengg@gmail.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1368709102-2854-1-git-send-email-prabhakar.csengg@gmail.com> References: <1368709102-2854-1-git-send-email-prabhakar.csengg@gmail.com> CC: Hans Verkuil , LKML , Laurent Pinchart , Mauro Carvalho Chehab 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 use devm_request_irq() instead of request_irq(). This ensures more consistent error values and simplifies error paths. use module_platform_driver to simplify the code. Signed-off-by: Lad, Prabhakar --- drivers/media/platform/davinci/vpif_capture.c | 75 +++++-------------------- 1 files changed, 14 insertions(+), 61 deletions(-) diff --git a/drivers/media/platform/davinci/vpif_capture.c b/drivers/media/platform/davinci/vpif_capture.c index c26b6e4..3e48c9c 100644 --- a/drivers/media/platform/davinci/vpif_capture.c +++ b/drivers/media/platform/davinci/vpif_capture.c @@ -2082,14 +2082,13 @@ static __init int vpif_probe(struct platform_device *pdev) while ((res = platform_get_resource(pdev, IORESOURCE_IRQ, res_idx))) { for (i = res->start; i <= res->end; i++) { - if (request_irq(i, vpif_channel_isr, IRQF_SHARED, - "VPIF_Capture", (void *) - (&vpif_obj.dev[res_idx]->channel_id))) { - err = -EBUSY; - for (j = 0; j < i; j++) - free_irq(j, (void *) - (&vpif_obj.dev[res_idx]->channel_id)); - goto vpif_int_err; + err = devm_request_irq(&pdev->dev, i, vpif_channel_isr, + IRQF_SHARED, "VPIF_Capture", + (void *)(&vpif_obj.dev[res_idx]-> + channel_id)); + if (err) { + err = -EINVAL; + goto vpif_unregister; } } res_idx++; @@ -2106,7 +2105,7 @@ static __init int vpif_probe(struct platform_device *pdev) video_device_release(ch->video_dev); } err = -ENOMEM; - goto vpif_int_err; + goto vpif_unregister; } /* Initialize field of video device */ @@ -2206,13 +2205,8 @@ vpif_sd_error: /* Note: does nothing if ch->video_dev == NULL */ video_device_release(ch->video_dev); } -vpif_int_err: +vpif_unregister: v4l2_device_unregister(&vpif_obj.v4l2_dev); - for (i = 0; i < res_idx; i++) { - res = platform_get_resource(pdev, IORESOURCE_IRQ, i); - for (j = res->start; j <= res->end; j++) - free_irq(j, (void *)(&vpif_obj.dev[i]->channel_id)); - } return err; } @@ -2224,18 +2218,20 @@ vpif_int_err: */ static int vpif_remove(struct platform_device *device) { - int i; struct channel_obj *ch; + int 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; } @@ -2325,47 +2321,4 @@ static __refdata struct platform_driver vpif_driver = { .remove = vpif_remove, }; -/** - * vpif_init: initialize the vpif driver - * - * This function registers device and driver to the kernel, requests irq - * handler and allocates memory - * for channel objects - */ -static __init int vpif_init(void) -{ - return platform_driver_register(&vpif_driver); -} - -/** - * vpif_cleanup : This function clean up the vpif capture resources - * - * This will un-registers device and driver to the kernel, frees - * requested irq handler and de-allocates memory allocated for channel - * objects. - */ -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 */ -module_init(vpif_init); -module_exit(vpif_cleanup); +module_platform_driver(vpif_driver);