| .. | .. |
|---|
| 778 | 778 | return -EINVAL; |
|---|
| 779 | 779 | } |
|---|
| 780 | 780 | |
|---|
| 781 | | - ark_set_pixclock(info, (hdiv * info->var.pixclock) / hmul); |
|---|
| 781 | + value = (hdiv * info->var.pixclock) / hmul; |
|---|
| 782 | + if (!value) { |
|---|
| 783 | + fb_dbg(info, "invalid pixclock\n"); |
|---|
| 784 | + value = 1; |
|---|
| 785 | + } |
|---|
| 786 | + ark_set_pixclock(info, value); |
|---|
| 782 | 787 | svga_set_timings(par->state.vgabase, &ark_timing_regs, &(info->var), hmul, hdiv, |
|---|
| 783 | 788 | (info->var.vmode & FB_VMODE_DOUBLE) ? 2 : 1, |
|---|
| 784 | 789 | (info->var.vmode & FB_VMODE_INTERLACED) ? 2 : 1, |
|---|
| .. | .. |
|---|
| 789 | 794 | value = ((value * hmul / hdiv) / 8) - 5; |
|---|
| 790 | 795 | vga_wcrt(par->state.vgabase, 0x42, (value + 1) / 2); |
|---|
| 791 | 796 | |
|---|
| 797 | + if (screen_size > info->screen_size) |
|---|
| 798 | + screen_size = info->screen_size; |
|---|
| 792 | 799 | memset_io(info->screen_base, 0x00, screen_size); |
|---|
| 793 | 800 | /* Device and screen back on */ |
|---|
| 794 | 801 | svga_wcrt_mask(par->state.vgabase, 0x17, 0x80, 0x80); |
|---|
| .. | .. |
|---|
| 917 | 924 | |
|---|
| 918 | 925 | /* Frame buffer operations */ |
|---|
| 919 | 926 | |
|---|
| 920 | | -static struct fb_ops arkfb_ops = { |
|---|
| 927 | +static const struct fb_ops arkfb_ops = { |
|---|
| 921 | 928 | .owner = THIS_MODULE, |
|---|
| 922 | 929 | .fb_open = arkfb_open, |
|---|
| 923 | 930 | .fb_release = arkfb_release, |
|---|
| .. | .. |
|---|
| 954 | 961 | |
|---|
| 955 | 962 | /* Allocate and fill driver data structure */ |
|---|
| 956 | 963 | info = framebuffer_alloc(sizeof(struct arkfb_info), &(dev->dev)); |
|---|
| 957 | | - if (! info) { |
|---|
| 958 | | - dev_err(&(dev->dev), "cannot allocate memory\n"); |
|---|
| 964 | + if (!info) |
|---|
| 959 | 965 | return -ENOMEM; |
|---|
| 960 | | - } |
|---|
| 961 | 966 | |
|---|
| 962 | 967 | par = info->par; |
|---|
| 963 | 968 | mutex_init(&par->open_lock); |
|---|
| .. | .. |
|---|
| 1087 | 1092 | } |
|---|
| 1088 | 1093 | |
|---|
| 1089 | 1094 | |
|---|
| 1090 | | -#ifdef CONFIG_PM |
|---|
| 1091 | 1095 | /* PCI suspend */ |
|---|
| 1092 | 1096 | |
|---|
| 1093 | | -static int ark_pci_suspend (struct pci_dev* dev, pm_message_t state) |
|---|
| 1097 | +static int __maybe_unused ark_pci_suspend(struct device *dev) |
|---|
| 1094 | 1098 | { |
|---|
| 1095 | | - struct fb_info *info = pci_get_drvdata(dev); |
|---|
| 1099 | + struct fb_info *info = dev_get_drvdata(dev); |
|---|
| 1096 | 1100 | struct arkfb_info *par = info->par; |
|---|
| 1097 | 1101 | |
|---|
| 1098 | 1102 | dev_info(info->device, "suspend\n"); |
|---|
| .. | .. |
|---|
| 1100 | 1104 | console_lock(); |
|---|
| 1101 | 1105 | mutex_lock(&(par->open_lock)); |
|---|
| 1102 | 1106 | |
|---|
| 1103 | | - if ((state.event == PM_EVENT_FREEZE) || (par->ref_count == 0)) { |
|---|
| 1107 | + if (par->ref_count == 0) { |
|---|
| 1104 | 1108 | mutex_unlock(&(par->open_lock)); |
|---|
| 1105 | 1109 | console_unlock(); |
|---|
| 1106 | 1110 | return 0; |
|---|
| 1107 | 1111 | } |
|---|
| 1108 | 1112 | |
|---|
| 1109 | 1113 | fb_set_suspend(info, 1); |
|---|
| 1110 | | - |
|---|
| 1111 | | - pci_save_state(dev); |
|---|
| 1112 | | - pci_disable_device(dev); |
|---|
| 1113 | | - pci_set_power_state(dev, pci_choose_state(dev, state)); |
|---|
| 1114 | 1114 | |
|---|
| 1115 | 1115 | mutex_unlock(&(par->open_lock)); |
|---|
| 1116 | 1116 | console_unlock(); |
|---|
| .. | .. |
|---|
| 1121 | 1121 | |
|---|
| 1122 | 1122 | /* PCI resume */ |
|---|
| 1123 | 1123 | |
|---|
| 1124 | | -static int ark_pci_resume (struct pci_dev* dev) |
|---|
| 1124 | +static int __maybe_unused ark_pci_resume(struct device *dev) |
|---|
| 1125 | 1125 | { |
|---|
| 1126 | | - struct fb_info *info = pci_get_drvdata(dev); |
|---|
| 1126 | + struct fb_info *info = dev_get_drvdata(dev); |
|---|
| 1127 | 1127 | struct arkfb_info *par = info->par; |
|---|
| 1128 | 1128 | |
|---|
| 1129 | 1129 | dev_info(info->device, "resume\n"); |
|---|
| .. | .. |
|---|
| 1134 | 1134 | if (par->ref_count == 0) |
|---|
| 1135 | 1135 | goto fail; |
|---|
| 1136 | 1136 | |
|---|
| 1137 | | - pci_set_power_state(dev, PCI_D0); |
|---|
| 1138 | | - pci_restore_state(dev); |
|---|
| 1139 | | - |
|---|
| 1140 | | - if (pci_enable_device(dev)) |
|---|
| 1141 | | - goto fail; |
|---|
| 1142 | | - |
|---|
| 1143 | | - pci_set_master(dev); |
|---|
| 1144 | | - |
|---|
| 1145 | 1137 | arkfb_set_par(info); |
|---|
| 1146 | 1138 | fb_set_suspend(info, 0); |
|---|
| 1147 | 1139 | |
|---|
| .. | .. |
|---|
| 1150 | 1142 | console_unlock(); |
|---|
| 1151 | 1143 | return 0; |
|---|
| 1152 | 1144 | } |
|---|
| 1153 | | -#else |
|---|
| 1154 | | -#define ark_pci_suspend NULL |
|---|
| 1155 | | -#define ark_pci_resume NULL |
|---|
| 1156 | | -#endif /* CONFIG_PM */ |
|---|
| 1145 | + |
|---|
| 1146 | +static const struct dev_pm_ops ark_pci_pm_ops = { |
|---|
| 1147 | +#ifdef CONFIG_PM_SLEEP |
|---|
| 1148 | + .suspend = ark_pci_suspend, |
|---|
| 1149 | + .resume = ark_pci_resume, |
|---|
| 1150 | + .freeze = NULL, |
|---|
| 1151 | + .thaw = ark_pci_resume, |
|---|
| 1152 | + .poweroff = ark_pci_suspend, |
|---|
| 1153 | + .restore = ark_pci_resume, |
|---|
| 1154 | +#endif |
|---|
| 1155 | +}; |
|---|
| 1157 | 1156 | |
|---|
| 1158 | 1157 | /* List of boards that we are trying to support */ |
|---|
| 1159 | 1158 | |
|---|
| .. | .. |
|---|
| 1170 | 1169 | .id_table = ark_devices, |
|---|
| 1171 | 1170 | .probe = ark_pci_probe, |
|---|
| 1172 | 1171 | .remove = ark_pci_remove, |
|---|
| 1173 | | - .suspend = ark_pci_suspend, |
|---|
| 1174 | | - .resume = ark_pci_resume, |
|---|
| 1172 | + .driver.pm = &ark_pci_pm_ops, |
|---|
| 1175 | 1173 | }; |
|---|
| 1176 | 1174 | |
|---|
| 1177 | 1175 | /* Cleanup */ |
|---|