Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

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

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
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -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;
+2 −2
Original line number Original line Diff line number Diff line
@@ -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,
	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;
+3 −6
Original line number Original line Diff line number Diff line
@@ -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);


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)
	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);
+2 −2
Original line number Original line Diff line number Diff line
@@ -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)


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);
+2 −2
Original line number Original line Diff line number Diff line
@@ -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)
	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
Loading