dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/6] drm/amdgpu: Remove redundant ternary operators
@ 2025-09-03 12:03 Liao Yuanhong
  2025-09-03 12:03 ` [PATCH 1/6] drm/amdgpu/amdgpu_cper: " Liao Yuanhong
                   ` (6 more replies)
  0 siblings, 7 replies; 9+ messages in thread
From: Liao Yuanhong @ 2025-09-03 12:03 UTC (permalink / raw)
  To: Alex Deucher, Christian König, David Airlie, Simona Vetter,
	Tao Zhou, Xiang Liu, Hawking Zhang, Yang Wang, Victor Skvortsov,
	Colin Ian King, Sunil Khatri, Lijo Lazar, Shashank Sharma,
	Srinivasan Shanmugam, Prike Liang, Rodrigo Siqueira, Jesse.Zhang,
	Felix Kuehling, Boyuan Zhang, Kent Russell, André Almeida,
	Tim Huang, Yifan Zhang, Natalie Vock, Candice Li, Shaoyun Liu,
	David Belanger, Emily Deng, Sathishkumar S, David (Ming Qiang) Wu,
	Leo Liu, Stanley.Yang, Mangesh Gadre, fanhuang,
	Saleemkhan Jamadar, open list:RADEON and AMDGPU DRM DRIVERS,
	open list:DRM DRIVERS, open list
  Cc: Liao Yuanhong

For ternary operators in the form of "a ? true : false" or
"a ? false : true", if 'a' itself returns a boolean result, the ternary
operator can be omitted. Remove redundant ternary operators to clean up the
code.

Liao Yuanhong (6):
  drm/amdgpu/amdgpu_cper: Remove redundant ternary operators
  drm/amdgpu/gfx: Remove redundant ternary operators
  drm/amdgpu/gmc: Remove redundant ternary operators
  drm/amdgpu/ih: Remove redundant ternary operators
  drm/amdgpu/jpeg: Remove redundant ternary operators
  drm/amdgpu/vcn: Remove redundant ternary operators

 drivers/gpu/drm/amd/amdgpu/amdgpu_cper.c | 2 +-
 drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c   | 3 +--
 drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c   | 3 +--
 drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c   | 3 +--
 drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c   | 3 +--
 drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c   | 3 +--
 drivers/gpu/drm/amd/amdgpu/ih_v6_0.c     | 3 +--
 drivers/gpu/drm/amd/amdgpu/ih_v6_1.c     | 3 +--
 drivers/gpu/drm/amd/amdgpu/ih_v7_0.c     | 3 +--
 drivers/gpu/drm/amd/amdgpu/jpeg_v4_0_5.c | 2 +-
 drivers/gpu/drm/amd/amdgpu/jpeg_v5_0_0.c | 2 +-
 drivers/gpu/drm/amd/amdgpu/jpeg_v5_0_1.c | 2 +-
 drivers/gpu/drm/amd/amdgpu/vcn_v4_0_5.c  | 2 +-
 drivers/gpu/drm/amd/amdgpu/vcn_v5_0_0.c  | 2 +-
 14 files changed, 14 insertions(+), 22 deletions(-)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 1/6] drm/amdgpu/amdgpu_cper: Remove redundant ternary operators
  2025-09-03 12:03 [PATCH 0/6] drm/amdgpu: Remove redundant ternary operators Liao Yuanhong
@ 2025-09-03 12:03 ` Liao Yuanhong
  2025-09-03 12:03 ` [PATCH 2/6] drm/amdgpu/gfx: " Liao Yuanhong
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Liao Yuanhong @ 2025-09-03 12:03 UTC (permalink / raw)
  To: Alex Deucher, Christian König, David Airlie, Simona Vetter,
	Tao Zhou, Xiang Liu, Hawking Zhang, Yang Wang, Colin Ian King,
	Victor Skvortsov, open list:RADEON and AMDGPU DRM DRIVERS,
	open list:DRM DRIVERS, open list
  Cc: Liao Yuanhong

For ternary operators in the form of "a ? false : true", 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/gpu/drm/amd/amdgpu/amdgpu_cper.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cper.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cper.c
index 6c266f18c598..c4590ec35cad 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cper.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cper.c
@@ -174,7 +174,7 @@ int amdgpu_cper_entry_fill_runtime_section(struct amdgpu_device *adev,
 	struct cper_sec_nonstd_err *section;
 	bool poison;
 
-	poison = (sev == CPER_SEV_NON_FATAL_CORRECTED) ? false : true;
+	poison = sev != CPER_SEV_NON_FATAL_CORRECTED;
 	section_desc = (struct cper_sec_desc *)((uint8_t *)hdr + SEC_DESC_OFFSET(idx));
 	section = (struct cper_sec_nonstd_err *)((uint8_t *)hdr +
 		   NONSTD_SEC_OFFSET(hdr->sec_cnt, idx));
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 2/6] drm/amdgpu/gfx: Remove redundant ternary operators
  2025-09-03 12:03 [PATCH 0/6] drm/amdgpu: Remove redundant ternary operators Liao Yuanhong
  2025-09-03 12:03 ` [PATCH 1/6] drm/amdgpu/amdgpu_cper: " Liao Yuanhong
@ 2025-09-03 12:03 ` Liao Yuanhong
  2025-09-03 12:03 ` [PATCH 3/6] drm/amdgpu/gmc: " Liao Yuanhong
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Liao Yuanhong @ 2025-09-03 12:03 UTC (permalink / raw)
  To: Alex Deucher, Christian König, David Airlie, Simona Vetter,
	Sunil Khatri, Lijo Lazar, Shashank Sharma, Srinivasan Shanmugam,
	Prike Liang, Rodrigo Siqueira, Jesse.Zhang,
	open list:RADEON and AMDGPU DRM DRIVERS, open list:DRM DRIVERS,
	open list
  Cc: Liao Yuanhong

For ternary operators in the form of "a ? false : true", 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/gpu/drm/amd/amdgpu/gfx_v11_0.c | 3 +--
 drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
index c85de8c8f6f5..3d9c045a8a64 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
@@ -4643,8 +4643,7 @@ static int gfx_v11_0_gfxhub_enable(struct amdgpu_device *adev)
 
 	amdgpu_device_flush_hdp(adev, NULL);
 
-	value = (amdgpu_vm_fault_stop == AMDGPU_VM_FAULT_STOP_ALWAYS) ?
-		false : true;
+	value = amdgpu_vm_fault_stop != AMDGPU_VM_FAULT_STOP_ALWAYS;
 
 	adev->gfxhub.funcs->set_fault_enable_default(adev, value);
 	/* TODO investigate why this and the hdp flush above is needed,
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c
index fd44d5503e28..5dbc5dbc694a 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c
@@ -3524,8 +3524,7 @@ static int gfx_v12_0_gfxhub_enable(struct amdgpu_device *adev)
 
 	amdgpu_device_flush_hdp(adev, NULL);
 
-	value = (amdgpu_vm_fault_stop == AMDGPU_VM_FAULT_STOP_ALWAYS) ?
-		false : true;
+	value = amdgpu_vm_fault_stop != AMDGPU_VM_FAULT_STOP_ALWAYS;
 
 	adev->gfxhub.funcs->set_fault_enable_default(adev, value);
 	/* TODO investigate why this and the hdp flush above is needed,
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 3/6] drm/amdgpu/gmc: Remove redundant ternary operators
  2025-09-03 12:03 [PATCH 0/6] drm/amdgpu: Remove redundant ternary operators Liao Yuanhong
  2025-09-03 12:03 ` [PATCH 1/6] drm/amdgpu/amdgpu_cper: " Liao Yuanhong
  2025-09-03 12:03 ` [PATCH 2/6] drm/amdgpu/gfx: " Liao Yuanhong
@ 2025-09-03 12:03 ` Liao Yuanhong
  2025-09-03 12:03 ` [PATCH 4/6] drm/amdgpu/ih: " Liao Yuanhong
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Liao Yuanhong @ 2025-09-03 12:03 UTC (permalink / raw)
  To: Alex Deucher, Christian König, David Airlie, Simona Vetter,
	Sunil Khatri, Felix Kuehling, Lijo Lazar, Boyuan Zhang,
	Kent Russell, André Almeida, Tim Huang, Yifan Zhang,
	David Belanger, Candice Li, Shaoyun Liu, Natalie Vock,
	open list:RADEON and AMDGPU DRM DRIVERS, open list:DRM DRIVERS,
	open list
  Cc: Liao Yuanhong

For ternary operators in the form of "a ? false : true", 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/gpu/drm/amd/amdgpu/gmc_v10_0.c | 3 +--
 drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c | 3 +--
 drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c | 3 +--
 3 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c
index 7031dd8c3c5e..d7499be8c4bf 100644
--- a/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c
@@ -963,8 +963,7 @@ static int gmc_v10_0_gart_enable(struct amdgpu_device *adev)
 	/* Flush HDP after it is initialized */
 	amdgpu_device_flush_hdp(adev, NULL);
 
-	value = (amdgpu_vm_fault_stop == AMDGPU_VM_FAULT_STOP_ALWAYS) ?
-		false : true;
+	value = amdgpu_vm_fault_stop != AMDGPU_VM_FAULT_STOP_ALWAYS;
 
 	if (!adev->in_s0ix)
 		adev->gfxhub.funcs->set_fault_enable_default(adev, value);
diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c
index 93d2b0bbe641..7bc389d9f5c4 100644
--- a/drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c
@@ -905,8 +905,7 @@ static int gmc_v11_0_gart_enable(struct amdgpu_device *adev)
 	/* Flush HDP after it is initialized */
 	amdgpu_device_flush_hdp(adev, NULL);
 
-	value = (amdgpu_vm_fault_stop == AMDGPU_VM_FAULT_STOP_ALWAYS) ?
-		false : true;
+	value = amdgpu_vm_fault_stop != AMDGPU_VM_FAULT_STOP_ALWAYS;
 
 	adev->mmhub.funcs->set_fault_enable_default(adev, value);
 	gmc_v11_0_flush_gpu_tlb(adev, 0, AMDGPU_MMHUB0(0), 0);
diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c
index 9ba055ddc00f..76d3c40735b0 100644
--- a/drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c
@@ -893,8 +893,7 @@ static int gmc_v12_0_gart_enable(struct amdgpu_device *adev)
 	/* Flush HDP after it is initialized */
 	amdgpu_device_flush_hdp(adev, NULL);
 
-	value = (amdgpu_vm_fault_stop == AMDGPU_VM_FAULT_STOP_ALWAYS) ?
-		false : true;
+	value = amdgpu_vm_fault_stop != AMDGPU_VM_FAULT_STOP_ALWAYS;
 
 	adev->mmhub.funcs->set_fault_enable_default(adev, value);
 	gmc_v12_0_flush_gpu_tlb(adev, 0, AMDGPU_MMHUB0(0), 0);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 4/6] drm/amdgpu/ih: Remove redundant ternary operators
  2025-09-03 12:03 [PATCH 0/6] drm/amdgpu: Remove redundant ternary operators Liao Yuanhong
                   ` (2 preceding siblings ...)
  2025-09-03 12:03 ` [PATCH 3/6] drm/amdgpu/gmc: " Liao Yuanhong
@ 2025-09-03 12:03 ` Liao Yuanhong
  2025-09-03 12:03 ` [PATCH 5/6] drm/amdgpu/jpeg: " Liao Yuanhong
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Liao Yuanhong @ 2025-09-03 12:03 UTC (permalink / raw)
  To: Alex Deucher, Christian König, David Airlie, Simona Vetter,
	Sunil Khatri, Boyuan Zhang, Emily Deng,
	open list:RADEON and AMDGPU DRM DRIVERS, open list:DRM DRIVERS,
	open list
  Cc: Liao Yuanhong

For ternary operators in the form of "a ? false : true", 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/gpu/drm/amd/amdgpu/ih_v6_0.c | 3 +--
 drivers/gpu/drm/amd/amdgpu/ih_v6_1.c | 3 +--
 drivers/gpu/drm/amd/amdgpu/ih_v7_0.c | 3 +--
 3 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/ih_v6_0.c b/drivers/gpu/drm/amd/amdgpu/ih_v6_0.c
index 5900b560b7de..333e9c30c091 100644
--- a/drivers/gpu/drm/amd/amdgpu/ih_v6_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/ih_v6_0.c
@@ -587,8 +587,7 @@ static int ih_v6_0_sw_init(struct amdgpu_ip_block *ip_block)
 	/* use gpu virtual address for ih ring
 	 * until ih_checken is programmed to allow
 	 * use bus address for ih ring by psp bl */
-	use_bus_addr =
-		(adev->firmware.load_type == AMDGPU_FW_LOAD_PSP) ? false : true;
+	use_bus_addr = adev->firmware.load_type != AMDGPU_FW_LOAD_PSP;
 	r = amdgpu_ih_ring_init(adev, &adev->irq.ih, IH_RING_SIZE, use_bus_addr);
 	if (r)
 		return r;
diff --git a/drivers/gpu/drm/amd/amdgpu/ih_v6_1.c b/drivers/gpu/drm/amd/amdgpu/ih_v6_1.c
index 068ed849dbad..95b3f4e55ec3 100644
--- a/drivers/gpu/drm/amd/amdgpu/ih_v6_1.c
+++ b/drivers/gpu/drm/amd/amdgpu/ih_v6_1.c
@@ -562,8 +562,7 @@ static int ih_v6_1_sw_init(struct amdgpu_ip_block *ip_block)
 	/* use gpu virtual address for ih ring
 	 * until ih_checken is programmed to allow
 	 * use bus address for ih ring by psp bl */
-	use_bus_addr =
-		(adev->firmware.load_type == AMDGPU_FW_LOAD_PSP) ? false : true;
+	use_bus_addr = adev->firmware.load_type != AMDGPU_FW_LOAD_PSP;
 	r = amdgpu_ih_ring_init(adev, &adev->irq.ih, 256 * 1024, use_bus_addr);
 	if (r)
 		return r;
diff --git a/drivers/gpu/drm/amd/amdgpu/ih_v7_0.c b/drivers/gpu/drm/amd/amdgpu/ih_v7_0.c
index 40a3530e0453..b32ea4129c61 100644
--- a/drivers/gpu/drm/amd/amdgpu/ih_v7_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/ih_v7_0.c
@@ -552,8 +552,7 @@ static int ih_v7_0_sw_init(struct amdgpu_ip_block *ip_block)
 	/* use gpu virtual address for ih ring
 	 * until ih_checken is programmed to allow
 	 * use bus address for ih ring by psp bl */
-	use_bus_addr =
-		(adev->firmware.load_type == AMDGPU_FW_LOAD_PSP) ? false : true;
+	use_bus_addr = adev->firmware.load_type != AMDGPU_FW_LOAD_PSP;
 	r = amdgpu_ih_ring_init(adev, &adev->irq.ih, 256 * 1024, use_bus_addr);
 	if (r)
 		return r;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 5/6] drm/amdgpu/jpeg: Remove redundant ternary operators
  2025-09-03 12:03 [PATCH 0/6] drm/amdgpu: Remove redundant ternary operators Liao Yuanhong
                   ` (3 preceding siblings ...)
  2025-09-03 12:03 ` [PATCH 4/6] drm/amdgpu/ih: " Liao Yuanhong
@ 2025-09-03 12:03 ` Liao Yuanhong
  2025-09-03 12:03 ` [PATCH 6/6] drm/amdgpu/vcn: " Liao Yuanhong
  2025-09-03 12:41 ` [PATCH 0/6] drm/amdgpu: " Christian König
  6 siblings, 0 replies; 9+ messages in thread
From: Liao Yuanhong @ 2025-09-03 12:03 UTC (permalink / raw)
  To: Alex Deucher, Christian König, David Airlie, Simona Vetter,
	Sunil Khatri, Sathishkumar S, Lijo Lazar, David (Ming Qiang) Wu,
	Boyuan Zhang, Jesse.zhang@amd.com, Hawking Zhang, Leo Liu,
	Mangesh Gadre, Stanley.Yang, fanhuang,
	open list:RADEON and AMDGPU DRM DRIVERS, open list:DRM DRIVERS,
	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/gpu/drm/amd/amdgpu/jpeg_v4_0_5.c | 2 +-
 drivers/gpu/drm/amd/amdgpu/jpeg_v5_0_0.c | 2 +-
 drivers/gpu/drm/amd/amdgpu/jpeg_v5_0_1.c | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/jpeg_v4_0_5.c b/drivers/gpu/drm/amd/amdgpu/jpeg_v4_0_5.c
index 481d1a2dbe5a..5d86e1d846eb 100644
--- a/drivers/gpu/drm/amd/amdgpu/jpeg_v4_0_5.c
+++ b/drivers/gpu/drm/amd/amdgpu/jpeg_v4_0_5.c
@@ -686,7 +686,7 @@ static int jpeg_v4_0_5_set_clockgating_state(struct amdgpu_ip_block *ip_block,
 					  enum amd_clockgating_state state)
 {
 	struct amdgpu_device *adev = ip_block->adev;
-	bool enable = (state == AMD_CG_STATE_GATE) ? true : false;
+	bool enable = state == AMD_CG_STATE_GATE;
 	int i;
 
 	for (i = 0; i < adev->jpeg.num_jpeg_inst; ++i) {
diff --git a/drivers/gpu/drm/amd/amdgpu/jpeg_v5_0_0.c b/drivers/gpu/drm/amd/amdgpu/jpeg_v5_0_0.c
index e0a71909252b..34c70270ea1d 100644
--- a/drivers/gpu/drm/amd/amdgpu/jpeg_v5_0_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/jpeg_v5_0_0.c
@@ -584,7 +584,7 @@ static int jpeg_v5_0_0_set_clockgating_state(struct amdgpu_ip_block *ip_block,
 					  enum amd_clockgating_state state)
 {
 	struct amdgpu_device *adev = ip_block->adev;
-	bool enable = (state == AMD_CG_STATE_GATE) ? true : false;
+	bool enable = state == AMD_CG_STATE_GATE;
 
 	if (enable) {
 		if (!jpeg_v5_0_0_is_idle(ip_block))
diff --git a/drivers/gpu/drm/amd/amdgpu/jpeg_v5_0_1.c b/drivers/gpu/drm/amd/amdgpu/jpeg_v5_0_1.c
index 47bde62b3909..baf097d2e1ac 100644
--- a/drivers/gpu/drm/amd/amdgpu/jpeg_v5_0_1.c
+++ b/drivers/gpu/drm/amd/amdgpu/jpeg_v5_0_1.c
@@ -697,7 +697,7 @@ static int jpeg_v5_0_1_set_clockgating_state(struct amdgpu_ip_block *ip_block,
 					     enum amd_clockgating_state state)
 {
 	struct amdgpu_device *adev = ip_block->adev;
-	bool enable = (state == AMD_CG_STATE_GATE) ? true : false;
+	bool enable = state == AMD_CG_STATE_GATE;
 
 	int i;
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 6/6] drm/amdgpu/vcn: Remove redundant ternary operators
  2025-09-03 12:03 [PATCH 0/6] drm/amdgpu: Remove redundant ternary operators Liao Yuanhong
                   ` (4 preceding siblings ...)
  2025-09-03 12:03 ` [PATCH 5/6] drm/amdgpu/jpeg: " Liao Yuanhong
@ 2025-09-03 12:03 ` Liao Yuanhong
  2025-09-03 12:41 ` [PATCH 0/6] drm/amdgpu: " Christian König
  6 siblings, 0 replies; 9+ messages in thread
From: Liao Yuanhong @ 2025-09-03 12:03 UTC (permalink / raw)
  To: Alex Deucher, Christian König, David Airlie, Simona Vetter,
	Boyuan Zhang, Sunil Khatri, Leo Liu, David (Ming Qiang) Wu,
	Saleemkhan Jamadar, Sathishkumar S,
	open list:RADEON and AMDGPU DRM DRIVERS, open list:DRM DRIVERS,
	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/gpu/drm/amd/amdgpu/vcn_v4_0_5.c | 2 +-
 drivers/gpu/drm/amd/amdgpu/vcn_v5_0_0.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/vcn_v4_0_5.c b/drivers/gpu/drm/amd/amdgpu/vcn_v4_0_5.c
index 75c884a8f556..6dbf33b26ee2 100644
--- a/drivers/gpu/drm/amd/amdgpu/vcn_v4_0_5.c
+++ b/drivers/gpu/drm/amd/amdgpu/vcn_v4_0_5.c
@@ -1591,7 +1591,7 @@ static int vcn_v4_0_5_set_clockgating_state(struct amdgpu_ip_block *ip_block,
 					  enum amd_clockgating_state state)
 {
 	struct amdgpu_device *adev = ip_block->adev;
-	bool enable = (state == AMD_CG_STATE_GATE) ? true : false;
+	bool enable = state == AMD_CG_STATE_GATE;
 	int i;
 
 	for (i = 0; i < adev->vcn.num_vcn_inst; ++i) {
diff --git a/drivers/gpu/drm/amd/amdgpu/vcn_v5_0_0.c b/drivers/gpu/drm/amd/amdgpu/vcn_v5_0_0.c
index 455f829b8bb9..536f06b81706 100644
--- a/drivers/gpu/drm/amd/amdgpu/vcn_v5_0_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/vcn_v5_0_0.c
@@ -1311,7 +1311,7 @@ static int vcn_v5_0_0_set_clockgating_state(struct amdgpu_ip_block *ip_block,
 					  enum amd_clockgating_state state)
 {
 	struct amdgpu_device *adev = ip_block->adev;
-	bool enable = (state == AMD_CG_STATE_GATE) ? true : false;
+	bool enable = state == AMD_CG_STATE_GATE;
 	int i;
 
 	for (i = 0; i < adev->vcn.num_vcn_inst; ++i) {
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH 0/6] drm/amdgpu: Remove redundant ternary operators
  2025-09-03 12:03 [PATCH 0/6] drm/amdgpu: Remove redundant ternary operators Liao Yuanhong
                   ` (5 preceding siblings ...)
  2025-09-03 12:03 ` [PATCH 6/6] drm/amdgpu/vcn: " Liao Yuanhong
@ 2025-09-03 12:41 ` Christian König
  2025-09-03 14:36   ` Alex Deucher
  6 siblings, 1 reply; 9+ messages in thread
From: Christian König @ 2025-09-03 12:41 UTC (permalink / raw)
  To: Liao Yuanhong, Alex Deucher, David Airlie, Simona Vetter,
	Tao Zhou, Xiang Liu, Hawking Zhang, Yang Wang, Victor Skvortsov,
	Colin Ian King, Sunil Khatri, Lijo Lazar, Shashank Sharma,
	Srinivasan Shanmugam, Prike Liang, Rodrigo Siqueira, Jesse.Zhang,
	Felix Kuehling, Boyuan Zhang, Kent Russell, André Almeida,
	Tim Huang, Yifan Zhang, Natalie Vock, Candice Li, Shaoyun Liu,
	David Belanger, Emily Deng, Sathishkumar S, David (Ming Qiang) Wu,
	Leo Liu, Stanley.Yang, Mangesh Gadre, fanhuang,
	Saleemkhan Jamadar, open list:RADEON and AMDGPU DRM DRIVERS,
	open list:DRM DRIVERS, open list

Reviewed-by: Christian König <christian.koenig@amd.com> for the entire series.

On 03.09.25 14:03, Liao Yuanhong wrote:
> For ternary operators in the form of "a ? true : false" or
> "a ? false : true", if 'a' itself returns a boolean result, the ternary
> operator can be omitted. Remove redundant ternary operators to clean up the
> code.
> 
> Liao Yuanhong (6):
>   drm/amdgpu/amdgpu_cper: Remove redundant ternary operators
>   drm/amdgpu/gfx: Remove redundant ternary operators
>   drm/amdgpu/gmc: Remove redundant ternary operators
>   drm/amdgpu/ih: Remove redundant ternary operators
>   drm/amdgpu/jpeg: Remove redundant ternary operators
>   drm/amdgpu/vcn: Remove redundant ternary operators
> 
>  drivers/gpu/drm/amd/amdgpu/amdgpu_cper.c | 2 +-
>  drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c   | 3 +--
>  drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c   | 3 +--
>  drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c   | 3 +--
>  drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c   | 3 +--
>  drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c   | 3 +--
>  drivers/gpu/drm/amd/amdgpu/ih_v6_0.c     | 3 +--
>  drivers/gpu/drm/amd/amdgpu/ih_v6_1.c     | 3 +--
>  drivers/gpu/drm/amd/amdgpu/ih_v7_0.c     | 3 +--
>  drivers/gpu/drm/amd/amdgpu/jpeg_v4_0_5.c | 2 +-
>  drivers/gpu/drm/amd/amdgpu/jpeg_v5_0_0.c | 2 +-
>  drivers/gpu/drm/amd/amdgpu/jpeg_v5_0_1.c | 2 +-
>  drivers/gpu/drm/amd/amdgpu/vcn_v4_0_5.c  | 2 +-
>  drivers/gpu/drm/amd/amdgpu/vcn_v5_0_0.c  | 2 +-
>  14 files changed, 14 insertions(+), 22 deletions(-)
> 


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 0/6] drm/amdgpu: Remove redundant ternary operators
  2025-09-03 12:41 ` [PATCH 0/6] drm/amdgpu: " Christian König
@ 2025-09-03 14:36   ` Alex Deucher
  0 siblings, 0 replies; 9+ messages in thread
From: Alex Deucher @ 2025-09-03 14:36 UTC (permalink / raw)
  To: Christian König
  Cc: Liao Yuanhong, Alex Deucher, David Airlie, Simona Vetter,
	Tao Zhou, Xiang Liu, Hawking Zhang, Yang Wang, Victor Skvortsov,
	Colin Ian King, Sunil Khatri, Lijo Lazar, Shashank Sharma,
	Srinivasan Shanmugam, Prike Liang, Rodrigo Siqueira, Jesse.Zhang,
	Felix Kuehling, Boyuan Zhang, Kent Russell, André Almeida,
	Tim Huang, Yifan Zhang, Natalie Vock, Candice Li, Shaoyun Liu,
	David Belanger, Emily Deng, Sathishkumar S, David (Ming Qiang) Wu,
	Leo Liu, Stanley.Yang, Mangesh Gadre, fanhuang,
	Saleemkhan Jamadar, open list:RADEON and AMDGPU DRM DRIVERS,
	open list:DRM DRIVERS, open list

Applied.  Thanks!

Alex

On Wed, Sep 3, 2025 at 8:49 AM Christian König <christian.koenig@amd.com> wrote:
>
> Reviewed-by: Christian König <christian.koenig@amd.com> for the entire series.
>
> On 03.09.25 14:03, Liao Yuanhong wrote:
> > For ternary operators in the form of "a ? true : false" or
> > "a ? false : true", if 'a' itself returns a boolean result, the ternary
> > operator can be omitted. Remove redundant ternary operators to clean up the
> > code.
> >
> > Liao Yuanhong (6):
> >   drm/amdgpu/amdgpu_cper: Remove redundant ternary operators
> >   drm/amdgpu/gfx: Remove redundant ternary operators
> >   drm/amdgpu/gmc: Remove redundant ternary operators
> >   drm/amdgpu/ih: Remove redundant ternary operators
> >   drm/amdgpu/jpeg: Remove redundant ternary operators
> >   drm/amdgpu/vcn: Remove redundant ternary operators
> >
> >  drivers/gpu/drm/amd/amdgpu/amdgpu_cper.c | 2 +-
> >  drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c   | 3 +--
> >  drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c   | 3 +--
> >  drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c   | 3 +--
> >  drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c   | 3 +--
> >  drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c   | 3 +--
> >  drivers/gpu/drm/amd/amdgpu/ih_v6_0.c     | 3 +--
> >  drivers/gpu/drm/amd/amdgpu/ih_v6_1.c     | 3 +--
> >  drivers/gpu/drm/amd/amdgpu/ih_v7_0.c     | 3 +--
> >  drivers/gpu/drm/amd/amdgpu/jpeg_v4_0_5.c | 2 +-
> >  drivers/gpu/drm/amd/amdgpu/jpeg_v5_0_0.c | 2 +-
> >  drivers/gpu/drm/amd/amdgpu/jpeg_v5_0_1.c | 2 +-
> >  drivers/gpu/drm/amd/amdgpu/vcn_v4_0_5.c  | 2 +-
> >  drivers/gpu/drm/amd/amdgpu/vcn_v5_0_0.c  | 2 +-
> >  14 files changed, 14 insertions(+), 22 deletions(-)
> >
>

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2025-09-03 14:36 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-03 12:03 [PATCH 0/6] drm/amdgpu: Remove redundant ternary operators Liao Yuanhong
2025-09-03 12:03 ` [PATCH 1/6] drm/amdgpu/amdgpu_cper: " Liao Yuanhong
2025-09-03 12:03 ` [PATCH 2/6] drm/amdgpu/gfx: " Liao Yuanhong
2025-09-03 12:03 ` [PATCH 3/6] drm/amdgpu/gmc: " Liao Yuanhong
2025-09-03 12:03 ` [PATCH 4/6] drm/amdgpu/ih: " Liao Yuanhong
2025-09-03 12:03 ` [PATCH 5/6] drm/amdgpu/jpeg: " Liao Yuanhong
2025-09-03 12:03 ` [PATCH 6/6] drm/amdgpu/vcn: " Liao Yuanhong
2025-09-03 12:41 ` [PATCH 0/6] drm/amdgpu: " Christian König
2025-09-03 14:36   ` Alex Deucher

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).