[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20211119113644.1600-17-alx.manpages@gmail.com>
Date: Fri, 19 Nov 2021 12:36:44 +0100
From: Alejandro Colomar <alx.manpages@...il.com>
To: LKML <linux-kernel@...r.kernel.org>
Cc: Alejandro Colomar <alx.manpages@...il.com>
Subject: [PATCH 16/17] linux/array_size.h: Move ARRAY_SIZE(arr) to a separate header
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@...il.com>
---
include/linux/array_size.h | 15 +++++++++++++++
include/linux/clk-provider.h | 1 +
include/linux/counter.h | 1 +
include/linux/genl_magic_func.h | 1 +
include/linux/hashtable.h | 1 +
include/linux/kernel.h | 7 +------
include/linux/kfifo.h | 1 +
include/linux/kvm_host.h | 1 +
include/linux/moduleparam.h | 3 +++
include/linux/mtd/rawnand.h | 1 +
include/linux/netfilter.h | 1 +
include/linux/pagemap.h | 1 +
include/linux/phy.h | 1 +
include/linux/pinctrl/machine.h | 1 +
include/linux/property.h | 1 +
include/linux/rcupdate_wait.h | 1 +
include/linux/regmap.h | 1 +
include/linux/skmsg.h | 2 ++
include/linux/string.h | 1 +
include/linux/surface_aggregator/controller.h | 1 +
20 files changed, 37 insertions(+), 6 deletions(-)
create mode 100644 include/linux/array_size.h
diff --git a/include/linux/array_size.h b/include/linux/array_size.h
new file mode 100644
index 000000000000..4f62840f808a
--- /dev/null
+++ b/include/linux/array_size.h
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _LINUX_ARRAY_SIZE_H
+#define _LINUX_ARRAY_SIZE_H
+
+#include <linux/compiler.h>
+
+
+/**
+ * ARRAY_SIZE - get the number of elements in array @arr
+ * @arr: array to be sized
+ */
+#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
+
+
+#endif /* _LINUX_ARRAY_SIZE_H */
diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
index f59c875271a0..f6860d22d1ab 100644
--- a/include/linux/clk-provider.h
+++ b/include/linux/clk-provider.h
@@ -6,6 +6,7 @@
#ifndef __LINUX_CLK_PROVIDER_H
#define __LINUX_CLK_PROVIDER_H
+#include <linux/array_size.h>
#include <linux/of.h>
#include <linux/of_clk.h>
diff --git a/include/linux/counter.h b/include/linux/counter.h
index b7d0a00a61cf..f7f6f2e50390 100644
--- a/include/linux/counter.h
+++ b/include/linux/counter.h
@@ -6,6 +6,7 @@
#ifndef _COUNTER_H_
#define _COUNTER_H_
+#include <linux/array_size.h>
#include <linux/cdev.h>
#include <linux/device.h>
#include <linux/kernel.h>
diff --git a/include/linux/genl_magic_func.h b/include/linux/genl_magic_func.h
index 939b1a8f571b..e3b5bd816bcd 100644
--- a/include/linux/genl_magic_func.h
+++ b/include/linux/genl_magic_func.h
@@ -2,6 +2,7 @@
#ifndef GENL_MAGIC_FUNC_H
#define GENL_MAGIC_FUNC_H
+#include <linux/array_size.h>
#include <linux/build_bug.h>
#include <linux/genl_magic_struct.h>
diff --git a/include/linux/hashtable.h b/include/linux/hashtable.h
index f6c666730b8c..09c5f1522b06 100644
--- a/include/linux/hashtable.h
+++ b/include/linux/hashtable.h
@@ -7,6 +7,7 @@
#ifndef _LINUX_HASHTABLE_H
#define _LINUX_HASHTABLE_H
+#include <linux/array_size.h>
#include <linux/list.h>
#include <linux/types.h>
#include <linux/kernel.h>
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 77755ac3e189..1437bfaadec5 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -2,6 +2,7 @@
#ifndef _LINUX_KERNEL_H
#define _LINUX_KERNEL_H
+#include <linux/array_size.h>
#include <linux/stdarg.h>
#include <linux/align.h>
#include <linux/limits.h>
@@ -39,12 +40,6 @@
#define READ 0
#define WRITE 1
-/**
- * ARRAY_SIZE - get the number of elements in array @arr
- * @arr: array to be sized
- */
-#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
-
#define PTR_IF(cond, ptr) ((cond) ? (ptr) : NULL)
#define u64_to_user_ptr(x) ( \
diff --git a/include/linux/kfifo.h b/include/linux/kfifo.h
index 86249476b57f..ef0e4b979ba0 100644
--- a/include/linux/kfifo.h
+++ b/include/linux/kfifo.h
@@ -36,6 +36,7 @@
* to lock the reader.
*/
+#include <linux/array_size.h>
#include <linux/kernel.h>
#include <linux/spinlock.h>
#include <linux/stddef.h>
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index f89a516f3a39..67dfcf9dd166 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -3,6 +3,7 @@
#define __KVM_HOST_H
+#include <linux/array_size.h>
#include <linux/types.h>
#include <linux/hardirq.h>
#include <linux/list.h>
diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
index 962cd41a2cb5..4a6eb8ce7c94 100644
--- a/include/linux/moduleparam.h
+++ b/include/linux/moduleparam.h
@@ -2,10 +2,13 @@
#ifndef _LINUX_MODULE_PARAMS_H
#define _LINUX_MODULE_PARAMS_H
/* (C) Copyright 2001, 2002 Rusty Russell IBM Corporation */
+
+#include <linux/array_size.h>
#include <linux/init.h>
#include <linux/stringify.h>
#include <linux/kernel.h>
+
/* You can override this manually, but generally this should match the
module name. */
#ifdef MODULE
diff --git a/include/linux/mtd/rawnand.h b/include/linux/mtd/rawnand.h
index b2f9dd3cbd69..cdb8e92db7ec 100644
--- a/include/linux/mtd/rawnand.h
+++ b/include/linux/mtd/rawnand.h
@@ -13,6 +13,7 @@
#ifndef __LINUX_MTD_RAWNAND_H
#define __LINUX_MTD_RAWNAND_H
+#include <linux/array_size.h>
#include <linux/mtd/mtd.h>
#include <linux/mtd/nand.h>
#include <linux/mtd/flashchip.h>
diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h
index 3fda1a508733..11a01c1fcc3c 100644
--- a/include/linux/netfilter.h
+++ b/include/linux/netfilter.h
@@ -2,6 +2,7 @@
#ifndef __LINUX_NETFILTER_H
#define __LINUX_NETFILTER_H
+#include <linux/array_size.h>
#include <linux/init.h>
#include <linux/skbuff.h>
#include <linux/net.h>
diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
index 1a0c646eb6ff..529282a85cb3 100644
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -5,6 +5,7 @@
/*
* Copyright 1995 Linus Torvalds
*/
+#include <linux/array_size.h>
#include <linux/mm.h>
#include <linux/fs.h>
#include <linux/list.h>
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 96e43fbb2dd8..ca86f7990751 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -11,6 +11,7 @@
#ifndef __PHY_H
#define __PHY_H
+#include <linux/array_size.h>
#include <linux/compiler.h>
#include <linux/spinlock.h>
#include <linux/ethtool.h>
diff --git a/include/linux/pinctrl/machine.h b/include/linux/pinctrl/machine.h
index e987dc9fd2af..6c264dd0e163 100644
--- a/include/linux/pinctrl/machine.h
+++ b/include/linux/pinctrl/machine.h
@@ -11,6 +11,7 @@
#ifndef __LINUX_PINCTRL_MACHINE_H
#define __LINUX_PINCTRL_MACHINE_H
+#include <linux/array_size.h>
#include <linux/bug.h>
#include <linux/pinctrl/pinctrl-state.h>
diff --git a/include/linux/property.h b/include/linux/property.h
index 88fa726a76df..add29cf6c0c4 100644
--- a/include/linux/property.h
+++ b/include/linux/property.h
@@ -10,6 +10,7 @@
#ifndef _LINUX_PROPERTY_H_
#define _LINUX_PROPERTY_H_
+#include <linux/array_size.h>
#include <linux/bits.h>
#include <linux/fwnode.h>
#include <linux/types.h>
diff --git a/include/linux/rcupdate_wait.h b/include/linux/rcupdate_wait.h
index 699b938358bf..a321404eeec0 100644
--- a/include/linux/rcupdate_wait.h
+++ b/include/linux/rcupdate_wait.h
@@ -6,6 +6,7 @@
* RCU synchronization types and methods:
*/
+#include <linux/array_size.h>
#include <linux/rcupdate.h>
#include <linux/completion.h>
diff --git a/include/linux/regmap.h b/include/linux/regmap.h
index e3c9a25a853a..e039cd815fc1 100644
--- a/include/linux/regmap.h
+++ b/include/linux/regmap.h
@@ -10,6 +10,7 @@
* Author: Mark Brown <broonie@...nsource.wolfsonmicro.com>
*/
+#include <linux/array_size.h>
#include <linux/list.h>
#include <linux/rbtree.h>
#include <linux/ktime.h>
diff --git a/include/linux/skmsg.h b/include/linux/skmsg.h
index 46e76f4ff0de..2f1bdc81fafb 100644
--- a/include/linux/skmsg.h
+++ b/include/linux/skmsg.h
@@ -4,6 +4,7 @@
#ifndef _LINUX_SKMSG_H
#define _LINUX_SKMSG_H
+#include <linux/array_size.h>
#include <linux/bpf.h>
#include <linux/filter.h>
#include <linux/offsetofend.h>
@@ -14,6 +15,7 @@
#include <net/tcp.h>
#include <net/strparser.h>
+
#define MAX_MSG_FRAGS MAX_SKB_FRAGS
#define NR_MSG_FRAG_IDS (MAX_MSG_FRAGS + 1)
diff --git a/include/linux/string.h b/include/linux/string.h
index 555b6f00c73d..88324a05c34a 100644
--- a/include/linux/string.h
+++ b/include/linux/string.h
@@ -2,6 +2,7 @@
#ifndef _LINUX_STRING_H_
#define _LINUX_STRING_H_
+#include <linux/array_size.h>
#include <linux/compiler.h> /* for inline */
#include <linux/NULL.h>
#include <linux/types.h> /* for size_t */
diff --git a/include/linux/surface_aggregator/controller.h b/include/linux/surface_aggregator/controller.h
index 74bfdffaf7b0..9a355c38132c 100644
--- a/include/linux/surface_aggregator/controller.h
+++ b/include/linux/surface_aggregator/controller.h
@@ -12,6 +12,7 @@
#ifndef _LINUX_SURFACE_AGGREGATOR_CONTROLLER_H
#define _LINUX_SURFACE_AGGREGATOR_CONTROLLER_H
+#include <linux/array_size.h>
#include <linux/completion.h>
#include <linux/device.h>
#include <linux/types.h>
--
2.33.1
Powered by blists - more mailing lists