mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-12 08:56:47 +07:00
5a0e3ad6af
percpu.h is included by sched.h and module.h and thus ends up being included when building most .c files. percpu.h includes slab.h which in turn includes gfp.h making everything defined by the two files universally available and complicating inclusion dependencies. percpu.h -> slab.h dependency is about to be removed. Prepare for this change by updating users of gfp and slab facilities include those headers directly instead of assuming availability. As this conversion needs to touch large number of source files, the following script is used as the basis of conversion. http://userweb.kernel.org/~tj/misc/slabh-sweep.py The script does the followings. * Scan files for gfp and slab usages and update includes such that only the necessary includes are there. ie. if only gfp is used, gfp.h, if slab is used, slab.h. * When the script inserts a new include, it looks at the include blocks and try to put the new include such that its order conforms to its surrounding. It's put in the include block which contains core kernel includes, in the same order that the rest are ordered - alphabetical, Christmas tree, rev-Xmas-tree or at the end if there doesn't seem to be any matching order. * If the script can't find a place to put a new include (mostly because the file doesn't have fitting include block), it prints out an error message indicating which .h file needs to be added to the file. The conversion was done in the following steps. 1. The initial automatic conversion of all .c files updated slightly over 4000 files, deleting around 700 includes and adding ~480 gfp.h and ~3000 slab.h inclusions. The script emitted errors for ~400 files. 2. Each error was manually checked. Some didn't need the inclusion, some needed manual addition while adding it to implementation .h or embedding .c file was more appropriate for others. This step added inclusions to around 150 files. 3. The script was run again and the output was compared to the edits from #2 to make sure no file was left behind. 4. Several build tests were done and a couple of problems were fixed. e.g. lib/decompress_*.c used malloc/free() wrappers around slab APIs requiring slab.h to be added manually. 5. The script was run on all .h files but without automatically editing them as sprinkling gfp.h and slab.h inclusions around .h files could easily lead to inclusion dependency hell. Most gfp.h inclusion directives were ignored as stuff from gfp.h was usually wildly available and often used in preprocessor macros. Each slab.h inclusion directive was examined and added manually as necessary. 6. percpu.h was updated not to include slab.h. 7. Build test were done on the following configurations and failures were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my distributed build env didn't work with gcov compiles) and a few more options had to be turned off depending on archs to make things build (like ipr on powerpc/64 which failed due to missing writeq). * x86 and x86_64 UP and SMP allmodconfig and a custom test config. * powerpc and powerpc64 SMP allmodconfig * sparc and sparc64 SMP allmodconfig * ia64 SMP allmodconfig * s390 SMP allmodconfig * alpha SMP allmodconfig * um on x86_64 SMP allmodconfig 8. percpu.h modifications were reverted so that it could be applied as a separate patch and serve as bisection point. Given the fact that I had only a couple of failures from tests on step 6, I'm fairly confident about the coverage of this conversion patch. If there is a breakage, it's likely to be something in one of the arch headers which should be easily discoverable easily on most builds of the specific arch. Signed-off-by: Tejun Heo <tj@kernel.org> Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org> Cc: Ingo Molnar <mingo@redhat.com> Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
211 lines
6.4 KiB
C
211 lines
6.4 KiB
C
/*
|
|
* Intel Wireless WiMAX Connection 2400m
|
|
* Implement backend for the WiMAX stack rfkill support
|
|
*
|
|
*
|
|
* Copyright (C) 2007-2008 Intel Corporation <linux-wimax@intel.com>
|
|
* Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public License version
|
|
* 2 as published by the Free Software Foundation.
|
|
*
|
|
* 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., 51 Franklin Street, Fifth Floor, Boston, MA
|
|
* 02110-1301, USA.
|
|
*
|
|
*
|
|
* The WiMAX kernel stack integrates into RF-Kill and keeps the
|
|
* switches's status. We just need to:
|
|
*
|
|
* - report changes in the HW RF Kill switch [with
|
|
* wimax_rfkill_{sw,hw}_report(), which happens when we detect those
|
|
* indications coming through hardware reports]. We also do it on
|
|
* initialization to let the stack know the intial HW state.
|
|
*
|
|
* - implement indications from the stack to change the SW RF Kill
|
|
* switch (coming from sysfs, the wimax stack or user space).
|
|
*/
|
|
#include "i2400m.h"
|
|
#include <linux/wimax/i2400m.h>
|
|
#include <linux/slab.h>
|
|
|
|
|
|
|
|
#define D_SUBMODULE rfkill
|
|
#include "debug-levels.h"
|
|
|
|
/*
|
|
* Return true if the i2400m radio is in the requested wimax_rf_state state
|
|
*
|
|
*/
|
|
static
|
|
int i2400m_radio_is(struct i2400m *i2400m, enum wimax_rf_state state)
|
|
{
|
|
if (state == WIMAX_RF_OFF)
|
|
return i2400m->state == I2400M_SS_RF_OFF
|
|
|| i2400m->state == I2400M_SS_RF_SHUTDOWN;
|
|
else if (state == WIMAX_RF_ON)
|
|
/* state == WIMAX_RF_ON */
|
|
return i2400m->state != I2400M_SS_RF_OFF
|
|
&& i2400m->state != I2400M_SS_RF_SHUTDOWN;
|
|
else {
|
|
BUG();
|
|
return -EINVAL; /* shut gcc warnings on certain arches */
|
|
}
|
|
}
|
|
|
|
|
|
/*
|
|
* WiMAX stack operation: implement SW RFKill toggling
|
|
*
|
|
* @wimax_dev: device descriptor
|
|
* @skb: skb where the message has been received; skb->data is
|
|
* expected to point to the message payload.
|
|
* @genl_info: passed by the generic netlink layer
|
|
*
|
|
* Generic Netlink will call this function when a message is sent from
|
|
* userspace to change the software RF-Kill switch status.
|
|
*
|
|
* This function will set the device's sofware RF-Kill switch state to
|
|
* match what is requested.
|
|
*
|
|
* NOTE: the i2400m has a strict state machine; we can only set the
|
|
* RF-Kill switch when it is on, the HW RF-Kill is on and the
|
|
* device is initialized. So we ignore errors steaming from not
|
|
* being in the right state (-EILSEQ).
|
|
*/
|
|
int i2400m_op_rfkill_sw_toggle(struct wimax_dev *wimax_dev,
|
|
enum wimax_rf_state state)
|
|
{
|
|
int result;
|
|
struct i2400m *i2400m = wimax_dev_to_i2400m(wimax_dev);
|
|
struct device *dev = i2400m_dev(i2400m);
|
|
struct sk_buff *ack_skb;
|
|
struct {
|
|
struct i2400m_l3l4_hdr hdr;
|
|
struct i2400m_tlv_rf_operation sw_rf;
|
|
} __attribute__((packed)) *cmd;
|
|
char strerr[32];
|
|
|
|
d_fnstart(4, dev, "(wimax_dev %p state %d)\n", wimax_dev, state);
|
|
|
|
result = -ENOMEM;
|
|
cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
|
|
if (cmd == NULL)
|
|
goto error_alloc;
|
|
cmd->hdr.type = cpu_to_le16(I2400M_MT_CMD_RF_CONTROL);
|
|
cmd->hdr.length = sizeof(cmd->sw_rf);
|
|
cmd->hdr.version = cpu_to_le16(I2400M_L3L4_VERSION);
|
|
cmd->sw_rf.hdr.type = cpu_to_le16(I2400M_TLV_RF_OPERATION);
|
|
cmd->sw_rf.hdr.length = cpu_to_le16(sizeof(cmd->sw_rf.status));
|
|
switch (state) {
|
|
case WIMAX_RF_OFF: /* RFKILL ON, radio OFF */
|
|
cmd->sw_rf.status = cpu_to_le32(2);
|
|
break;
|
|
case WIMAX_RF_ON: /* RFKILL OFF, radio ON */
|
|
cmd->sw_rf.status = cpu_to_le32(1);
|
|
break;
|
|
default:
|
|
BUG();
|
|
}
|
|
|
|
ack_skb = i2400m_msg_to_dev(i2400m, cmd, sizeof(*cmd));
|
|
result = PTR_ERR(ack_skb);
|
|
if (IS_ERR(ack_skb)) {
|
|
dev_err(dev, "Failed to issue 'RF Control' command: %d\n",
|
|
result);
|
|
goto error_msg_to_dev;
|
|
}
|
|
result = i2400m_msg_check_status(wimax_msg_data(ack_skb),
|
|
strerr, sizeof(strerr));
|
|
if (result < 0) {
|
|
dev_err(dev, "'RF Control' (0x%04x) command failed: %d - %s\n",
|
|
I2400M_MT_CMD_RF_CONTROL, result, strerr);
|
|
goto error_cmd;
|
|
}
|
|
|
|
/* Now we wait for the state to change to RADIO_OFF or RADIO_ON */
|
|
result = wait_event_timeout(
|
|
i2400m->state_wq, i2400m_radio_is(i2400m, state),
|
|
5 * HZ);
|
|
if (result == 0)
|
|
result = -ETIMEDOUT;
|
|
if (result < 0)
|
|
dev_err(dev, "Error waiting for device to toggle RF state: "
|
|
"%d\n", result);
|
|
result = 0;
|
|
error_cmd:
|
|
kfree_skb(ack_skb);
|
|
error_msg_to_dev:
|
|
error_alloc:
|
|
d_fnend(4, dev, "(wimax_dev %p state %d) = %d\n",
|
|
wimax_dev, state, result);
|
|
return result;
|
|
}
|
|
|
|
|
|
/*
|
|
* Inform the WiMAX stack of changes in the RF Kill switches reported
|
|
* by the device
|
|
*
|
|
* @i2400m: device descriptor
|
|
* @rfss: TLV for RF Switches status; already validated
|
|
*
|
|
* NOTE: the reports on RF switch status cannot be trusted
|
|
* or used until the device is in a state of RADIO_OFF
|
|
* or greater.
|
|
*/
|
|
void i2400m_report_tlv_rf_switches_status(
|
|
struct i2400m *i2400m,
|
|
const struct i2400m_tlv_rf_switches_status *rfss)
|
|
{
|
|
struct device *dev = i2400m_dev(i2400m);
|
|
enum i2400m_rf_switch_status hw, sw;
|
|
enum wimax_st wimax_state;
|
|
|
|
sw = le32_to_cpu(rfss->sw_rf_switch);
|
|
hw = le32_to_cpu(rfss->hw_rf_switch);
|
|
|
|
d_fnstart(3, dev, "(i2400m %p rfss %p [hw %u sw %u])\n",
|
|
i2400m, rfss, hw, sw);
|
|
/* We only process rw switch evens when the device has been
|
|
* fully initialized */
|
|
wimax_state = wimax_state_get(&i2400m->wimax_dev);
|
|
if (wimax_state < WIMAX_ST_RADIO_OFF) {
|
|
d_printf(3, dev, "ignoring RF switches report, state %u\n",
|
|
wimax_state);
|
|
goto out;
|
|
}
|
|
switch (sw) {
|
|
case I2400M_RF_SWITCH_ON: /* RF Kill disabled (radio on) */
|
|
wimax_report_rfkill_sw(&i2400m->wimax_dev, WIMAX_RF_ON);
|
|
break;
|
|
case I2400M_RF_SWITCH_OFF: /* RF Kill enabled (radio off) */
|
|
wimax_report_rfkill_sw(&i2400m->wimax_dev, WIMAX_RF_OFF);
|
|
break;
|
|
default:
|
|
dev_err(dev, "HW BUG? Unknown RF SW state 0x%x\n", sw);
|
|
}
|
|
|
|
switch (hw) {
|
|
case I2400M_RF_SWITCH_ON: /* RF Kill disabled (radio on) */
|
|
wimax_report_rfkill_hw(&i2400m->wimax_dev, WIMAX_RF_ON);
|
|
break;
|
|
case I2400M_RF_SWITCH_OFF: /* RF Kill enabled (radio off) */
|
|
wimax_report_rfkill_hw(&i2400m->wimax_dev, WIMAX_RF_OFF);
|
|
break;
|
|
default:
|
|
dev_err(dev, "HW BUG? Unknown RF HW state 0x%x\n", hw);
|
|
}
|
|
out:
|
|
d_fnend(3, dev, "(i2400m %p rfss %p [hw %u sw %u]) = void\n",
|
|
i2400m, rfss, hw, sw);
|
|
}
|