Skip to content

Commit cedb945

Browse files
gregkhtdz
authored andcommitted
drm/vgem/vgem_drv convert to use faux_device
The vgem driver does not need to create a platform device, as there is no real platform resources associated it, it only did so because it was simple to do that in order to get a device to use for resource management of drm resources. Change the driver to use the faux device instead as this is NOT a real platform device. Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com> Cc: Maxime Ripard <mripard@kernel.org> Cc: David Airlie <airlied@gmail.com> Cc: Simona Vetter <simona@ffwll.ch> Cc: dri-devel@lists.freedesktop.org Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de> Reviewed-by: Lyude Paul <lyude@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Link: https://lore.kernel.org/r/2025070114-iron-shiny-b92e@gregkh
1 parent 5686601 commit cedb945

1 file changed

Lines changed: 15 additions & 15 deletions

File tree

drivers/gpu/drm/vgem/vgem_drv.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
#include <linux/dma-buf.h>
3434
#include <linux/module.h>
35-
#include <linux/platform_device.h>
35+
#include <linux/device/faux.h>
3636
#include <linux/shmem_fs.h>
3737
#include <linux/vmalloc.h>
3838

@@ -52,7 +52,7 @@
5252

5353
static struct vgem_device {
5454
struct drm_device drm;
55-
struct platform_device *platform;
55+
struct faux_device *faux_dev;
5656
} *vgem_device;
5757

5858
static int vgem_open(struct drm_device *dev, struct drm_file *file)
@@ -127,27 +127,27 @@ static const struct drm_driver vgem_driver = {
127127
static int __init vgem_init(void)
128128
{
129129
int ret;
130-
struct platform_device *pdev;
130+
struct faux_device *fdev;
131131

132-
pdev = platform_device_register_simple("vgem", -1, NULL, 0);
133-
if (IS_ERR(pdev))
134-
return PTR_ERR(pdev);
132+
fdev = faux_device_create("vgem", NULL, NULL);
133+
if (!fdev)
134+
return -ENODEV;
135135

136-
if (!devres_open_group(&pdev->dev, NULL, GFP_KERNEL)) {
136+
if (!devres_open_group(&fdev->dev, NULL, GFP_KERNEL)) {
137137
ret = -ENOMEM;
138138
goto out_unregister;
139139
}
140140

141-
dma_coerce_mask_and_coherent(&pdev->dev,
141+
dma_coerce_mask_and_coherent(&fdev->dev,
142142
DMA_BIT_MASK(64));
143143

144-
vgem_device = devm_drm_dev_alloc(&pdev->dev, &vgem_driver,
144+
vgem_device = devm_drm_dev_alloc(&fdev->dev, &vgem_driver,
145145
struct vgem_device, drm);
146146
if (IS_ERR(vgem_device)) {
147147
ret = PTR_ERR(vgem_device);
148148
goto out_devres;
149149
}
150-
vgem_device->platform = pdev;
150+
vgem_device->faux_dev = fdev;
151151

152152
/* Final step: expose the device/driver to userspace */
153153
ret = drm_dev_register(&vgem_device->drm, 0);
@@ -157,19 +157,19 @@ static int __init vgem_init(void)
157157
return 0;
158158

159159
out_devres:
160-
devres_release_group(&pdev->dev, NULL);
160+
devres_release_group(&fdev->dev, NULL);
161161
out_unregister:
162-
platform_device_unregister(pdev);
162+
faux_device_destroy(fdev);
163163
return ret;
164164
}
165165

166166
static void __exit vgem_exit(void)
167167
{
168-
struct platform_device *pdev = vgem_device->platform;
168+
struct faux_device *fdev = vgem_device->faux_dev;
169169

170170
drm_dev_unregister(&vgem_device->drm);
171-
devres_release_group(&pdev->dev, NULL);
172-
platform_device_unregister(pdev);
171+
devres_release_group(&fdev->dev, NULL);
172+
faux_device_destroy(fdev);
173173
}
174174

175175
module_init(vgem_init);

0 commit comments

Comments
 (0)