fbdev: savage: Convert to managed PCI and ioremap API

Fix missing pci_disable_device() in probe and remove.

Use pcim_enable_device(), pcim_request_all_regions(),
devm_ioremap() and devm_ioremap_wc() to replace manual resource
management. Remove all pci_release_regions() and iounmap() calls.
Merge failed_init label into failed_enable.

Signed-off-by: Shixiong Ou <oushixiong@kylinos.cn>
Signed-off-by: Helge Deller <deller@gmx.de>
This commit is contained in:
Shixiong Ou
2026-08-13 20:50:13 +08:00
committed by Helge Deller
parent a41961f364
commit d37b232649

View File

@@ -1728,7 +1728,7 @@ static int savage_map_mmio(struct fb_info *info)
par->mmio.len = SAVAGE_NEWMMIO_REGSIZE;
par->mmio.vbase = ioremap(par->mmio.pbase, par->mmio.len);
par->mmio.vbase = devm_ioremap(&par->pcidev->dev, par->mmio.pbase, par->mmio.len);
if (!par->mmio.vbase) {
printk("savagefb: unable to map memory mapped IO\n");
return -ENOMEM;
@@ -1755,7 +1755,6 @@ static void savage_unmap_mmio(struct fb_info *info)
savage_disable_mmio(par);
if (par->mmio.vbase) {
iounmap(par->mmio.vbase);
par->mmio.vbase = NULL;
}
}
@@ -1774,7 +1773,7 @@ static int savage_map_video(struct fb_info *info, int video_len)
par->video.pbase = pci_resource_start(par->pcidev, resource);
par->video.len = video_len;
par->video.vbase = ioremap_wc(par->video.pbase, par->video.len);
par->video.vbase = devm_ioremap_wc(&par->pcidev->dev, par->video.pbase, par->video.len);
if (!par->video.vbase) {
printk("savagefb: unable to map screen memory\n");
@@ -1802,7 +1801,6 @@ static void savage_unmap_video(struct fb_info *info)
if (par->video.vbase) {
arch_phys_wc_del(par->video.wc_cookie);
iounmap(par->video.vbase);
par->video.vbase = NULL;
info->screen_base = NULL;
}
@@ -2188,11 +2186,12 @@ static int savagefb_probe(struct pci_dev *dev, const struct pci_device_id *id)
return -ENOMEM;
par = info->par;
mutex_init(&par->open_lock);
err = pci_enable_device(dev);
err = pcim_enable_device(dev);
if (err)
goto failed_enable;
if ((err = pci_request_regions(dev, "savagefb"))) {
err = pcim_request_all_regions(dev, "savagefb");
if (err) {
printk(KERN_ERR "cannot request PCI regions\n");
goto failed_enable;
}
@@ -2200,7 +2199,7 @@ static int savagefb_probe(struct pci_dev *dev, const struct pci_device_id *id)
err = -ENOMEM;
if ((err = savage_init_fb_info(info, dev, id)))
goto failed_init;
goto failed_enable;
err = savage_map_mmio(info);
if (err)
@@ -2331,8 +2330,6 @@ static int savagefb_probe(struct pci_dev *dev, const struct pci_device_id *id)
savage_unmap_mmio(info);
failed_mmio:
kfree(info->pixmap.addr);
failed_init:
pci_release_regions(dev);
failed_enable:
framebuffer_release(info);
@@ -2355,7 +2352,6 @@ static void savagefb_remove(struct pci_dev *dev)
savage_unmap_video(info);
savage_unmap_mmio(info);
kfree(info->pixmap.addr);
pci_release_regions(dev);
framebuffer_release(info);
}
}