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