Skip to content

Commit 58e980c

Browse files
author
Thomas Zimmermann
committed
drm/bochs: Do managed resource cleanup
Do managed cleanup of all PCI resources. Remove the now-unused cleanup helper bochs_hw_fini(). Signed-off-by: Thomas Zimmermann <[email protected]> Acked-by: Gerd Hoffmann <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 759ef92 commit 58e980c

File tree

1 file changed

+10
-32
lines changed

1 file changed

+10
-32
lines changed

drivers/gpu/drm/tiny/bochs.c

Lines changed: 10 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -212,22 +212,22 @@ static int bochs_hw_init(struct drm_device *dev)
212212
u16 id;
213213

214214
if (pdev->resource[2].flags & IORESOURCE_MEM) {
215+
ioaddr = pci_resource_start(pdev, 2);
216+
iosize = pci_resource_len(pdev, 2);
215217
/* mmio bar with vga and bochs registers present */
216-
if (pci_request_region(pdev, 2, "bochs-drm") != 0) {
218+
if (!devm_request_mem_region(&pdev->dev, ioaddr, iosize, "bochs-drm")) {
217219
DRM_ERROR("Cannot request mmio region\n");
218220
return -EBUSY;
219221
}
220-
ioaddr = pci_resource_start(pdev, 2);
221-
iosize = pci_resource_len(pdev, 2);
222-
bochs->mmio = ioremap(ioaddr, iosize);
222+
bochs->mmio = devm_ioremap(&pdev->dev, ioaddr, iosize);
223223
if (bochs->mmio == NULL) {
224224
DRM_ERROR("Cannot map mmio region\n");
225225
return -ENOMEM;
226226
}
227227
} else {
228228
ioaddr = VBE_DISPI_IOPORT_INDEX;
229229
iosize = 2;
230-
if (!request_region(ioaddr, iosize, "bochs-drm")) {
230+
if (!devm_request_region(&pdev->dev, ioaddr, iosize, "bochs-drm")) {
231231
DRM_ERROR("Cannot request ioports\n");
232232
return -EBUSY;
233233
}
@@ -254,10 +254,10 @@ static int bochs_hw_init(struct drm_device *dev)
254254
size = min(size, mem);
255255
}
256256

257-
if (pci_request_region(pdev, 0, "bochs-drm") != 0)
257+
if (!devm_request_mem_region(&pdev->dev, addr, size, "bochs-drm"))
258258
DRM_WARN("Cannot request framebuffer, boot fb still active?\n");
259259

260-
bochs->fb_map = ioremap(addr, size);
260+
bochs->fb_map = devm_ioremap(&pdev->dev, addr, size);
261261
if (bochs->fb_map == NULL) {
262262
DRM_ERROR("Cannot map framebuffer\n");
263263
return -ENOMEM;
@@ -286,21 +286,6 @@ static int bochs_hw_init(struct drm_device *dev)
286286
return 0;
287287
}
288288

289-
static void bochs_hw_fini(struct drm_device *dev)
290-
{
291-
struct bochs_device *bochs = dev->dev_private;
292-
293-
/* TODO: shot down existing vram mappings */
294-
295-
if (bochs->mmio)
296-
iounmap(bochs->mmio);
297-
if (bochs->ioports)
298-
release_region(VBE_DISPI_IOPORT_INDEX, 2);
299-
if (bochs->fb_map)
300-
iounmap(bochs->fb_map);
301-
pci_release_regions(to_pci_dev(dev->dev));
302-
}
303-
304289
static void bochs_hw_blank(struct bochs_device *bochs, bool blank)
305290
{
306291
DRM_DEBUG_DRIVER("hw_blank %d\n", blank);
@@ -565,17 +550,13 @@ static int bochs_load(struct drm_device *dev)
565550

566551
ret = drmm_vram_helper_init(dev, bochs->fb_base, bochs->fb_size);
567552
if (ret)
568-
goto err_hw_fini;
553+
return ret;
569554

570555
ret = bochs_kms_init(bochs);
571556
if (ret)
572-
goto err_hw_fini;
557+
return ret;
573558

574559
return 0;
575-
576-
err_hw_fini:
577-
bochs_hw_fini(dev);
578-
return ret;
579560
}
580561

581562
DEFINE_DRM_GEM_FOPS(bochs_fops);
@@ -650,13 +631,11 @@ static int bochs_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent
650631

651632
ret = drm_dev_register(dev, 0);
652633
if (ret)
653-
goto err_hw_fini;
634+
goto err_free_dev;
654635

655636
drm_fbdev_ttm_setup(dev, 32);
656637
return ret;
657638

658-
err_hw_fini:
659-
bochs_hw_fini(dev);
660639
err_free_dev:
661640
drm_dev_put(dev);
662641
return ret;
@@ -668,7 +647,6 @@ static void bochs_pci_remove(struct pci_dev *pdev)
668647

669648
drm_dev_unplug(dev);
670649
drm_atomic_helper_shutdown(dev);
671-
bochs_hw_fini(dev);
672650
drm_dev_put(dev);
673651
}
674652

0 commit comments

Comments
 (0)