Skip to content

Commit 8b914fd

Browse files
committed
Revert "Revert "fbdev: Allow client to request a particular /dev/fbN node""
This reverts commit 23d9180.
1 parent 862316f commit 8b914fd

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

drivers/video/fbdev/core/fbmem.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ struct class *fb_class;
3131
DEFINE_MUTEX(registration_lock);
3232
struct fb_info *registered_fb[FB_MAX] __read_mostly;
3333
int num_registered_fb __read_mostly;
34+
int min_dynamic_fb __read_mostly;
3435
#define for_each_registered_fb(i) \
3536
for (i = 0; i < FB_MAX; i++) \
3637
if (!registered_fb[i]) {} else
@@ -399,10 +400,12 @@ static int do_register_framebuffer(struct fb_info *fb_info)
399400
if (num_registered_fb == FB_MAX)
400401
return -ENXIO;
401402

402-
for (i = 0 ; i < FB_MAX; i++)
403-
if (!registered_fb[i])
404-
break;
405-
403+
i = fb_info->node;
404+
if (!fb_info->custom_fb_num || fb_info->node >= FB_MAX || registered_fb[fb_info->node]) {
405+
for (i = min_dynamic_fb ; i < FB_MAX; i++)
406+
if (!registered_fb[i])
407+
break;
408+
}
406409
if (!fb_info->modelist.prev || !fb_info->modelist.next)
407410
INIT_LIST_HEAD(&fb_info->modelist);
408411

@@ -503,6 +506,12 @@ static void do_unregister_framebuffer(struct fb_info *fb_info)
503506
put_fb_info(fb_info);
504507
}
505508

509+
void fb_set_lowest_dynamic_fb(int min_fb_dev)
510+
{
511+
min_dynamic_fb = min_fb_dev;
512+
}
513+
EXPORT_SYMBOL(fb_set_lowest_dynamic_fb);
514+
506515
/**
507516
* register_framebuffer - registers a frame buffer device
508517
* @fb_info: frame buffer info structure

include/linux/fb.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,7 @@ struct fb_info {
511511

512512
bool skip_vt_switch; /* no VT switch on suspend/resume required */
513513
bool skip_panic; /* Do not write to the fb after a panic */
514+
bool custom_fb_num; /* Use value in node as the preferred node number */
514515
};
515516

516517
/* This will go away
@@ -600,6 +601,7 @@ extern ssize_t fb_sys_write(struct fb_info *info, const char __user *buf,
600601
.fb_imageblit = sys_imageblit
601602

602603
/* fbmem.c */
604+
extern void fb_set_lowest_dynamic_fb(int min_fb_dev);
603605
extern int register_framebuffer(struct fb_info *fb_info);
604606
extern void unregister_framebuffer(struct fb_info *fb_info);
605607
extern int devm_register_framebuffer(struct device *dev, struct fb_info *fb_info);

0 commit comments

Comments
 (0)