rfkill.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. #ifndef __RFKILL_H
  2. #define __RFKILL_H
  3. /*
  4. * Copyright (C) 2006 Ivo van Doorn
  5. * Copyright (C) 2007 Dmitry Torokhov
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the
  19. * Free Software Foundation, Inc.,
  20. * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  21. */
  22. #include <linux/types.h>
  23. #include <linux/kernel.h>
  24. #include <linux/list.h>
  25. #include <linux/mutex.h>
  26. #include <linux/device.h>
  27. /**
  28. * enum rfkill_type - type of rfkill switch.
  29. * RFKILL_TYPE_WLAN: switch is no a Wireless network devices.
  30. * RFKILL_TYPE_BlUETOOTH: switch is on a bluetooth device.
  31. * RFKILL_TYPE_UWB: switch is on a Ultra wideband device.
  32. */
  33. enum rfkill_type {
  34. RFKILL_TYPE_WLAN ,
  35. RFKILL_TYPE_BLUETOOTH,
  36. RFKILL_TYPE_UWB,
  37. RFKILL_TYPE_MAX,
  38. };
  39. enum rfkill_state {
  40. RFKILL_STATE_OFF = 0,
  41. RFKILL_STATE_ON = 1,
  42. };
  43. /**
  44. * struct rfkill - rfkill control structure.
  45. * @name: Name of the switch.
  46. * @type: Radio type which the button controls, the value stored
  47. * here should be a value from enum rfkill_type.
  48. * @state: State of the switch (on/off).
  49. * @user_claim: Set when the switch is controlled exlusively by userspace.
  50. * @mutex: Guards switch state transitions
  51. * @data: Pointer to the RF button drivers private data which will be
  52. * passed along when toggling radio state.
  53. * @toggle_radio(): Mandatory handler to control state of the radio.
  54. * @dev: Device structure integrating the switch into device tree.
  55. * @node: Used to place switch into list of all switches known to the
  56. * the system.
  57. *
  58. * This structure represents a RF switch located on a network device.
  59. */
  60. struct rfkill {
  61. const char *name;
  62. enum rfkill_type type;
  63. enum rfkill_state state;
  64. bool user_claim;
  65. struct mutex mutex;
  66. void *data;
  67. int (*toggle_radio)(void *data, enum rfkill_state state);
  68. struct device dev;
  69. struct list_head node;
  70. };
  71. #define to_rfkill(d) container_of(d, struct rfkill, dev)
  72. struct rfkill *rfkill_allocate(struct device *parent, enum rfkill_type type);
  73. void rfkill_free(struct rfkill *rfkill);
  74. int rfkill_register(struct rfkill *rfkill);
  75. void rfkill_unregister(struct rfkill *rfkill);
  76. void rfkill_switch_all(enum rfkill_type type, enum rfkill_state state);
  77. #endif /* RFKILL_H */