[PATCH] mailbox: bcm-flexrm-mailbox: Remove redundant ternary operators

Liao Yuanhong posted 1 patch 4 weeks ago
drivers/mailbox/bcm-flexrm-mailbox.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
[PATCH] mailbox: bcm-flexrm-mailbox: Remove redundant ternary operators
Posted by Liao Yuanhong 4 weeks ago
For ternary operators in the form of "a ? true : false", if 'a' itself
returns a boolean result, the ternary operator can be omitted. Remove
redundant ternary operators to clean up the code.

Signed-off-by: Liao Yuanhong <liaoyuanhong@vivo.com>
---
 drivers/mailbox/bcm-flexrm-mailbox.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/mailbox/bcm-flexrm-mailbox.c b/drivers/mailbox/bcm-flexrm-mailbox.c
index 41f79e51d9e5..99b4cdfb82bd 100644
--- a/drivers/mailbox/bcm-flexrm-mailbox.c
+++ b/drivers/mailbox/bcm-flexrm-mailbox.c
@@ -329,7 +329,7 @@ static bool flexrm_is_next_table_desc(void *desc_ptr)
 	u64 desc = flexrm_read_desc(desc_ptr);
 	u32 type = DESC_DEC(desc, DESC_TYPE_SHIFT, DESC_TYPE_MASK);
 
-	return (type == NPTR_TYPE) ? true : false;
+	return type == NPTR_TYPE;
 }
 
 static u64 flexrm_next_table_desc(u32 toggle, dma_addr_t next_addr)
@@ -1217,7 +1217,7 @@ static bool flexrm_peek_data(struct mbox_chan *chan)
 {
 	int cnt = flexrm_process_completions(chan->con_priv);
 
-	return (cnt > 0) ? true : false;
+	return cnt > 0;
 }
 
 static int flexrm_startup(struct mbox_chan *chan)
-- 
2.34.1
Re: [PATCH] mailbox: bcm-flexrm-mailbox: Remove redundant ternary operators
Posted by Peng Fan 2 weeks, 1 day ago
On Thu, Sep 04, 2025 at 07:29:26PM +0800, Liao Yuanhong wrote:
>For ternary operators in the form of "a ? true : false", if 'a' itself
>returns a boolean result, the ternary operator can be omitted. Remove
>redundant ternary operators to clean up the code.
>
>Signed-off-by: Liao Yuanhong <liaoyuanhong@vivo.com>

Reviewed-by: Peng Fan <peng.fan@nxp.com>