Re: [PATCH] drm/amd/display: Guard ACPI calls with CONFIG_ACPI

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 6/10/2024 09:55, sunpeng.li@xxxxxxx wrote:
From: Leo Li <sunpeng.li@xxxxxxx>

To fix CONFIG_ACPI disabled build error.

Fixes: ec6f30c776ad ("drm/amd/display: Set default brightness according to ACPI")
Signed-off-by: Leo Li <sunpeng.li@xxxxxxx>
---
  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 6 ++++++
  1 file changed, 6 insertions(+)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index a2c098f1b07c..6b3634db4c15 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -4572,7 +4572,9 @@ amdgpu_dm_register_backlight_device(struct amdgpu_dm_connector *aconnector)
  	struct drm_device *drm = aconnector->base.dev;
  	struct amdgpu_display_manager *dm = &drm_to_adev(drm)->dm;
  	struct backlight_properties props = { 0 };
+#if defined(CONFIG_ACPI)
  	struct amdgpu_dm_backlight_caps caps = { 0 };
+#endif
  	char bl_name[16];
if (aconnector->bl_idx == -1)
@@ -4585,6 +4587,7 @@ amdgpu_dm_register_backlight_device(struct amdgpu_dm_connector *aconnector)
  		return;
  	}
+#if defined(CONFIG_ACPI)
  	amdgpu_acpi_get_backlight_caps(&caps);
  	if (caps.caps_valid) {
  		if (power_supply_is_system_supplied() > 0)
@@ -4593,6 +4596,9 @@ amdgpu_dm_register_backlight_device(struct amdgpu_dm_connector *aconnector)
  			props.brightness = caps.dc_level;
  	} else
  		props.brightness = AMDGPU_MAX_BL_LEVEL;
+#else
+	props.brightness = AMDGPU_MAX_BL_LEVEL;
+#endif

Hey Leo,

Thanks for the patch!

As caps is initialized to {0} caps.caps_valid will be invalid. So I see two other ways to solve this that are a little cleaner (IMO):

1)  Just block the one call:

#if defined(CONFIG_ACPI)
	amdgpu_acpi_get_backlight_caps(&caps);
#endif

2) Add a stub inline no-op function for amdgpu_acpi_get_backlight_caps() to the header.

I personally think #2 is cleaner (less ifdef makes a lot more readable code).

props.max_brightness = AMDGPU_MAX_BL_LEVEL;
  	props.type = BACKLIGHT_RAW;



[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux