Skip to content

Commit df2ce45

Browse files
Luben Tuikovdanvet
authored andcommitted
drm/amdgpu: Convert to using devm_drm_dev_alloc() (v2)
Convert to using devm_drm_dev_alloc(), as drm_dev_init() is going away. v2: Remove drm_dev_put() since a) devres doesn't do refcounting, see Documentation/driver-api/driver-model/devres.rst, Section 4, paragraph 1; and since b) devres acts as garbage collector when the DRM device's parent's devres "action" callback is called to free the container device (amdgpu_device), which embeds the DRM dev. Acked-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Luben Tuikov <luben.tuikov@amd.com> Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> Link: https://patchwork.freedesktop.org/patch/msgid/20200918132505.2316382-4-daniel.vetter@ffwll.ch
1 parent cd01269 commit df2ce45

1 file changed

Lines changed: 4 additions & 12 deletions

File tree

drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,25 +1142,20 @@ static int amdgpu_pci_probe(struct pci_dev *pdev,
11421142
if (ret)
11431143
return ret;
11441144

1145-
adev = kzalloc(sizeof(*adev), GFP_KERNEL);
1146-
if (!adev)
1147-
return -ENOMEM;
1145+
adev = devm_drm_dev_alloc(&pdev->dev, &kms_driver, typeof(*adev), ddev);
1146+
if (IS_ERR(adev))
1147+
return PTR_ERR(adev);
11481148

11491149
adev->dev = &pdev->dev;
11501150
adev->pdev = pdev;
11511151
ddev = adev_to_drm(adev);
1152-
ret = drm_dev_init(ddev, &kms_driver, &pdev->dev);
1153-
if (ret)
1154-
goto err_free;
1155-
1156-
drmm_add_final_kfree(ddev, adev);
11571152

11581153
if (!supports_atomic)
11591154
ddev->driver_features &= ~DRIVER_ATOMIC;
11601155

11611156
ret = pci_enable_device(pdev);
11621157
if (ret)
1163-
goto err_free;
1158+
return ret;
11641159

11651160
ddev->pdev = pdev;
11661161
pci_set_drvdata(pdev, ddev);
@@ -1188,8 +1183,6 @@ static int amdgpu_pci_probe(struct pci_dev *pdev,
11881183

11891184
err_pci:
11901185
pci_disable_device(pdev);
1191-
err_free:
1192-
drm_dev_put(ddev);
11931186
return ret;
11941187
}
11951188

@@ -1206,7 +1199,6 @@ amdgpu_pci_remove(struct pci_dev *pdev)
12061199
amdgpu_driver_unload_kms(dev);
12071200
pci_disable_device(pdev);
12081201
pci_set_drvdata(pdev, NULL);
1209-
drm_dev_put(dev);
12101202
}
12111203

12121204
static void

0 commit comments

Comments
 (0)