]> git.karo-electronics.de Git - linux-beck.git/commitdiff
mfd: db8500-prcmu: Return early if the TCPM cannot be located
authorLee Jones <lee.jones@linaro.org>
Thu, 4 Apr 2013 10:39:00 +0000 (11:39 +0100)
committerSamuel Ortiz <sameo@linux.intel.com>
Tue, 9 Apr 2013 10:02:42 +0000 (12:02 +0200)
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.

Signed-off-by: Lee Jones <lee.jones@linaro.org>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
drivers/mfd/db8500-prcmu.c

index 21434beb420ab54ddfbe9b0bb47af108e65825bc..25dda8d7cb00fe02c4c0cb6d03db9b7e40df533d 100644 (file)
@@ -2704,6 +2704,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");
@@ -2713,26 +2714,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(u32 phy_base, u32 size)