All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jani Nikula <jani.nikula@intel.com>
To: dri-devel@lists.freedesktop.org
Cc: jani.nikula@intel.com, intel-gfx@lists.freedesktop.org
Subject: [PATCH v2 1/2] drm: support feature masks in drm_core_check_feature()
Date: Wed, 22 Jan 2020 16:02:58 +0200	[thread overview]
Message-ID: <20200122140259.12086-1-jani.nikula@intel.com> (raw)

Allow a mask of features to be passed to drm_core_check_feature(). All
features in the mask are required.

v2:
- fix kernel-doc (Ville)
- add an extra variable for clarity (Ville)

Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 include/drm/drm_drv.h | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h
index cf13470810a5..f18e19f3f2d0 100644
--- a/include/drm/drm_drv.h
+++ b/include/drm/drm_drv.h
@@ -826,16 +826,20 @@ 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
+ * @features: 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 @features 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;
+	u32 supported = dev->driver->driver_features & dev->driver_features;
+
+	return features && (supported & features) == features;
 }
 
 /**
-- 
2.20.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

WARNING: multiple messages have this Message-ID (diff)
From: Jani Nikula <jani.nikula@intel.com>
To: dri-devel@lists.freedesktop.org
Cc: jani.nikula@intel.com, intel-gfx@lists.freedesktop.org
Subject: [Intel-gfx] [PATCH v2 1/2] drm: support feature masks in drm_core_check_feature()
Date: Wed, 22 Jan 2020 16:02:58 +0200	[thread overview]
Message-ID: <20200122140259.12086-1-jani.nikula@intel.com> (raw)

Allow a mask of features to be passed to drm_core_check_feature(). All
features in the mask are required.

v2:
- fix kernel-doc (Ville)
- add an extra variable for clarity (Ville)

Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 include/drm/drm_drv.h | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h
index cf13470810a5..f18e19f3f2d0 100644
--- a/include/drm/drm_drv.h
+++ b/include/drm/drm_drv.h
@@ -826,16 +826,20 @@ 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
+ * @features: 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 @features 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;
+	u32 supported = dev->driver->driver_features & dev->driver_features;
+
+	return features && (supported & features) == features;
 }
 
 /**
-- 
2.20.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

             reply	other threads:[~2020-01-22 14:03 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-22 14:02 Jani Nikula [this message]
2020-01-22 14:02 ` [Intel-gfx] [PATCH v2 1/2] drm: support feature masks in drm_core_check_feature() Jani Nikula
2020-01-22 14:02 ` [PATCH v2 2/2] drm/debugfs: also take per device driver features into account Jani Nikula
2020-01-22 14:02   ` [Intel-gfx] " Jani Nikula
2020-01-22 14:16 ` [PATCH v2 1/2] drm: support feature masks in drm_core_check_feature() Thomas Zimmermann
2020-01-22 14:16   ` [Intel-gfx] " Thomas Zimmermann
2020-01-22 14:27   ` Jani Nikula
2020-01-22 14:27     ` [Intel-gfx] " Jani Nikula
2020-01-22 15:31     ` Thomas Zimmermann
2020-01-22 15:31       ` [Intel-gfx] " Thomas Zimmermann
2020-01-22 21:12 ` [Intel-gfx] ✗ Fi.CI.BAT: failure for series starting with [v2,1/2] " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200122140259.12086-1-jani.nikula@intel.com \
    --to=jani.nikula@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.