Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

fbcon: move more common code into fb_open()

No idea why con2fb_acquire_newinfo() initializes much less than
fbcon_startup(), but so be it. From a quick look most of the
un-initialized stuff should be fairly harmless, but who knows.

Note that the error handling for the con2fb_acquire_newinfo() failure
case was very strange: Callers updated con2fb_map to the new value
before calling this function, but upon error con2fb_acquire_newinfo
reset it to the old value. Since I removed the call to fbcon_release
anyway that strange error path was sticking out like a sore thumb,
hence I removed it. Which also allows us to remove the oldidx
parameter from that function.

v2: Explain what's going on with oldidx and error paths (Sam)

v3: Drop unused variable (0day)

v4: Rebased over bisect fix in previous patch, unchagend end result.

Acked-by: Sam Ravnborg <sam@ravnborg.org> (v2)
Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
Cc: kernel test robot <lkp@intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Claudio Suarez <cssk@net-c.es>
Cc: Du Cheng <ducheng2@gmail.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20220405210335.3434130-12-daniel.vetter@ffwll.ch

+31 -46
+31 -46
drivers/video/fbdev/core/fbcon.c
··· 682 682 683 683 #endif /* CONFIG_MISC_TILEBLITTING */ 684 684 685 + static void fbcon_release(struct fb_info *info) 686 + { 687 + if (info->fbops->fb_release) 688 + info->fbops->fb_release(info, 0); 689 + 690 + module_put(info->fbops->owner); 691 + } 692 + 685 693 static int fbcon_open(struct fb_info *info) 686 694 { 695 + struct fbcon_ops *ops; 696 + 687 697 if (!try_module_get(info->fbops->owner)) 688 698 return -ENODEV; 689 699 ··· 703 693 return -ENODEV; 704 694 } 705 695 696 + ops = kzalloc(sizeof(struct fbcon_ops), GFP_KERNEL); 697 + if (!ops) { 698 + fbcon_release(info); 699 + return -ENOMEM; 700 + } 701 + 702 + INIT_DELAYED_WORK(&ops->cursor_work, fb_flashcursor); 703 + ops->info = info; 704 + info->fbcon_par = ops; 705 + ops->cur_blink_jiffies = HZ / 5; 706 + 706 707 return 0; 707 708 } 708 709 709 - static void fbcon_release(struct fb_info *info) 710 - { 711 - if (info->fbops->fb_release) 712 - info->fbops->fb_release(info, 0); 713 - 714 - module_put(info->fbops->owner); 715 - } 716 - 717 710 static int con2fb_acquire_newinfo(struct vc_data *vc, struct fb_info *info, 718 - int unit, int oldidx) 711 + int unit) 719 712 { 720 - struct fbcon_ops *ops = NULL; 721 713 int err; 722 714 723 715 err = fbcon_open(info); 724 716 if (err) 725 717 return err; 726 718 727 - if (!err) { 728 - ops = kzalloc(sizeof(struct fbcon_ops), GFP_KERNEL); 729 - if (!ops) 730 - err = -ENOMEM; 731 - } 732 - 733 - if (!err) { 734 - INIT_DELAYED_WORK(&ops->cursor_work, fb_flashcursor); 735 - 736 - ops->cur_blink_jiffies = HZ / 5; 737 - ops->info = info; 738 - info->fbcon_par = ops; 739 - 740 - if (vc) 741 - set_blitting_type(vc, info); 742 - } 743 - 744 - if (err) { 745 - con2fb_map[unit] = oldidx; 746 - fbcon_release(info); 747 - } 719 + if (vc) 720 + set_blitting_type(vc, info); 748 721 749 722 return err; 750 723 } ··· 835 842 836 843 found = search_fb_in_map(newidx); 837 844 838 - con2fb_map[unit] = newidx; 839 - if (!err && !found) 840 - err = con2fb_acquire_newinfo(vc, info, unit, oldidx); 845 + if (!err && !found) { 846 + err = con2fb_acquire_newinfo(vc, info, unit); 847 + if (!err) 848 + con2fb_map[unit] = newidx; 849 + } 841 850 842 851 /* 843 852 * If old fb is not mapped to any of the consoles, ··· 936 941 if (fbcon_open(info)) 937 942 return NULL; 938 943 939 - ops = kzalloc(sizeof(struct fbcon_ops), GFP_KERNEL); 940 - if (!ops) { 941 - fbcon_release(info); 942 - return NULL; 943 - } 944 - 945 - INIT_DELAYED_WORK(&ops->cursor_work, fb_flashcursor); 946 - 944 + ops = info->fbcon_par; 947 945 ops->currcon = -1; 948 946 ops->graphics = 1; 949 947 ops->cur_rotate = -1; 950 - ops->cur_blink_jiffies = HZ / 5; 951 - ops->info = info; 952 - info->fbcon_par = ops; 953 948 954 949 p->con_rotate = initial_rotation; 955 950 if (p->con_rotate == -1) ··· 1009 1024 return; 1010 1025 1011 1026 if (!info->fbcon_par) 1012 - con2fb_acquire_newinfo(vc, info, vc->vc_num, -1); 1027 + con2fb_acquire_newinfo(vc, info, vc->vc_num); 1013 1028 1014 1029 /* If we are not the first console on this 1015 1030 fb, copy the font from that console */