* [PATCH] reset: canaan: Remove redundant ternary operators
@ 2025-08-28 12:28 Liao Yuanhong
2025-08-28 13:10 ` Philipp Zabel
0 siblings, 1 reply; 2+ messages in thread
From: Liao Yuanhong @ 2025-08-28 12:28 UTC (permalink / raw)
To: Philipp Zabel, open list; +Cc: Liao Yuanhong
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] reset: canaan: Remove redundant ternary operators
2025-08-28 12:28 [PATCH] reset: canaan: Remove redundant ternary operators Liao Yuanhong
@ 2025-08-28 13:10 ` Philipp Zabel
0 siblings, 0 replies; 2+ messages in thread
From: Philipp Zabel @ 2025-08-28 13:10 UTC (permalink / raw)
To: Liao Yuanhong, open list
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-08-28 13:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-28 12:28 [PATCH] reset: canaan: Remove redundant ternary operators Liao Yuanhong
2025-08-28 13:10 ` Philipp Zabel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).