[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240215093646.3265823-9-max.kellermann@ionos.com>
Date: Thu, 15 Feb 2024 10:36:46 +0100
From: Max Kellermann <max.kellermann@...os.com>
To: linux-kernel@...r.kernel.org
Cc: Max Kellermann <max.kellermann@...os.com>
Subject: [PATCH v1 8/8] linux/kernel.h: move PTR_IF() to ptr_util.h
Reducing dependencies on the header linux/kernel.h.
Signed-off-by: Max Kellermann <max.kellermann@...os.com>
---
drivers/gpio/gpio-sim.c | 1 +
drivers/gpu/drm/i915/i915_driver.c | 1 +
drivers/pinctrl/pinctrl-ingenic.c | 1 +
include/linux/kernel.h | 2 --
include/linux/pm.h | 1 +
include/linux/ptr_util.h | 7 +++++++
include/rdma/uverbs_ioctl.h | 1 +
7 files changed, 12 insertions(+), 2 deletions(-)
create mode 100644 include/linux/ptr_util.h
diff --git a/drivers/gpio/gpio-sim.c b/drivers/gpio/gpio-sim.c
index c4106e37e6db..fdf17cc91b4c 100644
--- a/drivers/gpio/gpio-sim.c
+++ b/drivers/gpio/gpio-sim.c
@@ -29,6 +29,7 @@
#include <linux/notifier.h>
#include <linux/platform_device.h>
#include <linux/property.h>
+#include <linux/ptr_util.h> // for PTR_IF()
#include <linux/seq_file.h>
#include <linux/slab.h>
#include <linux/string.h>
diff --git a/drivers/gpu/drm/i915/i915_driver.c b/drivers/gpu/drm/i915/i915_driver.c
index 9ee902d5b72c..6dd0d8fdd6eb 100644
--- a/drivers/gpu/drm/i915/i915_driver.c
+++ b/drivers/gpu/drm/i915/i915_driver.c
@@ -34,6 +34,7 @@
#include <linux/pci.h>
#include <linux/pm.h>
#include <linux/pm_runtime.h>
+#include <linux/ptr_util.h> // for PTR_IF()
#include <linux/slab.h>
#include <linux/string_helpers.h>
#include <linux/vga_switcheroo.h>
diff --git a/drivers/pinctrl/pinctrl-ingenic.c b/drivers/pinctrl/pinctrl-ingenic.c
index bc6358a686fc..f88d2d3d217c 100644
--- a/drivers/pinctrl/pinctrl-ingenic.c
+++ b/drivers/pinctrl/pinctrl-ingenic.c
@@ -16,6 +16,7 @@
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/property.h>
+#include <linux/ptr_util.h> // for PTR_IF()
#include <linux/regmap.h>
#include <linux/seq_file.h>
#include <linux/slab.h>
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 01a0cc0a0776..1f1b2ced524f 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -40,8 +40,6 @@
#define STACK_MAGIC 0xdeadbeef
-#define PTR_IF(cond, ptr) ((cond) ? (ptr) : NULL)
-
#define u64_to_user_ptr(x) ( \
{ \
typecheck(u64, (x)); \
diff --git a/include/linux/pm.h b/include/linux/pm.h
index 97b0e23363c8..7e593b5fc5f1 100644
--- a/include/linux/pm.h
+++ b/include/linux/pm.h
@@ -9,6 +9,7 @@
#define _LINUX_PM_H
#include <linux/export.h>
+#include <linux/ptr_util.h> // for PTR_IF()
#include <linux/list.h>
#include <linux/workqueue.h>
#include <linux/spinlock.h>
diff --git a/include/linux/ptr_util.h b/include/linux/ptr_util.h
new file mode 100644
index 000000000000..7469aff978a9
--- /dev/null
+++ b/include/linux/ptr_util.h
@@ -0,0 +1,7 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _LINUX_PTR_UTIL_H
+#define _LINUX_PTR_UTIL_H
+
+#define PTR_IF(cond, ptr) ((cond) ? (ptr) : NULL)
+
+#endif /* _LINUX_PTR_UTIL_H */
diff --git a/include/rdma/uverbs_ioctl.h b/include/rdma/uverbs_ioctl.h
index 5ed57a660ead..c94244e7a77d 100644
--- a/include/rdma/uverbs_ioctl.h
+++ b/include/rdma/uverbs_ioctl.h
@@ -7,6 +7,7 @@
#define _UVERBS_IOCTL_
#include <rdma/uverbs_types.h>
+#include <linux/ptr_util.h> // for PTR_IF()
#include <linux/uaccess.h>
#include <rdma/rdma_user_ioctl.h>
#include <rdma/ib_user_ioctl_verbs.h>
--
2.39.2
Powered by blists - more mailing lists