Commit d9906753 authored by Daniel Vetter's avatar Daniel Vetter Committed by Dave Airlie

drm: rip out drm_core_has_AGP

Most place actually want to just check for dev->agp (most do, but a
few don't so this fixes a few potential NULL derefs). The only
exception is the agp init code which should check for the AGP driver
feature flag.
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
parent 8da79ccd
...@@ -439,7 +439,7 @@ void drm_agp_clear(struct drm_device *dev) ...@@ -439,7 +439,7 @@ void drm_agp_clear(struct drm_device *dev)
{ {
struct drm_agp_mem *entry, *tempe; struct drm_agp_mem *entry, *tempe;
if (!drm_core_has_AGP(dev) || !dev->agp) if (!dev->agp)
return; return;
if (drm_core_check_feature(dev, DRIVER_MODESET)) if (drm_core_check_feature(dev, DRIVER_MODESET))
return; return;
......
...@@ -261,7 +261,7 @@ static int drm_addmap_core(struct drm_device * dev, resource_size_t offset, ...@@ -261,7 +261,7 @@ static int drm_addmap_core(struct drm_device * dev, resource_size_t offset,
struct drm_agp_mem *entry; struct drm_agp_mem *entry;
int valid = 0; int valid = 0;
if (!drm_core_has_AGP(dev)) { if (!dev->agp) {
kfree(map); kfree(map);
return -EINVAL; return -EINVAL;
} }
...@@ -1390,7 +1390,7 @@ int drm_mapbufs(struct drm_device *dev, void *data, ...@@ -1390,7 +1390,7 @@ int drm_mapbufs(struct drm_device *dev, void *data,
spin_unlock(&dev->count_lock); spin_unlock(&dev->count_lock);
if (request->count >= dma->buf_count) { if (request->count >= dma->buf_count) {
if ((drm_core_has_AGP(dev) && (dma->flags & _DRM_DMA_USE_AGP)) if ((dev->agp && (dma->flags & _DRM_DMA_USE_AGP))
|| (drm_core_check_feature(dev, DRIVER_SG) || (drm_core_check_feature(dev, DRIVER_SG)
&& (dma->flags & _DRM_DMA_USE_SG))) { && (dma->flags & _DRM_DMA_USE_SG))) {
struct drm_local_map *map = dev->agp_buffer_map; struct drm_local_map *map = dev->agp_buffer_map;
......
...@@ -110,8 +110,7 @@ static inline void *agp_remap(unsigned long offset, unsigned long size, ...@@ -110,8 +110,7 @@ static inline void *agp_remap(unsigned long offset, unsigned long size,
void drm_core_ioremap(struct drm_local_map *map, struct drm_device *dev) void drm_core_ioremap(struct drm_local_map *map, struct drm_device *dev)
{ {
if (drm_core_has_AGP(dev) && if (dev->agp && dev->agp->cant_use_aperture && map->type == _DRM_AGP)
dev->agp && dev->agp->cant_use_aperture && map->type == _DRM_AGP)
map->handle = agp_remap(map->offset, map->size, dev); map->handle = agp_remap(map->offset, map->size, dev);
else else
map->handle = ioremap(map->offset, map->size); map->handle = ioremap(map->offset, map->size);
...@@ -120,8 +119,7 @@ EXPORT_SYMBOL(drm_core_ioremap); ...@@ -120,8 +119,7 @@ EXPORT_SYMBOL(drm_core_ioremap);
void drm_core_ioremap_wc(struct drm_local_map *map, struct drm_device *dev) void drm_core_ioremap_wc(struct drm_local_map *map, struct drm_device *dev)
{ {
if (drm_core_has_AGP(dev) && if (dev->agp && dev->agp->cant_use_aperture && map->type == _DRM_AGP)
dev->agp && dev->agp->cant_use_aperture && map->type == _DRM_AGP)
map->handle = agp_remap(map->offset, map->size, dev); map->handle = agp_remap(map->offset, map->size, dev);
else else
map->handle = ioremap_wc(map->offset, map->size); map->handle = ioremap_wc(map->offset, map->size);
...@@ -133,8 +131,7 @@ void drm_core_ioremapfree(struct drm_local_map *map, struct drm_device *dev) ...@@ -133,8 +131,7 @@ void drm_core_ioremapfree(struct drm_local_map *map, struct drm_device *dev)
if (!map->handle || !map->size) if (!map->handle || !map->size)
return; return;
if (drm_core_has_AGP(dev) && if (dev->agp && dev->agp->cant_use_aperture && map->type == _DRM_AGP)
dev->agp && dev->agp->cant_use_aperture && map->type == _DRM_AGP)
vunmap(map->handle); vunmap(map->handle);
else else
iounmap(map->handle); iounmap(map->handle);
......
...@@ -264,7 +264,7 @@ static int drm_pci_irq_by_busid(struct drm_device *dev, struct drm_irq_busid *p) ...@@ -264,7 +264,7 @@ static int drm_pci_irq_by_busid(struct drm_device *dev, struct drm_irq_busid *p)
static void drm_pci_agp_init(struct drm_device *dev) static void drm_pci_agp_init(struct drm_device *dev)
{ {
if (drm_core_has_AGP(dev)) { if (drm_core_check_feature(dev, DRIVER_USE_AGP)) {
if (drm_pci_device_is_agp(dev)) if (drm_pci_device_is_agp(dev))
dev->agp = drm_agp_init(dev); dev->agp = drm_agp_init(dev);
if (dev->agp) { if (dev->agp) {
...@@ -278,7 +278,7 @@ static void drm_pci_agp_init(struct drm_device *dev) ...@@ -278,7 +278,7 @@ static void drm_pci_agp_init(struct drm_device *dev)
static void drm_pci_agp_destroy(struct drm_device *dev) static void drm_pci_agp_destroy(struct drm_device *dev)
{ {
if (drm_core_has_AGP(dev) && dev->agp) { if (dev->agp) {
arch_phys_wc_del(dev->agp->agp_mtrr); arch_phys_wc_del(dev->agp->agp_mtrr);
drm_agp_clear(dev); drm_agp_clear(dev);
drm_agp_destroy(dev->agp); drm_agp_destroy(dev->agp);
......
...@@ -101,7 +101,7 @@ static int drm_do_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf) ...@@ -101,7 +101,7 @@ static int drm_do_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
/* /*
* Find the right map * Find the right map
*/ */
if (!drm_core_has_AGP(dev)) if (!dev->agp)
goto vm_fault_error; goto vm_fault_error;
if (!dev->agp || !dev->agp->cant_use_aperture) if (!dev->agp || !dev->agp->cant_use_aperture)
...@@ -592,7 +592,7 @@ int drm_mmap_locked(struct file *filp, struct vm_area_struct *vma) ...@@ -592,7 +592,7 @@ int drm_mmap_locked(struct file *filp, struct vm_area_struct *vma)
switch (map->type) { switch (map->type) {
#if !defined(__arm__) #if !defined(__arm__)
case _DRM_AGP: case _DRM_AGP:
if (drm_core_has_AGP(dev) && dev->agp->cant_use_aperture) { if (dev->agp && dev->agp->cant_use_aperture) {
/* /*
* On some platforms we can't talk to bus dma address from the CPU, so for * On some platforms we can't talk to bus dma address from the CPU, so for
* memory of type DRM_AGP, we'll deal with sorting out the real physical * memory of type DRM_AGP, we'll deal with sorting out the real physical
......
...@@ -142,7 +142,7 @@ static int radeon_init_mem_type(struct ttm_bo_device *bdev, uint32_t type, ...@@ -142,7 +142,7 @@ static int radeon_init_mem_type(struct ttm_bo_device *bdev, uint32_t type,
man->flags = TTM_MEMTYPE_FLAG_MAPPABLE | TTM_MEMTYPE_FLAG_CMA; man->flags = TTM_MEMTYPE_FLAG_MAPPABLE | TTM_MEMTYPE_FLAG_CMA;
#if __OS_HAS_AGP #if __OS_HAS_AGP
if (rdev->flags & RADEON_IS_AGP) { if (rdev->flags & RADEON_IS_AGP) {
if (!(drm_core_has_AGP(rdev->ddev) && rdev->ddev->agp)) { if (!rdev->ddev->agp) {
DRM_ERROR("AGP is not enabled for memory type %u\n", DRM_ERROR("AGP is not enabled for memory type %u\n",
(unsigned)type); (unsigned)type);
return -EINVAL; return -EINVAL;
......
...@@ -46,12 +46,6 @@ int drm_agp_unbind_ioctl(struct drm_device *dev, void *data, ...@@ -46,12 +46,6 @@ int drm_agp_unbind_ioctl(struct drm_device *dev, void *data,
int drm_agp_bind(struct drm_device *dev, struct drm_agp_binding *request); int drm_agp_bind(struct drm_device *dev, struct drm_agp_binding *request);
int drm_agp_bind_ioctl(struct drm_device *dev, void *data, int drm_agp_bind_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv); struct drm_file *file_priv);
static inline int drm_core_has_AGP(struct drm_device *dev)
{
return drm_core_check_feature(dev, DRIVER_USE_AGP);
}
#else /* __OS_HAS_AGP */ #else /* __OS_HAS_AGP */
static inline void drm_free_agp(DRM_AGP_MEM * handle, int pages) static inline void drm_free_agp(DRM_AGP_MEM * handle, int pages)
...@@ -183,12 +177,6 @@ static inline int drm_agp_bind_ioctl(struct drm_device *dev, void *data, ...@@ -183,12 +177,6 @@ static inline int drm_agp_bind_ioctl(struct drm_device *dev, void *data,
{ {
return -ENODEV; return -ENODEV;
} }
static inline int drm_core_has_AGP(struct drm_device *dev)
{
return 0;
}
#endif /* __OS_HAS_AGP */ #endif /* __OS_HAS_AGP */
#endif /* _DRM_AGPSUPPORT_H_ */ #endif /* _DRM_AGPSUPPORT_H_ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment