[PATCH 05/17] linux/typeof_member.h: Move typeof_member() to a separate header

From: Alejandro Colomar
Date: Fri Nov 19 2021 - 06:37:22 EST


Touching files so used for the kernel,
forces 'make' to recompile most of the kernel.

Having those definitions in more granular files
helps avoid recompiling so much of the kernel.

Signed-off-by: Alejandro Colomar <alx.manpages@xxxxxxxxx>
---
drivers/gpu/drm/i915/i915_sw_fence.c | 1 +
drivers/platform/x86/wmi.c | 1 +
fs/proc/inode.c | 1 +
include/linux/container_of.h | 2 --
include/linux/typeof_member.h | 11 +++++++++++
include/linux/virtio_config.h | 1 +
kernel/kallsyms.c | 1 +
7 files changed, 16 insertions(+), 2 deletions(-)
create mode 100644 include/linux/typeof_member.h

diff --git a/drivers/gpu/drm/i915/i915_sw_fence.c b/drivers/gpu/drm/i915/i915_sw_fence.c
index c589a681da77..911ad08978b2 100644
--- a/drivers/gpu/drm/i915/i915_sw_fence.c
+++ b/drivers/gpu/drm/i915/i915_sw_fence.c
@@ -8,6 +8,7 @@
#include <linux/dma-fence.h>
#include <linux/irq_work.h>
#include <linux/dma-resv.h>
+#include <linux/typeof_member.h>

#include "i915_sw_fence.h"
#include "i915_selftest.h"
diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c
index c34341f4da76..5daadcafd808 100644
--- a/drivers/platform/x86/wmi.c
+++ b/drivers/platform/x86/wmi.c
@@ -33,6 +33,7 @@
#include <linux/uuid.h>
#include <linux/wmi.h>
#include <linux/fs.h>
+#include <linux/typeof_member.h>
#include <uapi/linux/wmi.h>

MODULE_AUTHOR("Carlos Corbacho");
diff --git a/fs/proc/inode.c b/fs/proc/inode.c
index 599eb724ff2d..e73e55e8dad4 100644
--- a/fs/proc/inode.c
+++ b/fs/proc/inode.c
@@ -25,6 +25,7 @@
#include <linux/slab.h>
#include <linux/mount.h>
#include <linux/bug.h>
+#include <linux/typeof_member.h>

#include <linux/uaccess.h>

diff --git a/include/linux/container_of.h b/include/linux/container_of.h
index 2f1eb5ddd20a..082188b5cd29 100644
--- a/include/linux/container_of.h
+++ b/include/linux/container_of.h
@@ -7,8 +7,6 @@
#include <linux/memberof.h>


-#define typeof_member(T, m) typeof(memberof(T, m))
-
/**
* container_of - cast a member of a structure out to the containing structure
* @ptr: the pointer to the member.
diff --git a/include/linux/typeof_member.h b/include/linux/typeof_member.h
new file mode 100644
index 000000000000..38aa030d86d2
--- /dev/null
+++ b/include/linux/typeof_member.h
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _LINUX_TYPEOF_MEMBER_H
+#define _LINUX_TYPEOF_MEMBER_H
+
+#include <linux/memberof.h>
+
+
+#define typeof_member(T, m) typeof(memberof(T, m))
+
+
+#endif /* _LINUX_TYPEOF_MEMBER_H */
diff --git a/include/linux/virtio_config.h b/include/linux/virtio_config.h
index ddbd51208ce1..ff1752441e5d 100644
--- a/include/linux/virtio_config.h
+++ b/include/linux/virtio_config.h
@@ -8,6 +8,7 @@
#include <linux/virtio.h>
#include <linux/virtio_byteorder.h>
#include <linux/compiler_types.h>
+#include <linux/typeof_member.h>
#include <uapi/linux/virtio_config.h>

struct irq_affinity;
diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
index 3011bc33a5ba..3bf04d89d72c 100644
--- a/kernel/kallsyms.c
+++ b/kernel/kallsyms.c
@@ -29,6 +29,7 @@
#include <linux/compiler.h>
#include <linux/module.h>
#include <linux/kernel.h>
+#include <linux/typeof_member.h>

/*
* These will be re-linked against their real values
--
2.33.1