diff mbox series

[1/2] drm: support feature masks in drm_core_check_feature()

Message ID 20200121105331.6825-1-jani.nikula@intel.com (mailing list archive)
State New, archived
Headers show
Series [1/2] drm: support feature masks in drm_core_check_feature() | expand

Commit Message

Jani Nikula Jan. 21, 2020, 10:53 a.m. UTC
Allow a mask of features to be passed to drm_core_check_feature(). All
features in the mask are required.

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 include/drm/drm_drv.h | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

Comments

Ville Syrjälä Jan. 21, 2020, 2:26 p.m. UTC | #1
On Tue, Jan 21, 2020 at 12:53:30PM +0200, Jani Nikula wrote:
> Allow a mask of features to be passed to drm_core_check_feature(). All
> features in the mask are required.
> 
> Signed-off-by: Jani Nikula <jani.nikula@intel.com>
> ---
>  include/drm/drm_drv.h | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h
> index cf13470810a5..51b486d1ee81 100644
> --- a/include/drm/drm_drv.h
> +++ b/include/drm/drm_drv.h
> @@ -826,16 +826,18 @@ static inline bool drm_dev_is_unplugged(struct drm_device *dev)
>  /**
>   * drm_core_check_feature - check driver feature flags
>   * @dev: DRM device to check
> - * @feature: feature flag
> + * @feature: feature flag(s)
              ^
missing 's'

>   *
>   * This checks @dev for driver features, see &drm_driver.driver_features,
>   * &drm_device.driver_features, and the various &enum drm_driver_feature flags.
>   *
> - * Returns true if the @feature is supported, false otherwise.
> + * Returns true if all features in the @feature mask are supported, false

same here

> + * otherwise.
>   */
> -static inline bool drm_core_check_feature(const struct drm_device *dev, u32 feature)
> +static inline bool drm_core_check_feature(const struct drm_device *dev, u32 features)
>  {
> -	return dev->driver->driver_features & dev->driver_features & feature;
> +	return features && (dev->driver->driver_features & dev->driver_features &
> +			    features) == features;

Could maybe do with an extra variable?

u32 supported = driver->driver_features & dev->driver_features;
return features && (features & supported) == features;

Series is
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

>  }
>  
>  /**
> -- 
> 2.20.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
diff mbox series

Patch

diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h
index cf13470810a5..51b486d1ee81 100644
--- a/include/drm/drm_drv.h
+++ b/include/drm/drm_drv.h
@@ -826,16 +826,18 @@  static inline bool drm_dev_is_unplugged(struct drm_device *dev)
 /**
  * drm_core_check_feature - check driver feature flags
  * @dev: DRM device to check
- * @feature: feature flag
+ * @feature: feature flag(s)
  *
  * This checks @dev for driver features, see &drm_driver.driver_features,
  * &drm_device.driver_features, and the various &enum drm_driver_feature flags.
  *
- * Returns true if the @feature is supported, false otherwise.
+ * Returns true if all features in the @feature mask are supported, false
+ * otherwise.
  */
-static inline bool drm_core_check_feature(const struct drm_device *dev, u32 feature)
+static inline bool drm_core_check_feature(const struct drm_device *dev, u32 features)
 {
-	return dev->driver->driver_features & dev->driver_features & feature;
+	return features && (dev->driver->driver_features & dev->driver_features &
+			    features) == features;
 }
 
 /**