drm: nouveau: use crtc helper drm_crtc_from_index()
authorShawn Guo <shawn.guo@linaro.org>
Mon, 9 Jan 2017 11:25:43 +0000 (19:25 +0800)
committerSean Paul <seanpaul@chromium.org>
Wed, 18 Jan 2017 14:21:06 +0000 (09:21 -0500)
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>
Signed-off-by: Sean Paul <seanpaul@chromium.org>
Link: http://patchwork.freedesktop.org/patch/msgid/1483961145-18453-5-git-send-email-shawnguo@kernel.org
drivers/gpu/drm/nouveau/nouveau_display.c

index add353e230f48e5423817025d139839f455a34e9..6b570079d1854475d94ef81059884f9fe92c9b1c 100644 (file)
@@ -58,27 +58,30 @@ int
 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