blob: c4546e15c85395d52b880b7e82cf281654ab3e57 [file] [log] [blame]
Ivo van Doorncf4328c2007-05-07 00:34:20 -07001#ifndef __RFKILL_H
2#define __RFKILL_H
3
4/*
5 * Copyright (C) 2006 Ivo van Doorn
6 * Copyright (C) 2007 Dmitry Torokhov
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
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
20 * Free Software Foundation, Inc.,
21 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 */
23
24#include <linux/types.h>
25#include <linux/kernel.h>
26#include <linux/list.h>
27#include <linux/mutex.h>
28#include <linux/device.h>
29
30/**
31 * enum rfkill_type - type of rfkill switch.
32 * RFKILL_TYPE_WLAN: switch is no a Wireless network devices.
33 * RFKILL_TYPE_BlUETOOTH: switch is on a bluetooth device.
Ivo van Doorncf4328c2007-05-07 00:34:20 -070034 */
35enum rfkill_type {
Ivo van Doorn234a0ca2007-09-13 09:20:42 +020036 RFKILL_TYPE_WLAN ,
37 RFKILL_TYPE_BLUETOOTH,
38 RFKILL_TYPE_MAX,
Ivo van Doorncf4328c2007-05-07 00:34:20 -070039};
40
41enum rfkill_state {
42 RFKILL_STATE_OFF = 0,
43 RFKILL_STATE_ON = 1,
44};
45
46/**
47 * struct rfkill - rfkill control structure.
48 * @name: Name of the switch.
49 * @type: Radio type which the button controls, the value stored
50 * here should be a value from enum rfkill_type.
51 * @state: State of the switch (on/off).
52 * @user_claim: Set when the switch is controlled exlusively by userspace.
53 * @mutex: Guards switch state transitions
54 * @data: Pointer to the RF button drivers private data which will be
55 * passed along when toggling radio state.
56 * @toggle_radio(): Mandatory handler to control state of the radio.
57 * @dev: Device structure integrating the switch into device tree.
58 * @node: Used to place switch into list of all switches known to the
59 * the system.
60 *
61 * This structure represents a RF switch located on a network device.
62 */
63struct rfkill {
Ivo van Doornc36befb2007-06-05 00:04:46 -070064 const char *name;
Ivo van Doorncf4328c2007-05-07 00:34:20 -070065 enum rfkill_type type;
66
67 enum rfkill_state state;
68 bool user_claim;
69
70 struct mutex mutex;
71
72 void *data;
73 int (*toggle_radio)(void *data, enum rfkill_state state);
74
75 struct device dev;
76 struct list_head node;
77};
78#define to_rfkill(d) container_of(d, struct rfkill, dev)
79
80struct rfkill *rfkill_allocate(struct device *parent, enum rfkill_type type);
81void rfkill_free(struct rfkill *rfkill);
82int rfkill_register(struct rfkill *rfkill);
83void rfkill_unregister(struct rfkill *rfkill);
84
85void rfkill_switch_all(enum rfkill_type type, enum rfkill_state state);
86
87#endif /* RFKILL_H */