From: Shixiong Ou <[email protected]>
Fix missing pci_disable_device() in probe and remove.
Use pcim_enable_device(), pcim_request_region(), devm_ioremap()
and devm_ioremap_wc() to replace manual resource management.
Remove all release_mem_region() and iounmap() calls.
Signed-off-by: Shixiong Ou <[email protected]>
---
drivers/video/fbdev/aty/aty128fb.c | 40 +++++++++---------------------
1 file changed, 12 insertions(+), 28 deletions(-)
diff --git a/drivers/video/fbdev/aty/aty128fb.c b/drivers/video/fbdev/aty/aty128fb.c
index bcb10e66221c..b76bfe014f41 100644
--- a/drivers/video/fbdev/aty/aty128fb.c
+++ b/drivers/video/fbdev/aty/aty128fb.c
@@ -2009,31 +2009,30 @@ static int aty128_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
return err;
/* Enable device in PCI config */
- if ((err = pci_enable_device(pdev))) {
+ err = pcim_enable_device(pdev);
+ if (err) {
printk(KERN_ERR "aty128fb: Cannot enable PCI device: %d\n",
err);
return -ENODEV;
}
fb_addr = pci_resource_start(pdev, 0);
- if (!request_mem_region(fb_addr, pci_resource_len(pdev, 0),
- "aty128fb FB")) {
+ if (!pcim_request_region(pdev, 0, "aty128fb FB")) {
printk(KERN_ERR "aty128fb: cannot reserve frame "
"buffer memory\n");
return -ENODEV;
}
reg_addr = pci_resource_start(pdev, 2);
- if (!request_mem_region(reg_addr, pci_resource_len(pdev, 2),
- "aty128fb MMIO")) {
+ if (!pcim_request_region(pdev, 2, "aty128fb MMIO")) {
printk(KERN_ERR "aty128fb: cannot reserve MMIO region\n");
- goto err_free_fb;
+ goto err_free_info;
}
/* We have the resources. Now virtualize them */
info = framebuffer_alloc(sizeof(struct aty128fb_par), &pdev->dev);
if (!info)
- goto err_free_mmio;
+ goto err_free_info;
par = info->par;
@@ -2041,7 +2040,8 @@ static int aty128_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
/* Virtualize mmio region */
info->fix.mmio_start = reg_addr;
- par->regbase = pci_ioremap_bar(pdev, 2);
+ par->regbase = devm_ioremap(&pdev->dev, pci_resource_start(pdev, 2),
+ pci_resource_len(pdev, 2));
if (!par->regbase)
goto err_free_info;
@@ -2050,9 +2050,9 @@ static int aty128_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
par->vram_size = aty_ld_le32(CNFG_MEMSIZE) & 0x03FFFFFF;
/* Virtualize the framebuffer */
- info->screen_base = ioremap_wc(fb_addr, par->vram_size);
+ info->screen_base = devm_ioremap_wc(&pdev->dev, fb_addr, par->vram_size);
if (!info->screen_base)
- goto err_unmap_out;
+ goto err_free_info;
/* Set up info->fix */
info->fix = aty128fb_fix;
@@ -2063,7 +2063,7 @@ static int aty128_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
/* If we can't test scratch registers, something is seriously wrong */
if (!register_test(par)) {
printk(KERN_ERR "aty128fb: Can't write to video register!\n");
- goto err_out;
+ goto err_free_info;
}
#ifndef __sparc__
@@ -2085,25 +2085,15 @@ static int aty128_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
pci_set_drvdata(pdev, info);
if (!aty128_init(pdev, ent))
- goto err_out;
+ goto err_free_info;
if (mtrr)
par->wc_cookie = arch_phys_wc_add(info->fix.smem_start,
par->vram_size);
return 0;
-err_out:
- iounmap(info->screen_base);
-err_unmap_out:
- iounmap(par->regbase);
err_free_info:
framebuffer_release(info);
-err_free_mmio:
- release_mem_region(pci_resource_start(pdev, 2),
- pci_resource_len(pdev, 2));
-err_free_fb:
- release_mem_region(pci_resource_start(pdev, 0),
- pci_resource_len(pdev, 0));
return -ENODEV;
}
@@ -2124,13 +2114,7 @@ static void aty128_remove(struct pci_dev *pdev)
unregister_framebuffer(info);
arch_phys_wc_del(par->wc_cookie);
- iounmap(par->regbase);
- iounmap(info->screen_base);
- release_mem_region(pci_resource_start(pdev, 0),
- pci_resource_len(pdev, 0));
- release_mem_region(pci_resource_start(pdev, 2),
- pci_resource_len(pdev, 2));
framebuffer_release(info);
}
#endif /* CONFIG_PCI */
--
2.25.1
No virus found
Checked by Hillstone Network AntiVirus
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.