soc: imx: gpc: fix domain_index sanity check issue
authorDong Aisheng <aisheng.dong@nxp.com>
Thu, 23 Mar 2017 04:53:20 +0000 (12:53 +0800)
committerShawn Guo <shawnguo@kernel.org>
Fri, 24 Mar 2017 05:42:01 +0000 (13:42 +0800)
ARRAY_SIZE(imx_gpc_domains) represents all power domains supported
by different SoCs. Driver should use SoC specific of_id_data->num_domains
instead to do power domain index sanity check.
e.g. MX6Q supports two power domains while MX6SL supports three.

Fixes: 721cabf6c660 ("soc: imx: move PGC handling to a new GPC driver")
Acked-by: Lucas Stach <l.stach@pengutronix.de>
Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
Signed-off-by: Shawn Guo <shawnguo@kernel.org>
drivers/soc/imx/gpc.c

index 7e6a672bf5f4dda81451c916c3462f535aac9ab4..ba6e7ab2c2405a08db4d3c420f18eef16fa15a8f 100644 (file)
@@ -413,7 +413,7 @@ static int imx_gpc_probe(struct platform_device *pdev)
                                of_node_put(np);
                                return ret;
                        }
-                       if (domain_index >= ARRAY_SIZE(imx_gpc_domains))
+                       if (domain_index >= of_id_data->num_domains)
                                continue;
 
                        domain = &imx_gpc_domains[domain_index];