]>
Commit | Line | Data |
---|---|---|
4562236b HW |
1 | /* |
2 | * Copyright 2012-16 Advanced Micro Devices, Inc. | |
3 | * | |
4 | * Permission is hereby granted, free of charge, to any person obtaining a | |
5 | * copy of this software and associated documentation files (the "Software"), | |
6 | * to deal in the Software without restriction, including without limitation | |
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | |
8 | * and/or sell copies of the Software, and to permit persons to whom the | |
9 | * Software is furnished to do so, subject to the following conditions: | |
10 | * | |
11 | * The above copyright notice and this permission notice shall be included in | |
12 | * all copies or substantial portions of the Software. | |
13 | * | |
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | |
17 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR | |
18 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | |
19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | |
20 | * OTHER DEALINGS IN THE SOFTWARE. | |
21 | * | |
22 | * Authors: AMD | |
23 | * | |
24 | */ | |
25 | ||
26 | #include "dm_services.h" | |
27 | ||
28 | /* | |
29 | * Pre-requisites: headers required by header of this unit | |
30 | */ | |
31 | #include "include/i2caux_interface.h" | |
32 | #include "../i2caux.h" | |
33 | #include "../engine.h" | |
34 | #include "../i2c_engine.h" | |
35 | #include "../i2c_sw_engine.h" | |
36 | #include "../i2c_hw_engine.h" | |
37 | ||
38 | /* | |
39 | * Header of this unit | |
40 | */ | |
41 | #include "i2caux_diag.h" | |
42 | ||
43 | /* | |
44 | * Post-requisites: headers required by this unit | |
45 | */ | |
46 | ||
47 | /* | |
48 | * This unit | |
49 | */ | |
50 | ||
51 | static void destruct( | |
52 | struct i2caux *i2caux) | |
53 | { | |
54 | dal_i2caux_destruct(i2caux); | |
55 | } | |
56 | ||
57 | static void destroy( | |
58 | struct i2caux **i2c_engine) | |
59 | { | |
60 | destruct(*i2c_engine); | |
61 | ||
2004f45e | 62 | kfree(*i2c_engine); |
4562236b HW |
63 | |
64 | *i2c_engine = NULL; | |
65 | } | |
66 | ||
67 | /* function table */ | |
68 | static const struct i2caux_funcs i2caux_funcs = { | |
69 | .destroy = destroy, | |
70 | .acquire_i2c_hw_engine = NULL, | |
71 | .release_engine = NULL, | |
72 | .acquire_i2c_sw_engine = NULL, | |
73 | .acquire_aux_engine = NULL, | |
74 | }; | |
75 | ||
76 | static bool construct( | |
77 | struct i2caux *i2caux, | |
78 | struct dc_context *ctx) | |
79 | { | |
80 | if (!dal_i2caux_construct(i2caux, ctx)) { | |
81 | ASSERT_CRITICAL(false); | |
82 | return false; | |
83 | } | |
84 | ||
85 | i2caux->funcs = &i2caux_funcs; | |
86 | ||
87 | return true; | |
88 | } | |
89 | ||
90 | struct i2caux *dal_i2caux_diag_fpga_create( | |
91 | struct dc_context *ctx) | |
92 | { | |
2004f45e HW |
93 | struct i2caux *i2caux = kzalloc(sizeof(struct i2caux), |
94 | GFP_KERNEL); | |
4562236b HW |
95 | |
96 | if (!i2caux) { | |
97 | ASSERT_CRITICAL(false); | |
98 | return NULL; | |
99 | } | |
100 | ||
101 | if (construct(i2caux, ctx)) | |
102 | return i2caux; | |
103 | ||
104 | ASSERT_CRITICAL(false); | |
105 | ||
2004f45e | 106 | kfree(i2caux); |
4562236b HW |
107 | |
108 | return NULL; | |
109 | } |