linux-hyperv.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Zimmermann <tzimmermann@suse.de>
To: deller@gmx.de, daniel@ffwll.ch, sam@ravnborg.org, javierm@redhat.com
Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org,
	linux-staging@lists.linux.dev, linux-hyperv@vger.kernel.org,
	linux-input@vger.kernel.org,
	Thomas Zimmermann <tzimmermann@suse.de>
Subject: [PATCH 7/8] staging/fbtft: Initialize fb_op struct as static const
Date: Mon, 28 Aug 2023 15:14:23 +0200	[thread overview]
Message-ID: <20230828132131.29295-8-tzimmermann@suse.de> (raw)
In-Reply-To: <20230828132131.29295-1-tzimmermann@suse.de>

Replace dynamic allocation of the fb_ops instance with static
allocation. Initialize the fields at module-load time. The owner
field changes to THIS_MODULE, as in all other fbdev drivers.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
 drivers/staging/fbtft/fbtft-core.c | 30 +++++++++++++-----------------
 1 file changed, 13 insertions(+), 17 deletions(-)

diff --git a/drivers/staging/fbtft/fbtft-core.c b/drivers/staging/fbtft/fbtft-core.c
index eac1d570f437..e4a77a4e7be6 100644
--- a/drivers/staging/fbtft/fbtft-core.c
+++ b/drivers/staging/fbtft/fbtft-core.c
@@ -473,6 +473,18 @@ static int fbtft_fb_blank(int blank, struct fb_info *info)
 	return ret;
 }
 
+static const struct fb_ops fbtft_ops = {
+	.owner        = THIS_MODULE;
+	.fb_read      = fb_sys_read;
+	.fb_write     = fbtft_fb_write;
+	.fb_fillrect  = fbtft_fb_fillrect;
+	.fb_copyarea  = fbtft_fb_copyarea;
+	.fb_imageblit = fbtft_fb_imageblit;
+	.fb_setcolreg = fbtft_fb_setcolreg;
+	.fb_blank     = fbtft_fb_blank;
+	.fb_mmap      = fb_deferred_io_mmap;
+};
+
 static void fbtft_merge_fbtftops(struct fbtft_ops *dst, struct fbtft_ops *src)
 {
 	if (src->write)
@@ -521,7 +533,6 @@ static void fbtft_merge_fbtftops(struct fbtft_ops *dst, struct fbtft_ops *src)
  * Creates a new frame buffer info structure.
  *
  * Also creates and populates the following structures:
- *   info->fbops
  *   info->fbdefio
  *   info->pseudo_palette
  *   par->fbtftops
@@ -536,7 +547,6 @@ struct fb_info *fbtft_framebuffer_alloc(struct fbtft_display *display,
 {
 	struct fb_info *info;
 	struct fbtft_par *par;
-	struct fb_ops *fbops = NULL;
 	struct fb_deferred_io *fbdefio = NULL;
 	u8 *vmem = NULL;
 	void *txbuf = NULL;
@@ -611,10 +621,6 @@ struct fb_info *fbtft_framebuffer_alloc(struct fbtft_display *display,
 	if (!vmem)
 		goto alloc_fail;
 
-	fbops = devm_kzalloc(dev, sizeof(struct fb_ops), GFP_KERNEL);
-	if (!fbops)
-		goto alloc_fail;
-
 	fbdefio = devm_kzalloc(dev, sizeof(struct fb_deferred_io), GFP_KERNEL);
 	if (!fbdefio)
 		goto alloc_fail;
@@ -638,19 +644,9 @@ struct fb_info *fbtft_framebuffer_alloc(struct fbtft_display *display,
 		goto alloc_fail;
 
 	info->screen_buffer = vmem;
-	info->fbops = fbops;
+	info->fbops = &fbtft_ops;
 	info->fbdefio = fbdefio;
 
-	fbops->owner        =      dev->driver->owner;
-	fbops->fb_read      =      fb_sys_read;
-	fbops->fb_write     =      fbtft_fb_write;
-	fbops->fb_fillrect  =      fbtft_fb_fillrect;
-	fbops->fb_copyarea  =      fbtft_fb_copyarea;
-	fbops->fb_imageblit =      fbtft_fb_imageblit;
-	fbops->fb_setcolreg =      fbtft_fb_setcolreg;
-	fbops->fb_blank     =      fbtft_fb_blank;
-	fbops->fb_mmap      =      fb_deferred_io_mmap;
-
 	fbdefio->delay =            HZ / fps;
 	fbdefio->sort_pagereflist = true;
 	fbdefio->deferred_io =      fbtft_deferred_io;
-- 
2.41.0


  parent reply	other threads:[~2023-08-28 13:22 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-28 13:14 [PATCH 0/8] fbdev: Use helpers for deferred I/O Thomas Zimmermann
2023-08-28 13:14 ` [PATCH 1/8] fbdev/smscufx: Use fb_ops " Thomas Zimmermann
2023-09-04 12:59   ` Javier Martinez Canillas
2023-09-04 14:39     ` Thomas Zimmermann
2023-09-04 14:45       ` Thomas Zimmermann
2023-09-04 15:26       ` Javier Martinez Canillas
2023-08-28 13:14 ` [PATCH 2/8] fbdev/udlfb: " Thomas Zimmermann
2023-09-04 13:05   ` Javier Martinez Canillas
2023-09-04 14:43     ` Thomas Zimmermann
2023-09-04 15:28       ` Javier Martinez Canillas
2023-08-28 13:14 ` [PATCH 3/8] fbdev: Add Kconfig macro FB_IOMEM_HELPERS_DEFERRED Thomas Zimmermann
2023-09-04 13:10   ` Javier Martinez Canillas
2023-08-28 13:14 ` [PATCH 4/8] fbdev/hyperv_fb: Use fb_ops helpers for deferred I/O Thomas Zimmermann
2023-09-04 13:18   ` Javier Martinez Canillas
2023-08-28 13:14 ` [PATCH 5/8] hid: Remove trailing whitespace Thomas Zimmermann
2023-09-04 13:24   ` Javier Martinez Canillas
2023-08-28 13:14 ` [PATCH 6/8] hid/picolcd: Use fb_ops helpers for deferred I/O Thomas Zimmermann
2023-09-04 13:27   ` Javier Martinez Canillas
2023-08-28 13:14 ` Thomas Zimmermann [this message]
2023-08-28 14:51   ` [PATCH 7/8] staging/fbtft: Initialize fb_op struct as static const Greg KH
2023-09-04 13:28   ` Javier Martinez Canillas
2023-08-28 13:14 ` [PATCH 8/8] staging/fbtft: Use fb_ops helpers for deferred I/O Thomas Zimmermann
2023-08-28 14:51   ` Greg KH
2023-09-04 13:28   ` Javier Martinez Canillas

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=20230828132131.29295-8-tzimmermann@suse.de \
    --to=tzimmermann@suse.de \
    --cc=daniel@ffwll.ch \
    --cc=deller@gmx.de \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=javierm@redhat.com \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=linux-hyperv@vger.kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=sam@ravnborg.org \
    /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).