mirror of
https://github.com/FEX-Emu/linux.git
synced 2024-12-24 18:38:38 +00: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>
406 lines
9.3 KiB
C
406 lines
9.3 KiB
C
/*
|
|
*
|
|
* Author Karsten Keil <kkeil@novell.com>
|
|
*
|
|
* Copyright 2008 by Karsten Keil <kkeil@novell.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.
|
|
*
|
|
*/
|
|
|
|
|
|
#include <linux/slab.h>
|
|
#include <linux/module.h>
|
|
#include <linux/mISDNhw.h>
|
|
#include "core.h"
|
|
#include "layer1.h"
|
|
#include "fsm.h"
|
|
|
|
static u_int *debug;
|
|
|
|
struct layer1 {
|
|
u_long Flags;
|
|
struct FsmInst l1m;
|
|
struct FsmTimer timer;
|
|
int delay;
|
|
struct dchannel *dch;
|
|
dchannel_l1callback *dcb;
|
|
};
|
|
|
|
#define TIMER3_VALUE 7000
|
|
|
|
static
|
|
struct Fsm l1fsm_s = {NULL, 0, 0, NULL, NULL};
|
|
|
|
enum {
|
|
ST_L1_F2,
|
|
ST_L1_F3,
|
|
ST_L1_F4,
|
|
ST_L1_F5,
|
|
ST_L1_F6,
|
|
ST_L1_F7,
|
|
ST_L1_F8,
|
|
};
|
|
|
|
#define L1S_STATE_COUNT (ST_L1_F8+1)
|
|
|
|
static char *strL1SState[] =
|
|
{
|
|
"ST_L1_F2",
|
|
"ST_L1_F3",
|
|
"ST_L1_F4",
|
|
"ST_L1_F5",
|
|
"ST_L1_F6",
|
|
"ST_L1_F7",
|
|
"ST_L1_F8",
|
|
};
|
|
|
|
enum {
|
|
EV_PH_ACTIVATE,
|
|
EV_PH_DEACTIVATE,
|
|
EV_RESET_IND,
|
|
EV_DEACT_CNF,
|
|
EV_DEACT_IND,
|
|
EV_POWER_UP,
|
|
EV_ANYSIG_IND,
|
|
EV_INFO2_IND,
|
|
EV_INFO4_IND,
|
|
EV_TIMER_DEACT,
|
|
EV_TIMER_ACT,
|
|
EV_TIMER3,
|
|
};
|
|
|
|
#define L1_EVENT_COUNT (EV_TIMER3 + 1)
|
|
|
|
static char *strL1Event[] =
|
|
{
|
|
"EV_PH_ACTIVATE",
|
|
"EV_PH_DEACTIVATE",
|
|
"EV_RESET_IND",
|
|
"EV_DEACT_CNF",
|
|
"EV_DEACT_IND",
|
|
"EV_POWER_UP",
|
|
"EV_ANYSIG_IND",
|
|
"EV_INFO2_IND",
|
|
"EV_INFO4_IND",
|
|
"EV_TIMER_DEACT",
|
|
"EV_TIMER_ACT",
|
|
"EV_TIMER3",
|
|
};
|
|
|
|
static void
|
|
l1m_debug(struct FsmInst *fi, char *fmt, ...)
|
|
{
|
|
struct layer1 *l1 = fi->userdata;
|
|
va_list va;
|
|
|
|
va_start(va, fmt);
|
|
printk(KERN_DEBUG "%s: ", dev_name(&l1->dch->dev.dev));
|
|
vprintk(fmt, va);
|
|
printk("\n");
|
|
va_end(va);
|
|
}
|
|
|
|
static void
|
|
l1_reset(struct FsmInst *fi, int event, void *arg)
|
|
{
|
|
mISDN_FsmChangeState(fi, ST_L1_F3);
|
|
}
|
|
|
|
static void
|
|
l1_deact_cnf(struct FsmInst *fi, int event, void *arg)
|
|
{
|
|
struct layer1 *l1 = fi->userdata;
|
|
|
|
mISDN_FsmChangeState(fi, ST_L1_F3);
|
|
if (test_bit(FLG_L1_ACTIVATING, &l1->Flags))
|
|
l1->dcb(l1->dch, HW_POWERUP_REQ);
|
|
}
|
|
|
|
static void
|
|
l1_deact_req_s(struct FsmInst *fi, int event, void *arg)
|
|
{
|
|
struct layer1 *l1 = fi->userdata;
|
|
|
|
mISDN_FsmChangeState(fi, ST_L1_F3);
|
|
mISDN_FsmRestartTimer(&l1->timer, 550, EV_TIMER_DEACT, NULL, 2);
|
|
test_and_set_bit(FLG_L1_DEACTTIMER, &l1->Flags);
|
|
}
|
|
|
|
static void
|
|
l1_power_up_s(struct FsmInst *fi, int event, void *arg)
|
|
{
|
|
struct layer1 *l1 = fi->userdata;
|
|
|
|
if (test_bit(FLG_L1_ACTIVATING, &l1->Flags)) {
|
|
mISDN_FsmChangeState(fi, ST_L1_F4);
|
|
l1->dcb(l1->dch, INFO3_P8);
|
|
} else
|
|
mISDN_FsmChangeState(fi, ST_L1_F3);
|
|
}
|
|
|
|
static void
|
|
l1_go_F5(struct FsmInst *fi, int event, void *arg)
|
|
{
|
|
mISDN_FsmChangeState(fi, ST_L1_F5);
|
|
}
|
|
|
|
static void
|
|
l1_go_F8(struct FsmInst *fi, int event, void *arg)
|
|
{
|
|
mISDN_FsmChangeState(fi, ST_L1_F8);
|
|
}
|
|
|
|
static void
|
|
l1_info2_ind(struct FsmInst *fi, int event, void *arg)
|
|
{
|
|
struct layer1 *l1 = fi->userdata;
|
|
|
|
mISDN_FsmChangeState(fi, ST_L1_F6);
|
|
l1->dcb(l1->dch, INFO3_P8);
|
|
}
|
|
|
|
static void
|
|
l1_info4_ind(struct FsmInst *fi, int event, void *arg)
|
|
{
|
|
struct layer1 *l1 = fi->userdata;
|
|
|
|
mISDN_FsmChangeState(fi, ST_L1_F7);
|
|
l1->dcb(l1->dch, INFO3_P8);
|
|
if (test_and_clear_bit(FLG_L1_DEACTTIMER, &l1->Flags))
|
|
mISDN_FsmDelTimer(&l1->timer, 4);
|
|
if (!test_bit(FLG_L1_ACTIVATED, &l1->Flags)) {
|
|
if (test_and_clear_bit(FLG_L1_T3RUN, &l1->Flags))
|
|
mISDN_FsmDelTimer(&l1->timer, 3);
|
|
mISDN_FsmRestartTimer(&l1->timer, 110, EV_TIMER_ACT, NULL, 2);
|
|
test_and_set_bit(FLG_L1_ACTTIMER, &l1->Flags);
|
|
}
|
|
}
|
|
|
|
static void
|
|
l1_timer3(struct FsmInst *fi, int event, void *arg)
|
|
{
|
|
struct layer1 *l1 = fi->userdata;
|
|
|
|
test_and_clear_bit(FLG_L1_T3RUN, &l1->Flags);
|
|
if (test_and_clear_bit(FLG_L1_ACTIVATING, &l1->Flags)) {
|
|
if (test_and_clear_bit(FLG_L1_DBLOCKED, &l1->Flags))
|
|
l1->dcb(l1->dch, HW_D_NOBLOCKED);
|
|
l1->dcb(l1->dch, PH_DEACTIVATE_IND);
|
|
}
|
|
if (l1->l1m.state != ST_L1_F6) {
|
|
mISDN_FsmChangeState(fi, ST_L1_F3);
|
|
l1->dcb(l1->dch, HW_POWERUP_REQ);
|
|
}
|
|
}
|
|
|
|
static void
|
|
l1_timer_act(struct FsmInst *fi, int event, void *arg)
|
|
{
|
|
struct layer1 *l1 = fi->userdata;
|
|
|
|
test_and_clear_bit(FLG_L1_ACTTIMER, &l1->Flags);
|
|
test_and_set_bit(FLG_L1_ACTIVATED, &l1->Flags);
|
|
l1->dcb(l1->dch, PH_ACTIVATE_IND);
|
|
}
|
|
|
|
static void
|
|
l1_timer_deact(struct FsmInst *fi, int event, void *arg)
|
|
{
|
|
struct layer1 *l1 = fi->userdata;
|
|
|
|
test_and_clear_bit(FLG_L1_DEACTTIMER, &l1->Flags);
|
|
test_and_clear_bit(FLG_L1_ACTIVATED, &l1->Flags);
|
|
if (test_and_clear_bit(FLG_L1_DBLOCKED, &l1->Flags))
|
|
l1->dcb(l1->dch, HW_D_NOBLOCKED);
|
|
l1->dcb(l1->dch, PH_DEACTIVATE_IND);
|
|
l1->dcb(l1->dch, HW_DEACT_REQ);
|
|
}
|
|
|
|
static void
|
|
l1_activate_s(struct FsmInst *fi, int event, void *arg)
|
|
{
|
|
struct layer1 *l1 = fi->userdata;
|
|
|
|
mISDN_FsmRestartTimer(&l1->timer, TIMER3_VALUE, EV_TIMER3, NULL, 2);
|
|
test_and_set_bit(FLG_L1_T3RUN, &l1->Flags);
|
|
l1->dcb(l1->dch, HW_RESET_REQ);
|
|
}
|
|
|
|
static void
|
|
l1_activate_no(struct FsmInst *fi, int event, void *arg)
|
|
{
|
|
struct layer1 *l1 = fi->userdata;
|
|
|
|
if ((!test_bit(FLG_L1_DEACTTIMER, &l1->Flags)) &&
|
|
(!test_bit(FLG_L1_T3RUN, &l1->Flags))) {
|
|
test_and_clear_bit(FLG_L1_ACTIVATING, &l1->Flags);
|
|
if (test_and_clear_bit(FLG_L1_DBLOCKED, &l1->Flags))
|
|
l1->dcb(l1->dch, HW_D_NOBLOCKED);
|
|
l1->dcb(l1->dch, PH_DEACTIVATE_IND);
|
|
}
|
|
}
|
|
|
|
static struct FsmNode L1SFnList[] =
|
|
{
|
|
{ST_L1_F3, EV_PH_ACTIVATE, l1_activate_s},
|
|
{ST_L1_F6, EV_PH_ACTIVATE, l1_activate_no},
|
|
{ST_L1_F8, EV_PH_ACTIVATE, l1_activate_no},
|
|
{ST_L1_F3, EV_RESET_IND, l1_reset},
|
|
{ST_L1_F4, EV_RESET_IND, l1_reset},
|
|
{ST_L1_F5, EV_RESET_IND, l1_reset},
|
|
{ST_L1_F6, EV_RESET_IND, l1_reset},
|
|
{ST_L1_F7, EV_RESET_IND, l1_reset},
|
|
{ST_L1_F8, EV_RESET_IND, l1_reset},
|
|
{ST_L1_F3, EV_DEACT_CNF, l1_deact_cnf},
|
|
{ST_L1_F4, EV_DEACT_CNF, l1_deact_cnf},
|
|
{ST_L1_F5, EV_DEACT_CNF, l1_deact_cnf},
|
|
{ST_L1_F6, EV_DEACT_CNF, l1_deact_cnf},
|
|
{ST_L1_F7, EV_DEACT_CNF, l1_deact_cnf},
|
|
{ST_L1_F8, EV_DEACT_CNF, l1_deact_cnf},
|
|
{ST_L1_F6, EV_DEACT_IND, l1_deact_req_s},
|
|
{ST_L1_F7, EV_DEACT_IND, l1_deact_req_s},
|
|
{ST_L1_F8, EV_DEACT_IND, l1_deact_req_s},
|
|
{ST_L1_F3, EV_POWER_UP, l1_power_up_s},
|
|
{ST_L1_F4, EV_ANYSIG_IND, l1_go_F5},
|
|
{ST_L1_F6, EV_ANYSIG_IND, l1_go_F8},
|
|
{ST_L1_F7, EV_ANYSIG_IND, l1_go_F8},
|
|
{ST_L1_F3, EV_INFO2_IND, l1_info2_ind},
|
|
{ST_L1_F4, EV_INFO2_IND, l1_info2_ind},
|
|
{ST_L1_F5, EV_INFO2_IND, l1_info2_ind},
|
|
{ST_L1_F7, EV_INFO2_IND, l1_info2_ind},
|
|
{ST_L1_F8, EV_INFO2_IND, l1_info2_ind},
|
|
{ST_L1_F3, EV_INFO4_IND, l1_info4_ind},
|
|
{ST_L1_F4, EV_INFO4_IND, l1_info4_ind},
|
|
{ST_L1_F5, EV_INFO4_IND, l1_info4_ind},
|
|
{ST_L1_F6, EV_INFO4_IND, l1_info4_ind},
|
|
{ST_L1_F8, EV_INFO4_IND, l1_info4_ind},
|
|
{ST_L1_F3, EV_TIMER3, l1_timer3},
|
|
{ST_L1_F4, EV_TIMER3, l1_timer3},
|
|
{ST_L1_F5, EV_TIMER3, l1_timer3},
|
|
{ST_L1_F6, EV_TIMER3, l1_timer3},
|
|
{ST_L1_F8, EV_TIMER3, l1_timer3},
|
|
{ST_L1_F7, EV_TIMER_ACT, l1_timer_act},
|
|
{ST_L1_F3, EV_TIMER_DEACT, l1_timer_deact},
|
|
{ST_L1_F4, EV_TIMER_DEACT, l1_timer_deact},
|
|
{ST_L1_F5, EV_TIMER_DEACT, l1_timer_deact},
|
|
{ST_L1_F6, EV_TIMER_DEACT, l1_timer_deact},
|
|
{ST_L1_F7, EV_TIMER_DEACT, l1_timer_deact},
|
|
{ST_L1_F8, EV_TIMER_DEACT, l1_timer_deact},
|
|
};
|
|
|
|
static void
|
|
release_l1(struct layer1 *l1) {
|
|
mISDN_FsmDelTimer(&l1->timer, 0);
|
|
if (l1->dch)
|
|
l1->dch->l1 = NULL;
|
|
module_put(THIS_MODULE);
|
|
kfree(l1);
|
|
}
|
|
|
|
int
|
|
l1_event(struct layer1 *l1, u_int event)
|
|
{
|
|
int err = 0;
|
|
|
|
if (!l1)
|
|
return -EINVAL;
|
|
switch (event) {
|
|
case HW_RESET_IND:
|
|
mISDN_FsmEvent(&l1->l1m, EV_RESET_IND, NULL);
|
|
break;
|
|
case HW_DEACT_IND:
|
|
mISDN_FsmEvent(&l1->l1m, EV_DEACT_IND, NULL);
|
|
break;
|
|
case HW_POWERUP_IND:
|
|
mISDN_FsmEvent(&l1->l1m, EV_POWER_UP, NULL);
|
|
break;
|
|
case HW_DEACT_CNF:
|
|
mISDN_FsmEvent(&l1->l1m, EV_DEACT_CNF, NULL);
|
|
break;
|
|
case ANYSIGNAL:
|
|
mISDN_FsmEvent(&l1->l1m, EV_ANYSIG_IND, NULL);
|
|
break;
|
|
case LOSTFRAMING:
|
|
mISDN_FsmEvent(&l1->l1m, EV_ANYSIG_IND, NULL);
|
|
break;
|
|
case INFO2:
|
|
mISDN_FsmEvent(&l1->l1m, EV_INFO2_IND, NULL);
|
|
break;
|
|
case INFO4_P8:
|
|
mISDN_FsmEvent(&l1->l1m, EV_INFO4_IND, NULL);
|
|
break;
|
|
case INFO4_P10:
|
|
mISDN_FsmEvent(&l1->l1m, EV_INFO4_IND, NULL);
|
|
break;
|
|
case PH_ACTIVATE_REQ:
|
|
if (test_bit(FLG_L1_ACTIVATED, &l1->Flags))
|
|
l1->dcb(l1->dch, PH_ACTIVATE_IND);
|
|
else {
|
|
test_and_set_bit(FLG_L1_ACTIVATING, &l1->Flags);
|
|
mISDN_FsmEvent(&l1->l1m, EV_PH_ACTIVATE, NULL);
|
|
}
|
|
break;
|
|
case CLOSE_CHANNEL:
|
|
release_l1(l1);
|
|
break;
|
|
default:
|
|
if (*debug & DEBUG_L1)
|
|
printk(KERN_DEBUG "%s %x unhandled\n",
|
|
__func__, event);
|
|
err = -EINVAL;
|
|
}
|
|
return err;
|
|
}
|
|
EXPORT_SYMBOL(l1_event);
|
|
|
|
int
|
|
create_l1(struct dchannel *dch, dchannel_l1callback *dcb) {
|
|
struct layer1 *nl1;
|
|
|
|
nl1 = kzalloc(sizeof(struct layer1), GFP_ATOMIC);
|
|
if (!nl1) {
|
|
printk(KERN_ERR "kmalloc struct layer1 failed\n");
|
|
return -ENOMEM;
|
|
}
|
|
nl1->l1m.fsm = &l1fsm_s;
|
|
nl1->l1m.state = ST_L1_F3;
|
|
nl1->Flags = 0;
|
|
nl1->l1m.debug = *debug & DEBUG_L1_FSM;
|
|
nl1->l1m.userdata = nl1;
|
|
nl1->l1m.userint = 0;
|
|
nl1->l1m.printdebug = l1m_debug;
|
|
nl1->dch = dch;
|
|
nl1->dcb = dcb;
|
|
mISDN_FsmInitTimer(&nl1->l1m, &nl1->timer);
|
|
__module_get(THIS_MODULE);
|
|
dch->l1 = nl1;
|
|
return 0;
|
|
}
|
|
EXPORT_SYMBOL(create_l1);
|
|
|
|
int
|
|
l1_init(u_int *deb)
|
|
{
|
|
debug = deb;
|
|
l1fsm_s.state_count = L1S_STATE_COUNT;
|
|
l1fsm_s.event_count = L1_EVENT_COUNT;
|
|
l1fsm_s.strEvent = strL1Event;
|
|
l1fsm_s.strState = strL1SState;
|
|
mISDN_FsmNew(&l1fsm_s, L1SFnList, ARRAY_SIZE(L1SFnList));
|
|
return 0;
|
|
}
|
|
|
|
void
|
|
l1_cleanup(void)
|
|
{
|
|
mISDN_FsmFree(&l1fsm_s);
|
|
}
|