Subversion Repositories Kolibri OS

Rev

Rev 6588 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 6588 Rev 6936
Line 142... Line 142...
142
}
142
}
Line 143... Line 143...
143
 
143
 
144
/**
144
/**
145
 * struct property_entry - "Built-in" device property representation.
145
 * struct property_entry - "Built-in" device property representation.
-
 
146
 * @name: Name of the property.
146
 * @name: Name of the property.
147
 * @length: Length of data making up the value.
-
 
148
 * @is_array: True when the property is an array.
147
 * @type: Type of the property.
149
 * @is_string: True when property is a string.
148
 * @nval: Number of items of type @type making up the value.
150
 * @pointer: Pointer to the property (an array of items of the given type).
149
 * @value: Value of the property (an array of @nval items of type @type).
151
 * @value: Value of the property (when it is a single item of the given type).
150
 */
152
 */
151
struct property_entry {
153
struct property_entry {
152
	const char *name;
154
	const char *name;
153
	enum dev_prop_type type;
155
	size_t length;
-
 
156
	bool is_array;
-
 
157
	bool is_string;
154
	size_t nval;
158
	union {
155
	union {
159
	union {
156
		void *raw_data;
160
		void *raw_data;
157
		u8 *u8_data;
161
		u8 *u8_data;
158
		u16 *u16_data;
162
		u16 *u16_data;
159
		u32 *u32_data;
163
		u32 *u32_data;
160
		u64 *u64_data;
164
		u64 *u64_data;
-
 
165
		const char **str;
-
 
166
		} pointer;
-
 
167
		union {
-
 
168
			unsigned long long raw_data;
-
 
169
			u8 u8_data;
-
 
170
			u16 u16_data;
-
 
171
			u32 u32_data;
-
 
172
			u64 u64_data;
161
		const char **str;
173
			const char *str;
162
	} value;
174
	} value;
-
 
175
};
-
 
176
};
-
 
177
 
-
 
178
/*
-
 
179
 * Note: the below four initializers for the anonymous union are carefully
-
 
180
 * crafted to avoid gcc-4.4.4's problems with initialization of anon unions
-
 
181
 * and structs.
-
 
182
 */
-
 
183
 
-
 
184
#define PROPERTY_ENTRY_INTEGER_ARRAY(_name_, _type_, _val_)	\
-
 
185
{								\
-
 
186
	.name = _name_,						\
-
 
187
	.length = ARRAY_SIZE(_val_) * sizeof(_type_),		\
-
 
188
	.is_array = true,					\
-
 
189
	.is_string = false,					\
-
 
190
	{ .pointer = { _type_##_data = _val_ } },		\
-
 
191
}
-
 
192
 
-
 
193
#define PROPERTY_ENTRY_U8_ARRAY(_name_, _val_)			\
-
 
194
	PROPERTY_ENTRY_INTEGER_ARRAY(_name_, u8, _val_)
-
 
195
#define PROPERTY_ENTRY_U16_ARRAY(_name_, _val_)			\
-
 
196
	PROPERTY_ENTRY_INTEGER_ARRAY(_name_, u16, _val_)
-
 
197
#define PROPERTY_ENTRY_U32_ARRAY(_name_, _val_)			\
-
 
198
	PROPERTY_ENTRY_INTEGER_ARRAY(_name_, u32, _val_)
-
 
199
#define PROPERTY_ENTRY_U64_ARRAY(_name_, _val_)			\
-
 
200
	PROPERTY_ENTRY_INTEGER_ARRAY(_name_, u64, _val_)
-
 
201
 
-
 
202
#define PROPERTY_ENTRY_STRING_ARRAY(_name_, _val_)		\
-
 
203
{								\
-
 
204
	.name = _name_,						\
-
 
205
	.length = ARRAY_SIZE(_val_) * sizeof(const char *),	\
-
 
206
	.is_array = true,					\
-
 
207
	.is_string = true,					\
-
 
208
	{ .pointer = { .str = _val_ } },			\
-
 
209
}
-
 
210
 
-
 
211
#define PROPERTY_ENTRY_INTEGER(_name_, _type_, _val_)	\
-
 
212
{							\
-
 
213
	.name = _name_,					\
-
 
214
	.length = sizeof(_type_),			\
-
 
215
	.is_string = false,				\
-
 
216
	{ .value = { ._type_##_data = _val_ } },	\
-
 
217
}
-
 
218
 
-
 
219
#define PROPERTY_ENTRY_U8(_name_, _val_)		\
-
 
220
	PROPERTY_ENTRY_INTEGER(_name_, u8, _val_)
-
 
221
#define PROPERTY_ENTRY_U16(_name_, _val_)		\
-
 
222
	PROPERTY_ENTRY_INTEGER(_name_, u16, _val_)
-
 
223
#define PROPERTY_ENTRY_U32(_name_, _val_)		\
-
 
224
	PROPERTY_ENTRY_INTEGER(_name_, u32, _val_)
-
 
225
#define PROPERTY_ENTRY_U64(_name_, _val_)		\
-
 
226
	PROPERTY_ENTRY_INTEGER(_name_, u64, _val_)
-
 
227
 
-
 
228
#define PROPERTY_ENTRY_STRING(_name_, _val_)		\
-
 
229
{							\
-
 
230
	.name = _name_,					\
-
 
231
	.length = sizeof(_val_),			\
-
 
232
	.is_string = true,				\
-
 
233
	{ .value = { .str = _val_ } },			\
-
 
234
}
-
 
235
 
-
 
236
#define PROPERTY_ENTRY_BOOL(_name_)		\
-
 
237
{						\
-
 
238
	.name = _name_,				\
Line 163... Line 239...
163
};
239
}
164
 
240
 
165
/**
241
/**
166
 * struct property_set - Collection of "built-in" device properties.
242
 * struct property_set - Collection of "built-in" device properties.
Line 170... Line 246...
170
struct property_set {
246
struct property_set {
171
	struct fwnode_handle fwnode;
247
	struct fwnode_handle fwnode;
172
	struct property_entry *properties;
248
	struct property_entry *properties;
173
};
249
};
Line 174... Line 250...
174
 
250
 
-
 
251
int device_add_property_set(struct device *dev, const struct property_set *pset);
Line 175... Line 252...
175
void device_add_property_set(struct device *dev, struct property_set *pset);
252
void device_remove_property_set(struct device *dev);
Line 176... Line 253...
176
 
253