/src/barebox/common/structio.c
Line | Count | Source |
1 | | /* SPDX-License-Identifier: GPL-2.0-only */ |
2 | | |
3 | | #include <structio.h> |
4 | | #include <command.h> |
5 | | #include <device.h> |
6 | | #include <linux/export.h> |
7 | | |
8 | | static struct bobject *active_capture; |
9 | | |
10 | | struct bobject *structio_active(void) |
11 | 0 | { |
12 | 0 | return active_capture; |
13 | 0 | } |
14 | | |
15 | | int structio_run_command(struct bobject **bret, const char *cmd) |
16 | 0 | { |
17 | 0 | struct bobject *bobj; |
18 | 0 | int ret; |
19 | |
|
20 | 0 | if (!bret) |
21 | 0 | return run_command("%s", cmd); |
22 | | |
23 | 0 | active_capture = bobj = bobject_alloc("capture"); |
24 | 0 | bobj->local = true; |
25 | |
|
26 | 0 | ret = run_command("%s", cmd); |
27 | |
|
28 | 0 | active_capture = NULL; |
29 | |
|
30 | 0 | if (ret) { |
31 | 0 | bobject_free(bobj); |
32 | 0 | return ret; |
33 | 0 | } |
34 | | |
35 | 0 | *bret = bobj; |
36 | 0 | return 0; |
37 | 0 | } |
38 | | EXPORT_SYMBOL(structio_run_command); |
39 | | |
40 | | int structio_devinfo(struct bobject **bret, struct device *dev) |
41 | 0 | { |
42 | 0 | struct bobject *bobj; |
43 | |
|
44 | 0 | if (!bret) { |
45 | 0 | devinfo(dev); |
46 | 0 | return 0; |
47 | 0 | } |
48 | | |
49 | 0 | active_capture = bobj = bobject_alloc("devinfo"); |
50 | 0 | bobj->local = true; |
51 | |
|
52 | 0 | devinfo(dev); |
53 | |
|
54 | 0 | active_capture = NULL; |
55 | |
|
56 | 0 | *bret = bobj; |
57 | 0 | return 0; |
58 | 0 | } |
59 | | EXPORT_SYMBOL(structio_devinfo); |