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

[PATCH] atyfb, rivafb: minor fixes

aty128fb: return an error in the unlikely event that we cannot calculate
some key PLL info

rivafb:
* call CalcStateExt() directly, rather than via function pointers, since
CalcStateExt() is the only value ever assigned to ->CalcStateExt().
* propagate error return back from CalcVClock() through callers

Signed-off-by: Jeff Garzik <jeff@garzik.org>
Cc: "Antonino A. Daplas" <adaplas@pol.net>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by

Jeff Garzik and committed by
Linus Torvalds
fd717689 945f0ee2

+43 -11
+5
drivers/video/aty/aty128fb.c
··· 1333 1333 if (vclk * 12 < c.ppll_min) 1334 1334 vclk = c.ppll_min/12; 1335 1335 1336 + pll->post_divider = -1; 1337 + 1336 1338 /* now, find an acceptable divider */ 1337 1339 for (i = 0; i < sizeof(post_dividers); i++) { 1338 1340 output_freq = post_dividers[i] * vclk; ··· 1343 1341 break; 1344 1342 } 1345 1343 } 1344 + 1345 + if (pll->post_divider < 0) 1346 + return -EINVAL; 1346 1347 1347 1348 /* calculate feedback divider */ 1348 1349 n = c.ref_divider * output_freq;
+17 -5
drivers/video/riva/fbdev.c
··· 740 740 * CALLED FROM: 741 741 * rivafb_set_par() 742 742 */ 743 - static void riva_load_video_mode(struct fb_info *info) 743 + static int riva_load_video_mode(struct fb_info *info) 744 744 { 745 745 int bpp, width, hDisplaySize, hDisplay, hStart, 746 746 hEnd, hTotal, height, vDisplay, vStart, vEnd, vTotal, dotClock; 747 747 int hBlankStart, hBlankEnd, vBlankStart, vBlankEnd; 748 + int rc; 748 749 struct riva_par *par = info->par; 749 750 struct riva_regs newmode; 750 751 ··· 851 850 else 852 851 newmode.misc_output |= 0x80; 853 852 854 - par->riva.CalcStateExt(&par->riva, &newmode.ext, bpp, width, 855 - hDisplaySize, height, dotClock); 853 + rc = CalcStateExt(&par->riva, &newmode.ext, bpp, width, 854 + hDisplaySize, height, dotClock); 855 + if (rc) 856 + goto out; 856 857 857 858 newmode.ext.scale = NV_RD32(par->riva.PRAMDAC, 0x00000848) & 858 859 0xfff000ff; ··· 886 883 par->current_state = newmode; 887 884 riva_load_state(par, &par->current_state); 888 885 par->riva.LockUnlock(&par->riva, 0); /* important for HW cursor */ 886 + 887 + out: 889 888 rivafb_blank(FB_BLANK_UNBLANK, info); 890 889 NVTRACE_LEAVE(); 890 + 891 + return rc; 891 892 } 892 893 893 894 static void riva_update_var(struct fb_var_screeninfo *var, struct fb_videomode *modedb) ··· 1259 1252 static int rivafb_set_par(struct fb_info *info) 1260 1253 { 1261 1254 struct riva_par *par = info->par; 1255 + int rc = 0; 1262 1256 1263 1257 NVTRACE_ENTER(); 1264 1258 /* vgaHWunlock() + riva unlock (0x7F) */ 1265 1259 CRTCout(par, 0x11, 0xFF); 1266 1260 par->riva.LockUnlock(&par->riva, 0); 1267 - riva_load_video_mode(info); 1261 + rc = riva_load_video_mode(info); 1262 + if (rc) 1263 + goto out; 1268 1264 if(!(info->flags & FBINFO_HWACCEL_DISABLED)) 1269 1265 riva_setup_accel(info); 1270 1266 ··· 1280 1270 info->pixmap.scan_align = 1; 1281 1271 else 1282 1272 info->pixmap.scan_align = 4; 1273 + 1274 + out: 1283 1275 NVTRACE_LEAVE(); 1284 - return 0; 1276 + return rc; 1285 1277 } 1286 1278 1287 1279 /**
+5 -5
drivers/video/riva/riva_hw.c
··· 1227 1227 * Calculate extended mode parameters (SVGA) and save in a 1228 1228 * mode state structure. 1229 1229 */ 1230 - static void CalcStateExt 1230 + int CalcStateExt 1231 1231 ( 1232 1232 RIVA_HW_INST *chip, 1233 1233 RIVA_HW_STATE *state, ··· 1249 1249 * Extended RIVA registers. 1250 1250 */ 1251 1251 pixelDepth = (bpp + 1)/8; 1252 - CalcVClock(dotClock, &VClk, &m, &n, &p, chip); 1252 + if (!CalcVClock(dotClock, &VClk, &m, &n, &p, chip)) 1253 + return -EINVAL; 1253 1254 1254 1255 switch (chip->Architecture) 1255 1256 { ··· 1328 1327 state->pitch1 = 1329 1328 state->pitch2 = 1330 1329 state->pitch3 = pixelDepth * width; 1330 + 1331 + return 0; 1331 1332 } 1332 1333 /* 1333 1334 * Load fixed function state and pre-calculated/stored state. ··· 2029 2026 */ 2030 2027 chip->Busy = nv3Busy; 2031 2028 chip->ShowHideCursor = ShowHideCursor; 2032 - chip->CalcStateExt = CalcStateExt; 2033 2029 chip->LoadStateExt = LoadStateExt; 2034 2030 chip->UnloadStateExt = UnloadStateExt; 2035 2031 chip->SetStartAddress = SetStartAddress3; ··· 2086 2084 */ 2087 2085 chip->Busy = nv4Busy; 2088 2086 chip->ShowHideCursor = ShowHideCursor; 2089 - chip->CalcStateExt = CalcStateExt; 2090 2087 chip->LoadStateExt = LoadStateExt; 2091 2088 chip->UnloadStateExt = UnloadStateExt; 2092 2089 chip->SetStartAddress = SetStartAddress; ··· 2187 2186 */ 2188 2187 chip->Busy = nv10Busy; 2189 2188 chip->ShowHideCursor = ShowHideCursor; 2190 - chip->CalcStateExt = CalcStateExt; 2191 2189 chip->LoadStateExt = LoadStateExt; 2192 2190 chip->UnloadStateExt = UnloadStateExt; 2193 2191 chip->SetStartAddress = SetStartAddress;
+16 -1
drivers/video/riva/riva_hw.h
··· 463 463 * Common chip functions. 464 464 */ 465 465 int (*Busy)(struct _riva_hw_inst *); 466 - void (*CalcStateExt)(struct _riva_hw_inst *,struct _riva_hw_state *,int,int,int,int,int); 467 466 void (*LoadStateExt)(struct _riva_hw_inst *,struct _riva_hw_state *); 468 467 void (*UnloadStateExt)(struct _riva_hw_inst *,struct _riva_hw_state *); 469 468 void (*SetStartAddress)(struct _riva_hw_inst *,U032); ··· 527 528 U032 pitch2; 528 529 U032 pitch3; 529 530 } RIVA_HW_STATE; 531 + 532 + /* 533 + * function prototypes 534 + */ 535 + 536 + extern int CalcStateExt 537 + ( 538 + RIVA_HW_INST *chip, 539 + RIVA_HW_STATE *state, 540 + int bpp, 541 + int width, 542 + int hDisplaySize, 543 + int height, 544 + int dotClock 545 + ); 546 + 530 547 /* 531 548 * External routines. 532 549 */