From e3e4e9c61eb7bbd1171a2b948f1ea4591bac8289 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Sat, 21 May 2011 19:42:54 +0000 Subject: fbdev/amifb: Correct check for video memory size The check should compare the available memory size with the highest allocation value (VIDEOMEMSIZE_*_2M), not with the lowest value (VIDEOMEMSIZE_*_1M). Signed-off-by: Geert Uytterhoeven Signed-off-by: Paul Mundt --- drivers/video/amifb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/video/amifb.c') diff --git a/drivers/video/amifb.c b/drivers/video/amifb.c index e5d6b56..603f84f 100644 --- a/drivers/video/amifb.c +++ b/drivers/video/amifb.c @@ -2295,7 +2295,7 @@ default_chipset: defmode = amiga_vblank == 50 ? DEFMODE_PAL : DEFMODE_NTSC; if (amiga_chip_avail()-CHIPRAM_SAFETY_LIMIT > - VIDEOMEMSIZE_ECS_1M) + VIDEOMEMSIZE_ECS_2M) fb_info.fix.smem_len = VIDEOMEMSIZE_ECS_2M; else fb_info.fix.smem_len = VIDEOMEMSIZE_ECS_1M; @@ -2312,7 +2312,7 @@ default_chipset: maxfmode = TAG_FMODE_4; defmode = DEFMODE_AGA; if (amiga_chip_avail()-CHIPRAM_SAFETY_LIMIT > - VIDEOMEMSIZE_AGA_1M) + VIDEOMEMSIZE_AGA_2M) fb_info.fix.smem_len = VIDEOMEMSIZE_AGA_2M; else fb_info.fix.smem_len = VIDEOMEMSIZE_AGA_1M; -- cgit v1.1 From a707642a0653c457376068d9d4a77afe93c10c93 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Sat, 21 May 2011 19:42:55 +0000 Subject: fbdev/amifb: Do not call panic() if there's not enough Chip RAM Fail gracefully instead. Signed-off-by: Geert Uytterhoeven Signed-off-by: Paul Mundt --- drivers/video/amifb.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'drivers/video/amifb.c') diff --git a/drivers/video/amifb.c b/drivers/video/amifb.c index 603f84f..1b0185c 100644 --- a/drivers/video/amifb.c +++ b/drivers/video/amifb.c @@ -2230,8 +2230,10 @@ static inline u_long __init chipalloc(u_long size) { size += PAGE_SIZE-1; if (!(unaligned_chipptr = (u_long)amiga_chip_alloc(size, - "amifb [RAM]"))) - panic("No Chip RAM for frame buffer"); + "amifb [RAM]"))) { + pr_err("amifb: No Chip RAM for frame buffer"); + return 0; + } memset((void *)unaligned_chipptr, 0, size); return PAGE_ALIGN(unaligned_chipptr); } @@ -2385,6 +2387,10 @@ default_chipset: DUMMYSPRITEMEMSIZE+ COPINITSIZE+ 4*COPLISTSIZE); + if (!chipptr) { + err = -ENOMEM; + goto amifb_error; + } assignchunk(videomemory, u_long, chipptr, fb_info.fix.smem_len); assignchunk(spritememory, u_long, chipptr, SPRITEMEMSIZE); -- cgit v1.1 From 8f25c01dec43ccfb0ec7d6216c1494772917a429 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Sat, 21 May 2011 19:42:56 +0000 Subject: fbdev/amifb: Remove superfluous alignment of frame buffer memory amiga_chip_alloc() already aligns to the PAGE_SIZE Signed-off-by: Geert Uytterhoeven Signed-off-by: Paul Mundt --- drivers/video/amifb.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'drivers/video/amifb.c') diff --git a/drivers/video/amifb.c b/drivers/video/amifb.c index 1b0185c..5ea6596 100644 --- a/drivers/video/amifb.c +++ b/drivers/video/amifb.c @@ -2224,24 +2224,23 @@ static int amifb_ioctl(struct fb_info *info, * Allocate, Clear and Align a Block of Chip Memory */ -static u_long unaligned_chipptr = 0; +static void *aligned_chipptr; static inline u_long __init chipalloc(u_long size) { - size += PAGE_SIZE-1; - if (!(unaligned_chipptr = (u_long)amiga_chip_alloc(size, - "amifb [RAM]"))) { + aligned_chipptr = amiga_chip_alloc(size, "amifb [RAM]"); + if (!aligned_chipptr) { pr_err("amifb: No Chip RAM for frame buffer"); return 0; } - memset((void *)unaligned_chipptr, 0, size); - return PAGE_ALIGN(unaligned_chipptr); + memset(aligned_chipptr, 0, size); + return (u_long)aligned_chipptr; } static inline void chipfree(void) { - if (unaligned_chipptr) - amiga_chip_free((void *)unaligned_chipptr); + if (aligned_chipptr) + amiga_chip_free(aligned_chipptr); } -- cgit v1.1