[v1,8/8] linux/kernel.h: move PTR_IF() to ptr_util.h
Commit Message
Reducing dependencies on the header linux/kernel.h.
Signed-off-by: Max Kellermann <max.kellermann@ionos.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
@@ -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>
@@ -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>
@@ -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>
@@ -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)); \
@@ -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>
new file mode 100644
@@ -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 */
@@ -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>