hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/video/fbdev/s3fb.c
....@@ -902,6 +902,8 @@
902902 value = clamp((htotal + hsstart + 1) / 2 + 2, hsstart + 4, htotal + 1);
903903 svga_wcrt_multi(par->state.vgabase, s3_dtpc_regs, value);
904904
905
+ if (screen_size > info->screen_size)
906
+ screen_size = info->screen_size;
905907 memset_io(info->screen_base, 0x00, screen_size);
906908 /* Device and screen back on */
907909 svga_wcrt_mask(par->state.vgabase, 0x17, 0x80, 0x80);
....@@ -1037,7 +1039,7 @@
10371039
10381040 /* Frame buffer operations */
10391041
1040
-static struct fb_ops s3fb_ops = {
1042
+static const struct fb_ops s3fb_ops = {
10411043 .owner = THIS_MODULE,
10421044 .fb_open = s3fb_open,
10431045 .fb_release = s3fb_release,
....@@ -1128,10 +1130,8 @@
11281130
11291131 /* Allocate and fill driver data structure */
11301132 info = framebuffer_alloc(sizeof(struct s3fb_info), &(dev->dev));
1131
- if (!info) {
1132
- dev_err(&(dev->dev), "cannot allocate memory\n");
1133
+ if (!info)
11331134 return -ENOMEM;
1134
- }
11351135
11361136 par = info->par;
11371137 mutex_init(&par->open_lock);
....@@ -1412,9 +1412,9 @@
14121412
14131413 /* PCI suspend */
14141414
1415
-static int s3_pci_suspend(struct pci_dev* dev, pm_message_t state)
1415
+static int __maybe_unused s3_pci_suspend(struct device *dev)
14161416 {
1417
- struct fb_info *info = pci_get_drvdata(dev);
1417
+ struct fb_info *info = dev_get_drvdata(dev);
14181418 struct s3fb_info *par = info->par;
14191419
14201420 dev_info(info->device, "suspend\n");
....@@ -1422,17 +1422,13 @@
14221422 console_lock();
14231423 mutex_lock(&(par->open_lock));
14241424
1425
- if ((state.event == PM_EVENT_FREEZE) || (par->ref_count == 0)) {
1425
+ if (par->ref_count == 0) {
14261426 mutex_unlock(&(par->open_lock));
14271427 console_unlock();
14281428 return 0;
14291429 }
14301430
14311431 fb_set_suspend(info, 1);
1432
-
1433
- pci_save_state(dev);
1434
- pci_disable_device(dev);
1435
- pci_set_power_state(dev, pci_choose_state(dev, state));
14361432
14371433 mutex_unlock(&(par->open_lock));
14381434 console_unlock();
....@@ -1443,11 +1439,10 @@
14431439
14441440 /* PCI resume */
14451441
1446
-static int s3_pci_resume(struct pci_dev* dev)
1442
+static int __maybe_unused s3_pci_resume(struct device *dev)
14471443 {
1448
- struct fb_info *info = pci_get_drvdata(dev);
1444
+ struct fb_info *info = dev_get_drvdata(dev);
14491445 struct s3fb_info *par = info->par;
1450
- int err;
14511446
14521447 dev_info(info->device, "resume\n");
14531448
....@@ -1460,17 +1455,6 @@
14601455 return 0;
14611456 }
14621457
1463
- pci_set_power_state(dev, PCI_D0);
1464
- pci_restore_state(dev);
1465
- err = pci_enable_device(dev);
1466
- if (err) {
1467
- mutex_unlock(&(par->open_lock));
1468
- console_unlock();
1469
- dev_err(info->device, "error %d enabling device for resume\n", err);
1470
- return err;
1471
- }
1472
- pci_set_master(dev);
1473
-
14741458 s3fb_set_par(info);
14751459 fb_set_suspend(info, 0);
14761460
....@@ -1480,6 +1464,16 @@
14801464 return 0;
14811465 }
14821466
1467
+static const struct dev_pm_ops s3_pci_pm_ops = {
1468
+#ifdef CONFIG_PM_SLEEP
1469
+ .suspend = s3_pci_suspend,
1470
+ .resume = s3_pci_resume,
1471
+ .freeze = NULL,
1472
+ .thaw = s3_pci_resume,
1473
+ .poweroff = s3_pci_suspend,
1474
+ .restore = s3_pci_resume,
1475
+#endif
1476
+};
14831477
14841478 /* List of boards that we are trying to support */
14851479
....@@ -1512,8 +1506,7 @@
15121506 .id_table = s3_devices,
15131507 .probe = s3_pci_probe,
15141508 .remove = s3_pci_remove,
1515
- .suspend = s3_pci_suspend,
1516
- .resume = s3_pci_resume,
1509
+ .driver.pm = &s3_pci_pm_ops,
15171510 };
15181511
15191512 /* Parse user specified options */