diff mbox

fbdev: Make pixel_to_pat() failure mode more friendly

Message ID 1343117953.3715.23.camel@pasglop (mailing list archive)
State New, archived
Headers show

Commit Message

Benjamin Herrenschmidt July 24, 2012, 8:19 a.m. UTC
If we accidentally pass an incorrect bpp value to pixel_to_pat(),
it panics. This is pretty useless, as we generally have the various
console locks held at that point, so nothing will be displayed,
and there is no reason to make this a fatal event.

Let's WARN instead.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---



--
To unsubscribe from this list: send the line "unsubscribe linux-fbdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Florian Tobias Schandinat July 29, 2012, 9:16 p.m. UTC | #1
On 07/24/2012 08:19 AM, Benjamin Herrenschmidt wrote:
> If we accidentally pass an incorrect bpp value to pixel_to_pat(),
> it panics. This is pretty useless, as we generally have the various
> console locks held at that point, so nothing will be displayed,
> and there is no reason to make this a fatal event.
> 
> Let's WARN instead.
> 
> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>

Applied.


Thanks,

Florian Tobias Schandinat

> ---
> 
> diff --git a/drivers/video/fb_draw.h b/drivers/video/fb_draw.h
> index 04c01fa..624ee11 100644
> --- a/drivers/video/fb_draw.h
> +++ b/drivers/video/fb_draw.h
> @@ -3,6 +3,7 @@
>  
>  #include <asm/types.h>
>  #include <linux/fb.h>
> +#include <linux/bug.h>
>  
>      /*
>       *  Compose two values, using a bitmask as decision value
> @@ -41,7 +42,8 @@ pixel_to_pat( u32 bpp, u32 pixel)
>  	case 32:
>  		return 0x0000000100000001ul*pixel;
>  	default:
> -		panic("pixel_to_pat(): unsupported pixelformat\n");
> +		WARN(1, "pixel_to_pat(): unsupported pixelformat %d\n", bpp);
> +		return 0;
>      }
>  }
>  #else
> @@ -66,7 +68,8 @@ pixel_to_pat( u32 bpp, u32 pixel)
>  	case 32:
>  		return 0x00000001ul*pixel;
>  	default:
> -		panic("pixel_to_pat(): unsupported pixelformat\n");
> +		WARN(1, "pixel_to_pat(): unsupported pixelformat %d\n", bpp);
> +		return 0;
>      }
>  }
>  #endif
> 
> 
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-fbdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/video/fb_draw.h b/drivers/video/fb_draw.h
index 04c01fa..624ee11 100644
--- a/drivers/video/fb_draw.h
+++ b/drivers/video/fb_draw.h
@@ -3,6 +3,7 @@ 
 
 #include <asm/types.h>
 #include <linux/fb.h>
+#include <linux/bug.h>
 
     /*
      *  Compose two values, using a bitmask as decision value
@@ -41,7 +42,8 @@  pixel_to_pat( u32 bpp, u32 pixel)
 	case 32:
 		return 0x0000000100000001ul*pixel;
 	default:
-		panic("pixel_to_pat(): unsupported pixelformat\n");
+		WARN(1, "pixel_to_pat(): unsupported pixelformat %d\n", bpp);
+		return 0;
     }
 }
 #else
@@ -66,7 +68,8 @@  pixel_to_pat( u32 bpp, u32 pixel)
 	case 32:
 		return 0x00000001ul*pixel;
 	default:
-		panic("pixel_to_pat(): unsupported pixelformat\n");
+		WARN(1, "pixel_to_pat(): unsupported pixelformat %d\n", bpp);
+		return 0;
     }
 }
 #endif