Commit 94853b65 authored by Alan Cox's avatar Alan Cox Committed by Greg Kroah-Hartman

atomisp: remove sh_css_malloc indirections where we can

Where we know the buffer size is reasonably constrained we can just use kmalloc,
and where it will be large vmalloc. This still leaves a pile in the middle.
Signed-off-by: default avatarAlan Cox <alan@linux.intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent da22013f
......@@ -12,6 +12,9 @@
* more details.
*/
#include <linux/slab.h>
#include <linux/vmalloc.h>
#include <math_support.h>
#include "platform_support.h"
#include "sh_css_firmware.h"
......@@ -93,9 +96,9 @@ setup_binary(struct ia_css_fw_info *fw, const char *fw_data, struct ia_css_fw_in
*sh_css_fw = *fw;
#if defined(HRT_UNSCHED)
sh_css_fw->blob.code = sh_css_malloc(1);
sh_css_fw->blob.code = vmalloc(1);
#else
sh_css_fw->blob.code = sh_css_malloc(fw->blob.size);
sh_css_fw->blob.code = vmalloc(fw->blob.size);
#endif
if (sh_css_fw->blob.code == NULL)
......@@ -143,11 +146,11 @@ sh_css_load_blob_info(const char *fw, const struct ia_css_fw_info *bi, struct ia
char *namebuffer;
int namelength = (int)strlen(name);
namebuffer = (char *) sh_css_malloc(namelength+1);
namebuffer = (char *) kmalloc(namelength + 1, GFP_KERNEL);
if (namebuffer == NULL)
return IA_CSS_ERR_CANNOT_ALLOCATE_MEMORY;
memcpy(namebuffer, name, namelength+1);
memcpy(namebuffer, name, namelength + 1);
bd->name = fw_minibuffer[index].name = namebuffer;
} else {
......@@ -159,7 +162,8 @@ sh_css_load_blob_info(const char *fw, const struct ia_css_fw_info *bi, struct ia
size_t configstruct_size = sizeof(struct ia_css_config_memory_offsets);
size_t statestruct_size = sizeof(struct ia_css_state_memory_offsets);
char *parambuf = (char *) sh_css_malloc(paramstruct_size + configstruct_size + statestruct_size);
char *parambuf = (char *)kmalloc(paramstruct_size + configstruct_size + statestruct_size,
GFP_KERNEL);
if (parambuf == NULL)
return IA_CSS_ERR_CANNOT_ALLOCATE_MEMORY;
......@@ -239,19 +243,18 @@ sh_css_load_firmware(const char *fw_data,
sh_css_num_binaries = file_header->binary_nr;
/* Only allocate memory for ISP blob info */
if (sh_css_num_binaries > (NUM_OF_SPS + NUM_OF_BLS)) {
sh_css_blob_info = sh_css_malloc(
sh_css_blob_info = kmalloc(
(sh_css_num_binaries - (NUM_OF_SPS + NUM_OF_BLS)) *
sizeof(*sh_css_blob_info));
sizeof(*sh_css_blob_info), GFP_KERNEL);
if (sh_css_blob_info == NULL)
return IA_CSS_ERR_CANNOT_ALLOCATE_MEMORY;
} else {
sh_css_blob_info = NULL;
}
fw_minibuffer = sh_css_malloc(sh_css_num_binaries * sizeof(struct fw_param));
fw_minibuffer = kzalloc(sh_css_num_binaries * sizeof(struct fw_param), GFP_KERNEL);
if (fw_minibuffer == NULL)
return IA_CSS_ERR_CANNOT_ALLOCATE_MEMORY;
memset(fw_minibuffer, 0, sh_css_num_binaries * sizeof(struct fw_param));
for (i = 0; i < sh_css_num_binaries; i++) {
struct ia_css_fw_info *bi = &binaries[i];
......@@ -309,17 +312,17 @@ void sh_css_unload_firmware(void)
unsigned int i = 0;
for (i = 0; i < sh_css_num_binaries; i++) {
if (fw_minibuffer[i].name)
sh_css_free((void *)fw_minibuffer[i].name);
kfree((void *)fw_minibuffer[i].name);
if (fw_minibuffer[i].buffer)
sh_css_free((void *)fw_minibuffer[i].buffer);
vfree((void *)fw_minibuffer[i].buffer);
}
sh_css_free(fw_minibuffer);
kfree(fw_minibuffer);
fw_minibuffer = NULL;
}
memset(&sh_css_sp_fw, 0, sizeof(sh_css_sp_fw));
if (sh_css_blob_info) {
sh_css_free(sh_css_blob_info);
kfree(sh_css_blob_info);
sh_css_blob_info = NULL;
}
sh_css_num_binaries = 0;
......
......@@ -12,7 +12,7 @@
* more details.
*/
#include <stddef.h>
#include <linux/slab.h>
#include <ia_css_host_data.h>
#include <sh_css_internal.h>
......@@ -20,13 +20,13 @@ struct ia_css_host_data *ia_css_host_data_allocate(size_t size)
{
struct ia_css_host_data *me;
me = sh_css_malloc(sizeof(struct ia_css_host_data));
me = kmalloc(sizeof(struct ia_css_host_data), GFP_KERNEL);
if (!me)
return NULL;
me->size = (uint32_t)size;
me->address = sh_css_malloc(size);
if (!me->address) {
sh_css_free(me);
kfree(me);
return NULL;
}
return me;
......@@ -37,6 +37,6 @@ void ia_css_host_data_free(struct ia_css_host_data *me)
if (me) {
sh_css_free(me->address);
me->address = NULL;
sh_css_free(me);
kfree(me);
}
}
......@@ -12,6 +12,8 @@
* more details.
*/
#include <linux/slab.h>
#include <math_support.h>
#include "sh_css_param_shading.h"
#include "ia_css_shading.h"
......@@ -362,7 +364,7 @@ ia_css_shading_table_alloc(
IA_CSS_ENTER("");
me = sh_css_malloc(sizeof(*me));
me = kmalloc(sizeof(*me), GFP_KERNEL);
if (me == NULL) {
IA_CSS_ERROR("out of memory");
return me;
......@@ -382,7 +384,7 @@ ia_css_shading_table_alloc(
sh_css_free(me->data[j]);
me->data[j] = NULL;
}
sh_css_free(me);
kfree(me);
return NULL;
}
}
......@@ -410,7 +412,7 @@ ia_css_shading_table_free(struct ia_css_shading_table *table)
table->data[i] = NULL;
}
}
sh_css_free(table);
kfree(table);
IA_CSS_LEAVE("");
}
......
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