]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blob - drivers/staging/ccree/ssi_fips_ext.c
Merge tag 'iio-for-4.13b' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23...
[mirror_ubuntu-artful-kernel.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 == NULL) {
45 return -EINVAL;
46 }
47
48 *p_state = fips_state;
49
50 return rc;
51 }
52
53 /*
54 * This function returns the FIPS REE error.
55 * The function should be implemented by the driver user, depends on where
56 * the error value is stored.
57 * The reference code uses global variable.
58 */
59 int ssi_fips_ext_get_error(ssi_fips_error_t *p_err)
60 {
61 int rc = 0;
62
63 if (p_err == NULL) {
64 return -EINVAL;
65 }
66
67 *p_err = fips_error;
68
69 return rc;
70 }
71
72 /*
73 * This function sets the FIPS REE state.
74 * The function should be implemented by the driver user, depends on where
75 * the state value is stored.
76 * The reference code uses global variable.
77 */
78 int ssi_fips_ext_set_state(ssi_fips_state_t state)
79 {
80 fips_state = state;
81 return 0;
82 }
83
84 /*
85 * This function sets the FIPS REE error.
86 * The function should be implemented by the driver user, depends on where
87 * the error value is stored.
88 * The reference code uses global variable.
89 */
90 int ssi_fips_ext_set_error(ssi_fips_error_t err)
91 {
92 fips_error = err;
93 return 0;
94 }
95
96