Skip to content

Commit 261200e

Browse files
committed
drm/i915/rpm: add rpm_to_i915() helper around container_of()
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
1 parent dcdf1bb commit 261200e

1 file changed

Lines changed: 10 additions & 14 deletions

File tree

drivers/gpu/drm/i915/intel_runtime_pm.c

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@
5050
* present for a given platform.
5151
*/
5252

53+
static struct drm_i915_private *rpm_to_i915(struct intel_runtime_pm *rpm)
54+
{
55+
return container_of(rpm, struct drm_i915_private, runtime_pm);
56+
}
57+
5358
#if IS_ENABLED(CONFIG_DRM_I915_DEBUG_RUNTIME_PM)
5459

5560
#include <linux/sort.h>
@@ -349,9 +354,7 @@ intel_runtime_pm_release(struct intel_runtime_pm *rpm, int wakelock)
349354
static intel_wakeref_t __intel_runtime_pm_get(struct intel_runtime_pm *rpm,
350355
bool wakelock)
351356
{
352-
struct drm_i915_private *i915 = container_of(rpm,
353-
struct drm_i915_private,
354-
runtime_pm);
357+
struct drm_i915_private *i915 = rpm_to_i915(rpm);
355358
int ret;
356359

357360
ret = pm_runtime_get_sync(rpm->kdev);
@@ -556,9 +559,7 @@ void intel_runtime_pm_put(struct intel_runtime_pm *rpm, intel_wakeref_t wref)
556559
*/
557560
void intel_runtime_pm_enable(struct intel_runtime_pm *rpm)
558561
{
559-
struct drm_i915_private *i915 = container_of(rpm,
560-
struct drm_i915_private,
561-
runtime_pm);
562+
struct drm_i915_private *i915 = rpm_to_i915(rpm);
562563
struct device *kdev = rpm->kdev;
563564

564565
/*
@@ -611,9 +612,7 @@ void intel_runtime_pm_enable(struct intel_runtime_pm *rpm)
611612

612613
void intel_runtime_pm_disable(struct intel_runtime_pm *rpm)
613614
{
614-
struct drm_i915_private *i915 = container_of(rpm,
615-
struct drm_i915_private,
616-
runtime_pm);
615+
struct drm_i915_private *i915 = rpm_to_i915(rpm);
617616
struct device *kdev = rpm->kdev;
618617

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

629628
void intel_runtime_pm_driver_release(struct intel_runtime_pm *rpm)
630629
{
631-
struct drm_i915_private *i915 = container_of(rpm,
632-
struct drm_i915_private,
633-
runtime_pm);
630+
struct drm_i915_private *i915 = rpm_to_i915(rpm);
634631
int count = atomic_read(&rpm->wakeref_count);
635632

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

646643
void intel_runtime_pm_init_early(struct intel_runtime_pm *rpm)
647644
{
648-
struct drm_i915_private *i915 =
649-
container_of(rpm, struct drm_i915_private, runtime_pm);
645+
struct drm_i915_private *i915 = rpm_to_i915(rpm);
650646
struct pci_dev *pdev = to_pci_dev(i915->drm.dev);
651647
struct device *kdev = &pdev->dev;
652648

0 commit comments

Comments
 (0)