diff mbox

[4/6] drm: nouveau: use crtc helper drm_crtc_from_index()

Message ID 1483961145-18453-5-git-send-email-shawnguo@kernel.org
State New
Headers show

Commit Message

Shawn Guo Jan. 9, 2017, 11:25 a.m. UTC
From: Shawn Guo <shawn.guo@linaro.org>

Use drm_crtc_from_index() to find drm_crtc for given index.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Cc: Ben Skeggs <bskeggs@redhat.com>
---
 drivers/gpu/drm/nouveau/nouveau_display.c | 33 +++++++++++++++++--------------
 1 file changed, 18 insertions(+), 15 deletions(-)

Comments

Sean Paul Jan. 18, 2017, 3:07 p.m. UTC | #1
On Mon, Jan 9, 2017 at 6:25 AM, Shawn Guo <shawnguo@kernel.org> wrote:
> From: Shawn Guo <shawn.guo@linaro.org>
>
> Use drm_crtc_from_index() to find drm_crtc for given index.
>
> Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
> Cc: Ben Skeggs <bskeggs@redhat.com>


Applied to drm-misc-next

Thanks!

Sean

> ---
>  drivers/gpu/drm/nouveau/nouveau_display.c | 33 +++++++++++++++++--------------
>  1 file changed, 18 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/gpu/drm/nouveau/nouveau_display.c b/drivers/gpu/drm/nouveau/nouveau_display.c
> index cef08da1da4e..a0e7221d6568 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_display.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_display.c
> @@ -58,27 +58,30 @@
>  nouveau_display_vblank_enable(struct drm_device *dev, unsigned int pipe)
>  {
>         struct drm_crtc *crtc;
> -       list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
> -               struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
> -               if (nv_crtc->index == pipe) {
> -                       nvif_notify_get(&nv_crtc->vblank);
> -                       return 0;
> -               }
> -       }
> -       return -EINVAL;
> +       struct nouveau_crtc *nv_crtc;
> +
> +       crtc = drm_crtc_from_index(dev, pipe);
> +       if (!crtc)
> +               return -EINVAL;
> +
> +       nv_crtc = nouveau_crtc(crtc);
> +       nvif_notify_get(&nv_crtc->vblank);
> +
> +       return 0;
>  }
>
>  void
>  nouveau_display_vblank_disable(struct drm_device *dev, unsigned int pipe)
>  {
>         struct drm_crtc *crtc;
> -       list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
> -               struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
> -               if (nv_crtc->index == pipe) {
> -                       nvif_notify_put(&nv_crtc->vblank);
> -                       return;
> -               }
> -       }
> +       struct nouveau_crtc *nv_crtc;
> +
> +       crtc = drm_crtc_from_index(dev, pipe);
> +       if (!crtc)
> +               return;
> +
> +       nv_crtc = nouveau_crtc(crtc);
> +       nvif_notify_put(&nv_crtc->vblank);
>  }
>
>  static inline int
> --
> 1.9.1
>
diff mbox

Patch

diff --git a/drivers/gpu/drm/nouveau/nouveau_display.c b/drivers/gpu/drm/nouveau/nouveau_display.c
index cef08da1da4e..a0e7221d6568 100644
--- a/drivers/gpu/drm/nouveau/nouveau_display.c
+++ b/drivers/gpu/drm/nouveau/nouveau_display.c
@@ -58,27 +58,30 @@ 
 nouveau_display_vblank_enable(struct drm_device *dev, unsigned int pipe)
 {
 	struct drm_crtc *crtc;
-	list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
-		struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
-		if (nv_crtc->index == pipe) {
-			nvif_notify_get(&nv_crtc->vblank);
-			return 0;
-		}
-	}
-	return -EINVAL;
+	struct nouveau_crtc *nv_crtc;
+
+	crtc = drm_crtc_from_index(dev, pipe);
+	if (!crtc)
+		return -EINVAL;
+
+	nv_crtc = nouveau_crtc(crtc);
+	nvif_notify_get(&nv_crtc->vblank);
+
+	return 0;
 }
 
 void
 nouveau_display_vblank_disable(struct drm_device *dev, unsigned int pipe)
 {
 	struct drm_crtc *crtc;
-	list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
-		struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
-		if (nv_crtc->index == pipe) {
-			nvif_notify_put(&nv_crtc->vblank);
-			return;
-		}
-	}
+	struct nouveau_crtc *nv_crtc;
+
+	crtc = drm_crtc_from_index(dev, pipe);
+	if (!crtc)
+		return;
+
+	nv_crtc = nouveau_crtc(crtc);
+	nvif_notify_put(&nv_crtc->vblank);
 }
 
 static inline int