[PATCH 1/3] drm: Tune up error message during format->bpp/cpp conversion

Imre Deak imre.deak at intel.com
Thu May 12 13:00:38 UTC 2016


Returning a 0 bpp/cpp value from these functions isn't ever valid. In
many cases it can also lead to a div-by-zero possibly at some later
point in time, so make sure we catch such errors as soon as possible via
louder error reporting.

CC: Dave Airlie <airlied at redhat.com>
Signed-off-by: Imre Deak <imre.deak at intel.com>
---
 drivers/gpu/drm/drm_crtc.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index 70f9c68..3a32606 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -5610,8 +5610,8 @@ void drm_fb_get_bpp_depth(uint32_t format, unsigned int *depth,
 		*bpp = 32;
 		break;
 	default:
-		DRM_DEBUG_KMS("unsupported pixel format %s\n",
-			      drm_get_format_name(format));
+		WARN(1, "unsupported pixel format %s\n",
+		     drm_get_format_name(format));
 		*depth = 0;
 		*bpp = 0;
 		break;
@@ -5666,8 +5666,12 @@ int drm_format_plane_cpp(uint32_t format, int plane)
 	unsigned int depth;
 	int bpp;
 
-	if (plane >= drm_format_num_planes(format))
+	if (plane >= drm_format_num_planes(format)) {
+		WARN(1, "invalid plane %d for format %s\n",
+		     plane, drm_get_format_name(format));
+
 		return 0;
+	}
 
 	switch (format) {
 	case DRM_FORMAT_YUYV:
-- 
2.5.0



More information about the dri-devel mailing list