1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * Support for Intel Camera Imaging ISP subsystem.
4  * Copyright (c) 2015, Intel Corporation.
5  */
6 
7 #include <linux/slab.h>
8 #include <ia_css_host_data.h>
9 #include <sh_css_internal.h>
10 
ia_css_host_data_allocate(size_t size)11 struct ia_css_host_data *ia_css_host_data_allocate(size_t size)
12 {
13 	struct ia_css_host_data *me;
14 
15 	me =  kmalloc(sizeof(struct ia_css_host_data), GFP_KERNEL);
16 	if (!me)
17 		return NULL;
18 	me->size = (uint32_t)size;
19 	me->address = kvmalloc(size, GFP_KERNEL);
20 	if (!me->address) {
21 		kfree(me);
22 		return NULL;
23 	}
24 	return me;
25 }
26 
ia_css_host_data_free(struct ia_css_host_data * me)27 void ia_css_host_data_free(struct ia_css_host_data *me)
28 {
29 	if (me) {
30 		kvfree(me->address);
31 		me->address = NULL;
32 		kfree(me);
33 	}
34 }
35