[RFCv1 04/12] drm: add DRM_MODE_PROP_SIGNED property flag

Matt Plumtree mattp at broadcom.com
Mon Oct 7 16:46:30 CEST 2013


> static bool drm_property_change_is_valid(struct drm_property *property,
>  					 uint64_t value)
>  {
> -	if (property->flags & DRM_MODE_PROP_IMMUTABLE)
> +	if (property->flags & DRM_MODE_PROP_IMMUTABLE) {
>  		return false;
> -	if (property->flags & DRM_MODE_PROP_RANGE) {
> +	} else if (property->flags & (DRM_MODE_PROP_RANGE|DRM_MODE_PROP_SIGNED)) {
> +		int64_t svalue = U642I64(value);
> +		if (svalue < U642I64(property->values[0]) ||
> +				svalue > U642I64(property->values[1]))
> +			return false;
> +		return true;
> +	} else if (property->flags & DRM_MODE_PROP_RANGE) {
>		if (value < property->values[0] || value > property->values[1])
>  			return false;
>  		return true;

I don't think this is doing what you think it should. If the flags include
DRM_MODE_PROP_RANGE, the first "else if" will be executed regardless of
whether DRM_MODE_PROP_SIGNED is set or not. This means that the second
"else if" will never be executed.

You'd need to add "== (DRM_MODE_PROP_RANGE|DRM_MODE_PROP_SIGNED)" or
similar.

Matt



More information about the dri-devel mailing list