Blob Blame History Raw
From: Linus Walleij <linus.walleij@linaro.org>
Date: Thu, 3 May 2018 16:04:31 +0200
Subject: drm/pl111: Fix module probe bug
Git-commit: 0a4587a034a43e5076770df10446214cfb3de8f8
Patch-mainline: v4.18-rc1
References: FATE#326289 FATE#326079 FATE#326049 FATE#322398 FATE#326166

Commit a30933c27602 ("drm/pl111: Support the Versatile Express")
Added a second module using the builtin_platform_driver() call,
which works fine as long as you do not try to build the PL111
driver as a module, because a module can only have one initcall
and cause the following build bug:

(...) multiple definition of `init_module' (...)

Reported-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Liviu Dudau <liviu.dudau@arm.com>
Cc: Pawel Moll <pawel.moll@arm.com>
Cc: Eric Anholt <eric@anholt.net>
Cc: Robin Murphy <robin.murphy@arm.com>
Reviewed-by: Sean Paul <seanpaul@chromium.org>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Fixes: a30933c27602 ("drm/pl111: Support the Versatile Express")
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20180503140431.5798-1-linus.walleij@linaro.org

Acked-by: Petr Tesarik <ptesarik@suse.com>
---
 drivers/gpu/drm/pl111/pl111_versatile.c |    7 +++++++
 drivers/gpu/drm/pl111/pl111_vexpress.c  |   11 ++++++++++-
 drivers/gpu/drm/pl111/pl111_vexpress.h  |    7 +++++++
 3 files changed, 24 insertions(+), 1 deletion(-)

--- a/drivers/gpu/drm/pl111/pl111_versatile.c
+++ b/drivers/gpu/drm/pl111/pl111_versatile.c
@@ -326,6 +326,13 @@ int pl111_versatile_init(struct device *
 	if (versatile_clcd_type == VEXPRESS_CLCD_V2M) {
 		struct platform_device *pdev;
 
+		/* Registers a driver for the muxfpga */
+		ret = vexpress_muxfpga_init();
+		if (ret) {
+			dev_err(dev, "unable to initialize muxfpga driver\n");
+			return ret;
+		}
+
 		/* Call into deep Vexpress configuration API */
 		pdev = of_find_device_by_node(np);
 		if (!pdev) {
--- a/drivers/gpu/drm/pl111/pl111_vexpress.c
+++ b/drivers/gpu/drm/pl111/pl111_vexpress.c
@@ -122,4 +122,13 @@ static struct platform_driver vexpress_m
 	.probe = vexpress_muxfpga_probe,
 };
 
-builtin_platform_driver(vexpress_muxfpga_driver);
+int vexpress_muxfpga_init(void)
+{
+	int ret;
+
+	ret = platform_driver_register(&vexpress_muxfpga_driver);
+	/* -EBUSY just means this driver is already registered */
+	if (ret == -EBUSY)
+		ret = 0;
+	return ret;
+}
--- a/drivers/gpu/drm/pl111/pl111_vexpress.h
+++ b/drivers/gpu/drm/pl111/pl111_vexpress.h
@@ -10,6 +10,8 @@ int pl111_vexpress_clcd_init(struct devi
 			     struct pl111_drm_dev_private *priv,
 			     struct regmap *map);
 
+int vexpress_muxfpga_init(void);
+
 #else
 
 static inline int pl111_vexpress_clcd_init(struct device *dev,
@@ -19,4 +21,9 @@ static inline int pl111_vexpress_clcd_in
 	return -ENODEV;
 }
 
+static inline int vexpress_muxfpga_init(void)
+{
+	return 0;
+}
+
 #endif