diff mbox

[2/8] drm/rockchip: use drm_for_each_connector_iter()

Message ID 20170511191049.28944-3-gustavo@padovan.org (mailing list archive)
State New, archived
Headers show

Commit Message

Gustavo Padovan May 11, 2017, 7:10 p.m. UTC
From: Gustavo Padovan <gustavo.padovan@collabora.com>

Drop legacy drm_for_each_connector() in favor of the race-free
drm_for_each_connector_iter()

Cc: Mark Yao <mark.yao@rock-chips.com>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.com>

---
only built-tested!
---
 drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Comments

Daniel Vetter May 12, 2017, 7:38 a.m. UTC | #1
On Thu, May 11, 2017 at 04:10:43PM -0300, Gustavo Padovan wrote:
> From: Gustavo Padovan <gustavo.padovan@collabora.com>
> 
> Drop legacy drm_for_each_connector() in favor of the race-free
> drm_for_each_connector_iter()
> 
> Cc: Mark Yao <mark.yao@rock-chips.com>
> Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.com>
> 
> ---
> only built-tested!

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>

> ---
>  drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
> index 40a5e6e..4f042ab 100644
> --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
> @@ -1118,16 +1118,16 @@ static void vop_crtc_destroy_state(struct drm_crtc *crtc,
>  #ifdef CONFIG_DRM_ANALOGIX_DP
>  static struct drm_connector *vop_get_edp_connector(struct vop *vop)
>  {
> -	struct drm_crtc *crtc = &vop->crtc;
>  	struct drm_connector *connector;
> +	struct drm_connector_list_iter conn_iter;
>  
> -	mutex_lock(&crtc->dev->mode_config.mutex);
> -	drm_for_each_connector(connector, crtc->dev)
> +	drm_connector_list_iter_begin(vop->drm_dev, &conn_iter);
> +	drm_for_each_connector_iter(connector, &conn_iter) {
>  		if (connector->connector_type == DRM_MODE_CONNECTOR_eDP) {
> -			mutex_unlock(&crtc->dev->mode_config.mutex);
> +			drm_connector_list_iter_end(&conn_iter);
>  			return connector;
>  		}
> -	mutex_unlock(&crtc->dev->mode_config.mutex);
> +	drm_connector_list_iter_end(&conn_iter);
>  
>  	return NULL;
>  }
> -- 
> 2.9.3
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
Sean Paul May 12, 2017, 9:59 p.m. UTC | #2
On Thu, May 11, 2017 at 04:10:43PM -0300, Gustavo Padovan wrote:
> From: Gustavo Padovan <gustavo.padovan@collabora.com>
> 
> Drop legacy drm_for_each_connector() in favor of the race-free
> drm_for_each_connector_iter()
> 
> Cc: Mark Yao <mark.yao@rock-chips.com>
> Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.com>
> 
> ---
> only built-tested!
> ---
>  drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
> index 40a5e6e..4f042ab 100644
> --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
> @@ -1118,16 +1118,16 @@ static void vop_crtc_destroy_state(struct drm_crtc *crtc,
>  #ifdef CONFIG_DRM_ANALOGIX_DP
>  static struct drm_connector *vop_get_edp_connector(struct vop *vop)
>  {
> -	struct drm_crtc *crtc = &vop->crtc;
>  	struct drm_connector *connector;
> +	struct drm_connector_list_iter conn_iter;
>  
> -	mutex_lock(&crtc->dev->mode_config.mutex);
> -	drm_for_each_connector(connector, crtc->dev)
> +	drm_connector_list_iter_begin(vop->drm_dev, &conn_iter);
> +	drm_for_each_connector_iter(connector, &conn_iter) {

Unmatched brace here. This code is protected by CONFIG_DRM_ANALOGIX_DP, so I'm
guessing that's why your build test didn't pick it up.

Sean

>  		if (connector->connector_type == DRM_MODE_CONNECTOR_eDP) {
> -			mutex_unlock(&crtc->dev->mode_config.mutex);
> +			drm_connector_list_iter_end(&conn_iter);
>  			return connector;
>  		}
> -	mutex_unlock(&crtc->dev->mode_config.mutex);
> +	drm_connector_list_iter_end(&conn_iter);
>  
>  	return NULL;
>  }
> -- 
> 2.9.3
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
diff mbox

Patch

diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
index 40a5e6e..4f042ab 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
@@ -1118,16 +1118,16 @@  static void vop_crtc_destroy_state(struct drm_crtc *crtc,
 #ifdef CONFIG_DRM_ANALOGIX_DP
 static struct drm_connector *vop_get_edp_connector(struct vop *vop)
 {
-	struct drm_crtc *crtc = &vop->crtc;
 	struct drm_connector *connector;
+	struct drm_connector_list_iter conn_iter;
 
-	mutex_lock(&crtc->dev->mode_config.mutex);
-	drm_for_each_connector(connector, crtc->dev)
+	drm_connector_list_iter_begin(vop->drm_dev, &conn_iter);
+	drm_for_each_connector_iter(connector, &conn_iter) {
 		if (connector->connector_type == DRM_MODE_CONNECTOR_eDP) {
-			mutex_unlock(&crtc->dev->mode_config.mutex);
+			drm_connector_list_iter_end(&conn_iter);
 			return connector;
 		}
-	mutex_unlock(&crtc->dev->mode_config.mutex);
+	drm_connector_list_iter_end(&conn_iter);
 
 	return NULL;
 }