Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * Linux WiMAX
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  * RF-kill framework integration
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  * Copyright (C) 2008 Intel Corporation <linux-wimax@intel.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  * This integrates into the Linux Kernel rfkill susbystem so that the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  * drivers just have to do the bare minimal work, which is providing a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)  * method to set the software RF-Kill switch and to report changes in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12)  * the software and hardware switch status.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14)  * A non-polled generic rfkill device is embedded into the WiMAX
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15)  * subsystem's representation of a device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17)  * FIXME: Need polled support? Let drivers provide a poll routine
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18)  *	  and hand it to rfkill ops then?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20)  * All device drivers have to do is after wimax_dev_init(), call
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21)  * wimax_report_rfkill_hw() and wimax_report_rfkill_sw() to update
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22)  * initial state and then every time it changes. See wimax.h:struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23)  * wimax_dev for more information.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25)  * ROADMAP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27)  * wimax_gnl_doit_rfkill()      User space calling wimax_rfkill()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28)  *   wimax_rfkill()             Kernel calling wimax_rfkill()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29)  *     __wimax_rf_toggle_radio()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31)  * wimax_rfkill_set_radio_block()  RF-Kill subsystem calling
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32)  *   __wimax_rf_toggle_radio()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34)  * __wimax_rf_toggle_radio()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35)  *   wimax_dev->op_rfkill_sw_toggle() Driver backend
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36)  *   __wimax_state_change()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38)  * wimax_report_rfkill_sw()     Driver reports state change
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39)  *   __wimax_state_change()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41)  * wimax_report_rfkill_hw()     Driver reports state change
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42)  *   __wimax_state_change()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44)  * wimax_rfkill_add()           Initialize/shutdown rfkill support
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45)  * wimax_rfkill_rm()            [called by wimax_dev_add/rm()]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) #include <net/wimax.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) #include <net/genetlink.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) #include <linux/wimax.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) #include <linux/security.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) #include <linux/rfkill.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) #include <linux/export.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) #include "wimax-internal.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) #define D_SUBMODULE op_rfkill
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) #include "debug-levels.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60)  * wimax_report_rfkill_hw - Reports changes in the hardware RF switch
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62)  * @wimax_dev: WiMAX device descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64)  * @state: New state of the RF Kill switch. %WIMAX_RF_ON radio on,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65)  *     %WIMAX_RF_OFF radio off.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67)  * When the device detects a change in the state of thehardware RF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68)  * switch, it must call this function to let the WiMAX kernel stack
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69)  * know that the state has changed so it can be properly propagated.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71)  * The WiMAX stack caches the state (the driver doesn't need to). As
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72)  * well, as the change is propagated it will come back as a request to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73)  * change the software state to mirror the hardware state.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75)  * If the device doesn't have a hardware kill switch, just report
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76)  * it on initialization as always on (%WIMAX_RF_ON, radio on).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) void wimax_report_rfkill_hw(struct wimax_dev *wimax_dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 			    enum wimax_rf_state state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	int result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	struct device *dev = wimax_dev_to_dev(wimax_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	enum wimax_st wimax_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	d_fnstart(3, dev, "(wimax_dev %p state %u)\n", wimax_dev, state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	BUG_ON(state == WIMAX_RF_QUERY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	BUG_ON(state != WIMAX_RF_ON && state != WIMAX_RF_OFF);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	mutex_lock(&wimax_dev->mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	result = wimax_dev_is_ready(wimax_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	if (result < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 		goto error_not_ready;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	if (state != wimax_dev->rf_hw) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 		wimax_dev->rf_hw = state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 		if (wimax_dev->rf_hw == WIMAX_RF_ON &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 		    wimax_dev->rf_sw == WIMAX_RF_ON)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 			wimax_state = WIMAX_ST_READY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 			wimax_state = WIMAX_ST_RADIO_OFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 		result = rfkill_set_hw_state(wimax_dev->rfkill,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 					     state == WIMAX_RF_OFF);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 		__wimax_state_change(wimax_dev, wimax_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) error_not_ready:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	mutex_unlock(&wimax_dev->mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	d_fnend(3, dev, "(wimax_dev %p state %u) = void [%d]\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 		wimax_dev, state, result);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) EXPORT_SYMBOL_GPL(wimax_report_rfkill_hw);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116)  * wimax_report_rfkill_sw - Reports changes in the software RF switch
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118)  * @wimax_dev: WiMAX device descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120)  * @state: New state of the RF kill switch. %WIMAX_RF_ON radio on,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121)  *     %WIMAX_RF_OFF radio off.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123)  * Reports changes in the software RF switch state to the WiMAX stack.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125)  * The main use is during initialization, so the driver can query the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126)  * device for its current software radio kill switch state and feed it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127)  * to the system.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129)  * On the side, the device does not change the software state by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130)  * itself. In practice, this can happen, as the device might decide to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131)  * switch (in software) the radio off for different reasons.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) void wimax_report_rfkill_sw(struct wimax_dev *wimax_dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 			    enum wimax_rf_state state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 	int result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 	struct device *dev = wimax_dev_to_dev(wimax_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	enum wimax_st wimax_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	d_fnstart(3, dev, "(wimax_dev %p state %u)\n", wimax_dev, state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 	BUG_ON(state == WIMAX_RF_QUERY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 	BUG_ON(state != WIMAX_RF_ON && state != WIMAX_RF_OFF);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 	mutex_lock(&wimax_dev->mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 	result = wimax_dev_is_ready(wimax_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 	if (result < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 		goto error_not_ready;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	if (state != wimax_dev->rf_sw) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 		wimax_dev->rf_sw = state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 		if (wimax_dev->rf_hw == WIMAX_RF_ON &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 		    wimax_dev->rf_sw == WIMAX_RF_ON)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 			wimax_state = WIMAX_ST_READY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 			wimax_state = WIMAX_ST_RADIO_OFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 		__wimax_state_change(wimax_dev, wimax_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 		rfkill_set_sw_state(wimax_dev->rfkill, state == WIMAX_RF_OFF);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) error_not_ready:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 	mutex_unlock(&wimax_dev->mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 	d_fnend(3, dev, "(wimax_dev %p state %u) = void [%d]\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 		wimax_dev, state, result);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) EXPORT_SYMBOL_GPL(wimax_report_rfkill_sw);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168)  * Callback for the RF Kill toggle operation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170)  * This function is called by:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172)  * - The rfkill subsystem when the RF-Kill key is pressed in the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173)  *   hardware and the driver notifies through
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174)  *   wimax_report_rfkill_hw(). The rfkill subsystem ends up calling back
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175)  *   here so the software RF Kill switch state is changed to reflect
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176)  *   the hardware switch state.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178)  * - When the user sets the state through sysfs' rfkill/state file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180)  * - When the user calls wimax_rfkill().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182)  * This call blocks!
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184)  * WARNING! When we call rfkill_unregister(), this will be called with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185)  * state 0!
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187)  * WARNING: wimax_dev must be locked
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) static
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) int __wimax_rf_toggle_radio(struct wimax_dev *wimax_dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 			    enum wimax_rf_state state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 	int result = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 	struct device *dev = wimax_dev_to_dev(wimax_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 	enum wimax_st wimax_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 	might_sleep();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 	d_fnstart(3, dev, "(wimax_dev %p state %u)\n", wimax_dev, state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 	if (wimax_dev->rf_sw == state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 		goto out_no_change;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 	if (wimax_dev->op_rfkill_sw_toggle != NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 		result = wimax_dev->op_rfkill_sw_toggle(wimax_dev, state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 	else if (state == WIMAX_RF_OFF)	/* No op? can't turn off */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 		result = -ENXIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 	else				/* No op? can turn on */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 		result = 0;		/* should never happen tho */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 	if (result >= 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 		result = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 		wimax_dev->rf_sw = state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 		wimax_state = state == WIMAX_RF_ON ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 			WIMAX_ST_READY : WIMAX_ST_RADIO_OFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 		__wimax_state_change(wimax_dev, wimax_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) out_no_change:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 	d_fnend(3, dev, "(wimax_dev %p state %u) = %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 		wimax_dev, state, result);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 	return result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222)  * Translate from rfkill state to wimax state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224)  * NOTE: Special state handling rules here
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226)  *     Just pretend the call didn't happen if we are in a state where
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227)  *     we know for sure it cannot be handled (WIMAX_ST_DOWN or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228)  *     __WIMAX_ST_QUIESCING). rfkill() needs it to register and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229)  *     unregister, as it will run this path.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231)  * NOTE: This call will block until the operation is completed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) static int wimax_rfkill_set_radio_block(void *data, bool blocked)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 	int result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 	struct wimax_dev *wimax_dev = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 	struct device *dev = wimax_dev_to_dev(wimax_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 	enum wimax_rf_state rf_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 	d_fnstart(3, dev, "(wimax_dev %p blocked %u)\n", wimax_dev, blocked);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 	rf_state = WIMAX_RF_ON;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 	if (blocked)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 		rf_state = WIMAX_RF_OFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 	mutex_lock(&wimax_dev->mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 	if (wimax_dev->state <= __WIMAX_ST_QUIESCING)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 		result = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 		result = __wimax_rf_toggle_radio(wimax_dev, rf_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 	mutex_unlock(&wimax_dev->mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 	d_fnend(3, dev, "(wimax_dev %p blocked %u) = %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 		wimax_dev, blocked, result);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 	return result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) static const struct rfkill_ops wimax_rfkill_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 	.set_block = wimax_rfkill_set_radio_block,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260)  * wimax_rfkill - Set the software RF switch state for a WiMAX device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262)  * @wimax_dev: WiMAX device descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264)  * @state: New RF state.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266)  * Returns:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268)  * >= 0 toggle state if ok, < 0 errno code on error. The toggle state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269)  * is returned as a bitmap, bit 0 being the hardware RF state, bit 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270)  * the software RF state.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272)  * 0 means disabled (%WIMAX_RF_ON, radio on), 1 means enabled radio
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273)  * off (%WIMAX_RF_OFF).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275)  * Description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277)  * Called by the user when he wants to request the WiMAX radio to be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278)  * switched on (%WIMAX_RF_ON) or off (%WIMAX_RF_OFF). With
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279)  * %WIMAX_RF_QUERY, just the current state is returned.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281)  * NOTE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283)  * This call will block until the operation is complete.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) int wimax_rfkill(struct wimax_dev *wimax_dev, enum wimax_rf_state state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 	int result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 	struct device *dev = wimax_dev_to_dev(wimax_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 	d_fnstart(3, dev, "(wimax_dev %p state %u)\n", wimax_dev, state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 	mutex_lock(&wimax_dev->mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 	result = wimax_dev_is_ready(wimax_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 	if (result < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 		/* While initializing, < 1.4.3 wimax-tools versions use
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 		 * this call to check if the device is a valid WiMAX
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 		 * device; so we allow it to proceed always,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 		 * considering the radios are all off. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 		if (result == -ENOMEDIUM && state == WIMAX_RF_QUERY)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 			result = WIMAX_RF_OFF << 1 | WIMAX_RF_OFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 		goto error_not_ready;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 	switch (state) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 	case WIMAX_RF_ON:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 	case WIMAX_RF_OFF:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 		result = __wimax_rf_toggle_radio(wimax_dev, state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 		if (result < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 			goto error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 		rfkill_set_sw_state(wimax_dev->rfkill, state == WIMAX_RF_OFF);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 	case WIMAX_RF_QUERY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) 		result = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 		goto error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) 	result = wimax_dev->rf_sw << 1 | wimax_dev->rf_hw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) error:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) error_not_ready:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) 	mutex_unlock(&wimax_dev->mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) 	d_fnend(3, dev, "(wimax_dev %p state %u) = %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 		wimax_dev, state, result);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 	return result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) EXPORT_SYMBOL(wimax_rfkill);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328)  * Register a new WiMAX device's RF Kill support
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330)  * WARNING: wimax_dev->mutex must be unlocked
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) int wimax_rfkill_add(struct wimax_dev *wimax_dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) 	int result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) 	struct rfkill *rfkill;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) 	struct device *dev = wimax_dev_to_dev(wimax_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) 	d_fnstart(3, dev, "(wimax_dev %p)\n", wimax_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) 	/* Initialize RF Kill */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) 	result = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) 	rfkill = rfkill_alloc(wimax_dev->name, dev, RFKILL_TYPE_WIMAX,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) 			      &wimax_rfkill_ops, wimax_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) 	if (rfkill == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) 		goto error_rfkill_allocate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) 	d_printf(1, dev, "rfkill %p\n", rfkill);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) 	wimax_dev->rfkill = rfkill;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) 	rfkill_init_sw_state(rfkill, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) 	result = rfkill_register(wimax_dev->rfkill);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) 	if (result < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) 		goto error_rfkill_register;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) 	/* If there is no SW toggle op, SW RFKill is always on */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) 	if (wimax_dev->op_rfkill_sw_toggle == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) 		wimax_dev->rf_sw = WIMAX_RF_ON;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) 	d_fnend(3, dev, "(wimax_dev %p) = 0\n", wimax_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) error_rfkill_register:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) 	rfkill_destroy(wimax_dev->rfkill);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) error_rfkill_allocate:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) 	d_fnend(3, dev, "(wimax_dev %p) = %d\n", wimax_dev, result);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) 	return result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371)  * Deregister a WiMAX device's RF Kill support
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373)  * Ick, we can't call rfkill_free() after rfkill_unregister()...oh
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374)  * well.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376)  * WARNING: wimax_dev->mutex must be unlocked
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) void wimax_rfkill_rm(struct wimax_dev *wimax_dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) 	struct device *dev = wimax_dev_to_dev(wimax_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) 	d_fnstart(3, dev, "(wimax_dev %p)\n", wimax_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) 	rfkill_unregister(wimax_dev->rfkill);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) 	rfkill_destroy(wimax_dev->rfkill);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) 	d_fnend(3, dev, "(wimax_dev %p)\n", wimax_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389)  * Exporting to user space over generic netlink
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391)  * Parse the rfkill command from user space, return a combination
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392)  * value that describe the states of the different toggles.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394)  * Only one attribute: the new state requested (on, off or no change,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395)  * just query).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) int wimax_gnl_doit_rfkill(struct sk_buff *skb, struct genl_info *info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) 	int result, ifindex;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) 	struct wimax_dev *wimax_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) 	struct device *dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) 	enum wimax_rf_state new_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) 	d_fnstart(3, NULL, "(skb %p info %p)\n", skb, info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) 	result = -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) 	if (info->attrs[WIMAX_GNL_RFKILL_IFIDX] == NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) 		pr_err("WIMAX_GNL_OP_RFKILL: can't find IFIDX attribute\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) 		goto error_no_wimax_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) 	ifindex = nla_get_u32(info->attrs[WIMAX_GNL_RFKILL_IFIDX]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) 	wimax_dev = wimax_dev_get_by_genl_info(info, ifindex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) 	if (wimax_dev == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) 		goto error_no_wimax_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) 	dev = wimax_dev_to_dev(wimax_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) 	result = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) 	if (info->attrs[WIMAX_GNL_RFKILL_STATE] == NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) 		dev_err(dev, "WIMAX_GNL_RFKILL: can't find RFKILL_STATE "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) 			"attribute\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) 		goto error_no_pid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) 	new_state = nla_get_u32(info->attrs[WIMAX_GNL_RFKILL_STATE]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) 	/* Execute the operation and send the result back to user space */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) 	result = wimax_rfkill(wimax_dev, new_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) error_no_pid:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) 	dev_put(wimax_dev->net_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) error_no_wimax_dev:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) 	d_fnend(3, NULL, "(skb %p info %p) = %d\n", skb, info, result);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) 	return result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) }