drm/i915: Syntatic sugar for using intel_runtime_pm
Frequently, we use intel_runtime_pm_get/_put around a small block. Formalise that usage by providing a macro to define such a block with an automatic closure to scope the intel_runtime_pm wakeref to that block, i.e. macro abuse smelling of python. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Cc: Jani Nikula <jani.nikula@intel.com> Reviewed-by: Mika Kuoppala <mika.kuoppala@linux.intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20190114142129.24398-15-chris@chris-wilson.co.uk
This commit is contained in:
@@ -1204,17 +1204,19 @@ static int intel_backlight_device_get_brightness(struct backlight_device *bd)
|
||||
struct drm_device *dev = connector->base.dev;
|
||||
struct drm_i915_private *dev_priv = to_i915(dev);
|
||||
intel_wakeref_t wakeref;
|
||||
u32 hw_level;
|
||||
int ret;
|
||||
int ret = 0;
|
||||
|
||||
wakeref = intel_runtime_pm_get(dev_priv);
|
||||
drm_modeset_lock(&dev->mode_config.connection_mutex, NULL);
|
||||
with_intel_runtime_pm(dev_priv, wakeref) {
|
||||
u32 hw_level;
|
||||
|
||||
hw_level = intel_panel_get_backlight(connector);
|
||||
ret = scale_hw_to_user(connector, hw_level, bd->props.max_brightness);
|
||||
drm_modeset_lock(&dev->mode_config.connection_mutex, NULL);
|
||||
|
||||
drm_modeset_unlock(&dev->mode_config.connection_mutex);
|
||||
intel_runtime_pm_put(dev_priv, wakeref);
|
||||
hw_level = intel_panel_get_backlight(connector);
|
||||
ret = scale_hw_to_user(connector,
|
||||
hw_level, bd->props.max_brightness);
|
||||
|
||||
drm_modeset_unlock(&dev->mode_config.connection_mutex);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
Reference in New Issue
Block a user