diff mbox

[v7,02/11] drm/i915: Use offsetof() to calculate the offset of members in PVINFO page

Message ID 1465312727-2211-3-git-send-email-zhi.a.wang@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Wang, Zhi A June 7, 2016, 3:18 p.m. UTC
To get the offset of the members in PVINFO page, offsetof() looks much
better than the tricky approach in current code.

v7:

- Move "offsetof()" modification into a dedicated patch. (Joonas)

Signed-off-by: Zhi Wang <zhi.a.wang@intel.com>
---
 drivers/gpu/drm/i915/i915_pvinfo.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Joonas Lahtinen June 8, 2016, 7:57 a.m. UTC | #1
On ti, 2016-06-07 at 11:18 -0400, Zhi Wang wrote:
> To get the offset of the members in PVINFO page, offsetof() looks much
> better than the tricky approach in current code.
> 
> v7:
> 
> - Move "offsetof()" modification into a dedicated patch. (Joonas)
> 
> Signed-off-by: Zhi Wang <zhi.a.wang@intel.com>

It's good idea to add Cc: in patches resulting from discussions (or
Suggested-by:). Then it would be easier to spot for me if I was not
reviewing the series as whole.

Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>

> ---
>  drivers/gpu/drm/i915/i915_pvinfo.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_pvinfo.h b/drivers/gpu/drm/i915/i915_pvinfo.h
> index 68bdf60..7b3cec4 100644
> --- a/drivers/gpu/drm/i915/i915_pvinfo.h
> +++ b/drivers/gpu/drm/i915/i915_pvinfo.h
> @@ -104,7 +104,7 @@ struct vgt_if {
>  } __packed;
>  
>  #define vgtif_reg(x) \
> -	_MMIO((VGT_PVINFO_PAGE + (long)&((struct vgt_if *)NULL)->x))
> +	_MMIO((VGT_PVINFO_PAGE + offsetof(struct vgt_if, x)))
>  
>  /* vGPU display status to be used by the host side */
>  #define VGT_DRV_DISPLAY_NOT_READY 0
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/i915_pvinfo.h b/drivers/gpu/drm/i915/i915_pvinfo.h
index 68bdf60..7b3cec4 100644
--- a/drivers/gpu/drm/i915/i915_pvinfo.h
+++ b/drivers/gpu/drm/i915/i915_pvinfo.h
@@ -104,7 +104,7 @@  struct vgt_if {
 } __packed;
 
 #define vgtif_reg(x) \
-	_MMIO((VGT_PVINFO_PAGE + (long)&((struct vgt_if *)NULL)->x))
+	_MMIO((VGT_PVINFO_PAGE + offsetof(struct vgt_if, x)))
 
 /* vGPU display status to be used by the host side */
 #define VGT_DRV_DISPLAY_NOT_READY 0