[Intel-gfx] [PATCH 08/20] drm/i915: Promote ptrdiff() to i915_utils.h
Daniel Vetter
daniel at ffwll.ch
Fri Jun 4 08:11:02 UTC 2021
On Thu, Jun 03, 2021 at 07:02:57PM -0700, Matthew Brost wrote:
> On Thu, Jun 03, 2021 at 11:35:28PM +0200, Daniel Vetter wrote:
> > On Wed, Jun 02, 2021 at 10:16:18PM -0700, Matthew Brost wrote:
> > > From: Michal Wajdeczko <michal.wajdeczko at intel.com>
> > >
> > > Generic helpers should be placed in i915_utils.h.
> >
> > Random rant, but we're _way_ too happy to just stuff random things into
> > i915_utils.h without trying to properly upstream it.
> >
> > For thinks like this the general dumping ground would be kernel.h, there's
> > a few pointer helpers there already. Follow up patch maybe nice.
> > -Daniel
> >
>
> Sure. I've added this to a list of follow ups so this comment doesn't
> get lost.
btw I think we probably want to rename it, because it's not just the
well-defined C pointer difference. We convert to void * so we get the
difference in bytes. So maybe ptr_offset or ptrdiff_in_bytes or something
like that which makes it clear.
-Daniel
>
> Matt
>
> > >
> > > Signed-off-by: Michal Wajdeczko <michal.wajdeczko at intel.com>
> > > Signed-off-by: Matthew Brost <matthew.brost at intel.com>
> > > Reviewed-by: Matthew Brost <matthew.brost at intel.com>
> > > ---
> > > drivers/gpu/drm/i915/i915_utils.h | 5 +++++
> > > drivers/gpu/drm/i915/i915_vma.h | 5 -----
> > > 2 files changed, 5 insertions(+), 5 deletions(-)
> > >
> > > diff --git a/drivers/gpu/drm/i915/i915_utils.h b/drivers/gpu/drm/i915/i915_utils.h
> > > index f02f52ab5070..5259edacde38 100644
> > > --- a/drivers/gpu/drm/i915/i915_utils.h
> > > +++ b/drivers/gpu/drm/i915/i915_utils.h
> > > @@ -201,6 +201,11 @@ __check_struct_size(size_t base, size_t arr, size_t count, size_t *size)
> > > __T; \
> > > })
> > >
> > > +static __always_inline ptrdiff_t ptrdiff(const void *a, const void *b)
> > > +{
> > > + return a - b;
> > > +}
> > > +
> > > /*
> > > * container_of_user: Extract the superclass from a pointer to a member.
> > > *
> > > diff --git a/drivers/gpu/drm/i915/i915_vma.h b/drivers/gpu/drm/i915/i915_vma.h
> > > index dc6926d89626..eca452a9851f 100644
> > > --- a/drivers/gpu/drm/i915/i915_vma.h
> > > +++ b/drivers/gpu/drm/i915/i915_vma.h
> > > @@ -151,11 +151,6 @@ static inline void i915_vma_put(struct i915_vma *vma)
> > > i915_gem_object_put(vma->obj);
> > > }
> > >
> > > -static __always_inline ptrdiff_t ptrdiff(const void *a, const void *b)
> > > -{
> > > - return a - b;
> > > -}
> > > -
> > > static inline long
> > > i915_vma_compare(struct i915_vma *vma,
> > > struct i915_address_space *vm,
> > > --
> > > 2.28.0
> > >
> >
> > --
> > Daniel Vetter
> > Software Engineer, Intel Corporation
> > http://blog.ffwll.ch
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
More information about the Intel-gfx
mailing list