mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-30 13:23:02 -04:00
fbdev: matrox: Convert to managed PCI and ioremap API
Fix missing pci_disable_device() in probe and remove. Use pcim_enable_device(), devm_request_mem_region(), devm_ioremap() and devm_ioremap_wc() to replace manual resource management. Remove all release_mem_region() and iounmap() calls. Use devm_request_mem_region() instead of pcim_request_region() because the requested sizes (16384 for MMIO, maxvram for FB) do not match the full PCI BAR sizes. Signed-off-by: Shixiong Ou <oushixiong@kylinos.cn> Signed-off-by: Helge Deller <deller@gmx.de>
This commit is contained in:
committed by
Helge Deller
parent
d37b232649
commit
b2c3a91e2b
@@ -374,10 +374,6 @@ static void matroxfb_remove(struct matrox_fb_info *minfo, int dummy)
|
||||
unregister_framebuffer(&minfo->fbcon);
|
||||
matroxfb_g450_shutdown(minfo);
|
||||
arch_phys_wc_del(minfo->wc_cookie);
|
||||
iounmap(minfo->mmio.vbase.vaddr);
|
||||
iounmap(minfo->video.vbase.vaddr);
|
||||
release_mem_region(minfo->video.base, minfo->video.len_maximum);
|
||||
release_mem_region(minfo->mmio.base, 16384);
|
||||
kfree(minfo);
|
||||
}
|
||||
|
||||
@@ -1712,11 +1708,13 @@ static int initMatrox2(struct matrox_fb_info *minfo, struct board *b)
|
||||
goto fail;
|
||||
}
|
||||
memsize = b->base->maxvram;
|
||||
if (!request_mem_region(ctrlptr_phys, 16384, "matroxfb MMIO")) {
|
||||
if (!devm_request_mem_region(&minfo->pcidev->dev, ctrlptr_phys, 16384,
|
||||
"matroxfb MMIO")) {
|
||||
goto fail;
|
||||
}
|
||||
if (!request_mem_region(video_base_phys, memsize, "matroxfb FB")) {
|
||||
goto failCtrlMR;
|
||||
if (!devm_request_mem_region(&minfo->pcidev->dev, video_base_phys,
|
||||
memsize, "matroxfb FB")) {
|
||||
goto fail;
|
||||
}
|
||||
minfo->video.len_maximum = memsize;
|
||||
/* convert mem (autodetect k, M) */
|
||||
@@ -1727,19 +1725,19 @@ static int initMatrox2(struct matrox_fb_info *minfo, struct board *b)
|
||||
memsize = mem;
|
||||
err = -ENOMEM;
|
||||
|
||||
minfo->mmio.vbase.vaddr = ioremap(ctrlptr_phys, 16384);
|
||||
minfo->mmio.vbase.vaddr = devm_ioremap(&minfo->pcidev->dev, ctrlptr_phys, 16384);
|
||||
if (!minfo->mmio.vbase.vaddr) {
|
||||
printk(KERN_ERR "matroxfb: cannot ioremap(%lX, 16384), matroxfb disabled\n", ctrlptr_phys);
|
||||
goto failVideoMR;
|
||||
goto fail;
|
||||
}
|
||||
minfo->mmio.base = ctrlptr_phys;
|
||||
minfo->mmio.len = 16384;
|
||||
minfo->video.base = video_base_phys;
|
||||
minfo->video.vbase.vaddr = ioremap_wc(video_base_phys, memsize);
|
||||
minfo->video.vbase.vaddr = devm_ioremap_wc(&minfo->pcidev->dev, video_base_phys, memsize);
|
||||
if (!minfo->video.vbase.vaddr) {
|
||||
printk(KERN_ERR "matroxfb: cannot ioremap(%lX, %d), matroxfb disabled\n",
|
||||
video_base_phys, memsize);
|
||||
goto failCtrlIO;
|
||||
goto fail;
|
||||
}
|
||||
{
|
||||
u_int32_t cmd;
|
||||
@@ -1954,13 +1952,6 @@ static int initMatrox2(struct matrox_fb_info *minfo, struct board *b)
|
||||
return 0;
|
||||
failVideoIO:;
|
||||
matroxfb_g450_shutdown(minfo);
|
||||
iounmap(minfo->video.vbase.vaddr);
|
||||
failCtrlIO:;
|
||||
iounmap(minfo->mmio.vbase.vaddr);
|
||||
failVideoMR:;
|
||||
release_mem_region(video_base_phys, minfo->video.len_maximum);
|
||||
failCtrlMR:;
|
||||
release_mem_region(ctrlptr_phys, 16384);
|
||||
fail:;
|
||||
return err;
|
||||
}
|
||||
@@ -2069,9 +2060,8 @@ static int matroxfb_probe(struct pci_dev* pdev, const struct pci_device_id* dumm
|
||||
return -ENODEV;
|
||||
}
|
||||
pci_read_config_dword(pdev, PCI_COMMAND, &cmd);
|
||||
if (pci_enable_device(pdev)) {
|
||||
if (pcim_enable_device(pdev))
|
||||
return -1;
|
||||
}
|
||||
|
||||
minfo = kzalloc_obj(*minfo);
|
||||
if (!minfo)
|
||||
|
||||
Reference in New Issue
Block a user