[PATCH] reset: canaan: Remove redundant ternary operators

Liao Yuanhong posted 1 patch 1 month ago
drivers/reset/reset-k230.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
[PATCH] reset: canaan: Remove redundant ternary operators
Posted by Liao Yuanhong 1 month 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/reset/reset-k230.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/reset/reset-k230.c b/drivers/reset/reset-k230.c
index c81045bb4a14..2eb16aac60c0 100644
--- a/drivers/reset/reset-k230.c
+++ b/drivers/reset/reset-k230.c
@@ -218,7 +218,7 @@ static int k230_rst_assert(struct reset_controller_dev *rcdev, unsigned long id)
 		break;
 	case RST_TYPE_SW_DONE:
 		k230_rst_update(rstc, id, true, false,
-				id == RST_SPI2AXI ? false : true);
+				id != RST_SPI2AXI);
 		break;
 	case RST_TYPE_CPU0:
 	case RST_TYPE_FLUSH:
@@ -249,7 +249,7 @@ static int k230_rst_deassert(struct reset_controller_dev *rcdev,
 		break;
 	case RST_TYPE_SW_DONE:
 		k230_rst_update(rstc, id, false, false,
-				id == RST_SPI2AXI ? false : true);
+				id != RST_SPI2AXI);
 		break;
 	case RST_TYPE_CPU0:
 	case RST_TYPE_FLUSH:
-- 
2.34.1
Re: [PATCH] reset: canaan: Remove redundant ternary operators
Posted by Philipp Zabel 1 month ago
On Do, 2025-08-28 at 20:28 +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.

Here you are replacing "a ? false : true" with "!a", though.

> Remove
> redundant ternary operators to clean up the code.
> 
> Signed-off-by: Liao Yuanhong <liaoyuanhong@vivo.com>
> ---
>  drivers/reset/reset-k230.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/reset/reset-k230.c b/drivers/reset/reset-k230.c
> index c81045bb4a14..2eb16aac60c0 100644
> --- a/drivers/reset/reset-k230.c
> +++ b/drivers/reset/reset-k230.c
> @@ -218,7 +218,7 @@ static int k230_rst_assert(struct reset_controller_dev *rcdev, unsigned long id)
>  		break;
>  	case RST_TYPE_SW_DONE:
>  		k230_rst_update(rstc, id, true, false,
> -				id == RST_SPI2AXI ? false : true);
> +				id != RST_SPI2AXI);

Remove the line break. The line is short enough. Same for the other
occurrence.

regards
Philipp