hc
2023-12-09 b22da3d8526a935aa31e086e63f60ff3246cb61c
kernel/drivers/video/fbdev/vt8623fb.c
....@@ -62,24 +62,24 @@
6262
6363 /* CRT timing register sets */
6464
65
-static struct vga_regset vt8623_h_total_regs[] = {{0x00, 0, 7}, {0x36, 3, 3}, VGA_REGSET_END};
66
-static struct vga_regset vt8623_h_display_regs[] = {{0x01, 0, 7}, VGA_REGSET_END};
67
-static struct vga_regset vt8623_h_blank_start_regs[] = {{0x02, 0, 7}, VGA_REGSET_END};
68
-static struct vga_regset vt8623_h_blank_end_regs[] = {{0x03, 0, 4}, {0x05, 7, 7}, {0x33, 5, 5}, VGA_REGSET_END};
69
-static struct vga_regset vt8623_h_sync_start_regs[] = {{0x04, 0, 7}, {0x33, 4, 4}, VGA_REGSET_END};
70
-static struct vga_regset vt8623_h_sync_end_regs[] = {{0x05, 0, 4}, VGA_REGSET_END};
65
+static const struct vga_regset vt8623_h_total_regs[] = {{0x00, 0, 7}, {0x36, 3, 3}, VGA_REGSET_END};
66
+static const struct vga_regset vt8623_h_display_regs[] = {{0x01, 0, 7}, VGA_REGSET_END};
67
+static const struct vga_regset vt8623_h_blank_start_regs[] = {{0x02, 0, 7}, VGA_REGSET_END};
68
+static const struct vga_regset vt8623_h_blank_end_regs[] = {{0x03, 0, 4}, {0x05, 7, 7}, {0x33, 5, 5}, VGA_REGSET_END};
69
+static const struct vga_regset vt8623_h_sync_start_regs[] = {{0x04, 0, 7}, {0x33, 4, 4}, VGA_REGSET_END};
70
+static const struct vga_regset vt8623_h_sync_end_regs[] = {{0x05, 0, 4}, VGA_REGSET_END};
7171
72
-static struct vga_regset vt8623_v_total_regs[] = {{0x06, 0, 7}, {0x07, 0, 0}, {0x07, 5, 5}, {0x35, 0, 0}, VGA_REGSET_END};
73
-static struct vga_regset vt8623_v_display_regs[] = {{0x12, 0, 7}, {0x07, 1, 1}, {0x07, 6, 6}, {0x35, 2, 2}, VGA_REGSET_END};
74
-static struct vga_regset vt8623_v_blank_start_regs[] = {{0x15, 0, 7}, {0x07, 3, 3}, {0x09, 5, 5}, {0x35, 3, 3}, VGA_REGSET_END};
75
-static struct vga_regset vt8623_v_blank_end_regs[] = {{0x16, 0, 7}, VGA_REGSET_END};
76
-static struct vga_regset vt8623_v_sync_start_regs[] = {{0x10, 0, 7}, {0x07, 2, 2}, {0x07, 7, 7}, {0x35, 1, 1}, VGA_REGSET_END};
77
-static struct vga_regset vt8623_v_sync_end_regs[] = {{0x11, 0, 3}, VGA_REGSET_END};
72
+static const struct vga_regset vt8623_v_total_regs[] = {{0x06, 0, 7}, {0x07, 0, 0}, {0x07, 5, 5}, {0x35, 0, 0}, VGA_REGSET_END};
73
+static const struct vga_regset vt8623_v_display_regs[] = {{0x12, 0, 7}, {0x07, 1, 1}, {0x07, 6, 6}, {0x35, 2, 2}, VGA_REGSET_END};
74
+static const struct vga_regset vt8623_v_blank_start_regs[] = {{0x15, 0, 7}, {0x07, 3, 3}, {0x09, 5, 5}, {0x35, 3, 3}, VGA_REGSET_END};
75
+static const struct vga_regset vt8623_v_blank_end_regs[] = {{0x16, 0, 7}, VGA_REGSET_END};
76
+static const struct vga_regset vt8623_v_sync_start_regs[] = {{0x10, 0, 7}, {0x07, 2, 2}, {0x07, 7, 7}, {0x35, 1, 1}, VGA_REGSET_END};
77
+static const struct vga_regset vt8623_v_sync_end_regs[] = {{0x11, 0, 3}, VGA_REGSET_END};
7878
79
-static struct vga_regset vt8623_offset_regs[] = {{0x13, 0, 7}, {0x35, 5, 7}, VGA_REGSET_END};
80
-static struct vga_regset vt8623_line_compare_regs[] = {{0x18, 0, 7}, {0x07, 4, 4}, {0x09, 6, 6}, {0x33, 0, 2}, {0x35, 4, 4}, VGA_REGSET_END};
81
-static struct vga_regset vt8623_fetch_count_regs[] = {{0x1C, 0, 7}, {0x1D, 0, 1}, VGA_REGSET_END};
82
-static struct vga_regset vt8623_start_address_regs[] = {{0x0d, 0, 7}, {0x0c, 0, 7}, {0x34, 0, 7}, {0x48, 0, 1}, VGA_REGSET_END};
79
+static const struct vga_regset vt8623_offset_regs[] = {{0x13, 0, 7}, {0x35, 5, 7}, VGA_REGSET_END};
80
+static const struct vga_regset vt8623_line_compare_regs[] = {{0x18, 0, 7}, {0x07, 4, 4}, {0x09, 6, 6}, {0x33, 0, 2}, {0x35, 4, 4}, VGA_REGSET_END};
81
+static const struct vga_regset vt8623_fetch_count_regs[] = {{0x1C, 0, 7}, {0x1D, 0, 1}, VGA_REGSET_END};
82
+static const struct vga_regset vt8623_start_address_regs[] = {{0x0d, 0, 7}, {0x0c, 0, 7}, {0x34, 0, 7}, {0x48, 0, 1}, VGA_REGSET_END};
8383
8484 static const struct svga_timing_regs vt8623_timing_regs = {
8585 vt8623_h_total_regs, vt8623_h_display_regs, vt8623_h_blank_start_regs,
....@@ -504,6 +504,8 @@
504504 (info->var.vmode & FB_VMODE_DOUBLE) ? 2 : 1, 1,
505505 1, info->node);
506506
507
+ if (screen_size > info->screen_size)
508
+ screen_size = info->screen_size;
507509 memset_io(info->screen_base, 0x00, screen_size);
508510
509511 /* Device and screen back on */
....@@ -634,7 +636,7 @@
634636
635637 /* Frame buffer operations */
636638
637
-static struct fb_ops vt8623fb_ops = {
639
+static const struct fb_ops vt8623fb_ops = {
638640 .owner = THIS_MODULE,
639641 .fb_open = vt8623fb_open,
640642 .fb_release = vt8623fb_release,
....@@ -669,10 +671,8 @@
669671
670672 /* Allocate and fill driver data structure */
671673 info = framebuffer_alloc(sizeof(struct vt8623fb_info), &(dev->dev));
672
- if (! info) {
673
- dev_err(&(dev->dev), "cannot allocate memory\n");
674
+ if (!info)
674675 return -ENOMEM;
675
- }
676676
677677 par = info->par;
678678 mutex_init(&par->open_lock);
....@@ -817,12 +817,11 @@
817817 }
818818
819819
820
-#ifdef CONFIG_PM
821820 /* PCI suspend */
822821
823
-static int vt8623_pci_suspend(struct pci_dev* dev, pm_message_t state)
822
+static int __maybe_unused vt8623_pci_suspend(struct device *dev)
824823 {
825
- struct fb_info *info = pci_get_drvdata(dev);
824
+ struct fb_info *info = dev_get_drvdata(dev);
826825 struct vt8623fb_info *par = info->par;
827826
828827 dev_info(info->device, "suspend\n");
....@@ -830,17 +829,13 @@
830829 console_lock();
831830 mutex_lock(&(par->open_lock));
832831
833
- if ((state.event == PM_EVENT_FREEZE) || (par->ref_count == 0)) {
832
+ if (par->ref_count == 0) {
834833 mutex_unlock(&(par->open_lock));
835834 console_unlock();
836835 return 0;
837836 }
838837
839838 fb_set_suspend(info, 1);
840
-
841
- pci_save_state(dev);
842
- pci_disable_device(dev);
843
- pci_set_power_state(dev, pci_choose_state(dev, state));
844839
845840 mutex_unlock(&(par->open_lock));
846841 console_unlock();
....@@ -851,9 +846,9 @@
851846
852847 /* PCI resume */
853848
854
-static int vt8623_pci_resume(struct pci_dev* dev)
849
+static int __maybe_unused vt8623_pci_resume(struct device *dev)
855850 {
856
- struct fb_info *info = pci_get_drvdata(dev);
851
+ struct fb_info *info = dev_get_drvdata(dev);
857852 struct vt8623fb_info *par = info->par;
858853
859854 dev_info(info->device, "resume\n");
....@@ -864,14 +859,6 @@
864859 if (par->ref_count == 0)
865860 goto fail;
866861
867
- pci_set_power_state(dev, PCI_D0);
868
- pci_restore_state(dev);
869
-
870
- if (pci_enable_device(dev))
871
- goto fail;
872
-
873
- pci_set_master(dev);
874
-
875862 vt8623fb_set_par(info);
876863 fb_set_suspend(info, 0);
877864
....@@ -881,10 +868,17 @@
881868
882869 return 0;
883870 }
884
-#else
885
-#define vt8623_pci_suspend NULL
886
-#define vt8623_pci_resume NULL
887
-#endif /* CONFIG_PM */
871
+
872
+static const struct dev_pm_ops vt8623_pci_pm_ops = {
873
+#ifdef CONFIG_PM_SLEEP
874
+ .suspend = vt8623_pci_suspend,
875
+ .resume = vt8623_pci_resume,
876
+ .freeze = NULL,
877
+ .thaw = vt8623_pci_resume,
878
+ .poweroff = vt8623_pci_suspend,
879
+ .restore = vt8623_pci_resume,
880
+#endif /* CONFIG_PM_SLEEP */
881
+};
888882
889883 /* List of boards that we are trying to support */
890884
....@@ -900,8 +894,7 @@
900894 .id_table = vt8623_devices,
901895 .probe = vt8623_pci_probe,
902896 .remove = vt8623_pci_remove,
903
- .suspend = vt8623_pci_suspend,
904
- .resume = vt8623_pci_resume,
897
+ .driver.pm = &vt8623_pci_pm_ops,
905898 };
906899
907900 /* Cleanup */