wimax-internal.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*
  2. * Linux WiMAX
  3. * Internal API for kernel space WiMAX stack
  4. *
  5. *
  6. * Copyright (C) 2007 Intel Corporation <linux-wimax@intel.com>
  7. * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.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 version
  11. * 2 as published by the Free Software Foundation.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  21. * 02110-1301, USA.
  22. *
  23. *
  24. * This header file is for declarations and definitions internal to
  25. * the WiMAX stack. For public APIs and documentation, see
  26. * include/net/wimax.h and include/linux/wimax.h.
  27. */
  28. #ifndef __WIMAX_INTERNAL_H__
  29. #define __WIMAX_INTERNAL_H__
  30. #ifdef __KERNEL__
  31. #include <linux/device.h>
  32. #include <net/wimax.h>
  33. /*
  34. * Decide if a (locked) device is ready for use
  35. *
  36. * Before using the device structure, it must be locked
  37. * (wimax_dev->mutex). As well, most operations need to call this
  38. * function to check if the state is the right one.
  39. *
  40. * An error value will be returned if the state is not the right
  41. * one. In that case, the caller should not attempt to use the device
  42. * and just unlock it.
  43. */
  44. static inline __must_check
  45. int wimax_dev_is_ready(struct wimax_dev *wimax_dev)
  46. {
  47. if (wimax_dev->state == __WIMAX_ST_NULL)
  48. return -EINVAL; /* Device is not even registered! */
  49. if (wimax_dev->state == WIMAX_ST_DOWN)
  50. return -ENOMEDIUM;
  51. if (wimax_dev->state == __WIMAX_ST_QUIESCING)
  52. return -ESHUTDOWN;
  53. return 0;
  54. }
  55. static inline
  56. void __wimax_state_set(struct wimax_dev *wimax_dev, enum wimax_st state)
  57. {
  58. wimax_dev->state = state;
  59. }
  60. extern void __wimax_state_change(struct wimax_dev *, enum wimax_st);
  61. #ifdef CONFIG_DEBUG_FS
  62. extern int wimax_debugfs_add(struct wimax_dev *);
  63. extern void wimax_debugfs_rm(struct wimax_dev *);
  64. #else
  65. static inline int wimax_debugfs_add(struct wimax_dev *wimax_dev)
  66. {
  67. return 0;
  68. }
  69. static inline void wimax_debugfs_rm(struct wimax_dev *wimax_dev) {}
  70. #endif
  71. extern void wimax_id_table_add(struct wimax_dev *);
  72. extern struct wimax_dev *wimax_dev_get_by_genl_info(struct genl_info *, int);
  73. extern void wimax_id_table_rm(struct wimax_dev *);
  74. extern void wimax_id_table_release(void);
  75. extern int wimax_rfkill_add(struct wimax_dev *);
  76. extern void wimax_rfkill_rm(struct wimax_dev *);
  77. extern struct genl_family wimax_gnl_family;
  78. extern struct genl_multicast_group wimax_gnl_mcg;
  79. #endif /* #ifdef __KERNEL__ */
  80. #endif /* #ifndef __WIMAX_INTERNAL_H__ */