public inbox for linux-tegra@vger.kernel.org
 help / color / mirror / Atom feed
From: Thomas Zimmermann <tzimmermann@suse.de>
To: thierry.reding@gmail.com, jonathanh@nvidia.com,
	javierm@redhat.com, airlied@gmail.com, daniel@ffwll.ch
Cc: dri-devel@lists.freedesktop.org, linux-tegra@vger.kernel.org,
	Thomas Zimmermann <tzimmermann@suse.de>
Subject: [PATCH 4/7] drm/tegra: Remove struct tegra_fbdev
Date: Thu, 30 Mar 2023 10:36:04 +0200	[thread overview]
Message-ID: <20230330083607.12834-5-tzimmermann@suse.de> (raw)
In-Reply-To: <20230330083607.12834-1-tzimmermann@suse.de>

Remove struct tegra_fbdev, which is an empty wrapper around struct
drm_fb_helper. Use the latter directly. No functional changes.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
 drivers/gpu/drm/tegra/drm.h | 10 -------
 drivers/gpu/drm/tegra/fb.c  | 59 ++++++++++++++-----------------------
 2 files changed, 22 insertions(+), 47 deletions(-)

diff --git a/drivers/gpu/drm/tegra/drm.h b/drivers/gpu/drm/tegra/drm.h
index 8f8e5cda78da..593a60b03189 100644
--- a/drivers/gpu/drm/tegra/drm.h
+++ b/drivers/gpu/drm/tegra/drm.h
@@ -29,12 +29,6 @@
 
 struct reset_control;
 
-#ifdef CONFIG_DRM_FBDEV_EMULATION
-struct tegra_fbdev {
-	struct drm_fb_helper base;
-};
-#endif
-
 struct tegra_drm {
 	struct drm_device *drm;
 
@@ -52,10 +46,6 @@ struct tegra_drm {
 	struct mutex clients_lock;
 	struct list_head clients;
 
-#ifdef CONFIG_DRM_FBDEV_EMULATION
-	struct tegra_fbdev *fbdev;
-#endif
-
 	unsigned int hmask, vmask;
 	unsigned int pitch_align;
 	unsigned int num_crtcs;
diff --git a/drivers/gpu/drm/tegra/fb.c b/drivers/gpu/drm/tegra/fb.c
index 1ee4771b77d3..12eb260d9f51 100644
--- a/drivers/gpu/drm/tegra/fb.c
+++ b/drivers/gpu/drm/tegra/fb.c
@@ -17,13 +17,6 @@
 #include "drm.h"
 #include "gem.h"
 
-#ifdef CONFIG_DRM_FBDEV_EMULATION
-static inline struct tegra_fbdev *to_tegra_fbdev(struct drm_fb_helper *helper)
-{
-	return container_of(helper, struct tegra_fbdev, base);
-}
-#endif
-
 struct tegra_bo *tegra_fb_get_plane(struct drm_framebuffer *framebuffer,
 				    unsigned int index)
 {
@@ -296,42 +289,42 @@ static const struct drm_fb_helper_funcs tegra_fb_helper_funcs = {
 	.fb_probe = tegra_fbdev_probe,
 };
 
-static struct tegra_fbdev *tegra_fbdev_create(struct drm_device *drm)
+static struct drm_fb_helper *tegra_fbdev_create(struct drm_device *drm)
 {
-	struct tegra_fbdev *fbdev;
+	struct drm_fb_helper *helper;
 
-	fbdev = kzalloc(sizeof(*fbdev), GFP_KERNEL);
-	if (!fbdev) {
+	helper = kzalloc(sizeof(*helper), GFP_KERNEL);
+	if (!helper) {
 		dev_err(drm->dev, "failed to allocate DRM fbdev\n");
 		return ERR_PTR(-ENOMEM);
 	}
 
-	drm_fb_helper_prepare(drm, &fbdev->base, 32, &tegra_fb_helper_funcs);
+	drm_fb_helper_prepare(drm, helper, 32, &tegra_fb_helper_funcs);
 
-	return fbdev;
+	return helper;
 }
 
-static void tegra_fbdev_free(struct tegra_fbdev *fbdev)
+static void tegra_fbdev_free(struct drm_fb_helper *helper)
 {
-	drm_fb_helper_unprepare(&fbdev->base);
-	kfree(fbdev);
+	drm_fb_helper_unprepare(helper);
+	kfree(helper);
 }
 
-static int tegra_fbdev_init(struct tegra_fbdev *fbdev,
+static int tegra_fbdev_init(struct drm_fb_helper *helper,
 			    unsigned int num_crtc,
 			    unsigned int max_connectors)
 {
-	struct drm_device *drm = fbdev->base.dev;
+	struct drm_device *drm = helper->dev;
 	int err;
 
-	err = drm_fb_helper_init(drm, &fbdev->base);
+	err = drm_fb_helper_init(drm, helper);
 	if (err < 0) {
 		dev_err(drm->dev, "failed to initialize DRM FB helper: %d\n",
 			err);
 		return err;
 	}
 
-	err = drm_fb_helper_initial_config(&fbdev->base);
+	err = drm_fb_helper_initial_config(helper);
 	if (err < 0) {
 		dev_err(drm->dev, "failed to set initial configuration: %d\n",
 			err);
@@ -341,13 +334,12 @@ static int tegra_fbdev_init(struct tegra_fbdev *fbdev,
 	return 0;
 
 fini:
-	drm_fb_helper_fini(&fbdev->base);
+	drm_fb_helper_fini(helper);
 	return err;
 }
 
-static void tegra_fbdev_exit(struct tegra_fbdev *fbdev)
+static void tegra_fbdev_exit(struct drm_fb_helper *helper)
 {
-	struct drm_fb_helper *helper = &fbdev->base;
 	struct drm_framebuffer *fb = helper->fb;
 
 	drm_fb_helper_unregister_info(helper);
@@ -365,18 +357,16 @@ static void tegra_fbdev_exit(struct tegra_fbdev *fbdev)
 	}
 
 	drm_fb_helper_fini(helper);
-	tegra_fbdev_free(fbdev);
+	tegra_fbdev_free(helper);
 }
 #endif
 
 int tegra_drm_fb_prepare(struct drm_device *drm)
 {
 #ifdef CONFIG_DRM_FBDEV_EMULATION
-	struct tegra_drm *tegra = drm->dev_private;
-
-	tegra->fbdev = tegra_fbdev_create(drm);
-	if (IS_ERR(tegra->fbdev))
-		return PTR_ERR(tegra->fbdev);
+	drm->fb_helper = tegra_fbdev_create(drm);
+	if (IS_ERR(drm->fb_helper))
+		return PTR_ERR(drm->fb_helper);
 #endif
 
 	return 0;
@@ -385,19 +375,16 @@ int tegra_drm_fb_prepare(struct drm_device *drm)
 void tegra_drm_fb_free(struct drm_device *drm)
 {
 #ifdef CONFIG_DRM_FBDEV_EMULATION
-	struct tegra_drm *tegra = drm->dev_private;
-
-	tegra_fbdev_free(tegra->fbdev);
+	tegra_fbdev_free(drm->fb_helper);
 #endif
 }
 
 int tegra_drm_fb_init(struct drm_device *drm)
 {
 #ifdef CONFIG_DRM_FBDEV_EMULATION
-	struct tegra_drm *tegra = drm->dev_private;
 	int err;
 
-	err = tegra_fbdev_init(tegra->fbdev, drm->mode_config.num_crtc,
+	err = tegra_fbdev_init(drm->fb_helper, drm->mode_config.num_crtc,
 			       drm->mode_config.num_connector);
 	if (err < 0)
 		return err;
@@ -409,8 +396,6 @@ int tegra_drm_fb_init(struct drm_device *drm)
 void tegra_drm_fb_exit(struct drm_device *drm)
 {
 #ifdef CONFIG_DRM_FBDEV_EMULATION
-	struct tegra_drm *tegra = drm->dev_private;
-
-	tegra_fbdev_exit(tegra->fbdev);
+	tegra_fbdev_exit(drm->fb_helper);
 #endif
 }
-- 
2.40.0


  parent reply	other threads:[~2023-03-30  8:36 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-30  8:36 [PATCH 0/7] drm/tegra: Convert fbdev to DRM client Thomas Zimmermann
2023-03-30  8:36 ` [PATCH 1/7] drm/tegra: Include <linux/of.h> Thomas Zimmermann
2023-03-30 12:51   ` [1/7] " Sui Jingfeng
2023-04-03 10:42     ` Thomas Zimmermann
2023-04-03 13:46       ` Sui Jingfeng
2023-03-30  8:36 ` [PATCH 2/7] drm/tegra: Include <linux/i2c.h> Thomas Zimmermann
2023-03-30 12:52   ` [2/7] " Sui Jingfeng
2023-03-30  8:36 ` [PATCH 3/7] drm/tegra: Removed fb from struct tegra_fbdev Thomas Zimmermann
2023-03-30  8:36 ` Thomas Zimmermann [this message]
2023-03-30  8:36 ` [PATCH 5/7] drm/tegra: Hide fbdev support behind config option Thomas Zimmermann
2023-03-30  8:36 ` [PATCH 6/7] drm/tegra: Initialize fbdev DRM client Thomas Zimmermann
2023-03-30  8:36 ` [PATCH 7/7] drm/tegra: Implement fbdev emulation as in-kernel client Thomas Zimmermann
2023-04-05 14:55 ` [PATCH 0/7] drm/tegra: Convert fbdev to DRM client Thierry Reding
2023-04-05 15:06   ` Thomas Zimmermann
2023-04-05 15:04 ` Thierry Reding

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=20230330083607.12834-5-tzimmermann@suse.de \
    --to=tzimmermann@suse.de \
    --cc=airlied@gmail.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=javierm@redhat.com \
    --cc=jonathanh@nvidia.com \
    --cc=linux-tegra@vger.kernel.org \
    --cc=thierry.reding@gmail.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