treewide: remove redundant IS_ERR() before error code check
[linux/fpc-iii.git] / drivers / gpu / drm / mgag200 / mgag200_ttm.c
blobe89657630ea711ad5596e3f2fcdfb8d5a165daa8
1 /*
2 * Copyright 2012 Red Hat Inc.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the
6 * "Software"), to deal in the Software without restriction, including
7 * without limitation the rights to use, copy, modify, merge, publish,
8 * distribute, sub license, and/or sell copies of the Software, and to
9 * permit persons to whom the Software is furnished to do so, subject to
10 * the following conditions:
12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
15 * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
16 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
17 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
18 * USE OR OTHER DEALINGS IN THE SOFTWARE.
20 * The above copyright notice and this permission notice (including the
21 * next paragraph) shall be included in all copies or substantial portions
22 * of the Software.
26 * Authors: Dave Airlie <airlied@redhat.com>
29 #include <linux/pci.h>
31 #include "mgag200_drv.h"
33 int mgag200_mm_init(struct mga_device *mdev)
35 struct drm_vram_mm *vmm;
36 int ret;
37 struct drm_device *dev = mdev->dev;
39 vmm = drm_vram_helper_alloc_mm(dev, pci_resource_start(dev->pdev, 0),
40 mdev->mc.vram_size);
41 if (IS_ERR(vmm)) {
42 ret = PTR_ERR(vmm);
43 DRM_ERROR("Error initializing VRAM MM; %d\n", ret);
44 return ret;
47 arch_io_reserve_memtype_wc(pci_resource_start(dev->pdev, 0),
48 pci_resource_len(dev->pdev, 0));
50 mdev->fb_mtrr = arch_phys_wc_add(pci_resource_start(dev->pdev, 0),
51 pci_resource_len(dev->pdev, 0));
53 mdev->vram_fb_available = mdev->mc.vram_size;
55 return 0;
58 void mgag200_mm_fini(struct mga_device *mdev)
60 struct drm_device *dev = mdev->dev;
62 mdev->vram_fb_available = 0;
64 drm_vram_helper_release_mm(dev);
66 arch_io_free_memtype_wc(pci_resource_start(dev->pdev, 0),
67 pci_resource_len(dev->pdev, 0));
68 arch_phys_wc_del(mdev->fb_mtrr);
69 mdev->fb_mtrr = 0;