Commit a9ed2f05 authored by Wu Hoi Pok's avatar Wu Hoi Pok Committed by Alex Deucher

drm/radeon: change drm_dev_alloc to devm_drm_dev_alloc

"drm_dev_alloc" is deprecated, in order to use the newer "devm_drm_dev_alloc",
the "drm_device" is stored inside "radeon_device", by changing "rdev_to_drm(rdev)"
other functions still gain access to the member "drm_device". Also, "devm_drm_dev_alloc"
is now allocating "radeon_device", allocation inside "radeon_driver_load_kms" has to be
removed.

In "radeon_device_init", it originally assigned "rdev->dev" etc. However it is already
done right after "devm_drm_dev_alloc" as you can see down below. It is better remove them.
Reviewed-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
Tested-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
Signed-off-by: default avatarWu Hoi Pok <wuhoipok@gmail.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent fb1b5e1d
...@@ -2297,7 +2297,7 @@ typedef void (*radeon_wreg_t)(struct radeon_device*, uint32_t, uint32_t); ...@@ -2297,7 +2297,7 @@ typedef void (*radeon_wreg_t)(struct radeon_device*, uint32_t, uint32_t);
struct radeon_device { struct radeon_device {
struct device *dev; struct device *dev;
struct drm_device *ddev; struct drm_device ddev;
struct pci_dev *pdev; struct pci_dev *pdev;
#ifdef __alpha__ #ifdef __alpha__
struct pci_controller *hose; struct pci_controller *hose;
...@@ -2478,7 +2478,7 @@ void cik_mm_wdoorbell(struct radeon_device *rdev, u32 index, u32 v); ...@@ -2478,7 +2478,7 @@ void cik_mm_wdoorbell(struct radeon_device *rdev, u32 index, u32 v);
static inline struct drm_device *rdev_to_drm(struct radeon_device *rdev) static inline struct drm_device *rdev_to_drm(struct radeon_device *rdev)
{ {
return rdev->ddev; return &rdev->ddev;
} }
/* /*
......
...@@ -1285,9 +1285,6 @@ int radeon_device_init(struct radeon_device *rdev, ...@@ -1285,9 +1285,6 @@ int radeon_device_init(struct radeon_device *rdev,
bool runtime = false; bool runtime = false;
rdev->shutdown = false; rdev->shutdown = false;
rdev->dev = &pdev->dev;
rdev->ddev = ddev;
rdev->pdev = pdev;
rdev->flags = flags; rdev->flags = flags;
rdev->family = flags & RADEON_FAMILY_MASK; rdev->family = flags & RADEON_FAMILY_MASK;
rdev->is_atom_bios = false; rdev->is_atom_bios = false;
......
...@@ -260,6 +260,7 @@ static int radeon_pci_probe(struct pci_dev *pdev, ...@@ -260,6 +260,7 @@ static int radeon_pci_probe(struct pci_dev *pdev,
{ {
unsigned long flags = 0; unsigned long flags = 0;
struct drm_device *ddev; struct drm_device *ddev;
struct radeon_device *rdev;
int ret; int ret;
if (!ent) if (!ent)
...@@ -300,9 +301,14 @@ static int radeon_pci_probe(struct pci_dev *pdev, ...@@ -300,9 +301,14 @@ static int radeon_pci_probe(struct pci_dev *pdev,
if (ret) if (ret)
return ret; return ret;
ddev = drm_dev_alloc(&kms_driver, &pdev->dev); rdev = devm_drm_dev_alloc(&pdev->dev, &kms_driver, typeof(*rdev), ddev);
if (IS_ERR(ddev)) if (IS_ERR(rdev))
return PTR_ERR(ddev); return PTR_ERR(rdev);
rdev->dev = &pdev->dev;
rdev->pdev = pdev;
ddev = rdev_to_drm(rdev);
ddev->dev_private = rdev;
ret = pci_enable_device(pdev); ret = pci_enable_device(pdev);
if (ret) if (ret)
......
...@@ -104,15 +104,9 @@ void radeon_driver_unload_kms(struct drm_device *dev) ...@@ -104,15 +104,9 @@ void radeon_driver_unload_kms(struct drm_device *dev)
int radeon_driver_load_kms(struct drm_device *dev, unsigned long flags) int radeon_driver_load_kms(struct drm_device *dev, unsigned long flags)
{ {
struct pci_dev *pdev = to_pci_dev(dev->dev); struct pci_dev *pdev = to_pci_dev(dev->dev);
struct radeon_device *rdev; struct radeon_device *rdev = dev->dev_private;
int r, acpi_status; int r, acpi_status;
rdev = kzalloc(sizeof(struct radeon_device), GFP_KERNEL);
if (rdev == NULL) {
return -ENOMEM;
}
dev->dev_private = (void *)rdev;
#ifdef __alpha__ #ifdef __alpha__
rdev->hose = pdev->sysdata; rdev->hose = pdev->sysdata;
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment