]> git.baikalelectronics.ru Git - kernel.git/commit
drm/i915: use REG_FIELD_PREP() to define register bitfield values
authorJani Nikula <jani.nikula@intel.com>
Fri, 15 Mar 2019 13:56:20 +0000 (15:56 +0200)
committerJani Nikula <jani.nikula@intel.com>
Mon, 18 Mar 2019 14:28:04 +0000 (16:28 +0200)
commit4adc06770919789cafe2cd84edc78af5268d26cb
treebea5b845777c75b1cd493b1c0a89a96e587f72e5
parent1461010894e582e540e3e93b9efa4422c04c7d9a
drm/i915: use REG_FIELD_PREP() to define register bitfield values

Slightly verbose, but does away with hand rolled shifts. Ties the field
values with the mask defining the field.

Unfortunately we have to make a local copy of FIELD_PREP() to evaluate
to a integer constant expression. But with this, we can ensure the mask
is non-zero, power of 2, fits u32, and the value fits the mask (when the
value is a constant expression).

Convert power sequencer registers as an example.

v4:
- rebase

v3:
- rename the macro to REG_FIELD_PREP to avoid underscore prefix and to
  be in line with kernel macros (Chris)
- rename power of 2 check macro (Chris)

v2:
 - add build-time checks with BUILD_BUG_ON_ZERO()
 - rename to just _FIELD() due to regmap.h REG_FIELD() clash

Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
Cc: Mika Kuoppala <mika.kuoppala@linux.intel.com>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Acked-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/a844edda2afa6b54d9b12a6251da02c43ea8a942.1552657998.git.jani.nikula@intel.com
drivers/gpu/drm/i915/i915_reg.h