From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Ingo Molnar <mingo@kernel.org>,
linux-kernel@vger.kernel.org
Cc: Andrew Morton <akpm@linux-foundation.org>
Subject: [rft, PATCH v1 4/4] kernel.h: Split out ARRAY_SZIE()
Date: Mon, 24 Oct 2022 16:24:34 +0300 [thread overview]
Message-ID: <20221024132434.47057-4-andriy.shevchenko@linux.intel.com> (raw)
In-Reply-To: <20221024132434.47057-1-andriy.shevchenko@linux.intel.com>
kernel.h is being used as a dump for all kinds of stuff for a long time.
ARRAY_SIZE() is used in many drivers without need of the full kernel.h
dependency train with it.
Here is the attempt on cleaning it up by splitting out ARRAY_SIZE().
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
include/linux/array_size.h | 13 +++++++++++++
include/linux/kernel.h | 8 +-------
2 files changed, 14 insertions(+), 7 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..c9cdba26555f
--- /dev/null
+++ b/include/linux/array_size.h
@@ -0,0 +1,13 @@
+/* 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/kernel.h b/include/linux/kernel.h
index 7e9612de01b8..011eab2b0e93 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -17,7 +17,7 @@
#include <linux/linkage.h>
#include <linux/stddef.h>
#include <linux/types.h>
-#include <linux/compiler.h>
+#include <linux/array_size.h>
#include <linux/container_of.h>
#include <linux/bitops.h>
#include <linux/hex.h>
@@ -46,12 +46,6 @@
*/
#define REPEAT_BYTE(x) ((~0ul / 0xff) * (x))
-/**
- * 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) ( \
--
2.35.1
next prev parent reply other threads:[~2022-10-24 15:22 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-24 13:24 [rft, PATCH v1 1/4] kernel.h: Move READ/WRITE definitions to <linux/types.h> Andy Shevchenko
2022-10-24 13:24 ` [rft, PATCH v1 2/4] kernel.h: Split the hexadecimal related helpers to hex.h Andy Shevchenko
2022-10-24 13:24 ` [rft, PATCH v1 3/4] kernel.h: Split out sprintf() and friends Andy Shevchenko
2022-10-24 13:24 ` Andy Shevchenko [this message]
-- strict thread matches above, loose matches on Subject: below --
2022-10-24 15:44 [rft, PATCH v1 4/4] kernel.h: Split out ARRAY_SZIE() Alexey Dobriyan
2022-10-24 16:05 ` Andy Shevchenko
2022-10-24 16:06 ` Andy Shevchenko
2022-10-24 18:14 ` Alexey Dobriyan
2022-10-25 8:20 ` Andy Shevchenko
2022-10-29 10:05 ` Alexey Dobriyan
2022-10-30 21:52 ` Andy Shevchenko
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=20221024132434.47057-4-andriy.shevchenko@linux.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@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