Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 70e1e0ec authored by Damien Lespiau's avatar Damien Lespiau Committed by Daniel Vetter
Browse files

drm/i915: Use for_each_crtc() when iterating through the CRTCs



Patch done using the following semantic patch (thanks Daniel for the
help!)

  @@
  iterator name list_for_each_entry;
  iterator name for_each_crtc;
  struct drm_crtc * crtc;
  struct drm_device * dev;
  @@
  -list_for_each_entry(crtc,&dev->mode_config.crtc_list, head) {
  +for_each_crtc(dev,crtc) {
  	...
  }

Followed by a couple of fixups by hand (that spatch doesn't match the
cases where list_for_each_entry() is not followed by a set of '{', '}',
but I couldn't figure out a way to leave the '{' out of the iterator
match).

Signed-off-by: default avatarDamien Lespiau <damien.lespiau@intel.com>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
parent d79b814d
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -486,7 +486,7 @@ static int i915_drm_freeze(struct drm_device *dev)
		 * for _thaw.
		 * for _thaw.
		 */
		 */
		mutex_lock(&dev->mode_config.mutex);
		mutex_lock(&dev->mode_config.mutex);
		list_for_each_entry(crtc, &dev->mode_config.crtc_list, head)
		for_each_crtc(dev, crtc)
			dev_priv->display.crtc_disable(crtc);
			dev_priv->display.crtc_disable(crtc);
		mutex_unlock(&dev->mode_config.mutex);
		mutex_unlock(&dev->mode_config.mutex);


+9 −9
Original line number Original line Diff line number Diff line
@@ -2312,7 +2312,7 @@ static void intel_find_plane_obj(struct intel_crtc *intel_crtc,
	 * Failed to alloc the obj, check to see if we should share
	 * Failed to alloc the obj, check to see if we should share
	 * an fb with another CRTC instead
	 * an fb with another CRTC instead
	 */
	 */
	list_for_each_entry(c, &dev->mode_config.crtc_list, head) {
	for_each_crtc(dev, c) {
		i = to_intel_crtc(c);
		i = to_intel_crtc(c);


		if (c == &intel_crtc->base)
		if (c == &intel_crtc->base)
@@ -2540,7 +2540,7 @@ void intel_display_handle_reset(struct drm_device *dev)
	 * pending_flip_queue really got woken up.
	 * pending_flip_queue really got woken up.
	 */
	 */


	list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
	for_each_crtc(dev, crtc) {
		struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
		struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
		enum plane plane = intel_crtc->plane;
		enum plane plane = intel_crtc->plane;


@@ -2548,7 +2548,7 @@ void intel_display_handle_reset(struct drm_device *dev)
		intel_finish_page_flip_plane(dev, plane);
		intel_finish_page_flip_plane(dev, plane);
	}
	}


	list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
	for_each_crtc(dev, crtc) {
		struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
		struct intel_crtc *intel_crtc = to_intel_crtc(crtc);


		mutex_lock(&crtc->mutex);
		mutex_lock(&crtc->mutex);
@@ -8298,7 +8298,7 @@ bool intel_get_load_detect_pipe(struct drm_connector *connector,
	}
	}


	/* Find an unused one (if possible) */
	/* Find an unused one (if possible) */
	list_for_each_entry(possible_crtc, &dev->mode_config.crtc_list, head) {
	for_each_crtc(dev, possible_crtc) {
		i++;
		i++;
		if (!(encoder->possible_crtcs & (1 << i)))
		if (!(encoder->possible_crtcs & (1 << i)))
			continue;
			continue;
@@ -8689,7 +8689,7 @@ void intel_mark_idle(struct drm_device *dev)
	if (!i915.powersave)
	if (!i915.powersave)
		goto out;
		goto out;


	list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
	for_each_crtc(dev, crtc) {
		if (!crtc->primary->fb)
		if (!crtc->primary->fb)
			continue;
			continue;


@@ -8712,7 +8712,7 @@ void intel_mark_fb_busy(struct drm_i915_gem_object *obj,
	if (!i915.powersave)
	if (!i915.powersave)
		return;
		return;


	list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
	for_each_crtc(dev, crtc) {
		if (!crtc->primary->fb)
		if (!crtc->primary->fb)
			continue;
			continue;


@@ -10336,7 +10336,7 @@ static int intel_set_config_save_state(struct drm_device *dev,
	 * restored, not the drivers personal bookkeeping.
	 * restored, not the drivers personal bookkeeping.
	 */
	 */
	count = 0;
	count = 0;
	list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
	for_each_crtc(dev, crtc) {
		config->save_crtc_enabled[count++] = crtc->enabled;
		config->save_crtc_enabled[count++] = crtc->enabled;
	}
	}


@@ -12045,7 +12045,7 @@ void intel_modeset_gem_init(struct drm_device *dev)
	 * for this.
	 * for this.
	 */
	 */
	mutex_lock(&dev->struct_mutex);
	mutex_lock(&dev->struct_mutex);
	list_for_each_entry(c, &dev->mode_config.crtc_list, head) {
	for_each_crtc(dev, c) {
		if (!c->primary->fb)
		if (!c->primary->fb)
			continue;
			continue;


@@ -12091,7 +12091,7 @@ void intel_modeset_cleanup(struct drm_device *dev)


	intel_unregister_dsm_handler();
	intel_unregister_dsm_handler();


	list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
	for_each_crtc(dev, crtc) {
		/* Skip inactive CRTCs */
		/* Skip inactive CRTCs */
		if (!crtc->primary->fb)
		if (!crtc->primary->fb)
			continue;
			continue;
+3 −3
Original line number Original line Diff line number Diff line
@@ -488,7 +488,7 @@ static bool intel_fbdev_init_bios(struct drm_device *dev,
		return false;
		return false;


	/* Find the largest fb */
	/* Find the largest fb */
	list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
	for_each_crtc(dev, crtc) {
		intel_crtc = to_intel_crtc(crtc);
		intel_crtc = to_intel_crtc(crtc);


		if (!intel_crtc->active || !crtc->primary->fb) {
		if (!intel_crtc->active || !crtc->primary->fb) {
@@ -512,7 +512,7 @@ static bool intel_fbdev_init_bios(struct drm_device *dev,
	}
	}


	/* Now make sure all the pipes will fit into it */
	/* Now make sure all the pipes will fit into it */
	list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
	for_each_crtc(dev, crtc) {
		unsigned int cur_size;
		unsigned int cur_size;


		intel_crtc = to_intel_crtc(crtc);
		intel_crtc = to_intel_crtc(crtc);
@@ -577,7 +577,7 @@ static bool intel_fbdev_init_bios(struct drm_device *dev,
	drm_framebuffer_reference(&ifbdev->fb->base);
	drm_framebuffer_reference(&ifbdev->fb->base);


	/* Final pass to check if any active pipes don't have fbs */
	/* Final pass to check if any active pipes don't have fbs */
	list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
	for_each_crtc(dev, crtc) {
		intel_crtc = to_intel_crtc(crtc);
		intel_crtc = to_intel_crtc(crtc);


		if (!intel_crtc->active)
		if (!intel_crtc->active)
+3 −3
Original line number Original line Diff line number Diff line
@@ -487,7 +487,7 @@ void intel_update_fbc(struct drm_device *dev)
	 *   - new fb is too large to fit in compressed buffer
	 *   - new fb is too large to fit in compressed buffer
	 *   - going to an unsupported config (interlace, pixel multiply, etc.)
	 *   - going to an unsupported config (interlace, pixel multiply, etc.)
	 */
	 */
	list_for_each_entry(tmp_crtc, &dev->mode_config.crtc_list, head) {
	for_each_crtc(dev, tmp_crtc) {
		if (intel_crtc_active(tmp_crtc) &&
		if (intel_crtc_active(tmp_crtc) &&
		    to_intel_crtc(tmp_crtc)->primary_enabled) {
		    to_intel_crtc(tmp_crtc)->primary_enabled) {
			if (crtc) {
			if (crtc) {
@@ -1010,7 +1010,7 @@ static struct drm_crtc *single_enabled_crtc(struct drm_device *dev)
{
{
	struct drm_crtc *crtc, *enabled = NULL;
	struct drm_crtc *crtc, *enabled = NULL;


	list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
	for_each_crtc(dev, crtc) {
		if (intel_crtc_active(crtc)) {
		if (intel_crtc_active(crtc)) {
			if (enabled)
			if (enabled)
				return NULL;
				return NULL;
@@ -2747,7 +2747,7 @@ void ilk_wm_get_hw_state(struct drm_device *dev)
	struct ilk_wm_values *hw = &dev_priv->wm.hw;
	struct ilk_wm_values *hw = &dev_priv->wm.hw;
	struct drm_crtc *crtc;
	struct drm_crtc *crtc;


	list_for_each_entry(crtc, &dev->mode_config.crtc_list, head)
	for_each_crtc(dev, crtc)
		ilk_pipe_wm_get_hw_state(crtc);
		ilk_pipe_wm_get_hw_state(crtc);


	hw->wm_lp[0] = I915_READ(WM1_LP_ILK);
	hw->wm_lp[0] = I915_READ(WM1_LP_ILK);