From patchwork Wed Nov 12 16:15:51 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 5290821 Return-Path: X-Original-To: patchwork-linux-fbdev@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 469DBC11AC for ; Wed, 12 Nov 2014 16:16:51 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 597702017D for ; Wed, 12 Nov 2014 16:16:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7079820107 for ; Wed, 12 Nov 2014 16:16:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753159AbaKLQQs (ORCPT ); Wed, 12 Nov 2014 11:16:48 -0500 Received: from mx1.redhat.com ([209.132.183.28]:57922 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753009AbaKLQQs (ORCPT ); Wed, 12 Nov 2014 11:16:48 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id sACGGDmK010831 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 12 Nov 2014 11:16:13 -0500 Received: from shalem.localdomain.com (vpn1-6-39.ams2.redhat.com [10.36.6.39]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id sACGFsUn010837; Wed, 12 Nov 2014 11:16:10 -0500 From: Hans de Goede To: Tomi Valkeinen Cc: Stephen Warren , Jean-Christophe Plagniol-Villard , Grant Likely , Rob Herring , Luc Verhaegen , Maxime Ripard , Mike Turquette , David Herrmann , Geert Uytterhoeven , linux-fbdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree , linux-sunxi@googlegroups.com, Hans de Goede Subject: [PATCH v5 4/5] simplefb: add goto error path to probe Date: Wed, 12 Nov 2014 17:15:51 +0100 Message-Id: <1415808952-23549-5-git-send-email-hdegoede@redhat.com> In-Reply-To: <1415808952-23549-1-git-send-email-hdegoede@redhat.com> References: <1415808952-23549-1-git-send-email-hdegoede@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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: Luc Verhaegen Use the usual kernel style of goto error_foo to free resources on probe error. This is a preparation patch for adding clocks support. While at it also update ioremap_wc error return from ENODEV to ENOMEM. Signed-off-by: Luc Verhaegen Acked-by: Stephen Warren Reviewed-by: Hans de Goede Signed-off-by: Hans de Goede Acked-by: Geert Uytterhoeven Reviewed-by: Maxime Ripard Reviewed-by: David Herrmann Acked-by: Grant Likely --- Changes in v5: -Improved commit message --- drivers/video/fbdev/simplefb.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/drivers/video/fbdev/simplefb.c b/drivers/video/fbdev/simplefb.c index ec112c1..cdcf1fe 100644 --- a/drivers/video/fbdev/simplefb.c +++ b/drivers/video/fbdev/simplefb.c @@ -220,8 +220,8 @@ static int simplefb_probe(struct platform_device *pdev) info->apertures = alloc_apertures(1); if (!info->apertures) { - framebuffer_release(info); - return -ENOMEM; + ret = -ENOMEM; + goto error_fb_release; } info->apertures->ranges[0].base = info->fix.smem_start; info->apertures->ranges[0].size = info->fix.smem_len; @@ -231,8 +231,8 @@ static int simplefb_probe(struct platform_device *pdev) info->screen_base = ioremap_wc(info->fix.smem_start, info->fix.smem_len); if (!info->screen_base) { - framebuffer_release(info); - return -ENODEV; + ret = -ENOMEM; + goto error_fb_release; } info->pseudo_palette = par->palette; @@ -247,14 +247,18 @@ static int simplefb_probe(struct platform_device *pdev) ret = register_framebuffer(info); if (ret < 0) { dev_err(&pdev->dev, "Unable to register simplefb: %d\n", ret); - iounmap(info->screen_base); - framebuffer_release(info); - return ret; + goto error_unmap; } dev_info(&pdev->dev, "fb%d: simplefb registered!\n", info->node); return 0; + +error_unmap: + iounmap(info->screen_base); +error_fb_release: + framebuffer_release(info); + return ret; } static int simplefb_remove(struct platform_device *pdev)