Define a conditional drm_dev_access guard to automate the drm_dev_{enter,exit}() sequence.
Signed-off-by: Boris Brezillon boris.brezillon@collabora.com --- include/drm/drm_drv.h | 9 +++++++++ 1 file changed, 9 insertions(+)
diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h index 42fc085f986d..79d1958f93e4 100644 --- a/include/drm/drm_drv.h +++ b/include/drm/drm_drv.h @@ -490,6 +490,15 @@ void drm_dev_unplug(struct drm_device *dev); int drm_dev_wedged_event(struct drm_device *dev, unsigned long method, struct drm_wedge_task_info *info);
+/* + * Only the conditional drm_dev_access guard is valid. The drm_dev one is + * here so we can extend it with a conditional variant. + */ +DEFINE_LOCK_GUARD_1(drm_dev, struct drm_device, + { WARN_ON("Use cond guards"); _T->idx = -1; }, + drm_dev_exit(_T->idx), int idx); +DEFINE_LOCK_GUARD_1_COND(drm_dev, _access, drm_dev_enter(_T->lock, &_T->idx)); + /** * drm_dev_is_unplugged - is a DRM device unplugged * @dev: DRM device