linux/net/rfkill/core.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * Copyright (C) 2006 - 2007 Ivo van Doorn
 * Copyright (C) 2007 Dmitry Torokhov
 * Copyright 2009 Johannes Berg <[email protected]>
 */

#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/workqueue.h>
#include <linux/capability.h>
#include <linux/list.h>
#include <linux/mutex.h>
#include <linux/rfkill.h>
#include <linux/sched.h>
#include <linux/spinlock.h>
#include <linux/device.h>
#include <linux/miscdevice.h>
#include <linux/wait.h>
#include <linux/poll.h>
#include <linux/fs.h>
#include <linux/slab.h>

#include "rfkill.h"

#define POLL_INTERVAL

#define RFKILL_BLOCK_HW
#define RFKILL_BLOCK_SW
#define RFKILL_BLOCK_SW_PREV
#define RFKILL_BLOCK_ANY
#define RFKILL_BLOCK_SW_SETCALL

struct rfkill {};
#define to_rfkill(d)

struct rfkill_int_event {};

struct rfkill_data {};


MODULE_AUTHOR();
MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_LICENSE();


/*
 * The locking here should be made much smarter, we currently have
 * a bit of a stupid situation because drivers might want to register
 * the rfkill struct under their own lock, and take this lock during
 * rfkill method calls -- which will cause an AB-BA deadlock situation.
 *
 * To fix that, we need to rework this code here to be mostly lock-free
 * and only use the mutex for list manipulations, not to protect the
 * various other global variables. Then we can avoid holding the mutex
 * around driver operations, and all is happy.
 */
static LIST_HEAD(rfkill_list);	/* list of registered rf switches */
static DEFINE_MUTEX(rfkill_global_mutex);
static LIST_HEAD(rfkill_fds);	/* list of open fds of /dev/rfkill */

static unsigned int rfkill_default_state =;
module_param_named(default_state, rfkill_default_state, uint, 0444);
MODULE_PARM_DESC();

static struct {} rfkill_global_states[NUM_RFKILL_TYPES];

static bool rfkill_epo_lock_active;


#ifdef CONFIG_RFKILL_LEDS
static void rfkill_led_trigger_event(struct rfkill *rfkill)
{}

static int rfkill_led_trigger_activate(struct led_classdev *led)
{}

const char *rfkill_get_led_trigger_name(struct rfkill *rfkill)
{}
EXPORT_SYMBOL();

void rfkill_set_led_trigger_name(struct rfkill *rfkill, const char *name)
{}
EXPORT_SYMBOL();

static int rfkill_led_trigger_register(struct rfkill *rfkill)
{}

static void rfkill_led_trigger_unregister(struct rfkill *rfkill)
{}

static struct led_trigger rfkill_any_led_trigger;
static struct led_trigger rfkill_none_led_trigger;
static struct work_struct rfkill_global_led_trigger_work;

static void rfkill_global_led_trigger_worker(struct work_struct *work)
{}

static void rfkill_global_led_trigger_event(void)
{}

static int rfkill_global_led_trigger_register(void)
{}

static void rfkill_global_led_trigger_unregister(void)
{}
#else
static void rfkill_led_trigger_event(struct rfkill *rfkill)
{
}

static inline int rfkill_led_trigger_register(struct rfkill *rfkill)
{
	return 0;
}

static inline void rfkill_led_trigger_unregister(struct rfkill *rfkill)
{
}

static void rfkill_global_led_trigger_event(void)
{
}

static int rfkill_global_led_trigger_register(void)
{
	return 0;
}

static void rfkill_global_led_trigger_unregister(void)
{
}
#endif /* CONFIG_RFKILL_LEDS */

static void rfkill_fill_event(struct rfkill_event_ext *ev,
			      struct rfkill *rfkill,
			      enum rfkill_operation op)
{}

static void rfkill_send_events(struct rfkill *rfkill, enum rfkill_operation op)
{}

static void rfkill_event(struct rfkill *rfkill)
{}

/**
 * rfkill_set_block - wrapper for set_block method
 *
 * @rfkill: the rfkill struct to use
 * @blocked: the new software state
 *
 * Calls the set_block method (when applicable) and handles notifications
 * etc. as well.
 */
static void rfkill_set_block(struct rfkill *rfkill, bool blocked)
{}

static void rfkill_sync(struct rfkill *rfkill)
{}

static void rfkill_update_global_state(enum rfkill_type type, bool blocked)
{}

#ifdef CONFIG_RFKILL_INPUT
static atomic_t rfkill_input_disabled =;

/**
 * __rfkill_switch_all - Toggle state of all switches of given type
 * @type: type of interfaces to be affected
 * @blocked: the new state
 *
 * This function sets the state of all switches of given type,
 * unless a specific switch is suspended.
 *
 * Caller must have acquired rfkill_global_mutex.
 */
static void __rfkill_switch_all(const enum rfkill_type type, bool blocked)
{}

/**
 * rfkill_switch_all - Toggle state of all switches of given type
 * @type: type of interfaces to be affected
 * @blocked: the new state
 *
 * Acquires rfkill_global_mutex and calls __rfkill_switch_all(@type, @state).
 * Please refer to __rfkill_switch_all() for details.
 *
 * Does nothing if the EPO lock is active.
 */
void rfkill_switch_all(enum rfkill_type type, bool blocked)
{}

/**
 * rfkill_epo - emergency power off all transmitters
 *
 * This kicks all non-suspended rfkill devices to RFKILL_STATE_SOFT_BLOCKED,
 * ignoring everything in its path but rfkill_global_mutex and rfkill->mutex.
 *
 * The global state before the EPO is saved and can be restored later
 * using rfkill_restore_states().
 */
void rfkill_epo(void)
{}

/**
 * rfkill_restore_states - restore global states
 *
 * Restore (and sync switches to) the global state from the
 * states in rfkill_default_states.  This can undo the effects of
 * a call to rfkill_epo().
 */
void rfkill_restore_states(void)
{}

/**
 * rfkill_remove_epo_lock - unlock state changes
 *
 * Used by rfkill-input manually unlock state changes, when
 * the EPO switch is deactivated.
 */
void rfkill_remove_epo_lock(void)
{}

/**
 * rfkill_is_epo_lock_active - returns true EPO is active
 *
 * Returns 0 (false) if there is NOT an active EPO condition,
 * and 1 (true) if there is an active EPO condition, which
 * locks all radios in one of the BLOCKED states.
 *
 * Can be called in atomic context.
 */
bool rfkill_is_epo_lock_active(void)
{}

/**
 * rfkill_get_global_sw_state - returns global state for a type
 * @type: the type to get the global state of
 *
 * Returns the current global state for a given wireless
 * device type.
 */
bool rfkill_get_global_sw_state(const enum rfkill_type type)
{}
#endif

bool rfkill_set_hw_state_reason(struct rfkill *rfkill,
				bool blocked, unsigned long reason)
{}
EXPORT_SYMBOL();

static void __rfkill_set_sw_state(struct rfkill *rfkill, bool blocked)
{}

bool rfkill_set_sw_state(struct rfkill *rfkill, bool blocked)
{}
EXPORT_SYMBOL();

void rfkill_init_sw_state(struct rfkill *rfkill, bool blocked)
{}
EXPORT_SYMBOL();

void rfkill_set_states(struct rfkill *rfkill, bool sw, bool hw)
{}
EXPORT_SYMBOL();

static const char * const rfkill_types[] =;

enum rfkill_type rfkill_find_type(const char *name)
{}
EXPORT_SYMBOL();

static ssize_t name_show(struct device *dev, struct device_attribute *attr,
			 char *buf)
{}
static DEVICE_ATTR_RO(name);

static ssize_t type_show(struct device *dev, struct device_attribute *attr,
			 char *buf)
{}
static DEVICE_ATTR_RO(type);

static ssize_t index_show(struct device *dev, struct device_attribute *attr,
			  char *buf)
{}
static DEVICE_ATTR_RO(index);

static ssize_t persistent_show(struct device *dev,
			       struct device_attribute *attr, char *buf)
{}
static DEVICE_ATTR_RO(persistent);

static ssize_t hard_show(struct device *dev, struct device_attribute *attr,
			 char *buf)
{}
static DEVICE_ATTR_RO(hard);

static ssize_t soft_show(struct device *dev, struct device_attribute *attr,
			 char *buf)
{}

static ssize_t soft_store(struct device *dev, struct device_attribute *attr,
			  const char *buf, size_t count)
{}
static DEVICE_ATTR_RW(soft);

static ssize_t hard_block_reasons_show(struct device *dev,
				       struct device_attribute *attr,
				       char *buf)
{}
static DEVICE_ATTR_RO(hard_block_reasons);

static u8 user_state_from_blocked(unsigned long state)
{}

static ssize_t state_show(struct device *dev, struct device_attribute *attr,
			  char *buf)
{}

static ssize_t state_store(struct device *dev, struct device_attribute *attr,
			   const char *buf, size_t count)
{}
static DEVICE_ATTR_RW(state);

static struct attribute *rfkill_dev_attrs[] =;
ATTRIBUTE_GROUPS();

static void rfkill_release(struct device *dev)
{}

static int rfkill_dev_uevent(const struct device *dev, struct kobj_uevent_env *env)
{}

void rfkill_pause_polling(struct rfkill *rfkill)
{}
EXPORT_SYMBOL();

void rfkill_resume_polling(struct rfkill *rfkill)
{}
EXPORT_SYMBOL();

#ifdef CONFIG_PM_SLEEP
static int rfkill_suspend(struct device *dev)
{}

static int rfkill_resume(struct device *dev)
{}

static SIMPLE_DEV_PM_OPS(rfkill_pm_ops, rfkill_suspend, rfkill_resume);
#define RFKILL_PM_OPS
#else
#define RFKILL_PM_OPS
#endif

static struct class rfkill_class =;

bool rfkill_blocked(struct rfkill *rfkill)
{}
EXPORT_SYMBOL();

bool rfkill_soft_blocked(struct rfkill *rfkill)
{}
EXPORT_SYMBOL();

struct rfkill * __must_check rfkill_alloc(const char *name,
					  struct device *parent,
					  const enum rfkill_type type,
					  const struct rfkill_ops *ops,
					  void *ops_data)
{}
EXPORT_SYMBOL();

static void rfkill_poll(struct work_struct *work)
{}

static void rfkill_uevent_work(struct work_struct *work)
{}

static void rfkill_sync_work(struct work_struct *work)
{}

int __must_check rfkill_register(struct rfkill *rfkill)
{}
EXPORT_SYMBOL();

void rfkill_unregister(struct rfkill *rfkill)
{}
EXPORT_SYMBOL();

void rfkill_destroy(struct rfkill *rfkill)
{}
EXPORT_SYMBOL();

static int rfkill_fop_open(struct inode *inode, struct file *file)
{}

static __poll_t rfkill_fop_poll(struct file *file, poll_table *wait)
{}

static ssize_t rfkill_fop_read(struct file *file, char __user *buf,
			       size_t count, loff_t *pos)
{}

static ssize_t rfkill_fop_write(struct file *file, const char __user *buf,
				size_t count, loff_t *pos)
{}

static int rfkill_fop_release(struct inode *inode, struct file *file)
{}

static long rfkill_fop_ioctl(struct file *file, unsigned int cmd,
			     unsigned long arg)
{}

static const struct file_operations rfkill_fops =;

#define RFKILL_NAME

static struct miscdevice rfkill_miscdev =;

static int __init rfkill_init(void)
{}
subsys_initcall(rfkill_init);

static void __exit rfkill_exit(void)
{}
module_exit(rfkill_exit);

MODULE_ALIAS_MISCDEV();
MODULE_ALIAS();