dm: core: Add a note about how livetree updates work
[platform/kernel/u-boot.git] / include / dm / util.h
1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3  * Copyright (c) 2013 Google, Inc
4  */
5
6 #ifndef __DM_UTIL_H
7 #define __DM_UTIL_H
8
9 struct dm_stats;
10
11 #if CONFIG_IS_ENABLED(DM_WARN)
12 #define dm_warn(fmt...) log(LOGC_DM, LOGL_WARNING, ##fmt)
13 #else
14 static inline void dm_warn(const char *fmt, ...)
15 {
16 }
17 #endif
18
19 struct list_head;
20
21 /**
22  * list_count_items() - Count number of items in a list
23  *
24  * @param head:         Head of list
25  * Return: number of items, or 0 if empty
26  */
27 int list_count_items(struct list_head *head);
28
29 /* Dump out a tree of all devices */
30 void dm_dump_tree(void);
31
32 /* Dump out a list of uclasses and their devices */
33 void dm_dump_uclass(void);
34
35 #ifdef CONFIG_DEBUG_DEVRES
36 /* Dump out a list of device resources */
37 void dm_dump_devres(void);
38 #else
39 static inline void dm_dump_devres(void)
40 {
41 }
42 #endif
43
44 /* Dump out a list of drivers */
45 void dm_dump_drivers(void);
46
47 /* Dump out a list with each driver's compatibility strings */
48 void dm_dump_driver_compat(void);
49
50 /* Dump out a list of drivers with static platform data */
51 void dm_dump_static_driver_info(void);
52
53 /**
54  * dm_dump_mem() - Dump stats on memory usage in driver model
55  *
56  * @mem: Stats to dump
57  */
58 void dm_dump_mem(struct dm_stats *stats);
59
60 #if CONFIG_IS_ENABLED(OF_PLATDATA_INST) && CONFIG_IS_ENABLED(READ_ONLY)
61 void *dm_priv_to_rw(void *priv);
62 #else
63 static inline void *dm_priv_to_rw(void *priv)
64 {
65         return priv;
66 }
67 #endif
68
69 #endif