Re: [PATCH net-next 4/4] net: ipa: activate some commented assertions

From: Alex Elder
Date: Fri Mar 19 2021 - 08:41:09 EST


On 3/19/21 12:00 AM, Leon Romanovsky wrote:
On Thu, Mar 18, 2021 at 11:29:23PM -0500, Alex Elder wrote:
Convert some commented assertion statements into real calls to
ipa_assert(). If the IPA device pointer is available, provide it,
otherwise pass NULL for that.

There are lots more places to convert, but this serves as an initial
verification of the new mechanism. The assertions here implement
both runtime and build-time assertions, both with and without the
device pointer.

Signed-off-by: Alex Elder <elder@xxxxxxxxxx>
---
drivers/net/ipa/ipa_reg.h | 7 ++++---
drivers/net/ipa/ipa_table.c | 5 ++++-
2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ipa/ipa_reg.h b/drivers/net/ipa/ipa_reg.h
index 732e691e9aa62..d0de85de9f08d 100644
--- a/drivers/net/ipa/ipa_reg.h
+++ b/drivers/net/ipa/ipa_reg.h
@@ -9,6 +9,7 @@
#include <linux/bitfield.h>
#include "ipa_version.h"
+#include "ipa_assert.h"
struct ipa;
@@ -212,7 +213,7 @@ static inline u32 ipa_reg_bcr_val(enum ipa_version version)
BCR_HOLB_DROP_L2_IRQ_FMASK |
BCR_DUAL_TX_FMASK;
- /* assert(version != IPA_VERSION_4_5); */
+ ipa_assert(NULL, version != IPA_VERSION_4_5);

This assert will fire for IPA_VERSION_4_2, I doubt that this is
something you want.

No, it will only fail if version == IPA_VERSION_4_5.
The logic of an assertion is the opposite of BUG_ON().
It fails only if the asserted condition yields false.

-Alex


Thanks