From patchwork Tue Jul 30 12:25:33 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guennadi Liakhovetski X-Patchwork-Id: 2835600 Return-Path: X-Original-To: patchwork-linux-media@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 7DECD9F4D4 for ; Tue, 30 Jul 2013 12:26:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5637620348 for ; Tue, 30 Jul 2013 12:26:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9756420303 for ; Tue, 30 Jul 2013 12:26:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753371Ab3G3M03 (ORCPT ); Tue, 30 Jul 2013 08:26:29 -0400 Received: from moutng.kundenserver.de ([212.227.126.187]:49541 "EHLO moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753354Ab3G3MZk (ORCPT ); Tue, 30 Jul 2013 08:25:40 -0400 Received: from axis700.grange (dslb-094-220-155-198.pools.arcor-ip.net [94.220.155.198]) by mrelayeu.kundenserver.de (node=mreu2) with ESMTP (Nemesis) id 0MWfMN-1UakYb2Qo7-00Xg2W; Tue, 30 Jul 2013 14:25:38 +0200 Received: from 6a.grange (6a.grange [192.168.1.11]) by axis700.grange (Postfix) with ESMTPS id 0C01640BB4 for ; Tue, 30 Jul 2013 14:25:38 +0200 (CEST) Received: from lyakh by 6a.grange with local (Exim 4.72) (envelope-from ) id 1V48zh-0003vC-Pe for linux-media@vger.kernel.org; Tue, 30 Jul 2013 14:25:37 +0200 From: Guennadi Liakhovetski To: linux-media@vger.kernel.org Subject: [PATCH 1/6] V4L2: mx3_camera: convert to managed resource allocation Date: Tue, 30 Jul 2013 14:25:33 +0200 Message-Id: <1375187137-15045-3-git-send-email-g.liakhovetski@gmx.de> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1375187137-15045-1-git-send-email-g.liakhovetski@gmx.de> References: <1375187137-15045-1-git-send-email-g.liakhovetski@gmx.de> X-Provags-ID: V02:K0:7dnTjTuO6QJ9+VjDGga2ARmX9VJS4SKfCtbBYvUki1L zHu3biuPopPL/Z9se0NEBf0iTlXAvQ94y6D+xTBF1WWTE9qJqV AigFg6zwFDYPU40+nv7jpUITYfR2JzARfP5vnDs74jE5it9FCK aN0TKiHbUUneNUhX9jPrDAf5KEi3c5zEZSBFZPyIJnyMTwlHrE 5ptaMFL5RbQ8LYJ4VNtKxC08JVDafBLlqe4mGRAouNOZNva6GW UmFhMlt46uCYXmF2N+NLgUIKi7Bs+XjWwtYTApa7WCIwaPA+EG rLnmGnzzk1nGiRjIdcuAjR3WfjRp/XFR9Gk7yKlPVEYzkD7trv X/62JA8aqtxW+Gs+qInSsbdLCuojufEgKHtKPe2VDEV/pUkawZ Wro/eAqlsf3rw== Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-8.4 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, 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 Use devm_* resource allocators to simplify the driver's probe and clean up paths. Signed-off-by: Guennadi Liakhovetski --- drivers/media/platform/soc_camera/mx3_camera.c | 47 +++++------------------- 1 files changed, 10 insertions(+), 37 deletions(-) diff --git a/drivers/media/platform/soc_camera/mx3_camera.c b/drivers/media/platform/soc_camera/mx3_camera.c index 1047e3e..e526096 100644 --- a/drivers/media/platform/soc_camera/mx3_camera.c +++ b/drivers/media/platform/soc_camera/mx3_camera.c @@ -1151,23 +1151,19 @@ static int mx3_camera_probe(struct platform_device *pdev) struct soc_camera_host *soc_host; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!res) { - err = -ENODEV; - goto egetres; - } + base = devm_ioremap_resource(&pdev->dev, res); + if (IS_ERR(base)) + return PTR_ERR(base); - mx3_cam = vzalloc(sizeof(*mx3_cam)); + mx3_cam = devm_kzalloc(&pdev->dev, sizeof(*mx3_cam), GFP_KERNEL); if (!mx3_cam) { dev_err(&pdev->dev, "Could not allocate mx3 camera object\n"); - err = -ENOMEM; - goto ealloc; + return -ENOMEM; } - mx3_cam->clk = clk_get(&pdev->dev, NULL); - if (IS_ERR(mx3_cam->clk)) { - err = PTR_ERR(mx3_cam->clk); - goto eclkget; - } + mx3_cam->clk = devm_clk_get(&pdev->dev, NULL); + if (IS_ERR(mx3_cam->clk)) + return PTR_ERR(mx3_cam->clk); mx3_cam->pdata = pdev->dev.platform_data; mx3_cam->platform_flags = mx3_cam->pdata->flags; @@ -1201,13 +1197,6 @@ static int mx3_camera_probe(struct platform_device *pdev) INIT_LIST_HEAD(&mx3_cam->capture); spin_lock_init(&mx3_cam->lock); - base = ioremap(res->start, resource_size(res)); - if (!base) { - pr_err("Couldn't map %x@%x\n", resource_size(res), res->start); - err = -ENOMEM; - goto eioremap; - } - mx3_cam->base = base; soc_host = &mx3_cam->soc_host; @@ -1218,10 +1207,8 @@ static int mx3_camera_probe(struct platform_device *pdev) soc_host->nr = pdev->id; mx3_cam->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev); - if (IS_ERR(mx3_cam->alloc_ctx)) { - err = PTR_ERR(mx3_cam->alloc_ctx); - goto eallocctx; - } + if (IS_ERR(mx3_cam->alloc_ctx)) + return PTR_ERR(mx3_cam->alloc_ctx); err = soc_camera_host_register(soc_host); if (err) @@ -1234,14 +1221,6 @@ static int mx3_camera_probe(struct platform_device *pdev) ecamhostreg: vb2_dma_contig_cleanup_ctx(mx3_cam->alloc_ctx); -eallocctx: - iounmap(base); -eioremap: - clk_put(mx3_cam->clk); -eclkget: - vfree(mx3_cam); -ealloc: -egetres: return err; } @@ -1251,12 +1230,8 @@ static int mx3_camera_remove(struct platform_device *pdev) struct mx3_camera_dev *mx3_cam = container_of(soc_host, struct mx3_camera_dev, soc_host); - clk_put(mx3_cam->clk); - soc_camera_host_unregister(soc_host); - iounmap(mx3_cam->base); - /* * The channel has either not been allocated, * or should have been released @@ -1266,8 +1241,6 @@ static int mx3_camera_remove(struct platform_device *pdev) vb2_dma_contig_cleanup_ctx(mx3_cam->alloc_ctx); - vfree(mx3_cam); - dmaengine_put(); return 0;