blob: 9242fb0221ba46d53da783d8360ce024dba7a95d [file] [log] [blame]
Rafael J. Wysockib31384f2014-11-04 01:28:56 +01001/*
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
43static inline bool device_property_read_bool(struct device *dev,
44 const char *propname)
45{
46 return device_property_present(dev, propname);
47}
48
49static inline int device_property_read_u8(struct device *dev,
50 const char *propname, u8 *val)
51{
52 return device_property_read_u8_array(dev, propname, val, 1);
53}
54
55static inline int device_property_read_u16(struct device *dev,
56 const char *propname, u16 *val)
57{
58 return device_property_read_u16_array(dev, propname, val, 1);
59}
60
61static inline int device_property_read_u32(struct device *dev,
62 const char *propname, u32 *val)
63{
64 return device_property_read_u32_array(dev, propname, val, 1);
65}
66
67static inline int device_property_read_u64(struct device *dev,
68 const char *propname, u64 *val)
69{
70 return device_property_read_u64_array(dev, propname, val, 1);
71}
72
73#endif /* _LINUX_PROPERTY_H_ */