staging: sm7xxfb: reserve PCI resource
authorSudip Mukherjee <sudipm.mukherjee@gmail.com>
Sat, 28 Mar 2015 09:03:40 +0000 (14:33 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 3 Apr 2015 11:55:03 +0000 (13:55 +0200)
before starting to access any address inside the PCI region we should
reserve the resource and release the resource when the module exits.

Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/sm7xxfb/sm7xxfb.c

index 5b3e6143a0bafdb8353a1e5ef5bf7a23e8e3f921..149286efda5d42321e6b38dcc485b98753c33992 100644 (file)
@@ -776,6 +776,12 @@ static int smtcfb_pci_probe(struct pci_dev *pdev,
        if (err)
                return err;
 
+       err = pci_request_region(pdev, 0, "sm7xxfb");
+       if (err < 0) {
+               dev_err(&pdev->dev, "cannot reserve framebuffer region\n");
+               goto failed_regions;
+       }
+
        sprintf(smtcfb_fix.id, "sm%Xfb", ent->device);
 
        sfb = smtc_alloc_fb_info(pdev);
@@ -905,6 +911,9 @@ failed_fb:
        smtc_free_fb_info(sfb);
 
 failed_free:
+       pci_release_region(pdev, 0);
+
+failed_regions:
        pci_disable_device(pdev);
 
        return err;
@@ -933,6 +942,7 @@ static void smtcfb_pci_remove(struct pci_dev *pdev)
        smtc_unmap_mmio(sfb);
        unregister_framebuffer(&sfb->fb);
        smtc_free_fb_info(sfb);
+       pci_release_region(pdev, 0);
 }
 
 #ifdef CONFIG_PM