diff mbox

[RFC,5/7] drm: change the drm vblank callback item type

Message ID 1416426435-2237-7-git-send-email-przanoni@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Paulo Zanoni Nov. 19, 2014, 7:47 p.m. UTC
From: Paulo Zanoni <paulo.r.zanoni@intel.com>

Now that we have created drm_vblank_wait_item, let's use it as the
type passed. In the future, callers will have to use container_of to
find our their original allocated structure, just like we're doing
with the send_vblank_event() callback.

Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
---
 drivers/gpu/drm/drm_irq.c           | 40 ++++++++++++++++++-------------------
 drivers/gpu/drm/i915/i915_debugfs.c |  4 +++-
 include/drm/drmP.h                  |  4 +++-
 3 files changed, 26 insertions(+), 22 deletions(-)
diff mbox

Patch

diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index a82e5ca..4c03240 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -881,10 +881,13 @@  u32 drm_vblank_count_and_time(struct drm_device *dev, int crtc,
 EXPORT_SYMBOL(drm_vblank_count_and_time);
 
 static void send_vblank_event(struct drm_device *dev,
-		struct drm_pending_vblank_event *e,
+		struct drm_vblank_wait_item *item,
 		unsigned long seq, struct timeval *now,
 		bool premature)
 {
+	struct drm_pending_vblank_event *e =
+		container_of(item, struct drm_pending_vblank_event, item);
+
 	WARN_ON_SMP(!spin_is_locked(&dev->event_lock));
 	e->event.sequence = seq;
 	e->event.tv_sec = now->tv_sec;
@@ -919,7 +922,7 @@  void drm_send_vblank_event(struct drm_device *dev, int crtc,
 		now = get_drm_timestamp();
 	}
 	e->item.pipe = crtc;
-	send_vblank_event(dev, e, seq, &now, false);
+	send_vblank_event(dev, &e->item, seq, &now, false);
 }
 EXPORT_SYMBOL(drm_send_vblank_event);
 
@@ -1109,18 +1112,18 @@  void drm_crtc_wait_one_vblank(struct drm_crtc *crtc)
 EXPORT_SYMBOL(drm_crtc_wait_one_vblank);
 
 static void drm_wait_vblank_callback(struct drm_device *dev,
-				     struct drm_pending_vblank_event *e,
+				     struct drm_vblank_wait_item *item,
 				     unsigned long seq, struct timeval *now,
 				     bool premature)
 {
-	if (e->item.callback_from_work) {
-		e->item.callback_args.dev = dev;
-		e->item.callback_args.seq = seq;
-		e->item.callback_args.now = now;
-		e->item.callback_args.premature = premature;
-		schedule_work(&e->item.callback_work);
+	if (item->callback_from_work) {
+		item->callback_args.dev = dev;
+		item->callback_args.seq = seq;
+		item->callback_args.now = now;
+		item->callback_args.premature = premature;
+		schedule_work(&item->callback_work);
 	} else {
-		e->item.callback(dev, e, seq, now, premature);
+		item->callback(dev, item, seq, now, premature);
 	}
 }
 
@@ -1176,7 +1179,7 @@  void drm_vblank_off(struct drm_device *dev, int crtc)
 			  e->item.wanted_seq, seq);
 		list_del(&e->base.link);
 		drm_vblank_put(dev, e->item.pipe);
-		drm_wait_vblank_callback(dev, e, seq, &now, true);
+		drm_wait_vblank_callback(dev, &e->item, seq, &now, true);
 	}
 	spin_unlock_irqrestore(&dev->event_lock, irqflags);
 }
@@ -1390,14 +1393,11 @@  int drm_modeset_ctl(struct drm_device *dev, void *data,
 
 static void drm_vblank_event_work_func(struct work_struct *work)
 {
-	struct drm_pending_vblank_event *e =
-		container_of(work, struct drm_pending_vblank_event,
-			     item.callback_work);
+	struct drm_vblank_wait_item *item =
+		container_of(work, struct drm_vblank_wait_item, callback_work);
 
-	e->item.callback(e->item.callback_args.dev, e,
-			 e->item.callback_args.seq,
-			 e->item.callback_args.now,
-			 e->item.callback_args.premature);
+	item->callback(item->callback_args.dev, item, item->callback_args.seq,
+		       item->callback_args.now, item->callback_args.premature);
 }
 
 static int drm_queue_vblank_event(struct drm_device *dev, int pipe,
@@ -1472,7 +1472,7 @@  static int drm_queue_vblank_event(struct drm_device *dev, int pipe,
 	e->item.wanted_seq = vblwait->request.sequence;
 	if ((seq - vblwait->request.sequence) <= (1 << 23)) {
 		drm_vblank_put(dev, pipe);
-		drm_wait_vblank_callback(dev, e, seq, &now, false);
+		drm_wait_vblank_callback(dev, &e->item, seq, &now, false);
 		vblwait->reply.sequence = seq;
 	} else {
 		/* drm_handle_vblank_events will call drm_vblank_put */
@@ -1654,7 +1654,7 @@  static void drm_handle_vblank_events(struct drm_device *dev, int crtc)
 
 		list_del(&e->base.link);
 		drm_vblank_put(dev, e->item.pipe);
-		drm_wait_vblank_callback(dev, e, seq, &now, false);
+		drm_wait_vblank_callback(dev, &e->item, seq, &now, false);
 	}
 
 	trace_drm_vblank_event(crtc, seq);
diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
index 95cf6d3..b5c3f81 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -2722,10 +2722,12 @@  struct vblank_data {
 };
 
 static void vblank_callback(struct drm_device *dev,
-			    struct drm_pending_vblank_event *e,
+			    struct drm_vblank_wait_item *item,
 			    unsigned long seq, struct timeval *now,
 			    bool premature)
 {
+	struct drm_pending_vblank_event *e =
+		container_of(item, struct drm_pending_vblank_event, item);
 	struct vblank_data *data = (struct vblank_data *)e->event.user_data;
 
 	WARN_ON(data->can_sleep != drm_can_sleep());
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index dcec05b..474c892 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -660,8 +660,10 @@  struct drm_minor {
 	struct drm_mode_group mode_group;
 };
 
+struct drm_vblank_wait_item;
+
 typedef void (*drm_vblank_callback_t)(struct drm_device *dev,
-				      struct drm_pending_vblank_event *e,
+				      struct drm_vblank_wait_item *item,
 				      unsigned long seq, struct timeval *now,
 				      bool premature);