linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ACPICA: Use uintptr_t and offsetof() in Linux kernel builds
@ 2022-01-11 15:55 Rafael J. Wysocki
  2022-01-12  8:45 ` Arnd Bergmann
  0 siblings, 1 reply; 3+ messages in thread
From: Rafael J. Wysocki @ 2022-01-11 15:55 UTC (permalink / raw)
  To: Linux ACPI; +Cc: LKML, Bob Moore, Arnd Bergmann

From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

To avoid "performing pointer subtraction with a null pointer has
undefined behavior" compiler warnings, use uintptr_t and offsetof()
that are always available during Linux kernel builds to define
acpi_uintptr_t and the ACPI_TO_INTEGER() and ACPI_OFFSET() macros.

Based on earlier proposal from Arnd Bergmann.

Link: https://lore.kernel.org/linux-acpi/20210927121338.938994-1-arnd@kernel.org
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 include/acpi/actypes.h          |    4 ++++
 include/acpi/platform/aclinux.h |    5 +++++
 2 files changed, 9 insertions(+)

Index: linux-pm/include/acpi/platform/aclinux.h
===================================================================
--- linux-pm.orig/include/acpi/platform/aclinux.h
+++ linux-pm/include/acpi/platform/aclinux.h
@@ -114,6 +114,11 @@
 #define acpi_raw_spinlock                   raw_spinlock_t *
 #define acpi_cpu_flags                      unsigned long
 
+#define acpi_uintptr_t                      uintptr_t
+
+#define ACPI_TO_INTEGER(p)                  ((uintptr_t)(p))
+#define ACPI_OFFSET(d, f)                   offsetof(d, f)
+
 /* Use native linux version of acpi_os_allocate_zeroed */
 
 #define USE_NATIVE_ALLOCATE_ZEROED
Index: linux-pm/include/acpi/actypes.h
===================================================================
--- linux-pm.orig/include/acpi/actypes.h
+++ linux-pm/include/acpi/actypes.h
@@ -507,8 +507,12 @@ typedef u64 acpi_integer;
 /* Pointer/Integer type conversions */
 
 #define ACPI_TO_POINTER(i)              ACPI_CAST_PTR (void, (acpi_size) (i))
+#ifndef ACPI_TO_INTEGER
 #define ACPI_TO_INTEGER(p)              ACPI_PTR_DIFF (p, (void *) 0)
+#endif
+#ifndef ACPI_OFFSET
 #define ACPI_OFFSET(d, f)               ACPI_PTR_DIFF (&(((d *) 0)->f), (void *) 0)
+#endif
 #define ACPI_PTR_TO_PHYSADDR(i)         ACPI_TO_INTEGER(i)
 
 /* Optimizations for 4-character (32-bit) acpi_name manipulation */




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

* Re: [PATCH] ACPICA: Use uintptr_t and offsetof() in Linux kernel builds
  2022-01-11 15:55 [PATCH] ACPICA: Use uintptr_t and offsetof() in Linux kernel builds Rafael J. Wysocki
@ 2022-01-12  8:45 ` Arnd Bergmann
  2022-01-25 17:43   ` Rafael J. Wysocki
  0 siblings, 1 reply; 3+ messages in thread
From: Arnd Bergmann @ 2022-01-12  8:45 UTC (permalink / raw)
  To: Rafael J. Wysocki; +Cc: Linux ACPI, LKML, Bob Moore

On Tue, Jan 11, 2022 at 4:55 PM Rafael J. Wysocki <rjw@rjwysocki.net> wrote:
>
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>
> To avoid "performing pointer subtraction with a null pointer has
> undefined behavior" compiler warnings, use uintptr_t and offsetof()
> that are always available during Linux kernel builds to define
> acpi_uintptr_t and the ACPI_TO_INTEGER() and ACPI_OFFSET() macros.
>
> Based on earlier proposal from Arnd Bergmann.
>
> Link: https://lore.kernel.org/linux-acpi/20210927121338.938994-1-arnd@kernel.org
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

Thanks for the follow-up. I can't easily test this at the moment, but
it looks correct to
me. I had a different approach that I had planned to eventually
submit, but yours
looks better anyway, so let's go with this.

Reviewed-by: Arnd Bergmann <arnd@arndb.de>

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

* Re: [PATCH] ACPICA: Use uintptr_t and offsetof() in Linux kernel builds
  2022-01-12  8:45 ` Arnd Bergmann
@ 2022-01-25 17:43   ` Rafael J. Wysocki
  0 siblings, 0 replies; 3+ messages in thread
From: Rafael J. Wysocki @ 2022-01-25 17:43 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: Rafael J. Wysocki, Linux ACPI, LKML, Bob Moore

On Wed, Jan 12, 2022 at 9:45 AM Arnd Bergmann <arnd@kernel.org> wrote:
>
> On Tue, Jan 11, 2022 at 4:55 PM Rafael J. Wysocki <rjw@rjwysocki.net> wrote:
> >
> > From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> >
> > To avoid "performing pointer subtraction with a null pointer has
> > undefined behavior" compiler warnings, use uintptr_t and offsetof()
> > that are always available during Linux kernel builds to define
> > acpi_uintptr_t and the ACPI_TO_INTEGER() and ACPI_OFFSET() macros.
> >
> > Based on earlier proposal from Arnd Bergmann.
> >
> > Link: https://lore.kernel.org/linux-acpi/20210927121338.938994-1-arnd@kernel.org
> > Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>
> Thanks for the follow-up. I can't easily test this at the moment, but
> it looks correct to
> me. I had a different approach that I had planned to eventually
> submit, but yours
> looks better anyway, so let's go with this.
>
> Reviewed-by: Arnd Bergmann <arnd@arndb.de>

Thank you, I've applied this patch as 5.18 material.

A pull request for the analogous change in the upstream code base has
been submitted and Bob is going to take it AFAICS.

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

end of thread, other threads:[~2022-01-25 17:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-11 15:55 [PATCH] ACPICA: Use uintptr_t and offsetof() in Linux kernel builds Rafael J. Wysocki
2022-01-12  8:45 ` Arnd Bergmann
2022-01-25 17:43   ` Rafael J. Wysocki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).