linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alejandro Colomar <alx.manpages@gmail.com>
To: LKML <linux-kernel@vger.kernel.org>
Cc: Alejandro Colomar <alx.manpages@gmail.com>
Subject: [PATCH 16/17] linux/array_size.h: Move ARRAY_SIZE(arr) to a separate header
Date: Fri, 19 Nov 2021 12:36:44 +0100	[thread overview]
Message-ID: <20211119113644.1600-17-alx.manpages@gmail.com> (raw)
In-Reply-To: <20211119113644.1600-1-alx.manpages@gmail.com>

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@gmail.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@opensource.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


  parent reply	other threads:[~2021-11-19 11:37 UTC|newest]

Thread overview: 86+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-19 11:36 [PATCH 00/17] Add memberof(), split some headers, and slightly simplify code Alejandro Colomar
2021-11-19 11:36 ` [PATCH 01/17] linux/container_of.h: Add memberof(T, m) Alejandro Colomar
2021-11-19 11:36 ` [PATCH 02/17] Use memberof(T, m) instead of explicit NULL dereference Alejandro Colomar
2021-11-23 18:07   ` Rafael J. Wysocki
2021-11-19 11:36 ` [PATCH 03/17] Replace some uses of memberof() by its wrappers Alejandro Colomar
2021-11-19 11:36 ` [PATCH 04/17] linux/memberof.h: Move memberof() to separate header Alejandro Colomar
2021-11-19 11:36 ` [PATCH 05/17] linux/typeof_member.h: Move typeof_member() to a " Alejandro Colomar
2021-11-19 11:36 ` [PATCH 06/17] Simplify sizeof(typeof_member()) to sizeof_field() Alejandro Colomar
2021-11-19 11:36 ` [PATCH 07/17] linux/NULL.h: Move NULL to a separate header Alejandro Colomar
2021-11-19 11:36 ` [PATCH 08/17] linux/offsetof.h: Move offsetof(T, m) " Alejandro Colomar
2021-11-19 11:36 ` [PATCH 09/17] linux/offsetof.h: Implement offsetof() in terms of memberof() Alejandro Colomar
2021-11-19 11:36 ` [PATCH 10/17] linux/container_of.h: Implement container_of_safe() in terms of container_of() Alejandro Colomar
2021-11-19 11:36 ` [PATCH 11/17] linux/container_of.h: Cosmetic Alejandro Colomar
2021-11-19 11:36 ` [PATCH 12/17] linux/container_of.h: Remove unnecessary cast to (void *) Alejandro Colomar
2021-11-19 11:36 ` [PATCH 13/17] linux/sizeof_field.h: Move sizeof_field(T, m) to a separate header Alejandro Colomar
2021-11-19 11:36 ` [PATCH 14/17] include/linux/: Include a smaller header if just for NULL Alejandro Colomar
2021-11-19 11:36 ` [PATCH 15/17] linux/offsetofend.h: Move offsetofend(T, m) to a separate header Alejandro Colomar
2021-11-19 11:36 ` Alejandro Colomar [this message]
2021-11-19 11:36 ` [PATCH 17/17] include/: Include <linux/array_size.h> for ARRAY_SIZE() Alejandro Colomar
2021-11-19 12:47 ` [PATCH 00/17] Add memberof(), split some headers, and slightly simplify code Jani Nikula
2021-11-19 13:16   ` Alejandro Colomar (man-pages)
2021-11-19 13:48     ` Jani Nikula
2021-11-19 14:54     ` Andy Shevchenko
2021-11-19 14:47 ` Arnd Bergmann
2021-11-19 15:06   ` Alejandro Colomar (man-pages)
2021-11-19 15:34     ` Andy Shevchenko
2021-11-19 15:38       ` Alejandro Colomar (man-pages)
2021-11-19 15:43         ` Alejandro Colomar (man-pages)
2021-11-19 15:49           ` Andy Shevchenko
2021-11-19 15:52             ` Alejandro Colomar (man-pages)
2021-11-19 16:07               ` Andy Shevchenko
2021-11-19 15:57     ` Arnd Bergmann
2021-11-19 16:10       ` Andy Shevchenko
2021-11-19 16:18         ` Arnd Bergmann
2021-11-19 16:22           ` Alejandro Colomar (man-pages)
2021-11-19 16:27             ` Arnd Bergmann
2021-11-19 16:35             ` Andy Shevchenko
2021-11-22 12:36               ` Jonathan Cameron
2021-11-19 16:12       ` Alejandro Colomar (man-pages)
2021-11-19 16:25         ` Arnd Bergmann
2021-11-19 16:37         ` Andy Shevchenko
2021-11-19 16:49           ` Alejandro Colomar (man-pages)
2021-11-20 13:00 ` [PATCH v2 00/20] Add memberof(), split headers, and " Alejandro Colomar
2021-11-20 13:00   ` [PATCH v2 01/20] linux/stddef.h, linux/offsetof.h: Split offsetof() into a separate header Alejandro Colomar
2021-11-20 16:14     ` Andy Shevchenko
2021-11-20 16:22       ` Alejandro Colomar (man-pages)
2021-11-20 13:00   ` [PATCH v2 02/20] linux/stddef.h, linux/sizeof_field.h: Split sizeof_field() " Alejandro Colomar
2021-11-20 16:16     ` Andy Shevchenko
2021-11-20 13:00   ` [PATCH v2 03/20] linux/stddef.h, linux/offsetofend.h: Split offsetofend() " Alejandro Colomar
2021-11-20 13:00   ` [PATCH v2 04/20] linux/stddef.h, linux/NULL.h: Split NULL " Alejandro Colomar
2021-11-20 13:00   ` [PATCH v2 05/20] linux/container_of.h, linux/typeof_member.h: Split typeof_member() " Alejandro Colomar
2021-11-20 13:00   ` [PATCH v2 06/20] linux/kernel.h, linux/array_size.h: Split ARRAY_SIZE() " Alejandro Colomar
2021-11-22  7:36     ` kernel test robot
2021-11-20 13:00   ` [PATCH v2 07/20] linux/memberof.h: Add memberof(T, m) macro Alejandro Colomar
2021-11-20 13:00   ` [PATCH v2 08/20] Implement container_of_safe() in terms of container_of() Alejandro Colomar
2021-11-21 13:31     ` Arnd Bergmann
2021-11-20 13:00   ` [PATCH v2 09/20] Implement offsetof(), sizeof_member(), typeof_member(), and container_of() in terms of memberof() Alejandro Colomar
2021-11-20 13:00   ` [PATCH v2 10/20] linux/container_of.h: Remove unnecessary cast Alejandro Colomar
2021-11-20 19:05     ` kernel test robot
2021-11-22 17:39     ` kernel test robot
2021-11-20 13:00   ` [PATCH v2 11/20] linux/container_of.h: Cosmetic Alejandro Colomar
2021-11-20 16:12     ` Andy Shevchenko
2021-11-20 16:33       ` Joe Perches
2021-11-20 16:44         ` Alejandro Colomar (man-pages)
2021-11-20 13:00   ` [PATCH v2 12/20] linux/must_be.h: Add must_be() to improve readability of BUILD_BUG_ON_ZERO() Alejandro Colomar
2021-11-20 15:05     ` Alexey Dobriyan
2021-11-20 15:22       ` Alejandro Colomar (man-pages)
2021-11-21 13:18       ` Arnd Bergmann
2021-11-20 13:00   ` [PATCH v2 13/20] Move BUILD_BUG_ON_ZERO to <linux/must_be.h> Alejandro Colomar
2021-11-20 13:00   ` [PATCH v2 13/20] linux/build_bug.h, linux/must_be.h: " Alejandro Colomar
2021-11-20 13:00   ` [PATCH v2 14/20] linux/compiler_types.h, linux/same_type.h: Split __same_type() to a separate header Alejandro Colomar
2021-11-21 13:26     ` Arnd Bergmann
2021-11-20 13:00   ` [PATCH v2 15/20] linux/compiler.h: Implement __must_be_array() in terms of __must_be() Alejandro Colomar
2021-11-21 13:25     ` Arnd Bergmann
2021-11-20 13:01   ` [PATCH v2 16/20] linux/compiler.h, linux/array_size.h: Move __must_be_array() into <linux/array_size.h> Alejandro Colomar
2021-11-21 13:24     ` Arnd Bergmann
2021-11-22  8:51       ` Jani Nikula
2021-11-20 13:01   ` [PATCH v2 17/20] linux/array_size.h: Add __is_array(a) to help readability Alejandro Colomar
2021-11-21 13:22     ` Arnd Bergmann
2021-11-20 13:01   ` [PATCH v2 18/20] linux/power_of_2.h: Add __IS_POWER_OF_2(n) and __IS_POWER_OF_2_OR_0(n) macros Alejandro Colomar
2021-11-21 13:20     ` Arnd Bergmann
2021-11-22  8:55       ` Jani Nikula
2021-11-20 13:01   ` [PATCH v2 19/20] linux/build_bug.h, linux/power_of_2.h: Move [__]BUILD_BUG_ON_NOT_POWER_OF_2() to <linux/power_of_2.h> Alejandro Colomar
2021-11-20 13:01   ` [PATCH v2 20/20] linux/power_of_2.h: Implement [__]BUILD_BUG_ON_NOT_POWER_OF_2() in terms of __IS_POWER_OF_2[_OR_0]() Alejandro Colomar
2021-11-22 11:17   ` [PATCH v2 00/20] Add memberof(), split headers, and simplify code Andy Shevchenko
2021-11-22 12:07     ` Alejandro Colomar (man-pages)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211119113644.1600-17-alx.manpages@gmail.com \
    --to=alx.manpages@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).