diff mbox

[2/6] drm: WARN when trying add enum values to non-enum/bitmask properties

Message ID 20180306164849.2862-2-ville.syrjala@linux.intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Ville Syrjala March 6, 2018, 4:48 p.m. UTC
From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Trying to add enum values to non-enum/bitmask properties is a
programmer mistake. WARN to make sure the developers notice
their mistake.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/drm_property.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Daniel Vetter March 6, 2018, 6:16 p.m. UTC | #1
On Tue, Mar 06, 2018 at 06:48:45PM +0200, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> Trying to add enum values to non-enum/bitmask properties is a
> programmer mistake. WARN to make sure the developers notice
> their mistake.
> 
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> ---
>  drivers/gpu/drm/drm_property.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_property.c b/drivers/gpu/drm/drm_property.c
> index d77b0c4dc485..e676b1ecc705 100644
> --- a/drivers/gpu/drm/drm_property.c
> +++ b/drivers/gpu/drm/drm_property.c
> @@ -378,8 +378,8 @@ int drm_property_add_enum(struct drm_property *property, int index,
>  	if (WARN_ON(strlen(name) >= DRM_PROP_NAME_LEN))
>  		return -EINVAL;
>  
> -	if (!(drm_property_type_is(property, DRM_MODE_PROP_ENUM) ||
> -			drm_property_type_is(property, DRM_MODE_PROP_BITMASK)))
> +	if (WARN_ON(!drm_property_type_is(property, DRM_MODE_PROP_ENUM) &&
> +		    !drm_property_type_is(property, DRM_MODE_PROP_BITMASK)))
>  		return -EINVAL;
>  
>  	/*
> -- 
> 2.16.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
diff mbox

Patch

diff --git a/drivers/gpu/drm/drm_property.c b/drivers/gpu/drm/drm_property.c
index d77b0c4dc485..e676b1ecc705 100644
--- a/drivers/gpu/drm/drm_property.c
+++ b/drivers/gpu/drm/drm_property.c
@@ -378,8 +378,8 @@  int drm_property_add_enum(struct drm_property *property, int index,
 	if (WARN_ON(strlen(name) >= DRM_PROP_NAME_LEN))
 		return -EINVAL;
 
-	if (!(drm_property_type_is(property, DRM_MODE_PROP_ENUM) ||
-			drm_property_type_is(property, DRM_MODE_PROP_BITMASK)))
+	if (WARN_ON(!drm_property_type_is(property, DRM_MODE_PROP_ENUM) &&
+		    !drm_property_type_is(property, DRM_MODE_PROP_BITMASK)))
 		return -EINVAL;
 
 	/*