<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Mar 27, 2017 at 9:32 PM, Matthew Auld <span dir="ltr"><<a href="mailto:matthew.auld@intel.com" target="_blank">matthew.auld@intel.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Don't throw a warning if we are given an invalid property id. While<br>
here let's also bring back Robert' original idea of catching unhandled<br>
enumeration values at compile time.<br>
<br>
Fixes: eec688e1420d ("drm/i915: Add i915 perf infrastructure")<br>
Signed-off-by: Matthew Auld <<a href="mailto:matthew.auld@intel.com">matthew.auld@intel.com</a>><br>
Cc: Robert Bragg <<a href="mailto:robert@sixbynine.org">robert@sixbynine.org</a>><br>
---<br>
 drivers/gpu/drm/i915/i915_<wbr>perf.c | 8 ++++++--<br>
 1 file changed, 6 insertions(+), 2 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/i915/i915_<wbr>perf.c b/drivers/gpu/drm/i915/i915_<wbr>perf.c<br>
index 8c121187ff39..e52bc6a581e6 100644<br>
--- a/drivers/gpu/drm/i915/i915_<wbr>perf.c<br>
+++ b/drivers/gpu/drm/i915/i915_<wbr>perf.c<br>
@@ -1793,6 +1793,11 @@ static int read_properties_unlocked(<wbr>struct drm_i915_private *dev_priv,<br>
                if (ret)<br>
                        return ret;<br>
<br>
+               if (id == 0 || id >= DRM_I915_PERF_PROP_MAX) {<br>
+                       DRM_DEBUG("Unknown i915 perf property ID\n");<br>
+                       return -EINVAL;<br>
+               }<br>
+<br>
                switch ((enum drm_i915_perf_property_id)id) {<br>
                case DRM_I915_PERF_PROP_CTX_HANDLE:<br>
                        props->single_context = 1;<br>
@@ -1862,9 +1867,8 @@ static int read_properties_unlocked(<wbr>struct drm_i915_private *dev_priv,<br>
                        props->oa_periodic = true;<br>
                        props->oa_period_exponent = value;<br>
                        break;<br>
-               default:<br>
+               case DRM_I915_PERF_PROP_MAX:<br>
                        MISSING_CASE(id);<br>
-                       DRM_DEBUG("Unknown i915 perf property ID\n");<br>
                        return -EINVAL;<br>
                }<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
2.9.3<br>
<br></font></span></blockquote><div><br></div><div>Looks good to me, thanks.<br><br></div><div>Reviewed-by: Robert Bragg <<a href="mailto:robert@sixbynine.org">robert@sixbynine.org</a>> <br></div></div><br></div></div>