hwconfig.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * An inteface for configuring a hardware via u-boot environment.
  4. *
  5. * Copyright (c) 2009 MontaVista Software, Inc.
  6. * Copyright 2011 Freescale Semiconductor, Inc.
  7. *
  8. * Author: Anton Vorontsov <avorontsov@ru.mvista.com>
  9. */
  10. #ifndef _HWCONFIG_H
  11. #define _HWCONFIG_H
  12. #include <linux/types.h>
  13. #include <linux/errno.h>
  14. #ifdef CONFIG_HWCONFIG
  15. extern int hwconfig_f(const char *opt, char *buf);
  16. extern const char *hwconfig_arg_f(const char *opt, size_t *arglen, char *buf);
  17. extern int hwconfig_arg_cmp_f(const char *opt, const char *arg, char *buf);
  18. extern int hwconfig_sub_f(const char *opt, const char *subopt, char *buf);
  19. extern const char *hwconfig_subarg_f(const char *opt, const char *subopt,
  20. size_t *subarglen, char *buf);
  21. extern int hwconfig_subarg_cmp_f(const char *opt, const char *subopt,
  22. const char *subarg, char *buf);
  23. #else
  24. static inline int hwconfig_f(const char *opt, char *buf)
  25. {
  26. return -ENOSYS;
  27. }
  28. static inline const char *hwconfig_arg_f(const char *opt, size_t *arglen,
  29. char *buf)
  30. {
  31. *arglen = 0;
  32. return "";
  33. }
  34. static inline int hwconfig_arg_cmp_f(const char *opt, const char *arg,
  35. char *buf)
  36. {
  37. return -ENOSYS;
  38. }
  39. static inline int hwconfig_sub_f(const char *opt, const char *subopt, char *buf)
  40. {
  41. return -ENOSYS;
  42. }
  43. static inline const char *hwconfig_subarg_f(const char *opt, const char *subopt,
  44. size_t *subarglen, char *buf)
  45. {
  46. *subarglen = 0;
  47. return "";
  48. }
  49. static inline int hwconfig_subarg_cmp_f(const char *opt, const char *subopt,
  50. const char *subarg, char *buf)
  51. {
  52. return -ENOSYS;
  53. }
  54. #endif /* CONFIG_HWCONFIG */
  55. static inline int hwconfig(const char *opt)
  56. {
  57. return hwconfig_f(opt, NULL);
  58. }
  59. static inline const char *hwconfig_arg(const char *opt, size_t *arglen)
  60. {
  61. return hwconfig_arg_f(opt, arglen, NULL);
  62. }
  63. static inline int hwconfig_arg_cmp(const char *opt, const char *arg)
  64. {
  65. return hwconfig_arg_cmp_f(opt, arg, NULL);
  66. }
  67. static inline int hwconfig_sub(const char *opt, const char *subopt)
  68. {
  69. return hwconfig_sub_f(opt, subopt, NULL);
  70. }
  71. static inline const char *hwconfig_subarg(const char *opt, const char *subopt,
  72. size_t *subarglen)
  73. {
  74. return hwconfig_subarg_f(opt, subopt, subarglen, NULL);
  75. }
  76. static inline int hwconfig_subarg_cmp(const char *opt, const char *subopt,
  77. const char *subarg)
  78. {
  79. return hwconfig_subarg_cmp_f(opt, subopt, subarg, NULL);
  80. }
  81. #endif /* _HWCONFIG_H */