property.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. #ifndef _LINUX_PROPERTY_H_
  13. #define _LINUX_PROPERTY_H_
  14. #include <linux/types.h>
  15. struct device;
  16. enum dev_prop_type {
  17. DEV_PROP_U8,
  18. DEV_PROP_U16,
  19. DEV_PROP_U32,
  20. DEV_PROP_U64,
  21. DEV_PROP_STRING,
  22. DEV_PROP_MAX,
  23. };
  24. bool device_property_present(struct device *dev, const char *propname);
  25. int device_property_read_u8_array(struct device *dev, const char *propname,
  26. u8 *val, size_t nval);
  27. int device_property_read_u16_array(struct device *dev, const char *propname,
  28. u16 *val, size_t nval);
  29. int device_property_read_u32_array(struct device *dev, const char *propname,
  30. u32 *val, size_t nval);
  31. int device_property_read_u64_array(struct device *dev, const char *propname,
  32. u64 *val, size_t nval);
  33. int device_property_read_string_array(struct device *dev, const char *propname,
  34. const char **val, size_t nval);
  35. int device_property_read_string(struct device *dev, const char *propname,
  36. const char **val);
  37. static inline bool device_property_read_bool(struct device *dev,
  38. const char *propname)
  39. {
  40. return device_property_present(dev, propname);
  41. }
  42. static inline int device_property_read_u8(struct device *dev,
  43. const char *propname, u8 *val)
  44. {
  45. return device_property_read_u8_array(dev, propname, val, 1);
  46. }
  47. static inline int device_property_read_u16(struct device *dev,
  48. const char *propname, u16 *val)
  49. {
  50. return device_property_read_u16_array(dev, propname, val, 1);
  51. }
  52. static inline int device_property_read_u32(struct device *dev,
  53. const char *propname, u32 *val)
  54. {
  55. return device_property_read_u32_array(dev, propname, val, 1);
  56. }
  57. static inline int device_property_read_u64(struct device *dev,
  58. const char *propname, u64 *val)
  59. {
  60. return device_property_read_u64_array(dev, propname, val, 1);
  61. }
  62. #endif /* _LINUX_PROPERTY_H_ */