drm/amd/display: Incorrect 'not' operator usage
authorClay King <clayking@amd.com>
Thu, 14 Aug 2025 21:02:45 +0000 (17:02 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 27 Aug 2025 17:57:50 +0000 (13:57 -0400)
Consolidating multiple CodeQL Fixes for alerts with rule id: cpp/incorrect-not-operator-usage

Reviewed-by: Joshua Aberback <joshua.aberback@amd.com>
Signed-off-by: Clay King <clayking@amd.com>
Signed-off-by: Aurabindo Pillai <aurabindo.pillai@amd.com>
Tested-by: Dan Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/dc/dce/dce_i2c_hw.c
drivers/gpu/drm/amd/display/dc/dce/dce_i2c_sw.c
drivers/gpu/drm/amd/display/dc/dml/dcn20/display_rq_dlg_calc_20.c
drivers/gpu/drm/amd/display/dc/dml/dcn20/display_rq_dlg_calc_20v2.c
drivers/gpu/drm/amd/display/dc/dml/dcn21/display_rq_dlg_calc_21.c
drivers/gpu/drm/amd/display/dc/dml/dcn30/display_rq_dlg_calc_30.c
drivers/gpu/drm/amd/display/dc/dml/dcn31/display_rq_dlg_calc_31.c
drivers/gpu/drm/amd/display/dc/dml/dcn314/display_rq_dlg_calc_314.c

index 0421b26..365dd2e 100644 (file)
@@ -591,7 +591,7 @@ static bool dce_i2c_hw_engine_submit_payload(struct dce_i2c_hw *dce_i2c_hw,
                        DCE_I2C_TRANSACTION_ACTION_I2C_WRITE;
 
 
-       request.address = (uint8_t) ((payload->address << 1) | !payload->write);
+       request.address = (uint8_t) ((payload->address << 1) | (payload->write ? 0 : 1));
        request.length = payload->length;
        request.data = payload->data;
 
index e188447..2d73b94 100644 (file)
@@ -451,7 +451,7 @@ static bool dce_i2c_sw_engine_submit_payload(struct dce_i2c_sw *engine,
                        DCE_I2C_TRANSACTION_ACTION_I2C_WRITE_MOT :
                        DCE_I2C_TRANSACTION_ACTION_I2C_WRITE;
 
-       request.address = (uint8_t) ((payload->address << 1) | !payload->write);
+       request.address = (uint8_t) ((payload->address << 1) | (payload->write ? 0 : 1));
        request.length = payload->length;
        request.data = payload->data;
 
index 390c1a7..9c58ff1 100644 (file)
@@ -646,7 +646,7 @@ static void get_meta_and_pte_attr(struct display_mode_lib *mode_lib,
 
        // the dpte_group_bytes is reduced for the specific case of vertical
        // access of a tile surface that has dpte request of 8x1 ptes.
-       if (!surf_linear & (log2_dpte_req_height_ptes == 0) & surf_vert) //reduced, in this case, will have page fault within a group
+       if (!surf_linear && (log2_dpte_req_height_ptes == 0) && surf_vert) //reduced, in this case, will have page fault within a group
                rq_sizing_param->dpte_group_bytes = 512;
        else
                //full size
index 843d600..570e6e3 100644 (file)
@@ -646,7 +646,7 @@ static void get_meta_and_pte_attr(struct display_mode_lib *mode_lib,
 
        // the dpte_group_bytes is reduced for the specific case of vertical
        // access of a tile surface that has dpte request of 8x1 ptes.
-       if (!surf_linear & (log2_dpte_req_height_ptes == 0) & surf_vert) //reduced, in this case, will have page fault within a group
+       if (!surf_linear && (log2_dpte_req_height_ptes == 0) && surf_vert) //reduced, in this case, will have page fault within a group
                rq_sizing_param->dpte_group_bytes = 512;
        else
                //full size
index 5718000..f549da0 100644 (file)
@@ -652,7 +652,7 @@ static void get_meta_and_pte_attr(
        if (hostvm_enable)
                rq_sizing_param->dpte_group_bytes = 512;
        else {
-               if (!surf_linear & (log2_dpte_req_height_ptes == 0) & surf_vert) //reduced, in this case, will have page fault within a group
+               if (!surf_linear && (log2_dpte_req_height_ptes == 0) && surf_vert) //reduced, in this case, will have page fault within a group
                        rq_sizing_param->dpte_group_bytes = 512;
                else
                        //full size
index 8d4873f..4fb37df 100644 (file)
@@ -620,7 +620,7 @@ static void get_meta_and_pte_attr(struct display_mode_lib *mode_lib,
        if (hostvm_enable)
                rq_sizing_param->dpte_group_bytes = 512;
        else {
-               if (!surf_linear & (log2_dpte_req_height_ptes == 0) & surf_vert) //reduced, in this case, will have page fault within a group
+               if (!surf_linear && (log2_dpte_req_height_ptes == 0) && surf_vert) //reduced, in this case, will have page fault within a group
                        rq_sizing_param->dpte_group_bytes = 512;
                else
                        rq_sizing_param->dpte_group_bytes = 2048;
index c46bda2..bfeb014 100644 (file)
@@ -615,7 +615,7 @@ static void get_meta_and_pte_attr(
        if (hostvm_enable)
                rq_sizing_param->dpte_group_bytes = 512;
        else {
-               if (!surf_linear & (log2_dpte_req_height_ptes == 0) & surf_vert) //reduced, in this case, will have page fault within a group
+               if (!surf_linear && (log2_dpte_req_height_ptes == 0) && surf_vert) //reduced, in this case, will have page fault within a group
                        rq_sizing_param->dpte_group_bytes = 512;
                else
                        rq_sizing_param->dpte_group_bytes = 2048;
index b7d2a0c..04df263 100644 (file)
@@ -703,7 +703,7 @@ static void get_meta_and_pte_attr(
        if (hostvm_enable)
                rq_sizing_param->dpte_group_bytes = 512;
        else {
-               if (!surf_linear & (log2_dpte_req_height_ptes == 0) & surf_vert) //reduced, in this case, will have page fault within a group
+               if (!surf_linear && (log2_dpte_req_height_ptes == 0) && surf_vert) //reduced, in this case, will have page fault within a group
                        rq_sizing_param->dpte_group_bytes = 512;
                else
                        rq_sizing_param->dpte_group_bytes = 2048;