mirror of
https://github.com/torvalds/linux.git
synced 2026-04-27 19:12:29 -04:00
drm/amd/display/amdgpu_dm: Refactor register_backlight_device()
Refactor register_backlight_device(): 1) Turn the connector-type + signal check into an early exit condition to avoid the indentation level of the rest of the code 2) Add an array bounds check for the arrays indexed by dm->num_of_edps 3) register_backlight_device() always increases dm->num_of_edps if amdgpu_dm_register_backlight_device() has assigned a backlight_dev to the current dm->backlight_link[dm->num_of_edps] slot. So on its next call dm->backlight_dev[dm->num_of_edps] always point to the next empty slot and the "if (!dm->backlight_dev[dm->num_of_edps])" check will thus always succeed and can be removed. 4) Add a bl_idx local variable to use as array index, rather then using dm->num_of_edps to improve the code readability. Reviewed-by: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
committed by
Alex Deucher
parent
4db231d7dd
commit
ceb4a5619c
@@ -4269,21 +4269,23 @@ static int initialize_plane(struct amdgpu_display_manager *dm,
|
||||
static void register_backlight_device(struct amdgpu_display_manager *dm,
|
||||
struct dc_link *link)
|
||||
{
|
||||
if ((link->connector_signal & (SIGNAL_TYPE_EDP | SIGNAL_TYPE_LVDS)) &&
|
||||
link->type != dc_connection_none) {
|
||||
/*
|
||||
* Event if registration failed, we should continue with
|
||||
* DM initialization because not having a backlight control
|
||||
* is better then a black screen.
|
||||
*/
|
||||
if (!dm->backlight_dev[dm->num_of_edps])
|
||||
amdgpu_dm_register_backlight_device(dm);
|
||||
int bl_idx = dm->num_of_edps;
|
||||
|
||||
if (dm->backlight_dev[dm->num_of_edps]) {
|
||||
dm->backlight_link[dm->num_of_edps] = link;
|
||||
dm->num_of_edps++;
|
||||
}
|
||||
if (!(link->connector_signal & (SIGNAL_TYPE_EDP | SIGNAL_TYPE_LVDS)) ||
|
||||
link->type == dc_connection_none)
|
||||
return;
|
||||
|
||||
if (dm->num_of_edps >= AMDGPU_DM_MAX_NUM_EDP) {
|
||||
drm_warn(adev_to_drm(dm->adev), "Too much eDP connections, skipping backlight setup for additional eDPs\n");
|
||||
return;
|
||||
}
|
||||
|
||||
amdgpu_dm_register_backlight_device(dm);
|
||||
if (!dm->backlight_dev[bl_idx])
|
||||
return;
|
||||
|
||||
dm->backlight_link[bl_idx] = link;
|
||||
dm->num_of_edps++;
|
||||
}
|
||||
|
||||
static void amdgpu_set_panel_orientation(struct drm_connector *connector);
|
||||
|
||||
Reference in New Issue
Block a user