mirror of
https://github.com/torvalds/linux.git
synced 2026-05-31 10:33:41 +02:00
drm/i915 & drm/xe: save struct drm_device to drvdata
In the future, the display code shall not have any idea about struct xe_device or struct drm_i915_private, but will need to get at the struct drm_device via drvdata. Store the struct drm_device pointer to drvdata instead of the driver specific pointer. Avoid passing NULL to container_of() via to_i915()/to_xe_device(). (It does return NULL for NULL pointers when the offset happens to be 0, but otherwise returns garbage pointers for NULL.) Reviewed-by: Gustavo Sousa <gustavo.sousa@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/946805b32e38d4785880cc7857e01e6a309126a9.1724942754.git.jani.nikula@intel.com Signed-off-by: Jani Nikula <jani.nikula@intel.com>
This commit is contained in:
parent
8be4dce5ea
commit
83e5af5997
|
|
@ -723,7 +723,7 @@ i915_driver_create(struct pci_dev *pdev, const struct pci_device_id *ent)
|
|||
if (IS_ERR(i915))
|
||||
return i915;
|
||||
|
||||
pci_set_drvdata(pdev, i915);
|
||||
pci_set_drvdata(pdev, &i915->drm);
|
||||
|
||||
/* Device parameters start as a copy of module parameters. */
|
||||
i915_params_copy(&i915->params, &i915_modparams);
|
||||
|
|
|
|||
|
|
@ -365,12 +365,16 @@ static inline struct drm_i915_private *to_i915(const struct drm_device *dev)
|
|||
|
||||
static inline struct drm_i915_private *kdev_to_i915(struct device *kdev)
|
||||
{
|
||||
return dev_get_drvdata(kdev);
|
||||
struct drm_device *drm = dev_get_drvdata(kdev);
|
||||
|
||||
return drm ? to_i915(drm) : NULL;
|
||||
}
|
||||
|
||||
static inline struct drm_i915_private *pdev_to_i915(struct pci_dev *pdev)
|
||||
{
|
||||
return pci_get_drvdata(pdev);
|
||||
struct drm_device *drm = pci_get_drvdata(pdev);
|
||||
|
||||
return drm ? to_i915(drm) : NULL;
|
||||
}
|
||||
|
||||
static inline struct intel_gt *to_gt(const struct drm_i915_private *i915)
|
||||
|
|
|
|||
|
|
@ -172,7 +172,7 @@ struct drm_i915_private *mock_gem_device(void)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
pci_set_drvdata(pdev, i915);
|
||||
pci_set_drvdata(pdev, &i915->drm);
|
||||
|
||||
/* Device parameters start as a copy of module parameters. */
|
||||
i915_params_copy(&i915->params, &i915_modparams);
|
||||
|
|
|
|||
|
|
@ -23,7 +23,9 @@ static inline struct drm_i915_private *to_i915(const struct drm_device *dev)
|
|||
|
||||
static inline struct drm_i915_private *kdev_to_i915(struct device *kdev)
|
||||
{
|
||||
return dev_get_drvdata(kdev);
|
||||
struct drm_device *drm = dev_get_drvdata(kdev);
|
||||
|
||||
return drm ? to_i915(drm) : NULL;
|
||||
}
|
||||
|
||||
#define IS_PLATFORM(xe, x) ((xe)->info.platform == x)
|
||||
|
|
|
|||
|
|
@ -17,12 +17,16 @@ static inline struct xe_device *to_xe_device(const struct drm_device *dev)
|
|||
|
||||
static inline struct xe_device *kdev_to_xe_device(struct device *kdev)
|
||||
{
|
||||
return dev_get_drvdata(kdev);
|
||||
struct drm_device *drm = dev_get_drvdata(kdev);
|
||||
|
||||
return drm ? to_xe_device(drm) : NULL;
|
||||
}
|
||||
|
||||
static inline struct xe_device *pdev_to_xe_device(struct pci_dev *pdev)
|
||||
{
|
||||
return pci_get_drvdata(pdev);
|
||||
struct drm_device *drm = pci_get_drvdata(pdev);
|
||||
|
||||
return drm ? to_xe_device(drm) : NULL;
|
||||
}
|
||||
|
||||
static inline struct xe_device *xe_device_const_cast(const struct xe_device *xe)
|
||||
|
|
|
|||
|
|
@ -793,7 +793,7 @@ static int xe_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
|
|||
if (IS_ERR(xe))
|
||||
return PTR_ERR(xe);
|
||||
|
||||
pci_set_drvdata(pdev, xe);
|
||||
pci_set_drvdata(pdev, &xe->drm);
|
||||
|
||||
xe_pm_assert_unbounded_bridge(xe);
|
||||
subplatform_desc = find_subplatform(xe, desc);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user