mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-29 22:14:41 +08:00
cd354f1ae7
After Al Viro (finally) succeeded in removing the sched.h #include in module.h recently, it makes sense again to remove other superfluous sched.h includes. There are quite a lot of files which include it but don't actually need anything defined in there. Presumably these includes were once needed for macros that used to live in sched.h, but moved to other header files in the course of cleaning it up. To ease the pain, this time I did not fiddle with any header files and only removed #includes from .c-files, which tend to cause less trouble. Compile tested against 2.6.20-rc2 and 2.6.20-rc2-mm2 (with offsets) on alpha, arm, i386, ia64, mips, powerpc, and x86_64 with allnoconfig, defconfig, allmodconfig, and allyesconfig as well as a few randconfigs on x86_64 and all configs in arch/arm/configs on arm. I also checked that no new warnings were introduced by the patch (actually, some warnings are removed that were emitted by unnecessarily included header files). Signed-off-by: Tim Schmielau <tim@physik3.uni-rostock.de> Acked-by: Russell King <rmk+kernel@arm.linux.org.uk> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
205 lines
4.8 KiB
C
205 lines
4.8 KiB
C
/*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* Copyright (C) Jonathan Naylor G4KLX (g4klx@g4klx.demon.co.uk)
|
|
*/
|
|
#include <linux/errno.h>
|
|
#include <linux/types.h>
|
|
#include <linux/socket.h>
|
|
#include <linux/in.h>
|
|
#include <linux/kernel.h>
|
|
#include <linux/timer.h>
|
|
#include <linux/string.h>
|
|
#include <linux/sockios.h>
|
|
#include <linux/net.h>
|
|
#include <linux/spinlock.h>
|
|
#include <net/ax25.h>
|
|
#include <linux/inet.h>
|
|
#include <linux/netdevice.h>
|
|
#include <linux/if_arp.h>
|
|
#include <linux/skbuff.h>
|
|
#include <net/sock.h>
|
|
#include <asm/uaccess.h>
|
|
#include <asm/system.h>
|
|
#include <linux/fcntl.h>
|
|
#include <linux/mm.h>
|
|
#include <linux/interrupt.h>
|
|
#include <linux/init.h>
|
|
|
|
ax25_dev *ax25_dev_list;
|
|
DEFINE_SPINLOCK(ax25_dev_lock);
|
|
|
|
ax25_dev *ax25_addr_ax25dev(ax25_address *addr)
|
|
{
|
|
ax25_dev *ax25_dev, *res = NULL;
|
|
|
|
spin_lock_bh(&ax25_dev_lock);
|
|
for (ax25_dev = ax25_dev_list; ax25_dev != NULL; ax25_dev = ax25_dev->next)
|
|
if (ax25cmp(addr, (ax25_address *)ax25_dev->dev->dev_addr) == 0) {
|
|
res = ax25_dev;
|
|
}
|
|
spin_unlock_bh(&ax25_dev_lock);
|
|
|
|
return res;
|
|
}
|
|
|
|
/*
|
|
* This is called when an interface is brought up. These are
|
|
* reasonable defaults.
|
|
*/
|
|
void ax25_dev_device_up(struct net_device *dev)
|
|
{
|
|
ax25_dev *ax25_dev;
|
|
|
|
if ((ax25_dev = kzalloc(sizeof(*ax25_dev), GFP_ATOMIC)) == NULL) {
|
|
printk(KERN_ERR "AX.25: ax25_dev_device_up - out of memory\n");
|
|
return;
|
|
}
|
|
|
|
ax25_unregister_sysctl();
|
|
|
|
dev->ax25_ptr = ax25_dev;
|
|
ax25_dev->dev = dev;
|
|
dev_hold(dev);
|
|
ax25_dev->forward = NULL;
|
|
|
|
ax25_dev->values[AX25_VALUES_IPDEFMODE] = AX25_DEF_IPDEFMODE;
|
|
ax25_dev->values[AX25_VALUES_AXDEFMODE] = AX25_DEF_AXDEFMODE;
|
|
ax25_dev->values[AX25_VALUES_BACKOFF] = AX25_DEF_BACKOFF;
|
|
ax25_dev->values[AX25_VALUES_CONMODE] = AX25_DEF_CONMODE;
|
|
ax25_dev->values[AX25_VALUES_WINDOW] = AX25_DEF_WINDOW;
|
|
ax25_dev->values[AX25_VALUES_EWINDOW] = AX25_DEF_EWINDOW;
|
|
ax25_dev->values[AX25_VALUES_T1] = AX25_DEF_T1;
|
|
ax25_dev->values[AX25_VALUES_T2] = AX25_DEF_T2;
|
|
ax25_dev->values[AX25_VALUES_T3] = AX25_DEF_T3;
|
|
ax25_dev->values[AX25_VALUES_IDLE] = AX25_DEF_IDLE;
|
|
ax25_dev->values[AX25_VALUES_N2] = AX25_DEF_N2;
|
|
ax25_dev->values[AX25_VALUES_PACLEN] = AX25_DEF_PACLEN;
|
|
ax25_dev->values[AX25_VALUES_PROTOCOL] = AX25_DEF_PROTOCOL;
|
|
ax25_dev->values[AX25_VALUES_DS_TIMEOUT]= AX25_DEF_DS_TIMEOUT;
|
|
|
|
#if defined(CONFIG_AX25_DAMA_SLAVE) || defined(CONFIG_AX25_DAMA_MASTER)
|
|
init_timer(&ax25_dev->dama.slave_timer);
|
|
#endif
|
|
|
|
spin_lock_bh(&ax25_dev_lock);
|
|
ax25_dev->next = ax25_dev_list;
|
|
ax25_dev_list = ax25_dev;
|
|
spin_unlock_bh(&ax25_dev_lock);
|
|
|
|
ax25_register_sysctl();
|
|
}
|
|
|
|
void ax25_dev_device_down(struct net_device *dev)
|
|
{
|
|
ax25_dev *s, *ax25_dev;
|
|
|
|
if ((ax25_dev = ax25_dev_ax25dev(dev)) == NULL)
|
|
return;
|
|
|
|
ax25_unregister_sysctl();
|
|
|
|
spin_lock_bh(&ax25_dev_lock);
|
|
|
|
#ifdef CONFIG_AX25_DAMA_SLAVE
|
|
ax25_ds_del_timer(ax25_dev);
|
|
#endif
|
|
|
|
/*
|
|
* Remove any packet forwarding that points to this device.
|
|
*/
|
|
for (s = ax25_dev_list; s != NULL; s = s->next)
|
|
if (s->forward == dev)
|
|
s->forward = NULL;
|
|
|
|
if ((s = ax25_dev_list) == ax25_dev) {
|
|
ax25_dev_list = s->next;
|
|
spin_unlock_bh(&ax25_dev_lock);
|
|
dev_put(dev);
|
|
kfree(ax25_dev);
|
|
ax25_register_sysctl();
|
|
return;
|
|
}
|
|
|
|
while (s != NULL && s->next != NULL) {
|
|
if (s->next == ax25_dev) {
|
|
s->next = ax25_dev->next;
|
|
spin_unlock_bh(&ax25_dev_lock);
|
|
dev_put(dev);
|
|
kfree(ax25_dev);
|
|
ax25_register_sysctl();
|
|
return;
|
|
}
|
|
|
|
s = s->next;
|
|
}
|
|
spin_unlock_bh(&ax25_dev_lock);
|
|
dev->ax25_ptr = NULL;
|
|
|
|
ax25_register_sysctl();
|
|
}
|
|
|
|
int ax25_fwd_ioctl(unsigned int cmd, struct ax25_fwd_struct *fwd)
|
|
{
|
|
ax25_dev *ax25_dev, *fwd_dev;
|
|
|
|
if ((ax25_dev = ax25_addr_ax25dev(&fwd->port_from)) == NULL)
|
|
return -EINVAL;
|
|
|
|
switch (cmd) {
|
|
case SIOCAX25ADDFWD:
|
|
if ((fwd_dev = ax25_addr_ax25dev(&fwd->port_to)) == NULL)
|
|
return -EINVAL;
|
|
if (ax25_dev->forward != NULL)
|
|
return -EINVAL;
|
|
ax25_dev->forward = fwd_dev->dev;
|
|
break;
|
|
|
|
case SIOCAX25DELFWD:
|
|
if (ax25_dev->forward == NULL)
|
|
return -EINVAL;
|
|
ax25_dev->forward = NULL;
|
|
break;
|
|
|
|
default:
|
|
return -EINVAL;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
struct net_device *ax25_fwd_dev(struct net_device *dev)
|
|
{
|
|
ax25_dev *ax25_dev;
|
|
|
|
if ((ax25_dev = ax25_dev_ax25dev(dev)) == NULL)
|
|
return dev;
|
|
|
|
if (ax25_dev->forward == NULL)
|
|
return dev;
|
|
|
|
return ax25_dev->forward;
|
|
}
|
|
|
|
/*
|
|
* Free all memory associated with device structures.
|
|
*/
|
|
void __exit ax25_dev_free(void)
|
|
{
|
|
ax25_dev *s, *ax25_dev;
|
|
|
|
spin_lock_bh(&ax25_dev_lock);
|
|
ax25_dev = ax25_dev_list;
|
|
while (ax25_dev != NULL) {
|
|
s = ax25_dev;
|
|
dev_put(ax25_dev->dev);
|
|
ax25_dev = ax25_dev->next;
|
|
kfree(s);
|
|
}
|
|
ax25_dev_list = NULL;
|
|
spin_unlock_bh(&ax25_dev_lock);
|
|
}
|