hwconfig.h 2.4 KB

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