]> git.itanic.dy.fi Git - linux-stable/commit
drm/i915: Add _PICK_EVEN_2RANGES()
authorLucas De Marchi <lucas.demarchi@intel.com>
Wed, 25 Jan 2023 18:24:03 +0000 (10:24 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 17 May 2023 12:02:04 +0000 (14:02 +0200)
commit0ee18aa1a8b9cd7de51536661317049b4503798f
tree72088d7aa377ec06abafed09d3ab20aa6fee6f0e
parent92758439c0fafa347bcd6501128ebd6fbb43cc5c
drm/i915: Add _PICK_EVEN_2RANGES()

[ Upstream commit 357513233d6456c9f99e34794897efd4ae907e83 ]

It's a constant pattern in the driver to need to use 2 ranges of MMIOs
based on port, phy, pll, etc. When that happens, instead of using
_PICK_EVEN(), _PICK() needs to be used.  Using _PICK() is discouraged
due to some reasons like:

1) It increases the code size since the array is declared
   in each call site
2) Developers need to be careful not to incur an
   out-of-bounds array access
3) Developers need to be careful that the indexes match the
   table. For that it may be that the table needs to contain
   holes, making (1) even worse.

Add a variant of _PICK_EVEN() that works with 2 ranges and selects which
one to use depending on the index value.

v2: Fix the address expansion in the example (Anusha)
v3: Also rename macro to _PICK_EVEN_2RANGES() in the documentation
    and reword it to clarify what ranges are chosen based on the index
    (Jani)

Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
Reviewed-by: Anusha Srivatsa <anusha.srivatsa@intel.com>
Acked-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230125182403.7526-1-lucas.demarchi@intel.com
Stable-dep-of: 214b09db6197 ("drm/msm: fix drm device leak on bind errors")
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/gpu/drm/i915/i915_reg_defs.h