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
dm_warn(const char * fmt,...)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 /**
30  * Dump out a tree of all devices
31  *
32  * @sort: Sort by uclass name
33  */
34 void dm_dump_tree(bool sort);
35 
36 /* Dump out a list of uclasses and their devices */
37 void dm_dump_uclass(void);
38 
39 #ifdef CONFIG_DEBUG_DEVRES
40 /* Dump out a list of device resources */
41 void dm_dump_devres(void);
42 #else
dm_dump_devres(void)43 static inline void dm_dump_devres(void)
44 {
45 }
46 #endif
47 
48 /* Dump out a list of drivers */
49 void dm_dump_drivers(void);
50 
51 /* Dump out a list with each driver's compatibility strings */
52 void dm_dump_driver_compat(void);
53 
54 /* Dump out a list of drivers with static platform data */
55 void dm_dump_static_driver_info(void);
56 
57 /**
58  * dm_dump_mem() - Dump stats on memory usage in driver model
59  *
60  * @mem: Stats to dump
61  */
62 void dm_dump_mem(struct dm_stats *stats);
63 
64 #if CONFIG_IS_ENABLED(OF_PLATDATA_INST) && CONFIG_IS_ENABLED(READ_ONLY)
65 void *dm_priv_to_rw(void *priv);
66 #else
dm_priv_to_rw(void * priv)67 static inline void *dm_priv_to_rw(void *priv)
68 {
69 	return priv;
70 }
71 #endif
72 
73 #endif
74