Merge tag 'v4.0-rc2' into timers/core, to refresh the tree before pulling more changes
[deliverable/linux.git] / include / linux / property.h
CommitLineData
b31384fa
RW
1/*
2 * property.h - Unified device property interface.
3 *
4 * Copyright (C) 2014, Intel Corporation
5 * Authors: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
6 * Mika Westerberg <mika.westerberg@linux.intel.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12
13#ifndef _LINUX_PROPERTY_H_
14#define _LINUX_PROPERTY_H_
15
16#include <linux/types.h>
17
18struct device;
19
20enum dev_prop_type {
21 DEV_PROP_U8,
22 DEV_PROP_U16,
23 DEV_PROP_U32,
24 DEV_PROP_U64,
25 DEV_PROP_STRING,
26 DEV_PROP_MAX,
27};
28
29bool device_property_present(struct device *dev, const char *propname);
30int device_property_read_u8_array(struct device *dev, const char *propname,
31 u8 *val, size_t nval);
32int device_property_read_u16_array(struct device *dev, const char *propname,
33 u16 *val, size_t nval);
34int device_property_read_u32_array(struct device *dev, const char *propname,
35 u32 *val, size_t nval);
36int device_property_read_u64_array(struct device *dev, const char *propname,
37 u64 *val, size_t nval);
38int device_property_read_string_array(struct device *dev, const char *propname,
39 const char **val, size_t nval);
40int device_property_read_string(struct device *dev, const char *propname,
41 const char **val);
42
8a0662d9
RW
43enum fwnode_type {
44 FWNODE_INVALID = 0,
45 FWNODE_OF,
46 FWNODE_ACPI,
47};
48
49struct fwnode_handle {
50 enum fwnode_type type;
51};
52
53bool fwnode_property_present(struct fwnode_handle *fwnode, const char *propname);
54int fwnode_property_read_u8_array(struct fwnode_handle *fwnode,
55 const char *propname, u8 *val,
56 size_t nval);
57int fwnode_property_read_u16_array(struct fwnode_handle *fwnode,
58 const char *propname, u16 *val,
59 size_t nval);
60int fwnode_property_read_u32_array(struct fwnode_handle *fwnode,
61 const char *propname, u32 *val,
62 size_t nval);
63int fwnode_property_read_u64_array(struct fwnode_handle *fwnode,
64 const char *propname, u64 *val,
65 size_t nval);
66int fwnode_property_read_string_array(struct fwnode_handle *fwnode,
67 const char *propname, const char **val,
68 size_t nval);
69int fwnode_property_read_string(struct fwnode_handle *fwnode,
70 const char *propname, const char **val);
71
72struct fwnode_handle *device_get_next_child_node(struct device *dev,
73 struct fwnode_handle *child);
74
75#define device_for_each_child_node(dev, child) \
76 for (child = device_get_next_child_node(dev, NULL); child; \
77 child = device_get_next_child_node(dev, child))
78
79void fwnode_handle_put(struct fwnode_handle *fwnode);
80
81unsigned int device_get_child_node_count(struct device *dev);
82
b31384fa
RW
83static inline bool device_property_read_bool(struct device *dev,
84 const char *propname)
85{
86 return device_property_present(dev, propname);
87}
88
89static inline int device_property_read_u8(struct device *dev,
90 const char *propname, u8 *val)
91{
92 return device_property_read_u8_array(dev, propname, val, 1);
93}
94
95static inline int device_property_read_u16(struct device *dev,
96 const char *propname, u16 *val)
97{
98 return device_property_read_u16_array(dev, propname, val, 1);
99}
100
101static inline int device_property_read_u32(struct device *dev,
102 const char *propname, u32 *val)
103{
104 return device_property_read_u32_array(dev, propname, val, 1);
105}
106
107static inline int device_property_read_u64(struct device *dev,
108 const char *propname, u64 *val)
109{
110 return device_property_read_u64_array(dev, propname, val, 1);
111}
112
8a0662d9
RW
113static inline bool fwnode_property_read_bool(struct fwnode_handle *fwnode,
114 const char *propname)
115{
116 return fwnode_property_present(fwnode, propname);
117}
118
119static inline int fwnode_property_read_u8(struct fwnode_handle *fwnode,
120 const char *propname, u8 *val)
121{
122 return fwnode_property_read_u8_array(fwnode, propname, val, 1);
123}
124
125static inline int fwnode_property_read_u16(struct fwnode_handle *fwnode,
126 const char *propname, u16 *val)
127{
128 return fwnode_property_read_u16_array(fwnode, propname, val, 1);
129}
130
131static inline int fwnode_property_read_u32(struct fwnode_handle *fwnode,
132 const char *propname, u32 *val)
133{
134 return fwnode_property_read_u32_array(fwnode, propname, val, 1);
135}
136
137static inline int fwnode_property_read_u64(struct fwnode_handle *fwnode,
138 const char *propname, u64 *val)
139{
140 return fwnode_property_read_u64_array(fwnode, propname, val, 1);
141}
142
b31384fa 143#endif /* _LINUX_PROPERTY_H_ */
This page took 0.044619 seconds and 5 git commands to generate.