Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cf4328cd authored by Ivo van Doorn's avatar Ivo van Doorn Committed by David S. Miller
Browse files

[NET]: rfkill: add support for input key to control wireless radio



The RF kill patch that provides infrastructure for implementing
switches controlling radio states on various network and other cards.

[dtor@insightbb.com: address review comments]
[akpm@linux-foundation.org: cleanups, build fixes]

Signed-off-by: default avatarIvo van Doorn <IvDoorn@gmail.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarDmitry Torokhov <dtor@mail.ru>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 2396a22e
Loading
Loading
Loading
Loading

include/linux/rfkill.h

0 → 100644
+89 −0
Original line number Diff line number Diff line
#ifndef __RFKILL_H
#define __RFKILL_H

/*
 * Copyright (C) 2006 Ivo van Doorn
 * Copyright (C) 2007 Dmitry Torokhov
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the
 * Free Software Foundation, Inc.,
 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/list.h>
#include <linux/mutex.h>
#include <linux/device.h>

/**
 * enum rfkill_type - type of rfkill switch.
 * RFKILL_TYPE_WLAN: switch is no a Wireless network devices.
 * RFKILL_TYPE_BlUETOOTH: switch is on a bluetooth device.
 * RFKILL_TYPE_IRDA: switch is on an infrared devices.
 */
enum rfkill_type {
	RFKILL_TYPE_WLAN = 0,
	RFKILL_TYPE_BLUETOOTH = 1,
	RFKILL_TYPE_IRDA = 2,
	RFKILL_TYPE_MAX = 3,
};

enum rfkill_state {
	RFKILL_STATE_OFF	= 0,
	RFKILL_STATE_ON		= 1,
};

/**
 * struct rfkill - rfkill control structure.
 * @name: Name of the switch.
 * @type: Radio type which the button controls, the value stored
 *	here should be a value from enum rfkill_type.
 * @state: State of the switch (on/off).
 * @user_claim: Set when the switch is controlled exlusively by userspace.
 * @mutex: Guards switch state transitions
 * @data: Pointer to the RF button drivers private data which will be
 *	passed along when toggling radio state.
 * @toggle_radio(): Mandatory handler to control state of the radio.
 * @dev: Device structure integrating the switch into device tree.
 * @node: Used to place switch into list of all switches known to the
 *	the system.
 *
 * This structure represents a RF switch located on a network device.
 */
struct rfkill {
	char *name;
	enum rfkill_type type;

	enum rfkill_state state;
	bool user_claim;

	struct mutex mutex;

	void *data;
	int (*toggle_radio)(void *data, enum rfkill_state state);

	struct device dev;
	struct list_head node;
};
#define to_rfkill(d)	container_of(d, struct rfkill, dev)

struct rfkill *rfkill_allocate(struct device *parent, enum rfkill_type type);
void rfkill_free(struct rfkill *rfkill);
int rfkill_register(struct rfkill *rfkill);
void rfkill_unregister(struct rfkill *rfkill);

void rfkill_switch_all(enum rfkill_type type, enum rfkill_state state);

#endif /* RFKILL_H */
+2 −0
Original line number Diff line number Diff line
@@ -225,6 +225,8 @@ source "net/ieee80211/Kconfig"

endmenu

source "net/rfkill/Kconfig"

endif   # if NET
endmenu # Networking
+1 −0
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ obj-$(CONFIG_IEEE80211) += ieee80211/
obj-$(CONFIG_TIPC)		+= tipc/
obj-$(CONFIG_NETLABEL)		+= netlabel/
obj-$(CONFIG_IUCV)		+= iucv/
obj-$(CONFIG_RFKILL)		+= rfkill/

ifeq ($(CONFIG_NET),y)
obj-$(CONFIG_SYSCTL)		+= sysctl_net.o

net/rfkill/Kconfig

0 → 100644
+24 −0
Original line number Diff line number Diff line
#
# RF switch subsystem configuration
#
menuconfig RFKILL
	tristate "RF switch subsystem support"
	help
	  Say Y here if you want to have control over RF switches
	  found on many WiFi, Bluetooth and IRDA cards.

	  To compile this driver as a module, choose M here: the
	  module will be called rfkill.

config RFKILL_INPUT
	tristate "Input layer to RF switch connector"
	depends on RFKILL && INPUT
	help
	  Say Y here if you want kernel automatically toggle state
	  of RF switches on and off when user presses appropriate
	  button or a key on the keyboard. Without this module you
	  need a some kind of userspace application to control
	  state of the switches.

	  To compile this driver as a module, choose M here: the
	  module will be called rfkill-input.

net/rfkill/Makefile

0 → 100644
+6 −0
Original line number Diff line number Diff line
#
# Makefile for the RF switch subsystem.
#

obj-$(CONFIG_RFKILL)			+= rfkill.o
obj-$(CONFIG_RFKILL_INPUT)		+= rfkill-input.o
Loading