diff mbox series

[v3,1/2] drm/i915/display: Use explicit base values in POWER_DOMAIN_*() macros

Message ID 20250227-improve-type-safey-power-domain-macros-v3-1-b6eaa00f9c33@intel.com (mailing list archive)
State New
Headers show
Series Improve type-safety on POWER_DOMAIN_*() macros | expand

Commit Message

Gustavo Sousa Feb. 27, 2025, 9:09 p.m. UTC
Although we have comments in intel_display_limits.h saying that the
code expects PIPE_A and TRANSCODER_A to be zero, it doesn't hurt to add
them as explicit base values for calculating the power domain offset in
POWER_DOMAIN_*() macros.

On the plus side, we have that this:

 * Fixes a warning reported by kernel test robot <lkp@intel.com>
   about doing arithmetic with two different enum types.
 * Makes the code arguably more robust (in the unlikely event of those
   bases becoming non-zero).

v2:
  - Prefer using explicit base values instead of simply casting the
    macro argument to int. (Ville)
  - Update commit message to match the new approach (for reference, the
    old message subject was "drm/i915/display: Use explicit cast in
    POWER_DOMAIN_*() macros").

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202502120809.XfmcqkBD-lkp@intel.com/
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Gustavo Sousa <gustavo.sousa@intel.com>
---
 drivers/gpu/drm/i915/display/intel_display_power.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/display/intel_display_power.h b/drivers/gpu/drm/i915/display/intel_display_power.h
index a3a5c1be8bab1fd6867cd8c38023b24bd5021cd4..4ad35bd4b040f2fb0220376d443ad84ae2ecab48 100644
--- a/drivers/gpu/drm/i915/display/intel_display_power.h
+++ b/drivers/gpu/drm/i915/display/intel_display_power.h
@@ -117,12 +117,12 @@  enum intel_display_power_domain {
 	POWER_DOMAIN_INVALID = POWER_DOMAIN_NUM,
 };
 
-#define POWER_DOMAIN_PIPE(pipe) ((pipe) + POWER_DOMAIN_PIPE_A)
+#define POWER_DOMAIN_PIPE(pipe) ((pipe) - PIPE_A + POWER_DOMAIN_PIPE_A)
 #define POWER_DOMAIN_PIPE_PANEL_FITTER(pipe) \
-		((pipe) + POWER_DOMAIN_PIPE_PANEL_FITTER_A)
+		((pipe) - PIPE_A + POWER_DOMAIN_PIPE_PANEL_FITTER_A)
 #define POWER_DOMAIN_TRANSCODER(tran) \
 	((tran) == TRANSCODER_EDP ? POWER_DOMAIN_TRANSCODER_EDP : \
-	 (tran) + POWER_DOMAIN_TRANSCODER_A)
+	 (tran) - TRANSCODER_A + POWER_DOMAIN_TRANSCODER_A)
 
 struct intel_power_domain_mask {
 	DECLARE_BITMAP(bits, POWER_DOMAIN_NUM);