1158486a6SFrançois Tigeot /* 2*1dedbd3bSFrançois Tigeot * Copyright (c) 2015-2019 François Tigeot <ftigeot@wolfpond.org> 3158486a6SFrançois Tigeot * All rights reserved. 4158486a6SFrançois Tigeot * 5158486a6SFrançois Tigeot * Redistribution and use in source and binary forms, with or without 6158486a6SFrançois Tigeot * modification, are permitted provided that the following conditions 7158486a6SFrançois Tigeot * are met: 8158486a6SFrançois Tigeot * 1. Redistributions of source code must retain the above copyright 9158486a6SFrançois Tigeot * notice unmodified, this list of conditions, and the following 10158486a6SFrançois Tigeot * disclaimer. 11158486a6SFrançois Tigeot * 2. Redistributions in binary form must reproduce the above copyright 12158486a6SFrançois Tigeot * notice, this list of conditions and the following disclaimer in the 13158486a6SFrançois Tigeot * documentation and/or other materials provided with the distribution. 14158486a6SFrançois Tigeot * 15158486a6SFrançois Tigeot * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16158486a6SFrançois Tigeot * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17158486a6SFrançois Tigeot * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18158486a6SFrançois Tigeot * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19158486a6SFrançois Tigeot * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20158486a6SFrançois Tigeot * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21158486a6SFrançois Tigeot * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22158486a6SFrançois Tigeot * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23158486a6SFrançois Tigeot * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24158486a6SFrançois Tigeot * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25158486a6SFrançois Tigeot */ 26158486a6SFrançois Tigeot 27158486a6SFrançois Tigeot #ifndef _LINUX_SLAB_H_ 28158486a6SFrançois Tigeot #define _LINUX_SLAB_H_ 29158486a6SFrançois Tigeot 30f43360b9SFrançois Tigeot #include <linux/gfp.h> 3129f241cfSFrançois Tigeot #include <linux/types.h> 32f43360b9SFrançois Tigeot 33c8480522SFrançois Tigeot MALLOC_DECLARE(M_DRM); 34c8480522SFrançois Tigeot 35f43360b9SFrançois Tigeot #define kzalloc(size, flags) kmalloc(size, M_DRM, flags | M_ZERO) 36f43360b9SFrançois Tigeot 37158486a6SFrançois Tigeot #define kfree(ptr) do { \ 38158486a6SFrançois Tigeot if (ptr != NULL) \ 39*1dedbd3bSFrançois Tigeot kfree((void *)ptr, M_DRM); \ 40158486a6SFrançois Tigeot } while (0) 41158486a6SFrançois Tigeot 42e0b9e154SSascha Wildner #define kcalloc(n, size, flags) kzalloc((n) * (size), flags) 4329f241cfSFrançois Tigeot 4439cfddd2SFrançois Tigeot static inline void * 4539cfddd2SFrançois Tigeot kmalloc_array(size_t n, size_t size, gfp_t flags) 4639cfddd2SFrançois Tigeot { 4739cfddd2SFrançois Tigeot return kmalloc(n * size, M_DRM, flags); 4839cfddd2SFrançois Tigeot } 4939cfddd2SFrançois Tigeot 50*1dedbd3bSFrançois Tigeot #include <linux/kasan.h> 51*1dedbd3bSFrançois Tigeot 52*1dedbd3bSFrançois Tigeot #define kmem_cache_free(slab, ptr) kfree(ptr) 53*1dedbd3bSFrançois Tigeot 54158486a6SFrançois Tigeot #endif /* _LINUX_SLAB_H_ */ 55