GNU Linux-libre 4.14.313-gnu1
[releases.git] / drivers / staging / media / atomisp / pci / atomisp2 / css2400 / sh_css_host_data.c
1 /*
2  * Support for Intel Camera Imaging ISP subsystem.
3  * Copyright (c) 2015, Intel Corporation.
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms and conditions of the GNU General Public License,
7  * version 2, as published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
12  * more details.
13  */
14
15 #include <linux/slab.h>
16 #include <ia_css_host_data.h>
17 #include <sh_css_internal.h>
18
19 struct ia_css_host_data *ia_css_host_data_allocate(size_t size)
20 {
21         struct ia_css_host_data *me;
22
23         me =  kmalloc(sizeof(struct ia_css_host_data), GFP_KERNEL);
24         if (!me)
25                 return NULL;
26         me->size = (uint32_t)size;
27         me->address = sh_css_malloc(size);
28         if (!me->address) {
29                 kfree(me);
30                 return NULL;
31         }
32         return me;
33 }
34
35 void ia_css_host_data_free(struct ia_css_host_data *me)
36 {
37         if (me) {
38                 sh_css_free(me->address);
39                 me->address = NULL;
40                 kfree(me);
41         }
42 }