All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alex Elder <elder@linaro.org>
To: davem@davemloft.net, arnd@arndb.de, bjorn.andersson@linaro.org,
	ilias.apalodimas@linaro.org
Cc: evgreen@chromium.org, benchan@google.com, ejcaruso@google.com,
	cpratapa@codeaurora.org, syadagir@codeaurora.org,
	subashab@codeaurora.org, abhishek.esse@gmail.com,
	netdev@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-soc@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-arm-msm@vger.kernel.org
Subject: [PATCH v2 01/17] bitfield.h: add FIELD_MAX() and field_max()
Date: Thu, 30 May 2019 22:53:32 -0500	[thread overview]
Message-ID: <20190531035348.7194-2-elder@linaro.org> (raw)
In-Reply-To: <20190531035348.7194-1-elder@linaro.org>

Define FIELD_MAX(), which supplies the maximum value that can be
represented by a field value.  Define field_max() as well, to go
along with the lower-case forms of the field mask functions.

Signed-off-by: Alex Elder <elder@linaro.org>
---
 include/linux/bitfield.h | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/include/linux/bitfield.h b/include/linux/bitfield.h
index 3f1ef4450a7c..cf4f06774520 100644
--- a/include/linux/bitfield.h
+++ b/include/linux/bitfield.h
@@ -63,6 +63,19 @@
 					      (1ULL << __bf_shf(_mask))); \
 	})
 
+/**
+ * FIELD_MAX() - produce the maximum value representable by a field
+ * @_mask: shifted mask defining the field's length and position
+ *
+ * FIELD_MAX() returns the maximum value that can be held in the field
+ * specified by @_mask.
+ */
+#define FIELD_MAX(_mask)						\
+	({								\
+		__BF_FIELD_CHECK(_mask, 0ULL, 0ULL, "FIELD_MAX: ");	\
+		(typeof(_mask))((_mask) >> __bf_shf(_mask));		\
+	})
+
 /**
  * FIELD_FIT() - check if value fits in the field
  * @_mask: shifted mask defining the field's length and position
@@ -118,6 +131,7 @@ static __always_inline u64 field_mask(u64 field)
 {
 	return field / field_multiplier(field);
 }
+#define field_max(field)	((typeof(field))field_mask(field))
 #define ____MAKE_OP(type,base,to,from)					\
 static __always_inline __##type type##_encode_bits(base v, base field)	\
 {									\
-- 
2.20.1


WARNING: multiple messages have this Message-ID (diff)
From: Alex Elder <elder@linaro.org>
To: davem@davemloft.net, arnd@arndb.de, bjorn.andersson@linaro.org,
	ilias.apalodimas@linaro.org
Cc: devicetree@vger.kernel.org, syadagir@codeaurora.org,
	ejcaruso@google.com, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, evgreen@chromium.org,
	linux-arm-kernel@lists.infradead.org,
	linux-arm-msm@vger.kernel.org, subashab@codeaurora.org,
	linux-soc@vger.kernel.org, abhishek.esse@gmail.com,
	cpratapa@codeaurora.org, benchan@google.com
Subject: [PATCH v2 01/17] bitfield.h: add FIELD_MAX() and field_max()
Date: Thu, 30 May 2019 22:53:32 -0500	[thread overview]
Message-ID: <20190531035348.7194-2-elder@linaro.org> (raw)
In-Reply-To: <20190531035348.7194-1-elder@linaro.org>

Define FIELD_MAX(), which supplies the maximum value that can be
represented by a field value.  Define field_max() as well, to go
along with the lower-case forms of the field mask functions.

Signed-off-by: Alex Elder <elder@linaro.org>
---
 include/linux/bitfield.h | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/include/linux/bitfield.h b/include/linux/bitfield.h
index 3f1ef4450a7c..cf4f06774520 100644
--- a/include/linux/bitfield.h
+++ b/include/linux/bitfield.h
@@ -63,6 +63,19 @@
 					      (1ULL << __bf_shf(_mask))); \
 	})
 
+/**
+ * FIELD_MAX() - produce the maximum value representable by a field
+ * @_mask: shifted mask defining the field's length and position
+ *
+ * FIELD_MAX() returns the maximum value that can be held in the field
+ * specified by @_mask.
+ */
+#define FIELD_MAX(_mask)						\
+	({								\
+		__BF_FIELD_CHECK(_mask, 0ULL, 0ULL, "FIELD_MAX: ");	\
+		(typeof(_mask))((_mask) >> __bf_shf(_mask));		\
+	})
+
 /**
  * FIELD_FIT() - check if value fits in the field
  * @_mask: shifted mask defining the field's length and position
@@ -118,6 +131,7 @@ static __always_inline u64 field_mask(u64 field)
 {
 	return field / field_multiplier(field);
 }
+#define field_max(field)	((typeof(field))field_mask(field))
 #define ____MAKE_OP(type,base,to,from)					\
 static __always_inline __##type type##_encode_bits(base v, base field)	\
 {									\
-- 
2.20.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2019-05-31  3:56 UTC|newest]

Thread overview: 227+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-31  3:53 [PATCH v2 00/17] net: introduce Qualcomm IPA driver Alex Elder
2019-05-31  3:53 ` Alex Elder
2019-05-31  3:53 ` Alex Elder [this message]
2019-05-31  3:53   ` [PATCH v2 01/17] bitfield.h: add FIELD_MAX() and field_max() Alex Elder
2019-05-31  3:53 ` [PATCH v2 02/17] dt-bindings: soc: qcom: add IPA bindings Alex Elder
2019-05-31  3:53   ` Alex Elder
2019-05-31  3:53   ` Alex Elder
2019-06-10 22:08   ` Rob Herring
2019-06-10 22:08     ` Rob Herring
2019-06-11  2:11     ` Alex Elder
2019-06-11  2:11       ` Alex Elder
2019-07-03 15:09       ` Alex Elder
2019-07-03 15:09         ` Alex Elder
2019-05-31  3:53 ` [PATCH v2 03/17] soc: qcom: ipa: main code Alex Elder
2019-05-31  3:53   ` Alex Elder
2019-05-31 21:50   ` David Miller
2019-05-31 21:50     ` David Miller
2019-05-31 22:25     ` Alex Elder
2019-05-31 22:25       ` Alex Elder
2019-05-31  3:53 ` [PATCH v2 04/17] soc: qcom: ipa: configuration data Alex Elder
2019-05-31  3:53   ` Alex Elder
2019-05-31  3:53 ` [PATCH v2 05/17] soc: qcom: ipa: clocking, interrupts, and memory Alex Elder
2019-05-31  3:53   ` Alex Elder
2019-05-31  3:53 ` [PATCH v2 06/17] soc: qcom: ipa: GSI headers Alex Elder
2019-05-31  3:53   ` Alex Elder
2019-05-31  3:53 ` [PATCH v2 07/17] soc: qcom: ipa: the generic software interface Alex Elder
2019-05-31  3:53   ` Alex Elder
2019-05-31  3:53 ` [PATCH v2 08/17] soc: qcom: ipa: GSI transactions Alex Elder
2019-05-31  3:53   ` Alex Elder
2019-05-31  3:53 ` [PATCH v2 09/17] soc: qcom: ipa: IPA interface to GSI Alex Elder
2019-05-31  3:53   ` Alex Elder
2019-05-31  3:53 ` [PATCH v2 10/17] soc: qcom: ipa: IPA endpoints Alex Elder
2019-05-31  3:53   ` Alex Elder
2019-05-31  3:53 ` [PATCH v2 11/17] soc: qcom: ipa: immediate commands Alex Elder
2019-05-31  3:53   ` Alex Elder
2019-05-31  3:53 ` [PATCH v2 12/17] soc: qcom: ipa: IPA network device and microcontroller Alex Elder
2019-05-31  3:53   ` Alex Elder
2019-05-31  3:53 ` [PATCH v2 13/17] soc: qcom: ipa: AP/modem communications Alex Elder
2019-05-31  3:53   ` Alex Elder
2019-05-31  3:53 ` [PATCH v2 14/17] soc: qcom: ipa: support build of IPA code Alex Elder
2019-05-31  3:53   ` Alex Elder
2019-05-31  3:53 ` [PATCH v2 15/17] MAINTAINERS: add entry for the Qualcomm IPA driver Alex Elder
2019-05-31  3:53   ` Alex Elder
2019-05-31  3:53 ` [PATCH v2 16/17] arm64: dts: sdm845: add IPA information Alex Elder
2019-05-31  3:53   ` Alex Elder
2019-05-31  3:53 ` [PATCH v2 17/17] arm64: defconfig: enable build of IPA code Alex Elder
2019-05-31  3:53   ` Alex Elder
2019-05-31 14:58 ` [PATCH v2 00/17] net: introduce Qualcomm IPA driver Dan Williams
2019-05-31 14:58   ` Dan Williams
2019-05-31 16:36   ` Alex Elder
2019-05-31 16:36     ` Alex Elder
2019-05-31 19:19     ` Arnd Bergmann
2019-05-31 19:19       ` Arnd Bergmann
2019-05-31 20:47       ` Alex Elder
2019-05-31 20:47         ` Alex Elder
2019-05-31 21:12         ` Arnd Bergmann
2019-05-31 21:12           ` Arnd Bergmann
2019-05-31 22:08           ` Alex Elder
2019-05-31 22:08             ` Alex Elder
2019-06-07 17:43             ` Alex Elder
2019-06-07 17:43               ` Alex Elder
2019-05-31 23:33         ` Bjorn Andersson
2019-05-31 23:33           ` Bjorn Andersson
2019-05-31 23:59           ` Subash Abhinov Kasiviswanathan
2019-05-31 23:59             ` Subash Abhinov Kasiviswanathan
2019-06-03 10:04             ` Arnd Bergmann
2019-06-03 10:04               ` Arnd Bergmann
2019-06-03 13:32               ` Alex Elder
2019-06-03 13:32                 ` Alex Elder
2019-06-04  8:13                 ` Arnd Bergmann
2019-06-04  8:13                   ` Arnd Bergmann
2019-06-04 15:18                   ` Dan Williams
2019-06-04 15:18                     ` Dan Williams
2019-06-04 20:04                     ` Arnd Bergmann
2019-06-04 20:04                       ` Arnd Bergmann
2019-06-04 21:29                       ` Dan Williams
2019-06-04 21:29                         ` Dan Williams
2019-06-06 17:42                         ` Alex Elder
2019-06-06 17:42                           ` Alex Elder
2019-06-11  8:12                           ` Johannes Berg
2019-06-11  8:12                             ` Johannes Berg
2019-06-11 11:56                             ` Arnd Bergmann
2019-06-11 11:56                               ` Arnd Bergmann
2019-06-11 15:53                               ` Dan Williams
2019-06-11 15:53                                 ` Dan Williams
2019-06-11 16:52                                 ` Subash Abhinov Kasiviswanathan
2019-06-11 16:52                                   ` Subash Abhinov Kasiviswanathan
2019-06-11 17:22                                   ` Dan Williams
2019-06-11 17:22                                     ` Dan Williams
2019-06-12  8:31                                     ` Arnd Bergmann
2019-06-12  8:31                                       ` Arnd Bergmann
2019-06-12 14:27                                       ` Dan Williams
2019-06-12 14:27                                         ` Dan Williams
2019-06-12 15:06                                         ` Arnd Bergmann
2019-06-12 15:06                                           ` Arnd Bergmann
2019-06-17 11:42                                           ` Johannes Berg
2019-06-17 11:42                                             ` Johannes Berg
2019-06-17 12:25                                             ` Johannes Berg
2019-06-17 12:25                                               ` Johannes Berg
2019-06-17 12:25                                               ` Johannes Berg
2019-06-18 15:20                                               ` Alex Elder
2019-06-18 15:20                                                 ` Alex Elder
2019-06-18 18:06                                                 ` Dan Williams
2019-06-18 18:06                                                   ` Dan Williams
2019-06-24 16:21                                                   ` Alex Elder
2019-06-24 16:21                                                     ` Alex Elder
2019-06-25 14:14                                                     ` Johannes Berg
2019-06-25 14:14                                                       ` Johannes Berg
2019-06-26 13:36                                                       ` Alex Elder
2019-06-26 13:36                                                         ` Alex Elder
2019-06-26 17:55                                                         ` Johannes Berg
2019-06-26 17:55                                                           ` Johannes Berg
2019-06-26 17:55                                                           ` Johannes Berg
2019-06-18 18:48                                                 ` Johannes Berg
2019-06-18 18:48                                                   ` Johannes Berg
2019-06-24 16:21                                                   ` Alex Elder
2019-06-24 16:21                                                     ` Alex Elder
2019-06-18 13:45                                             ` Alex Elder
2019-06-18 13:45                                               ` Alex Elder
2019-06-18 19:03                                               ` Johannes Berg
2019-06-18 19:03                                                 ` Johannes Berg
2019-06-18 20:09                                                 ` Arnd Bergmann
2019-06-18 20:09                                                   ` Arnd Bergmann
2019-06-18 20:15                                                   ` Johannes Berg
2019-06-18 20:15                                                     ` Johannes Berg
2019-06-18 20:15                                                     ` Johannes Berg
2019-06-18 20:33                                                     ` Arnd Bergmann
2019-06-18 20:33                                                       ` Arnd Bergmann
2019-06-18 20:33                                                       ` Arnd Bergmann
2019-06-18 20:39                                                       ` Johannes Berg
2019-06-18 20:39                                                         ` Johannes Berg
2019-06-18 21:06                                                         ` Arnd Bergmann
2019-06-18 21:06                                                           ` Arnd Bergmann
2019-06-19 20:56                                                           ` Dan Williams
2019-06-19 20:56                                                             ` Dan Williams
2019-06-24 16:21                                                 ` Alex Elder
2019-06-24 16:21                                                   ` Alex Elder
2019-06-24 16:40                                                   ` Arnd Bergmann
2019-06-24 16:40                                                     ` Arnd Bergmann
2019-06-25 14:19                                                     ` Johannes Berg
2019-06-25 14:19                                                       ` Johannes Berg
2019-06-26 13:39                                                       ` Alex Elder
2019-06-26 13:39                                                         ` Alex Elder
2019-06-26 13:58                                                         ` Arnd Bergmann
2019-06-26 13:58                                                           ` Arnd Bergmann
2019-06-26 17:48                                                           ` Johannes Berg
2019-06-26 17:48                                                             ` Johannes Berg
2019-06-26 17:45                                                         ` Johannes Berg
2019-06-26 17:45                                                           ` Johannes Berg
2019-06-26 17:45                                                           ` Johannes Berg
2019-06-26 13:51                                                     ` Alex Elder
2019-06-26 13:51                                                       ` Alex Elder
2019-06-17 11:28                               ` Johannes Berg
2019-06-17 11:28                                 ` Johannes Berg
2019-06-17 11:28                                 ` Johannes Berg
2019-06-18 13:16                                 ` Alex Elder
2019-06-18 13:16                                   ` Alex Elder
2019-06-18 13:48                                   ` Arnd Bergmann
2019-06-18 13:48                                     ` Arnd Bergmann
2019-06-18 19:14                                   ` Johannes Berg
2019-06-18 19:14                                     ` Johannes Berg
2019-06-18 19:14                                     ` Johannes Berg
2019-06-18 19:59                                     ` Arnd Bergmann
2019-06-18 19:59                                       ` Arnd Bergmann
2019-06-18 19:59                                       ` Arnd Bergmann
2019-06-18 20:36                                       ` Johannes Berg
2019-06-18 20:36                                         ` Johannes Berg
2019-06-18 20:55                                         ` Arnd Bergmann
2019-06-18 20:55                                           ` Arnd Bergmann
2019-06-18 20:55                                           ` Arnd Bergmann
2019-06-18 21:02                                           ` Johannes Berg
2019-06-18 21:02                                             ` Johannes Berg
2019-06-18 21:02                                             ` Johannes Berg
2019-06-18 21:15                                           ` Subash Abhinov Kasiviswanathan
2019-06-18 21:15                                             ` Subash Abhinov Kasiviswanathan
2019-06-19 12:23                                             ` Arnd Bergmann
2019-06-19 12:23                                               ` Arnd Bergmann
2019-06-19 18:47                                               ` Subash Abhinov Kasiviswanathan
2019-06-19 18:47                                                 ` Subash Abhinov Kasiviswanathan
2019-06-20  1:25                                                 ` Dan Williams
2019-06-20  1:25                                                   ` Dan Williams
2019-06-20  1:25                                                   ` Dan Williams
2019-06-24 16:21                                     ` Alex Elder
2019-06-24 16:21                                       ` Alex Elder
2019-06-17 12:14                               ` Johannes Berg
2019-06-17 12:14                                 ` Johannes Berg
2019-06-18 14:00                                 ` Alex Elder
2019-06-18 14:00                                   ` Alex Elder
2019-06-18 19:22                                   ` Johannes Berg
2019-06-18 19:22                                     ` Johannes Berg
2019-06-18 19:22                                     ` Johannes Berg
2019-06-24 16:21                                     ` Alex Elder
2019-06-24 16:21                                       ` Alex Elder
2019-06-03 14:50             ` Dan Williams
2019-06-03 14:50               ` Dan Williams
2019-06-03 14:54         ` Dan Williams
2019-06-03 14:54           ` Dan Williams
2019-06-03 15:52           ` Alex Elder
2019-06-03 15:52             ` Alex Elder
2019-06-03 16:18             ` Dan Williams
2019-06-03 16:18               ` Dan Williams
2019-06-03 19:04               ` Subash Abhinov Kasiviswanathan
2019-06-03 19:04                 ` Subash Abhinov Kasiviswanathan
2019-06-04 15:21                 ` Dan Williams
2019-06-04 15:21                   ` Dan Williams
2019-05-31 23:27       ` Bjorn Andersson
2019-05-31 23:27         ` Bjorn Andersson
2019-05-31 23:27         ` Bjorn Andersson
2019-06-10  2:44 ` Alex Elder
2019-06-10  2:44   ` Alex Elder
2019-06-20 13:41 ` [PATCH v2 05/17] soc: qcom: ipa: clocking, interrupts, and memory Hillf Danton
2019-06-20 13:41   ` Hillf Danton
2019-06-24 16:30 ` WWAN Controller Framework (was IPA [PATCH v2 00/17]) Alex Elder
2019-06-24 16:30   ` Alex Elder
2019-06-24 17:06   ` Alex Elder
2019-06-24 17:06     ` Alex Elder
2019-06-25 14:34     ` Johannes Berg
2019-06-25 14:34       ` Johannes Berg
2019-06-26 13:40       ` Alex Elder
2019-06-26 13:40         ` Alex Elder
2019-06-26 17:58         ` Johannes Berg
2019-06-26 17:58           ` Johannes Berg
2019-06-24 19:54   ` Dan Williams
2019-06-24 19:54     ` Dan Williams
2019-06-24 21:16     ` Alex Elder
2019-06-24 21:16       ` Alex Elder
2019-06-24 21:16       ` Alex Elder

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=20190531035348.7194-2-elder@linaro.org \
    --to=elder@linaro.org \
    --cc=abhishek.esse@gmail.com \
    --cc=arnd@arndb.de \
    --cc=benchan@google.com \
    --cc=bjorn.andersson@linaro.org \
    --cc=cpratapa@codeaurora.org \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=ejcaruso@google.com \
    --cc=evgreen@chromium.org \
    --cc=ilias.apalodimas@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-soc@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=subashab@codeaurora.org \
    --cc=syadagir@codeaurora.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.