1 /*
2  * Copyright (c) 2020 Intel Corporation
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #include <ztest.h>
8 #include <device.h>
9 #include "abstract_driver.h"
10 
11 #define MY_DRIVER_A	"my_driver_A"
12 #define MY_DRIVER_B	"my_driver_B"
13 
14 /* define indivial driver A */
my_driver_A_do_this(const struct device * device,int foo,int bar)15 static int my_driver_A_do_this(const struct device *device, int foo, int bar)
16 {
17 	return foo + bar;
18 }
19 
my_driver_A_do_that(const struct device * device,unsigned int * baz)20 static void my_driver_A_do_that(const struct device *device,
21 				unsigned int *baz)
22 {
23 	*baz = 1;
24 }
25 
26 static struct subsystem_api my_driver_A_api_funcs = {
27 	.do_this = my_driver_A_do_this,
28 	.do_that = my_driver_A_do_that
29 };
30 
common_driver_init(const struct device * dev)31 int common_driver_init(const struct device *dev)
32 {
33 	return 0;
34 }
35 
36 /* define indivial driver B */
my_driver_B_do_this(const struct device * device,int foo,int bar)37 static int my_driver_B_do_this(const struct device *device, int foo, int bar)
38 {
39 	return foo - bar;
40 }
41 
my_driver_B_do_that(const struct device * device,unsigned int * baz)42 static void my_driver_B_do_that(const struct device *device,
43 				unsigned int *baz)
44 {
45 	*baz = 2;
46 }
47 
48 static struct subsystem_api my_driver_B_api_funcs = {
49 	.do_this = my_driver_B_do_this,
50 	.do_that = my_driver_B_do_that
51 };
52 
53 /**
54  * @cond INTERNAL_HIDDEN
55  */
56 DEVICE_DEFINE(my_driver_A, MY_DRIVER_A, &common_driver_init,
57 		NULL, NULL, NULL,
58 		POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT,
59 		&my_driver_A_api_funcs);
60 
61 DEVICE_DEFINE(my_driver_B, MY_DRIVER_B, &common_driver_init,
62 		NULL, NULL, NULL,
63 		POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT,
64 		&my_driver_B_api_funcs);
65 
66 /**
67  * @endcond
68  */
69