Skip to content

Commit d6e9d4b

Browse files
committed
Use framebuffer_alloc() to initialize fb_info
The reason to do such changes is that the flag FBINFO_DEFAULT has been removed from the Linux kernel since v6.6, which was the default value of fb_info.flags. To initialize the fb_info structure (and the value of fb_info.flags) correctly without using FBINFO_DEFAULT, the framebuffer_alloc() function provided by the Linux kernel should be used. Since framebuffer_alloc() only accepts pointer to fb_info, the type of the info field in struct vcamfb_info was changed from 'struct fb_info' to 'pointer to struct fb_info'. As a result, framebuffer_release() was added to deallocate the memory pointed to by the info field. Additionally, several changes were made to accommodate the change of the info field's type.
1 parent 274af8f commit d6e9d4b

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

fb.c

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include "fb.h"
99

1010
struct vcamfb_info {
11-
struct fb_info info;
11+
struct fb_info *info;
1212
void *addr;
1313
unsigned int offset;
1414
char name[FB_NAME_MAXLENGTH];
@@ -363,7 +363,10 @@ int vcamfb_init(struct vcam_device *dev)
363363
/* malloc vcamfb_info */
364364
fb_data = vmalloc(sizeof(struct vcamfb_info));
365365
dev->fb_priv = (void *) fb_data;
366-
info = &fb_data->info;
366+
367+
/* malloc fb_info */
368+
fb_data->info = framebuffer_alloc(0, &dev->vdev.dev);
369+
info = fb_data->info;
367370

368371
/* malloc framebuffer and init framebuffer */
369372
size = dev->input_format.sizeimage * 2;
@@ -402,8 +405,6 @@ int vcamfb_init(struct vcam_device *dev)
402405
info->fbops = &vcamfb_ops;
403406
info->par = dev;
404407
info->pseudo_palette = NULL;
405-
info->flags = FBINFO_FLAG_DEFAULT;
406-
info->device = &dev->vdev.dev;
407408
INIT_LIST_HEAD(&info->modelist);
408409

409410
/* set the fb_cmap */
@@ -428,25 +429,33 @@ int vcamfb_init(struct vcam_device *dev)
428429

429430
fb_alloc_failure:
430431
fb_dealloc_cmap(&info->cmap);
432+
framebuffer_release(info);
431433
return -EINVAL;
432434
}
433435

434436
void vcamfb_destroy(struct vcam_device *dev)
435437
{
436438
struct vcamfb_info *fb_data = (struct vcamfb_info *) dev->fb_priv;
437-
struct fb_info *info = &fb_data->info;
439+
struct fb_info *info;
440+
441+
if (!fb_data)
442+
return;
443+
444+
info = fb_data->info;
438445
if (info) {
439446
unregister_framebuffer(info);
440-
vfree(fb_data->addr);
441447
fb_dealloc_cmap(&info->cmap);
442-
vfree(dev->fb_priv);
448+
framebuffer_release(info);
443449
}
450+
451+
vfree(fb_data->addr);
452+
vfree(fb_data);
444453
}
445454

446455
void vcamfb_update(struct vcam_device *dev)
447456
{
448457
struct vcamfb_info *fb_data = (struct vcamfb_info *) dev->fb_priv;
449-
struct fb_info *info = &fb_data->info;
458+
struct fb_info *info = fb_data->info;
450459
struct vcam_in_queue *q = &dev->in_queue;
451460

452461
/* remalloc the framebuffer and vcam_in_queue */

0 commit comments

Comments
 (0)