hwconfig.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License as
  11. * published by the Free Software Foundation; either version 2 of
  12. * the License, or (at your option) any later version.
  13. */
  14. #ifndef _HWCONFIG_H
  15. #define _HWCONFIG_H
  16. #include <linux/types.h>
  17. #include <asm/errno.h>
  18. #ifdef CONFIG_HWCONFIG
  19. extern int hwconfig_f(const char *opt, char *buf);
  20. extern const char *hwconfig_arg_f(const char *opt, size_t *arglen, char *buf);
  21. extern int hwconfig_arg_cmp_f(const char *opt, const char *arg, char *buf);
  22. extern int hwconfig_sub_f(const char *opt, const char *subopt, char *buf);
  23. extern const char *hwconfig_subarg_f(const char *opt, const char *subopt,
  24. size_t *subarglen, char *buf);
  25. extern int hwconfig_subarg_cmp_f(const char *opt, const char *subopt,
  26. const char *subarg, char *buf);
  27. #else
  28. static inline int hwconfig_f(const char *opt, char *buf)
  29. {
  30. return -ENOSYS;
  31. }
  32. static inline const char *hwconfig_arg_f(const char *opt, size_t *arglen,
  33. char *buf)
  34. {
  35. *arglen = 0;
  36. return "";
  37. }
  38. static inline int hwconfig_arg_cmp_f(const char *opt, const char *arg,
  39. char *buf)
  40. {
  41. return -ENOSYS;
  42. }
  43. static inline int hwconfig_sub_f(const char *opt, const char *subopt, char *buf)
  44. {
  45. return -ENOSYS;
  46. }
  47. static inline const char *hwconfig_subarg_f(const char *opt, const char *subopt,
  48. size_t *subarglen, char *buf)
  49. {
  50. *subarglen = 0;
  51. return "";
  52. }
  53. static inline int hwconfig_subarg_cmp_f(const char *opt, const char *subopt,
  54. const char *subarg, char *buf)
  55. {
  56. return -ENOSYS;
  57. }
  58. #endif /* CONFIG_HWCONFIG */
  59. static inline int hwconfig(const char *opt)
  60. {
  61. return hwconfig_f(opt, NULL);
  62. }
  63. static inline const char *hwconfig_arg(const char *opt, size_t *arglen)
  64. {
  65. return hwconfig_arg_f(opt, arglen, NULL);
  66. }
  67. static inline int hwconfig_arg_cmp(const char *opt, const char *arg)
  68. {
  69. return hwconfig_arg_cmp_f(opt, arg, NULL);
  70. }
  71. static inline int hwconfig_sub(const char *opt, const char *subopt)
  72. {
  73. return hwconfig_sub_f(opt, subopt, NULL);
  74. }
  75. static inline const char *hwconfig_subarg(const char *opt, const char *subopt,
  76. size_t *subarglen)
  77. {
  78. return hwconfig_subarg_f(opt, subopt, subarglen, NULL);
  79. }
  80. static inline int hwconfig_subarg_cmp(const char *opt, const char *subopt,
  81. const char *subarg)
  82. {
  83. return hwconfig_subarg_cmp_f(opt, subopt, subarg, NULL);
  84. }
  85. #endif /* _HWCONFIG_H */