Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm
[sfrench/cifs-2.6.git] / drivers / gpu / drm / i915 / intel_wakeref.h
index 9cbb2ebf575b5f610c27535728c4f9fd79c25ff4..38275310b196dbea82402d3b49648070049c1611 100644 (file)
@@ -65,6 +65,21 @@ intel_wakeref_get(struct intel_runtime_pm *rpm,
        return 0;
 }
 
+/**
+ * intel_wakeref_get_if_in_use: Acquire the wakeref
+ * @wf: the wakeref
+ *
+ * Acquire a hold on the wakeref, but only if the wakeref is already
+ * active.
+ *
+ * Returns: true if the wakeref was acquired, false otherwise.
+ */
+static inline bool
+intel_wakeref_get_if_active(struct intel_wakeref *wf)
+{
+       return atomic_inc_not_zero(&wf->count);
+}
+
 /**
  * intel_wakeref_put: Release the wakeref
  * @i915: the drm_i915_private device