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

staging/sm750fb: Declare fb_ops as constant

Split up lynxfb_ops and declare each as constant. The fb_ops
instance used to be modified while initializing the driver. It is
now constant and the driver picks the correct instance, depending
on the settings for acceleration and cursor support.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
Cc: Teddy Wang <teddy.wang@siliconmotion.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-staging@lists.linux.dev
Acked-by: Javier Martinez Canillas <javierm@redhat.com>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20231127131655.4020-26-tzimmermann@suse.de

+49 -10
+49 -10
drivers/staging/sm750fb/sm750.c
··· 663 663 return ret; 664 664 } 665 665 666 - static struct fb_ops lynxfb_ops = { 666 + static const struct fb_ops lynxfb_ops = { 667 667 .owner = THIS_MODULE, 668 668 .fb_check_var = lynxfb_ops_check_var, 669 669 .fb_set_par = lynxfb_ops_set_par, 670 670 .fb_setcolreg = lynxfb_ops_setcolreg, 671 671 .fb_blank = lynxfb_ops_blank, 672 + .fb_pan_display = lynxfb_ops_pan_display, 672 673 .fb_fillrect = cfb_fillrect, 673 674 .fb_imageblit = cfb_imageblit, 674 675 .fb_copyarea = cfb_copyarea, 675 - /* cursor */ 676 + }; 677 + 678 + static const struct fb_ops lynxfb_ops_with_cursor = { 679 + .owner = THIS_MODULE, 680 + .fb_check_var = lynxfb_ops_check_var, 681 + .fb_set_par = lynxfb_ops_set_par, 682 + .fb_setcolreg = lynxfb_ops_setcolreg, 683 + .fb_blank = lynxfb_ops_blank, 684 + .fb_pan_display = lynxfb_ops_pan_display, 685 + .fb_fillrect = cfb_fillrect, 686 + .fb_copyarea = cfb_copyarea, 687 + .fb_imageblit = cfb_imageblit, 688 + .fb_cursor = lynxfb_ops_cursor, 689 + }; 690 + 691 + static const struct fb_ops lynxfb_ops_accel = { 692 + .owner = THIS_MODULE, 693 + .fb_check_var = lynxfb_ops_check_var, 694 + .fb_set_par = lynxfb_ops_set_par, 695 + .fb_setcolreg = lynxfb_ops_setcolreg, 696 + .fb_blank = lynxfb_ops_blank, 697 + .fb_pan_display = lynxfb_ops_pan_display, 698 + .fb_fillrect = lynxfb_ops_fillrect, 699 + .fb_copyarea = lynxfb_ops_copyarea, 700 + .fb_imageblit = lynxfb_ops_imageblit, 701 + }; 702 + 703 + static const struct fb_ops lynxfb_ops_accel_with_cursor = { 704 + .owner = THIS_MODULE, 705 + .fb_check_var = lynxfb_ops_check_var, 706 + .fb_set_par = lynxfb_ops_set_par, 707 + .fb_setcolreg = lynxfb_ops_setcolreg, 708 + .fb_blank = lynxfb_ops_blank, 709 + .fb_pan_display = lynxfb_ops_pan_display, 710 + .fb_fillrect = lynxfb_ops_fillrect, 711 + .fb_copyarea = lynxfb_ops_copyarea, 712 + .fb_imageblit = lynxfb_ops_imageblit, 676 713 .fb_cursor = lynxfb_ops_cursor, 677 714 }; 678 715 ··· 751 714 par->index = index; 752 715 output->channel = &crtc->channel; 753 716 sm750fb_set_drv(par); 754 - lynxfb_ops.fb_pan_display = lynxfb_ops_pan_display; 755 717 756 718 /* 757 719 * set current cursor variable and proc pointer, ··· 767 731 crtc->cursor.vstart = sm750_dev->pvMem + crtc->cursor.offset; 768 732 769 733 memset_io(crtc->cursor.vstart, 0, crtc->cursor.size); 770 - if (!g_hwcursor) { 771 - lynxfb_ops.fb_cursor = NULL; 734 + if (!g_hwcursor) 772 735 sm750_hw_cursor_disable(&crtc->cursor); 773 - } 774 736 775 737 /* set info->fbops, must be set before fb_find_mode */ 776 738 if (!sm750_dev->accel_off) { 777 739 /* use 2d acceleration */ 778 - lynxfb_ops.fb_fillrect = lynxfb_ops_fillrect; 779 - lynxfb_ops.fb_copyarea = lynxfb_ops_copyarea; 780 - lynxfb_ops.fb_imageblit = lynxfb_ops_imageblit; 740 + if (!g_hwcursor) 741 + info->fbops = &lynxfb_ops_accel; 742 + else 743 + info->fbops = &lynxfb_ops_accel_with_cursor; 744 + } else { 745 + if (!g_hwcursor) 746 + info->fbops = &lynxfb_ops; 747 + else 748 + info->fbops = &lynxfb_ops_with_cursor; 781 749 } 782 - info->fbops = &lynxfb_ops; 783 750 784 751 if (!g_fbmode[index]) { 785 752 g_fbmode[index] = g_def_fbmode;