[PATCH 09/13] drm/irq: Make pipe unsigned and name consistent

2014-12-16 Thread Thierry Reding
From: Thierry Reding tred...@nvidia.com

Name all references to the pipe number (CRTC index) consistently to make
it easier to distinguish which is a pipe number and which is a pointer
to struct drm_crtc.

While at it also make all references to the pipe number unsigned because
there is no longer any reason why it should ever be negative.

Signed-off-by: Thierry Reding tred...@nvidia.com
---
 drivers/gpu/drm/drm_irq.c | 319 +++---
 include/drm/drmP.h|  34 ++---
 2 files changed, 179 insertions(+), 174 deletions(-)

diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index cb207e047505..9c32a1d7aec2 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -43,8 +43,8 @@
 #include linux/export.h
 
 /* Access macro for slots in vblank timestamp ringbuffer. */
-#define vblanktimestamp(dev, crtc, count) \
-   ((dev)-vblank[crtc].time[(count) % DRM_VBLANKTIME_RBSIZE])
+#define vblanktimestamp(dev, pipe, count) \
+   ((dev)-vblank[pipe].time[(count) % DRM_VBLANKTIME_RBSIZE])
 
 /* Retry timestamp calculation up to 3 times to satisfy
  * drm_timestamp_precision before giving up.
@@ -57,7 +57,7 @@
 #define DRM_REDUNDANT_VBLIRQ_THRESH_NS 100
 
 static bool
-drm_get_last_vbltimestamp(struct drm_device *dev, int crtc,
+drm_get_last_vbltimestamp(struct drm_device *dev, unsigned int pipe,
  struct timeval *tvblank, unsigned flags);
 
 static unsigned int drm_timestamp_precision = 20;  /* Default to 20 usecs. */
@@ -77,7 +77,7 @@ module_param_named(timestamp_monotonic, 
drm_timestamp_monotonic, int, 0600);
 /**
  * drm_update_vblank_count - update the master vblank counter
  * @dev: DRM device
- * @crtc: counter to update
+ * @pipe: counter to update
  *
  * Call back into the driver to update the appropriate vblank counter
  * (specified by @crtc).  Deal with wraparound, if it occurred, and
@@ -90,9 +90,9 @@ module_param_named(timestamp_monotonic, 
drm_timestamp_monotonic, int, 0600);
  * Note: caller must hold dev-vbl_lock since this reads  writes
  * device vblank fields.
  */
-static void drm_update_vblank_count(struct drm_device *dev, int crtc)
+static void drm_update_vblank_count(struct drm_device *dev, unsigned int pipe)
 {
-   struct drm_vblank_crtc *vblank = dev-vblank[crtc];
+   struct drm_vblank_crtc *vblank = dev-vblank[pipe];
u32 cur_vblank, diff, tslot;
bool rc;
struct timeval t_vblank;
@@ -110,21 +110,21 @@ static void drm_update_vblank_count(struct drm_device 
*dev, int crtc)
 * corresponding vblank timestamp.
 */
do {
-   cur_vblank = dev-driver-get_vblank_counter(dev, crtc);
-   rc = drm_get_last_vbltimestamp(dev, crtc, t_vblank, 0);
-   } while (cur_vblank != dev-driver-get_vblank_counter(dev, crtc));
+   cur_vblank = dev-driver-get_vblank_counter(dev, pipe);
+   rc = drm_get_last_vbltimestamp(dev, pipe, t_vblank, 0);
+   } while (cur_vblank != dev-driver-get_vblank_counter(dev, pipe));
 
/* Deal with counter wrap */
diff = cur_vblank - vblank-last;
if (cur_vblank  vblank-last) {
diff += dev-max_vblank_count;
 
-   DRM_DEBUG(last_vblank[%d]=0x%x, cur_vblank=0x%x = 
diff=0x%x\n,
- crtc, vblank-last, cur_vblank, diff);
+   DRM_DEBUG(last_vblank[%u]=0x%x, cur_vblank=0x%x = 
diff=0x%x\n,
+ pipe, vblank-last, cur_vblank, diff);
}
 
-   DRM_DEBUG(updating vblank count on crtc %d, missed %d\n,
- crtc, diff);
+   DRM_DEBUG(updating vblank count on crtc %u, missed %d\n,
+ pipe, diff);
 
if (diff == 0)
return;
@@ -135,7 +135,7 @@ static void drm_update_vblank_count(struct drm_device *dev, 
int crtc)
 */
if (rc) {
tslot = atomic_read(vblank-count) + diff;
-   vblanktimestamp(dev, crtc, tslot) = t_vblank;
+   vblanktimestamp(dev, pipe, tslot) = t_vblank;
}
 
smp_mb__before_atomic();
@@ -149,9 +149,9 @@ static void drm_update_vblank_count(struct drm_device *dev, 
int crtc)
  * are preserved, even if there are any spurious vblank irq's after
  * disable.
  */
-static void vblank_disable_and_save(struct drm_device *dev, int crtc)
+static void vblank_disable_and_save(struct drm_device *dev, unsigned int pipe)
 {
-   struct drm_vblank_crtc *vblank = dev-vblank[crtc];
+   struct drm_vblank_crtc *vblank = dev-vblank[pipe];
unsigned long irqflags;
u32 vblcount;
s64 diff_ns;
@@ -179,13 +179,13 @@ static void vblank_disable_and_save(struct drm_device 
*dev, int crtc)
 * vblank interrupt is disabled.
 */
if (!vblank-enabled 
-   drm_get_last_vbltimestamp(dev, crtc, tvblank, 0)) {
-   drm_update_vblank_count(dev, crtc);
+   drm_get_last_vbltimestamp(dev, pipe, 

Re: [PATCH 09/13] drm/irq: Make pipe unsigned and name consistent

2014-12-16 Thread Daniel Vetter
On Tue, Dec 16, 2014 at 05:53:31PM +0100, Thierry Reding wrote:
 -void drm_wait_one_vblank(struct drm_device *dev, int crtc)
 +void drm_wait_one_vblank(struct drm_device *dev, unsigned int pipe)
  {
 + struct drm_vblank_crtc *vblank = dev-vblank[pipe];
   int ret;
   u32 last;
  
 - ret = drm_vblank_get(dev, crtc);
 - if (WARN(ret, vblank not available on crtc %i, ret=%i\n, crtc, ret))
 + if (WARN_ON(pipe = dev-num_crtcs))

This addition should be in the previous patch. I didn't spot anything else
but it's a bit a tedious patch. But makes sense.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
--
To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html