Skip to content

Commit

Permalink
drm/i915/rpm: add rpm_to_i915() helper around container_of()
Browse files Browse the repository at this point in the history
Reduce the duplication.

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20231205121545.2338665-1-jani.nikula@intel.com
  • Loading branch information
Jani Nikula committed Dec 7, 2023
1 parent dcdf1bb commit 261200e
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions drivers/gpu/drm/i915/intel_runtime_pm.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@
* present for a given platform.
*/

static struct drm_i915_private *rpm_to_i915(struct intel_runtime_pm *rpm)
{
return container_of(rpm, struct drm_i915_private, runtime_pm);
}

#if IS_ENABLED(CONFIG_DRM_I915_DEBUG_RUNTIME_PM)

#include <linux/sort.h>
Expand Down Expand Up @@ -349,9 +354,7 @@ intel_runtime_pm_release(struct intel_runtime_pm *rpm, int wakelock)
static intel_wakeref_t __intel_runtime_pm_get(struct intel_runtime_pm *rpm,
bool wakelock)
{
struct drm_i915_private *i915 = container_of(rpm,
struct drm_i915_private,
runtime_pm);
struct drm_i915_private *i915 = rpm_to_i915(rpm);
int ret;

ret = pm_runtime_get_sync(rpm->kdev);
Expand Down Expand Up @@ -556,9 +559,7 @@ void intel_runtime_pm_put(struct intel_runtime_pm *rpm, intel_wakeref_t wref)
*/
void intel_runtime_pm_enable(struct intel_runtime_pm *rpm)
{
struct drm_i915_private *i915 = container_of(rpm,
struct drm_i915_private,
runtime_pm);
struct drm_i915_private *i915 = rpm_to_i915(rpm);
struct device *kdev = rpm->kdev;

/*
Expand Down Expand Up @@ -611,9 +612,7 @@ void intel_runtime_pm_enable(struct intel_runtime_pm *rpm)

void intel_runtime_pm_disable(struct intel_runtime_pm *rpm)
{
struct drm_i915_private *i915 = container_of(rpm,
struct drm_i915_private,
runtime_pm);
struct drm_i915_private *i915 = rpm_to_i915(rpm);
struct device *kdev = rpm->kdev;

/* Transfer rpm ownership back to core */
Expand All @@ -628,9 +627,7 @@ void intel_runtime_pm_disable(struct intel_runtime_pm *rpm)

void intel_runtime_pm_driver_release(struct intel_runtime_pm *rpm)
{
struct drm_i915_private *i915 = container_of(rpm,
struct drm_i915_private,
runtime_pm);
struct drm_i915_private *i915 = rpm_to_i915(rpm);
int count = atomic_read(&rpm->wakeref_count);

intel_wakeref_auto_fini(&rpm->userfault_wakeref);
Expand All @@ -645,8 +642,7 @@ void intel_runtime_pm_driver_release(struct intel_runtime_pm *rpm)

void intel_runtime_pm_init_early(struct intel_runtime_pm *rpm)
{
struct drm_i915_private *i915 =
container_of(rpm, struct drm_i915_private, runtime_pm);
struct drm_i915_private *i915 = rpm_to_i915(rpm);
struct pci_dev *pdev = to_pci_dev(i915->drm.dev);
struct device *kdev = &pdev->dev;

Expand Down

0 comments on commit 261200e

Please sign in to comment.