dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: devel@driverdev.osuosl.org, Hans de Goede <hdegoede@redhat.com>,
	Michael Thayer <michael.thayer@oracle.com>,
	dri-devel@lists.freedesktop.org
Subject: [PATCH 02/12] staging: vboxvideo: Move setup of modesetting from driver_load to mode_init
Date: Tue, 18 Sep 2018 19:44:28 +0200	[thread overview]
Message-ID: <20180918174438.19780-3-hdegoede@redhat.com> (raw)
In-Reply-To: <20180918174438.19780-1-hdegoede@redhat.com>

Move the setup of drm modesetting config from vbox_driver_load() to
vbox_mode_init().

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/staging/vboxvideo/vbox_main.c | 45 -------------------
 drivers/staging/vboxvideo/vbox_mode.c | 62 ++++++++++++++++++++++++---
 2 files changed, 57 insertions(+), 50 deletions(-)

diff --git a/drivers/staging/vboxvideo/vbox_main.c b/drivers/staging/vboxvideo/vbox_main.c
index 783a68c0de3b..a1cd29fe98fd 100644
--- a/drivers/staging/vboxvideo/vbox_main.c
+++ b/drivers/staging/vboxvideo/vbox_main.c
@@ -173,40 +173,6 @@ int vbox_framebuffer_init(struct drm_device *dev,
 	return 0;
 }
 
-static struct drm_framebuffer *vbox_user_framebuffer_create(
-		struct drm_device *dev,
-		struct drm_file *filp,
-		const struct drm_mode_fb_cmd2 *mode_cmd)
-{
-	struct drm_gem_object *obj;
-	struct vbox_framebuffer *vbox_fb;
-	int ret = -ENOMEM;
-
-	obj = drm_gem_object_lookup(filp, mode_cmd->handles[0]);
-	if (!obj)
-		return ERR_PTR(-ENOENT);
-
-	vbox_fb = kzalloc(sizeof(*vbox_fb), GFP_KERNEL);
-	if (!vbox_fb)
-		goto err_unref_obj;
-
-	ret = vbox_framebuffer_init(dev, vbox_fb, mode_cmd, obj);
-	if (ret)
-		goto err_free_vbox_fb;
-
-	return &vbox_fb->base;
-
-err_free_vbox_fb:
-	kfree(vbox_fb);
-err_unref_obj:
-	drm_gem_object_put_unlocked(obj);
-	return ERR_PTR(ret);
-}
-
-static const struct drm_mode_config_funcs vbox_mode_funcs = {
-	.fb_create = vbox_user_framebuffer_create,
-};
-
 static int vbox_accel_init(struct vbox_private *vbox)
 {
 	unsigned int i;
@@ -375,15 +341,6 @@ int vbox_driver_load(struct drm_device *dev)
 	if (ret)
 		goto err_hw_fini;
 
-	drm_mode_config_init(dev);
-
-	dev->mode_config.funcs = (void *)&vbox_mode_funcs;
-	dev->mode_config.min_width = 64;
-	dev->mode_config.min_height = 64;
-	dev->mode_config.preferred_depth = 24;
-	dev->mode_config.max_width = VBE_DISPI_MAX_XRES;
-	dev->mode_config.max_height = VBE_DISPI_MAX_YRES;
-
 	ret = vbox_mode_init(dev);
 	if (ret)
 		goto err_drm_mode_cleanup;
@@ -403,7 +360,6 @@ int vbox_driver_load(struct drm_device *dev)
 err_mode_fini:
 	vbox_mode_fini(dev);
 err_drm_mode_cleanup:
-	drm_mode_config_cleanup(dev);
 	vbox_mm_fini(vbox);
 err_hw_fini:
 	vbox_hw_fini(vbox);
@@ -417,7 +373,6 @@ void vbox_driver_unload(struct drm_device *dev)
 	vbox_fbdev_fini(dev);
 	vbox_irq_fini(vbox);
 	vbox_mode_fini(dev);
-	drm_mode_config_cleanup(dev);
 	vbox_mm_fini(vbox);
 	vbox_hw_fini(vbox);
 }
diff --git a/drivers/staging/vboxvideo/vbox_mode.c b/drivers/staging/vboxvideo/vbox_mode.c
index 70701a6054c2..2587e6aecca2 100644
--- a/drivers/staging/vboxvideo/vbox_mode.c
+++ b/drivers/staging/vboxvideo/vbox_mode.c
@@ -696,6 +696,40 @@ static int vbox_connector_init(struct drm_device *dev,
 	return 0;
 }
 
+static struct drm_framebuffer *vbox_user_framebuffer_create(
+		struct drm_device *dev,
+		struct drm_file *filp,
+		const struct drm_mode_fb_cmd2 *mode_cmd)
+{
+	struct drm_gem_object *obj;
+	struct vbox_framebuffer *vbox_fb;
+	int ret = -ENOMEM;
+
+	obj = drm_gem_object_lookup(filp, mode_cmd->handles[0]);
+	if (!obj)
+		return ERR_PTR(-ENOENT);
+
+	vbox_fb = kzalloc(sizeof(*vbox_fb), GFP_KERNEL);
+	if (!vbox_fb)
+		goto err_unref_obj;
+
+	ret = vbox_framebuffer_init(dev, vbox_fb, mode_cmd, obj);
+	if (ret)
+		goto err_free_vbox_fb;
+
+	return &vbox_fb->base;
+
+err_free_vbox_fb:
+	kfree(vbox_fb);
+err_unref_obj:
+	drm_gem_object_put_unlocked(obj);
+	return ERR_PTR(ret);
+}
+
+static const struct drm_mode_config_funcs vbox_mode_funcs = {
+	.fb_create = vbox_user_framebuffer_create,
+};
+
 int vbox_mode_init(struct drm_device *dev)
 {
 	struct vbox_private *vbox = dev->dev_private;
@@ -704,24 +738,42 @@ int vbox_mode_init(struct drm_device *dev)
 	unsigned int i;
 	int ret;
 
+	drm_mode_config_init(dev);
+
+	dev->mode_config.funcs = (void *)&vbox_mode_funcs;
+	dev->mode_config.min_width = 64;
+	dev->mode_config.min_height = 64;
+	dev->mode_config.preferred_depth = 24;
+	dev->mode_config.max_width = VBE_DISPI_MAX_XRES;
+	dev->mode_config.max_height = VBE_DISPI_MAX_YRES;
+
 	/* vbox_cursor_init(dev); */
 	for (i = 0; i < vbox->num_crtcs; ++i) {
 		vbox_crtc = vbox_crtc_init(dev, i);
-		if (!vbox_crtc)
-			return -ENOMEM;
+		if (!vbox_crtc) {
+			ret = -ENOMEM;
+			goto err_drm_mode_cleanup;
+		}
 		encoder = vbox_encoder_init(dev, i);
-		if (!encoder)
-			return -ENOMEM;
+		if (!encoder) {
+			ret = -ENOMEM;
+			goto err_drm_mode_cleanup;
+		}
 		ret = vbox_connector_init(dev, vbox_crtc, encoder);
 		if (ret)
-			return ret;
+			goto err_drm_mode_cleanup;
 	}
 
 	return 0;
+
+err_drm_mode_cleanup:
+	drm_mode_config_cleanup(dev);
+	return ret;
 }
 
 void vbox_mode_fini(struct drm_device *dev)
 {
+	drm_mode_config_cleanup(dev);
 	/* vbox_cursor_fini(dev); */
 }
 
-- 
2.19.0.rc1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  parent reply	other threads:[~2018-09-18 17:44 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-18 17:44 [PATCH 00/12] staging: vboxvideo: Preparation work for moving to atomic modesetting Hans de Goede
2018-09-18 17:44 ` [PATCH 01/12] staging: vboxvideo: Let DRM core handle connector registering Hans de Goede
2018-09-18 17:44 ` Hans de Goede [this message]
2018-09-18 17:44 ` [PATCH 03/12] staging: vboxvideo: Fold driver_load/unload into probe/remove functions Hans de Goede
2018-09-18 17:44 ` [PATCH 04/12] staging: vboxvideo: Embed drm_device into driver structure Hans de Goede
2018-09-18 17:44 ` [PATCH 05/12] staging: vboxvideo: Fold vbox_drm_resume() into vbox_pm_resume() Hans de Goede
2018-09-18 17:44 ` [PATCH 06/12] staging: vboxvideo: Add fl_flag argument to vbox_fb_pin() helper Hans de Goede
2018-09-18 17:44 ` [PATCH 07/12] staging: vboxvideo: Expose creation of universal primary plane Hans de Goede
2018-09-18 17:44 ` [PATCH 08/12] staging: vboxvideo: Init fb_info.fix.smem once from fbdev_create Hans de Goede
2018-09-18 17:44 ` [PATCH 09/12] staging: vboxvideo: Move pin / unpin of fb out of vbox_crtc_set_base_and_mode Hans de Goede
2018-09-18 17:44 ` [PATCH 10/12] staging: vboxvideo: Fix NULL ptr deref in vbox_set_up_input_mapping() Hans de Goede
2018-09-18 17:44 ` [PATCH 11/12] staging: vboxvideo: Move bo_[un]resere calls into vbox_bo_[un]pin Hans de Goede
2018-09-18 17:44 ` [PATCH 12/12] staging: vboxvideo: Add vbox_bo_k[un]map helper functions Hans de Goede
2018-09-20 10:32 ` [PATCH 00/12] staging: vboxvideo: Preparation work for moving to atomic modesetting Greg Kroah-Hartman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180918174438.19780-3-hdegoede@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=michael.thayer@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).