From patchwork Sat May 25 16:36:35 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lad, Prabhakar" X-Patchwork-Id: 2613731 Return-Path: X-Original-To: patchwork-davinci@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from bear.ext.ti.com (bear.ext.ti.com [192.94.94.41]) by patchwork2.kernel.org (Postfix) with ESMTP id 47562DF2A2 for ; Sat, 25 May 2013 16:41:42 +0000 (UTC) Received: from dflxv15.itg.ti.com ([128.247.5.124]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id r4PGeIDv028313; Sat, 25 May 2013 11:40:18 -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 r4PGeIh1006953; Sat, 25 May 2013 11:40:18 -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; Sat, 25 May 2013 11:40:17 -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 r4PGeHB2027266; Sat, 25 May 2013 11:40:17 -0500 Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id DD45F80627; Sat, 25 May 2013 11:40:17 -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 227108062B for ; Sat, 25 May 2013 11:38:50 -0500 (CDT) Received: from neches.ext.ti.com (neches.ext.ti.com [192.91.81.29]) by dflp52.itg.ti.com (8.13.7/8.13.8) with ESMTP id r4PGco51011953 for ; Sat, 25 May 2013 11:38:50 -0500 (CDT) Received: from mail6.bemta7.messagelabs.com (mail6.bemta7.messagelabs.com [216.82.255.55]) by neches.ext.ti.com (8.13.7/8.13.7) with ESMTP id r4PGcn6d002536 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sat, 25 May 2013 11:38:49 -0500 Received: from [216.82.253.147:8734] by server-4.bemta-7.messagelabs.com id C4/AF-04977-919E0A15; Sat, 25 May 2013 16:38:49 +0000 X-Env-Sender: prabhakar.csengg@gmail.com X-Msg-Ref: server-14.tower-165.messagelabs.com!1369499928!12672982!1 X-Originating-IP: [209.85.160.53] 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 11934 invoked from network); 25 May 2013 16:38:48 -0000 Received: from mail-pb0-f53.google.com (HELO mail-pb0-f53.google.com) (209.85.160.53) by server-14.tower-165.messagelabs.com with RC4-SHA encrypted SMTP; 25 May 2013 16:38:48 -0000 Received: by mail-pb0-f53.google.com with SMTP id un4so5349136pbc.12 for ; Sat, 25 May 2013 09:38:47 -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=0o6+IMccvzfzQspTIAaN21FNSKalM5hAtWgmcVAsWx4=; b=Ya721MDM+JpSD4Ubqs4NTB5/ovs5vVGu1toz5ENNEsLHSU4j59oaszI7Kmr6WuQclE ZkP7o+uTm5zSy5/cQ5NwNFf9DdWQsX+M+OS6qjq3smhI1IzGc9jaOU4Ng6aPL7Hc3X8G lH9gochEaTlghEx2JqoxeQX/GLurqAp0IllYU2TaA4QX5h/UHw7yFrREKOxGNZ+gzioh qKttOMkW4ytypfpPe13pArzCg1Bd40Ig4E9RcLTyjtUU//DR5KZUrLQ4wDYCQ6aaLqAu sA86lZCiJNNpE+n5IedsSAn2vQbiMvo+aQqMcSXkJGYQoMPlX5ZjkR+t2fSsODaIx3wa SHhA== X-Received: by 10.66.139.198 with SMTP id ra6mr23092501pab.140.1369499927914; Sat, 25 May 2013 09:38:47 -0700 (PDT) Received: from localhost.localdomain ([112.79.40.180]) by mx.google.com with ESMTPSA id kv2sm21040398pbc.28.2013.05.25.09.38.39 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Sat, 25 May 2013 09:38:47 -0700 (PDT) From: Prabhakar Lad To: Hans Verkuil , Mauro Carvalho Chehab , LMML , Laurent Pinchart Subject: [PATCH v2 4/5] media: davinci: vpif_capture: Convert to devm_* api Date: Sat, 25 May 2013 22:06:35 +0530 Message-ID: <1369499796-18762-5-git-send-email-prabhakar.csengg@gmail.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1369499796-18762-1-git-send-email-prabhakar.csengg@gmail.com> References: <1369499796-18762-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 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 | 73 +++++-------------------- 1 files changed, 13 insertions(+), 60 deletions(-) diff --git a/drivers/media/platform/davinci/vpif_capture.c b/drivers/media/platform/davinci/vpif_capture.c index caaf4fe..f37adf1 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 */ @@ -2207,13 +2206,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; } @@ -2229,14 +2223,16 @@ static int vpif_remove(struct platform_device *device) struct channel_obj *ch; 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; } @@ -2326,47 +2322,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);