[RFC PATCH v3 4/4] drm/exynos: clean up machine compatible string check

Inki Dae inki.dae at samsung.com
Thu Nov 20 02:24:48 PST 2014


Use 'for' statemant instead of hard-coded 'if' statement.

Changelog v3:
- none

Changelog v2:
- none

Signed-off-by: Inki Dae <inki.dae at samsung.com>
---
 drivers/gpu/drm/exynos/exynos_drm_drv.c |   20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c b/drivers/gpu/drm/exynos/exynos_drm_drv.c
index 3ac39b6..4579186 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_drv.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c
@@ -587,9 +587,16 @@ static struct platform_driver exynos_drm_platform_driver = {
 	},
 };
 
+static const char * const strings[] = {
+	"samsung,exynos3",
+	"samsung,exynos4",
+	"samsung,exynos5",
+};
+
 static int exynos_drm_init(void)
 {
-	int ret;
+	bool is_exynos = false;
+	int ret, i;
 
 	/*
 	 * Register device object only in case of Exynos SoC.
@@ -598,9 +605,14 @@ static int exynos_drm_init(void)
 	 * by Exynos drm driver when using multi-platform kernel.
 	 * So these codes will be replaced with more generic way later.
 	 */
-	if (!of_machine_is_compatible("samsung,exynos3") &&
-			!of_machine_is_compatible("samsung,exynos4") &&
-			!of_machine_is_compatible("samsung,exynos5"))
+	for (i = 0; i < ARRAY_SIZE(strings); i++) {
+		if (of_machine_is_compatible(strings[i])) {
+			is_exynos = true;
+			break;
+		}
+	}
+
+	if (!is_exynos)
 		return -ENODEV;
 
 	exynos_drm_pdev = platform_device_register_simple("exynos-drm", -1,
-- 
1.7.9.5



More information about the dri-devel mailing list