drm: Implement and use the Linux version of kfree()
authorFrançois Tigeot <ftigeot@wolfpond.org>
Sun, 24 May 2015 07:53:21 +0000 (08:53 +0100)
committerFrançois Tigeot <ftigeot@wolfpond.org>
Sun, 25 Jan 2015 08:20:54 +0000 (09:20 +0100)
34 files changed:
sys/dev/drm/drm_bufs.c
sys/dev/drm/drm_crtc_helper.c
sys/dev/drm/drm_edid.c
sys/dev/drm/drm_fb_helper.c
sys/dev/drm/drm_hashtab.c
sys/dev/drm/drm_linux_list_sort.c
sys/dev/drm/drm_vm.c
sys/dev/drm/i915/i915_dma.c
sys/dev/drm/i915/i915_gem.c
sys/dev/drm/i915/i915_gem_context.c
sys/dev/drm/i915/i915_gem_gtt.c
sys/dev/drm/i915/intel_crt.c
sys/dev/drm/i915/intel_ddi.c
sys/dev/drm/i915/intel_display.c
sys/dev/drm/i915/intel_dp.c
sys/dev/drm/i915/intel_fb.c
sys/dev/drm/i915/intel_hdmi.c
sys/dev/drm/i915/intel_lvds.c
sys/dev/drm/i915/intel_modes.c
sys/dev/drm/i915/intel_overlay.c
sys/dev/drm/i915/intel_pm.c
sys/dev/drm/i915/intel_ringbuffer.c
sys/dev/drm/i915/intel_sdvo.c
sys/dev/drm/i915/intel_sprite.c
sys/dev/drm/i915/intel_tv.c
sys/dev/drm/include/drm/drmP.h
sys/dev/drm/include/drm/drm_mem_util.h
sys/dev/drm/include/linux/slab.h [new file with mode: 0644]
sys/dev/drm/include/linux/workqueue.h
sys/dev/drm/radeon/radeon_connectors.c
sys/dev/drm/radeon/radeon_display.c
sys/dev/drm/ttm/ttm_bo.c
sys/dev/drm/ttm/ttm_bo_manager.c
sys/dev/drm/ttm/ttm_bo_util.c

index ef45766..09e1fab 100644 (file)
@@ -233,7 +233,7 @@ int drm_addmap(struct drm_device * dev, resource_size_t offset,
                 * need to point to a 64bit variable first. */
                dmah = drm_pci_alloc(dev, map->size, map->size);
                if (!dmah) {
-                       kfree(map, M_DRM);
+                       kfree(map);
                        return -ENOMEM;
                }
                map->handle = dmah->vaddr;
index 6dd2708..03367ca 100644 (file)
@@ -787,9 +787,9 @@ int drm_crtc_helper_set_config(struct drm_mode_set *set)
                }
        }
 
-       kfree(save_connectors, M_DRM);
-       kfree(save_encoders, M_DRM);
-       kfree(save_crtcs, M_DRM);
+       kfree(save_connectors);
+       kfree(save_encoders);
+       kfree(save_crtcs);
        return 0;
 
 fail:
index 1c0fd56..b66e4c1 100644 (file)
@@ -1135,7 +1135,7 @@ carp:
        connector->bad_edid_counter++;
 
 out:
-       kfree(block, M_DRM);
+       kfree(block);
        return NULL;
 }
 
index cf98792..bb8d2d4 100644 (file)
@@ -466,7 +466,7 @@ int drm_fb_helper_init(struct drm_device *dev,
            sizeof(struct drm_fb_helper_connector *), M_DRM,
            M_WAITOK | M_ZERO);
        if (!fb_helper->connector_info) {
-               kfree(fb_helper->crtc_info, M_DRM);
+               kfree(fb_helper->crtc_info);
                return -ENOMEM;
        }
        fb_helper->connector_count = 0;
index 55b996e..bbea5f7 100644 (file)
@@ -198,7 +198,7 @@ EXPORT_SYMBOL(drm_ht_remove_item);
 void drm_ht_remove(struct drm_open_hash *ht)
 {
        if (ht->table) {
-               kfree(ht->table, M_DRM);
+               kfree(ht->table);
                ht->table = NULL;
        }
 }
index 1d24b77..1d07cf0 100644 (file)
@@ -72,5 +72,5 @@ drm_list_sort(void *priv, struct list_head *head, int (*cmp)(void *priv,
        INIT_LIST_HEAD(head);
        for (i = 0; i < count; i++)
                list_add_tail(ar[i], head);
-       kfree(ar, M_TEMP);
+       kfree(ar);
 }
index 6244370..2f01e64 100644 (file)
@@ -201,7 +201,7 @@ vm_phys_fictitious_reg_range(vm_paddr_t start, vm_paddr_t end,
                 }
         }
         mtx_unlock(&vm_phys_fictitious_reg_mtx);
-        kfree(fp, M_DRM);
+        kfree(fp);
         return (EBUSY);
 }
 
@@ -220,7 +220,7 @@ vm_phys_fictitious_unreg_range(vm_paddr_t start, vm_paddr_t end)
                        fp = seg->first_page;
                        seg->first_page = NULL;
                        mtx_unlock(&vm_phys_fictitious_reg_mtx);
-                       kfree(fp, M_DRM);
+                       kfree(fp);
                        return;
                }
        }
index c696eea..54c771c 100644 (file)
@@ -657,7 +657,7 @@ static int i915_batchbuffer(struct drm_device *dev, void *data,
                sarea_priv->last_dispatch = READ_BREADCRUMB(dev_priv);
 
 fail_free:
-       kfree(cliprects, M_DRM);
+       kfree(cliprects);
        return ret;
 }
 
@@ -1573,7 +1573,7 @@ out_gem_unload:
 out_mtrrfree:
 put_bridge:
 free_priv:
-       kfree(dev_priv, M_DRM);
+       kfree(dev_priv);
        return ret;
 }
 
@@ -1625,7 +1625,7 @@ int i915_driver_unload(struct drm_device *dev)
                 * config parsed from VBT
                 */
                if (dev_priv->child_dev && dev_priv->child_dev_num) {
-                       kfree(dev_priv->child_dev, M_DRM);
+                       kfree(dev_priv->child_dev);
                        dev_priv->child_dev = NULL;
                        dev_priv->child_dev_num = 0;
                }
@@ -1736,7 +1736,7 @@ void i915_driver_postclose(struct drm_device *dev, struct drm_file *file)
 {
        struct drm_i915_file_private *file_priv = file->driver_priv;
 
-       kfree(file_priv, M_DRM);
+       kfree(file_priv);
 }
 
 struct drm_ioctl_desc i915_ioctls[] = {
index e02738d..edf5db9 100644 (file)
@@ -1646,7 +1646,7 @@ i915_add_request(struct intel_ring_buffer *ring,
 
        ret = ring->add_request(ring);
        if (ret) {
-               kfree(request, M_DRM);
+               kfree(request);
                return ret;
        }
 
@@ -1809,7 +1809,7 @@ i915_gem_retire_requests_ring(struct intel_ring_buffer *ring)
 
                list_del(&request->list);
                i915_gem_request_remove_from_client(request);
-               kfree(request, M_DRM);
+               kfree(request);
        }
 
        /* Move any buffers on the active list that are no longer referenced
@@ -3405,7 +3405,7 @@ struct drm_i915_gem_object *i915_gem_alloc_object(struct drm_device *dev,
                return NULL;
 
        if (drm_gem_object_init(dev, &obj->base, size) != 0) {
-               kfree(obj, M_DRM);
+               kfree(obj);
                return NULL;
        }
 
index 237af04..fed7afd 100644 (file)
@@ -131,7 +131,7 @@ static void do_destroy(struct i915_hw_context *ctx)
                idr_remove(&ctx->file_priv->context_idr, ctx->id);
 
        drm_gem_object_unreference(&ctx->obj->base);
-       kfree(ctx, M_DRM);
+       kfree(ctx);
 }
 
 static struct i915_hw_context *
@@ -148,7 +148,7 @@ create_hw_context(struct drm_device *dev,
 
        ctx->obj = i915_gem_alloc_object(dev, dev_priv->hw_context_size);
        if (ctx->obj == NULL) {
-               kfree(ctx, M_DRM);
+               kfree(ctx);
                DRM_DEBUG_DRIVER("Context object allocated failed\n");
                return ERR_PTR(-ENOMEM);
        }
index 21105f9..88df8f8 100644 (file)
@@ -234,7 +234,7 @@ static int i915_gem_init_aliasing_ppgtt(struct drm_device *dev)
 
        ret = gen6_ppgtt_init(ppgtt);
        if (ret)
-               kfree(ppgtt, M_DRM);
+               kfree(ppgtt);
        else
                dev_priv->mm.aliasing_ppgtt = ppgtt;
 
index 8886d4d..601e0b6 100644 (file)
@@ -410,7 +410,7 @@ static int intel_crt_ddc_get_modes(struct drm_connector *connector,
                return 0;
 
        ret = intel_connector_update_modes(connector, edid);
-       kfree(edid, M_DRM);
+       kfree(edid);
 
        return ret;
 }
@@ -735,7 +735,7 @@ void intel_crt_init(struct drm_device *dev)
        intel_connector = kmalloc(sizeof(struct intel_connector), M_DRM,
            M_WAITOK | M_ZERO);
        if (!intel_connector) {
-               kfree(crt, M_DRM);
+               kfree(crt);
                return;
        }
 
index f3ea7a2..83a3fda 100644 (file)
@@ -1510,7 +1510,7 @@ void intel_ddi_init(struct drm_device *dev, enum port port)
        dp_connector = kmalloc(sizeof(struct intel_connector),
                M_DRM, M_WAITOK | M_ZERO);
        if (!dp_connector) {
-               kfree(intel_dig_port, M_DRM);
+               kfree(intel_dig_port);
                return;
        }
 
@@ -1518,8 +1518,8 @@ void intel_ddi_init(struct drm_device *dev, enum port port)
                hdmi_connector = kmalloc(sizeof(struct intel_connector),
                        M_DRM, M_WAITOK | M_ZERO);
                if (!hdmi_connector) {
-                       kfree(dp_connector, M_DRM);
-                       kfree(intel_dig_port, M_DRM);
+                       kfree(dp_connector);
+                       kfree(intel_dig_port);
                        return;
                }
        }
index 63a3be9..729290a 100644 (file)
@@ -6514,7 +6514,7 @@ intel_framebuffer_create(struct drm_device *dev,
        ret = intel_framebuffer_init(dev, intel_fb, mode_cmd, obj);
        if (ret) {
                drm_gem_object_unreference_unlocked(&obj->base);
-               kfree(intel_fb, M_DRM);
+               kfree(intel_fb);
                return ERR_PTR(ret);
        }
 
@@ -6959,7 +6959,7 @@ static void intel_crtc_destroy(struct drm_crtc *crtc)
 
        if (work) {
                cancel_work_sync(&work->work);
-               kfree(work, M_DRM);
+               kfree(work);
        }
 
        drm_crtc_cleanup(crtc);
@@ -7906,7 +7906,7 @@ done:
        }
 
 out:
-       kfree(saved_mode, M_DRM);
+       kfree(saved_mode);
        return ret;
 }
 
index caa4e95..766c089 100644 (file)
@@ -2395,7 +2395,7 @@ intel_dp_detect(struct drm_connector *connector, bool force)
                edid = intel_dp_get_edid(connector, intel_dp->adapter);
                if (edid) {
                        intel_dp->has_audio = drm_detect_monitor_audio(edid);
-                       kfree(edid, M_DRM);
+                       kfree(edid);
                }
        }
 
@@ -2441,7 +2441,7 @@ intel_dp_detect_audio(struct drm_connector *connector)
        edid = intel_dp_get_edid(connector, intel_dp->adapter);
        if (edid) {
                has_audio = drm_detect_monitor_audio(edid);
-               kfree(edid, M_DRM);
+               kfree(edid);
        }
 
        return has_audio;
@@ -2534,7 +2534,7 @@ intel_dp_destroy(struct drm_connector *connector)
        struct intel_connector *intel_connector = to_intel_connector(connector);
 
        if (!IS_ERR_OR_NULL(intel_connector->edid))
-               kfree(intel_connector->edid, M_DRM);
+               kfree(intel_connector->edid);
 
        if (is_edp(intel_dp))
                intel_panel_fini(&intel_connector->panel);
@@ -2543,7 +2543,7 @@ intel_dp_destroy(struct drm_connector *connector)
        drm_sysfs_connector_remove(connector);
 #endif
        drm_connector_cleanup(connector);
-       kfree(connector, M_DRM);
+       kfree(connector);
 }
 
 void intel_dp_encoder_destroy(struct drm_encoder *encoder)
@@ -2566,7 +2566,7 @@ void intel_dp_encoder_destroy(struct drm_encoder *encoder)
                ironlake_panel_vdd_off_sync(intel_dp);
                mutex_unlock(&dev->mode_config.mutex);
        }
-       kfree(intel_dig_port, M_DRM);
+       kfree(intel_dig_port);
 }
 
 static const struct drm_encoder_helper_funcs intel_dp_helper_funcs = {
@@ -2906,7 +2906,7 @@ intel_dp_init_connector(struct intel_digital_port *intel_dig_port,
                                drm_mode_connector_update_edid_property(connector, edid);
                                drm_edid_to_eld(connector, edid);
                        } else {
-                               kfree(edid, M_DRM);
+                               kfree(edid);
                                edid = ERR_PTR(-EINVAL);
                        }
                } else {
@@ -2965,7 +2965,7 @@ intel_dp_init(struct drm_device *dev, int output_reg, enum port port)
        intel_connector = kmalloc(sizeof(struct intel_connector), M_DRM,
            M_WAITOK | M_ZERO);
        if (!intel_connector) {
-               kfree(intel_dig_port, M_DRM);
+               kfree(intel_dig_port);
                return;
        }
 
index 9391ab5..e313151 100644 (file)
@@ -237,7 +237,7 @@ int intel_fbdev_init(struct drm_device *dev)
                                 dev_priv->num_pipe,
                                 INTELFB_CONN_LIMIT);
        if (ret) {
-               kfree(ifbdev, M_DRM);
+               kfree(ifbdev);
                return ret;
        }
 
@@ -262,7 +262,7 @@ void intel_fbdev_fini(struct drm_device *dev)
                return;
 
        intel_fbdev_destroy(dev, dev_priv->fbdev);
-       kfree(dev_priv->fbdev, M_DRM);
+       kfree(dev_priv->fbdev);
        dev_priv->fbdev = NULL;
 }
 
index 4ee3c8e..9a2b581 100644 (file)
@@ -1067,7 +1067,7 @@ void intel_hdmi_init(struct drm_device *dev, int sdvox_reg, enum port port)
        intel_connector = kmalloc(sizeof(struct intel_connector), M_DRM,
            M_WAITOK | M_ZERO);
        if (!intel_connector) {
-               kfree(intel_dig_port, M_DRM);
+               kfree(intel_dig_port);
                return;
        }
 
index f49644b..62eee29 100644 (file)
@@ -618,7 +618,7 @@ static void intel_lvds_destroy(struct drm_connector *connector)
 #endif
 
        if (!IS_ERR_OR_NULL(lvds_connector->base.edid))
-               kfree(lvds_connector->base.edid, M_DRM);
+               kfree(lvds_connector->base.edid);
 
        intel_panel_fini(&lvds_connector->base.panel);
 
@@ -626,7 +626,7 @@ static void intel_lvds_destroy(struct drm_connector *connector)
        drm_sysfs_connector_remove(connector);
 #endif
        drm_connector_cleanup(connector);
-       kfree(connector, M_DRM);
+       kfree(connector);
 }
 
 static int intel_lvds_set_property(struct drm_connector *connector,
@@ -1092,7 +1092,7 @@ bool intel_lvds_init(struct drm_device *dev)
        lvds_connector = kmalloc(sizeof(struct intel_lvds_connector), M_DRM,
            M_WAITOK | M_ZERO);
        if (!lvds_connector) {
-               kfree(lvds_encoder, M_DRM);
+               kfree(lvds_encoder);
                return false;
        }
 
@@ -1168,7 +1168,7 @@ bool intel_lvds_init(struct drm_device *dev)
                        drm_mode_connector_update_edid_property(connector,
                                                                edid);
                } else {
-                       kfree(edid, M_DRM);
+                       kfree(edid);
                        edid = ERR_PTR(-EINVAL);
                }
        } else {
@@ -1277,7 +1277,7 @@ failed:
        drm_encoder_cleanup(encoder);
        if (fixed_mode)
                drm_mode_destroy(dev, fixed_mode);
-       kfree(lvds_encoder, M_DRM);
-       kfree(lvds_connector, M_DRM);
+       kfree(lvds_encoder);
+       kfree(lvds_connector);
        return false;
 }
index 94af089..5d2702c 100644 (file)
@@ -64,7 +64,7 @@ int intel_ddc_get_modes(struct drm_connector *connector,
                return 0;
 
        ret = intel_connector_update_modes(connector, edid);
-       kfree(edid, M_DRM);
+       kfree(edid);
 
        return ret;
 }
index c7bb232..cc1f3cb 100644 (file)
@@ -1160,7 +1160,7 @@ int intel_overlay_put_image(struct drm_device *dev, void *data,
        mutex_unlock(&dev->struct_mutex);
        drm_modeset_unlock_all(dev);
 
-       kfree(params, M_DRM);
+       kfree(params);
 
        return 0;
 
@@ -1169,7 +1169,7 @@ out_unlock:
        drm_modeset_unlock_all(dev);
        drm_gem_object_unreference_unlocked(&new_bo->base);
 out_free:
-       kfree(params, M_DRM);
+       kfree(params);
 
        return ret;
 }
@@ -1392,7 +1392,7 @@ out_free_bo:
        drm_gem_object_unreference(&reg_bo->base);
 out_free:
        mutex_unlock(&dev->struct_mutex);
-       kfree(overlay, M_DRM);
+       kfree(overlay);
        return;
 }
 
@@ -1409,7 +1409,7 @@ void intel_cleanup_overlay(struct drm_device *dev)
        BUG_ON(dev_priv->overlay->active);
 
        drm_gem_object_unreference_unlocked(&dev_priv->overlay->reg_bo->base);
-       kfree(dev_priv->overlay, M_DRM);
+       kfree(dev_priv->overlay);
 }
 
 #ifdef CONFIG_DEBUG_FS
@@ -1480,7 +1480,7 @@ intel_overlay_capture_error_state(struct drm_device *dev)
        return error;
 
 err:
-       kfree(error, M_DRM);
+       kfree(error);
        return NULL;
 }
 
index b2bc61f..f63e51b 100644 (file)
@@ -288,7 +288,7 @@ static void intel_fbc_work_fn(struct work_struct *__work)
        }
        mutex_unlock(&dev->struct_mutex);
 
-       kfree(work, M_DRM);
+       kfree(work);
 }
 
 static void intel_cancel_fbc_work(struct drm_i915_private *dev_priv)
@@ -304,7 +304,7 @@ static void intel_cancel_fbc_work(struct drm_i915_private *dev_priv)
         */
        if (cancel_delayed_work(&dev_priv->fbc_work->work))
                /* tasklet was killed before being run, clean up */
-               kfree(dev_priv->fbc_work, M_DRM);
+               kfree(dev_priv->fbc_work);
 
        /* Mark the work as no longer wanted so that if it does
         * wake-up (because the work was already running and waiting
index a2f1f4a..39fd071 100644 (file)
@@ -483,7 +483,7 @@ err_unpin:
 err_unref:
        drm_gem_object_unreference(&obj->base);
 err:
-       kfree(pc, M_DRM);
+       kfree(pc);
        return ret;
 }
 
@@ -503,7 +503,7 @@ cleanup_pipe_control(struct intel_ring_buffer *ring)
        i915_gem_object_unpin(obj);
        drm_gem_object_unreference(&obj->base);
 
-       kfree(pc, M_DRM);
+       kfree(pc);
        ring->private = NULL;
 }
 
index e632385..b2d297a 100644 (file)
@@ -1595,7 +1595,7 @@ intel_sdvo_detect(struct drm_connector *connector, bool force)
                        else
                                ret = connector_status_disconnected;
 
-                       kfree(edid, M_DRM);
+                       kfree(edid);
                } else
                        ret = connector_status_connected;
        }
@@ -2824,7 +2824,7 @@ bool intel_sdvo_init(struct drm_device *dev, uint32_t sdvo_reg, bool is_sdvob)
        intel_sdvo->slave_addr = intel_sdvo_get_slave_addr(dev, intel_sdvo) >> 1;
        intel_sdvo_select_i2c_bus(dev_priv, intel_sdvo, sdvo_reg);
        if (!intel_sdvo_init_ddc_proxy(intel_sdvo, dev, sdvo_reg)) {
-               kfree(intel_sdvo, M_DRM);
+               kfree(intel_sdvo);
                return false;
        }
 
@@ -2925,7 +2925,7 @@ err_output:
 err:
        drm_encoder_cleanup(&intel_encoder->base);
        intel_sdvo_unselect_i2c_bus(intel_sdvo);
-       kfree(intel_sdvo, M_DRM);
+       kfree(intel_sdvo);
 
        return false;
 }
index 95baf51..6347181 100644 (file)
@@ -582,7 +582,7 @@ static void intel_destroy_plane(struct drm_plane *plane)
        struct intel_plane *intel_plane = to_intel_plane(plane);
        intel_disable_plane(plane);
        drm_plane_cleanup(plane);
-       kfree(intel_plane, M_DRM);
+       kfree(intel_plane);
 }
 
 int intel_sprite_set_colorkey(struct drm_device *dev, void *data,
@@ -722,7 +722,7 @@ intel_plane_init(struct drm_device *dev, enum i915_pipe pipe)
                break;
 
        default:
-               kfree(intel_plane, M_DRM);
+               kfree(intel_plane);
                return -ENODEV;
        }
 
@@ -733,7 +733,7 @@ intel_plane_init(struct drm_device *dev, enum i915_pipe pipe)
                             plane_formats, num_plane_formats,
                             false);
        if (ret)
-               kfree(intel_plane, M_DRM);
+               kfree(intel_plane);
 
        return ret;
 }
index b7ee87a..5e19217 100644 (file)
@@ -1430,7 +1430,7 @@ intel_tv_destroy(struct drm_connector *connector)
        drm_sysfs_connector_remove(connector);
 #endif
        drm_connector_cleanup(connector);
-       kfree(connector, M_DRM);
+       kfree(connector);
 }
 
 
@@ -1598,7 +1598,7 @@ intel_tv_init(struct drm_device *dev)
        intel_connector = kmalloc(sizeof(struct intel_connector), M_DRM,
            M_WAITOK | M_ZERO);
        if (!intel_connector) {
-               kfree(intel_tv, M_DRM);
+               kfree(intel_tv);
                return;
        }
 
index d0578c3..4bb7b6f 100644 (file)
@@ -107,6 +107,7 @@ MALLOC_DECLARE(M_DRM);
 #include <linux/mm.h>
 #include <linux/moduleparam.h>
 #include <linux/mutex.h>
+#include <linux/slab.h>
 #include <linux/scatterlist.h>
 #include <linux/timer.h>
 #include <asm/io.h>
@@ -1541,22 +1542,10 @@ drm_calloc(size_t nmemb, size_t size, struct malloc_type *area)
        return kmalloc(size * nmemb, area, M_WAITOK | M_NULLOK | M_ZERO);
 }
 
-static __inline__ void *
-drm_realloc(void *oldpt, size_t oldsize, size_t size,
-    struct malloc_type *area)
-{
-       void *res;
-       res = krealloc(oldpt, size, area, M_WAITOK | M_NULLOK);
-       if (res == NULL && oldpt != NULL)
-               kfree(oldpt,area);
-       return res;
-}
-
 static __inline__ void
 drm_free(void *pt, struct malloc_type *area)
 {
-       if (pt != NULL)
-               kfree(pt, area);
+       kfree(pt);
 }
 
 /* Inline replacements for DRM_IOREMAP macros */
index 46bca01..3adf183 100644 (file)
@@ -49,7 +49,7 @@ static __inline__ void *drm_malloc_ab(size_t nmemb, size_t size)
 
 static __inline void drm_free_large(void *ptr)
 {
-       kfree(ptr, M_DRM);
+       kfree(ptr);
 }
 
 #endif
diff --git a/sys/dev/drm/include/linux/slab.h b/sys/dev/drm/include/linux/slab.h
new file mode 100644 (file)
index 0000000..4053d4d
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2015 François Tigeot
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice unmodified, this list of conditions, and the following
+ *    disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _LINUX_SLAB_H_
+#define _LINUX_SLAB_H_
+
+#define kfree(ptr)     do {            \
+       if (ptr != NULL)                \
+               kfree(ptr, M_DRM);      \
+} while (0)
+
+#endif /* _LINUX_SLAB_H_ */
index 90e59b5..c5f82fc 100644 (file)
@@ -163,7 +163,7 @@ static inline void
 destroy_workqueue(struct workqueue_struct *wq)
 {
        taskqueue_free(wq->taskqueue);
-       kfree(wq, M_DRM);
+       kfree(wq);
 }
 
 #define        flush_workqueue(wq)     flush_taskqueue((wq)->taskqueue)
index 7fc287c..4baddc4 100644 (file)
@@ -1876,7 +1876,7 @@ radeon_add_atom_connector(struct drm_device *dev,
 
 failed:
        drm_connector_cleanup(connector);
-       kfree(connector, M_DRM);
+       kfree(connector);
 }
 
 void
index a7104e3..5cec7e3 100644 (file)
@@ -1124,7 +1124,7 @@ radeon_user_framebuffer_create(struct drm_device *dev,
 
        ret = radeon_framebuffer_init(dev, radeon_fb, mode_cmd, obj);
        if (ret) {
-               kfree(radeon_fb, M_DRM);
+               kfree(radeon_fb);
                drm_gem_object_unreference_unlocked(obj);
                return ERR_PTR(ret);
        }
index 66adfc0..6a0336e 100644 (file)
@@ -128,7 +128,7 @@ static void ttm_bo_release_list(struct kref *list_kref)
        if (bo->destroy)
                bo->destroy(bo);
        else {
-               kfree(bo, M_DRM);
+               kfree(bo);
        }
        ttm_mem_global_free(bdev->glob->mem_glob, acc_size);
 }
@@ -1256,7 +1256,7 @@ int ttm_bo_init(struct ttm_bo_device *bdev,
                if (destroy)
                        (*destroy)(bo);
                else
-                       kfree(bo, M_DRM);
+                       kfree(bo);
                return -ENOMEM;
        }
 
@@ -1266,7 +1266,7 @@ int ttm_bo_init(struct ttm_bo_device *bdev,
                if (destroy)
                        (*destroy)(bo);
                else
-                       kfree(bo, M_DRM);
+                       kfree(bo);
                ttm_mem_global_free(mem_glob, acc_size);
                return -EINVAL;
        }
@@ -1565,7 +1565,7 @@ out_no_shrink:
        vm_page_free(glob->dummy_read_page);
        */
 out_no_drp:
-       kfree(glob, M_DRM);
+       kfree(glob);
        return ret;
 }
 EXPORT_SYMBOL(ttm_bo_global_init);
index c88e715..4cb6e1c 100644 (file)
@@ -111,7 +111,7 @@ static int ttm_bo_man_init(struct ttm_mem_type_manager *man,
 
        ret = drm_mm_init(&rman->mm, 0, p_size);
        if (ret) {
-               kfree(rman, M_DRM);
+               kfree(rman);
                return ret;
        }
 
@@ -129,7 +129,7 @@ static int ttm_bo_man_takedown(struct ttm_mem_type_manager *man)
        if (drm_mm_clean(mm)) {
                drm_mm_takedown(mm);
                lockmgr(&rman->lock, LK_RELEASE);
-               kfree(rman, M_DRM);
+               kfree(rman);
                man->priv = NULL;
                return 0;
        }
index f7cea75..51354e5 100644 (file)
@@ -379,7 +379,7 @@ EXPORT_SYMBOL(ttm_bo_move_memcpy);
 
 static void ttm_transfered_destroy(struct ttm_buffer_object *bo)
 {
-       kfree(bo, M_DRM);
+       kfree(bo);
 }
 
 /**