Skip to content

Commit

Permalink
drm/radeon: change drm_dev_alloc to devm_drm_dev_alloc
Browse files Browse the repository at this point in the history
"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: Thomas Zimmermann <tzimmermann@suse.de>
Tested-by: Thomas Zimmermann <tzimmermann@suse.de>
Signed-off-by: Wu Hoi Pok <wuhoipok@gmail.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
  • Loading branch information
Wu Hoi Pok authored and Alex Deucher committed Jul 23, 2024
1 parent fb1b5e1 commit a9ed2f0
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 15 deletions.
4 changes: 2 additions & 2 deletions drivers/gpu/drm/radeon/radeon.h
Original file line number Diff line number Diff line change
Expand Up @@ -2297,7 +2297,7 @@ typedef void (*radeon_wreg_t)(struct radeon_device*, uint32_t, uint32_t);

struct radeon_device {
struct device *dev;
struct drm_device *ddev;
struct drm_device ddev;
struct pci_dev *pdev;
#ifdef __alpha__
struct pci_controller *hose;
Expand Down Expand Up @@ -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)
{
return rdev->ddev;
return &rdev->ddev;
}

/*
Expand Down
3 changes: 0 additions & 3 deletions drivers/gpu/drm/radeon/radeon_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -1285,9 +1285,6 @@ int radeon_device_init(struct radeon_device *rdev,
bool runtime = false;

rdev->shutdown = false;
rdev->dev = &pdev->dev;
rdev->ddev = ddev;
rdev->pdev = pdev;
rdev->flags = flags;
rdev->family = flags & RADEON_FAMILY_MASK;
rdev->is_atom_bios = false;
Expand Down
12 changes: 9 additions & 3 deletions drivers/gpu/drm/radeon/radeon_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ static int radeon_pci_probe(struct pci_dev *pdev,
{
unsigned long flags = 0;
struct drm_device *ddev;
struct radeon_device *rdev;
int ret;

if (!ent)
Expand Down Expand Up @@ -300,9 +301,14 @@ static int radeon_pci_probe(struct pci_dev *pdev,
if (ret)
return ret;

ddev = drm_dev_alloc(&kms_driver, &pdev->dev);
if (IS_ERR(ddev))
return PTR_ERR(ddev);
rdev = devm_drm_dev_alloc(&pdev->dev, &kms_driver, typeof(*rdev), ddev);
if (IS_ERR(rdev))
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);
if (ret)
Expand Down
8 changes: 1 addition & 7 deletions drivers/gpu/drm/radeon/radeon_kms.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
struct pci_dev *pdev = to_pci_dev(dev->dev);
struct radeon_device *rdev;
struct radeon_device *rdev = dev->dev_private;
int r, acpi_status;

rdev = kzalloc(sizeof(struct radeon_device), GFP_KERNEL);
if (rdev == NULL) {
return -ENOMEM;
}
dev->dev_private = (void *)rdev;

#ifdef __alpha__
rdev->hose = pdev->sysdata;
#endif
Expand Down

0 comments on commit a9ed2f0

Please sign in to comment.