drm: Add modeset object iterators
And roll them out across drm_* files. The point here isn't code prettification (it helps with that too) but that some of these lists aren't static any more. And having macros will gives us a convenient place to put locking checks into. I didn't add an iterator for props since that's only used by a list_for_each_entry_safe in the driver teardown code. Search&replace was done with the below cocci spatch. Note that there's a bunch more places that didn't match and which would need some manual changes, but I've intentially left these out for this mostly automated patch. iterator name drm_for_each_crtc; struct drm_crtc *crtc; struct drm_device *dev; expression head; @@ - list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { + drm_for_each_crtc (crtc, dev) { ... } @@ iterator name drm_for_each_encoder; struct drm_encoder *encoder; struct drm_device *dev; expression head; @@ - list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) { + drm_for_each_encoder (encoder, dev) { ... } @@ iterator name drm_for_each_fb; struct drm_framebuffer *fb; struct drm_device *dev; expression head; @@ - list_for_each_entry(fb, &dev->mode_config.fb_list, head) { + drm_for_each_fb (fb, dev) { ... } @@ iterator name drm_for_each_connector; struct drm_connector *connector; struct drm_device *dev; expression head; @@ - list_for_each_entry(connector, &dev->mode_config.connector_list, head) { + drm_for_each_connector (connector, dev) { ... } Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
This commit is contained in:
@@ -615,7 +615,7 @@ void drm_framebuffer_remove(struct drm_framebuffer *fb)
|
||||
if (atomic_read(&fb->refcount.refcount) > 1) {
|
||||
drm_modeset_lock_all(dev);
|
||||
/* remove from any CRTC */
|
||||
list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
|
||||
drm_for_each_crtc(crtc, dev) {
|
||||
if (crtc->primary->fb == fb) {
|
||||
/* should turn off the crtc */
|
||||
memset(&set, 0, sizeof(struct drm_mode_set));
|
||||
@@ -627,7 +627,7 @@ void drm_framebuffer_remove(struct drm_framebuffer *fb)
|
||||
}
|
||||
}
|
||||
|
||||
list_for_each_entry(plane, &dev->mode_config.plane_list, head) {
|
||||
drm_for_each_plane(plane, dev) {
|
||||
if (plane->fb == fb)
|
||||
drm_plane_force_disable(plane);
|
||||
}
|
||||
@@ -1305,7 +1305,7 @@ drm_plane_from_index(struct drm_device *dev, int idx)
|
||||
struct drm_plane *plane;
|
||||
unsigned int i = 0;
|
||||
|
||||
list_for_each_entry(plane, &dev->mode_config.plane_list, head) {
|
||||
drm_for_each_plane(plane, dev) {
|
||||
if (i == idx)
|
||||
return plane;
|
||||
i++;
|
||||
@@ -1838,8 +1838,7 @@ int drm_mode_getresources(struct drm_device *dev, void *data,
|
||||
copied = 0;
|
||||
crtc_id = (uint32_t __user *)(unsigned long)card_res->crtc_id_ptr;
|
||||
if (!mode_group) {
|
||||
list_for_each_entry(crtc, &dev->mode_config.crtc_list,
|
||||
head) {
|
||||
drm_for_each_crtc(crtc, dev) {
|
||||
DRM_DEBUG_KMS("[CRTC:%d]\n", crtc->base.id);
|
||||
if (put_user(crtc->base.id, crtc_id + copied)) {
|
||||
ret = -EFAULT;
|
||||
@@ -1865,9 +1864,7 @@ int drm_mode_getresources(struct drm_device *dev, void *data,
|
||||
copied = 0;
|
||||
encoder_id = (uint32_t __user *)(unsigned long)card_res->encoder_id_ptr;
|
||||
if (!mode_group) {
|
||||
list_for_each_entry(encoder,
|
||||
&dev->mode_config.encoder_list,
|
||||
head) {
|
||||
drm_for_each_encoder(encoder, dev) {
|
||||
DRM_DEBUG_KMS("[ENCODER:%d:%s]\n", encoder->base.id,
|
||||
encoder->name);
|
||||
if (put_user(encoder->base.id, encoder_id +
|
||||
@@ -1896,9 +1893,7 @@ int drm_mode_getresources(struct drm_device *dev, void *data,
|
||||
copied = 0;
|
||||
connector_id = (uint32_t __user *)(unsigned long)card_res->connector_id_ptr;
|
||||
if (!mode_group) {
|
||||
list_for_each_entry(connector,
|
||||
&dev->mode_config.connector_list,
|
||||
head) {
|
||||
drm_for_each_connector(connector, dev) {
|
||||
DRM_DEBUG_KMS("[CONNECTOR:%d:%s]\n",
|
||||
connector->base.id,
|
||||
connector->name);
|
||||
@@ -2187,7 +2182,7 @@ static struct drm_crtc *drm_encoder_get_crtc(struct drm_encoder *encoder)
|
||||
|
||||
/* For atomic drivers only state objects are synchronously updated and
|
||||
* protected by modeset locks, so check those first. */
|
||||
list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
|
||||
drm_for_each_connector(connector, dev) {
|
||||
if (!connector->state)
|
||||
continue;
|
||||
|
||||
@@ -5393,7 +5388,7 @@ void drm_mode_config_reset(struct drm_device *dev)
|
||||
if (encoder->funcs->reset)
|
||||
encoder->funcs->reset(encoder);
|
||||
|
||||
list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
|
||||
drm_for_each_connector(connector, dev) {
|
||||
connector->status = connector_status_unknown;
|
||||
|
||||
if (connector->funcs->reset)
|
||||
|
Reference in New Issue
Block a user