]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
drm/i915: Avoid BIT(max) - 1 and use GENMASK(max - 1, 0)
authorJoonas Lahtinen <joonas.lahtinen@linux.intel.com>
Wed, 8 Feb 2017 13:12:09 +0000 (15:12 +0200)
committerJoonas Lahtinen <joonas.lahtinen@linux.intel.com>
Wed, 8 Feb 2017 15:22:00 +0000 (17:22 +0200)
"BIT(max) - 1" will overflow when max = 32, and GCC will complain.
We already have GENMASK for generating the mask, use it!

v2: Majestic off by one spotted (Chris)

Signed-off-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
drivers/gpu/drm/i915/intel_device_info.c
drivers/gpu/drm/i915/intel_fbdev.c
drivers/gpu/drm/i915/intel_runtime_pm.c

index fcf81815daff3abb53ecbb95c46a06701e3f526b..0891cc0e86267a3752f302f71f3fc16551e11345 100644 (file)
@@ -234,7 +234,7 @@ static void broadwell_sseu_info_init(struct drm_i915_private *dev_priv)
         * The subslice disable field is global, i.e. it applies
         * to each of the enabled slices.
         */
-       sseu->subslice_mask = BIT(ss_max) - 1;
+       sseu->subslice_mask = GENMASK(ss_max - 1, 0);
        sseu->subslice_mask &= ~((fuse2 & GEN8_F2_SS_DIS_MASK) >>
                                 GEN8_F2_SS_DIS_SHIFT);
 
index e0d9e72cf3d1dfee344896c120a9937f4a8b5824..03b7391fb5660bedfdd43241b64a72d14fc0f3f5 100644 (file)
@@ -371,7 +371,7 @@ static bool intel_fb_initial_config(struct drm_fb_helper *fb_helper,
                return false;
 
        memcpy(save_enabled, enabled, count);
-       mask = BIT(count) - 1;
+       mask = GENMASK(count - 1, 0);
        conn_configured = 0;
 retry:
        for (i = 0; i < count; i++) {
index 66aa1bbb42f0e5c7cb623ae5ab2a58d94e140219..94df466a4801343512791ec7f436410056ff4786 100644 (file)
@@ -1249,7 +1249,7 @@ static void vlv_dpio_cmn_power_well_disable(struct drm_i915_private *dev_priv,
        vlv_set_power_well(dev_priv, power_well, false);
 }
 
-#define POWER_DOMAIN_MASK (BIT(POWER_DOMAIN_NUM) - 1)
+#define POWER_DOMAIN_MASK (GENMASK(POWER_DOMAIN_NUM - 1, 0))
 
 static struct i915_power_well *lookup_power_well(struct drm_i915_private *dev_priv,
                                                 int power_well_id)