![Tejun Heo](/assets/img/avatar_default.png)
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>
221 lines
5 KiB
C
221 lines
5 KiB
C
/*
|
|
* Linux ARCnet driver - COM20020 chipset support
|
|
*
|
|
* Written 1997 by David Woodhouse.
|
|
* Written 1994-1999 by Avery Pennarun.
|
|
* Written 1999-2000 by Martin Mares <mj@ucw.cz>.
|
|
* Derived from skeleton.c by Donald Becker.
|
|
*
|
|
* Special thanks to Contemporary Controls, Inc. (www.ccontrols.com)
|
|
* for sponsoring the further development of this driver.
|
|
*
|
|
* **********************
|
|
*
|
|
* The original copyright of skeleton.c was as follows:
|
|
*
|
|
* skeleton.c Written 1993 by Donald Becker.
|
|
* Copyright 1993 United States Government as represented by the
|
|
* Director, National Security Agency. This software may only be used
|
|
* and distributed according to the terms of the GNU General Public License as
|
|
* modified by SRC, incorporated herein by reference.
|
|
*
|
|
* **********************
|
|
*
|
|
* For more details, see drivers/net/arcnet.c
|
|
*
|
|
* **********************
|
|
*/
|
|
#include <linux/module.h>
|
|
#include <linux/moduleparam.h>
|
|
#include <linux/kernel.h>
|
|
#include <linux/types.h>
|
|
#include <linux/ioport.h>
|
|
#include <linux/errno.h>
|
|
#include <linux/delay.h>
|
|
#include <linux/netdevice.h>
|
|
#include <linux/init.h>
|
|
#include <linux/bootmem.h>
|
|
#include <linux/arcdevice.h>
|
|
#include <linux/com20020.h>
|
|
|
|
#include <asm/io.h>
|
|
|
|
#define VERSION "arcnet: COM20020 ISA support (by David Woodhouse et al.)\n"
|
|
|
|
|
|
/*
|
|
* We cannot (yet) probe for an IO mapped card, although we can check that
|
|
* it's where we were told it was, and even do autoirq.
|
|
*/
|
|
static int __init com20020isa_probe(struct net_device *dev)
|
|
{
|
|
int ioaddr;
|
|
unsigned long airqmask;
|
|
struct arcnet_local *lp = netdev_priv(dev);
|
|
int err;
|
|
|
|
BUGLVL(D_NORMAL) printk(VERSION);
|
|
|
|
ioaddr = dev->base_addr;
|
|
if (!ioaddr) {
|
|
BUGMSG(D_NORMAL, "No autoprobe (yet) for IO mapped cards; you "
|
|
"must specify the base address!\n");
|
|
return -ENODEV;
|
|
}
|
|
if (!request_region(ioaddr, ARCNET_TOTAL_SIZE, "arcnet (COM20020)")) {
|
|
BUGMSG(D_NORMAL, "IO region %xh-%xh already allocated.\n",
|
|
ioaddr, ioaddr + ARCNET_TOTAL_SIZE - 1);
|
|
return -ENXIO;
|
|
}
|
|
if (ASTATUS() == 0xFF) {
|
|
BUGMSG(D_NORMAL, "IO address %x empty\n", ioaddr);
|
|
err = -ENODEV;
|
|
goto out;
|
|
}
|
|
if (com20020_check(dev)) {
|
|
err = -ENODEV;
|
|
goto out;
|
|
}
|
|
|
|
if (!dev->irq) {
|
|
/* if we do this, we're sure to get an IRQ since the
|
|
* card has just reset and the NORXflag is on until
|
|
* we tell it to start receiving.
|
|
*/
|
|
BUGMSG(D_INIT_REASONS, "intmask was %02Xh\n", inb(_INTMASK));
|
|
outb(0, _INTMASK);
|
|
airqmask = probe_irq_on();
|
|
outb(NORXflag, _INTMASK);
|
|
udelay(1);
|
|
outb(0, _INTMASK);
|
|
dev->irq = probe_irq_off(airqmask);
|
|
|
|
if (dev->irq <= 0) {
|
|
BUGMSG(D_INIT_REASONS, "Autoprobe IRQ failed first time\n");
|
|
airqmask = probe_irq_on();
|
|
outb(NORXflag, _INTMASK);
|
|
udelay(5);
|
|
outb(0, _INTMASK);
|
|
dev->irq = probe_irq_off(airqmask);
|
|
if (dev->irq <= 0) {
|
|
BUGMSG(D_NORMAL, "Autoprobe IRQ failed.\n");
|
|
err = -ENODEV;
|
|
goto out;
|
|
}
|
|
}
|
|
}
|
|
|
|
lp->card_name = "ISA COM20020";
|
|
if ((err = com20020_found(dev, 0)) != 0)
|
|
goto out;
|
|
|
|
return 0;
|
|
|
|
out:
|
|
release_region(ioaddr, ARCNET_TOTAL_SIZE);
|
|
return err;
|
|
}
|
|
|
|
static int node = 0;
|
|
static int io = 0x0; /* <--- EDIT THESE LINES FOR YOUR CONFIGURATION */
|
|
static int irq = 0; /* or use the insmod io= irq= shmem= options */
|
|
static char device[9]; /* use eg. device="arc1" to change name */
|
|
static int timeout = 3;
|
|
static int backplane = 0;
|
|
static int clockp = 0;
|
|
static int clockm = 0;
|
|
|
|
module_param(node, int, 0);
|
|
module_param(io, int, 0);
|
|
module_param(irq, int, 0);
|
|
module_param_string(device, device, sizeof(device), 0);
|
|
module_param(timeout, int, 0);
|
|
module_param(backplane, int, 0);
|
|
module_param(clockp, int, 0);
|
|
module_param(clockm, int, 0);
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
static struct net_device *my_dev;
|
|
|
|
static int __init com20020_init(void)
|
|
{
|
|
struct net_device *dev;
|
|
struct arcnet_local *lp;
|
|
|
|
dev = alloc_arcdev(device);
|
|
if (!dev)
|
|
return -ENOMEM;
|
|
|
|
if (node && node != 0xff)
|
|
dev->dev_addr[0] = node;
|
|
|
|
dev->netdev_ops = &com20020_netdev_ops;
|
|
|
|
lp = netdev_priv(dev);
|
|
lp->backplane = backplane;
|
|
lp->clockp = clockp & 7;
|
|
lp->clockm = clockm & 3;
|
|
lp->timeout = timeout & 3;
|
|
lp->hw.owner = THIS_MODULE;
|
|
|
|
dev->base_addr = io;
|
|
dev->irq = irq;
|
|
|
|
if (dev->irq == 2)
|
|
dev->irq = 9;
|
|
|
|
if (com20020isa_probe(dev)) {
|
|
free_netdev(dev);
|
|
return -EIO;
|
|
}
|
|
|
|
my_dev = dev;
|
|
return 0;
|
|
}
|
|
|
|
static void __exit com20020_exit(void)
|
|
{
|
|
unregister_netdev(my_dev);
|
|
free_irq(my_dev->irq, my_dev);
|
|
release_region(my_dev->base_addr, ARCNET_TOTAL_SIZE);
|
|
free_netdev(my_dev);
|
|
}
|
|
|
|
#ifndef MODULE
|
|
static int __init com20020isa_setup(char *s)
|
|
{
|
|
int ints[8];
|
|
|
|
s = get_options(s, 8, ints);
|
|
if (!ints[0])
|
|
return 1;
|
|
|
|
switch (ints[0]) {
|
|
default: /* ERROR */
|
|
printk("com90xx: Too many arguments.\n");
|
|
case 6: /* Timeout */
|
|
timeout = ints[6];
|
|
case 5: /* CKP value */
|
|
clockp = ints[5];
|
|
case 4: /* Backplane flag */
|
|
backplane = ints[4];
|
|
case 3: /* Node ID */
|
|
node = ints[3];
|
|
case 2: /* IRQ */
|
|
irq = ints[2];
|
|
case 1: /* IO address */
|
|
io = ints[1];
|
|
}
|
|
if (*s)
|
|
snprintf(device, sizeof(device), "%s", s);
|
|
return 1;
|
|
}
|
|
|
|
__setup("com20020=", com20020isa_setup);
|
|
|
|
#endif /* MODULE */
|
|
|
|
module_init(com20020_init)
|
|
module_exit(com20020_exit)
|