diff options
Diffstat (limited to 'include/drm/drm_connector.h')
-rw-r--r-- | include/drm/drm_connector.h | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h index a9b95246e26e..0e41a2e184a9 100644 --- a/include/drm/drm_connector.h +++ b/include/drm/drm_connector.h @@ -839,6 +839,11 @@ void drm_mode_put_tile_group(struct drm_device *dev, * @dev: the DRM device * * Iterate over all connectors of @dev. + * + * WARNING: + * + * This iterator is not safe against hotadd/removal of connectors and is + * deprecated. Use drm_for_each_connector_iter() instead. */ #define drm_for_each_connector(connector, dev) \ for (assert_drm_connector_list_read_locked(&(dev)->mode_config), \ @@ -847,4 +852,37 @@ void drm_mode_put_tile_group(struct drm_device *dev, &connector->head != (&(dev)->mode_config.connector_list); \ connector = list_next_entry(connector, head)) +/** + * struct drm_connector_list_iter - connector_list iterator + * + * This iterator tracks state needed to be able to walk the connector_list + * within struct drm_mode_config. Only use together with + * drm_connector_list_iter_get(), drm_connector_list_iter_put() and + * drm_connector_list_iter_next() respectively the convenience macro + * drm_for_each_connector_iter(). + */ +struct drm_connector_list_iter { +/* private: */ + struct drm_device *dev; + struct drm_connector *conn; +}; + +void drm_connector_list_iter_get(struct drm_device *dev, + struct drm_connector_list_iter *iter); +struct drm_connector * +drm_connector_list_iter_next(struct drm_connector_list_iter *iter); +void drm_connector_list_iter_put(struct drm_connector_list_iter *iter); + +/** + * drm_for_each_connector_iter - connector_list iterator macro + * @connector: struct &drm_connector pointer used as cursor + * @iter: struct &drm_connector_list_iter + * + * Note that @connector is only valid within the list body, if you want to use + * @connector after calling drm_connector_list_iter_put() then you need to grab + * your own reference first using drm_connector_reference(). + */ +#define drm_for_each_connector_iter(connector, iter) \ + while ((connector = drm_connector_list_iter_next(iter))) + #endif |