From patchwork Thu Apr 4 09:31:16 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 15898 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 825D44C13C2 for ; Thu, 4 Apr 2013 09:31:31 +0000 (UTC) Received: from mail-qa0-f69.google.com (mail-qa0-f69.google.com [209.85.216.69]) by fiordland.canonical.com (Postfix) with ESMTP id 19431A180A3 for ; Thu, 4 Apr 2013 09:31:31 +0000 (UTC) Received: by mail-qa0-f69.google.com with SMTP id o13sf3757087qaj.4 for ; Thu, 04 Apr 2013 02:31:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:mime-version:x-beenthere:x-received:received-spf :x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:x-received:from:to:cc:subject:date:message-id:x-mailer :x-gm-message-state:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-google-group-id:list-post:list-help:list-archive:list-unsubscribe; bh=sIlxRZzbT2LpEJ+gQ34ANsIxP3q+HJk5R9y2vu+U+7k=; b=TsYRIDWqFBgS9NnfGATqyTWBBgYN72AOsjakfPrNx54yF//Acv33NWeN0tq6pqztEj GsNqVGUxoWNm/Br4yDV3NSNkI4tmnvgKhZj75Gi+XsbU1Dhla4ik2YwLwTdhjyDSjWVK GwJPeyEBP8g4I620j4Q4T7IKz9dLojz85SCUOV7vZuJce8FX5ZMD8YeUt3c2IwN/vLw6 1WC5D/EB1IAlbveswOA/zzhJ1fVk4cf25nVKJbpUWRHt8kPo3VvLHZmLJizCSbpmit1r DbUgT614NSC5IGX64Z0VyobQure2UYx3mAh+QyipEVOv+GHJlhN4xq7ws5lfsMjDyqFm bDSQ== X-Received: by 10.224.185.79 with SMTP id cn15mr2970685qab.4.1365067890611; Thu, 04 Apr 2013 02:31:30 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.130.134 with SMTP id oe6ls1356645qeb.46.gmail; Thu, 04 Apr 2013 02:31:30 -0700 (PDT) X-Received: by 10.220.153.143 with SMTP id k15mr4134630vcw.13.1365067890280; Thu, 04 Apr 2013 02:31:30 -0700 (PDT) Received: from mail-vb0-x22e.google.com (mail-vb0-x22e.google.com [2607:f8b0:400c:c02::22e]) by mx.google.com with ESMTPS id q17si7710993vcw.30.2013.04.04.02.31.30 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 04 Apr 2013 02:31:30 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400c:c02::22e is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=2607:f8b0:400c:c02::22e; Received: by mail-vb0-f46.google.com with SMTP id 11so1138765vbe.33 for ; Thu, 04 Apr 2013 02:31:30 -0700 (PDT) X-Received: by 10.58.168.208 with SMTP id zy16mr4125237veb.3.1365067890109; Thu, 04 Apr 2013 02:31:30 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.58.85.136 with SMTP id h8csp207504vez; Thu, 4 Apr 2013 02:31:29 -0700 (PDT) X-Received: by 10.194.178.100 with SMTP id cx4mr8236104wjc.47.1365067888490; Thu, 04 Apr 2013 02:31:28 -0700 (PDT) Received: from mail-we0-x22d.google.com (mail-we0-x22d.google.com [2a00:1450:400c:c03::22d]) by mx.google.com with ESMTPS id e4si4002331wjy.166.2013.04.04.02.31.27 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 04 Apr 2013 02:31:28 -0700 (PDT) Received-SPF: neutral (google.com: 2a00:1450:400c:c03::22d is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=2a00:1450:400c:c03::22d; Received: by mail-we0-f173.google.com with SMTP id t57so1848923wey.18 for ; Thu, 04 Apr 2013 02:31:27 -0700 (PDT) X-Received: by 10.181.12.5 with SMTP id em5mr7989851wid.24.1365067887882; Thu, 04 Apr 2013 02:31:27 -0700 (PDT) Received: from localhost.localdomain (cpc34-aztw25-2-0-cust250.18-1.cable.virginmedia.com. [86.16.136.251]) by mx.google.com with ESMTPS id bk1sm14760755wib.2.2013.04.04.02.31.24 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 04 Apr 2013 02:31:26 -0700 (PDT) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: arnd@arndb.de, linus.walleij@stericsson.com, Lee Jones , Samuel Ortiz Subject: [PATCH 1/2] mfd: db8500-prcmu: Return early if the TCPM cannot be located Date: Thu, 4 Apr 2013 10:31:16 +0100 Message-Id: <1365067877-29459-1-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.7.10.4 X-Gm-Message-State: ALoCoQkJOLgqQi3dZMOC5tlkOCmxG8f5sd6UIxDd2dWqICMtlrukN4qt1QSnbYSODM9Bicj3J+NW X-Original-Sender: lee.jones@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:400c:c02::22e is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Currently we check to see if we obtained the Tightly Coupled Program Memory (TCPM) base and only execute the code within the check if we have it. It's more traditional to return early if we don't have it. This way we can flatten most of the function's code down to a single tab spacing. Cc: Samuel Ortiz Signed-off-by: Lee Jones --- drivers/mfd/db8500-prcmu.c | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/drivers/mfd/db8500-prcmu.c b/drivers/mfd/db8500-prcmu.c index 21f261b..1c4edbf8 100644 --- a/drivers/mfd/db8500-prcmu.c +++ b/drivers/mfd/db8500-prcmu.c @@ -2794,6 +2794,7 @@ static void dbx500_fw_version_init(struct platform_device *pdev, { struct resource *res; void __iomem *tcpm_base; + u32 version; res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "prcmu-tcpm"); @@ -2803,26 +2804,27 @@ static void dbx500_fw_version_init(struct platform_device *pdev, return; } tcpm_base = ioremap(res->start, resource_size(res)); - if (tcpm_base != NULL) { - u32 version; - - version = readl(tcpm_base + version_offset); - fw_info.version.project = (version & 0xFF); - fw_info.version.api_version = (version >> 8) & 0xFF; - fw_info.version.func_version = (version >> 16) & 0xFF; - fw_info.version.errata = (version >> 24) & 0xFF; - strncpy(fw_info.version.project_name, - fw_project_name(fw_info.version.project), - PRCMU_FW_PROJECT_NAME_LEN); - fw_info.valid = true; - pr_info("PRCMU firmware: %s(%d), version %d.%d.%d\n", - fw_info.version.project_name, - fw_info.version.project, - fw_info.version.api_version, - fw_info.version.func_version, - fw_info.version.errata); - iounmap(tcpm_base); + if (!tcpm_base) { + dev_err(&pdev->dev, "no prcmu tcpm mem region provided\n"); + return; } + + version = readl(tcpm_base + version_offset); + fw_info.version.project = (version & 0xFF); + fw_info.version.api_version = (version >> 8) & 0xFF; + fw_info.version.func_version = (version >> 16) & 0xFF; + fw_info.version.errata = (version >> 24) & 0xFF; + strncpy(fw_info.version.project_name, + fw_project_name(fw_info.version.project), + PRCMU_FW_PROJECT_NAME_LEN); + fw_info.valid = true; + pr_info("PRCMU firmware: %s(%d), version %d.%d.%d\n", + fw_info.version.project_name, + fw_info.version.project, + fw_info.version.api_version, + fw_info.version.func_version, + fw_info.version.errata); + iounmap(tcpm_base); } void __init db8500_prcmu_early_init(void)