.. | .. |
---|
902 | 902 | value = clamp((htotal + hsstart + 1) / 2 + 2, hsstart + 4, htotal + 1); |
---|
903 | 903 | svga_wcrt_multi(par->state.vgabase, s3_dtpc_regs, value); |
---|
904 | 904 | |
---|
| 905 | + if (screen_size > info->screen_size) |
---|
| 906 | + screen_size = info->screen_size; |
---|
905 | 907 | memset_io(info->screen_base, 0x00, screen_size); |
---|
906 | 908 | /* Device and screen back on */ |
---|
907 | 909 | svga_wcrt_mask(par->state.vgabase, 0x17, 0x80, 0x80); |
---|
.. | .. |
---|
1037 | 1039 | |
---|
1038 | 1040 | /* Frame buffer operations */ |
---|
1039 | 1041 | |
---|
1040 | | -static struct fb_ops s3fb_ops = { |
---|
| 1042 | +static const struct fb_ops s3fb_ops = { |
---|
1041 | 1043 | .owner = THIS_MODULE, |
---|
1042 | 1044 | .fb_open = s3fb_open, |
---|
1043 | 1045 | .fb_release = s3fb_release, |
---|
.. | .. |
---|
1128 | 1130 | |
---|
1129 | 1131 | /* Allocate and fill driver data structure */ |
---|
1130 | 1132 | info = framebuffer_alloc(sizeof(struct s3fb_info), &(dev->dev)); |
---|
1131 | | - if (!info) { |
---|
1132 | | - dev_err(&(dev->dev), "cannot allocate memory\n"); |
---|
| 1133 | + if (!info) |
---|
1133 | 1134 | return -ENOMEM; |
---|
1134 | | - } |
---|
1135 | 1135 | |
---|
1136 | 1136 | par = info->par; |
---|
1137 | 1137 | mutex_init(&par->open_lock); |
---|
.. | .. |
---|
1412 | 1412 | |
---|
1413 | 1413 | /* PCI suspend */ |
---|
1414 | 1414 | |
---|
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) |
---|
1416 | 1416 | { |
---|
1417 | | - struct fb_info *info = pci_get_drvdata(dev); |
---|
| 1417 | + struct fb_info *info = dev_get_drvdata(dev); |
---|
1418 | 1418 | struct s3fb_info *par = info->par; |
---|
1419 | 1419 | |
---|
1420 | 1420 | dev_info(info->device, "suspend\n"); |
---|
.. | .. |
---|
1422 | 1422 | console_lock(); |
---|
1423 | 1423 | mutex_lock(&(par->open_lock)); |
---|
1424 | 1424 | |
---|
1425 | | - if ((state.event == PM_EVENT_FREEZE) || (par->ref_count == 0)) { |
---|
| 1425 | + if (par->ref_count == 0) { |
---|
1426 | 1426 | mutex_unlock(&(par->open_lock)); |
---|
1427 | 1427 | console_unlock(); |
---|
1428 | 1428 | return 0; |
---|
1429 | 1429 | } |
---|
1430 | 1430 | |
---|
1431 | 1431 | 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)); |
---|
1436 | 1432 | |
---|
1437 | 1433 | mutex_unlock(&(par->open_lock)); |
---|
1438 | 1434 | console_unlock(); |
---|
.. | .. |
---|
1443 | 1439 | |
---|
1444 | 1440 | /* PCI resume */ |
---|
1445 | 1441 | |
---|
1446 | | -static int s3_pci_resume(struct pci_dev* dev) |
---|
| 1442 | +static int __maybe_unused s3_pci_resume(struct device *dev) |
---|
1447 | 1443 | { |
---|
1448 | | - struct fb_info *info = pci_get_drvdata(dev); |
---|
| 1444 | + struct fb_info *info = dev_get_drvdata(dev); |
---|
1449 | 1445 | struct s3fb_info *par = info->par; |
---|
1450 | | - int err; |
---|
1451 | 1446 | |
---|
1452 | 1447 | dev_info(info->device, "resume\n"); |
---|
1453 | 1448 | |
---|
.. | .. |
---|
1460 | 1455 | return 0; |
---|
1461 | 1456 | } |
---|
1462 | 1457 | |
---|
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 | | - |
---|
1474 | 1458 | s3fb_set_par(info); |
---|
1475 | 1459 | fb_set_suspend(info, 0); |
---|
1476 | 1460 | |
---|
.. | .. |
---|
1480 | 1464 | return 0; |
---|
1481 | 1465 | } |
---|
1482 | 1466 | |
---|
| 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 | +}; |
---|
1483 | 1477 | |
---|
1484 | 1478 | /* List of boards that we are trying to support */ |
---|
1485 | 1479 | |
---|
.. | .. |
---|
1512 | 1506 | .id_table = s3_devices, |
---|
1513 | 1507 | .probe = s3_pci_probe, |
---|
1514 | 1508 | .remove = s3_pci_remove, |
---|
1515 | | - .suspend = s3_pci_suspend, |
---|
1516 | | - .resume = s3_pci_resume, |
---|
| 1509 | + .driver.pm = &s3_pci_pm_ops, |
---|
1517 | 1510 | }; |
---|
1518 | 1511 | |
---|
1519 | 1512 | /* Parse user specified options */ |
---|