soc: samsung: added the genpd state alloc
authorLee Yongjin <yongjin0.lee@samsung.com>
Mon, 22 Jan 2018 11:25:06 +0000 (20:25 +0900)
committerChungwoo Park <cww.park@samsung.com>
Mon, 21 May 2018 08:26:16 +0000 (17:26 +0900)
Change-Id: Iee5b3f0bd5e9649ba64add619653f722522cd389
Signed-off-by: Lee Yongjin <yongjin0.lee@samsung.com>
drivers/soc/samsung/exynos-pd.c

index 997a7fa1d88bc2998ac77ec831b85073c1519a14..f203fb0c5595f52065bdfd61623502f2ba4de13b 100644 (file)
@@ -253,17 +253,24 @@ static void of_get_power_down_ok(struct exynos_pm_domain *pd)
        }
 }
 
-static void exynos_pd_genpd_init(struct exynos_pm_domain *pd, int state)
+static int exynos_pd_genpd_init(struct exynos_pm_domain *pd, int state)
 {
        pd->genpd.name = pd->name;
        pd->genpd.power_off = exynos_pd_power_off;
        pd->genpd.power_on = exynos_pd_power_on;
 
        /* pd power on/off latency is less than 1ms */
+       pm_genpd_init(&pd->genpd, NULL, state ? false : true);
+
+       pd->genpd.states = kzalloc(sizeof(pd->genpd.states), GFP_KERNEL);
+
+       if (!pd->genpd.states)
+               return -ENOMEM;
+
        pd->genpd.states[0].power_on_latency_ns = 1000000;
        pd->genpd.states[0].power_off_latency_ns = 1000000;
 
-       pm_genpd_init(&pd->genpd, NULL, state ? false : true);
+       return 0;
 }
 
 /* exynos_pd_show_power_domain - show current power domain status.
@@ -350,7 +357,13 @@ static __init int exynos_pd_dt_parse(void)
                mutex_init(&pd->access_lock);
                platform_set_drvdata(pdev, pd);
 
-               exynos_pd_genpd_init(pd, initial_state);
+               ret = exynos_pd_genpd_init(pd, initial_state);
+               if (ret) {
+                       pr_err(EXYNOS_PD_PREFIX "%s: exynos_pd_genpd_init fail: %s, ret:%d\n",
+                                       __func__, pd->name, ret);
+                       return ret;
+               }
+
                of_genpd_add_provider_simple(np, &pd->genpd);
 
                /* add LOGICAL sub-domain
@@ -388,7 +401,13 @@ static __init int exynos_pd_dt_parse(void)
                        mutex_init(&sub_pd->access_lock);
                        platform_set_drvdata(sub_pdev, sub_pd);
 
-                       exynos_pd_genpd_init(sub_pd, initial_state);
+                       ret = exynos_pd_genpd_init(sub_pd, initial_state);
+                       if (ret) {
+                               pr_err(EXYNOS_PD_PREFIX "%s: exynos_pd_genpd_init fail: %s, ret:%d\n",
+                                               __func__, pd->name, ret);
+                               return ret;
+                       }
+
                        of_genpd_add_provider_simple(children, &sub_pd->genpd);
 
                        if (pm_genpd_add_subdomain(&pd->genpd, &sub_pd->genpd))