All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/i915/pmu: Hide the (unsigned long)ptr cast
@ 2017-11-23 17:42 Chris Wilson
  2017-11-23 18:17 ` ✓ Fi.CI.BAT: success for " Patchwork
                   ` (6 more replies)
  0 siblings, 7 replies; 12+ messages in thread
From: Chris Wilson @ 2017-11-23 17:42 UTC (permalink / raw)
  To: intel-gfx

We pretend the PMU config id is a pointer value when encoding it into
the device parameters for presentation via sysfs. This requires casting
of an unsigned long into and out of the pointer member, which annoys
smatch:

drivers/gpu/drm/i915/i915_pmu.c:684 i915_pmu_event_show() warn: argument 3 to %lx specifier is cast from pointer

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
---
 drivers/gpu/drm/i915/i915_pmu.c   | 2 +-
 drivers/gpu/drm/i915/i915_utils.h | 5 +++++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/i915_pmu.c b/drivers/gpu/drm/i915/i915_pmu.c
index 6a42e7f7967d..a8816d25a77b 100644
--- a/drivers/gpu/drm/i915/i915_pmu.c
+++ b/drivers/gpu/drm/i915/i915_pmu.c
@@ -681,7 +681,7 @@ static ssize_t i915_pmu_event_show(struct device *dev,
 	struct dev_ext_attribute *eattr;
 
 	eattr = container_of(attr, struct dev_ext_attribute, attr);
-	return sprintf(buf, "config=0x%lx\n", (unsigned long)eattr->var);
+	return sprintf(buf, "config=0x%lx\n", ptr_to_ulong(eattr->var));
 }
 
 #define I915_EVENT_ATTR(_name, _config) \
diff --git a/drivers/gpu/drm/i915/i915_utils.h b/drivers/gpu/drm/i915/i915_utils.h
index 8d07764887ec..2595fbf6451f 100644
--- a/drivers/gpu/drm/i915/i915_utils.h
+++ b/drivers/gpu/drm/i915/i915_utils.h
@@ -107,6 +107,11 @@ static inline u64 ptr_to_u64(const void *ptr)
 	return (uintptr_t)ptr;
 }
 
+static inline unsigned long ptr_to_ulong(const void *ptr)
+{
+	return ptr_to_u64(ptr);
+}
+
 #define u64_to_ptr(T, x) ({						\
 	typecheck(u64, x);						\
 	(T *)(uintptr_t)(x);						\
-- 
2.15.0

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2017-11-24  9:35 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-23 17:42 [PATCH] drm/i915/pmu: Hide the (unsigned long)ptr cast Chris Wilson
2017-11-23 18:17 ` ✓ Fi.CI.BAT: success for " Patchwork
2017-11-23 18:20 ` [PATCH] " Michal Wajdeczko
2017-11-23 20:58   ` Chris Wilson
2017-11-23 21:17 ` [PATCH v2] " Chris Wilson
2017-11-24  8:42   ` Tvrtko Ursulin
2017-11-24  9:35     ` Chris Wilson
2017-11-23 21:40 ` ✗ Fi.CI.IGT: warning for " Patchwork
2017-11-23 21:50 ` ✓ Fi.CI.BAT: success for drm/i915/pmu: Hide the (unsigned long)ptr cast (rev2) Patchwork
2017-11-24  0:54 ` ✓ Fi.CI.IGT: " Patchwork
2017-11-24  8:04 ` [PATCH] drm/i915/pmu: Hide the (unsigned long)ptr cast Tvrtko Ursulin
2017-11-24  8:59   ` Chris Wilson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.