]> git.kernelconcepts.de Git - karo-tx-linux.git/blob - drivers/staging/ccree/ssi_fips_ext.c
staging: ccree: remove comparisons to NULL
[karo-tx-linux.git] / drivers / staging / ccree / ssi_fips_ext.c
1 /*
2  * Copyright (C) 2012-2017 ARM Limited or its affiliates.
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, see <http://www.gnu.org/licenses/>.
15  */
16
17 /**************************************************************
18  * This file defines the driver FIPS functions that should be
19  * implemented by the driver user. Current implementation is sample code only.
20  ***************************************************************/
21
22 #include <linux/module.h>
23 #include "ssi_fips_local.h"
24 #include "ssi_driver.h"
25
26
27 static bool tee_error;
28 module_param(tee_error, bool, 0644);
29 MODULE_PARM_DESC(tee_error, "Simulate TEE library failure flag: 0 - no error (default), 1 - TEE error occured ");
30
31 static ssi_fips_state_t fips_state = CC_FIPS_STATE_NOT_SUPPORTED;
32 static ssi_fips_error_t fips_error = CC_REE_FIPS_ERROR_OK;
33
34 /*
35  * This function returns the FIPS REE state.
36  * The function should be implemented by the driver user, depends on where
37  * the state value is stored.
38  * The reference code uses global variable.
39  */
40 int ssi_fips_ext_get_state(ssi_fips_state_t *p_state)
41 {
42         int rc = 0;
43
44         if (!p_state)
45                 return -EINVAL;
46
47         *p_state = fips_state;
48
49         return rc;
50 }
51
52 /*
53  * This function returns the FIPS REE error.
54  * The function should be implemented by the driver user, depends on where
55  * the error value is stored.
56  * The reference code uses global variable.
57  */
58 int ssi_fips_ext_get_error(ssi_fips_error_t *p_err)
59 {
60         int rc = 0;
61
62         if (!p_err)
63                 return -EINVAL;
64
65         *p_err = fips_error;
66
67         return rc;
68 }
69
70 /*
71  * This function sets the FIPS REE state.
72  * The function should be implemented by the driver user, depends on where
73  * the state value is stored.
74  * The reference code uses global variable.
75  */
76 int ssi_fips_ext_set_state(ssi_fips_state_t state)
77 {
78         fips_state = state;
79         return 0;
80 }
81
82 /*
83  * This function sets the FIPS REE error.
84  * The function should be implemented by the driver user, depends on where
85  * the error value is stored.
86  * The reference code uses global variable.
87  */
88 int ssi_fips_ext_set_error(ssi_fips_error_t err)
89 {
90         fips_error = err;
91         return 0;
92 }
93
94