diff -Nru a/MAINTAINERS b/MAINTAINERS --- a/MAINTAINERS Tue Feb 18 10:57:56 2003 +++ b/MAINTAINERS Thu Mar 6 09:07:03 2003 @@ -641,7 +641,7 @@ P: Rui Sousa M: rui.p.m.sousa@clix.pt L: emu10k1-devel@lists.sourceforge.net -W: http://opensource.creative.com/ +W: http://sourceforge.net/projects/emu10k1/ S: Maintained ETHEREXPRESS-16 NETWORK DRIVER diff -Nru a/Makefile b/Makefile --- a/Makefile Tue Mar 4 19:11:15 2003 +++ b/Makefile Fri Mar 7 04:25:09 2003 @@ -1,7 +1,7 @@ VERSION = 2 PATCHLEVEL = 5 SUBLEVEL = 64 -EXTRAVERSION = +EXTRAVERSION = bk2 # *DOCUMENTATION* # To see a list of typical targets execute "make help" @@ -107,6 +107,11 @@ # For now, leave verbose as default +ifdef V + ifeq ("$(origin V)", "command line") + KBUILD_VERBOSE = $(V) + endif +endif ifndef KBUILD_VERBOSE KBUILD_VERBOSE = 1 endif @@ -322,13 +327,14 @@ # set -e makes the rule exit immediately on error define rule_vmlinux__ - set -e; \ + set -e \ $(if $(filter .tmp_kallsyms%,$^),, \ echo ' GEN .version'; \ . $(srctree)/scripts/mkversion > .tmp_version; \ mv -f .tmp_version .version; \ $(MAKE) $(build)=init; \ ) + set -e \ $(call cmd,vmlinux__); \ echo 'cmd_$@ := $(cmd_vmlinux__)' > $(@D)/.$(@F).cmd endef diff -Nru a/arch/alpha/kernel/core_marvel.c b/arch/alpha/kernel/core_marvel.c --- a/arch/alpha/kernel/core_marvel.c Fri Feb 14 05:51:04 2003 +++ b/arch/alpha/kernel/core_marvel.c Sat Feb 15 04:55:38 2003 @@ -1076,7 +1076,7 @@ /* * Fill it in. */ - agp->type = 0 /* FIXME: ALPHA_CORE_AGP */; + agp->type = ALPHA_CORE_AGP; agp->hose = hose; agp->private = NULL; agp->ops = &marvel_agp_ops; diff -Nru a/arch/alpha/kernel/core_titan.c b/arch/alpha/kernel/core_titan.c --- a/arch/alpha/kernel/core_titan.c Fri Jan 17 11:59:36 2003 +++ b/arch/alpha/kernel/core_titan.c Sat Feb 15 04:55:54 2003 @@ -764,7 +764,7 @@ /* * Fill it in. */ - agp->type = 0 /* FIXME: ALPHA_CORE_AGP */; + agp->type = ALPHA_CORE_AGP; agp->hose = hose; agp->private = port; agp->ops = &titan_agp_ops; diff -Nru a/arch/alpha/kernel/pci.c b/arch/alpha/kernel/pci.c --- a/arch/alpha/kernel/pci.c Wed Feb 26 17:20:09 2003 +++ b/arch/alpha/kernel/pci.c Thu Mar 6 11:08:47 2003 @@ -393,26 +393,36 @@ } static void __init +pcibios_claim_one_bus(struct pci_bus *b) +{ + struct list_head *ld; + struct pci_bus *child_bus; + + for (ld = b->devices.next; ld != &b->devices; ld = ld->next) { + struct pci_dev *dev = pci_dev_b(ld); + int i; + + for (i = 0; i < PCI_NUM_RESOURCES; i++) { + struct resource *r = &dev->resource[i]; + + if (r->parent || !r->start || !r->flags) + continue; + pci_claim_resource(dev, i); + } + } + + list_for_each_entry(child_bus, &b->children, node) + pcibios_claim_one_bus(child_bus); +} + +static void __init pcibios_claim_console_setup(void) { struct list_head *lb; for(lb = pci_root_buses.next; lb != &pci_root_buses; lb = lb->next) { struct pci_bus *b = pci_bus_b(lb); - struct list_head *ld; - - for (ld = b->devices.next; ld != &b->devices; ld = ld->next) { - struct pci_dev *dev = pci_dev_b(ld); - int i; - - for (i = 0; i < PCI_NUM_RESOURCES; i++) { - struct resource *r = &dev->resource[i]; - - if (r->parent || !r->start || !r->flags) - continue; - pci_claim_resource(dev, i); - } - } + pcibios_claim_one_bus(b); } } diff -Nru a/arch/alpha/kernel/sys_nautilus.c b/arch/alpha/kernel/sys_nautilus.c --- a/arch/alpha/kernel/sys_nautilus.c Thu Jan 23 10:59:07 2003 +++ b/arch/alpha/kernel/sys_nautilus.c Sun Mar 2 17:34:25 2003 @@ -78,6 +78,8 @@ nautilus_kill_arch(int mode) { struct pci_bus *bus = pci_isa_hose->bus; + u32 pmuport; + int off; switch (mode) { case LINUX_REBOOT_CMD_RESTART: @@ -92,14 +94,18 @@ break; case LINUX_REBOOT_CMD_POWER_OFF: - { - u32 pmuport; - pci_bus_read_config_dword(bus, 0x88, 0x10, &pmuport); - pmuport &= 0xfffe; - outl(0xffff, pmuport); /* clear pending events */ - outw(0x2000, pmuport+4); /* power off */ - /* NOTREACHED */ + /* Assume M1543C */ + off = 0x2000; /* SLP_TYPE = 0, SLP_EN = 1 */ + pci_bus_read_config_dword(bus, 0x88, 0x10, &pmuport); + if (!pmuport) { + /* M1535D/D+ */ + off = 0x3400; /* SLP_TYPE = 5, SLP_EN = 1 */ + pci_bus_read_config_dword(bus, 0x88, 0xe0, &pmuport); } + pmuport &= 0xfffe; + outw(0xffff, pmuport); /* Clear pending events. */ + outw(off, pmuport + 4); + /* NOTREACHED */ break; } } diff -Nru a/arch/alpha/mm/fault.c b/arch/alpha/mm/fault.c --- a/arch/alpha/mm/fault.c Mon Jan 6 10:11:27 2003 +++ b/arch/alpha/mm/fault.c Thu Mar 6 08:19:03 2003 @@ -232,11 +232,11 @@ else { /* Synchronize this task's top level page-table with the "reference" page table from init. */ - long offset = __pgd_offset(address); + long index = pgd_index(address); pgd_t *pgd, *pgd_k; - pgd = current->active_mm->pgd + offset; - pgd_k = swapper_pg_dir + offset; + pgd = current->active_mm->pgd + index; + pgd_k = swapper_pg_dir + index; if (!pgd_present(*pgd) && pgd_present(*pgd_k)) { pgd_val(*pgd) = pgd_val(*pgd_k); return; diff -Nru a/arch/alpha/vmlinux.lds.S b/arch/alpha/vmlinux.lds.S --- a/arch/alpha/vmlinux.lds.S Wed Jan 15 19:04:27 2003 +++ b/arch/alpha/vmlinux.lds.S Fri Feb 14 14:36:36 2003 @@ -63,6 +63,13 @@ .init.ramfs : { *(.init.ramfs) } __initramfs_end = .; + . = ALIGN(8) + .con_initcall.init: { + __con_initcall_start = .; + *(.con_initcall.init) + __con_initcall_end = .; + } + . = ALIGN(64); __per_cpu_start = .; .data.percpu : { *(.data.percpu) } diff -Nru a/arch/arm/Kconfig b/arch/arm/Kconfig --- a/arch/arm/Kconfig Sat Feb 15 01:34:08 2003 +++ b/arch/arm/Kconfig Thu Mar 6 11:27:03 2003 @@ -534,15 +534,63 @@ written) to implement the policy. If you don't understand what this is all about, it's safe to say 'N'. + +# CPUfreq on SA11x0 is special -- it _needs_ the userspace governor + +config CPU_FREQ_SA1100 + bool + depends on CPU_FREQ && SA1100_LART + default y + +config CPU_FREQ_SA1110 + bool + depends on CPU_FREQ && (SA1100_ASSABET || SA1100_CERF || SA1100_PT_SYSTEM3) + default y + +if (CPU_FREQ_SA1100 || CPU_FREQ_SA1110) + +config CPU_FREQ_GOV_USERSPACE + bool + depends on CPU_FREQ + default y + config CPU_FREQ_24_API bool - depends on CPU_FREQ + depends on CPU_FREQ_GOV_USERSPACE && SYSCTL default y config CPU_FREQ_PROC_INTF - tristate - depends on CPU_FREQ + tristate "/proc/cpufreq interface (deprecated)" + depends on CPU_FREQ && PROC_FS + help + This enables the /proc/cpufreq interface for controlling + CPUFreq. Please note that it is recommended to use the sysfs + interface instead (which is built automatically). + + For details, take a look at linux/Documentation/cpufreq. + + If in doubt, say N. + +endif + +# CPUfreq on Integrator can use the generic cpufreq core + +config CPU_FREQ_INTEGRATOR + tristate "CPUfreq driver for ARM Integrator CPUs" + depends on ARCH_INTEGRATOR && CPU_FREQ default y + help + This enables the CPUfreq driver for ARM Integrator CPUs. + + For details, take a look at linux/Documentation/cpufreq. + + If in doubt, say Y. + +if (CPU_FREQ_INTEGRATOR) + +source "drivers/cpufreq/Kconfig" + +endif source "drivers/pci/Kconfig" diff -Nru a/arch/arm/common/sa1111.c b/arch/arm/common/sa1111.c --- a/arch/arm/common/sa1111.c Mon Feb 17 12:43:37 2003 +++ b/arch/arm/common/sa1111.c Thu Mar 6 08:08:19 2003 @@ -743,25 +743,23 @@ static int sa1111_suspend(struct device *dev, u32 state, u32 level) { struct sa1111 *sachip = dev_get_drvdata(dev); + struct sa1111_save_data *save; unsigned long flags; char *base; + if (!dev->saved_state && level == SUSPEND_NOTIFY) + dev->saved_state = kmalloc(sizeof(struct sa1111_save_data), GFP_KERNEL); + if (!dev->saved_state) + return -ENOMEM; + + save = (struct sa1111_save_data *)dev->saved_state; + + spin_lock_irqsave(&sachip->lock, flags); + /* * Save state. */ - if (level == SUSPEND_SAVE_STATE || - level == SUSPEND_DISABLE || - level == SUSPEND_POWER_DOWN) { - struct sa1111_save_data *save; - - if (!dev->saved_state) - dev->saved_state = kmalloc(sizeof(struct sa1111_save_data), GFP_KERNEL); - if (!dev->saved_state) - return -ENOMEM; - - save = (struct sa1111_save_data *)dev->saved_state; - - spin_lock_irqsave(&sachip->lock, flags); + if (level == SUSPEND_SAVE_STATE) { base = sachip->base; save->skcr = sa1111_readl(base + SA1111_SKCR); save->skpcr = sa1111_readl(base + SA1111_SKPCR); @@ -779,26 +777,21 @@ save->wakepol1 = sa1111_readl(base + SA1111_WAKEPOL1); save->wakeen0 = sa1111_readl(base + SA1111_WAKEEN0); save->wakeen1 = sa1111_readl(base + SA1111_WAKEEN1); - spin_unlock_irqrestore(&sachip->lock, flags); } /* * Disable. */ - if (level == SUSPEND_DISABLE && state == 4) { - unsigned int val; - - spin_lock_irqsave(&sachip->lock, flags); - base = sachip->base; - - sa1111_writel(0, base + SA1111_SKPWM0); - sa1111_writel(0, base + SA1111_SKPWM1); - val = sa1111_readl(base + SA1111_SKCR); - sa1111_writel(val | SKCR_SLEEP, base + SA1111_SKCR); + if (level == SUSPEND_POWER_DOWN && state == 4) { + unsigned int val = sa1111_readl(sachip->base + SA1111_SKCR); - spin_unlock_irqrestore(&sachip->lock, flags); + sa1111_writel(val | SKCR_SLEEP, sachip->base + SA1111_SKCR); + sa1111_writel(0, sachip->base + SA1111_SKPWM0); + sa1111_writel(0, sachip->base + SA1111_SKPWM1); } + spin_unlock_irqrestore(&sachip->lock, flags); + return 0; } @@ -819,17 +812,15 @@ unsigned long flags, id; char *base; - if (level != RESUME_RESTORE_STATE && level != RESUME_ENABLE) - return 0; - save = (struct sa1111_save_data *)dev->saved_state; if (!save) return 0; - dev->saved_state = NULL; + spin_lock_irqsave(&sachip->lock, flags); /* * Ensure that the SA1111 is still here. + * FIXME: shouldn't do this here. */ id = sa1111_readl(sachip->base + SA1111_SKID); if ((id & SKID_ID_MASK) != SKID_SA1111_ID) { @@ -839,29 +830,42 @@ return 0; } - spin_lock_irqsave(&sachip->lock, flags); - sa1111_wake(sachip); + /* + * First of all, wake up the chip. + */ + if (level == RESUME_POWER_ON) { + sa1111_wake(sachip); + + sa1111_writel(0, sachip->base + SA1111_INTC + SA1111_INTEN0); + sa1111_writel(0, sachip->base + SA1111_INTC + SA1111_INTEN1); + } + + if (level == RESUME_RESTORE_STATE) { + base = sachip->base; + sa1111_writel(save->skcr, base + SA1111_SKCR); + sa1111_writel(save->skpcr, base + SA1111_SKPCR); + sa1111_writel(save->skcdr, base + SA1111_SKCDR); + sa1111_writel(save->skaud, base + SA1111_SKAUD); + sa1111_writel(save->skpwm0, base + SA1111_SKPWM0); + sa1111_writel(save->skpwm1, base + SA1111_SKPWM1); + + base = sachip->base + SA1111_INTC; + sa1111_writel(save->intpol0, base + SA1111_INTPOL0); + sa1111_writel(save->intpol1, base + SA1111_INTPOL1); + sa1111_writel(save->inten0, base + SA1111_INTEN0); + sa1111_writel(save->inten1, base + SA1111_INTEN1); + sa1111_writel(save->wakepol0, base + SA1111_WAKEPOL0); + sa1111_writel(save->wakepol1, base + SA1111_WAKEPOL1); + sa1111_writel(save->wakeen0, base + SA1111_WAKEEN0); + sa1111_writel(save->wakeen1, base + SA1111_WAKEEN1); + } - base = sachip->base; - sa1111_writel(save->skcr, base + SA1111_SKCR); - sa1111_writel(save->skpcr, base + SA1111_SKPCR); - sa1111_writel(save->skcdr, base + SA1111_SKCDR); - sa1111_writel(save->skaud, base + SA1111_SKAUD); - sa1111_writel(save->skpwm0, base + SA1111_SKPWM0); - sa1111_writel(save->skpwm1, base + SA1111_SKPWM1); - - base = sachip->base + SA1111_INTC; - sa1111_writel(save->intpol0, base + SA1111_INTPOL0); - sa1111_writel(save->intpol1, base + SA1111_INTPOL1); - sa1111_writel(save->inten0, base + SA1111_INTEN0); - sa1111_writel(save->inten1, base + SA1111_INTEN1); - sa1111_writel(save->wakepol0, base + SA1111_WAKEPOL0); - sa1111_writel(save->wakepol1, base + SA1111_WAKEPOL1); - sa1111_writel(save->wakeen0, base + SA1111_WAKEEN0); - sa1111_writel(save->wakeen1, base + SA1111_WAKEEN1); spin_unlock_irqrestore(&sachip->lock, flags); - kfree(save); + if (level == RESUME_ENABLE) { + dev->saved_state = NULL; + kfree(save); + } return 0; } diff -Nru a/arch/arm/kernel/Makefile b/arch/arm/kernel/Makefile --- a/arch/arm/kernel/Makefile Mon Feb 3 14:19:35 2003 +++ b/arch/arm/kernel/Makefile Thu Mar 6 07:59:42 2003 @@ -16,6 +16,7 @@ obj- := obj-$(CONFIG_APM) += apm.o +obj-$(CONFIG_PM) += pm.o obj-$(CONFIG_ARCH_ACORN) += ecard.o time-acorn.o obj-$(CONFIG_ARCH_CLPS7500) += time-acorn.o obj-$(CONFIG_FOOTBRIDGE) += isa.o diff -Nru a/arch/arm/kernel/apm.c b/arch/arm/kernel/apm.c --- /dev/null Wed Dec 31 16:00:00 1969 +++ b/arch/arm/kernel/apm.c Thu Mar 6 07:59:42 2003 @@ -0,0 +1,573 @@ +/* + * bios-less APM driver for ARM Linux + * Jamey Hicks + * adapted from the APM BIOS driver for Linux by Stephen Rothwell (sfr@linuxcare.com) + * + * APM 1.2 Reference: + * Intel Corporation, Microsoft Corporation. Advanced Power Management + * (APM) BIOS Interface Specification, Revision 1.2, February 1996. + * + * [This document is available from Microsoft at: + * http://www.microsoft.com/hwdev/busbios/amp_12.htm] + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +/* + * The apm_bios device is one of the misc char devices. + * This is its minor number. + */ +#define APM_MINOR_DEV 134 + +/* + * See Documentation/Config.help for the configuration options. + * + * Various options can be changed at boot time as follows: + * (We allow underscores for compatibility with the modules code) + * apm=on/off enable/disable APM + */ + +/* + * Maximum number of events stored + */ +#define APM_MAX_EVENTS 20 + +/* + * The per-file APM data + */ +struct apm_user { + struct list_head list; + + int suser: 1; + int writer: 1; + int reader: 1; + int suspend_wait: 1; + int suspend_result; + + int suspends_pending; + int standbys_pending; + unsigned int suspends_read; + unsigned int standbys_read; + + int event_head; + int event_tail; + apm_event_t events[APM_MAX_EVENTS]; +}; + +/* + * Local variables + */ +static int suspends_pending; +static int standbys_pending; +static int apm_disabled; + +static DECLARE_WAIT_QUEUE_HEAD(apm_waitqueue); +static DECLARE_WAIT_QUEUE_HEAD(apm_suspend_waitqueue); + +/* + * This is a list of everyone who has opened /dev/apm_bios + */ +static spinlock_t user_list_lock = SPIN_LOCK_UNLOCKED; +static LIST_HEAD(apm_user_list); + +/* + * The kapmd info. + */ +static struct task_struct *kapmd; +static DECLARE_COMPLETION(kapmd_exit); + +static const char driver_version[] = "1.13"; /* no spaces */ + +/* + * This structure gets filled in by the machine specific 'get_power_status' + * implementation. Any fields which are not set default to a safe value. + */ +struct apm_power_info { + unsigned char ac_line_status; + unsigned char battery_status; + unsigned char battery_flag; + unsigned char battery_life; + int time; + int units; +}; + +/* + * Compatibility cruft until the IPAQ people move over to the new + * interface. + */ +static void __apm_get_power_status(struct apm_power_info *info) +{ +#if 0 && defined(CONFIG_SA1100_H3600) && defined(CONFIG_TOUCHSCREEN_H3600) + extern int h3600_apm_get_power_status(u_char *, u_char *, u_char *, + u_char *, u_short *); + + if (machine_is_h3600()) { + int dx; + h3600_apm_get_power_status(&info->ac_line_status, + &info->battery_status, &info->battery_flag, + &info->battery_life, &dx); + info->time = dx & 0x7fff; + info->units = dx & 0x8000 ? 0 : 1; + } +#endif +} + +/* + * This allows machines to provide their own "apm get power status" function. + */ +void (*apm_get_power_status)(struct apm_power_info *) = __apm_get_power_status; +EXPORT_SYMBOL(apm_get_power_status); + +static int queue_empty(struct apm_user *as) +{ + return as->event_head == as->event_tail; +} + +static apm_event_t get_queued_event(struct apm_user *as) +{ + as->event_tail = (as->event_tail + 1) % APM_MAX_EVENTS; + return as->events[as->event_tail]; +} + +static void queue_event_one_user(struct apm_user *as, apm_event_t event) +{ + as->event_head = (as->event_head + 1) % APM_MAX_EVENTS; + if (as->event_head == as->event_tail) { + static int notified; + + if (notified++ == 0) + printk(KERN_ERR "apm: an event queue overflowed\n"); + as->event_tail = (as->event_tail + 1) % APM_MAX_EVENTS; + } + as->events[as->event_head] = event; + + if (!as->suser || !as->writer) + return; + + switch (event) { + case APM_SYS_SUSPEND: + case APM_USER_SUSPEND: + as->suspends_pending++; + suspends_pending++; + break; + + case APM_SYS_STANDBY: + case APM_USER_STANDBY: + as->standbys_pending++; + standbys_pending++; + break; + } +} + +static void queue_event(apm_event_t event, struct apm_user *sender) +{ + struct list_head *l; + + spin_lock(&user_list_lock); + list_for_each(l, &apm_user_list) { + struct apm_user *as = list_entry(l, struct apm_user, list); + + if (as != sender && as->reader) + queue_event_one_user(as, event); + } + spin_unlock(&user_list_lock); + wake_up_interruptible(&apm_waitqueue); +} + +/* defined in pm.c */ +extern int suspend(void); + +static int apm_suspend(void) +{ + struct list_head *l; + int err = suspend(); + + /* + * Anyone on the APM queues will think we're still suspended. + * Send a message so everyone knows we're now awake again. + */ + queue_event(APM_NORMAL_RESUME, NULL); + + /* + * Finally, wake up anyone who is sleeping on the suspend. + */ + spin_lock(&user_list_lock); + list_for_each(l, &apm_user_list) { + struct apm_user *as = list_entry(l, struct apm_user, list); + + as->suspend_result = err; + as->suspend_wait = 0; + } + spin_unlock(&user_list_lock); + + wake_up_interruptible(&apm_suspend_waitqueue); + return err; +} + +static ssize_t apm_read(struct file *fp, char *buf, size_t count, loff_t *ppos) +{ + struct apm_user *as = fp->private_data; + apm_event_t event; + int i = count, ret = 0, nonblock = fp->f_flags & O_NONBLOCK; + + if (count < sizeof(apm_event_t)) + return -EINVAL; + + if (queue_empty(as) && nonblock) + return -EAGAIN; + + wait_event_interruptible(apm_waitqueue, !queue_empty(as)); + + while ((i >= sizeof(event)) && !queue_empty(as)) { + event = get_queued_event(as); + printk(" apm_read: event=%d\n", event); + + ret = -EFAULT; + if (copy_to_user(buf, &event, sizeof(event))) + break; + + switch (event) { + case APM_SYS_SUSPEND: + case APM_USER_SUSPEND: + as->suspends_read++; + break; + + case APM_SYS_STANDBY: + case APM_USER_STANDBY: + as->standbys_read++; + break; + } + + buf += sizeof(event); + i -= sizeof(event); + } + + if (i < count) + ret = count - i; + + return ret; +} + +static unsigned int apm_poll(struct file *fp, poll_table * wait) +{ + struct apm_user * as = fp->private_data; + + poll_wait(fp, &apm_waitqueue, wait); + return queue_empty(as) ? 0 : POLLIN | POLLRDNORM; +} + +/* + * apm_ioctl - handle APM ioctl + * + * APM_IOC_SUSPEND + * This IOCTL is overloaded, and performs two functions. It is used to: + * - initiate a suspend + * - acknowledge a suspend read from /dev/apm_bios. + * Only when everyone who has opened /dev/apm_bios with write permission + * has acknowledge does the actual suspend happen. + */ +static int +apm_ioctl(struct inode * inode, struct file *filp, u_int cmd, u_long arg) +{ + struct apm_user *as = filp->private_data; + int err = -EINVAL; + + if (!as->suser || !as->writer) + return -EPERM; + + switch (cmd) { + case APM_IOC_STANDBY: + break; + + case APM_IOC_SUSPEND: + /* + * If we read a suspend command from /dev/apm_bios, + * then the corresponding APM_IOC_SUSPEND ioctl is + * interpreted as an acknowledge. + */ + if (as->suspends_read > 0) { + as->suspends_read--; + as->suspends_pending--; + suspends_pending--; + } else { + queue_event(APM_USER_SUSPEND, as); + } + + /* + * If there are outstanding suspend requests for other + * people on /dev/apm_bios, we must sleep for them. + * Last one to bed turns the lights out. + */ + if (suspends_pending > 0) { + as->suspend_wait = 1; + err = wait_event_interruptible(apm_suspend_waitqueue, + as->suspend_wait == 0); + if (err == 0) + err = as->suspend_result; + } else { + err = apm_suspend(); + } + break; + } + + return err; +} + +static int apm_release(struct inode * inode, struct file * filp) +{ + struct apm_user *as = filp->private_data; + filp->private_data = NULL; + + spin_lock(&user_list_lock); + list_del(&as->list); + spin_unlock(&user_list_lock); + + /* + * We are now unhooked from the chain. As far as new + * events are concerned, we no longer exist. However, we + * need to balance standbys_pending and suspends_pending, + * which means the possibility of sleeping. + */ + if (as->standbys_pending > 0) { + standbys_pending -= as->standbys_pending; +// if (standbys_pending <= 0) +// standby(); + } + if (as->suspends_pending > 0) { + suspends_pending -= as->suspends_pending; + if (suspends_pending <= 0) + apm_suspend(); + } + + kfree(as); + return 0; +} + +static int apm_open(struct inode * inode, struct file * filp) +{ + struct apm_user *as; + + as = (struct apm_user *)kmalloc(sizeof(*as), GFP_KERNEL); + if (as) { + memset(as, 0, sizeof(*as)); + + /* + * XXX - this is a tiny bit broken, when we consider BSD + * process accounting. If the device is opened by root, we + * instantly flag that we used superuser privs. Who knows, + * we might close the device immediately without doing a + * privileged operation -- cevans + */ + as->suser = capable(CAP_SYS_ADMIN); + as->writer = (filp->f_mode & FMODE_WRITE) == FMODE_WRITE; + as->reader = (filp->f_mode & FMODE_READ) == FMODE_READ; + + spin_lock(&user_list_lock); + list_add(&as->list, &apm_user_list); + spin_unlock(&user_list_lock); + + filp->private_data = as; + } + + return as ? 0 : -ENOMEM; +} + +static struct file_operations apm_bios_fops = { + owner: THIS_MODULE, + read: apm_read, + poll: apm_poll, + ioctl: apm_ioctl, + open: apm_open, + release: apm_release, +}; + +static struct miscdevice apm_device = { + minor: APM_MINOR_DEV, + name: "apm_bios", + fops: &apm_bios_fops +}; + + +#ifdef CONFIG_PROC_FS +/* + * Arguments, with symbols from linux/apm_bios.h. + * + * 0) Linux driver version (this will change if format changes) + * 1) APM BIOS Version. Usually 1.0, 1.1 or 1.2. + * 2) APM flags from APM Installation Check (0x00): + * bit 0: APM_16_BIT_SUPPORT + * bit 1: APM_32_BIT_SUPPORT + * bit 2: APM_IDLE_SLOWS_CLOCK + * bit 3: APM_BIOS_DISABLED + * bit 4: APM_BIOS_DISENGAGED + * 3) AC line status + * 0x00: Off-line + * 0x01: On-line + * 0x02: On backup power (BIOS >= 1.1 only) + * 0xff: Unknown + * 4) Battery status + * 0x00: High + * 0x01: Low + * 0x02: Critical + * 0x03: Charging + * 0x04: Selected battery not present (BIOS >= 1.2 only) + * 0xff: Unknown + * 5) Battery flag + * bit 0: High + * bit 1: Low + * bit 2: Critical + * bit 3: Charging + * bit 7: No system battery + * 0xff: Unknown + * 6) Remaining battery life (percentage of charge): + * 0-100: valid + * -1: Unknown + * 7) Remaining battery life (time units): + * Number of remaining minutes or seconds + * -1: Unknown + * 8) min = minutes; sec = seconds + */ +static int apm_get_info(char *buf, char **start, off_t fpos, int length) +{ + struct apm_power_info info; + char *units; + int ret; + + info.ac_line_status = 0xff; + info.battery_status = 0xff; + info.battery_flag = 0xff; + info.battery_life = 255; + info.time = -1; + info.units = -1; + + if (apm_get_power_status) + apm_get_power_status(&info); + + switch (info.units) { + default: units = "?"; break; + case 0: units = "min"; break; + case 1: units = "sec"; break; + } + + ret = sprintf(buf, "%s 1.2 0x%02x 0x%02x 0x%02x 0x%02x %d%% %d %s\n", + driver_version, APM_32_BIT_SUPPORT, + info.ac_line_status, info.battery_status, + info.battery_flag, info.battery_life, + info.time, units); + + return ret; +} +#endif + +#if 0 +static int kapmd(void *startup) +{ + struct task_struct *tsk = current; + + daemonize(); + strcpy(tsk->comm, "kapmd"); + kapmd = tsk; + + spin_lock_irq(&tsk->sigmask_lock); + siginitsetinv(&tsk->blocked, sigmask(SIGQUIT)); + recalc_sigpending(tsk); + spin_unlock_irq(&tsk->sigmask_lock); + + complete((struct completion *)startup); + + do { + set_task_state(tsk, TASK_INTERRUPTIBLE); + schedule(); + } while (!signal_pending(tsk)); + + complete_and_exit(&kapmd_exit, 0); +} +#endif + +static int __init apm_init(void) +{ +// struct completion startup = COMPLETION_INITIALIZER(startup); + int ret; + + if (apm_disabled) { + printk(KERN_NOTICE "apm: disabled on user request.\n"); + return -ENODEV; + } + + if (PM_IS_ACTIVE()) { + printk(KERN_NOTICE "apm: overridden by ACPI.\n"); + return -EINVAL; + } + +// ret = kernel_thread(kapmd, &startup, CLONE_FS | CLONE_FILES); +// if (ret) +// return ret; +// wait_for_completion(&startup); + + pm_active = 1; + +#ifdef CONFIG_PROC_FS + create_proc_info_entry("apm", 0, NULL, apm_get_info); +#endif + + ret = misc_register(&apm_device); + if (ret != 0) { + pm_active = 0; + remove_proc_entry("apm", NULL); + send_sig(SIGQUIT, kapmd, 1); + wait_for_completion(&kapmd_exit); + } + + return ret; +} + +static void __exit apm_exit(void) +{ + misc_deregister(&apm_device); + remove_proc_entry("apm", NULL); + pm_active = 0; +// send_sig(SIGQUIT, kapmd, 1); +// wait_for_completion(&kapmd_exit); +} + +module_init(apm_init); +module_exit(apm_exit); + +MODULE_AUTHOR("Stephen Rothwell"); +MODULE_DESCRIPTION("Advanced Power Management"); +MODULE_LICENSE("GPL"); + +EXPORT_NO_SYMBOLS; + +#ifndef MODULE +static int __init apm_setup(char *str) +{ + while ((str != NULL) && (*str != '\0')) { + if (strncmp(str, "off", 3) == 0) + apm_disabled = 1; + if (strncmp(str, "on", 2) == 0) + apm_disabled = 0; + str = strchr(str, ','); + if (str != NULL) + str += strspn(str, ", \t"); + } + return 1; +} + +__setup("apm=", apm_setup); +#endif diff -Nru a/arch/arm/kernel/bios32.c b/arch/arm/kernel/bios32.c --- a/arch/arm/kernel/bios32.c Thu Jan 16 06:42:22 2003 +++ b/arch/arm/kernel/bios32.c Thu Mar 6 08:26:25 2003 @@ -18,7 +18,6 @@ #include static int debug_pci; -int have_isa_bridge; void pcibios_report_status(u_int status_mask, int warn) { @@ -363,9 +362,8 @@ void __devinit pcibios_fixup_bus(struct pci_bus *bus) { struct pci_sys_data *root = bus->sysdata; - struct list_head *walk; - u16 features = PCI_COMMAND_SERR | PCI_COMMAND_PARITY; - u16 all_status = -1; + struct pci_dev *dev; + u16 features = PCI_COMMAND_SERR | PCI_COMMAND_PARITY | PCI_COMMAND_FAST_BACK; pbus_assign_bus_resources(bus, root); @@ -373,42 +371,43 @@ * Walk the devices on this bus, working out what we can * and can't support. */ - for (walk = bus->devices.next; walk != &bus->devices; walk = walk->next) { - struct pci_dev *dev = pci_dev_b(walk); + list_for_each_entry(dev, &bus->devices, bus_list) { u16 status; pdev_fixup_device_resources(root, dev); pci_read_config_word(dev, PCI_STATUS, &status); - all_status &= status; + + /* + * If any device on this bus does not support fast back + * to back transfers, then the bus as a whole is not able + * to support them. Having fast back to back transfers + * on saves us one PCI cycle per transaction. + */ + if (!(status & PCI_STATUS_FAST_BACK)) + features &= ~PCI_COMMAND_FAST_BACK; if (pdev_bad_for_parity(dev)) features &= ~(PCI_COMMAND_SERR | PCI_COMMAND_PARITY); - /* - * If this device is an ISA bridge, set the have_isa_bridge - * flag. We will then go looking for things like keyboard, - * etc - */ - if (dev->class >> 8 == PCI_CLASS_BRIDGE_ISA || - dev->class >> 8 == PCI_CLASS_BRIDGE_EISA) - have_isa_bridge = !0; + switch (dev->class >> 8) { +#if defined(CONFIG_ISA) || defined(CONFIG_EISA) + case PCI_CLASS_BRIDGE_ISA: + case PCI_CLASS_BRIDGE_EISA: + /* + * If this device is an ISA bridge, set isa_bridge + * to point at this device. We will then go looking + * for things like keyboard, etc. + */ + isa_bridge = dev; + break; +#endif } /* - * If any device on this bus does not support fast back to back - * transfers, then the bus as a whole is not able to support them. - * Having fast back to back transfers on saves us one PCI cycle - * per transaction. - */ - if (all_status & PCI_STATUS_FAST_BACK) - features |= PCI_COMMAND_FAST_BACK; - - /* * Now walk the devices again, this time setting them up. */ - for (walk = bus->devices.next; walk != &bus->devices; walk = walk->next) { - struct pci_dev *dev = pci_dev_b(walk); + list_for_each_entry(dev, &bus->devices, bus_list) { u16 cmd; pci_read_config_word(dev, PCI_COMMAND, &cmd); @@ -416,7 +415,17 @@ pci_write_config_word(dev, PCI_COMMAND, cmd); pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, - SMP_CACHE_BYTES >> 2); + L1_CACHE_BYTES >> 2); + } + + /* + * Propagate the flags to the PCI bridge. + */ + if (bus->self && bus->self->hdr_type == PCI_HEADER_TYPE_BRIDGE) { + if (features & PCI_COMMAND_FAST_BACK) + bus->bridge_ctl |= PCI_BRIDGE_CTL_FAST_BACK; + if (features & PCI_COMMAND_PARITY) + bus->bridge_ctl |= PCI_BRIDGE_CTL_PARITY; } /* @@ -454,20 +463,17 @@ */ u8 __devinit pci_std_swizzle(struct pci_dev *dev, u8 *pinp) { - int pin = *pinp; + int pin = *pinp - 1; - if (pin != 0) { - pin -= 1; - while (dev->bus->self) { - pin = (pin + PCI_SLOT(dev->devfn)) & 3; - /* - * move up the chain of bridges, - * swizzling as we go. - */ - dev = dev->bus->self; - } - *pinp = pin + 1; + while (dev->bus->self) { + pin = (pin + PCI_SLOT(dev->devfn)) & 3; + /* + * move up the chain of bridges, + * swizzling as we go. + */ + dev = dev->bus->self; } + *pinp = pin + 1; return PCI_SLOT(dev->devfn); } diff -Nru a/arch/arm/kernel/ecard.c b/arch/arm/kernel/ecard.c --- a/arch/arm/kernel/ecard.c Tue Feb 11 14:57:50 2003 +++ b/arch/arm/kernel/ecard.c Thu Mar 6 05:14:05 2003 @@ -37,7 +37,6 @@ #include #include #include -#include #include #include @@ -57,7 +56,7 @@ enum req { req_readbytes, - req_reset_all + req_reset }; struct ecard_request { @@ -131,14 +130,11 @@ #define POD_INT_ADDR(x) ((volatile unsigned char *)\ ((BUS_ADDR((x)) - IO_BASE) + IO_START)) -static inline void ecard_task_reset(void) +static inline void ecard_task_reset(struct ecard_request *req) { - ecard_t *ec; - - for (ec = cards; ec; ec = ec->next) - if (ec->loader) - ecard_loader_reset(POD_INT_ADDR(ec->podaddr), - ec->loader); + struct expansion_card *ec = req->ec; + if (ec->loader) + ecard_loader_reset(POD_INT_ADDR(ec->podaddr), ec->loader); } static void @@ -218,8 +214,8 @@ ecard_task_readbytes(req); break; - case req_reset_all: - ecard_task_reset(); + case req_reset: + ecard_task_reset(req); break; } } @@ -355,60 +351,6 @@ /* ======================= Mid-level card control ===================== */ -/* - * This function is responsible for resetting the expansion cards to a - * sensible state immediately prior to rebooting the system. This function - * has process state (keventd), so we can sleep. - * - * Possible "val" values here: - * SYS_RESTART - restarting system - * SYS_HALT - halting system - * SYS_POWER_OFF - powering down system - * - * We ignore all calls, unless it is a SYS_RESTART call - power down/halts - * will be followed by a SYS_RESTART if ctrl-alt-del is pressed again. - */ -static int ecard_reboot(struct notifier_block *me, unsigned long val, void *v) -{ - struct ecard_request req; - - if (val != SYS_RESTART) - return 0; - - /* - * Disable the expansion card interrupt - */ - disable_irq(IRQ_EXPANSIONCARD); - - /* - * If we have any expansion card loader code which will handle - * the reset for us, call it now. - */ - req.req = req_reset_all; - ecard_call(&req); - - /* - * Disable the expansion card interrupt again, just to be sure. - */ - disable_irq(IRQ_EXPANSIONCARD); - - /* - * Finally, reset the expansion card interrupt mask to - * all enable (RISC OS doesn't set this) - */ -#ifdef HAS_EXPMASK - have_expmask = ~0; - __raw_writeb(have_expmask, EXPMASK_ENABLE); -#endif - return 0; -} - -static struct notifier_block ecard_reboot_notifier = { - .notifier_call = ecard_reboot, -}; - - - static void ecard_readbytes(void *addr, ecard_t *ec, int off, int len, int useld) { @@ -1083,11 +1025,6 @@ { int slot, irqhw; - /* - * Register our reboot notifier - */ - register_reboot_notifier(&ecard_reboot_notifier); - #ifdef CONFIG_CPU_32 init_waitqueue_head(&ecard_wait); #endif @@ -1158,11 +1095,32 @@ return 0; } +/* + * Before rebooting, we must make sure that the expansion card is in a + * sensible state, so it can be re-detected. This means that the first + * page of the ROM must be visible. We call the expansion cards reset + * handler, if any. + */ +static void ecard_drv_shutdown(struct device *dev) +{ + struct expansion_card *ec = ECARD_DEV(dev); + struct ecard_driver *drv = ECARD_DRV(dev->driver); + struct ecard_request req; + + if (drv->shutdown) + drv->shutdown(ec); + ecard_release(ec); + req.req = req_reset; + req.ec = ec; + ecard_call(&req); +} + int ecard_register_driver(struct ecard_driver *drv) { drv->drv.bus = &ecard_bus_type; drv->drv.probe = ecard_drv_probe; drv->drv.remove = ecard_drv_remove; + drv->drv.shutdown = ecard_drv_shutdown; return driver_register(&drv->drv); } diff -Nru a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S --- a/arch/arm/kernel/entry-armv.S Mon Feb 24 12:42:23 2003 +++ b/arch/arm/kernel/entry-armv.S Thu Mar 6 07:52:20 2003 @@ -1028,8 +1028,10 @@ @ @ now branch to the relevant MODE handling routine @ - mov r13, #PSR_I_BIT | MODE_SVC - msr spsr_c, r13 @ switch to SVC_32 mode + mrs r13, cpsr + bic r13, r13, #MODE_MASK + orr r13, r13, #MODE_SVC + msr spsr, r13 @ switch to SVC_32 mode and lr, lr, #15 ldr lr, [pc, lr, lsl #2] diff -Nru a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S --- a/arch/arm/kernel/entry-common.S Sat Jul 27 12:49:37 2002 +++ b/arch/arm/kernel/entry-common.S Thu Mar 6 05:18:11 2003 @@ -75,9 +75,8 @@ * This is how we return from a fork. */ ENTRY(ret_from_fork) -#ifdef CONFIG_PREEMPT + ldr r0, [r0, #TI_TASK] bl schedule_tail -#endif get_thread_info tsk ldr r1, [tsk, #TI_FLAGS] @ check for syscall tracing mov why, #1 diff -Nru a/arch/arm/kernel/pm.c b/arch/arm/kernel/pm.c --- /dev/null Wed Dec 31 16:00:00 1969 +++ b/arch/arm/kernel/pm.c Thu Mar 6 07:59:45 2003 @@ -0,0 +1,126 @@ +/* + * linux/arch/arm/kernel/suspend.c + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License. + * + * This is the common support code for suspending an ARM machine. + * pm_do_suspend() is responsible for actually putting the CPU to + * sleep. + */ +#include +#include +#include +#include + +#include +#include + +int suspend(void) +{ + int ret; + + /* + * Suspend "legacy" devices. + */ + ret = pm_send_all(PM_SUSPEND, (void *)3); + if (ret != 0) + goto out; + + /* + * Tell LDM devices we're going to suspend. + */ + ret = device_suspend(4, SUSPEND_NOTIFY); + if (ret != 0) + goto resume_legacy; + + /* + * Disable, devices, and save state. + */ + device_suspend(4, SUSPEND_DISABLE); + device_suspend(4, SUSPEND_SAVE_STATE); + + /* + * Tell devices that they're going to be powered off. + */ + device_suspend(4, SUSPEND_POWER_DOWN); + + local_irq_disable(); + leds_event(led_stop); + + ret = pm_do_suspend(); + + leds_event(led_start); + local_irq_enable(); + + /* + * Tell devices that they now have power. + */ + device_resume(RESUME_POWER_ON); + + /* + * Restore the CPU frequency settings. + */ +#ifdef CONFIG_CPU_FREQ + cpufreq_restore(); +#endif + + /* + * Resume LDM devices. + */ + device_resume(RESUME_RESTORE_STATE); + device_resume(RESUME_ENABLE); + + resume_legacy: + /* + * Resume "legacy" devices. + */ + pm_send_all(PM_RESUME, (void *)0); + + out: + return ret; +} + +#ifdef CONFIG_SYSCTL +#include +#include + +/* + * This came from arch/arm/mach-sa1100/pm.c: + * Copyright (c) 2001 Cliff Brake + * with modifications by Nicolas Pitre and Russell King. + * + * ARGH! ACPI people defined CTL_ACPI in linux/acpi.h rather than + * linux/sysctl.h. + * + * This means our interface here won't survive long - it needs a new + * interface. Quick hack to get this working - use sysctl id 9999. + */ +#warning ACPI broke the kernel, this interface needs to be fixed up. +#define CTL_ACPI 9999 +#define ACPI_S1_SLP_TYP 19 + +static struct ctl_table pm_table[] = +{ + {ACPI_S1_SLP_TYP, "suspend", NULL, 0, 0600, NULL, (proc_handler *)&suspend}, + {0} +}; + +static struct ctl_table pm_dir_table[] = +{ + {CTL_ACPI, "pm", NULL, 0, 0555, pm_table}, + {0} +}; + +/* + * Initialize power interface + */ +static int __init pm_init(void) +{ + register_sysctl_table(pm_dir_table, 1); + return 0; +} + +fs_initcall(pm_init); + +#endif diff -Nru a/arch/arm/kernel/time.c b/arch/arm/kernel/time.c --- a/arch/arm/kernel/time.c Mon Feb 24 23:13:09 2003 +++ b/arch/arm/kernel/time.c Thu Mar 6 05:40:54 2003 @@ -200,6 +200,7 @@ static struct irqaction timer_irq = { .name = "timer", + .flags = SA_INTERRUPT, }; /* diff -Nru a/arch/arm/mach-integrator/Makefile b/arch/arm/mach-integrator/Makefile --- a/arch/arm/mach-integrator/Makefile Sat Dec 14 04:38:56 2002 +++ b/arch/arm/mach-integrator/Makefile Thu Mar 6 08:48:28 2003 @@ -4,10 +4,11 @@ # Object file lists. -obj-y := arch.o cpu.o irq.o mm.o time.o +obj-y := arch.o irq.o mm.o time.o obj-m := obj-n := obj- := obj-$(CONFIG_LEDS) += leds.o obj-$(CONFIG_PCI) += pci_v3.o pci.o +obj-$(CONFIG_CPU_FREQ_INTEGRATOR) += cpu.o diff -Nru a/arch/arm/mach-integrator/cpu.c b/arch/arm/mach-integrator/cpu.c --- a/arch/arm/mach-integrator/cpu.c Tue Jan 14 16:01:39 2003 +++ b/arch/arm/mach-integrator/cpu.c Thu Mar 6 11:27:03 2003 @@ -23,6 +23,8 @@ #include #include +static struct cpufreq_driver integrator_driver; + #define CM_ID (IO_ADDRESS(INTEGRATOR_HDR_BASE)+INTEGRATOR_HDR_ID_OFFSET) #define CM_OSC (IO_ADDRESS(INTEGRATOR_HDR_BASE)+INTEGRATOR_HDR_OSC_OFFSET) #define CM_STAT (IO_ADDRESS(INTEGRATOR_HDR_BASE)+INTEGRATOR_HDR_STAT_OFFSET) @@ -43,7 +45,6 @@ return 2000 * (vco.vdw + 8) / cc_divisor[vco.od] / factor; } -#ifdef CONFIG_CPU_FREQ /* * Divisor indexes in ascending divisor order */ @@ -69,21 +70,17 @@ return vco; } + /* - * Validate the speed in khz. If it is outside our - * range, then return the lowest. + * Validate the speed policy. */ -static int integrator_verify_speed(struct cpufreq_policy *policy) +static int integrator_verify_policy(struct cpufreq_policy *policy) { struct vco vco; - if (policy->max > policy->cpuinfo.max_freq) - policy->max = policy->cpuinfo.max_freq; - - if (policy->max < 12000) - policy->max = 12000; - if (policy->max > 160000) - policy->max = 160000; + cpufreq_verify_within_limits(policy, + policy->cpuinfo.min_freq, + policy->cpuinfo.max_freq); vco = freq_to_vco(policy->max, 1); @@ -92,12 +89,28 @@ if (vco.vdw > 152) vco.vdw = 152; - policy->min = policy->max = vco_to_freq(vco, 1); + policy->max = vco_to_freq(vco, 1); + + vco = freq_to_vco(policy->min, 1); + + if (vco.vdw < 4) + vco.vdw = 4; + if (vco.vdw > 152) + vco.vdw = 152; + + policy->min = vco_to_freq(vco, 1); + + cpufreq_verify_within_limits(policy, + policy->cpuinfo.min_freq, + policy->cpuinfo.max_freq); return 0; } -static int integrator_set_policy(struct cpufreq_policy *policy) + +static int integrator_set_target(struct cpufreq_policy *policy, + unsigned int target_freq, + unsigned int relation) { unsigned long cpus_allowed; int cpu = policy->cpu; @@ -121,9 +134,18 @@ cm_osc = __raw_readl(CM_OSC); vco.od = (cm_osc >> 8) & 7; vco.vdw = cm_osc & 255; - freqs.old = vco_to_freq(vco, 1); - freqs.new = target_freq; + + /* freq_to_vco rounds down -- so we need the next larger freq in + * case of CPUFREQ_RELATION_L. + */ + if (relation == CPUFREQ_RELATION_L) + target_freq += 1999; + if (target_freq > policy->max) + target_freq = policy->max; + vco = freq_to_vco(target_freq, 1); + freqs.new = vco_to_freq(vco, 1); + freqs.cpu = policy->cpu; if (freqs.old == freqs.new) { @@ -132,7 +154,6 @@ } cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); - vco = freq_to_vco(policy->max, 1); cm_osc = __raw_readl(CM_OSC); cm_osc &= 0xfffff800; @@ -152,80 +173,64 @@ return 0; } -static struct cpufreq_policy integrator_policy = { - .cpu = 0, - .policy = CPUFREQ_POLICY_POWERSAVE, - .cpuinfo = { - .max_freq = 160000, - .min_freq = 12000, - .transition_latency = CPUFREQ_ETERNAL, - }, -}; +static int integrator_cpufreq_init(struct cpufreq *policy) +{ + unsigned long cus_allowed; + unsigned int cpu = policy->cpu; + u_int cm_osc, cm_stat, mem_freq_khz; + struct vco vco; -static struct cpufreq_driver integrator_driver = { - .verify = integrator_verify_speed, - .setpolicy = integrator_set_policy, - .policy = &integrator_policy, - .name = "integrator", -}; -#endif + cpus_allowed = current->cpus_allowed; -static int __init integrator_cpu_init(void) -{ - struct cpufreq_policy *policies; - unsigned long cpus_allowed; - int cpu; + set_cpus_allowed(current, 1 << cpu); + BUG_ON(cpu != smp_processor_id()); - policies = kmalloc(sizeof(struct cpufreq_policy) * NR_CPUS, - GFP_KERNEL); - if (!policies) { - printk(KERN_ERR "CPU: unable to allocate policies structure\n"); - return -ENOMEM; - } + /* detect memory etc. */ + cm_stat = __raw_readl(CM_STAT); + cm_osc = __raw_readl(CM_OSC); + vco.od = (cm_osc >> 20) & 7; + vco.vdw = (cm_osc >> 12) & 255; + mem_freq_khz = vco_to_freq(vco, 2); + + printk(KERN_INFO "CPU%d: Module id: %d\n", cpu, cm_stat & 255); + printk(KERN_INFO "CPU%d: Memory clock = %d.%03d MHz\n", + cpu, mem_freq_khz / 1000, mem_freq_khz % 1000); - cpus_allowed = current->cpus_allowed; - for (cpu = 0; cpu < NR_CPUS; cpu++) { - u_int cm_osc, cm_stat, mem_freq_khz; - struct vco vco; - - if (!cpu_online(cpu)) - continue; - - set_cpus_allowed(current, 1 << cpu); - BUG_ON(cpu != smp_processor_id()); - - cm_stat = __raw_readl(CM_STAT); - cm_osc = __raw_readl(CM_OSC); - vco.od = (cm_osc >> 20) & 7; - vco.vdw = (cm_osc >> 12) & 255; - mem_freq_khz = vco_to_freq(vco, 2); - - printk(KERN_INFO "CPU%d: Module id: %d\n", cpu, cm_stat & 255); - printk(KERN_INFO "CPU%d: Memory clock = %d.%03d MHz\n", - cpu, mem_freq_khz / 1000, mem_freq_khz % 1000); - - vco.od = (cm_osc >> 8) & 7; - vco.vdw = cm_osc & 255; - - policies[cpu].cpu = cpu; - policies[cpu].policy = CPUFREQ_POLICY_POWERSAVE, - policies[cpu].cpuinfo.max_freq = 160000; - policies[cpu].cpuinfo.min_freq = 12000; - policies[cpu].cpuinfo.transition_latency = CPUFREQ_ETERNAL; - policies[cpu].min = - policies[cpu].max = vco_to_freq(vco, 1); - } + vco.od = (cm_osc >> 8) & 7; + vco.vdw = cm_osc & 255; - set_cpus_allowed(current, cpus_allowed); + /* set default policy and cpuinfo */ + policy->policy = CPUFREQ_POLICY_PERFORMANCE; + policy->cpuinfo.max_freq = 160000; + policy->cpuinfo.min_freq = 12000; + policy->cpuinfo.transition_latency = 1000; /* 1 ms, assumed */ + policy->cur = policy->min = policy->max = vco_to_freq(vco, 1); /* current freq */ -#ifdef CONFIG_CPU_FREQ - integrator_driver.policy = policies; - cpufreq_register(&integrator_driver); -#else - kfree(policies); -#endif + set_cpus_allowed(current, cpus_allowed); return 0; } -arch_initcall(integrator_cpu_init); +static struct cpufreq_driver integrator_driver = { + .verify = integrator_verify_policy, + .target = integrator_set_target, + .init = integrator_cpufreq_init, + .name = "integrator", +}; + +static int __init integrator_cpu_init(void) +{ + return cpufreq_register_driver(&integrator_driver); +} + +static void __exit integrator_cpu_exit(void) +{ + cpufreq_unregister_driver(&integrator_driver); +} + +MODULE_AUTHOR ("Russell M. King"); +MODULE_DESCRIPTION ("cpufreq driver for ARM Integrator CPUs"); +MODULE_LICENSE ("GPL"); + +module_init(integrator_cpu_init); +module_exit(integrator_cpu_exit); diff -Nru a/arch/arm/mach-sa1100/Kconfig b/arch/arm/mach-sa1100/Kconfig --- a/arch/arm/mach-sa1100/Kconfig Wed Nov 13 08:41:25 2002 +++ b/arch/arm/mach-sa1100/Kconfig Thu Mar 6 16:15:28 2003 @@ -326,6 +326,15 @@ # help # :: write me :: +config SA1100_SSP + tristate "Generic PIO SSP" + depends on ARCH_SA1100 + help + Say Y here to enable support for the generic PIO SSP driver. + This isn't for audio support, but for attached sensors and + other devices, eg for BadgePAD 4 sensor support, or Jornada + 720 touchscreen support. + config SA1100_USB tristate "SA1100 USB function support" depends on ARCH_SA1100 diff -Nru a/arch/arm/mach-sa1100/Makefile b/arch/arm/mach-sa1100/Makefile --- a/arch/arm/mach-sa1100/Makefile Mon Feb 3 14:19:35 2003 +++ b/arch/arm/mach-sa1100/Makefile Thu Mar 6 16:15:28 2003 @@ -9,15 +9,8 @@ obj- := led-y := leds.o -# This needs to be cleaned up. We probably need to have SA1100 -# and SA1110 config symbols. -ifeq ($(CONFIG_CPU_FREQ),y) -obj-$(CONFIG_SA1100_ASSABET) += cpu-sa1110.o -obj-$(CONFIG_SA1100_CERF) += cpu-sa1110.o -obj-$(CONFIG_SA1100_HACKKIT) += cpu-sa1110.o -obj-$(CONFIG_SA1100_LART) += cpu-sa1100.o -obj-$(CONFIG_SA1100_PT_SYSTEM3) += cpu-sa1110.o -endif +obj-$(CONFIG_CPU_FREQ_SA1100) += cpu-sa1100.o +obj-$(CONFIG_CPU_FREQ_SA1110) += cpu-sa1110.o # Specific board support obj-$(CONFIG_SA1100_ADSBITSY) += adsbitsy.o @@ -99,3 +92,4 @@ # Miscelaneous functions obj-$(CONFIG_PM) += pm.o sleep.o +obj-$(CONFIG_SA1100_SSP) += ssp.o diff -Nru a/arch/arm/mach-sa1100/cpu-sa1100.c b/arch/arm/mach-sa1100/cpu-sa1100.c --- a/arch/arm/mach-sa1100/cpu-sa1100.c Tue Jan 14 16:01:40 2003 +++ b/arch/arm/mach-sa1100/cpu-sa1100.c Thu Mar 6 11:27:04 2003 @@ -101,7 +101,7 @@ } sa1100_dram_regs_t; - +static struct cpufreq_driver sa1100_driver; static sa1100_dram_regs_t sa1100_dram_settings[] = { @@ -176,60 +176,73 @@ } } -static int sa1100_setspeed(struct cpufreq_policy *policy) +static int sa1100_target(struct cpufreq_policy *policy, + unsigned int target_freq, + unsigned int relation) { unsigned int cur = sa11x0_getspeed(); + unsigned int new_ppcr; + struct cpufreq_freqs freqs; + switch(relation){ + case CPUFREQ_RELATION_L: + new_ppcr = sa11x0_freq_to_ppcr(target_freq); + if (sa11x0_ppcr_to_freq(new_ppcr) > policy->max) + new_ppcr--; + break; + case CPUFREQ_RELATION_H: + new_ppcr = sa11x0_freq_to_ppcr(target_freq); + if ((sa11x0_ppcr_to_freq(new_ppcr) > target_freq) && + (sa11x0_ppcr_to_freq(new_ppcr - 1) >= policy->min)) + mew_ppcr--; + break; + } freqs.old = cur; - freqs.new = policy->max; + freqs.new = sa11x0_ppcr_to_freq(new_ppcr); freqs.cpu = 0; cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); - if (policy->max > cur) - sa1100_update_dram_timings(cur, policy->max); + if (freqs.new > cur) + sa1100_update_dram_timings(cur, freqs.new); - PPCR = sa11x0_freq_to_ppcr(policy->max); + PPCR = new_ppcr; - if (policy->max < cur) - sa1100_update_dram_timings(cur, policy->max); + if (freqs.new < cur) + sa1100_update_dram_timings(cur, freqs.new); cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); return 0; } -static struct cpufreq_policy sa1100_policy = { - .cpu = 0, - .policy = CPUFREQ_POLICY_POWERSAVE, - .cpuinfo = { - .max_freq = 287000, - .min_freq = 59000, - .transition_latency = CPUFREQ_ETERNAL, - }, -}; +static int __init sa1100_cpu_init(struct cpufreq_policy *policy) +{ + if (policy->cpu != 0) + return -EINVAL; + policy->cur = policy->min = policy->max = sa11x0_getspeed(); + policy->policy = CPUFREQ_POLICY_POWERSAVE; + policy->cpuinfo.min_freq = 59000; + policy->cpuinfo.max_freq = 287000; + policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL; + return 0; +} static struct cpufreq_driver sa1100_driver = { .verify = sa11x0_verify_speed, - .setpolicy = sa1100_setspeed, - .policy = &sa1100_policy, + .target = sa1100_target, + .init = sa1100_cpu_init, .name = "sa1100", }; static int __init sa1100_dram_init(void) { - int ret = -ENODEV; - - if ((processor_id & CPU_SA1100_MASK) == CPU_SA1100_ID) { - sa1100_driver.cpu_cur_freq[0] = - sa1100_policy.min = - sa1100_policy.max = sa11x0_getspeed(); - - ret = cpufreq_register(&sa1100_driver); - } - - return ret; + cpufreq_gov_userspace_init(); + if ((processor_id & CPU_SA1100_MASK) == CPU_SA1100_ID) + return cpufreq_register_driver(&sa1100_driver); + else + return -ENODEV; } arch_initcall(sa1100_dram_init); diff -Nru a/arch/arm/mach-sa1100/cpu-sa1110.c b/arch/arm/mach-sa1100/cpu-sa1110.c --- a/arch/arm/mach-sa1100/cpu-sa1110.c Tue Jan 14 16:01:40 2003 +++ b/arch/arm/mach-sa1100/cpu-sa1110.c Thu Mar 6 11:27:04 2003 @@ -32,6 +32,8 @@ #undef DEBUG +static struct cpufreq_driver sa1110_driver; + struct sdram_params { u_char rows; /* bits */ u_char cas_latency; /* cycles */ @@ -208,11 +210,11 @@ } /* - * Ok, set the CPU frequency. Since we've done the validation - * above, we can match for an exact frequency. If we don't find - * an exact match, we will to set the lowest frequency to be safe. + * Ok, set the CPU frequency. */ -static int sa1110_setspeed(struct cpufreq_policy *policy) +static int sa1110_target(struct cpufreq_policy *policy, + unsigned int target_freq, + unsigned int relation) { struct sdram_params *sdram = &sdram_params; struct cpufreq_freqs freqs; @@ -220,8 +222,25 @@ unsigned long flags; unsigned int ppcr, unused; - ppcr = sa11x0_freq_to_ppcr(policy->max); - sdram_calculate_timing(&sd, policy->max, sdram); + switch(relation){ + case CPUFREQ_RELATION_L: + ppcr = sa11x0_freq_to_ppcr(target_freq); + if (sa11x0_ppcr_to_freq(ppcr) > policy->max) + ppcr--; + break; + case CPUFREQ_RELATION_H: + ppcr = sa11x0_freq_to_ppcr(target_freq); + if (ppcr && (sa11x0_ppcr_to_freq(ppcr) > target_freq) && + (sa11x0_ppcr_to_freq(ppcr-1) >= policy->min)) + ppcr--; + break; + } + + freqs.old = sa11x0_getspeed(); + freqs.new = sa11x0_ppcr_to_freq(ppcr); + freqs.cpu = 0; + + sdram_calculate_timing(&sd, freqs.new, sdram); #if 0 /* @@ -240,10 +259,6 @@ sd.mdcas[2] = 0xaaaaaaaa; #endif - freqs.old = sa11x0_getspeed(); - freqs.new = policy->max; - freqs.cpu = 0; - cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); /* @@ -288,27 +303,29 @@ /* * Now, return the SDRAM refresh back to normal. */ - sdram_update_refresh(policy->max, sdram); + sdram_update_refresh(freqs.new, sdram); cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); return 0; } -static struct cpufreq_policy sa1110_policy = { - .cpu = 0, - .policy = CPUFREQ_POLICY_POWERSAVE, - .cpuinfo = { - .max_freq = 287000, - .min_freq = 59000, - .transition_latency = CPUFREQ_ETERNAL, - }, -}; +static int __init sa1110_cpu_init(struct cpufreq_policy *policy) +{ + if (policy->cpu != 0) + return -EINVAL; + policy->cur = policy->min = policy->max = sa11x0_getspeed(); + policy->policy = CPUFREQ_POLICY_POWERSAVE; + policy->cpuinfo.min_freq = 59000; + policy->cpuinfo.max_freq = 287000; + policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL; + return 0; +} static struct cpufreq_driver sa1110_driver = { - .verify = sa11x0_verify_speed, - .setpolicy = sa1110_setspeed, - .policy = &sa1110_policy, + .verify = sa11x0_verify_speed, + .target = sa1110_target, + .init = sa1110_cpu_init, .name = "sa1110", }; @@ -331,15 +348,11 @@ sdram->tck, sdram->trcd, sdram->trp, sdram->twr, sdram->refresh, sdram->cas_latency); + cpufreq_gov_userspace_init(); + memcpy(&sdram_params, sdram, sizeof(sdram_params)); - sa1110_driver.cpu_cur_freq[0] = - sa1110_policy.min = - sa1110_policy.max = sa11x0_getspeed(); - - sa1110_setspeed(&sa1110_policy); - - return cpufreq_register(&sa1110_driver); + return cpufreq_register_driver(&sa1110_driver); } return 0; diff -Nru a/arch/arm/mach-sa1100/generic.c b/arch/arm/mach-sa1100/generic.c --- a/arch/arm/mach-sa1100/generic.c Fri Dec 13 06:22:36 2002 +++ b/arch/arm/mach-sa1100/generic.c Thu Mar 6 12:25:44 2003 @@ -48,33 +48,48 @@ 2802 /* 280.2 MHz */ }; -#ifdef CONFIG_CPU_FREQ +#if defined(CONFIG_CPU_FREQ_SA1100) || defined(CONFIG_CPU_FREQ_SA1110) +/* rounds up(!) */ unsigned int sa11x0_freq_to_ppcr(unsigned int khz) { int i; khz /= 100; - for (i = NR_FREQS - 1; i > 0; i--) - if (cclk_frequency_100khz[i] <= khz) + for (i = 0; i < NR_FREQS; i++) + if (cclk_frequency_100khz[i] >= khz) break; return i; } -/* - * Validate the policy. We aren't able to do any fancy in-kernel - * scaling, so we force min=max, and set the policy to "performance". - * If we can't generate the precise frequency requested, round it up. +unsigned int sa11x0_ppcr_to_freq(unsigned int idx) +{ + unsigned int freq = 0; + if (idx < NR_FREQS) + freq = cclk_frequency_100khz[idx] * 100; + return freq; +} + + +/* make sure that only the "userspace" governor is run -- anything else wouldn't make sense on + * this platform, anyway. */ int sa11x0_verify_speed(struct cpufreq_policy *policy) { - if (policy->max > policy->cpuinfo.max_freq) - policy->max = policy->cpuinfo.max_freq; + unsigned int tmp; + if (policy->cpu) + return -EINVAL; + + cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq, policy->cpuinfo.max_freq); + + /* make sure that at least one frequency is within the policy */ + tmp = cclk_frequency_100khz[sa11x0_freq_to_ppcr(policy->min)] * 100; + if (tmp > policy->max) + policy->max = tmp; + + cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq, policy->cpuinfo.max_freq); - policy->max = cclk_frequency_100khz[sa11x0_freq_to_ppcr(policy->max)] * 100; - policy->min = policy->max; - policy->policy = CPUFREQ_POLICY_POWERSAVE; return 0; } diff -Nru a/arch/arm/mach-sa1100/generic.h b/arch/arm/mach-sa1100/generic.h --- a/arch/arm/mach-sa1100/generic.h Sun Nov 24 15:14:21 2002 +++ b/arch/arm/mach-sa1100/generic.h Thu Mar 6 08:48:29 2003 @@ -23,3 +23,4 @@ extern unsigned int sa11x0_freq_to_ppcr(unsigned int khz); extern int sa11x0_verify_speed(struct cpufreq_policy *policy); extern unsigned int sa11x0_getspeed(void); +extern unsigned int sa11x0_ppcr_to_freq(unsigned int idx); diff -Nru a/arch/arm/mach-sa1100/irq.c b/arch/arm/mach-sa1100/irq.c --- a/arch/arm/mach-sa1100/irq.c Sun Mar 2 23:32:23 2003 +++ b/arch/arm/mach-sa1100/irq.c Thu Mar 6 12:33:33 2003 @@ -211,6 +211,99 @@ .end = 0x9005ffff, }; +struct sa1100irq_state { + unsigned int saved; + unsigned int icmr; + unsigned int iclr; + unsigned int iccr; +}; + +static int sa1100irq_suspend(struct device *dev, u32 state, u32 level) +{ + struct sa1100irq_state *st; + + if (!dev->saved_state && level == SUSPEND_NOTIFY) + dev->saved_state = kmalloc(sizeof(struct sa1100irq_state), + GFP_KERNEL); + if (!dev->saved_state) + return -ENOMEM; + + if (level == SUSPEND_POWER_DOWN) { + st = (struct sa1100irq_state *)dev->saved_state; + + st->saved = 1; + st->icmr = ICMR; + st->iclr = ICLR; + st->iccr = ICCR; + + /* + * Disable all GPIO-based interrupts. + */ + ICMR &= ~(IC_GPIO11_27|IC_GPIO10|IC_GPIO9|IC_GPIO8|IC_GPIO7| + IC_GPIO6|IC_GPIO5|IC_GPIO4|IC_GPIO3|IC_GPIO2| + IC_GPIO1|IC_GPIO0); + + /* + * Set the appropriate edges for wakeup. + */ + GRER = PWER & GPIO_IRQ_rising_edge; + GFER = PWER & GPIO_IRQ_falling_edge; + + /* + * Clear any pending GPIO interrupts. + */ + GEDR = GEDR; + } + return 0; +} + +static int sa1100irq_resume(struct device *dev, u32 level) +{ + struct sa1100irq_state *st; + + if (level == RESUME_POWER_ON) { + st = (struct sa1100irq_state *)dev->saved_state; + dev->saved_state = NULL; + + if (st->saved) { + ICCR = st->iccr; + ICLR = st->iclr; + + GRER = GPIO_IRQ_rising_edge & GPIO_IRQ_mask; + GFER = GPIO_IRQ_falling_edge & GPIO_IRQ_mask; + + ICMR = st->icmr; + } + + kfree(st); + } + return 0; +} + +static struct device_driver sa1100irq_driver = { + .name = "sa11x0-irq", + .bus = &system_bus_type, + .suspend = sa1100irq_suspend, + .resume = sa1100irq_resume, +}; + +static struct sys_device sa1100irq_device = { + .name = "irq", + .id = 0, + .dev = { + .name = "Intel SA11x0 [Interrupt Controller]", + .driver = &sa1100irq_driver, + }, +}; + +static int __init sa1100irq_init_devicefs(void) +{ + driver_register(&sa1100irq_driver); + return sys_device_register(&sa1100irq_device); +} + +device_initcall(sa1100irq_init_devicefs); + void __init sa1100_init_irq(void) { unsigned int irq; diff -Nru a/arch/arm/mach-sa1100/pm.c b/arch/arm/mach-sa1100/pm.c --- a/arch/arm/mach-sa1100/pm.c Sun Nov 17 07:31:13 2002 +++ b/arch/arm/mach-sa1100/pm.c Thu Mar 6 08:08:20 2003 @@ -22,25 +22,12 @@ * 2002-05-27: Nicolas Pitre Killed sleep.h and the kmalloced save array. * Storage is local on the stack now. */ -#include -#include -#include -#include -#include #include -#include -#include +#include #include #include #include -#include - - -/* - * Debug macros - */ -#undef DEBUG extern void sa1100_cpu_suspend(void); extern void sa1100_cpu_resume(void); @@ -58,10 +45,9 @@ SLEEP_SAVE_OSCR, SLEEP_SAVE_OIER, SLEEP_SAVE_OSMR0, SLEEP_SAVE_OSMR1, SLEEP_SAVE_OSMR2, SLEEP_SAVE_OSMR3, - SLEEP_SAVE_GPDR, SLEEP_SAVE_GRER, SLEEP_SAVE_GFER, SLEEP_SAVE_GAFR, + SLEEP_SAVE_GPDR, SLEEP_SAVE_GAFR, SLEEP_SAVE_PPDR, SLEEP_SAVE_PPSR, SLEEP_SAVE_PPAR, SLEEP_SAVE_PSDR, - SLEEP_SAVE_ICMR, SLEEP_SAVE_Ser1SDCR0, SLEEP_SAVE_SIZE @@ -72,10 +58,6 @@ { unsigned long sleep_save[SLEEP_SAVE_SIZE]; - local_irq_disable(); - - leds_event(led_stop); - /* preserve current time */ RCNR = xtime.tv_sec; @@ -88,8 +70,6 @@ SAVE(OIER); SAVE(GPDR); - SAVE(GRER); - SAVE(GFER); SAVE(GAFR); SAVE(PPDR); @@ -99,13 +79,6 @@ SAVE(Ser1SDCR0); - SAVE(ICMR); - - /* ... maybe a global variable initialized by arch code to set this? */ - GRER = PWER; - GFER = 0; - GEDR = GEDR; - /* Clear previous reset status */ RCSR = RCSR_HWR | RCSR_SWR | RCSR_WDR | RCSR_SMR; @@ -115,22 +88,23 @@ /* go zzz */ sa1100_cpu_suspend(); - /* ensure not to come back here if it wasn't intended */ + /* + * Ensure not to come back here if it wasn't intended + */ PSPR = 0; -#ifdef DEBUG - printk(KERN_DEBUG "*** made it back from resume\n"); -#endif + /* + * Ensure interrupt sources are disabled; we will re-init + * the interrupt subsystem via the device manager. + */ + ICLR = 0; + ICCR = 1; + ICMR = 0; /* restore registers */ RESTORE(GPDR); - RESTORE(GRER); - RESTORE(GFER); RESTORE(GAFR); - /* clear any edge detect bit */ - GEDR = GEDR; - RESTORE(PPDR); RESTORE(PPSR); RESTORE(PPAR); @@ -138,6 +112,9 @@ RESTORE(Ser1SDCR0); + /* + * Clear the peripheral sleep-hold bit. + */ PSSR = PSSR_PH; RESTORE(OSMR0); @@ -147,24 +124,9 @@ RESTORE(OSCR); RESTORE(OIER); - ICLR = 0; - ICCR = 1; - RESTORE(ICMR); - /* restore current time */ xtime.tv_sec = RCNR; - leds_event(led_start); - - local_irq_enable(); - - /* - * Restore the CPU frequency settings. - */ -#ifdef CONFIG_CPU_FREQ - cpufreq_restore(); -#endif - return 0; } @@ -172,78 +134,3 @@ { return virt_to_phys(sp); } - -#ifdef CONFIG_SYSCTL -/* - * ARGH! ACPI people defined CTL_ACPI in linux/acpi.h rather than - * linux/sysctl.h. - * - * This means our interface here won't survive long - it needs a new - * interface. Quick hack to get this working - use sysctl id 9999. - */ -#warning ACPI broke the kernel, this interface needs to be fixed up. -#define CTL_ACPI 9999 -#define ACPI_S1_SLP_TYP 19 - -/* - * Send us to sleep. - */ -static int sysctl_pm_do_suspend(void) -{ - int retval; - - /* - * Suspend "legacy" devices. - */ - retval = pm_send_all(PM_SUSPEND, (void *)3); - if (retval == 0) { - /* - * Suspend LDM devices. - */ - device_suspend(4, SUSPEND_NOTIFY); - device_suspend(4, SUSPEND_SAVE_STATE); - device_suspend(4, SUSPEND_DISABLE); - - retval = pm_do_suspend(); - - /* - * Resume LDM devices. - */ - device_resume(RESUME_RESTORE_STATE); - device_resume(RESUME_ENABLE); - - /* - * Resume "legacy" devices. - */ - pm_send_all(PM_RESUME, (void *)0); - } - - return retval; -} - -static struct ctl_table pm_table[] = -{ - {ACPI_S1_SLP_TYP, "suspend", NULL, 0, 0600, NULL, (proc_handler *)&sysctl_pm_do_suspend}, - {0} -}; - -static struct ctl_table pm_dir_table[] = -{ - {CTL_ACPI, "pm", NULL, 0, 0555, pm_table}, - {0} -}; - -/* - * Initialize power interface - */ -static int __init pm_init(void) -{ - register_sysctl_table(pm_dir_table, 1); - return 0; -} - -fs_initcall(pm_init); - -#endif - -EXPORT_SYMBOL(pm_do_suspend); diff -Nru a/arch/arm/mach-sa1100/ssp.c b/arch/arm/mach-sa1100/ssp.c --- /dev/null Wed Dec 31 16:00:00 1969 +++ b/arch/arm/mach-sa1100/ssp.c Thu Mar 6 16:15:28 2003 @@ -0,0 +1,208 @@ +/* + * linux/arch/arm/mach-sa1100/ssp.c + * + * Copyright (C) 2003 Russell King. + * + * 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. + * + * Generic SSP driver. This provides the generic core for simple + * IO-based SSP applications. + */ +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +static void ssp_interrupt(int irq, void *dev_id, struct pt_regs *regs) +{ + unsigned int status = Ser4SSSR; + + if (status & SSSR_ROR) { + printk(KERN_WARNING "SSP: receiver overrun\n"); + } + + Ser4SSSR = SSSR_ROR; +} + +/** + * ssp_write_word - write a word to the SSP port + * @data: 16-bit, MSB justified data to write. + * + * Wait for a free entry in the SSP transmit FIFO, and write a data + * word to the SSP port. + * + * The caller is expected to perform the necessary locking. + * + * Returns: + * %-ETIMEDOUT timeout occurred (for future) + * 0 success + */ +int ssp_write_word(u16 data) +{ + while (!(Ser4SSSR & SSSR_TNF)) + cpu_relax(); + + Ser4SSDR = data; + + return 0; +} + +/** + * ssp_read_word - read a word from the SSP port + * + * Wait for a data word in the SSP receive FIFO, and return the + * received data. Data is LSB justified. + * + * Note: Currently, if data is not expected to be received, this + * function will wait for ever. + * + * The caller is expected to perform the necessary locking. + * + * Returns: + * %-ETIMEDOUT timeout occurred (for future) + * 16-bit data success + */ +int ssp_read_word(void) +{ + while (!(Ser4SSSR & SSSR_RNE)) + cpu_relax(); + + return Ser4SSDR; +} + +/** + * ssp_flush - flush the transmit and receive FIFOs + * + * Wait for the SSP to idle, and ensure that the receive FIFO + * is empty. + * + * The caller is expected to perform the necessary locking. + */ +void ssp_flush(void) +{ + do { + while (Ser4SSSR & SSSR_RNE) { + (void) Ser4SSDR; + } + } while (Ser4SSSR & SSSR_BSY); +} + +/** + * ssp_enable - enable the SSP port + * + * Turn on the SSP port. + */ +void ssp_enable(void) +{ + Ser4SSCR0 |= SSCR0_SSE; +} + +/** + * ssp_disable - shut down the SSP port + * + * Turn off the SSP port, optionally powering it down. + */ +void ssp_disable(void) +{ + Ser4SSCR0 &= ~SSCR0_SSE; +} + +/** + * ssp_save_state - save the SSP configuration + * @ssp: pointer to structure to save SSP configuration + * + * Save the configured SSP state for suspend. + */ +void ssp_save_state(struct ssp_state *ssp) +{ + ssp->cr0 = Ser4SSCR0; + ssp->cr1 = Ser4SSCR1; + + Ser4SSCR0 &= ~SSCR0_SSE; +} + +/** + * ssp_restore_state - restore a previously saved SSP configuration + * @ssp: pointer to configuration saved by ssp_save_state + * + * Restore the SSP configuration saved previously by ssp_save_state. + */ +void ssp_restore_state(struct ssp_state *ssp) +{ + Ser4SSSR = SSSR_ROR; + + Ser4SSCR0 = ssp->cr0 & ~SSCR0_SSE; + Ser4SSCR1 = ssp->cr1; + Ser4SSCR0 = ssp->cr0; +} + +/** + * ssp_init - setup the SSP port + * + * initialise and claim resources for the SSP port. + * + * Returns: + * %-ENODEV if the SSP port is unavailable + * %-EBUSY if the resources are already in use + * %0 on success + */ +int ssp_init(void) +{ + int ret; + + if (!(PPAR & PPAR_SPR) && (Ser4MCCR0 & MCCR0_MCE)) + return -ENODEV; + + if (!request_mem_region(__PREG(Ser4SSCR0), 0x18, "SSP")) { + return -EBUSY; + } + + Ser4SSSR = SSSR_ROR; + + ret = request_irq(IRQ_Ser4SSP, ssp_interrupt, 0, "SSP", NULL); + if (ret) + goto out_region; + + return 0; + + out_region: + release_mem_region(__PREG(Ser4SSCR0), 0x18); + return ret; +} + +/** + * ssp_exit - undo the effects of ssp_init + * + * release and free resources for the SSP port. + */ +void ssp_exit(void) +{ + Ser4SSCR0 &= ~SSCR0_SSE; + + free_irq(IRQ_Ser4SSP, NULL); + release_mem_region(__PREG(Ser4SSCR0), 0x18); +} + +MODULE_AUTHOR("Russell King"); +MODULE_DESCRIPTION("SA11x0 SSP PIO driver"); +MODULE_LICENSE("GPL"); + +EXPORT_SYMBOL(ssp_write_word); +EXPORT_SYMBOL(ssp_read_word); +EXPORT_SYMBOL(ssp_flush); +EXPORT_SYMBOL(ssp_enable); +EXPORT_SYMBOL(ssp_disable); +EXPORT_SYMBOL(ssp_save_state); +EXPORT_SYMBOL(ssp_restore_state); +EXPORT_SYMBOL(ssp_init); +EXPORT_SYMBOL(ssp_exit); diff -Nru a/arch/arm/mach-sa1100/system3.c b/arch/arm/mach-sa1100/system3.c --- a/arch/arm/mach-sa1100/system3.c Sun Nov 17 07:31:13 2002 +++ b/arch/arm/mach-sa1100/system3.c Thu Mar 6 08:48:29 2003 @@ -213,11 +213,17 @@ static int sdram_notifier(struct notifier_block *nb, unsigned long event, void *data) { + struct cpufreq_policy *policy = data; switch (event) { - case CPUFREQ_MINMAX: - cpufreq_updateminmax(data, 147500, 206000); + case CPUFREQ_ADJUST: + case CPUFREQ_INCOMPATIBLE: + cpufreq_verify_within_limits(policy, 147500, 206000); + break; + case CPUFREQ_NOTIFY: + if ((policy->min < 147500) || + (policy->max > 206000)) + panic("cpufreq failed to limit the speed\n"); break; - } return 0; } @@ -405,7 +411,7 @@ goto DONE; } -#if defined( CONFIG_CPU_FREQ ) +#ifdef CONFIG_CPU_FREQ ret = cpufreq_register_notifier(&system3_clkchg_block); if ( ret != 0 ) { printk( KERN_WARNING"PT Digital Board: could not register clock scale callback\n" ); diff -Nru a/arch/arm/mm/fault-common.c b/arch/arm/mm/fault-common.c --- a/arch/arm/mm/fault-common.c Sun Jan 12 09:11:08 2003 +++ b/arch/arm/mm/fault-common.c Thu Mar 6 08:19:03 2003 @@ -342,20 +342,20 @@ struct pt_regs *regs) { struct task_struct *tsk; - unsigned int offset; + unsigned int index; pgd_t *pgd, *pgd_k; pmd_t *pmd, *pmd_k; if (addr < TASK_SIZE) return do_page_fault(addr, fsr, regs); - offset = __pgd_offset(addr); + index = pgd_index(addr); /* * FIXME: CP15 C1 is write only on ARMv3 architectures. */ - pgd = cpu_get_pgd() + offset; - pgd_k = init_mm.pgd + offset; + pgd = cpu_get_pgd() + index; + pgd_k = init_mm.pgd + index; if (pgd_none(*pgd_k)) goto bad_area; diff -Nru a/arch/arm/tools/mach-types b/arch/arm/tools/mach-types --- a/arch/arm/tools/mach-types Thu Jan 16 06:52:35 2003 +++ b/arch/arm/tools/mach-types Thu Mar 6 06:57:42 2003 @@ -6,7 +6,7 @@ # To add an entry into this database, please see Documentation/arm/README, # or contact rmk@arm.linux.org.uk # -# Last update: Mon Jan 13 22:55:16 2003 +# Last update: Wed Mar 5 22:11:59 2003 # # machine_is_xxx CONFIG_xxxx MACH_TYPE_xxx number # @@ -228,7 +228,7 @@ arnold SA1100_ARNOLD ARNOLD 217 psiboard SA1100_PSIBOARD PSIBOARD 218 jz8028 ARCH_JZ8028 JZ8028 219 -ipaq3 ARCH_IPAQ3 IPAQ3 220 +h5400 ARCH_IPAQ3 IPAQ3 220 forte SA1100_FORTE FORTE 221 acam SA1100_ACAM ACAM 222 abox SA1100_ABOX ABOX 223 @@ -259,7 +259,7 @@ stork_egg ARCH_STORK_EGG STORK_EGG 248 wismo SA1100_WISMO WISMO 249 ezlinx ARCH_EZLINX EZLINX 250 -at91rm9200 ARCH_AT91 AT91 251 +at91 ARCH_AT91 AT91 251 orion ARCH_ORION ORION 252 neptune ARCH_NEPTUNE NEPTUNE 253 hackkit SA1100_HACKKIT HACKKIT 254 @@ -281,3 +281,27 @@ siren ARCH_SIREN SIREN 270 greenlake ARCH_GREENLAKE GREENLAKE 271 argus ARCH_ARGUS ARGUS 272 +combadge SA1100_COMBADGE COMBADGE 273 +rokepxa ARCH_ROKEPXA ROKEPXA 274 +cintegrator ARCH_CINTEGRATOR CINTEGRATOR 275 +guidea07 ARCH_GUIDEA07 GUIDEA07 276 +tat257 ARCH_TAT257 TAT257 277 +igp2425 ARCH_IGP2425 IGP2425 278 +bluegrama ARCH_BLUEGRAMMA BLUEGRAMMA 279 +ipod ARCH_IPOD IPOD 280 +adsbitsyx ARCH_ADSBITSYX ADSBITSYX 281 +trizeps2 ARCH_TRIZEPS2 TRIZEPS2 282 +viper ARCH_VIPER VIPER 283 +adsbitsyplus SA1100_ADSBITSYPLUS ADSBITSYPLUS 284 +adsagc SA1100_ADSAGC ADSAGC 285 +stp7312 ARCH_STP7312 STP7312 286 +nx_phnx ARCH_PXA255 PXA255 287 +wep_ep250 ARCH_WEP_EP250 WEP_EP250 288 +inhandelf3 ARCH_INHANDELF3 INHANDELF3 289 +adi_coyote ARCH_ADI_COYOTE ADI_COYOTE 290 +iyonix ARCH_IYONIX IYONIX 291 +damicam_sa1110 ARCH_DAMICAM_SA1110 DAMICAM_SA1110 292 +meg03 ARCH_MEG03 MEG03 293 +pxa_whitechapel ARCH_PXA_WHITECHAPEL PXA_WHITECHAPEL 294 +nwsc ARCH_NWSC NWSC 295 +nwlarm ARCH_NWLARM NWLARM 296 diff -Nru a/arch/arm/vmlinux-armo.lds.in b/arch/arm/vmlinux-armo.lds.in --- a/arch/arm/vmlinux-armo.lds.in Wed Jan 15 09:48:42 2003 +++ b/arch/arm/vmlinux-armo.lds.in Fri Feb 14 14:36:57 2003 @@ -38,6 +38,9 @@ *(.initcall6.init) *(.initcall7.init) __initcall_end = .; + __con_initcall_start = .; + *(.con_initcall.init) + __con_initcall_end = .; . = ALIGN(32768); __init_end = .; } diff -Nru a/arch/arm/vmlinux-armv.lds.in b/arch/arm/vmlinux-armv.lds.in --- a/arch/arm/vmlinux-armv.lds.in Tue Feb 11 08:24:17 2003 +++ b/arch/arm/vmlinux-armv.lds.in Wed Feb 19 07:21:37 2003 @@ -45,6 +45,9 @@ *(.initcall6.init) *(.initcall7.init) __initcall_end = .; + __con_initcall_start = .; + *(.con_initcall.init) + __con_initcall_end = .; . = ALIGN(32); __initramfs_start = .; usr/built-in.o(.init.ramfs) diff -Nru a/arch/cris/vmlinux.lds.S b/arch/cris/vmlinux.lds.S --- a/arch/cris/vmlinux.lds.S Wed Jan 15 09:48:42 2003 +++ b/arch/cris/vmlinux.lds.S Fri Feb 14 14:37:05 2003 @@ -69,7 +69,12 @@ *(.initcall6.init); *(.initcall7.init); __initcall_end = .; - + } + .con_initcall.init : { + __con_initcall_start = .; + *(.con_initcall.init) + __con_initcall_end = .; + /* We fill to the next page, so we can discard all init pages without needing to consider what payload might be appended to the kernel image. */ diff -Nru a/arch/i386/Makefile b/arch/i386/Makefile --- a/arch/i386/Makefile Fri Feb 21 19:34:09 2003 +++ b/arch/i386/Makefile Tue Mar 4 15:09:44 2003 @@ -92,7 +92,8 @@ boot := arch/i386/boot -.PHONY: zImage bzImage compressed zlilo bzlilo zdisk bzdisk install +.PHONY: zImage bzImage compressed zlilo bzlilo \ + zdisk bzdisk fdimage fdimage144 fdimage288 install all: bzImage @@ -110,8 +111,8 @@ zdisk bzdisk: vmlinux $(Q)$(MAKE) $(build)=$(boot) BOOTIMAGE=$(BOOTIMAGE) zdisk -install: vmlinux - $(Q)$(MAKE) $(build)=$(boot) BOOTIMAGE=$(BOOTIMAGE) install +install fdimage fdimage144 fdimage288: vmlinux + $(Q)$(MAKE) $(build)=$(boot) BOOTIMAGE=$(BOOTIMAGE) $@ archclean: $(Q)$(MAKE) $(clean)=arch/i386/boot @@ -122,5 +123,8 @@ echo ' (your) ~/bin/installkernel or' echo ' (distribution) /sbin/installkernel or' echo ' install to $$(INSTALL_PATH) and run lilo' + echo ' bzdisk - Create a boot floppy in /dev/fd0' + echo ' fdimage - Create a boot floppy image' endef +CLEAN_FILES += arch/$(ARCH)/boot/fdimage arch/$(ARCH)/boot/mtools.conf diff -Nru a/arch/i386/boot/Makefile b/arch/i386/boot/Makefile --- a/arch/i386/boot/Makefile Mon Dec 30 23:11:35 2002 +++ b/arch/i386/boot/Makefile Tue Mar 4 15:09:44 2003 @@ -62,8 +62,36 @@ $(Q)$(MAKE) -f scripts/Makefile.build obj=$(obj)/compressed \ IMAGE_OFFSET=$(IMAGE_OFFSET) $@ -zdisk: $(BOOTIMAGE) - dd bs=8192 if=$(BOOTIMAGE) of=/dev/fd0 +# Set this if you want to pass append arguments to the zdisk/fdimage kernel +FDARGS = + +$(obj)/mtools.conf: $(obj)/mtools.conf.in + sed -e 's|@OBJ@|$(obj)|g' < $< > $@ + +# This requires write access to /dev/fd0 +zdisk: $(BOOTIMAGE) $(obj)/mtools.conf + MTOOLSRC=$(src)/mtools.conf mformat a: ; sync + syslinux /dev/fd0 ; sync + echo 'default linux $(FDARGS)' | \ + MTOOLSRC=$(src)/mtools.conf mcopy - a:syslinux.cfg + MTOOLSRC=$(src)/mtools.conf mcopy $(BOOTIMAGE) a:linux ; sync + +# These require being root or having syslinux 2.02 or higher installed +fdimage fdimage144: $(BOOTIMAGE) $(src)/mtools.conf + dd if=/dev/zero of=$(obj)/fdimage bs=1024 count=1440 + MTOOLSRC=$(src)/mtools.conf mformat v: ; sync + syslinux $(obj)/fdimage ; sync + echo 'default linux $(FDARGS)' | \ + MTOOLSRC=$(src)/mtools.conf mcopy - v:syslinux.cfg + MTOOLSRC=$(src)/mtools.conf mcopy $(BOOTIMAGE) v:linux ; sync + +fdimage288: $(BOOTIMAGE) $(src)/mtools.conf + dd if=/dev/zero of=$(obj)/fdimage bs=1024 count=2880 + MTOOLSRC=$(src)/mtools.conf mformat w: ; sync + syslinux $(obj)/fdimage ; sync + echo 'default linux $(FDARGS)' | \ + MTOOLSRC=$(src)/mtools.conf mcopy - w:syslinux.cfg + MTOOLSRC=$(src)/mtools.conf mcopy $(BOOTIMAGE) w:linux ; sync zlilo: $(BOOTIMAGE) if [ -f $(INSTALL_PATH)/vmlinuz ]; then mv $(INSTALL_PATH)/vmlinuz $(INSTALL_PATH)/vmlinuz.old; fi diff -Nru a/arch/i386/boot/bootsect.S b/arch/i386/boot/bootsect.S --- a/arch/i386/boot/bootsect.S Fri Feb 21 06:03:16 2003 +++ b/arch/i386/boot/bootsect.S Tue Mar 4 15:10:25 2003 @@ -4,29 +4,13 @@ * modified by Drew Eckhardt * modified by Bruce Evans (bde) * modified by Chris Noe (May 1999) (as86 -> gas) - * - * 360k/720k disk support: Andrzej Krzysztofowicz + * gutted by H. Peter Anvin (Jan 2003) * * BIG FAT NOTE: We're in real mode using 64k segments. Therefore segment * addresses must be multiplied by 16 to obtain their respective linear * addresses. To avoid confusion, linear addresses are written using leading * hex while segment addresses are written as segment:offset. * - * bde - should not jump blindly, there may be systems with only 512K low - * memory. Use int 0x12 to get the top of memory, etc. - * - * It then loads 'setup' directly after itself (0x90200), and the system - * at 0x10000, using BIOS interrupts. - * - * NOTE! currently system is at most (8*65536-4096) bytes long. This should - * be no problem, even in the future. I want to keep it simple. This 508 kB - * kernel size should be enough, especially as this doesn't contain the - * buffer cache as in minix (and especially now that the kernel is - * compressed :-) - * - * The loader has been made as simple as possible, and continuous - * read errors will result in a unbreakable loop. Reboot by hand. It - * loads pretty fast by getting whole tracks at a time whenever possible. */ #include @@ -59,359 +43,51 @@ .global _start _start: -# First things first. Move ourself from 0x7C00 -> 0x90000 and jump there. + # Normalize the start address + jmpl $BOOTSEG, $start2 - movw $BOOTSEG, %ax - movw %ax, %ds # %ds = BOOTSEG - movw $INITSEG, %ax - movw %ax, %es # %ax = %es = INITSEG - movw $256, %cx - subw %si, %si - subw %di, %di - cld - rep - movsw - ljmp $INITSEG, $go - -# bde - changed 0xff00 to 0x4000 to use debugger at 0x6400 up (bde). We -# wouldn't have to worry about this if we checked the top of memory. Also -# my BIOS can be configured to put the wini drive tables in high memory -# instead of in the vector table. The old stack might have clobbered the -# drive table. - -go: movw $0x4000-12, %di # 0x4000 is an arbitrary value >= - # length of bootsect + length of - # setup + room for stack; - # 12 is disk parm size. - movw %ax, %ds # %ax and %es already contain INITSEG +start2: + movw %cs, %ax + movw %ax, %ds + movw %ax, %es movw %ax, %ss - movw %di, %sp # put stack at INITSEG:0x4000-12. + movw $0x7c00, %sp + sti + cld -# Many BIOS's default disk parameter tables will not recognize -# multi-sector reads beyond the maximum sector number specified -# in the default diskette parameter tables - this may mean 7 -# sectors in some cases. -# -# Since single sector reads are slow and out of the question, -# we must take care of this by creating new parameter tables -# (for the first disk) in RAM. We will set the maximum sector -# count to 36 - the most we will encounter on an ED 2.88. -# -# High doesn't hurt. Low does. -# -# Segments are as follows: %cs = %ds = %es = %ss = INITSEG, %fs = 0, -# and %gs is unused. - - movw %cx, %fs # %fs = 0 - movw $0x78, %bx # %fs:%bx is parameter table address - pushw %ds - ldsw %fs:(%bx), %si # %ds:%si is source - movb $6, %cl # copy 12 bytes - pushw %di # %di = 0x4000-12. - rep # don't worry about cld - movsw # already done above - popw %di - popw %ds - movb $36, 0x4(%di) # patch sector count - movw %di, %fs:(%bx) - movw %es, %fs:2(%bx) - -# Get disk drive parameters, specifically number of sectors/track. - -# It seems that there is no BIOS call to get the number of sectors. -# Guess 36 sectors if sector 36 can be read, 18 sectors if sector 18 -# can be read, 15 if sector 15 can be read. Otherwise guess 9. -# Note that %cx = 0 from rep movsw above. + movw $bugger_off_msg, %si - movw $disksizes, %si # table of sizes to try -probe_loop: +msg_loop: lodsb - cbtw # extend to word - movw %ax, sectors - cmpw $disksizes+4, %si - jae got_sectors # If all else fails, try 9 - - xchgw %cx, %ax # %cx = track and sector - xorw %dx, %dx # drive 0, head 0 - movw $0x0200, %bx # address = 512, in INITSEG (%es = %cs) - movw $0x0201, %ax # service 2, 1 sector - int $0x13 - jc probe_loop # try next value - -got_sectors: - movb $0x03, %ah # read cursor pos - xorb %bh, %bh - int $0x10 - movw $9, %cx - movb $0x07, %bl # page 0, attribute 7 (normal) - # %bh is set above; int10 doesn't - # modify it - movw $msg1, %bp - movw $0x1301, %ax # write string, move cursor - int $0x10 # tell the user we're loading.. - -# Load the setup-sectors directly after the moved bootblock (at 0x90200). -# We should know the drive geometry to do it, as setup may exceed first -# cylinder (for 9-sector 360K and 720K floppies). - - movw $0x0001, %ax # set sread (sector-to-read) to 1 as - movw $sread, %si # the boot sector has already been read - movw %ax, (%si) - - call kill_motor # reset FDC - movw $0x0200, %bx # address = 512, in INITSEG -next_step: - movb setup_sects, %al - movw sectors, %cx - subw (%si), %cx # (%si) = sread - cmpb %cl, %al - jbe no_cyl_crossing - movw sectors, %ax - subw (%si), %ax # (%si) = sread -no_cyl_crossing: - call read_track - pushw %ax # save it - call set_next # set %bx properly; it uses %ax,%cx,%dx - popw %ax # restore - subb %al, setup_sects # rest - for next step - jnz next_step - - pushw $SYSSEG - popw %es # %es = SYSSEG - call read_it - call kill_motor - call print_nl - -# After that we check which root-device to use. If the device is -# defined (!= 0), nothing is done and the given device is used. -# Otherwise, one of /dev/fd0H2880 (2,32) or /dev/PS0 (2,28) or /dev/at0 (2,8) -# depending on the number of sectors we pretend to know we have. - -# Segments are as follows: %cs = %ds = %ss = INITSEG, -# %es = SYSSEG, %fs = 0, %gs is unused. - - movw root_dev, %ax - orw %ax, %ax - jne root_defined - - movw sectors, %bx - movw $0x0208, %ax # /dev/ps0 - 1.2Mb - cmpw $15, %bx - je root_defined - - movb $0x1c, %al # /dev/PS0 - 1.44Mb - cmpw $18, %bx - je root_defined - - movb $0x20, %al # /dev/fd0H2880 - 2.88Mb - cmpw $36, %bx - je root_defined - - movb $0, %al # /dev/fd0 - autodetect -root_defined: - movw %ax, root_dev - -# After that (everything loaded), we jump to the setup-routine -# loaded directly after the bootblock: - - ljmp $SETUPSEG, $0 - -# These variables are addressed via %si register as it gives shorter code. - -sread: .word 0 # sectors read of current track -head: .word 0 # current head -track: .word 0 # current track - -# This routine loads the system at address SYSSEG, making sure -# no 64kB boundaries are crossed. We try to load it as fast as -# possible, loading whole tracks whenever we can. - -read_it: - movw %es, %ax # %es = SYSSEG when called - testw $0x0fff, %ax -die: jne die # %es must be at 64kB boundary - xorw %bx, %bx # %bx is starting address within segment -rp_read: -#ifdef __BIG_KERNEL__ # look in setup.S for bootsect_kludge - bootsect_kludge = 0x220 # 0x200 + 0x20 which is the size of the - lcall *bootsect_kludge # bootsector + bootsect_kludge offset -#else - movw %es, %ax - subw $SYSSEG, %ax - movw %bx, %cx - shr $4, %cx - add %cx, %ax # check offset -#endif - cmpw syssize, %ax # have we loaded everything yet? - jbe ok1_read - - ret - -ok1_read: - movw sectors, %ax - subw (%si), %ax # (%si) = sread - movw %ax, %cx - shlw $9, %cx - addw %bx, %cx - jnc ok2_read - - je ok2_read - - xorw %ax, %ax - subw %bx, %ax - shrw $9, %ax -ok2_read: - call read_track - call set_next - jmp rp_read - -read_track: - pusha - pusha - movw $0xe2e, %ax # loading... message 2e = . + andb %al, %al + jz die + movb $0xe, %ah movw $7, %bx - int $0x10 - popa - -# Accessing head, track, sread via %si gives shorter code. + int $0x10 + jmp msg_loop - movw 4(%si), %dx # 4(%si) = track - movw (%si), %cx # (%si) = sread - incw %cx - movb %dl, %ch - movw 2(%si), %dx # 2(%si) = head - movb %dl, %dh - andw $0x0100, %dx - movb $2, %ah - pushw %dx # save for error dump - pushw %cx - pushw %bx - pushw %ax - int $0x13 - jc bad_rt - - addw $8, %sp - popa - ret - -set_next: - movw %ax, %cx - addw (%si), %ax # (%si) = sread - cmp sectors, %ax - jne ok3_set - movw $0x0001, %ax - xorw %ax, 2(%si) # change head - jne ok4_set - incw 4(%si) # next track -ok4_set: +die: + # Allow the user to press a key, then reboot xorw %ax, %ax -ok3_set: - movw %ax, (%si) # set sread - shlw $9, %cx - addw %cx, %bx - jnc set_next_fin - movw %es, %ax - addb $0x10, %ah - movw %ax, %es - xorw %bx, %bx -set_next_fin: - ret - -bad_rt: - pushw %ax # save error code - call print_all # %ah = error, %al = read - xorb %ah, %ah - xorb %dl, %dl - int $0x13 - addw $10, %sp - popa - jmp read_track - -# print_all is for debugging purposes. -# -# it will print out all of the registers. The assumption is that this is -# called from a routine, with a stack frame like -# -# %dx -# %cx -# %bx -# %ax -# (error) -# ret <- %sp - -print_all: - movw $5, %cx # error code + 4 registers - movw %sp, %bp -print_loop: - pushw %cx # save count remaining - call print_nl # <-- for readability - cmpb $5, %cl - jae no_reg # see if register name is needed - - movw $0xe05 + 'A' - 1, %ax - subb %cl, %al - int $0x10 - movb $'X', %al - int $0x10 - movb $':', %al - int $0x10 -no_reg: - addw $2, %bp # next register - call print_hex # print it - popw %cx - loop print_loop - ret + int $0x16 + int $0x19 -print_nl: - movw $0xe0d, %ax # CR - int $0x10 - movb $0xa, %al # LF - int $0x10 - ret - -# print_hex is for debugging purposes, and prints the word -# pointed to by %ss:%bp in hexadecimal. - -print_hex: - movw $4, %cx # 4 hex digits - movw (%bp), %dx # load word into %dx -print_digit: - rolw $4, %dx # rotate to use low 4 bits - movw $0xe0f, %ax # %ah = request - andb %dl, %al # %al = mask for nybble - addb $0x90, %al # convert %al to ascii hex - daa # in only four instructions! - adc $0x40, %al - daa - int $0x10 - loop print_digit - ret + # int 0x19 should never return. In case it does anyway, + # invoke the BIOS reset code... + ljmp $0xf000,$0xfff0 -# This procedure turns off the floppy drive motor, so -# that we enter the kernel in a known state, and -# don't have to worry about it later. -# NOTE: Doesn't save %ax or %dx; do it yourself if you need to. - -kill_motor: -#if 1 - xorw %ax, %ax # reset FDC - xorb %dl, %dl - int $0x13 -#else - movw $0x3f2, %dx - xorb %al, %al - outb %al, %dx -#endif - ret -sectors: .word 0 -disksizes: .byte 36, 21, 18, 15, 9 -msg1: .byte 13, 10 - .ascii "Loading" +bugger_off_msg: + .ascii "Direct booting from floppy is no longer supported.\r\n" + .ascii "Please use a boot loader program instead.\r\n" + .ascii "\n" + .ascii "Remove disk and press any key to reboot . . .\r\n" + .byte 0 + -# XXX: This is a fairly snug fit. + # Kernel attributes; used by setup -.org 497 + .org 497 setup_sects: .byte SETUPSECTS root_flags: .word ROOT_RDONLY syssize: .word SYSSIZE diff -Nru a/arch/i386/boot/mtools.conf.in b/arch/i386/boot/mtools.conf.in --- /dev/null Wed Dec 31 16:00:00 1969 +++ b/arch/i386/boot/mtools.conf.in Tue Mar 4 15:09:44 2003 @@ -0,0 +1,17 @@ +# +# mtools configuration file for "make (b)zdisk" +# + +# Actual floppy drive +drive a: + file="/dev/fd0" + +# 1.44 MB floppy disk image +drive v: + file="@OBJ@/fdimage" cylinders=80 heads=2 sectors=18 filter + +# 2.88 MB floppy disk image (mostly for virtual uses) +drive w: + file="@OBJ@/fdimage" cylinders=80 heads=2 sectors=36 filter + + diff -Nru a/arch/i386/boot/tools/build.c b/arch/i386/boot/tools/build.c --- a/arch/i386/boot/tools/build.c Mon Feb 4 23:41:17 2002 +++ b/arch/i386/boot/tools/build.c Tue Mar 4 15:09:44 2003 @@ -150,13 +150,10 @@ sz = sb.st_size; fprintf (stderr, "System is %d kB\n", sz/1024); sys_size = (sz + 15) / 16; - /* 0x28000*16 = 2.5 MB, conservative estimate for the current maximum */ - if (sys_size > (is_big_kernel ? 0x28000 : DEF_SYSSIZE)) + /* 0x40000*16 = 4.0 MB, reasonable estimate for the current maximum */ + if (sys_size > (is_big_kernel ? 0x40000 : DEF_SYSSIZE)) die("System is too big. Try using %smodules.", is_big_kernel ? "" : "bzImage or "); - if (sys_size > 0xefff) - fprintf(stderr,"warning: kernel is too big for standalone boot " - "from floppy\n"); while (sz > 0) { int l, n; diff -Nru a/arch/i386/kernel/i386_ksyms.c b/arch/i386/kernel/i386_ksyms.c --- a/arch/i386/kernel/i386_ksyms.c Fri Feb 28 00:05:34 2003 +++ b/arch/i386/kernel/i386_ksyms.c Mon Mar 3 03:33:17 2003 @@ -68,6 +68,9 @@ EXPORT_SYMBOL(MCA_bus); #ifdef CONFIG_DISCONTIGMEM EXPORT_SYMBOL(node_data); +#ifdef CONFIG_X86_NUMAQ +EXPORT_SYMBOL(pfn_to_nid); +#endif #endif #ifdef CONFIG_X86_NUMAQ EXPORT_SYMBOL(xquad_portio); diff -Nru a/arch/i386/kernel/io_apic.c b/arch/i386/kernel/io_apic.c --- a/arch/i386/kernel/io_apic.c Sun Mar 2 18:13:32 2003 +++ b/arch/i386/kernel/io_apic.c Thu Mar 6 08:16:54 2003 @@ -221,8 +221,9 @@ # define Dprintk(x...) # endif -extern unsigned long irq_affinity [NR_IRQS]; -int __cacheline_aligned pending_irq_balance_apicid [NR_IRQS]; +extern unsigned long irq_affinity[NR_IRQS]; + +static int __cacheline_aligned pending_irq_balance_apicid[NR_IRQS]; static int irqbalance_disabled = NO_BALANCE_IRQ; static int physical_balance = 0; @@ -251,8 +252,54 @@ #define BALANCED_IRQ_LESS_DELTA (HZ) long balanced_irq_interval = MAX_BALANCED_IRQ_INTERVAL; - -static inline void balance_irq(int cpu, int irq); + +static unsigned long move(int curr_cpu, unsigned long allowed_mask, + unsigned long now, int direction) +{ + int search_idle = 1; + int cpu = curr_cpu; + + goto inside; + + do { + if (unlikely(cpu == curr_cpu)) + search_idle = 0; +inside: + if (direction == 1) { + cpu++; + if (cpu >= NR_CPUS) + cpu = 0; + } else { + cpu--; + if (cpu == -1) + cpu = NR_CPUS-1; + } + } while (!cpu_online(cpu) || !IRQ_ALLOWED(cpu,allowed_mask) || + (search_idle && !IDLE_ENOUGH(cpu,now))); + + return cpu; +} + +static inline void balance_irq(int cpu, int irq) +{ + unsigned long now = jiffies; + unsigned long allowed_mask; + unsigned int new_cpu; + + if (irqbalance_disabled) + return; + + allowed_mask = cpu_online_map & irq_affinity[irq]; + new_cpu = move(cpu, allowed_mask, now, 1); + if (cpu != new_cpu) { + irq_desc_t *desc = irq_desc + irq; + unsigned long flags; + + spin_lock_irqsave(&desc->lock, flags); + pending_irq_balance_apicid[irq]=cpu_to_logical_apicid(new_cpu); + spin_unlock_irqrestore(&desc->lock, flags); + } +} static inline void rotate_irqs_among_cpus(unsigned long useful_load_threshold) { @@ -263,7 +310,8 @@ if (!irq_desc[j].action) continue; /* Is it a significant load ? */ - if (IRQ_DELTA(CPU_TO_PACKAGEINDEX(i),j) < useful_load_threshold) + if (IRQ_DELTA(CPU_TO_PACKAGEINDEX(i),j) < + useful_load_threshold) continue; balance_irq(i, j); } @@ -430,7 +478,8 @@ * We seek the least loaded sibling by making the comparison * (A+B)/2 vs B */ - if (physical_balance && (CPU_IRQ(min_loaded) >> 1) > CPU_IRQ(cpu_sibling_map[min_loaded])) + if (physical_balance && (CPU_IRQ(min_loaded) >> 1) > + CPU_IRQ(cpu_sibling_map[min_loaded])) min_loaded = cpu_sibling_map[min_loaded]; allowed_mask = cpu_online_map & irq_affinity[selected_irq]; @@ -438,11 +487,15 @@ if (target_cpu_mask & allowed_mask) { irq_desc_t *desc = irq_desc + selected_irq; - Dprintk("irq = %d moved to cpu = %d\n", selected_irq, min_loaded); + unsigned long flags; + + Dprintk("irq = %d moved to cpu = %d\n", + selected_irq, min_loaded); /* mark for change destination */ - spin_lock(&desc->lock); - pending_irq_balance_apicid[selected_irq] = cpu_to_logical_apicid(min_loaded); - spin_unlock(&desc->lock); + spin_lock_irqsave(&desc->lock, flags); + pending_irq_balance_apicid[selected_irq] = + cpu_to_logical_apicid(min_loaded); + spin_unlock_irqrestore(&desc->lock, flags); /* Since we made a change, come back sooner to * check for more variation. */ @@ -453,58 +506,16 @@ goto tryanotherirq; not_worth_the_effort: - /* if we did not find an IRQ to move, then adjust the time interval upward */ + /* + * if we did not find an IRQ to move, then adjust the time interval + * upward + */ balanced_irq_interval = min((long)MAX_BALANCED_IRQ_INTERVAL, balanced_irq_interval + BALANCED_IRQ_MORE_DELTA); Dprintk("IRQ worth rotating not found\n"); return; } -static unsigned long move(int curr_cpu, unsigned long allowed_mask, unsigned long now, int direction) -{ - int search_idle = 1; - int cpu = curr_cpu; - - goto inside; - - do { - if (unlikely(cpu == curr_cpu)) - search_idle = 0; -inside: - if (direction == 1) { - cpu++; - if (cpu >= NR_CPUS) - cpu = 0; - } else { - cpu--; - if (cpu == -1) - cpu = NR_CPUS-1; - } - } while (!cpu_online(cpu) || !IRQ_ALLOWED(cpu,allowed_mask) || - (search_idle && !IDLE_ENOUGH(cpu,now))); - - return cpu; -} - -static inline void balance_irq (int cpu, int irq) -{ - unsigned long now = jiffies; - unsigned long allowed_mask; - unsigned int new_cpu; - - if (irqbalance_disabled) - return; - - allowed_mask = cpu_online_map & irq_affinity[irq]; - new_cpu = move(cpu, allowed_mask, now, 1); - if (cpu != new_cpu) { - irq_desc_t *desc = irq_desc + irq; - spin_lock(&desc->lock); - pending_irq_balance_apicid[irq] = cpu_to_logical_apicid(new_cpu); - spin_unlock(&desc->lock); - } -} - int balanced_irq(void *unused) { int i; @@ -516,26 +527,32 @@ /* push everything to CPU 0 to give us a starting point. */ for (i = 0 ; i < NR_IRQS ; i++) pending_irq_balance_apicid[i] = cpu_to_logical_apicid(0); - for (;;) { - set_current_state(TASK_INTERRUPTIBLE); - time_remaining = schedule_timeout(time_remaining); - if (time_after(jiffies, prev_balance_time+balanced_irq_interval)) { - Dprintk("balanced_irq: calling do_irq_balance() %lu\n", jiffies); - do_irq_balance(); - prev_balance_time = jiffies; - time_remaining = balanced_irq_interval; - } - } + +repeat: + set_current_state(TASK_INTERRUPTIBLE); + time_remaining = schedule_timeout(time_remaining); + if (time_after(jiffies, prev_balance_time+balanced_irq_interval)) { + Dprintk("balanced_irq: calling do_irq_balance() %lu\n", + jiffies); + do_irq_balance(); + prev_balance_time = jiffies; + time_remaining = balanced_irq_interval; + } + goto repeat; } static int __init balanced_irq_init(void) { int i; struct cpuinfo_x86 *c; + c = &boot_cpu_data; if (irqbalance_disabled) return 0; - /* Enable physical balance only if more than 1 physical processor is present */ + /* + * Enable physical balance only if more than 1 physical processor + * is present + */ if (smp_num_siblings > 1 && cpu_online_map >> 2) physical_balance = 1; @@ -1566,7 +1583,7 @@ */ static int __init timer_irq_works(void) { - unsigned int t1 = jiffies; + unsigned long t1 = jiffies; local_irq_enable(); /* Let ten ticks pass... */ diff -Nru a/arch/i386/mm/fault.c b/arch/i386/mm/fault.c --- a/arch/i386/mm/fault.c Fri Jan 10 19:29:47 2003 +++ b/arch/i386/mm/fault.c Thu Mar 6 08:19:03 2003 @@ -394,14 +394,14 @@ * Do _not_ use "tsk" here. We might be inside * an interrupt in the middle of a task switch.. */ - int offset = __pgd_offset(address); + int index = pgd_index(address); pgd_t *pgd, *pgd_k; pmd_t *pmd, *pmd_k; pte_t *pte_k; asm("movl %%cr3,%0":"=r" (pgd)); - pgd = offset + (pgd_t *)__va(pgd); - pgd_k = init_mm.pgd + offset; + pgd = index + (pgd_t *)__va(pgd); + pgd_k = init_mm.pgd + index; if (!pgd_present(*pgd_k)) goto no_context; diff -Nru a/arch/i386/mm/init.c b/arch/i386/mm/init.c --- a/arch/i386/mm/init.c Mon Feb 3 23:46:49 2003 +++ b/arch/i386/mm/init.c Thu Mar 6 08:19:07 2003 @@ -98,26 +98,26 @@ { pgd_t *pgd; pmd_t *pmd; - int pgd_ofs, pmd_ofs; + int pgd_idx, pmd_idx; unsigned long vaddr; vaddr = start; - pgd_ofs = __pgd_offset(vaddr); - pmd_ofs = __pmd_offset(vaddr); - pgd = pgd_base + pgd_ofs; + pgd_idx = pgd_index(vaddr); + pmd_idx = pmd_index(vaddr); + pgd = pgd_base + pgd_idx; - for ( ; (pgd_ofs < PTRS_PER_PGD) && (vaddr != end); pgd++, pgd_ofs++) { + for ( ; (pgd_idx < PTRS_PER_PGD) && (vaddr != end); pgd++, pgd_idx++) { if (pgd_none(*pgd)) one_md_table_init(pgd); pmd = pmd_offset(pgd, vaddr); - for (; (pmd_ofs < PTRS_PER_PMD) && (vaddr != end); pmd++, pmd_ofs++) { + for (; (pmd_idx < PTRS_PER_PMD) && (vaddr != end); pmd++, pmd_idx++) { if (pmd_none(*pmd)) one_page_table_init(pmd); vaddr += PMD_SIZE; } - pmd_ofs = 0; + pmd_idx = 0; } } @@ -132,17 +132,17 @@ pgd_t *pgd; pmd_t *pmd; pte_t *pte; - int pgd_ofs, pmd_ofs, pte_ofs; + int pgd_idx, pmd_idx, pte_ofs; - pgd_ofs = __pgd_offset(PAGE_OFFSET); - pgd = pgd_base + pgd_ofs; + pgd_idx = pgd_index(PAGE_OFFSET); + pgd = pgd_base + pgd_idx; pfn = 0; - for (; pgd_ofs < PTRS_PER_PGD; pgd++, pgd_ofs++) { + for (; pgd_idx < PTRS_PER_PGD; pgd++, pgd_idx++) { pmd = one_md_table_init(pgd); if (pfn >= max_low_pfn) continue; - for (pmd_ofs = 0; pmd_ofs < PTRS_PER_PMD && pfn < max_low_pfn; pmd++, pmd_ofs++) { + for (pmd_idx = 0; pmd_idx < PTRS_PER_PMD && pfn < max_low_pfn; pmd++, pmd_idx++) { /* Map with big pages if possible, otherwise create normal page tables. */ if (cpu_has_pse) { set_pmd(pmd, pfn_pmd(pfn, PAGE_KERNEL_LARGE)); @@ -214,7 +214,7 @@ vaddr = PKMAP_BASE; page_table_range_init(vaddr, vaddr + PAGE_SIZE*LAST_PKMAP, pgd_base); - pgd = swapper_pg_dir + __pgd_offset(vaddr); + pgd = swapper_pg_dir + pgd_index(vaddr); pmd = pmd_offset(pgd, vaddr); pte = pte_offset_kernel(pmd, vaddr); pkmap_page_table = pte; diff -Nru a/arch/i386/mm/ioremap.c b/arch/i386/mm/ioremap.c --- a/arch/i386/mm/ioremap.c Mon Feb 24 23:13:24 2003 +++ b/arch/i386/mm/ioremap.c Thu Mar 6 06:34:47 2003 @@ -148,7 +148,7 @@ */ offset = phys_addr & ~PAGE_MASK; phys_addr &= PAGE_MASK; - size = PAGE_ALIGN(last_addr) - phys_addr; + size = PAGE_ALIGN(last_addr+1) - phys_addr; /* * Ok, go for it.. diff -Nru a/arch/i386/mm/pgtable.c b/arch/i386/mm/pgtable.c --- a/arch/i386/mm/pgtable.c Sun Mar 2 18:14:31 2003 +++ b/arch/i386/mm/pgtable.c Thu Mar 6 08:19:03 2003 @@ -64,7 +64,7 @@ pmd_t *pmd; pte_t *pte; - pgd = swapper_pg_dir + __pgd_offset(vaddr); + pgd = swapper_pg_dir + pgd_index(vaddr); if (pgd_none(*pgd)) { BUG(); return; @@ -104,7 +104,7 @@ printk ("set_pmd_pfn: pfn misaligned\n"); return; /* BUG(); */ } - pgd = swapper_pg_dir + __pgd_offset(vaddr); + pgd = swapper_pg_dir + pgd_index(vaddr); if (pgd_none(*pgd)) { printk ("set_pmd_pfn: pgd_none\n"); return; /* BUG(); */ diff -Nru a/arch/i386/oprofile/nmi_int.c b/arch/i386/oprofile/nmi_int.c --- a/arch/i386/oprofile/nmi_int.c Sun Mar 2 18:13:32 2003 +++ b/arch/i386/oprofile/nmi_int.c Wed Mar 5 11:46:56 2003 @@ -58,7 +58,7 @@ unsigned int const nr_ctrls = model->num_controls; struct op_msr_group * counters = &msrs->counters; struct op_msr_group * controls = &msrs->controls; - int i; + unsigned int i; for (i = 0; i < nr_ctrs; ++i) { rdmsr(counters->addrs[i], @@ -108,7 +108,7 @@ unsigned int const nr_ctrls = model->num_controls; struct op_msr_group * counters = &msrs->counters; struct op_msr_group * controls = &msrs->controls; - int i; + unsigned int i; for (i = 0; i < nr_ctrls; ++i) { wrmsr(controls->addrs[i], @@ -182,7 +182,7 @@ static int nmi_create_files(struct super_block * sb, struct dentry * root) { - int i; + unsigned int i; for (i = 0; i < model->num_counters; ++i) { struct dentry * dir; diff -Nru a/arch/i386/oprofile/op_model_p4.c b/arch/i386/oprofile/op_model_p4.c --- a/arch/i386/oprofile/op_model_p4.c Thu Jan 30 19:57:28 2003 +++ b/arch/i386/oprofile/op_model_p4.c Sun Mar 2 22:48:07 2003 @@ -389,7 +389,7 @@ static void p4_fill_in_addresses(struct op_msrs * const msrs) { - int i; + unsigned int i; unsigned int addr, stag; setup_num_counters(); diff -Nru a/arch/i386/pci/irq.c b/arch/i386/pci/irq.c --- a/arch/i386/pci/irq.c Mon Oct 7 07:36:47 2002 +++ b/arch/i386/pci/irq.c Thu Feb 20 08:53:57 2003 @@ -804,6 +804,7 @@ int pirq_enable_irq(struct pci_dev *dev) { u8 pin; + extern int interrupt_line_quirk; pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin); if (pin && !pcibios_lookup_irq(dev, 1) && !dev->irq) { char *msg; @@ -813,9 +814,17 @@ msg = ""; else msg = " Please try using pci=biosirq."; + + /* With IDE legacy devices the IRQ lookup failure is not a problem.. */ + if (dev->class >> 8 == PCI_CLASS_STORAGE_IDE && !(dev->class & 0x5)) + return; + printk(KERN_WARNING "PCI: No IRQ known for interrupt pin %c of device %s.%s\n", 'A' + pin - 1, dev->slot_name, msg); } - + /* VIA bridges use interrupt line for apic/pci steering across + the V-Link */ + else if (interrupt_line_quirk) + pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq); return 0; } diff -Nru a/arch/i386/vmlinux.lds.S b/arch/i386/vmlinux.lds.S --- a/arch/i386/vmlinux.lds.S Tue Feb 18 18:58:52 2003 +++ b/arch/i386/vmlinux.lds.S Sun Feb 16 15:55:23 2003 @@ -74,6 +74,9 @@ *(.initcall7.init) } __initcall_end = .; + __con_initcall_start = .; + .con_initcall.init : { *(.con_initcall.init) } + __con_initcall_end = .; . = ALIGN(4096); __initramfs_start = .; .init.ramfs : { *(.init.ramfs) } diff -Nru a/arch/ia64/vmlinux.lds.S b/arch/ia64/vmlinux.lds.S --- a/arch/ia64/vmlinux.lds.S Wed Jan 29 22:16:51 2003 +++ b/arch/ia64/vmlinux.lds.S Fri Feb 14 15:08:44 2003 @@ -133,6 +133,10 @@ *(.initcall7.init) __initcall_end = .; } + __con_initcall_start = .; + .con_initcall.init : AT(ADDR(.con_initcall.init) - PAGE_OFFSET) + { *(.con_initcall.init) } + __con_initcall_end = .; . = ALIGN(PAGE_SIZE); __init_end = .; diff -Nru a/arch/m68k/vmlinux-std.lds b/arch/m68k/vmlinux-std.lds --- a/arch/m68k/vmlinux-std.lds Wed Jan 15 09:48:42 2003 +++ b/arch/m68k/vmlinux-std.lds Fri Feb 14 15:09:22 2003 @@ -60,6 +60,9 @@ *(.initcall7.init) } __initcall_end = .; + __con_initcall_start = .; + .con_initcall.init : { *(.con_initcall.init) } + __con_initcall_end = .; . = ALIGN(8192); __initramfs_start = .; .init.ramfs : { *(.init.ramfs) } diff -Nru a/arch/m68k/vmlinux-sun3.lds b/arch/m68k/vmlinux-sun3.lds --- a/arch/m68k/vmlinux-sun3.lds Wed Jan 15 09:48:42 2003 +++ b/arch/m68k/vmlinux-sun3.lds Fri Feb 14 15:09:22 2003 @@ -53,6 +53,9 @@ *(.initcall7.init) } __initcall_end = .; + __con_initcall_start = .; + .con_initcall.init : { *(.con_initcall.init) } + __con_initcall_end = .; . = ALIGN(8192); __initramfs_start = .; .init.ramfs : { *(.init.ramfs) } diff -Nru a/arch/mips/arc/arc_con.c b/arch/mips/arc/arc_con.c --- a/arch/mips/arc/arc_con.c Tue Feb 5 10:12:45 2002 +++ b/arch/mips/arc/arc_con.c Fri Feb 14 15:09:50 2003 @@ -63,7 +63,8 @@ * Register console. */ -void __init arc_console_init(void) +static void __init arc_console_init(void) { register_console(&arc_cons); } +console_initcall(arc_console_init); diff -Nru a/arch/mips/au1000/common/serial.c b/arch/mips/au1000/common/serial.c --- a/arch/mips/au1000/common/serial.c Mon Feb 24 10:28:52 2003 +++ b/arch/mips/au1000/common/serial.c Thu Mar 6 09:10:40 2003 @@ -3054,10 +3054,11 @@ /* * Register console. */ -void __init au1000_serial_console_init(void) +static void __init au1000_serial_console_init(void) { register_console(&sercons); } +console_initcall(au1000_serial_console_init); #endif /* diff -Nru a/arch/mips/vmlinux.lds.S b/arch/mips/vmlinux.lds.S --- a/arch/mips/vmlinux.lds.S Wed Jan 15 09:48:42 2003 +++ b/arch/mips/vmlinux.lds.S Fri Feb 14 15:09:55 2003 @@ -51,6 +51,9 @@ *(.initcall7.init) } __initcall_end = .; + __con_initcall_start = .; + .con_initcall.init : { *(.con_initcall.init) } + __con_initcall_end = .; . = ALIGN(4096); /* Align double page for init_task_union */ __init_end = .; diff -Nru a/arch/mips64/vmlinux.lds.S b/arch/mips64/vmlinux.lds.S --- a/arch/mips64/vmlinux.lds.S Wed Jan 15 09:48:42 2003 +++ b/arch/mips64/vmlinux.lds.S Fri Feb 14 15:10:00 2003 @@ -50,6 +50,9 @@ *(.initcall7.init) } __initcall_end = .; + __con_initcall_start = .; + .con_initcall.init : { *(.con_initcall.init) } + __con_initcall_end = .; . = ALIGN(4096); /* Align double page for init_task_union */ __init_end = .; diff -Nru a/arch/parisc/vmlinux.lds.S b/arch/parisc/vmlinux.lds.S --- a/arch/parisc/vmlinux.lds.S Wed Jan 15 09:48:42 2003 +++ b/arch/parisc/vmlinux.lds.S Fri Feb 14 15:10:04 2003 @@ -73,6 +73,9 @@ *(.initcall7.init) } __initcall_end = .; + __con_initcall_start = .; + .con_initcall.init : { *(.con_initcall.init) } + __con_initcall_end = .; . = ALIGN(4096); __initramfs_start = .; .init.ramfs : { *(.init.ramfs) } diff -Nru a/arch/ppc/8xx_io/uart.c b/arch/ppc/8xx_io/uart.c --- a/arch/ppc/8xx_io/uart.c Mon Feb 3 05:47:46 2003 +++ b/arch/ppc/8xx_io/uart.c Mon Mar 3 11:33:06 2003 @@ -2522,12 +2522,11 @@ /* * Register console. */ -long __init console_8xx_init(long kmem_start, long kmem_end) +static void __init console_8xx_init(long kmem_start, long kmem_end) { register_console(&sercons); - return kmem_start; } - +console_initcall(console_8xx_init); #endif /* Index in baud rate table of the default console baud rate. diff -Nru a/arch/ppc/boot/simple/rw4/ppc_40x.h b/arch/ppc/boot/simple/rw4/ppc_40x.h --- a/arch/ppc/boot/simple/rw4/ppc_40x.h Fri Feb 14 15:10:29 2003 +++ b/arch/ppc/boot/simple/rw4/ppc_40x.h Wed Feb 19 07:23:15 2003 @@ -42,7 +42,7 @@ #define dccr 0x3fa /* data cache control reg. */ #define dcwr 0x3ba /* data cache write-thru reg */ #define dear 0x3d5 /* data exception address reg */ -#define esr 0x3d4 /* exception syndrome registe */ +#define esr 0x3d4 /* exception syndrome register */ #define evpr 0x3d6 /* exception vector prefix reg */ #define iccr 0x3fb /* instruction cache cntrl re */ #define icdbdr 0x3d3 /* instr cache dbug data reg */ diff -Nru a/arch/ppc/vmlinux.lds.S b/arch/ppc/vmlinux.lds.S --- a/arch/ppc/vmlinux.lds.S Wed Jan 15 09:48:42 2003 +++ b/arch/ppc/vmlinux.lds.S Fri Feb 14 15:10:39 2003 @@ -107,6 +107,10 @@ } __initcall_end = .; + __con_initcall_start = .; + .con_initcall.init : { *(.con_initcall.init) } + __con_initcall_end = .; + __start___ftr_fixup = .; __ftr_fixup : { *(__ftr_fixup) } __stop___ftr_fixup = .; diff -Nru a/arch/ppc64/vmlinux.lds.S b/arch/ppc64/vmlinux.lds.S --- a/arch/ppc64/vmlinux.lds.S Wed Jan 15 09:48:42 2003 +++ b/arch/ppc64/vmlinux.lds.S Fri Feb 14 15:10:57 2003 @@ -97,6 +97,9 @@ *(.initcall7.init) } __initcall_end = .; + __con_initcall_start = .; + .con_initcall.init : { *(.con_initcall.init) } + __con_initcall_end = .; . = ALIGN(4096); __initramfs_start = .; .init.ramfs : { *(.init.ramfs) } diff -Nru a/arch/s390/vmlinux.lds.S b/arch/s390/vmlinux.lds.S --- a/arch/s390/vmlinux.lds.S Mon Feb 24 10:24:21 2003 +++ b/arch/s390/vmlinux.lds.S Mon Mar 3 11:37:38 2003 @@ -78,6 +78,9 @@ *(.initcall7.init) } __initcall_end = .; + __con_initcall_start = .; + .con_initcall.init : { *(.con_initcall.init) } + __con_initcall_end = .; . = ALIGN(256); __initramfs_start = .; .init.ramfs : { *(.init.initramfs) } diff -Nru a/arch/s390x/vmlinux.lds.S b/arch/s390x/vmlinux.lds.S --- a/arch/s390x/vmlinux.lds.S Mon Feb 24 10:24:21 2003 +++ b/arch/s390x/vmlinux.lds.S Mon Mar 3 11:44:26 2003 @@ -78,6 +78,9 @@ *(.initcall7.init) } __initcall_end = .; + __con_initcall_start = .; + .con_initcall.init : { *(.con_initcall.init) } + __con_initcall_end = .; . = ALIGN(256); __initramfs_start = .; .init.ramfs : { *(.init.initramfs) } diff -Nru a/arch/sh/vmlinux.lds.S b/arch/sh/vmlinux.lds.S --- a/arch/sh/vmlinux.lds.S Wed Jan 15 09:48:42 2003 +++ b/arch/sh/vmlinux.lds.S Fri Feb 14 15:11:24 2003 @@ -68,6 +68,9 @@ *(.initcall7.init) } __initcall_end = .; + __con_initcall_start = .; + .con_initcall.init : { *(.con_initcall.init) } + __con_initcall_end = .; __machvec_start = .; .machvec.init : { *(.machvec.init) } __machvec_end = .; diff -Nru a/arch/sparc/vmlinux.lds.S b/arch/sparc/vmlinux.lds.S --- a/arch/sparc/vmlinux.lds.S Wed Jan 15 09:48:42 2003 +++ b/arch/sparc/vmlinux.lds.S Fri Feb 14 15:11:32 2003 @@ -55,6 +55,9 @@ *(.initcall7.init) } __initcall_end = .; + __con_initcall_start = .; + .con_initcall.init : { *(.con_initcall.init) } + __con_initcall_end = .; . = ALIGN(4096); __initramfs_start = .; .init.ramfs : { *(.init.ramfs) } diff -Nru a/arch/sparc64/Kconfig b/arch/sparc64/Kconfig --- a/arch/sparc64/Kconfig Mon Mar 3 00:34:40 2003 +++ b/arch/sparc64/Kconfig Wed Mar 5 08:22:15 2003 @@ -151,9 +151,14 @@ If in doubt, say N. config CPU_FREQ_TABLE - tristate + tristate "CPU frequency table helpers" + depends on CPU_FREQ default y + help + Many CPUFreq drivers use these helpers, so only say N here if + the CPUFreq driver of your choice doesn't need these helpers. + If in doubt, say Y. config US3_FREQ tristate "UltraSPARC-III CPU Frequency driver" diff -Nru a/arch/sparc64/vmlinux.lds.S b/arch/sparc64/vmlinux.lds.S --- a/arch/sparc64/vmlinux.lds.S Wed Jan 15 09:48:42 2003 +++ b/arch/sparc64/vmlinux.lds.S Fri Feb 14 15:11:44 2003 @@ -61,6 +61,9 @@ *(.initcall7.init) } __initcall_end = .; + __con_initcall_start = .; + .con_initcall.init : { *(.con_initcall.init) } + __con_initcall_end = .; . = ALIGN(8192); __initramfs_start = .; .init.ramfs : { *(.init.ramfs) } diff -Nru a/arch/um/drivers/stdio_console.c b/arch/um/drivers/stdio_console.c --- a/arch/um/drivers/stdio_console.c Sat Dec 28 12:28:00 2002 +++ b/arch/um/drivers/stdio_console.c Fri Feb 14 15:11:51 2003 @@ -214,12 +214,13 @@ console_device, console_setup, CON_PRINTBUFFER); -void stdio_console_init(void) +static void __init stdio_console_init(void) { INIT_LIST_HEAD(&vts[0].chan_list); list_add(&init_console_chan.list, &vts[0].chan_list); register_console(&stdiocons); } +console_initcall(stdio_console_init); static int console_chan_setup(char *str) { diff -Nru a/arch/um/kernel/mem.c b/arch/um/kernel/mem.c --- a/arch/um/kernel/mem.c Wed Feb 5 20:16:02 2003 +++ b/arch/um/kernel/mem.c Thu Mar 6 08:19:07 2003 @@ -154,8 +154,8 @@ unsigned long vaddr; vaddr = start; - i = __pgd_offset(vaddr); - j = __pmd_offset(vaddr); + i = pgd_index(vaddr); + j = pmd_index(vaddr); pgd = pgd_base + i; for ( ; (i < PTRS_PER_PGD) && (vaddr < end); pgd++, i++) { @@ -257,7 +257,7 @@ vaddr = PKMAP_BASE; fixrange_init(vaddr, vaddr + PAGE_SIZE*LAST_PKMAP, swapper_pg_dir); - pgd = swapper_pg_dir + __pgd_offset(vaddr); + pgd = swapper_pg_dir + pgd_index(vaddr); pmd = pmd_offset(pgd, vaddr); pte = pte_offset_kernel(pmd, vaddr); pkmap_page_table = pte; diff -Nru a/arch/x86_64/boot/Makefile b/arch/x86_64/boot/Makefile --- a/arch/x86_64/boot/Makefile Wed Jan 29 20:41:18 2003 +++ b/arch/x86_64/boot/Makefile Tue Mar 4 15:09:44 2003 @@ -73,7 +73,7 @@ MTOOLSRC=$(src)/mtools.conf mcopy - a:syslinux.cfg MTOOLSRC=$(src)/mtools.conf mcopy $(BOOTIMAGE) a:linux ; sync -# These require being root or having syslinux run setuid +# These require being root or having syslinux 2.02 or higher installed fdimage fdimage144: $(BOOTIMAGE) $(src)/mtools.conf dd if=/dev/zero of=$(obj)/fdimage bs=1024 count=1440 MTOOLSRC=$(src)/mtools.conf mformat v: ; sync diff -Nru a/arch/x86_64/vmlinux.lds.S b/arch/x86_64/vmlinux.lds.S --- a/arch/x86_64/vmlinux.lds.S Tue Feb 11 03:00:35 2003 +++ b/arch/x86_64/vmlinux.lds.S Fri Feb 14 17:50:07 2003 @@ -98,6 +98,9 @@ *(.initcall7.init) } __initcall_end = .; + __con_initcall_start = .; + .con_initcall.init : { *(.con_initcall.init) } + __con_initcall_end = .; . = ALIGN(4096); __initramfs_start = .; .init.ramfs : { *(.init.ramfs) } diff -Nru a/drivers/acorn/net/ether1.c b/drivers/acorn/net/ether1.c --- a/drivers/acorn/net/ether1.c Sun Nov 17 13:36:31 2002 +++ b/drivers/acorn/net/ether1.c Thu Mar 6 05:00:32 2003 @@ -973,23 +973,6 @@ return &priv->stats; } -static int -ether1_set_mac_address(struct net_device *dev, void *p) -{ - struct sockaddr *addr = p; - - if (netif_running(dev)) - return -EBUSY; - - memcpy(dev->dev_addr, addr->sa_data, dev->addr_len); - - /* - * We'll set the MAC address on the chip when we open it. - */ - - return 0; -} - /* * Set or clear the multicast filter for this adaptor. * num_addrs == -1 Promiscuous mode, receive all packets. @@ -1062,7 +1045,6 @@ dev->hard_start_xmit = ether1_sendpacket; dev->get_stats = ether1_getstats; dev->set_multicast_list = ether1_setmulticastlist; - dev->set_mac_address = ether1_set_mac_address; dev->tx_timeout = ether1_timeout; dev->watchdog_timeo = 5 * HZ / 100; diff -Nru a/drivers/acorn/net/ether3.c b/drivers/acorn/net/ether3.c --- a/drivers/acorn/net/ether3.c Tue Feb 25 10:47:06 2003 +++ b/drivers/acorn/net/ether3.c Thu Mar 6 05:00:32 2003 @@ -461,23 +461,6 @@ return &priv->stats; } -static int -ether3_set_mac_address(struct net_device *dev, void *p) -{ - struct sockaddr *addr = p; - - if (netif_running(dev)) - return -EBUSY; - - memcpy(dev->dev_addr, addr->sa_data, dev->addr_len); - - /* - * We'll set the MAC address on the chip when we open it. - */ - - return 0; -} - /* * Set or clear promiscuous/multicast mode filter for this adaptor. * @@ -903,7 +886,6 @@ dev->hard_start_xmit = ether3_sendpacket; dev->get_stats = ether3_getstats; dev->set_multicast_list = ether3_setmulticastlist; - dev->set_mac_address = ether3_set_mac_address; dev->tx_timeout = ether3_timeout; dev->watchdog_timeo = 5 * HZ / 100; diff -Nru a/drivers/acorn/net/etherh.c b/drivers/acorn/net/etherh.c --- a/drivers/acorn/net/etherh.c Sun Nov 17 13:36:32 2002 +++ b/drivers/acorn/net/etherh.c Thu Mar 6 05:00:33 2003 @@ -482,23 +482,6 @@ return 0; } -static int -etherh_set_mac_address(struct net_device *dev, void *p) -{ - struct sockaddr *addr = p; - - if (netif_running(dev)) - return -EBUSY; - - memcpy(dev->dev_addr, addr->sa_data, dev->addr_len); - - /* - * We'll set the MAC address on the chip when we open it. - */ - - return 0; -} - /* * Initialisation */ @@ -585,7 +568,6 @@ dev->open = etherh_open; dev->stop = etherh_close; - dev->set_mac_address = etherh_set_mac_address; dev->set_config = etherh_set_config; dev->irq = ec->irq; dev->base_addr = ecard_address(ec, ECARD_MEMC, 0); diff -Nru a/drivers/atm/firestream.c b/drivers/atm/firestream.c --- a/drivers/atm/firestream.c Tue Feb 25 10:47:34 2003 +++ b/drivers/atm/firestream.c Thu Mar 6 09:14:50 2003 @@ -1792,7 +1792,7 @@ write_fs (dev, RAC, 0); /* Manual (AN9, page 6) says ASF1=0 means compare Utopia address - * too. I can't find ASF1 anywhere. Anyway, we AND with just hte + * too. I can't find ASF1 anywhere. Anyway, we AND with just the * other bits, then compare with 0, which is exactly what we * want. */ write_fs (dev, RAM, (1 << (28 - FS155_VPI_BITS - FS155_VCI_BITS)) - 1); diff -Nru a/drivers/base/platform.c b/drivers/base/platform.c --- a/drivers/base/platform.c Tue Mar 4 08:20:34 2003 +++ b/drivers/base/platform.c Wed Mar 5 15:33:09 2003 @@ -59,12 +59,9 @@ static int platform_match(struct device * dev, struct device_driver * drv) { - char name[BUS_ID_SIZE]; + struct platform_device *pdev = container_of(dev, struct platform_device, dev); - if (sscanf(dev->bus_id,"%s",name)) - return (strcmp(name,drv->name) == 0); - - return 0; + return (strncmp(pdev->name, drv->name, BUS_ID_SIZE) == 0); } struct bus_type platform_bus_type = { diff -Nru a/drivers/block/cciss.c b/drivers/block/cciss.c --- a/drivers/block/cciss.c Thu Feb 27 17:05:57 2003 +++ b/drivers/block/cciss.c Mon Mar 3 14:00:41 2003 @@ -2064,7 +2064,7 @@ unchar cache_line_size, latency_timer; unchar irq, revision; uint addr[6]; - __u32 board_id; + __u32 board_id, scratchpad = 0; int cfg_offset; int cfg_base_addr; int cfg_base_addr_index; @@ -2155,6 +2155,20 @@ printk("address 0 = %x\n", c->paddr); #endif /* CCISS_DEBUG */ c->vaddr = remap_pci_mem(c->paddr, 200); + + /* Wait for the board to become ready. (PCI hotplug needs this.) + * We poll for up to 120 secs, once per 100ms. */ + for (i=0; i < 1200; i++) { + scratchpad = readl(c->vaddr + SA5_SCRATCHPAD_OFFSET); + if (scratchpad == CCISS_FIRMWARE_READY) + break; + set_current_state(TASK_INTERRUPTIBLE); + schedule_timeout(HZ / 10); /* wait 100ms */ + } + if (scratchpad != CCISS_FIRMWARE_READY) { + printk(KERN_WARNING "cciss: Board not ready. Timed out.\n"); + return -1; + } /* get the address index number */ cfg_base_addr = readl(c->vaddr + SA5_CTCFG_OFFSET); diff -Nru a/drivers/block/cciss.h b/drivers/block/cciss.h --- a/drivers/block/cciss.h Thu Dec 5 08:03:43 2002 +++ b/drivers/block/cciss.h Mon Mar 3 13:52:06 2003 @@ -95,6 +95,7 @@ #define SA5_REPLY_INTR_MASK_OFFSET 0x34 #define SA5_REPLY_PORT_OFFSET 0x44 #define SA5_INTR_STATUS 0x30 +#define SA5_SCRATCHPAD_OFFSET 0xB0 #define SA5_CTCFG_OFFSET 0xB4 #define SA5_CTMEM_OFFSET 0xB8 @@ -104,6 +105,7 @@ #define SA5_INTR_PENDING 0x08 #define SA5B_INTR_PENDING 0x04 #define FIFO_EMPTY 0xffffffff +#define CCISS_FIRMWARE_READY 0xffff0000 /* value in scratchpad register */ #define CISS_ERROR_BIT 0x02 diff -Nru a/drivers/char/amiserial.c b/drivers/char/amiserial.c --- a/drivers/char/amiserial.c Mon Feb 3 05:47:46 2003 +++ b/drivers/char/amiserial.c Mon Mar 3 12:04:08 2003 @@ -2320,10 +2320,11 @@ /* * Register console. */ -void __init serial_console_init(void) +static void __init amiserial_console_init(void) { register_console(&sercons); } +console_initcall(amiserial_console_init); #endif MODULE_LICENSE("GPL"); diff -Nru a/drivers/char/decserial.c b/drivers/char/decserial.c --- a/drivers/char/decserial.c Mon Feb 4 23:45:05 2002 +++ b/drivers/char/decserial.c Fri Feb 14 15:14:03 2003 @@ -75,7 +75,7 @@ /* serial_console_init handles the special case of starting * up the console on the serial port */ -void __init serial_console_init(void) +static void __init decserial_console_init(void) { #if defined(CONFIG_ZS) && defined(CONFIG_DZ) if (IOASIC) @@ -94,5 +94,6 @@ #endif } +console_initcall(decserial_console_init); #endif diff -Nru a/drivers/char/hvc_console.c b/drivers/char/hvc_console.c --- a/drivers/char/hvc_console.c Tue Feb 11 14:57:50 2003 +++ b/drivers/char/hvc_console.c Fri Feb 14 15:14:16 2003 @@ -346,11 +346,12 @@ .index = -1, }; -int __init hvc_console_init(void) +static int __init hvc_console_init(void) { register_console(&hvc_con_driver); return 0; } +console_initcall(hvc_console_init); module_init(hvc_init); module_exit(hvc_exit); diff -Nru a/drivers/char/random.c b/drivers/char/random.c --- a/drivers/char/random.c Mon Feb 17 14:45:20 2003 +++ b/drivers/char/random.c Mon Mar 3 04:08:26 2003 @@ -1228,10 +1228,8 @@ * at which point we do a "catastrophic reseeding". */ static inline void xfer_secondary_pool(struct entropy_store *r, - size_t nbytes) + size_t nbytes, __u32 *tmp) { - __u32 tmp[TMP_BUF_SIZE]; - if (r->entropy_count < nbytes * 8 && r->entropy_count < r->poolinfo.POOLBITS) { int nwords = min_t(int, @@ -1284,7 +1282,7 @@ r->entropy_count = r->poolinfo.POOLBITS; if (flags & EXTRACT_ENTROPY_SECONDARY) - xfer_secondary_pool(r, nbytes); + xfer_secondary_pool(r, nbytes, tmp); DEBUG_ENT("%s has %d bits, want %d bits\n", r == sec_random_state ? "secondary" : diff -Nru a/drivers/char/rio/rio_linux.c b/drivers/char/rio/rio_linux.c --- a/drivers/char/rio/rio_linux.c Tue Feb 25 02:08:22 2003 +++ b/drivers/char/rio/rio_linux.c Thu Mar 6 09:17:26 2003 @@ -59,7 +59,6 @@ #include #include -#include #include #if BITS_PER_LONG != 32 @@ -725,14 +724,14 @@ switch (cmd) { #if 0 case TIOCGSOFTCAR: - rc = Put_user(((tty->termios->c_cflag & CLOCAL) ? 1 : 0), + rc = put_user(((tty->termios->c_cflag & CLOCAL) ? 1 : 0), (unsigned int *) arg); break; #endif case TIOCSSOFTCAR: if ((rc = verify_area(VERIFY_READ, (void *) arg, sizeof(int))) == 0) { - Get_user(ival, (unsigned int *) arg); + get_user(ival, (unsigned int *) arg); tty->termios->c_cflag = (tty->termios->c_cflag & ~CLOCAL) | (ival ? CLOCAL : 0); @@ -784,7 +783,7 @@ case TIOCMBIS: if ((rc = verify_area(VERIFY_READ, (void *) arg, sizeof(unsigned int))) == 0) { - Get_user(ival, (unsigned int *) arg); + get_user(ival, (unsigned int *) arg); rio_setsignals(port, ((ival & TIOCM_DTR) ? 1 : -1), ((ival & TIOCM_RTS) ? 1 : -1)); } @@ -792,7 +791,7 @@ case TIOCMBIC: if ((rc = verify_area(VERIFY_READ, (void *) arg, sizeof(unsigned int))) == 0) { - Get_user(ival, (unsigned int *) arg); + get_user(ival, (unsigned int *) arg); rio_setsignals(port, ((ival & TIOCM_DTR) ? 0 : -1), ((ival & TIOCM_RTS) ? 0 : -1)); } @@ -800,7 +799,7 @@ case TIOCMSET: if ((rc = verify_area(VERIFY_READ, (void *) arg, sizeof(unsigned int))) == 0) { - Get_user(ival, (unsigned int *) arg); + get_user(ival, (unsigned int *) arg); rio_setsignals(port, ((ival & TIOCM_DTR) ? 1 : 0), ((ival & TIOCM_RTS) ? 1 : 0)); } @@ -1126,7 +1125,7 @@ t, CNTRL_REG_GOODVALUE); writel (CNTRL_REG_GOODVALUE, rebase + CNTRL_REG_OFFSET); } - my_iounmap (hwbase, rebase); + iounmap((char*) rebase); } #endif @@ -1201,7 +1200,7 @@ hp = &p->RIOHosts[p->RIONumHosts]; hp->PaddrP = tint & PCI_BASE_ADDRESS_MEM_MASK; - hp->Ivec = get_irq (pdev); + hp->Ivec = pdev->irq; if (((1 << hp->Ivec) & rio_irqmask) == 0) hp->Ivec = 0; hp->CardP = (struct DpRam *) @@ -1234,8 +1233,7 @@ p->RIONumHosts++; found++; } else { - my_iounmap (p->RIOHosts[p->RIONumHosts].PaddrP, - p->RIOHosts[p->RIONumHosts].Caddr); + iounmap((char*) (p->RIOHosts[p->RIONumHosts].Caddr)); } #ifdef TWO_ZERO @@ -1272,7 +1270,7 @@ hp = &p->RIOHosts[p->RIONumHosts]; hp->PaddrP = tint & PCI_BASE_ADDRESS_MEM_MASK; - hp->Ivec = get_irq (pdev); + hp->Ivec = pdev->irq; if (((1 << hp->Ivec) & rio_irqmask) == 0) hp->Ivec = 0; hp->Ivec |= 0x8000; /* Mark as non-sharable */ @@ -1307,8 +1305,7 @@ p->RIONumHosts++; found++; } else { - my_iounmap (p->RIOHosts[p->RIONumHosts].PaddrP, - p->RIOHosts[p->RIONumHosts].Caddr); + iounmap((char*) (p->RIOHosts[p->RIONumHosts].Caddr)); } #else printk (KERN_ERR "Found an older RIO PCI card, but the driver is not " @@ -1361,7 +1358,7 @@ } if (!okboard) - my_iounmap (hp->PaddrP, hp->Caddr); + iounmap ((char*) (hp->Caddr)); } } diff -Nru a/drivers/char/rio/rioboot.c b/drivers/char/rio/rioboot.c --- a/drivers/char/rio/rioboot.c Sat Feb 15 13:50:01 2003 +++ b/drivers/char/rio/rioboot.c Sun Feb 16 16:15:30 2003 @@ -48,7 +48,6 @@ #include #include -#include #include diff -Nru a/drivers/char/rio/riocmd.c b/drivers/char/rio/riocmd.c --- a/drivers/char/rio/riocmd.c Thu Nov 21 09:58:01 2002 +++ b/drivers/char/rio/riocmd.c Sun Feb 16 16:15:30 2003 @@ -47,7 +47,6 @@ #include #include -#include #include #include "linux_compat.h" diff -Nru a/drivers/char/rio/rioctrl.c b/drivers/char/rio/rioctrl.c --- a/drivers/char/rio/rioctrl.c Tue Dec 3 13:17:27 2002 +++ b/drivers/char/rio/rioctrl.c Sun Feb 16 16:15:30 2003 @@ -47,7 +47,6 @@ #include #include -#include #include diff -Nru a/drivers/char/rio/rioinit.c b/drivers/char/rio/rioinit.c --- a/drivers/char/rio/rioinit.c Tue Feb 25 09:44:30 2003 +++ b/drivers/char/rio/rioinit.c Thu Mar 6 09:17:26 2003 @@ -47,7 +47,6 @@ #include #include -#include #include diff -Nru a/drivers/char/rio/riointr.c b/drivers/char/rio/riointr.c --- a/drivers/char/rio/riointr.c Mon Feb 4 23:45:07 2002 +++ b/drivers/char/rio/riointr.c Sun Feb 16 16:15:30 2003 @@ -48,7 +48,6 @@ #include #include -#include #include #include diff -Nru a/drivers/char/rio/rioparam.c b/drivers/char/rio/rioparam.c --- a/drivers/char/rio/rioparam.c Mon Feb 24 12:42:23 2003 +++ b/drivers/char/rio/rioparam.c Thu Mar 6 09:17:26 2003 @@ -48,7 +48,6 @@ #include #include -#include #include diff -Nru a/drivers/char/rio/rioroute.c b/drivers/char/rio/rioroute.c --- a/drivers/char/rio/rioroute.c Tue Feb 25 11:05:23 2003 +++ b/drivers/char/rio/rioroute.c Thu Mar 6 09:17:26 2003 @@ -46,7 +46,6 @@ #include #include -#include #include diff -Nru a/drivers/char/rio/riotable.c b/drivers/char/rio/riotable.c --- a/drivers/char/rio/riotable.c Tue Feb 25 11:05:23 2003 +++ b/drivers/char/rio/riotable.c Thu Mar 6 09:17:26 2003 @@ -48,7 +48,6 @@ #include #include -#include #include diff -Nru a/drivers/char/rio/riotty.c b/drivers/char/rio/riotty.c --- a/drivers/char/rio/riotty.c Tue Feb 25 02:17:56 2003 +++ b/drivers/char/rio/riotty.c Thu Mar 6 09:17:26 2003 @@ -51,7 +51,6 @@ #include -#include #include diff -Nru a/drivers/char/rtc.c b/drivers/char/rtc.c --- a/drivers/char/rtc.c Sat Feb 15 04:17:36 2003 +++ b/drivers/char/rtc.c Thu Mar 6 08:17:53 2003 @@ -152,6 +152,9 @@ static unsigned long rtc_max_user_freq = 64; /* > this, need CAP_SYS_RESOURCE */ #if RTC_IRQ +/* + * rtc_task_lock nests inside rtc_lock. + */ static spinlock_t rtc_task_lock = SPIN_LOCK_UNLOCKED; static rtc_task_t *rtc_callback = NULL; #endif @@ -746,13 +749,15 @@ #else unsigned char tmp; - spin_lock_irq(&rtc_task_lock); + spin_lock_irq(&rtc_lock); + spin_lock(&rtc_task_lock); if (rtc_callback != task) { - spin_unlock_irq(&rtc_task_lock); + spin_unlock(&rtc_task_lock); + spin_unlock_irq(&rtc_lock); return -ENXIO; } rtc_callback = NULL; - spin_lock(&rtc_lock); + /* disable controls */ tmp = CMOS_READ(RTC_CONTROL); tmp &= ~RTC_PIE; @@ -765,8 +770,8 @@ del_timer(&rtc_irq_timer); } rtc_status &= ~RTC_IS_OPEN; - spin_unlock(&rtc_lock); - spin_unlock_irq(&rtc_task_lock); + spin_unlock(&rtc_task_lock); + spin_unlock_irq(&rtc_lock); return 0; #endif } diff -Nru a/drivers/char/serial167.c b/drivers/char/serial167.c --- a/drivers/char/serial167.c Mon Nov 11 03:13:26 2002 +++ b/drivers/char/serial167.c Fri Feb 14 15:16:47 2003 @@ -2836,7 +2836,7 @@ }; -void __init serial167_console_init(void) +static void __init serial167_console_init(void) { if (vme_brdtype == VME_TYPE_MVME166 || vme_brdtype == VME_TYPE_MVME167 || @@ -2845,6 +2845,7 @@ register_console(&sercons); } } +console_initcall(serial167_console_init); #ifdef CONFIG_REMOTE_DEBUG void putDebugChar (int c) diff -Nru a/drivers/char/serial_tx3912.c b/drivers/char/serial_tx3912.c --- a/drivers/char/serial_tx3912.c Tue Nov 5 07:39:55 2002 +++ b/drivers/char/serial_tx3912.c Fri Feb 14 15:16:47 2003 @@ -1054,9 +1054,10 @@ .index = -1 }; -void __init tx3912_console_init(void) +static void __init tx3912_console_init(void) { register_console(&sercons); } +console_initcall(tx3912_console_init); #endif diff -Nru a/drivers/char/sh-sci.c b/drivers/char/sh-sci.c --- a/drivers/char/sh-sci.c Tue Nov 5 07:39:53 2002 +++ b/drivers/char/sh-sci.c Fri Feb 14 15:16:47 2003 @@ -1275,7 +1275,7 @@ extern void sh_console_unregister (void); #endif -void __init sci_console_init(void) +static void __init sci_console_init(void) { register_console(&sercons); #ifdef CONFIG_SH_EARLY_PRINTK @@ -1285,4 +1285,6 @@ sh_console_unregister(); #endif } +console_initcall(sci_console_init); + #endif /* CONFIG_SERIAL_CONSOLE */ diff -Nru a/drivers/char/tty_io.c b/drivers/char/tty_io.c --- a/drivers/char/tty_io.c Mon Mar 3 08:49:44 2003 +++ b/drivers/char/tty_io.c Thu Mar 6 09:17:26 2003 @@ -113,7 +113,15 @@ #define TTY_PARANOIA_CHECK 1 #define CHECK_TTY_COUNT 1 -struct termios tty_std_termios; /* for the benefit of tty drivers */ +struct termios tty_std_termios = { /* for the benefit of tty drivers */ + .c_iflag = ICRNL | IXON, + .c_oflag = OPOST | ONLCR, + .c_cflag = B38400 | CS8 | CREAD | HUPCL, + .c_lflag = ISIG | ICANON | ECHO | ECHOE | ECHOK | + ECHOCTL | ECHOKE | IEXTEN, + .c_cc = INIT_C_CC +}; + LIST_HEAD(tty_drivers); /* linked list of tty drivers */ struct tty_ldisc ldiscs[NR_LDISCS]; /* line disc dispatch table */ @@ -141,26 +149,13 @@ unsigned int cmd, unsigned long arg); static int tty_fasync(int fd, struct file * filp, int on); extern int vme_scc_init (void); -extern long vme_scc_console_init(void); extern int serial167_init(void); -extern long serial167_console_init(void); -extern void console_8xx_init(void); extern int rs_8xx_init(void); -extern void mac_scc_console_init(void); -extern void sclp_console_init(void); -extern void sclp_tty_init(void); -extern void con3215_init(void); -extern void tub3270_con_init(void); +extern void hwc_tty_init(void); +extern void tty3215_init(void); extern void tub3270_init(void); -extern void uart_console_init(void); -extern void sgi_serial_console_init(void); -extern void sci_console_init(void); -extern void m68328_console_init(void); -extern void mcfrs_console_init(void); extern void rs_360_init(void); -extern void tx3912_console_init(void); extern void tx3912_rs_init(void); -extern void hvc_console_init(void); static struct tty_struct *alloc_tty_struct(void) { @@ -306,13 +301,9 @@ if (tty->ldisc.open) retval = (tty->ldisc.open)(tty); if (retval < 0) { - module_put(tty->ldisc.owner); - tty->ldisc = o_ldisc; tty->termios->c_line = tty->ldisc.num; if (tty->ldisc.open && (tty->ldisc.open(tty) < 0)) { - module_put(tty->ldisc.owner); - tty->ldisc = ldiscs[N_TTY]; tty->termios->c_line = N_TTY; if (tty->ldisc.open) { @@ -2206,91 +2197,28 @@ */ void __init console_init(void) { + initcall_t *call; + /* Setup the default TTY line discipline. */ - memset(ldiscs, 0, sizeof(ldiscs)); (void) tty_register_ldisc(N_TTY, &tty_ldisc_N_TTY); /* - * Set up the standard termios. Individual tty drivers may - * deviate from this; this is used as a template. - */ - memset(&tty_std_termios, 0, sizeof(struct termios)); - memcpy(tty_std_termios.c_cc, INIT_C_CC, NCCS); - tty_std_termios.c_iflag = ICRNL | IXON; - tty_std_termios.c_oflag = OPOST | ONLCR; - tty_std_termios.c_cflag = B38400 | CS8 | CREAD | HUPCL; - tty_std_termios.c_lflag = ISIG | ICANON | ECHO | ECHOE | ECHOK | - ECHOCTL | ECHOKE | IEXTEN; - - /* * set up the console device so that later boot sequences can * inform about problems etc.. */ #ifdef CONFIG_EARLY_PRINTK disable_early_printk(); #endif -#ifdef CONFIG_VT - con_init(); -#endif -#ifdef CONFIG_AU1000_SERIAL_CONSOLE - au1000_serial_console_init(); -#endif -#ifdef CONFIG_SERIAL_CONSOLE -#if (defined(CONFIG_8xx) || defined(CONFIG_8260)) - console_8xx_init(); -#elif defined(CONFIG_MAC_SERIAL) - mac_scc_console_init(); -#elif defined(CONFIG_PARISC) - pdc_console_init(); -#elif defined(CONFIG_SERIAL) - serial_console_init(); -#endif /* CONFIG_8xx */ -#ifdef CONFIG_SGI_SERIAL - sgi_serial_console_init(); -#endif -#if defined(CONFIG_MVME162_SCC) || defined(CONFIG_BVME6000_SCC) || defined(CONFIG_MVME147_SCC) - vme_scc_console_init(); -#endif -#if defined(CONFIG_SERIAL167) - serial167_console_init(); -#endif -#if defined(CONFIG_SH_SCI) - sci_console_init(); -#endif -#endif -#ifdef CONFIG_TN3270_CONSOLE - tub3270_con_init(); -#endif -#ifdef CONFIG_TN3215_CONSOLE - con3215_init(); -#endif -#ifdef CONFIG_SCLP_CONSOLE - sclp_console_init(); -#endif -#ifdef CONFIG_STDIO_CONSOLE - stdio_console_init(); -#endif -#ifdef CONFIG_SERIAL_CORE_CONSOLE - uart_console_init(); -#endif -#ifdef CONFIG_ARC_CONSOLE - arc_console_init(); -#endif -#ifdef CONFIG_SERIAL_68328 - m68328_console_init(); -#endif -#ifdef CONFIG_SERIAL_COLDFIRE - mcfrs_console_init(); -#endif #ifdef CONFIG_SERIAL_68360 - rs_360_init(); -#endif -#ifdef CONFIG_SERIAL_TX3912_CONSOLE - tx3912_console_init(); -#endif -#ifdef CONFIG_HVC_CONSOLE - hvc_console_init(); -#endif + /* This is not a console initcall. I know not what it's doing here. + So I haven't moved it. dwmw2 */ + rs_360_init(); +#endif + call = &__con_initcall_start; + while (call < &__con_initcall_end) { + (*call)(); + call++; + } } static struct tty_driver dev_tty_driver, dev_syscons_driver; diff -Nru a/drivers/char/vme_scc.c b/drivers/char/vme_scc.c --- a/drivers/char/vme_scc.c Thu Nov 7 15:06:42 2002 +++ b/drivers/char/vme_scc.c Fri Feb 14 15:18:33 2003 @@ -1091,7 +1091,7 @@ }; -void __init vme_scc_console_init(void) +static void __init vme_scc_console_init(void) { if (vme_brdtype == VME_TYPE_MVME147 || vme_brdtype == VME_TYPE_MVME162 || @@ -1100,4 +1100,4 @@ vme_brdtype == VME_TYPE_BVME6000) register_console(&sercons); } - +console_initcall(vme_scc_console_init); diff -Nru a/drivers/char/vt.c b/drivers/char/vt.c --- a/drivers/char/vt.c Tue Feb 25 09:17:44 2003 +++ b/drivers/char/vt.c Thu Mar 6 21:27:16 2003 @@ -2443,7 +2443,7 @@ struct tty_driver console_driver; static int console_refcount; -void __init con_init(void) +static int __init con_init(void) { const char *display_desc = NULL; unsigned int currcons = 0; @@ -2452,7 +2452,7 @@ display_desc = conswitchp->con_startup(); if (!display_desc) { fg_console = 0; - return; + return 0; } init_timer(&console_timer); @@ -2491,7 +2491,9 @@ #ifdef CONFIG_VT_CONSOLE register_console(&vt_console_driver); #endif + return 0; } +console_initcall(con_init); int __init vty_init(void) { diff -Nru a/drivers/cpufreq/userspace.c b/drivers/cpufreq/userspace.c --- a/drivers/cpufreq/userspace.c Sun Feb 16 05:23:39 2003 +++ b/drivers/cpufreq/userspace.c Wed Mar 5 15:44:20 2003 @@ -511,7 +511,7 @@ cpu_min_freq[cpu] = policy->min; cpu_max_freq[cpu] = policy->max; cpu_cur_freq[cpu] = policy->cur; - device_create_file (policy->intf.dev, &dev_attr_scaling_setspeed); + device_create_file (policy->dev, &dev_attr_scaling_setspeed); memcpy (¤t_policy[cpu], policy, sizeof(struct cpufreq_policy)); up(&userspace_sem); break; @@ -520,7 +520,7 @@ cpu_is_managed[cpu] = 0; cpu_min_freq[cpu] = 0; cpu_max_freq[cpu] = 0; - device_remove_file (policy->intf.dev, &dev_attr_scaling_setspeed); + device_remove_file (policy->dev, &dev_attr_scaling_setspeed); up(&userspace_sem); module_put(THIS_MODULE); break; diff -Nru a/drivers/hotplug/acpiphp_glue.c b/drivers/hotplug/acpiphp_glue.c --- a/drivers/hotplug/acpiphp_glue.c Thu Feb 27 16:27:27 2003 +++ b/drivers/hotplug/acpiphp_glue.c Mon Feb 24 03:28:46 2003 @@ -801,7 +801,7 @@ static int enable_device (struct acpiphp_slot *slot) { u8 bus; - struct pci_dev dev0, *dev; + struct pci_dev *dev; struct pci_bus *child; struct list_head *l; struct acpiphp_func *func; @@ -824,16 +824,8 @@ if (retval) goto err_exit; - memset(&dev0, 0, sizeof (struct pci_dev)); - - dev0.bus = slot->bridge->pci_bus; - dev0.devfn = PCI_DEVFN(slot->device, 0); - dev0.sysdata = dev0.bus->sysdata; - dev0.dev.parent = dev0.bus->dev; - dev0.dev.bus = &pci_bus_type; - /* returned `dev' is the *first function* only! */ - dev = pci_scan_slot (&dev0); + dev = pci_scan_slot(slot->bridge->pci_bus, PCI_DEVFN(slot->device, 0)); if (!dev) { err("No new device found\n"); diff -Nru a/drivers/hotplug/cpci_hotplug_pci.c b/drivers/hotplug/cpci_hotplug_pci.c --- a/drivers/hotplug/cpci_hotplug_pci.c Mon Feb 24 08:17:14 2003 +++ b/drivers/hotplug/cpci_hotplug_pci.c Mon Feb 24 03:29:36 2003 @@ -574,19 +574,13 @@ /* Still NULL? Well then scan for it! */ if(slot->dev == NULL) { - struct pci_dev dev0; - dbg("pci_dev still null"); - memset(&dev0, 0, sizeof (struct pci_dev)); - dev0.bus = slot->bus; - dev0.devfn = slot->devfn; - dev0.sysdata = slot->bus->self->sysdata; /* * This will generate pci_dev structures for all functions, but * we will only call this case when lookup fails. */ - slot->dev = pci_scan_slot(&dev0); + slot->dev = pci_scan_slot(slot->bus, slot->devfn); if(slot->dev == NULL) { err("Could not find PCI device for slot %02x", slot->number); return 0; diff -Nru a/drivers/hotplug/cpqphp_pci.c b/drivers/hotplug/cpqphp_pci.c --- a/drivers/hotplug/cpqphp_pci.c Mon Feb 24 08:17:34 2003 +++ b/drivers/hotplug/cpqphp_pci.c Mon Feb 24 03:31:07 2003 @@ -84,24 +84,19 @@ int cpqhp_configure_device (struct controller* ctrl, struct pci_func* func) { unsigned char bus; - struct pci_dev dev0; struct pci_bus *child; int rc = 0; - memset(&dev0, 0, sizeof(struct pci_dev)); - if (func->pci_dev == NULL) func->pci_dev = pci_find_slot(func->bus, (func->device << 3) | (func->function & 0x7)); //Still NULL ? Well then scan for it ! if (func->pci_dev == NULL) { dbg("INFO: pci_dev still null\n"); - dev0.bus = ctrl->pci_dev->bus; - dev0.devfn = (func->device << 3) + (func->function & 0x7); - dev0.sysdata = ctrl->pci_dev->sysdata; //this will generate pci_dev structures for all functions, but we will only call this case when lookup fails - func->pci_dev = pci_scan_slot(&dev0); + func->pci_dev = pci_scan_slot(ctrl->pci_dev->bus, + (func->device << 3) + (func->function & 0x7)); if (func->pci_dev == NULL) { dbg("ERROR: pci_dev still null\n"); return 0; diff -Nru a/drivers/hotplug/ibmphp_core.c b/drivers/hotplug/ibmphp_core.c --- a/drivers/hotplug/ibmphp_core.c Thu Feb 27 13:49:39 2003 +++ b/drivers/hotplug/ibmphp_core.c Mon Feb 24 03:32:11 2003 @@ -845,26 +845,22 @@ static int ibm_configure_device (struct pci_func *func) { unsigned char bus; - struct pci_dev dev0; struct pci_bus *child; int rc = 0; int flag = 0; /* this is to make sure we don't double scan the bus, for bridged devices primarily */ - memset (&dev0, 0, sizeof (struct pci_dev)); - if (!(bus_structure_fixup (func->busno))) flag = 1; if (func->dev == NULL) func->dev = pci_find_slot (func->busno, (func->device << 3) | (func->function & 0x7)); if (func->dev == NULL) { - dev0.bus = ibmphp_find_bus (func->busno); - if (!dev0.bus) + struct pci_bus *bus = ibmphp_find_bus (func->busno); + if (!bus) return 0; - dev0.devfn = ((func->device << 3) + (func->function & 0x7)); - dev0.sysdata = dev0.bus->sysdata; - func->dev = pci_scan_slot (&dev0); + func->dev = pci_scan_slot(bus, + (func->device << 3) + (func->function & 0x7)); if (func->dev == NULL) { err ("ERROR... : pci_dev still NULL \n"); diff -Nru a/drivers/ide/Makefile b/drivers/ide/Makefile --- a/drivers/ide/Makefile Wed Feb 19 09:48:49 2003 +++ b/drivers/ide/Makefile Mon Mar 3 12:06:45 2003 @@ -28,3 +28,4 @@ endif obj-$(CONFIG_BLK_DEV_IDE) += legacy/ ppc/ arm/ +obj-$(CONFIG_BLK_DEV_HD) += legacy/ diff -Nru a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c --- a/drivers/ide/ide-disk.c Wed Nov 13 14:49:14 2002 +++ b/drivers/ide/ide-disk.c Tue Feb 18 10:06:17 2003 @@ -38,9 +38,11 @@ * Version 1.15 convert all calls to ide_raw_taskfile * since args will return register content. * Version 1.16 added suspend-resume-checkpower + * Version 1.17 do flush on standy, do flush on ATA < ATA6 + * fix wcache setup. */ -#define IDEDISK_VERSION "1.16" +#define IDEDISK_VERSION "1.17" #undef REALLY_SLOW_IO /* most systems can safely undef this */ @@ -140,7 +142,7 @@ static ide_startstop_t read_intr (ide_drive_t *drive) { ide_hwif_t *hwif = HWIF(drive); - int i = 0, nsect = 0, msect = drive->mult_count; + u32 i = 0, nsect = 0, msect = drive->mult_count; struct request *rq; unsigned long flags; u8 stat; @@ -157,7 +159,7 @@ ide_set_handler(drive, &read_intr, WAIT_CMD, NULL); return ide_started; } - + read_next: rq = HWGROUP(drive)->rq; if (msect) { @@ -203,7 +205,7 @@ ide_hwgroup_t *hwgroup = HWGROUP(drive); ide_hwif_t *hwif = HWIF(drive); struct request *rq = hwgroup->rq; - int i = 0; + u32 i = 0; u8 stat; if (!OK_STAT(stat = hwif->INB(IDE_STATUS_REG), @@ -506,14 +508,10 @@ if (drive->using_dma && !hwif->ide_dma_read(drive)) return ide_started; - if (HWGROUP(drive)->handler != NULL) - BUG(); - ide_set_handler(drive, &read_intr, WAIT_CMD, NULL); - command = ((drive->mult_count) ? ((lba48) ? WIN_MULTREAD_EXT : WIN_MULTREAD) : ((lba48) ? WIN_READ_EXT : WIN_READ)); - hwif->OUTB(command, IDE_COMMAND_REG); + ide_execute_command(drive, command, &read_intr, WAIT_CMD, NULL); return ide_started; } else if (rq_data_dir(rq) == WRITE) { ide_startstop_t startstop; @@ -628,11 +626,7 @@ static task_ioreg_t get_command (ide_drive_t *drive, int cmd) { - int lba48bit = (drive->id->cfs_enable_2 & 0x0400) ? 1 : 0; - -#if 1 - lba48bit = (drive->addressing == 1) ? 1 : 0; -#endif + int lba48bit = (drive->addressing == 1) ? 1 : 0; if ((cmd == READ) && drive->using_tcq) return lba48bit ? WIN_READDMA_QUEUED_EXT : WIN_READDMA_QUEUED; @@ -1412,32 +1406,6 @@ return call_idedisk_standby(drive, 0); } -#if 0 -static int call_idedisk_checkpower (ide_drive_t *drive, int arg) -{ - ide_task_t args; - u8 ckpw = (arg) ? WIN_CHECKPOWERMODE2 : WIN_CHECKPOWERMODE1; - memset(&args, 0, sizeof(ide_task_t)); - args.tfRegister[IDE_COMMAND_OFFSET] = ckpw; - args.command_type = ide_cmd_type_parser(&args); - ide_raw_taskfile(drive, &args, NULL); -#if 0 -if (errno != EIO || args[0] != 0 || args[1] != 0) - state = "unknown"; -else - state = "sleeping"; -} else { - state = (args[2] == 255) ? "active/idle" : "standby"; -#endif - return 0; -} - -static int do_idedisk_checkpower (ide_drive_t *drive) -{ - return call_idedisk_checkpower(drive, 0); -} -#endif - static int do_idedisk_flushcache (ide_drive_t *drive) { ide_task_t args; @@ -1596,13 +1564,8 @@ drive->doorlocking = 1; } } -#if 1 + (void) probe_lba_addressing(drive, 1); -#else - /* if using 48-bit addressing bump the request size up */ - if (probe_lba_addressing(drive, 1)) - blk_queue_max_sectors(&drive->queue, 2048); -#endif /* Extract geometry if we did not already have one for the drive */ if (!drive->cyl || !drive->head || !drive->sect) { @@ -1675,13 +1638,9 @@ static int idedisk_cleanup (ide_drive_t *drive) { + static int ide_cacheflush_p(ide_drive_t *drive); struct gendisk *g = drive->disk; - - do_idedisk_standby(drive); - if ((drive->id->cfs_enable_2 & 0x3000) && drive->wcache) - if (do_idedisk_flushcache(drive)) - printk (KERN_INFO "%s: Write Cache FAILED Flushing!\n", - drive->name); + ide_cacheflush_p(drive); if (ide_unregister_subdriver(drive)) return 1; del_gendisk(g); @@ -1725,6 +1684,7 @@ drive->usage++; if (drive->removable && drive->usage == 1) { ide_task_t args; + u8 cf; memset(&args, 0, sizeof(ide_task_t)); args.tfRegister[IDE_COMMAND_OFFSET] = WIN_DOORLOCK; args.command_type = ide_cmd_type_parser(&args); @@ -1736,6 +1696,32 @@ */ if (drive->doorlocking && ide_raw_taskfile(drive, &args, NULL)) drive->doorlocking = 0; + drive->wcache = 0; + /* Cache enabled ? */ + if (drive->id->csfo & 1) + drive->wcache = 1; + /* Cache command set available ? */ + if (drive->id->cfs_enable_1 & (1<<5)) + drive->wcache = 1; + /* ATA6 cache extended commands */ + cf = drive->id->command_set_2 >> 24; + if((cf & 0xC0) == 0x40 && (cf & 0x30) != 0) + drive->wcache = 1; + } + return 0; +} + +static int ide_cacheflush_p(ide_drive_t *drive) +{ + if(drive->wcache) + { + if (do_idedisk_flushcache(drive)) + { + printk (KERN_INFO "%s: Write Cache FAILED Flushing!\n", + drive->name); + return -EIO; + } + return 1; } return 0; } @@ -1752,10 +1738,7 @@ if (drive->doorlocking && ide_raw_taskfile(drive, &args, NULL)) drive->doorlocking = 0; } - if ((drive->id->cfs_enable_2 & 0x3000) && drive->wcache) - if (do_idedisk_flushcache(drive)) - printk (KERN_INFO "%s: Write Cache FAILED Flushing!\n", - drive->name); + ide_cacheflush_p(drive); drive->usage--; return 0; } diff -Nru a/drivers/ide/ide-dma.c b/drivers/ide/ide-dma.c --- a/drivers/ide/ide-dma.c Tue Feb 25 02:43:50 2003 +++ b/drivers/ide/ide-dma.c Thu Mar 6 09:21:37 2003 @@ -664,11 +664,6 @@ if (drive->media != ide_disk) return 0; - /* paranoia check */ - if (HWGROUP(drive)->handler != NULL) - BUG(); - ide_set_handler(drive, &ide_dma_intr, 2*WAIT_CMD, dma_timer_expiry); - command = (lba48) ? WIN_READDMA_EXT : WIN_READDMA; if (drive->vdma) @@ -680,8 +675,7 @@ } /* issue cmd to drive */ - hwif->OUTB(command, IDE_COMMAND_REG); - + ide_execute_command(drive, command, &ide_dma_intr, 2*WAIT_CMD, dma_timer_expiry); return HWIF(drive)->ide_dma_count(drive); } @@ -702,11 +696,6 @@ if (drive->media != ide_disk) return 0; - /* paranoia check */ - if (HWGROUP(drive)->handler != NULL) - BUG(); - ide_set_handler(drive, &ide_dma_intr, 2*WAIT_CMD, dma_timer_expiry); - command = (lba48) ? WIN_WRITEDMA_EXT : WIN_WRITEDMA; if (drive->vdma) command = (lba48) ? WIN_WRITE_EXT: WIN_WRITE; @@ -717,7 +706,7 @@ } /* issue cmd to drive */ - hwif->OUTB(command, IDE_COMMAND_REG); + ide_execute_command(drive, command, &ide_dma_intr, 2*WAIT_CMD, dma_timer_expiry); return HWIF(drive)->ide_dma_count(drive); } diff -Nru a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c --- a/drivers/ide/ide-floppy.c Tue Feb 18 10:06:17 2003 +++ b/drivers/ide/ide-floppy.c Tue Feb 18 10:06:17 2003 @@ -1077,14 +1077,11 @@ } if (test_bit (IDEFLOPPY_DRQ_INTERRUPT, &floppy->flags)) { - if (HWGROUP(drive)->handler != NULL) - BUG(); - ide_set_handler(drive, + /* Issue the packet command */ + ide_execute_command(drive, WIN_PACKETCMD, pkt_xfer_routine, IDEFLOPPY_WAIT_CMD, NULL); - /* Issue the packet command */ - HWIF(drive)->OUTB(WIN_PACKETCMD, IDE_COMMAND_REG); return ide_started; } else { /* Issue the packet command */ diff -Nru a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c --- a/drivers/ide/ide-io.c Mon Feb 24 10:30:38 2003 +++ b/drivers/ide/ide-io.c Thu Mar 6 09:21:48 2003 @@ -358,18 +358,15 @@ * Issue a simple drive command with interrupts. * The drive must be selected beforehand. */ - + void ide_cmd (ide_drive_t *drive, u8 cmd, u8 nsect, ide_handler_t *handler) { ide_hwif_t *hwif = HWIF(drive); - if (HWGROUP(drive)->handler != NULL) - BUG(); - ide_set_handler(drive, handler, WAIT_CMD, NULL); if (IDE_CONTROL_REG) hwif->OUTB(drive->ctl,IDE_CONTROL_REG); /* clear nIEN */ SELECT_MASK(drive,0); hwif->OUTB(nsect,IDE_NSECTOR_REG); - hwif->OUTB(cmd,IDE_COMMAND_REG); + ide_execute_command(drive, cmd, handler, WAIT_CMD, NULL); } EXPORT_SYMBOL(ide_cmd); @@ -841,14 +838,14 @@ * happens anyway when any interrupt comes in, IDE or otherwise * -- the kernel masks the IRQ while it is being handled. */ - if (masked_irq && hwif->irq != masked_irq) + if (hwif->irq != masked_irq) disable_irq_nosync(hwif->irq); spin_unlock(&ide_lock); local_irq_enable(); /* allow other IRQs while we start this request */ startstop = start_request(drive, rq); spin_lock_irq(&ide_lock); - if (masked_irq && hwif->irq != masked_irq) + if (hwif->irq != masked_irq) enable_irq(hwif->irq); if (startstop == ide_released) goto queue_next; @@ -864,7 +861,7 @@ */ void do_ide_request(request_queue_t *q) { - ide_do_request(q->queuedata, 0); + ide_do_request(q->queuedata, IDE_NO_IRQ); } /* @@ -1012,7 +1009,7 @@ hwgroup->busy = 0; } } - ide_do_request(hwgroup, 0); + ide_do_request(hwgroup, IDE_NO_IRQ); spin_unlock_irqrestore(&ide_lock, flags); } @@ -1302,7 +1299,7 @@ insert_end = 0; } __elv_add_request(&drive->queue, rq, insert_end, 0); - ide_do_request(hwgroup, 0); + ide_do_request(hwgroup, IDE_NO_IRQ); spin_unlock_irqrestore(&ide_lock, flags); err = 0; diff -Nru a/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c --- a/drivers/ide/ide-iops.c Tue Feb 18 10:06:17 2003 +++ b/drivers/ide/ide-iops.c Thu Feb 20 08:50:44 2003 @@ -59,11 +59,11 @@ { } -static void ide_unplugged_outb (u8 addr, unsigned long port) +static void ide_unplugged_outb (u8 val, unsigned long port) { } -static void ide_unplugged_outw (u16 addr, unsigned long port) +static void ide_unplugged_outw (u16 val, unsigned long port) { } @@ -71,7 +71,7 @@ { } -static void ide_unplugged_outl (u32 addr, unsigned long port) +static void ide_unplugged_outl (u32 val, unsigned long port) { } @@ -125,14 +125,14 @@ insl(port, addr, count); } -static void ide_outb (u8 addr, unsigned long port) +static void ide_outb (u8 val, unsigned long port) { - outb(addr, port); + outb(val, port); } -static void ide_outw (u16 addr, unsigned long port) +static void ide_outw (u16 val, unsigned long port) { - outw(addr, port); + outw(val, port); } static void ide_outsw (unsigned long port, void *addr, u32 count) @@ -140,9 +140,9 @@ outsw(port, addr, count); } -static void ide_outl (u32 addr, unsigned long port) +static void ide_outl (u32 val, unsigned long port) { - outl(addr, port); + outl(val, port); } static void ide_outsl (unsigned long port, void *addr, u32 count) diff -Nru a/drivers/ide/ide-lib.c b/drivers/ide/ide-lib.c --- a/drivers/ide/ide-lib.c Thu Nov 14 09:12:22 2002 +++ b/drivers/ide/ide-lib.c Tue Feb 18 10:06:17 2003 @@ -171,7 +171,7 @@ BUG(); return min(speed, speed_max[mode]); #else /* !CONFIG_BLK_DEV_IDEDMA */ - return min(speed, (u8)XFER_PIO_4); + return min(speed, XFER_PIO_4); #endif /* CONFIG_BLK_DEV_IDEDMA */ } diff -Nru a/drivers/ide/ide-taskfile.c b/drivers/ide/ide-taskfile.c --- a/drivers/ide/ide-taskfile.c Wed Nov 13 07:06:17 2002 +++ b/drivers/ide/ide-taskfile.c Tue Feb 18 10:06:17 2003 @@ -177,8 +177,7 @@ hwif->OUTB((taskfile->device_head & HIHI) | drive->select.all, IDE_SELECT_REG); if (task->handler != NULL) { - ide_set_handler(drive, task->handler, WAIT_WORSTCASE, NULL); - hwif->OUTB(taskfile->command, IDE_COMMAND_REG); + ide_execute_command(drive, taskfile->command, task->handler, WAIT_WORSTCASE, NULL); if (task->prehandler != NULL) return task->prehandler(drive, task->rq); return ide_started; @@ -1880,9 +1879,8 @@ if (task->handler == NULL) return ide_stopped; - ide_set_handler(drive, task->handler, WAIT_WORSTCASE, NULL); /* Issue the command */ - hwif->OUTB(taskfile->command, IDE_COMMAND_REG); + ide_execute_command(drive, taskfile->command, task->handler, WAIT_WORSTCASE, NULL); if (task->prehandler != NULL) return task->prehandler(drive, HWGROUP(drive)->rq); } diff -Nru a/drivers/ide/pci/amd74xx.c b/drivers/ide/pci/amd74xx.c --- a/drivers/ide/pci/amd74xx.c Wed Feb 19 12:15:57 2003 +++ b/drivers/ide/pci/amd74xx.c Mon Mar 3 12:09:31 2003 @@ -82,7 +82,7 @@ #include #include -static long amd_base; +static unsigned long amd_base; static struct pci_dev *bmide_dev; extern int (*amd74xx_display_info)(char *, char **, off_t, int); /* ide-proc.c */ @@ -102,7 +102,7 @@ amd_print("----------AMD BusMastering IDE Configuration----------------"); - amd_print("Driver Version: 2.8"); + amd_print("Driver Version: 2.9"); amd_print("South Bridge: %s", bmide_dev->dev.name); pci_read_config_byte(dev, PCI_REVISION_ID, &t); @@ -284,7 +284,7 @@ * and initialize its drive independent registers. */ -unsigned int __init init_chipset_amd74xx(struct pci_dev *dev, const char *name) +static unsigned int __init init_chipset_amd74xx(struct pci_dev *dev, const char *name) { unsigned char t; unsigned int u; @@ -378,12 +378,12 @@ return 0; } -unsigned int __init ata66_amd74xx(ide_hwif_t *hwif) +static unsigned int __init ata66_amd74xx(ide_hwif_t *hwif) { return ((amd_enabled & amd_80w) >> hwif->channel) & 1; } -void __init init_hwif_amd74xx(ide_hwif_t *hwif) +static void __init init_hwif_amd74xx(ide_hwif_t *hwif) { int i; diff -Nru a/drivers/ide/pci/via82cxxx.c b/drivers/ide/pci/via82cxxx.c --- a/drivers/ide/pci/via82cxxx.c Wed Feb 19 12:13:48 2003 +++ b/drivers/ide/pci/via82cxxx.c Mon Mar 3 12:11:59 2003 @@ -1,16 +1,6 @@ /* - * $Id: via82cxxx.c,v 3.35-ac2 2002/09/111 Alan Exp $ * - * Copyright (c) 2000-2001 Vojtech Pavlik - * - * Based on the work of: - * Michel Aubry - * Jeff Garzik - * Andre Hedrick - */ - -/* - * Version 3.35 + * Version 3.36 * * VIA IDE driver for Linux. Supported southbridges: * @@ -24,6 +14,10 @@ * Michel Aubry * Jeff Garzik * Andre Hedrick + * + * Documentation: + * Obsolete device documentation publically available from via.com.tw + * Current device documentation available under NDA only */ /* @@ -67,6 +61,7 @@ #define VIA_SET_FIFO 0x040 /* Needs to have FIFO split set */ #define VIA_NO_UNMASK 0x080 /* Doesn't work with IRQ unmasking on */ #define VIA_BAD_ID 0x100 /* Has wrong vendor ID (0x1107) */ +#define VIA_BAD_AST 0x200 /* Don't touch Address Setup Timing */ /* * VIA SouthBridge chips. @@ -82,8 +77,8 @@ #ifdef FUTURE_BRIDGES { "vt8237", PCI_DEVICE_ID_VIA_8237, 0x00, 0x2f, VIA_UDMA_133 }, #endif - { "vt8235", PCI_DEVICE_ID_VIA_8235, 0x00, 0x2f, VIA_UDMA_133 }, - { "vt8233a", PCI_DEVICE_ID_VIA_8233A, 0x00, 0x2f, VIA_UDMA_133 }, + { "vt8235", PCI_DEVICE_ID_VIA_8235, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST }, + { "vt8233a", PCI_DEVICE_ID_VIA_8233A, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST }, { "vt8233c", PCI_DEVICE_ID_VIA_8233C_0, 0x00, 0x2f, VIA_UDMA_100 }, { "vt8233", PCI_DEVICE_ID_VIA_8233_0, 0x00, 0x2f, VIA_UDMA_100 }, { "vt8231", PCI_DEVICE_ID_VIA_8231, 0x00, 0x2f, VIA_UDMA_100 }, @@ -152,7 +147,7 @@ via_print("----------VIA BusMastering IDE Configuration" "----------------"); - via_print("Driver Version: 3.35-ac"); + via_print("Driver Version: 3.36"); via_print("South Bridge: VIA %s", via_config->name); @@ -292,9 +287,11 @@ { u8 t; - pci_read_config_byte(dev, VIA_ADDRESS_SETUP, &t); - t = (t & ~(3 << ((3 - dn) << 1))) | ((FIT(timing->setup, 1, 4) - 1) << ((3 - dn) << 1)); - pci_write_config_byte(dev, VIA_ADDRESS_SETUP, t); + if (~via_config->flags & VIA_BAD_AST) { + pci_read_config_byte(dev, VIA_ADDRESS_SETUP, &t); + t = (t & ~(3 << ((3 - dn) << 1))) | ((FIT(timing->setup, 1, 4) - 1) << ((3 - dn) << 1)); + pci_write_config_byte(dev, VIA_ADDRESS_SETUP, t); + } pci_write_config_byte(dev, VIA_8BIT_TIMING + (1 - (dn >> 1)), ((FIT(timing->act8b, 1, 16) - 1) << 4) | (FIT(timing->rec8b, 1, 16) - 1)); diff -Nru a/drivers/macintosh/macserial.c b/drivers/macintosh/macserial.c --- a/drivers/macintosh/macserial.c Mon Nov 11 05:18:24 2002 +++ b/drivers/macintosh/macserial.c Fri Feb 14 15:20:31 2003 @@ -3043,10 +3043,12 @@ /* * Register console. */ -void __init mac_scc_console_init(void) +static void __init mac_scc_console_init(void) { register_console(&sercons); } +console_initcall(mac_scc_console_init); + #endif /* ifdef CONFIG_SERIAL_CONSOLE */ #ifdef CONFIG_KGDB diff -Nru a/drivers/media/video/bw-qcam.c b/drivers/media/video/bw-qcam.c --- a/drivers/media/video/bw-qcam.c Fri Nov 29 08:30:40 2002 +++ b/drivers/media/video/bw-qcam.c Sun Feb 16 16:16:53 2003 @@ -83,11 +83,9 @@ static unsigned int yieldlines=4; /* Yield after this many during capture */ static int video_nr = -1; -#if LINUX_VERSION_CODE >= 0x020117 MODULE_PARM(maxpoll,"i"); MODULE_PARM(yieldlines,"i"); MODULE_PARM(video_nr,"i"); -#endif static inline int read_lpstatus(struct qcam_device *q) { diff -Nru a/drivers/media/video/planb.c b/drivers/media/video/planb.c --- a/drivers/media/video/planb.c Fri Nov 29 08:30:40 2002 +++ b/drivers/media/video/planb.c Sun Feb 16 16:16:53 2003 @@ -181,12 +181,7 @@ /* Let's wait 30msec for this one */ current->state = TASK_INTERRUPTIBLE; -#if LINUX_VERSION_CODE >= 0x02017F schedule_timeout(30 * HZ / 1000); -#else - current->timeout = jiffies + 30 * HZ / 1000; /* 30 ms */; - schedule(); -#endif return (unsigned char)in_8 (&planb_regs->saa_status); } diff -Nru a/drivers/media/video/zoran.h b/drivers/media/video/zoran.h --- a/drivers/media/video/zoran.h Tue Feb 5 11:10:31 2002 +++ b/drivers/media/video/zoran.h Sun Feb 16 16:16:53 2003 @@ -32,10 +32,6 @@ #include -#if LINUX_VERSION_CODE < 0x20212 -typedef struct wait_queue *wait_queue_head_t; -#endif - /* The Buz only supports a maximum width of 720, but some V4L applications (e.g. xawtv are more happy with 768). If XAWTV_HACK is defined, we try to fake a device with bigger width */ diff -Nru a/drivers/media/video/zr36120.c b/drivers/media/video/zr36120.c --- a/drivers/media/video/zr36120.c Thu Feb 6 07:33:47 2003 +++ b/drivers/media/video/zr36120.c Sun Feb 16 16:16:53 2003 @@ -943,7 +943,6 @@ return -EINVAL; } -#if LINUX_VERSION_CODE >= 0x020100 static unsigned int zoran_poll(struct video_device *dev, struct file *file, poll_table *wait) { @@ -964,7 +963,6 @@ return mask; } -#endif /* append a new clipregion to the vector of video_clips */ static @@ -1745,7 +1743,6 @@ return count; } -#if LINUX_VERSION_CODE >= 0x020100 static unsigned int vbi_poll(struct video_device *dev, struct file *file, poll_table *wait) { @@ -1766,7 +1763,6 @@ return mask; } -#endif static int vbi_ioctl(struct video_device *dev, unsigned int cmd, void *arg) diff -Nru a/drivers/message/fusion/lsi/mpi_raid.h b/drivers/message/fusion/lsi/mpi_raid.h --- a/drivers/message/fusion/lsi/mpi_raid.h Fri Feb 21 06:26:38 2003 +++ b/drivers/message/fusion/lsi/mpi_raid.h Thu Feb 20 08:33:15 2003 @@ -184,7 +184,7 @@ /****************************************************************************/ -/* Mailbox reqeust structure */ +/* Mailbox request structure */ /****************************************************************************/ typedef struct _MSG_MAILBOX_REQUEST diff -Nru a/drivers/net/dgrs.c b/drivers/net/dgrs.c --- a/drivers/net/dgrs.c Tue Feb 25 11:05:27 2003 +++ b/drivers/net/dgrs.c Tue Mar 4 22:44:07 2003 @@ -981,7 +981,7 @@ { DGRS_PRIV *priv0 = (DGRS_PRIV *) dev0->priv; int is; - int i; + unsigned long i; static int iv2is[16] = { 0, 0, 0, ES4H_IS_INT3, @@ -1140,7 +1140,7 @@ dgrs_probe1(struct net_device *dev) { DGRS_PRIV *priv = (DGRS_PRIV *) dev->priv; - int i; + unsigned long i; int rc; printk("%s: Digi RightSwitch io=%lx mem=%lx irq=%d plx=%lx dma=%lx\n", diff -Nru a/drivers/net/eth16i.c b/drivers/net/eth16i.c --- a/drivers/net/eth16i.c Tue Feb 25 02:08:43 2003 +++ b/drivers/net/eth16i.c Thu Mar 6 09:23:56 2003 @@ -1404,7 +1404,6 @@ static char* mediatype[MAX_ETH16I_CARDS]; static int debug = -1; -#if (LINUX_VERSION_CODE >= 0x20115) MODULE_AUTHOR("Mika Kuoppala "); MODULE_DESCRIPTION("ICL EtherTeam 16i/32 driver"); MODULE_LICENSE("GPL"); @@ -1423,7 +1422,6 @@ MODULE_PARM(debug, "i"); MODULE_PARM_DESC(debug, "eth16i debug level (0-6)"); -#endif int init_module(void) { diff -Nru a/drivers/net/mac8390.c b/drivers/net/mac8390.c --- a/drivers/net/mac8390.c Sun Feb 9 17:29:54 2003 +++ b/drivers/net/mac8390.c Sun Feb 16 16:17:32 2003 @@ -376,11 +376,9 @@ } #ifdef MODULE -#if LINUX_VERSION_CODE > 0x20118 MODULE_AUTHOR("David Huggins-Daines and others"); MODULE_DESCRIPTION("Macintosh NS8390-based Nubus Ethernet driver"); MODUEL_LICENSE("GPL"); -#endif int init_module(void) { diff -Nru a/drivers/net/pppoe.c b/drivers/net/pppoe.c --- a/drivers/net/pppoe.c Tue Feb 25 09:17:47 2003 +++ b/drivers/net/pppoe.c Mon Mar 3 04:56:52 2003 @@ -538,7 +538,7 @@ if (!sk) return 0; - if (sk->dead != 0) + if (test_bit(SOCK_DEAD, &sk->flags)) return -EBADF; pppox_unbind_sock(sk); @@ -788,7 +788,7 @@ struct net_device *dev; char *start; - if (sk->dead || !(sk->state & PPPOX_CONNECTED)) { + if (test_bit(SOCK_DEAD, &sk->flags) || !(sk->state & PPPOX_CONNECTED)) { error = -ENOTCONN; goto end; } @@ -864,7 +864,7 @@ int data_len = skb->len; struct sk_buff *skb2; - if (sk->dead || !(sk->state & PPPOX_CONNECTED)) + if (test_bit(SOCK_DEAD, &sk->flags) || !(sk->state & PPPOX_CONNECTED)) goto abort; hdr.ver = 1; diff -Nru a/drivers/net/shaper.c b/drivers/net/shaper.c --- a/drivers/net/shaper.c Sat Feb 15 11:32:47 2003 +++ b/drivers/net/shaper.c Tue Mar 4 22:44:07 2003 @@ -88,10 +88,10 @@ #include struct shaper_cb { + unsigned long shapeclock; /* Time it should go out */ + unsigned long shapestamp; /* Stamp for shaper */ __u32 shapelatency; /* Latency on frame */ - __u32 shapeclock; /* Time it should go out */ __u32 shapelen; /* Frame length in clocks */ - __u32 shapestamp; /* Stamp for shaper */ __u16 shapepend; /* Pending */ }; #define SHAPERCB(skb) ((struct shaper_cb *) ((skb)->cb)) @@ -335,7 +335,7 @@ */ if(sh_debug) - printk("Clock = %d, jiffies = %ld\n", SHAPERCB(skb)->shapeclock, jiffies); + printk("Clock = %ld, jiffies = %ld\n", SHAPERCB(skb)->shapeclock, jiffies); if(time_before_eq(SHAPERCB(skb)->shapeclock - jiffies, SHAPER_BURST)) { /* diff -Nru a/drivers/net/sis900.c b/drivers/net/sis900.c --- a/drivers/net/sis900.c Tue Feb 25 02:45:05 2003 +++ b/drivers/net/sis900.c Tue Mar 4 22:44:07 2003 @@ -509,7 +509,7 @@ { struct sis900_private * sis_priv = net_dev->priv; u16 poll_bit = MII_STAT_LINK, status = 0; - unsigned int timeout = jiffies + 5 * HZ; + unsigned long timeout = jiffies + 5 * HZ; int phy_addr; u8 revision; diff -Nru a/drivers/net/sk98lin/h/skgepnm2.h b/drivers/net/sk98lin/h/skgepnm2.h --- a/drivers/net/sk98lin/h/skgepnm2.h Mon Feb 4 23:42:03 2002 +++ b/drivers/net/sk98lin/h/skgepnm2.h Thu Mar 6 08:18:07 2003 @@ -341,7 +341,7 @@ #if SK_TICKS_PER_SEC == 100 #define SK_PNMI_HUNDREDS_SEC(t) (t) #else -#define SK_PNMI_HUNDREDS_SEC(t) (((t) * 100) / (SK_TICKS_PER_SEC)) +#define SK_PNMI_HUNDREDS_SEC(t) ((((long)t) * 100) / (SK_TICKS_PER_SEC)) #endif /* diff -Nru a/drivers/net/sk_mca.c b/drivers/net/sk_mca.c --- a/drivers/net/sk_mca.c Mon Feb 24 12:16:14 2003 +++ b/drivers/net/sk_mca.c Thu Mar 6 09:24:43 2003 @@ -649,9 +649,7 @@ skb->protocol = eth_type_trans(skb, dev); skb->ip_summed = CHECKSUM_NONE; priv->stat.rx_packets++; -#if LINUX_VERSION_CODE >= 0x020119 /* byte counters for >= 2.1.25 */ priv->stat.rx_bytes += descr.Len; -#endif netif_rx(skb); dev->last_rx = jiffies; } @@ -709,9 +707,7 @@ /* update statistics */ if ((descr.Flags & TXDSCR_FLAGS_ERR) == 0) { priv->stat.tx_packets++; -#if LINUX_VERSION_CODE >= 0x020119 /* byte counters for >= 2.1.25 */ priv->stat.tx_bytes++; -#endif } else { priv->stat.tx_errors++; if ((descr.Status & TXDSCR_STATUS_UFLO) != 0) { @@ -1001,13 +997,8 @@ tx_done: - /* When did that change exactly ? */ - -#if LINUX_VERSION_CODE >= 0x020200 dev_kfree_skb(skb); -#else - dev_kfree_skb(skb, FREE_WRITE); -#endif + return retval; } @@ -1146,9 +1137,7 @@ mca_set_adapter_name(slot, "SKNET MC2+ Ethernet Adapter"); mca_set_adapter_procfn(slot, (MCA_ProcFn) skmca_getinfo, dev); -#if LINUX_VERSION_CODE >= 0x020200 mca_mark_as_used(slot); -#endif /* announce success */ printk("%s: SKNet %s adapter found in slot %d\n", dev->name, @@ -1283,9 +1272,7 @@ free_irq(dev->irq, dev); dev->irq = 0; unregister_netdev(dev); -#if LINUX_VERSION_CODE >= 0x020200 mca_mark_as_unused(priv->slot); -#endif mca_set_adapter_procfn(priv->slot, NULL, NULL); kfree(dev->priv); dev->priv = NULL; diff -Nru a/drivers/net/wan/comx-hw-munich.c b/drivers/net/wan/comx-hw-munich.c --- a/drivers/net/wan/comx-hw-munich.c Tue Feb 25 02:45:14 2003 +++ b/drivers/net/wan/comx-hw-munich.c Thu Mar 6 09:25:13 2003 @@ -812,13 +812,8 @@ printk("munich_probe: munich chip found, IRQ %d\n", pci->irq); -#if (LINUX_VERSION_CODE < 0x02030d) - bar1 = ioremap_nocache(pci->base_address[0], 0x100); - lbi = ioremap_nocache(pci->base_address[1], 0x100); -#else bar1 = ioremap_nocache(pci->resource[0].start, 0x100); lbi = ioremap_nocache(pci->resource[1].start, 0x100); -#endif if (bar1 && lbi) { diff -Nru a/drivers/net/wan/pc300_tty.c b/drivers/net/wan/pc300_tty.c --- a/drivers/net/wan/pc300_tty.c Thu Nov 21 14:06:12 2002 +++ b/drivers/net/wan/pc300_tty.c Sun Feb 16 16:22:42 2003 @@ -198,12 +198,6 @@ int port, aux; st_cpc_tty_area * cpc_tty; - if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)) { - printk("%s-tty: Error: TTY driver is supported on 2.4.X kernel!\n", - ((struct net_device*)(pc300dev->hdlc))->name); - return; - } - /* hdlcX - X=interface number */ port = ((struct net_device*)(pc300dev->hdlc))->name[4] - '0'; if (port >= CPC_TTY_NPORTS) { diff -Nru a/drivers/net/wan/sdla_chdlc.c b/drivers/net/wan/sdla_chdlc.c --- a/drivers/net/wan/sdla_chdlc.c Tue Feb 25 02:45:24 2003 +++ b/drivers/net/wan/sdla_chdlc.c Thu Mar 6 09:25:13 2003 @@ -60,14 +60,9 @@ #include /* ARPHRD_* defines */ -#if defined(LINUX_2_1) || defined(LINUX_2_4) - #include - #include - #include -#else - #include - #include /* Adding new route entries : 2.0.X kernels */ -#endif +#include +#include +#include #include /* sockaddr_in */ #include @@ -153,13 +148,11 @@ unsigned short timer_int_enabled; char update_comms_stats; /* updating comms stats */ -#if defined(LINUX_2_1) || defined(LINUX_2_4) bh_data_t *bh_head; /* Circular buffer for chdlc_bh */ unsigned long tq_working; volatile int bh_write; volatile int bh_read; atomic_t bh_buff_used; -#endif unsigned char interface_down; @@ -204,15 +197,8 @@ static int if_header (struct sk_buff* skb, netdevice_t* dev, unsigned short type, void* daddr, void* saddr, unsigned len); -#if defined(LINUX_2_1) || defined(LINUX_2_4) - static int if_rebuild_hdr (struct sk_buff *skb); - static struct net_device_stats* if_stats (netdevice_t* dev); - -#else - static int if_rebuild_hdr (void* hdr, netdevice_t* dev, unsigned long raddr, - struct sk_buff* skb); - static struct enet_statistics* if_stats (netdevice_t* dev); -#endif +static int if_rebuild_hdr (struct sk_buff *skb); +static struct net_device_stats* if_stats (netdevice_t* dev); static int if_send (struct sk_buff* skb, netdevice_t* dev); @@ -228,9 +214,7 @@ static int chdlc_disable_comm_shutdown (sdla_t *card); -#ifdef LINUX_2_4 - static void if_tx_timeout (netdevice_t *dev); -#endif +static void if_tx_timeout (netdevice_t *dev); /* Miscellaneous CHDLC Functions */ static int set_chdlc_config (sdla_t* card); @@ -260,12 +244,10 @@ static void rx_intr (sdla_t* card); static void timer_intr(sdla_t *); -#if defined(LINUX_2_1) || defined(LINUX_2_4) - /* Bottom half handlers */ - static void chdlc_work (netdevice_t *); - static int chdlc_work_cleanup (netdevice_t *); - static int bh_enqueue (netdevice_t *, struct sk_buff *); -#endif +/* Bottom half handlers */ +static void chdlc_work (netdevice_t *); +static int chdlc_work_cleanup (netdevice_t *); +static int bh_enqueue (netdevice_t *, struct sk_buff *); /* Miscellaneous functions */ static int chk_bcast_mcast_addr(sdla_t* card, netdevice_t* dev, @@ -287,8 +269,6 @@ /* TTY Global Definitions */ -#if defined(LINUX_2_4) || defined(LINUX_2_1) - #define NR_PORTS 4 #define WAN_TTY_MAJOR 226 #define WAN_TTY_MINOR 0 @@ -321,8 +301,6 @@ static void* tty_card_map[NR_PORTS] = {NULL,NULL,NULL,NULL}; -#endif - /****** Public Functions ****************************************************/ @@ -569,7 +547,6 @@ } if ((card->tty_opt=conf->tty) == WANOPT_YES){ -#if defined(LINUX_2_4) || defined(LINUX_2_1) int err; card->tty_minor = conf->tty_minor; @@ -582,11 +559,6 @@ if (err){ return err; } -#else - printk(KERN_INFO "%s: Error: TTY driver is not supported on 2.0.X kernels!\n", - card->devname); - return -EINVAL; -#endif }else{ @@ -851,18 +823,6 @@ min_t(unsigned int, conf->slarp_timer, MAX_SLARP_REQ_TIMER) : DEFAULT_SLARP_REQ_TIMER; -#ifdef LINUX_2_0 - if (card->u.c.slarp_timer){ - printk(KERN_INFO - "%s: Error: Dynamic IP support not available for 2.0.X kernels\n", - card->devname); - printk(KERN_INFO "%s: Defaulting to Static IP addressing\n", - card->devname); - } - card->u.c.slarp_timer=0; -#endif - - if (conf->hdlc_streaming == WANOPT_YES) { printk(KERN_INFO "%s: Enabling HDLC STREAMING Mode\n", wandev->name); @@ -892,40 +852,24 @@ } } else if( strcmp(conf->usedby, "API") == 0) { -#if defined(LINUX_2_1) || defined(LINUX_2_4) card->u.c.usedby = API; printk(KERN_INFO "%s: Running in API mode !\n", wandev->name); -#else - printk(KERN_INFO "%s: API Mode is not supported for kernels lower than 2.2.X!\n", - wandev->name); - printk(KERN_INFO "%s: Please upgrade to a 2.2.X kernel fro the API support\n", - wandev->name); - kfree(chdlc_priv_area); - return -EINVAL; -#endif } } -#if defined(LINUX_2_1) || defined(LINUX_2_4) /* Tells us that if this interface is a * gateway or not */ if ((chdlc_priv_area->gateway = conf->gateway) == WANOPT_YES){ printk(KERN_INFO "%s: Interface %s is set as a gateway.\n", card->devname,card->u.c.if_name); } -#endif /* Get Multicast Information */ chdlc_priv_area->mc = conf->mc; /* prepare network device data space for registration */ -#ifdef LINUX_2_4 strcpy(dev->name,card->u.c.if_name); -#else - dev->name = (char *)kmalloc(strlen(card->u.c.if_name) + 2, GFP_KERNEL); - sprintf(dev->name, "%s", card->u.c.if_name); -#endif dev->init = &if_init; dev->priv = chdlc_priv_area; @@ -958,9 +902,6 @@ chdlc_private_area_t* chdlc_priv_area = dev->priv; sdla_t* card = chdlc_priv_area->card; wan_device_t* wandev = &card->wandev; -#ifdef LINUX_2_0 - int i; -#endif /* Initialize device driver entry points */ dev->open = &if_open; @@ -969,10 +910,8 @@ dev->rebuild_header = &if_rebuild_hdr; dev->hard_start_xmit = &if_send; dev->get_stats = &if_stats; -#ifdef LINUX_2_4 dev->tx_timeout = &if_tx_timeout; dev->watchdog_timeo = TX_TIMEOUT; -#endif /* Initialize media-specific parameters */ @@ -984,16 +923,8 @@ dev->flags |= IFF_MULTICAST; } -#ifdef LINUX_2_0 - dev->family = AF_INET; -#endif - if (chdlc_priv_area->true_if_encoding){ -#if defined(LINUX_2_1) || defined(LINUX_2_4) dev->type = ARPHRD_HDLC; /* This breaks the tcpdump */ -#else - dev->type = ARPHRD_PPP; -#endif }else{ dev->type = ARPHRD_PPP; } @@ -1019,11 +950,6 @@ */ dev->tx_queue_len = 100; - /* Initialize socket buffers */ -#if !defined(LINUX_2_1) && !defined(LINUX_2_4) - for (i = 0; i < DEV_NUMBUFFS; ++i) - skb_queue_head_init(&dev->buffs[i]); -#endif return 0; } @@ -1043,10 +969,9 @@ /* Only one open per interface is allowed */ - if (is_dev_running(dev)) + if (netif_running(dev)) return -EBUSY; -#if defined(LINUX_2_1) || defined(LINUX_2_4) /* Initialize the work queue entry */ chdlc_priv_area->tq_working=0; @@ -1058,18 +983,11 @@ chdlc_priv_area->bh_head = kmalloc((sizeof(bh_data_t)*(MAX_BH_BUFF+1)),GFP_ATOMIC); memset(chdlc_priv_area->bh_head,0,(sizeof(bh_data_t)*(MAX_BH_BUFF+1))); atomic_set(&chdlc_priv_area->bh_buff_used, 0); -#endif do_gettimeofday(&tv); chdlc_priv_area->router_start_time = tv.tv_sec; -#ifdef LINUX_2_4 netif_start_queue(dev); -#else - dev->interrupt = 0; - dev->tbusy = 0; - dev->start = 1; -#endif wanpipe_open(card); @@ -1100,8 +1018,6 @@ chdlc_private_area_t* chdlc_priv_area = dev->priv; sdla_t* card = chdlc_priv_area->card; -#if defined(LINUX_2_1) || defined(LINUX_2_4) - if (chdlc_priv_area->bh_head){ int i; struct sk_buff *skb; @@ -1109,18 +1025,14 @@ for (i=0; i<(MAX_BH_BUFF+1); i++){ skb = ((bh_data_t *)&chdlc_priv_area->bh_head[i])->skb; if (skb != NULL){ - wan_dev_kfree_skb(skb, FREE_READ); + dev_kfree_skb_any(skb); } } kfree(chdlc_priv_area->bh_head); chdlc_priv_area->bh_head=NULL; } -#endif - stop_net_queue(dev); -#ifndef LINUX_2_4 - dev->start=0; -#endif + netif_stop_queue(dev); wanpipe_close(card); del_timer(&chdlc_priv_area->poll_delay_timer); return 0; @@ -1136,7 +1048,6 @@ flags->interrupt_info_struct.interrupt_permission = 0; } -#if defined(LINUX_2_4) || defined(LINUX_2_1) if (!tty_init_cnt) return; @@ -1160,7 +1071,6 @@ state = &rs_table[card->tty_minor]; memset(state,0,sizeof(state)); } -#endif return; } @@ -1183,7 +1093,6 @@ } -#ifdef LINUX_2_4 /*============================================================================ * Handle transmit timeout event from netif watchdog */ @@ -1203,7 +1112,6 @@ printk (KERN_INFO "%s: Transmit timed out on %s\n", card->devname,dev->name); netif_wake_queue (dev); } -#endif @@ -1213,18 +1121,11 @@ * Return: 1 physical address resolved. * 0 physical address not resolved */ -#if defined(LINUX_2_1) || defined(LINUX_2_4) static int if_rebuild_hdr (struct sk_buff *skb) { return 1; } -#else -static int if_rebuild_hdr (void* hdr, netdevice_t* dev, unsigned long raddr, - struct sk_buff* skb) -{ - return 1; -} -#endif + /*============================================================================ * Send a packet on a network interface. @@ -1253,9 +1154,7 @@ unsigned long smp_flags; int err=0; -#ifdef LINUX_2_4 netif_stop_queue(dev); -#endif if (skb == NULL){ /* If we get here, some higher layer thinks we've missed an @@ -1264,31 +1163,10 @@ printk(KERN_INFO "%s: interface %s got kicked!\n", card->devname, dev->name); - wake_net_dev(dev); + netif_wake_queue(dev); return 0; } -#ifndef LINUX_2_4 - if (dev->tbusy){ - - /* If our device stays busy for at least 5 seconds then we will - * kick start the device by making dev->tbusy = 0. We expect - * that our device never stays busy more than 5 seconds. So this - * is only used as a last resort. - */ - ++card->wandev.stats.collisions; - if((jiffies - chdlc_priv_area->tick_counter) < (5 * HZ)) { - return 1; - } - - printk (KERN_INFO "%s: Transmit timeout !\n", - card->devname); - - /* unbusy the interface */ - clear_bit(0,&dev->tbusy); - } -#endif - if (ntohs(skb->protocol) != htons(PVC_PROT)){ /* check the udp packet type */ @@ -1301,7 +1179,7 @@ chdlc_int->interrupt_permission |= APP_INT_ON_TIMER; } - start_net_queue(dev); + netif_start_queue(dev); return 0; } @@ -1309,8 +1187,8 @@ /* multicast IP address */ if(chk_bcast_mcast_addr(card, dev, skb)){ ++card->wandev.stats.tx_dropped; - wan_dev_kfree_skb(skb,FREE_WRITE); - start_net_queue(dev); + dev_kfree_skb_any(skb); + netif_start_queue(dev); return 0; } } @@ -1325,17 +1203,17 @@ printk(KERN_INFO "%s: Critical in if_send: %lx\n", card->wandev.name,card->wandev.critical); ++card->wandev.stats.tx_dropped; - start_net_queue(dev); + netif_start_queue(dev); goto if_send_exit_crit; } if(card->u.c.state != WAN_CONNECTED){ ++card->wandev.stats.tx_dropped; - start_net_queue(dev); + netif_start_queue(dev); }else if(!skb->protocol){ ++card->wandev.stats.tx_errors; - start_net_queue(dev); + netif_start_queue(dev); }else { void* data = skb->data; @@ -1355,7 +1233,7 @@ (len <= sizeof(api_tx_hdr_t))) { ++card->wandev.stats.tx_dropped; - start_net_queue(dev); + netif_start_queue(dev); goto if_send_exit_crit; } @@ -1366,25 +1244,21 @@ } if(chdlc_send(card, data, len)) { - stop_net_queue(dev); + netif_stop_queue(dev); }else{ ++card->wandev.stats.tx_packets; -#if defined(LINUX_2_1) || defined(LINUX_2_4) card->wandev.stats.tx_bytes += len; -#endif - start_net_queue(dev); + netif_start_queue(dev); -#ifdef LINUX_2_4 dev->trans_start = jiffies; -#endif } } if_send_exit_crit: - if (!(err=is_queue_stopped(dev))) { - wan_dev_kfree_skb(skb, FREE_WRITE); + if (!(err=netif_queue_stopped(dev))) { + dev_kfree_skb_any(skb); }else{ chdlc_priv_area->tick_counter = jiffies; chdlc_int->interrupt_permission |= APP_INT_ON_TX_FRAME; @@ -1409,14 +1283,12 @@ { u32 src_ip_addr; u32 broadcast_ip_addr = 0; -#if defined(LINUX_2_1) || defined(LINUX_2_4) struct in_device *in_dev; -#endif + /* read the IP source address from the outgoing packet */ src_ip_addr = *(u32 *)(skb->data + 12); /* read the IP broadcast address for the device */ -#if defined(LINUX_2_1) || defined(LINUX_2_4) in_dev = dev->ip_ptr; if(in_dev != NULL) { struct in_ifaddr *ifa= in_dev->ifa_list; @@ -1425,9 +1297,6 @@ else return 0; } -#else - broadcast_ip_addr = dev->pa_brdaddr; -#endif /* check if the IP Source Address is a Broadcast address */ if((dev->flags & IFF_BROADCAST) && (src_ip_addr == broadcast_ip_addr)) { @@ -1552,7 +1421,6 @@ * Get ethernet-style interface statistics. * Return a pointer to struct enet_statistics. */ -#if defined(LINUX_2_1) || defined(LINUX_2_4) static struct net_device_stats* if_stats (netdevice_t* dev) { sdla_t *my_card; @@ -1564,19 +1432,7 @@ my_card = chdlc_priv_area->card; return &my_card->wandev.stats; } -#else -static struct enet_statistics* if_stats (netdevice_t* dev) -{ - sdla_t *my_card; - chdlc_private_area_t* chdlc_priv_area = dev->priv; - if ((chdlc_priv_area=dev->priv) == NULL) - return NULL; - - my_card = chdlc_priv_area->card; - return &my_card->wandev.stats; -} -#endif /****** Cisco HDLC Firmware Interface Functions *******************************/ @@ -1846,7 +1702,7 @@ return 0; } -#if defined(LINUX_2_1) || defined(LINUX_2_4) + /********** Bottom Half Handlers ********************************************/ /* NOTE: There is no API, BH support for Kernels lower than 2.2.X. @@ -1873,7 +1729,7 @@ if (chan->common.sk == NULL || chan->common.func == NULL){ ++card->wandev.stats.rx_dropped; - wan_dev_kfree_skb(skb, FREE_READ); + dev_kfree_skb_any(skb); chdlc_work_cleanup(dev); continue; } @@ -1921,7 +1777,7 @@ if (atomic_read(&chan->bh_buff_used) == (MAX_BH_BUFF+1)){ ++card->wandev.stats.rx_dropped; - wan_dev_kfree_skb(skb, FREE_READ); + dev_kfree_skb_any(skb); return 1; } @@ -1940,7 +1796,6 @@ /* END OF API BH Support */ -#endif /****** Interrupt Handlers **************************************************/ @@ -2017,24 +1872,19 @@ flags->interrupt_info_struct.interrupt_permission &= ~APP_INT_ON_TX_FRAME; -#if defined(LINUX_2_1) || defined(LINUX_2_4) - if (card->tty_opt){ wanpipe_tty_trigger_poll(card); break; } - if (dev && is_queue_stopped(dev)){ + if (dev && netif_queue_stopped(dev)){ if (card->u.c.usedby == API){ - start_net_queue(dev); + netif_start_queue(dev); wakeup_sk_bh(dev); }else{ - wake_net_dev(dev); + netif_wake_queue(dev); } } -#else - wake_net_dev(dev); -#endif break; case COMMAND_COMPLETE_APP_INT_PEND:/* 0x04: cmd cplt */ @@ -2120,7 +1970,6 @@ len = rxbuf->frame_length; -#if defined(LINUX_2_4) || defined(LINUX_2_1) if (card->tty_opt){ if (rxbuf->error_flag){ @@ -2138,7 +1987,6 @@ wanpipe_tty_receive(card,addr,len); goto rx_exit; } -#endif dev = card->wandev.dev; @@ -2146,7 +1994,7 @@ goto rx_exit; } - if (!is_dev_running(dev)) + if (!netif_running(dev)) goto rx_exit; chdlc_priv_area = dev->priv; @@ -2177,9 +2025,7 @@ skb->protocol = htons(ETH_P_IP); card->wandev.stats.rx_packets ++; -#if defined(LINUX_2_1) || defined(LINUX_2_4) card->wandev.stats.rx_bytes += skb->len; -#endif udp_type = udp_pkt_type( skb, card ); if(udp_type == UDP_CPIPE_TYPE) { @@ -2189,7 +2035,6 @@ interrupt_permission |= APP_INT_ON_TIMER; } -#if defined(LINUX_2_1) || defined(LINUX_2_4) } else if(card->u.c.usedby == API) { api_rx_hdr_t* api_rx_hdr; @@ -2207,7 +2052,6 @@ if (!test_and_set_bit(0,&chdlc_priv_area->tq_working)) wanpipe_queue_work(&chdlc_priv_area->common.wanpipe_work); -#endif }else{ /* FIXME: we should check to see if the received packet is a multicast packet so that we can increment the multicast @@ -2331,7 +2175,6 @@ netdevice_t * dev = card->wandev.dev; chdlc_private_area_t *chdlc_priv_area = dev->priv; -#if defined(LINUX_2_1) || defined(LINUX_2_4) struct in_device *in_dev = dev->ip_ptr; if(in_dev != NULL) { @@ -2344,12 +2187,6 @@ chdlc_priv_area->IP_netmask = ntohl(ifa->ifa_mask); } } -#else - cfg.IP_address = ntohl(dev->pa_addr); - cfg.IP_netmask = ntohl(dev->pa_mask); - chdlc_priv_area->IP_address = ntohl(dev->pa_addr); - chdlc_priv_area->IP_netmask = ntohl(dev->pa_mask); -#endif /* FIXME: We must re-think this message in next release if((cfg.IP_address & 0x000000FF) > 2) { @@ -2647,15 +2484,10 @@ u32 remote_IP_addr = 0; u32 IP_netmask, IP_addr; int err = 0; -#if defined(LINUX_2_1) || defined(LINUX_2_4) struct in_device *in_dev; mm_segment_t fs; struct ifreq if_info; struct sockaddr_in *if_data1, *if_data2; -#else - unsigned long fs = 0; - struct rtentry route; -#endif chdlc_priv_area = dev->priv; port_num = card->u.c.comm_port; @@ -2705,7 +2537,6 @@ return; } -#if defined(LINUX_2_1) || defined(LINUX_2_4) in_dev = dev->ip_ptr; if(in_dev != NULL) { @@ -2715,11 +2546,6 @@ IP_netmask = ifa->ifa_mask; } } -#else - local_IP_addr = dev->pa_addr; - remote_IP_addr = dev->pa_dstaddr; - IP_netmask = dev->pa_mask; -#endif }else{ /* According to Cisco HDLC, if the point-to-point address is A.B.C.1, then we are the opposite (A.B.C.2), and vice-versa. @@ -2749,44 +2575,20 @@ fs = get_fs(); /* Save file system */ set_fs(get_ds()); /* Get user space block */ -#if defined(LINUX_2_1) || defined(LINUX_2_4) /* Setup a structure for adding/removing routes */ memset(&if_info, 0, sizeof(if_info)); strcpy(if_info.ifr_name, dev->name); -#else - /* Setup a structure for adding/removing routes */ - dev->pa_mask = IP_netmask; - dev->pa_dstaddr = remote_IP_addr; - dev->pa_addr = local_IP_addr; - - memset(&route, 0, sizeof(route)); - route.rt_dev = dev->name; - route.rt_flags = 0; - ((struct sockaddr_in *)&(route.rt_dst))->sin_addr.s_addr = - dev->pa_dstaddr; - ((struct sockaddr_in *)&(route.rt_dst))->sin_family = AF_INET; - ((struct sockaddr_in *)&(route.rt_genmask))->sin_addr.s_addr = - 0xFFFFFFFF; - ((struct sockaddr_in *)&(route.rt_genmask))->sin_family = - AF_INET; -#endif - switch (chdlc_priv_area->route_status) { case ADD_ROUTE: if(!card->u.c.slarp_timer) { -#if defined(LINUX_2_1) || defined(LINUX_2_4) if_data2 = (struct sockaddr_in *)&if_info.ifr_dstaddr; if_data2->sin_addr.s_addr = remote_IP_addr; if_data2->sin_family = AF_INET; err = devinet_ioctl(SIOCSIFDSTADDR, &if_info); -#else - err = ip_rt_new(&route); -#endif } else { -#if defined(LINUX_2_1) || defined(LINUX_2_4) if_data1 = (struct sockaddr_in *)&if_info.ifr_addr; if_data1->sin_addr.s_addr = local_IP_addr; if_data1->sin_family = AF_INET; @@ -2796,9 +2598,6 @@ if_data2->sin_family = AF_INET; err = devinet_ioctl(SIOCSIFDSTADDR, &if_info); } -#else - err = ip_rt_new(&route); -#endif } if(err) { @@ -2819,7 +2618,6 @@ case REMOVE_ROUTE: -#if defined(LINUX_2_1) || defined(LINUX_2_4) /* Change the local ip address of the interface to 0. * This will also delete the destination route. */ @@ -2835,11 +2633,6 @@ err = devinet_ioctl(SIOCSIFADDR,&if_info); } -#else - /* set the point-to-point IP address to 0.0.0.0 */ - dev->pa_dstaddr = 0; - err = ip_rt_kill(&route); -#endif if(err) { printk(KERN_INFO "%s: Remove route %u.%u.%u.%u failed, (err %d)\n", @@ -2880,9 +2673,9 @@ } if(udp_pkt_src == UDP_PKT_FRM_STACK){ - wan_dev_kfree_skb(skb, FREE_WRITE); + dev_kfree_skb_any(skb); }else{ - wan_dev_kfree_skb(skb, FREE_READ); + dev_kfree_skb_any(skb); } return(udp_pkt_stored); @@ -3256,9 +3049,7 @@ if(!chdlc_send(card, chdlc_priv_area->udp_pkt_data, len)) { ++ card->wandev.stats.tx_packets; -#if defined(LINUX_2_1) || defined(LINUX_2_4) card->wandev.stats.tx_bytes += len; -#endif } } } else { @@ -3808,30 +3599,21 @@ void s508_lock (sdla_t *card, unsigned long *smp_flags) { -#if defined(__SMP__) || defined(LINUX_2_4) spin_lock_irqsave(&card->wandev.lock, *smp_flags); if (card->next){ spin_lock(&card->next->wandev.lock); } -#else - disable_irq(card->hw.irq); -#endif } void s508_unlock (sdla_t *card, unsigned long *smp_flags) { -#if defined(__SMP__) || defined(LINUX_2_4) if (card->next){ spin_unlock(&card->next->wandev.lock); } spin_unlock_irqrestore(&card->wandev.lock, *smp_flags); -#else - enable_irq(card->hw.irq); -#endif } //*********** TTY SECTION **************** -#if defined(LINUX_2_4) || defined(LINUX_2_1) static void wanpipe_tty_trigger_tx_irq(sdla_t *card) { @@ -3858,8 +3640,7 @@ (tty->ldisc.write_wakeup)(tty); } wake_up_interruptible(&tty->write_wait); -#if defined(SERIAL_HAVE_POLL_WAIT) || \ - (defined LINUX_2_1 && LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,15)) +#if defined(SERIAL_HAVE_POLL_WAIT) wake_up_interruptible(&tty->poll_wait); #endif return; @@ -4479,8 +4260,7 @@ return; wake_up_interruptible(&tty->write_wait); -#if defined(SERIAL_HAVE_POLL_WAIT) || \ - (defined LINUX_2_1 && LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,15)) +#if defined(SERIAL_HAVE_POLL_WAIT) wake_up_interruptible(&tty->poll_wait); #endif if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) && @@ -4721,8 +4501,6 @@ INIT_WORK(&card->tty_work, tty_poll_work, (void*)card); return 0; } - -#endif MODULE_LICENSE("GPL"); diff -Nru a/drivers/net/wan/sdla_fr.c b/drivers/net/wan/sdla_fr.c --- a/drivers/net/wan/sdla_fr.c Tue Feb 25 11:05:23 2003 +++ b/drivers/net/wan/sdla_fr.c Thu Mar 6 09:25:30 2003 @@ -229,11 +229,7 @@ int inarp_interval; /* Time between InArp Requests */ unsigned long inarp_tick; /* InArp jiffies tick counter */ long interface_down; /* Bring interface down on disconnect */ - #if defined(LINUX_2_1) || defined(LINUX_2_4) struct net_device_stats ifstats; /* interface statistics */ - #else - struct enet_statistics ifstats; - #endif if_send_stat_t drvstats_if_send; rx_intr_stat_t drvstats_rx_intr; pipe_mgmt_stat_t drvstats_gen; @@ -242,14 +238,11 @@ unsigned short transmit_length; struct sk_buff *delay_skb; - - #if defined(LINUX_2_1) || defined(LINUX_2_4) bh_data_t *bh_head; /* Circular buffer for chdlc_bh */ unsigned long tq_working; volatile int bh_write; volatile int bh_read; atomic_t bh_buff_used; - #endif /* Polling task queue. Each interface * has its own task queue, which is used @@ -343,26 +336,14 @@ static int if_open(netdevice_t *dev); static int if_close(netdevice_t *dev); - -#ifdef LINUX_2_4 static void if_tx_timeout (netdevice_t *dev); -#endif -#if defined(LINUX_2_1) || defined(LINUX_2_4) static int if_rebuild_hdr (struct sk_buff *skb); -#else -static int if_rebuild_hdr (void* hdr, netdevice_t* dev, unsigned long raddr, - struct sk_buff* skb); -#endif static int if_send(struct sk_buff *skb, netdevice_t *dev); static int chk_bcast_mcast_addr(sdla_t *card, netdevice_t* dev, struct sk_buff *skb); -#if defined(LINUX_2_1) || defined(LINUX_2_4) static struct net_device_stats *if_stats(netdevice_t *dev); -#else -static struct enet_statistics* if_stats (netdevice_t* dev); -#endif /* Interrupt handlers */ static void fr_isr(sdla_t *card); @@ -417,13 +398,11 @@ netdevice_t * move_dev_to_next (sdla_t *, netdevice_t *); static int check_tx_status(sdla_t *, netdevice_t *); -#if defined(LINUX_2_1) || defined(LINUX_2_4) /* Frame Relay Socket API */ static void trigger_fr_bh (fr_channel_t *); static void fr_bh (netdevice_t *); static int fr_bh_cleanup (netdevice_t *); static int bh_enqueue (netdevice_t *, struct sk_buff *); -#endif static void trigger_fr_poll (netdevice_t *); static void fr_poll (netdevice_t *); @@ -886,26 +865,14 @@ chan->common.usedby = BRIDGE; -#if defined(LINUX_2_1) || defined(LINUX_2_4) printk(KERN_INFO "%s: Running in WANPIPE (BRIDGE) mode.\n", card->devname); -#else - printk(KERN_INFO "%s: WANPIPE Bridging mode not supported in 2.0.X kernels.\n", - card->devname); - err = -EPROTONOSUPPORT; -#endif }else if( strcmp(conf->usedby, "BRIDGE_N") == 0 ){ chan->common.usedby = BRIDGE_NODE; -#if defined(LINUX_2_1) || defined(LINUX_2_4) printk(KERN_INFO "%s: Running in WANPIPE (BRIDGE_NODE) mode.\n", card->devname); -#else - printk(KERN_INFO "%s: WANPIPE Bridging mode not supported in 2.0.X kernels.\n", - card->devname); - err = -EPROTONOSUPPORT; -#endif } if (!err){ @@ -922,18 +889,9 @@ } else if(strcmp(conf->usedby, "API") == 0){ -#if defined(LINUX_2_1) || defined(LINUX_2_4) chan->common.usedby = API; printk(KERN_INFO "%s: Running in API mode.\n", wandev->name); -#else - printk(KERN_INFO "%s: The API Mode is not supported for" - "kernels lower than 2.2.X !\n", - wandev->name); - printk(KERN_INFO "%s: Please upgrade to a 2.2.X kernel for the API support\n", - wandev->name); - err = -EINVAL; -#endif } if (err) { @@ -980,16 +938,9 @@ chan->mc = conf->mc; if (conf->inarp == WANOPT_YES){ -#if defined(LINUX_2_1) || defined(LINUX_2_4) printk(KERN_INFO "%s: Inverse ARP Support Enabled\n",card->devname); chan->inarp = conf->inarp ? INARP_REQUEST : INARP_NONE; chan->inarp_interval = conf->inarp_interval ? conf->inarp_interval : 10; -#else - printk(KERN_INFO "%s: Warning, Inverse ARP Support not available for 2.0.X kernels!\n", - card->devname); - chan->inarp = INARP_NONE; - chan->inarp_interval = 10; -#endif }else{ printk(KERN_INFO "%s: Inverse ARP Support Disabled\n",card->devname); chan->inarp = INARP_NONE; @@ -1023,17 +974,7 @@ chan->transmit_length = 0; /* prepare network device data space for registration */ -#ifdef LINUX_2_4 strcpy(dev->name,chan->name); -#else - dev->name = (char *)kmalloc(strlen(chan->name) + 2, GFP_KERNEL); - if(dev->name == NULL) - { - kfree(chan); - return -ENOMEM; - } - sprintf(dev->name, "%s", chan->name); -#endif dev->init = &if_init; dev->priv = chan; @@ -1042,9 +983,6 @@ * We need a poll routine for each network * interface. */ -#ifndef LINUX_2_4 - chan->fr_poll_task.next = NULL; -#endif chan->fr_poll_task.sync = 0; chan->fr_poll_task.routine = (void *)(void *)fr_poll; chan->fr_poll_task.data = dev; @@ -1138,8 +1076,6 @@ int err, len; fr_cmd_t cmd; -#if defined(LINUX_2_1) || defined(LINUX_2_4) - if(copy_from_user((void*)&cmd, u_cmd, sizeof(cmd))) return -EFAULT; @@ -1169,44 +1105,6 @@ if (len && u_data && !copy_to_user(u_data, (void*)&mbox->data, len)) return -EFAULT; return 0; - -#else - if (!u_cmd || verify_area(VERIFY_WRITE, u_cmd, sizeof(fr_cmd_t))) - return -EFAULT; - - memcpy_fromfs((void*)&cmd, u_cmd, sizeof(cmd)); - - if (cmd.length) { - - if (!u_data || verify_area(VERIFY_READ, u_data, cmd.length)) - return -EFAULT; - } - - /* execute command */ - do - { - memcpy(&mbox->cmd, &cmd, sizeof(cmd)); - - if (cmd.length) - memcpy_fromfs((void*)&mbox->data, u_data, cmd.length); - - if (sdla_exec(mbox)) - err = mbox->cmd.result; - - else return -EIO; - } while (err && retry-- && fr_event(card, err, mbox)); - - /* return result */ - memcpy_tofs(u_cmd, (void*)&mbox->cmd, sizeof(fr_cmd_t)); - len = mbox->cmd.length; - - if (len && u_data && !verify_area(VERIFY_WRITE, u_data, len)) - memcpy_tofs(u_data, (void*)&mbox->data, len); - - return 0; - -#endif - } /****** Network Device Interface ********************************************/ @@ -1223,9 +1121,6 @@ fr_channel_t* chan = dev->priv; sdla_t* card = chan->card; wan_device_t* wandev = &card->wandev; -#ifdef LINUX_2_0 - int i; -#endif /* Initialize device driver entry points */ dev->open = &if_open; @@ -1234,15 +1129,11 @@ dev->rebuild_header = &if_rebuild_hdr; dev->hard_start_xmit = &if_send; dev->get_stats = &if_stats; -#ifdef LINUX_2_4 dev->tx_timeout = &if_tx_timeout; dev->watchdog_timeo = TX_TIMEOUT; -#endif if (chan->common.usedby == WANPIPE || chan->common.usedby == API){ -#ifdef LINUX_2_0 - dev->family = AF_INET; -#endif + /* Initialize media-specific parameters */ if (chan->true_if_encoding){ dev->type = ARPHRD_DLCI; /* This breaks tcpdump */ @@ -1274,11 +1165,6 @@ /* Set transmit buffer queue length */ dev->tx_queue_len = 100; - /* Initialize socket buffers */ -#if !defined(LINUX_2_1) && !defined(LINUX_2_4) - for (i = 0; i < DEV_NUMBUFFS; ++i) - skb_queue_head_init(&dev->buffs[i]); -#endif }else{ /* Setup the interface for Bridging */ @@ -1315,16 +1201,12 @@ int err = 0; struct timeval tv; - if (is_dev_running(dev)) + if (netif_running(dev)) return -EBUSY; -#if defined(LINUX_2_1) || defined(LINUX_2_4) /* Initialize the task queue */ chan->tq_working=0; -#ifndef LINUX_2_4 - chan->common.wanpipe_task.next = NULL; -#endif chan->common.wanpipe_task.sync = 0; chan->common.wanpipe_task.routine = (void *)(void *)fr_bh; chan->common.wanpipe_task.data = dev; @@ -1333,15 +1215,8 @@ chan->bh_head = kmalloc((sizeof(bh_data_t)*MAX_BH_BUFF),GFP_ATOMIC); memset(chan->bh_head,0,(sizeof(bh_data_t)*MAX_BH_BUFF)); atomic_set(&chan->bh_buff_used, 0); -#endif -#ifdef LINUX_2_4 netif_start_queue(dev); -#else - dev->interrupt = 0; - dev->tbusy = 0; - dev->start = 1; -#endif wanpipe_open(card); do_gettimeofday( &tv ); @@ -1370,10 +1245,7 @@ chan->inarp = INARP_REQUEST; } - stop_net_queue(dev); -#ifndef LINUX_2_4 - dev->start=0; -#endif + netif_stop_queue(dev); wanpipe_close(card); return 0; @@ -1385,18 +1257,10 @@ * Return: 1 physical address resolved. * 0 physical address not resolved */ -#if defined(LINUX_2_1) || defined(LINUX_2_4) static int if_rebuild_hdr (struct sk_buff* skb) { -#else -static int if_rebuild_hdr (void* hdr, netdevice_t* dev, unsigned long raddr, - struct sk_buff* skb) -{ -#endif -#if defined(LINUX_2_1) || defined(LINUX_2_4) netdevice_t *dev = skb->dev; -#endif fr_channel_t* chan = dev->priv; sdla_t* card = chan->card; @@ -1405,7 +1269,6 @@ return 1; } -#ifdef LINUX_2_4 /*============================================================================ * Handle transmit timeout event from netif watchdog */ @@ -1429,7 +1292,7 @@ netif_wake_queue (dev); } -#endif + /*============================================================================ * Send a packet on a network interface. @@ -1448,7 +1311,7 @@ * 1. This routine is called either by the protocol stack or by the "net * bottom half" (with interrupts enabled). * - * 2. Using the start_net_queue() and stop_net_queue() MACROS + * 2. Using netif_start_queue() and netif_stop_queue() * will inhibit further transmit requests from the protocol stack * and can be used for flow control with protocol layer. */ @@ -1466,9 +1329,7 @@ chan->drvstats_if_send.if_send_entry++; -#ifdef LINUX_2_4 netif_stop_queue(dev); -#endif if (skb == NULL) { /* if we get here, some higher layer thinks we've missed an @@ -1478,7 +1339,7 @@ card->devname, dev->name); chan->drvstats_if_send.if_send_skb_null ++; - wake_net_dev(dev); + netif_wake_queue(dev); return 0; } @@ -1488,8 +1349,8 @@ printk(KERN_INFO "%s: Critical in if_send(): Peripheral running!\n", card->devname); - wan_dev_kfree_skb(skb,FREE_WRITE); - start_net_queue(dev); + dev_kfree_skb_any(skb); + netif_start_queue(dev); return 0; } @@ -1500,37 +1361,13 @@ */ set_bit(SEND_TXIRQ_CRIT, (void*)&card->wandev.critical); if(chan->transmit_length) { - stop_net_queue(dev); + netif_stop_queue(dev); chan->tick_counter = jiffies; clear_bit(SEND_TXIRQ_CRIT, (void*)&card->wandev.critical); return 1; } clear_bit(SEND_TXIRQ_CRIT, (void*)&card->wandev.critical); -#ifndef LINUX_2_4 - if (dev->tbusy) { - - /* If our device stays busy for at least 5 seconds then we will - * kick start the device by making dev->tbusy = 0. We expect - * that our device never stays busy more than 5 seconds. So this - * is only used as a last resort. - */ - - chan->drvstats_if_send.if_send_tbusy++; - ++chan->ifstats.collisions; - - if ((jiffies - chan->tick_counter) < (5 * HZ)) { - return 1; - } - - printk(KERN_INFO "%s: Transmit timed out on %s\n", - card->devname, chan->name); - chan->drvstats_if_send.if_send_tbusy_timeout ++; - dev->tbusy = 0; - } -#endif - - /* Move the if_header() code to here. By inserting frame * relay header in if_header() we would break the * tcpdump and other packet sniffers */ @@ -1539,8 +1376,8 @@ ++chan->ifstats.tx_dropped; ++card->wandev.stats.tx_dropped; - wan_dev_kfree_skb(skb,FREE_WRITE); - start_net_queue(dev); + dev_kfree_skb_any(skb); + netif_start_queue(dev); return 0; } @@ -1557,7 +1394,7 @@ if_send_PIPE_request ++; } } - start_net_queue(dev); + netif_start_queue(dev); return 0; } @@ -1569,8 +1406,8 @@ if(chk_bcast_mcast_addr(card, dev, skb)){ ++chan->ifstats.tx_dropped; ++card->wandev.stats.tx_dropped; - wan_dev_kfree_skb(skb, FREE_WRITE); - start_net_queue(dev); + dev_kfree_skb_any(skb); + netif_start_queue(dev); return 0; } } @@ -1691,26 +1528,22 @@ ++chan->ifstats.tx_packets; ++card->wandev.stats.tx_packets; -#if defined(LINUX_2_1) || defined(LINUX_2_4) chan->ifstats.tx_bytes += skb->len; card->wandev.stats.tx_bytes += skb->len; -#endif -#ifdef LINUX_2_4 dev->trans_start = jiffies; -#endif } } } if_send_start_and_exit: - start_net_queue(dev); + netif_start_queue(dev); /* If we queued the packet for transmission, we must not * deallocate it. The packet is unlinked from the IP stack * not copied. Therefore, we must keep the original packet */ if (!test_bit(1,&delay_tx_queued)) { - wan_dev_kfree_skb(skb, FREE_WRITE); + dev_kfree_skb_any(skb); }else{ adptr_flags->imask |= FR_INTR_TXRDY; card->u.f.tx_interrupts_pending ++; @@ -1786,16 +1619,13 @@ { u32 src_ip_addr; u32 broadcast_ip_addr = 0; -#if defined(LINUX_2_1) || defined(LINUX_2_4) struct in_device *in_dev; -#endif fr_channel_t* chan = dev->priv; /* read the IP source address from the outgoing packet */ src_ip_addr = *(u32 *)(skb->data + 14); /* read the IP broadcast address for the device */ -#if defined(LINUX_2_1) || defined(LINUX_2_4) in_dev = dev->ip_ptr; if(in_dev != NULL) { struct in_ifaddr *ifa= in_dev->ifa_list; @@ -1804,9 +1634,6 @@ else return 0; } -#else - broadcast_ip_addr = dev->pa_brdaddr; -#endif /* check if the IP Source Address is a Broadcast address */ if((dev->flags & IFF_BROADCAST) && (src_ip_addr == broadcast_ip_addr)) { @@ -1999,11 +1826,7 @@ * Get ethernet-style interface statistics. * Return a pointer to struct enet_statistics. */ -#if defined(LINUX_2_1) || defined(LINUX_2_4) static struct net_device_stats *if_stats(netdevice_t *dev) -#else -static struct enet_statistics* if_stats (netdevice_t* dev) -#endif { fr_channel_t* chan = dev->priv; @@ -2193,7 +2016,7 @@ skb = dev_alloc_skb(len); - if (!is_dev_running(dev) || (skb == NULL)){ + if (!netif_running(dev) || (skb == NULL)){ ++chan->ifstats.rx_dropped; @@ -2206,11 +2029,11 @@ chan->drvstats_rx_intr.rx_intr_no_socket ++; } - if (!is_dev_running(dev)){ + if (!netif_running(dev)){ chan->drvstats_rx_intr. rx_intr_dev_not_started ++; if (skb){ - wan_dev_kfree_skb(skb, FREE_READ); + dev_kfree_skb_any(skb); } } goto rx_done; @@ -2252,7 +2075,6 @@ } } -#if defined(LINUX_2_1) || defined(LINUX_2_4) }else if (chan->common.usedby == API) { /* We are in API mode. @@ -2281,7 +2103,6 @@ bh_enqueue(dev, skb); trigger_fr_bh(chan); - #endif }else if (handle_IPXWAN(skb->data,chan->name,chan->enable_IPX, chan->network_number)){ @@ -2289,7 +2110,7 @@ //if (chan->enable_IPX) { // fr_send(card, dlci, 0, skb->len,skb->data); //} - wan_dev_kfree_skb(skb, FREE_READ); + dev_kfree_skb_any(skb); } else if (is_arp(skb->data)) { @@ -2304,7 +2125,7 @@ card->devname); } } - wan_dev_kfree_skb(skb, FREE_READ); + dev_kfree_skb_any(skb); } else if (skb->data[0] != 0x03) { @@ -2312,7 +2133,7 @@ printk(KERN_INFO "%s: Non IETF packet discarded.\n", card->devname); } - wan_dev_kfree_skb(skb, FREE_READ); + dev_kfree_skb_any(skb); } else { @@ -2341,7 +2162,7 @@ if (!wanrouter_type_trans(skb, dev)) { /* can't decapsulate packet */ - wan_dev_kfree_skb(skb, FREE_READ); + dev_kfree_skb_any(skb); ++chan->drvstats_rx_intr.rx_intr_bfr_not_passed_to_stack; ++chan->ifstats.rx_errors; @@ -2359,10 +2180,8 @@ ++chan->ifstats.rx_packets; ++card->wandev.stats.rx_packets; -#if defined(LINUX_2_1) || defined(LINUX_2_4) chan->ifstats.rx_bytes += len_incl_hdr; card->wandev.stats.rx_bytes += len_incl_hdr; -#endif } rx_done: @@ -2454,36 +2273,28 @@ ++chan->ifstats.tx_packets; ++card->wandev.stats.tx_packets; -#if defined(LINUX_2_1) || defined(LINUX_2_4) chan->ifstats.tx_bytes += chan->transmit_length; card->wandev.stats.tx_bytes += chan->transmit_length; -#endif /* We must free an sk buffer, which we used * for delayed transmission; Otherwise, the sock * will run out of memory */ - wan_dev_kfree_skb(chan->delay_skb, FREE_WRITE); + dev_kfree_skb_any(chan->delay_skb); chan->delay_skb = NULL; chan->transmit_length = 0; -#ifdef LINUX_2_4 dev->trans_start = jiffies; -#endif -#ifdef LINUX_2_0 - wake_net_dev(dev); -#else - if (is_queue_stopped(dev)){ + if (netif_queue_stopped(dev)){ /* If using API, than wakeup socket BH handler */ if (chan->common.usedby == API){ - start_net_queue(dev); + netif_start_queue(dev); wakeup_sk_bh(dev); }else{ - wake_net_dev(dev); + netif_wake_queue(dev); } } -#endif } end_of_tx_intr: @@ -2778,8 +2589,6 @@ fr_channel_t *chan = dev->priv; sdla_t *card = chan->card; -#if defined(LINUX_2_1) || defined(LINUX_2_4) - struct ifreq if_info; struct sockaddr_in *if_data; mm_segment_t fs = get_fs(); @@ -2851,66 +2660,6 @@ } /* Case Statement */ -#else - /* Dynamic Route adding/removing */ - struct rtentry route; - int err = 0; - unsigned long fs = get_fs(); - - memset(&route, 0, sizeof(route)); - route.rt_dev = dev->name; - route.rt_flags = 0; - - ((struct sockaddr_in *) &(route.rt_dst)) -> - sin_addr.s_addr=dev->pa_dstaddr; - ((struct sockaddr_in *) &(route.rt_dst)) -> - sin_family = AF_INET; - ((struct sockaddr_in *) &(route.rt_genmask)) -> - sin_addr.s_addr = 0xFFFFFFFF; - ((struct sockaddr_in *) &(route.rt_genmask)) -> - sin_family = AF_INET; - switch(chan->route_flag) { - - case ADD_ROUTE: - - set_fs(get_ds()); /* get user space block */ - err = ip_rt_new(&route); - set_fs(fs); /* restore old block */ - - if (err) { - printk(KERN_INFO "%s: Adding of route failed. Error: %d\n", - card->devname,err); - printk(KERN_INFO "%s: Address: %u.%u.%u.%u\n", - chan->name, NIPQUAD(dev->pa_dstaddr) ); - } - else { - chan->route_flag = ROUTE_ADDED; - } - break; - - case REMOVE_ROUTE: - - set_fs(get_ds()); /* get user space block */ - err = ip_rt_kill(&route); - set_fs(fs); /* restore old block */ - - if (err) { - printk(KERN_INFO "%s: Deleting of route failed. Error: %d\n", - card->devname,err); - printk(KERN_INFO "%s: Address: %u.%u.%u.%u\n", - dev->name,NIPQUAD(dev->pa_dstaddr) ); - } else { - - printk(KERN_INFO "%s: Removed route.\n", - ((fr_channel_t*)dev->priv)->name); - chan->route_flag = NO_ROUTE; - - } - break; - } - -#endif - } @@ -3468,7 +3217,7 @@ "%s: DLCI %u is inactive!\n", card->devname, dlci); - if (dev && is_dev_running(dev)) + if (dev && netif_running(dev)) set_chan_state(dev, WAN_DISCONNECTED); } @@ -3478,7 +3227,7 @@ "%s: DLCI %u has been deleted!\n", card->devname, dlci); - if (dev && is_dev_running(dev)){ + if (dev && netif_running(dev)){ fr_channel_t *chan = dev->priv; @@ -3743,9 +3492,9 @@ } if(udp_pkt_src == UDP_PKT_FRM_STACK){ - wan_dev_kfree_skb(skb, FREE_WRITE); + dev_kfree_skb_any(skb); }else{ - wan_dev_kfree_skb(skb, FREE_READ); + dev_kfree_skb_any(skb); } return(udp_pkt_stored); @@ -4173,8 +3922,6 @@ { int err=0; -#if defined(LINUX_2_1) || defined(LINUX_2_4) - arphdr_1490_t *ArpPacket; arphdr_fr_t *arphdr; fr_channel_t *chan = dev->priv; @@ -4225,47 +3972,6 @@ return 1; } -#else - arphdr_1490_t *ArpPacket; - arphdr_fr_t *arphdr; - fr_channel_t *chan = dev->priv; - - ArpPacket = kmalloc(sizeof(arphdr_1490_t) + sizeof(arphdr_fr_t), GFP_ATOMIC); - /* SNAP Header indicating ARP */ - ArpPacket->control = 0x03; - ArpPacket->pad = 0x00; - ArpPacket->NLPID = 0x80; - ArpPacket->OUI[0] = 0; - ArpPacket->OUI[1] = 0; - ArpPacket->OUI[2] = 0; - ArpPacket->PID = 0x0608; - - arphdr = (arphdr_fr_t *)(ArpPacket + 1); // Go to ARP Packet - /* InARP request */ - arphdr->ar_hrd = 0x0F00; /* Frame Relay HW type */ - arphdr->ar_pro = 0x0008; /* IP Protocol */ - arphdr->ar_hln = 2; /* HW addr length */ - arphdr->ar_pln = 4; /* IP addr length */ - arphdr->ar_op = htons(0x08); /* InARP Request */ - arphdr->ar_sha = 0; /* src HW DLCI - Doesn't matter */ - arphdr->ar_sip = dev->pa_addr; /* Local Address */ - arphdr->ar_tha = 0; /* dst HW DLCI - Doesn't matter */ - arphdr->ar_tip = 0; /* Remote Address -- what we want */ - - printk(KERN_INFO "%s: Sending InARP request on DLCI %d.\n", card->devname, chan->dlci); - err = fr_send(card, chan->dlci, 0, - sizeof(arphdr_1490_t) + sizeof(arphdr_fr_t), - (void *)ArpPacket); - - if (!err){ - printk(KERN_INFO "\n%s: Sending InARP request on DLCI %d.\n", - card->devname, chan->dlci); - clear_bit(ARP_CRIT,&card->wandev.critical); - } - - kfree(ArpPacket); -#endif - return 0; } @@ -4293,15 +3999,10 @@ { -#if defined(LINUX_2_1) || defined(LINUX_2_4) arphdr_fr_t *arphdr = (arphdr_fr_t *)(ArpPacket + 1); /* Skip header */ fr_rx_buf_ctl_t* frbuf = card->rxmb; struct in_device *in_dev; fr_channel_t *chan = dev->priv; -#else - arphdr_fr_t *arphdr = (arphdr_fr_t *)(ArpPacket + 1); /* Skip header */ - fr_rx_buf_ctl_t* frbuf = card->rxmb; -#endif /* Before we transmit ARP packet, we must check * to see that we are not currently transmitting a @@ -4316,8 +4017,6 @@ return 0; } -#if defined(LINUX_2_1) || defined(LINUX_2_4) - in_dev = dev->ip_ptr; /* Check that IP addresses exist for our network address */ @@ -4434,87 +4133,6 @@ } return 0; -#else - - switch (ntohs(arphdr->ar_op)) { - - case 0x08: // Inverse ARP request -- Send Reply, add route. - - /* Check for valid Address */ - printk(KERN_INFO "%s: Recvd PtP addr %u.%u.%u.%u -InArp Req\n", - ((fr_channel_t *)dev->priv)->name, NIPQUAD(arphdr->ar_sip)); - - - if (dev->pa_mask != 0xFFFFFFFF){ - - if ((dev->pa_mask & arphdr->ar_sip) != (dev->pa_mask & dev->pa_addr)) { - printk(KERN_INFO "%s: Invalid PtP address. InARP ignored.\n", - card->devname); - return -1; - } - } - - if (dev->pa_addr == arphdr->ar_sip) { - printk(KERN_INFO "%s: Local addr = PtP addr. InARP ignored.\n", - card->devname); - return -1; - } - - arphdr->ar_op = htons(0x09); /* InARP Reply */ - - /* Set addresses */ - arphdr->ar_tip = arphdr->ar_sip; - arphdr->ar_sip = dev->pa_addr; - - fr_send(card, frbuf->dlci, 0, frbuf->length, (void *)ArpPacket); - - clear_bit(ARP_CRIT,&card->wandev.critical); - - /* Modify Point-to-Point Address */ - dev->pa_dstaddr = arphdr->ar_tip; - - /* Add Route Flag */ - /* The route will be added in the polling routine so - that it is not interrupt context. */ - ((fr_channel_t *) dev->priv)->route_flag = ADD_ROUTE; - trigger_fr_poll(dev); - - break; - case 0x09: // Inverse ARP reply - - /* Check for valid Address */ - printk(KERN_INFO "%s: Recvd PtP addr %u.%u.%u.%u -InArp Reply\n", - ((fr_channel_t *)dev->priv)->name, NIPQUAD(arphdr->ar_sip)); - - if ((dev->pa_mask & arphdr->ar_sip) != (dev->pa_mask & dev->pa_addr)) { - printk(KERN_INFO "%s: Invalid PtP address. InARP ignored.\n", - card->devname); - return -1; - } - - if (dev->pa_addr == arphdr->ar_sip) { - printk(KERN_INFO "%s: Local addr = PtP addr. InARP ignored.\n", - card->devname); - return -1; - } - - /* Modify Point-to-Point Address */ - dev->pa_dstaddr = arphdr->ar_sip; - /* Add Route Flag */ - /* The route will be added in the polling routine so - that it is not interrupt context. */ - - ((fr_channel_t *) dev->priv)->route_flag = ADD_ROUTE; - ((fr_channel_t *) dev->priv)->inarp = INARP_CONFIGURED; - trigger_fr_poll(dev); - - break; - default: // ARP's and RARP's -- Shouldn't happen. - } - - return 0; - -#endif } @@ -4706,15 +4324,9 @@ { if (card->hw.type != SDLA_S514){ -#if defined(__SMP__) || defined(LINUX_2_4) spin_lock_irqsave(&card->wandev.lock, *smp_flags); -#else - disable_irq(card->hw.irq); -#endif }else{ -#if defined(__SMP__) || defined(LINUX_2_4) spin_lock(&card->u.f.if_send_lock); -#endif } return; } @@ -4724,23 +4336,15 @@ { if (card->hw.type != SDLA_S514){ -#if defined(__SMP__) || defined(LINUX_2_4) spin_unlock_irqrestore (&card->wandev.lock, *smp_flags); -#else - enable_irq(card->hw.irq); -#endif }else{ -#if defined(__SMP__) || defined(LINUX_2_4) spin_unlock(&card->u.f.if_send_lock); -#endif } return; } -#if defined(LINUX_2_1) || defined(LINUX_2_4) - /*---------------------------------------------------------------------- RECEIVE INTERRUPT: BOTTOM HALF HANDLERS ----------------------------------------------------------------------*/ @@ -4770,7 +4374,7 @@ if (atomic_read(&chan->bh_buff_used) == MAX_BH_BUFF){ ++card->wandev.stats.rx_dropped; - wan_dev_kfree_skb(skb, FREE_READ); + dev_kfree_skb_any(skb); return 1; } @@ -4859,7 +4463,7 @@ if (chan->common.sk == NULL || chan->common.func == NULL){ ++card->wandev.stats.rx_dropped; ++chan->ifstats.rx_dropped; - wan_dev_kfree_skb(skb, FREE_READ); + dev_kfree_skb_any(skb); fr_bh_cleanup(dev); continue; } @@ -4896,7 +4500,6 @@ atomic_dec(&chan->bh_buff_used); return 0; } -#endif /*---------------------------------------------------------------------- @@ -4919,11 +4522,7 @@ static void trigger_fr_poll (netdevice_t *dev) { fr_channel_t* chan = dev->priv; -#ifdef LINUX_2_4 schedule_task(&chan->fr_poll_task); -#else - queue_task(&chan->fr_poll_task, &tq_scheduler); -#endif return; } @@ -5047,7 +4646,7 @@ } } - if (is_queue_stopped(dev) || (card->u.f.tx_interrupts_pending)) + if (netif_queue_stopped(dev) || (card->u.f.tx_interrupts_pending)) return 1; return 0; @@ -5295,7 +4894,6 @@ * an Ethernet header */ if (op_mode == BRIDGE || op_mode == BRIDGE_NODE){ -#if defined(LINUX_2_1) || defined(LINUX_2_4) /* Encapsulate the packet as a bridged Ethernet frame. */ #ifdef DEBUG @@ -5316,12 +4914,6 @@ skb->protocol = ETH_P_802_3; return 8; -#else - - /* BRIDGING is not supported in 2.0.X */ - return -EINVAL; - -#endif } return 0; diff -Nru a/drivers/net/wan/sdla_ft1.c b/drivers/net/wan/sdla_ft1.c --- a/drivers/net/wan/sdla_ft1.c Mon Aug 26 11:35:50 2002 +++ b/drivers/net/wan/sdla_ft1.c Sun Feb 16 16:22:42 2003 @@ -252,8 +252,6 @@ CHDLC_MAILBOX_STRUCT* mbox = card->mbox; int len; - -#if defined(LINUX_2_1) || defined(LINUX_2_4) if (copy_from_user((void*)&mbox->command, u_cmd, sizeof(ft1_exec_cmd_t))){ return -EFAULT; } @@ -281,36 +279,6 @@ if (len && u_data && copy_to_user(u_data, (void*)&mbox->data, len)){ return -EFAULT; } - -#else - - if (!u_cmd || verify_area(VERIFY_WRITE, u_cmd, sizeof(ft1_exec_cmd_t))){ - return -EFAULT; - } - - memcpy_fromfs((void*)&mbox->command, u_cmd, sizeof(ft1_exec_cmd_t)); - - len = mbox->buffer_length; - - if (len) { - if (!u_data || verify_area(VERIFY_READ, u_data, len)) - return -EFAULT; - memcpy_fromfs((void*)&mbox->data, u_data, len); - } - - /* execute command */ - if (!sdla_exec(mbox)) - return -EIO; - - /* return result */ - memcpy_tofs(u_cmd, (void*)&mbox->command, sizeof(ft1_exec_cmd_t)); - len = mbox->buffer_length; - - if (len && u_data && !verify_area(VERIFY_WRITE, u_data, len)){ - memcpy_tofs(u_data, (void*)&mbox->data, len); - } - -#endif return 0; diff -Nru a/drivers/net/wan/sdla_ppp.c b/drivers/net/wan/sdla_ppp.c --- a/drivers/net/wan/sdla_ppp.c Tue Feb 25 11:05:23 2003 +++ b/drivers/net/wan/sdla_ppp.c Thu Mar 6 09:25:30 2003 @@ -104,15 +104,9 @@ #include /* sockaddr_in */ -/* ---- 2.4.X KERNEL SUPPORT -----------------------*/ -#if defined(LINUX_2_1) || defined(LINUX_2_4) - #include - #include - #include -#else - #include - #include /* Adding new route entries : 2.0.X kernels */ -#endif +#include +#include +#include #include #include /* PPP firmware API definitions */ @@ -163,10 +157,6 @@ #define NUM_AUTH_REQ_WITHOUT_REPLY 10 #define END_OFFSET 0x1F0 -#if LINUX_VERSION_CODE < 0x020125 -#define test_and_set_bit set_bit -#define net_ratelimit() 1 -#endif /******Data Structures*****************************************************/ @@ -255,18 +245,10 @@ static int if_header(struct sk_buff *skb, netdevice_t *dev, unsigned short type, void *daddr, void *saddr, unsigned len); -#ifdef LINUX_2_4 static void if_tx_timeout (netdevice_t *dev); -#endif -#if defined(LINUX_2_1) || defined(LINUX_2_4) static int if_rebuild_hdr(struct sk_buff *skb); static struct net_device_stats *if_stats(netdevice_t *dev); -#else -static struct enet_statistics *if_stats(netdevice_t *dev); -static int if_rebuild_hdr (void* hdr, netdevice_t* dev, unsigned long raddr, - struct sk_buff* skb); -#endif static int if_send(struct sk_buff *skb, netdevice_t *dev); @@ -615,17 +597,7 @@ } /* prepare network device data space for registration */ -#ifdef LINUX_2_4 strcpy(dev->name,card->u.p.if_name); -#else - dev->name = (char *)kmalloc(strlen(card->u.p.if_name) + 2, GFP_KERNEL); - if(dev->name == NULL) - { - kfree(ppp_priv_area); - return -ENOMEM; - } - sprintf(dev->name, "%s", card->u.p.if_name); -#endif dev->init = &if_init; dev->priv = ppp_priv_area; @@ -673,7 +645,6 @@ ppp_mbox_t *mbox = card->mbox; int len; -#if defined(LINUX_2_1) || defined(LINUX_2_4) if (copy_from_user((void*)&mbox->cmd, u_cmd, sizeof(ppp_cmd_t))) return -EFAULT; @@ -698,35 +669,6 @@ if (len && u_data && copy_to_user(u_data, (void*)&mbox->data, len)) return -EFAULT; -#else - - if (!u_cmd || verify_area(VERIFY_WRITE, u_cmd, sizeof(ppp_cmd_t))) - return -EFAULT; - - memcpy_fromfs((void*)&mbox->cmd, u_cmd, sizeof(ppp_cmd_t)); - - len = mbox->cmd.length; - - if (len) { - - if (!u_data || verify_area(VERIFY_READ, u_data, len)) - return -EFAULT; - } - - /* execute command */ - if (!sdla_exec(mbox)) - return -EIO; - - /* return result */ - memcpy_tofs(u_cmd, (void*)&mbox->cmd, sizeof(ppp_cmd_t)); - len = mbox->cmd.length; - - if (len && u_data && !verify_area(VERIFY_WRITE, u_data, len)) - memcpy_tofs(u_data, (void*)&mbox->data, len); - - -#endif - return 0; } @@ -744,9 +686,6 @@ ppp_private_area_t *ppp_priv_area = dev->priv; sdla_t *card = ppp_priv_area->card; wan_device_t *wandev = &card->wandev; -#ifdef LINUX_2_0 - int i; -#endif /* Initialize device driver entry points */ dev->open = &if_open; @@ -755,10 +694,8 @@ dev->rebuild_header = &if_rebuild_hdr; dev->hard_start_xmit = &if_send; dev->get_stats = &if_stats; -#ifdef LINUX_2_4 dev->tx_timeout = &if_tx_timeout; dev->watchdog_timeo = TX_TIMEOUT; -#endif /* Initialize media-specific parameters */ dev->type = ARPHRD_PPP; /* ARP h/w type */ @@ -770,9 +707,6 @@ dev->flags |= IFF_MULTICAST; } -#ifdef LINUX_2_0 - dev->family = AF_INET; -#endif dev->mtu = wandev->mtu; dev->hard_header_len = PPP_HDR_LEN; /* media header length */ @@ -786,12 +720,6 @@ /* Set transmit buffer queue length */ dev->tx_queue_len = 100; - /* Initialize socket buffers */ - #if !defined(LINUX_2_1) && !defined(LINUX_2_4) - for (i = 0; i < DEV_NUMBUFFS; ++i) - skb_queue_head_init(&dev->buffs[i]); - #endif - return 0; } @@ -809,18 +737,12 @@ struct timeval tv; //unsigned long smp_flags; - if (is_dev_running(dev)) + if (netif_running(dev)) return -EBUSY; wanpipe_open(card); -#ifdef LINUX_2_4 netif_start_queue(dev); -#else - dev->interrupt = 0; - dev->tbusy = 0; - dev->start = 1; -#endif do_gettimeofday( &tv ); ppp_priv_area->router_start_time = tv.tv_sec; @@ -852,10 +774,7 @@ ppp_private_area_t *ppp_priv_area = dev->priv; sdla_t *card = ppp_priv_area->card; - stop_net_queue(dev); -#ifndef LINUX_2_4 - dev->start=0; -#endif + netif_stop_queue(dev); wanpipe_close(card); del_timer (&ppp_priv_area->poll_delay_timer); @@ -894,7 +813,6 @@ * Return: 1 physical address resolved. * 0 physical address not resolved */ -#if defined(LINUX_2_1) || defined(LINUX_2_4) static int if_rebuild_hdr (struct sk_buff *skb) { netdevice_t *dev = skb->dev; @@ -906,16 +824,6 @@ return 1; } -#else -static int if_rebuild_hdr (void* hdr, netdevice_t* dev, unsigned long raddr, - struct sk_buff* skb) -{ - return 1; - -} -#endif - -#ifdef LINUX_2_4 /*============================================================================ * Handle transmit timeout event from netif watchdog */ @@ -937,7 +845,6 @@ ++chan->if_send_stat.if_send_tbusy_timeout; netif_wake_queue (dev); } -#endif @@ -970,9 +877,7 @@ ++ppp_priv_area->if_send_stat.if_send_entry; -#ifdef LINUX_2_4 netif_stop_queue(dev); -#endif if (skb == NULL) { @@ -984,36 +889,10 @@ ++ppp_priv_area->if_send_stat.if_send_skb_null; - wake_net_dev(dev); + netif_wake_queue(dev); return 0; } -#ifndef LINUX_2_4 - if (dev->tbusy) { - - /* If our device stays busy for at least 5 seconds then we will - * kick start the device by making dev->tbusy = 0. We expect - * that our device never stays busy more than 5 seconds. So this - * is only used as a last resort. - */ - - ++ppp_priv_area->if_send_stat.if_send_tbusy; - ++card->wandev.stats.collisions; - - if ((jiffies - ppp_priv_area->tick_counter) < (5*HZ)) { - return 1; - } - - printk (KERN_INFO "%s: Transmit times out on %s\n",card->devname,dev->name); - - ++ppp_priv_area->if_send_stat.if_send_tbusy_timeout; - ++card->wandev.stats.collisions; - - /* unbusy the card (because only one interface per card)*/ - dev->tbusy = 0; - } -#endif - sendpacket = skb->data; udp_type = udp_pkt_type( skb, card ); @@ -1025,7 +904,7 @@ flags->imask |= PPP_INTR_TIMER; } ++ppp_priv_area->if_send_stat.if_send_PIPE_request; - start_net_queue(dev); + netif_start_queue(dev); return 0; } @@ -1034,8 +913,8 @@ */ if(chk_bcast_mcast_addr(card, dev, skb)){ ++card->wandev.stats.tx_dropped; - wan_dev_kfree_skb(skb,FREE_WRITE); - start_net_queue(dev); + dev_kfree_skb_any(skb); + netif_start_queue(dev); return 0; } @@ -1051,7 +930,7 @@ ++card->wandev.stats.tx_dropped; ++ppp_priv_area->if_send_stat.if_send_critical_non_ISR; - start_net_queue(dev); + netif_start_queue(dev); goto if_send_exit_crit; } @@ -1059,12 +938,12 @@ ++ppp_priv_area->if_send_stat.if_send_wan_disconnected; ++card->wandev.stats.tx_dropped; - start_net_queue(dev); + netif_start_queue(dev); } else if (!skb->protocol) { ++ppp_priv_area->if_send_stat.if_send_protocol_error; ++card->wandev.stats.tx_errors; - start_net_queue(dev); + netif_start_queue(dev); } else { @@ -1075,32 +954,28 @@ ppp_priv_area->network_number, 0); } else { ++card->wandev.stats.tx_dropped; - start_net_queue(dev); + netif_start_queue(dev); goto if_send_exit_crit; } } if (ppp_send(card, skb->data, skb->len, skb->protocol)) { - stop_net_queue(dev); + netif_stop_queue(dev); ++ppp_priv_area->if_send_stat.if_send_adptr_bfrs_full; ++ppp_priv_area->if_send_stat.if_send_tx_int_enabled; } else { ++ppp_priv_area->if_send_stat.if_send_bfr_passed_to_adptr; ++card->wandev.stats.tx_packets; -#if defined(LINUX_2_1) || defined(LINUX_2_4) card->wandev.stats.tx_bytes += skb->len; -#endif - start_net_queue(dev); -#ifdef LINUX_2_4 + netif_start_queue(dev); dev->trans_start = jiffies; -#endif } } if_send_exit_crit: - if (!(err=is_queue_stopped(dev))){ - wan_dev_kfree_skb(skb, FREE_WRITE); + if (!(err=netif_queue_stopped(dev))){ + dev_kfree_skb_any(skb); }else{ ppp_priv_area->tick_counter = jiffies; flags->imask |= PPP_INTR_TXRDY; /* unmask Tx interrupts */ @@ -1134,13 +1009,8 @@ udp_pkt_stored = 1; }else{ if (skb->len > MAX_LGTH_UDP_MGNT_PKT){ -#if defined(LINUX_2_1) || defined(LINUX_2_4) printk(KERN_INFO "%s: PIPEMON UDP request too long : %i\n", card->devname, skb->len); -#else - printk(KERN_INFO "%s: PIPEMON UDP request too long : %li\n", - card->devname, skb->len); -#endif }else{ printk(KERN_INFO "%s: PIPEMON UPD request already pending\n", card->devname); @@ -1149,9 +1019,9 @@ } if(udp_pkt_src == UDP_PKT_FRM_STACK){ - wan_dev_kfree_skb(skb, FREE_WRITE); + dev_kfree_skb_any(skb); }else{ - wan_dev_kfree_skb(skb, FREE_READ); + dev_kfree_skb_any(skb); } return(udp_pkt_stored); @@ -1319,11 +1189,7 @@ * Get ethernet-style interface statistics. * Return a pointer to struct net_device_stats. */ -#if defined(LINUX_2_1) || defined(LINUX_2_4) static struct net_device_stats *if_stats(netdevice_t *dev) -#else -static struct enet_statistics *if_stats(netdevice_t *dev) -#endif { ppp_private_area_t *ppp_priv_area = dev->priv; @@ -1743,7 +1609,7 @@ case PPP_INTR_TXRDY: /* transmit interrupt 0x02 (bit 1)*/ ++card->statistics.isr_tx; flags->imask &= ~PPP_INTR_TXRDY; - wake_net_dev(dev); + netif_wake_queue(dev); break; case PPP_INTR_CMD: /* interface command completed */ @@ -1821,7 +1687,7 @@ return; } - if (dev && is_dev_running(dev) && dev->priv){ + if (dev && netif_running(dev) && dev->priv){ len = rxbuf->length; ppp_priv_area = dev->priv; @@ -1881,7 +1747,7 @@ if (!test_bit(SEND_CRIT, &card->wandev.critical)){ ppp_send(card, skb->data, skb->len, htons(ETH_P_IPX)); } - wan_dev_kfree_skb(skb,FREE_READ); + dev_kfree_skb_any(skb); } else { ++card->wandev.stats.rx_dropped; @@ -1892,9 +1758,7 @@ skb->mac.raw = skb->data; ++card->wandev.stats.rx_packets; -#if defined(LINUX_2_1) || defined(LINUX_2_4) card->wandev.stats.rx_bytes += skb->len; -#endif ++ppp_priv_area->rx_intr_stat.rx_intr_bfr_passed_to_stack; netif_rx(skb); dev->last_rx = jiffies; @@ -2244,8 +2108,6 @@ netdevice_t *dev = card->wandev.dev; ppp_private_area_t *ppp_priv_area = dev->priv; -#if defined(LINUX_2_1) || defined(LINUX_2_4) - if ((card->u.p.ip_mode == WANOPT_PPP_PEER) && (flags->ip_state == 0x09)){ @@ -2276,29 +2138,6 @@ } } } -#else - - if ((card->u.p.ip_mode == WANOPT_PPP_PEER) && - (flags->ip_state == 0x09)){ - - if (ppp_priv_area->ip_local == 0) - return; - - printk(KERN_INFO "%s: IPCP State Opened.\n", card->devname); - if (read_info( card )) { - printk(KERN_INFO - "%s: An error occurred in IP assignment.\n", - card->devname); - } else { - printk(KERN_INFO "%s: Assigned Lcl. Addr: %u.%u.%u.%u\n", - card->devname, NIPQUAD(dev->pa_addr)); - printk(KERN_INFO "%s: Assigned Rmt. Addr: %u.%u.%u.%U\n", - card->devname, NIPQUAD(dev->pa_dstaddr)); - } - } - -#endif - } /*============================================================================ @@ -2328,9 +2167,7 @@ static int config508(netdevice_t *dev, sdla_t *card) { ppp508_conf_t cfg; -#if defined(LINUX_2_1) || defined(LINUX_2_4) struct in_device *in_dev = dev->ip_ptr; -#endif ppp_private_area_t *ppp_priv_area = dev->priv; /* Prepare PPP configuration structure */ @@ -2393,14 +2230,8 @@ printk(KERN_INFO "%s: PPP IP Mode: STATIC\n",card->devname); cfg.ip_options = L_AND_R_IP_NO_ASSIG | ENABLE_IP; -#if defined(LINUX_2_1) || defined(LINUX_2_4) cfg.ip_local = in_dev->ifa_list->ifa_local; cfg.ip_remote = in_dev->ifa_list->ifa_address; -#else - cfg.ip_local = dev->pa_addr; - cfg.ip_remote = dev->pa_dstaddr; -#endif - /* Debugging code used to check that IP addresses * obtained from the kernel are correct */ @@ -2414,14 +2245,8 @@ cfg.ip_options = L_IP_LOCAL_ASSIG | R_IP_LOCAL_ASSIG | ENABLE_IP; -#if defined(LINUX_2_1) || defined(LINUX_2_4) cfg.ip_local = in_dev->ifa_list->ifa_local; cfg.ip_remote = in_dev->ifa_list->ifa_address; -#else - cfg.ip_local = dev->pa_addr; - cfg.ip_remote = dev->pa_dstaddr; -#endif - /* Debugging code used to check that IP addresses * obtained from the kernel are correct */ NEX_PRINTK (KERN_INFO "Local %u.%u.%u.%u Remote %u.%u.%u.%u Name %s\n", @@ -2431,8 +2256,6 @@ case WANOPT_PPP_PEER: -#if defined(LINUX_2_1) || defined(LINUX_2_4) - printk(KERN_INFO "%s: PPP IP Mode: PEER\n",card->devname); cfg.ip_options = L_IP_REMOTE_ASSIG | R_IP_REMOTE_ASSIG | @@ -2441,16 +2264,6 @@ cfg.ip_remote = 0x00; break; -#else - - /* No PEER support for 2.0.X kernels, drop down to default - * condition */ - - printk(KERN_INFO "%s: ERROR, PEER mode is not supported in 2.0.X kernels\n", - card->devname); - -#endif - default: printk(KERN_INFO "%s: ERROR: Unsupported PPP Mode Selected\n", card->devname); @@ -3038,19 +2851,9 @@ ppp_private_area_t *ppp_priv_area = dev->priv; int err; -#if defined(LINUX_2_1) || defined(LINUX_2_4) struct ifreq if_info; struct sockaddr_in *if_data1, *if_data2; mm_segment_t fs; -#else -#ifdef _DYNAMIC_ROUTE_20X_SUPPORT_ - struct rtentry route; -#endif -#endif - - - -#if defined(LINUX_2_1) || defined(LINUX_2_4) /* Set Local and remote addresses */ memset(&if_info, 0, sizeof(if_info)); @@ -3074,39 +2877,6 @@ set_fs(fs); /* restore old block */ -#else - /* FIXME: Dynamic Routing in 2.0.X kernels is not - * supported. Sorry ! I'll come back to it when I get - * a chance. */ - - printk(KERN_INFO "%s: ERROR, Dynamic routing is not supported in 2.0.X kernels\n", - card->devname); - printk(KERN_INFO "%s: Please use the STATIC IP mode!\n", - card->devname); - - err = 0; - -#ifdef _DYNAMIC_ROUTE_20X_SUPPORT_ - dev->pa_dstaddr = ppp_priv_area->ip_remote; - dev->pa_addr = ppp_priv_area->ip_local; - - memset(&route, 0, sizeof(route)); - route.rt_dev = dev->name; - route.rt_flags = 0; - ((struct sockaddr_in *)&(route.rt_dst))->sin_addr.s_addr = - dev->pa_dstaddr; - ((struct sockaddr_in *)&(route.rt_dst))->sin_family = AF_INET; - ((struct sockaddr_in *)&(route.rt_genmask))->sin_addr.s_addr = - 0xFFFFFFFF; - ((struct sockaddr_in *)&(route.rt_genmask))->sin_family = - AF_INET; - - err = ip_rt_new(&route); - -#endif - -#endif - if (err) { printk (KERN_INFO "%s: Adding of route failed: %i\n", card->devname,err); @@ -3130,32 +2900,21 @@ long ip_addr; int err; -#if defined(LINUX_2_1) || defined(LINUX_2_4) mm_segment_t fs; struct ifreq if_info; struct sockaddr_in *if_data1; struct in_device *in_dev = dev->ip_ptr; struct in_ifaddr *ifa = in_dev->ifa_list; -#else - unsigned long fs = 0; - struct rtentry route; -#endif - -#if defined(LINUX_2_1) || defined(LINUX_2_4) ip_addr = ifa->ifa_local; /* Set Local and remote addresses */ memset(&if_info, 0, sizeof(if_info)); strcpy(if_info.ifr_name, dev->name); -#endif - fs = get_fs(); set_fs(get_ds()); /* get user space block */ - -#if defined(LINUX_2_1) || defined(LINUX_2_4) /* Change the local ip address of the interface to 0. * This will also delete the destination route. */ @@ -3163,26 +2922,6 @@ if_data1->sin_addr.s_addr = 0; if_data1->sin_family = AF_INET; err = devinet_ioctl( SIOCSIFADDR, &if_info ); -#else - - ip_addr = dev->pa_addr; - dev->pa_dstaddr = 0; - - memset(&route, 0, sizeof(route)); - route.rt_dev = dev->name; - route.rt_flags = 0; - ((struct sockaddr_in *)&(route.rt_dst))->sin_addr.s_addr = - dev->pa_dstaddr; - ((struct sockaddr_in *)&(route.rt_dst))->sin_family = AF_INET; - ((struct sockaddr_in *)&(route.rt_genmask))->sin_addr.s_addr = - 0xFFFFFFFF; - ((struct sockaddr_in *)&(route.rt_genmask))->sin_family = - AF_INET; - - - err = ip_rt_kill(&route); - -#endif set_fs(fs); /* restore old block */ @@ -3288,14 +3027,12 @@ { u32 src_ip_addr; u32 broadcast_ip_addr = 0; -#if defined(LINUX_2_1) || defined(LINUX_2_4) struct in_device *in_dev; -#endif + /* read the IP source address from the outgoing packet */ src_ip_addr = *(u32 *)(skb->data + 12); /* read the IP broadcast address for the device */ -#if defined(LINUX_2_1) || defined(LINUX_2_4) in_dev = dev->ip_ptr; if(in_dev != NULL) { struct in_ifaddr *ifa= in_dev->ifa_list; @@ -3304,9 +3041,6 @@ else return 0; } -#else - broadcast_ip_addr = dev->pa_brdaddr; -#endif /* check if the IP Source Address is a Broadcast address */ if((dev->flags & IFF_BROADCAST) && (src_ip_addr == broadcast_ip_addr)) { @@ -3328,20 +3062,12 @@ void s508_lock (sdla_t *card, unsigned long *smp_flags) { -#if defined(__SMP__) || defined(LINUX_2_4) spin_lock_irqsave(&card->wandev.lock, *smp_flags); -#else - disable_irq(card->hw.irq); -#endif } void s508_unlock (sdla_t *card, unsigned long *smp_flags) { -#if defined(__SMP__) || defined(LINUX_2_4) spin_unlock_irqrestore(&card->wandev.lock, *smp_flags); -#else - enable_irq(card->hw.irq); -#endif } static int read_connection_info (sdla_t *card) diff -Nru a/drivers/net/wan/sdla_x25.c b/drivers/net/wan/sdla_x25.c --- a/drivers/net/wan/sdla_x25.c Tue Feb 25 11:05:23 2003 +++ b/drivers/net/wan/sdla_x25.c Thu Mar 6 09:25:30 2003 @@ -95,12 +95,7 @@ #include #include /* Experimental delay */ -#if defined(LINUX_2_1) || defined(LINUX_2_4) - #include -#else - #include - #include -#endif +#include #include #include @@ -281,11 +276,7 @@ int ch_idx; unsigned char enable_IPX; unsigned long network_number; -#if defined(LINUX_2_1) || defined(LINUX_2_4) struct net_device_stats ifstats; /* interface statistics */ -#else - struct enet_statistics ifstats; -#endif unsigned short transmit_length; unsigned short tx_offset; char transmit_buffer[X25_CHAN_MTU+sizeof(x25api_hdr_t)]; @@ -369,9 +360,7 @@ static int if_send (struct sk_buff* skb, netdevice_t* dev); static struct net_device_stats *if_stats (netdevice_t* dev); -#ifdef LINUX_2_4 static void if_tx_timeout (netdevice_t *dev); -#endif /*================================================= * Interrupt handlers @@ -792,9 +781,6 @@ init_global_statistics(card); -#ifndef LINUX_2_4 - card->u.x.x25_poll_task.next = NULL; -#endif card->u.x.x25_poll_task.sync=0; card->u.x.x25_poll_task.routine = (void*)(void*)wpx_poll; card->u.x.x25_poll_task.data = card; @@ -1011,18 +997,8 @@ chan->network_number = 0xDEADBEEF; /* prepare network device data space for registration */ -#ifdef LINUX_2_4 strcpy(dev->name,chan->name); -#else - dev->name = (char *)kmalloc(strlen(chan->name) + 2, GFP_KERNEL); - if(dev->name == NULL) - { - kfree(chan); - dev->priv = NULL; - return -ENOMEM; - } - sprintf(dev->name, "%s", chan->name); -#endif + dev->init = &if_init; init_x25_channel_struct(chan); @@ -1124,9 +1100,6 @@ x25_channel_t* chan = dev->priv; sdla_t* card = chan->card; wan_device_t* wandev = &card->wandev; -#ifdef LINUX_2_0 - int i; -#endif /* Initialize device driver entry points */ dev->open = &if_open; @@ -1135,19 +1108,11 @@ dev->rebuild_header = &if_rebuild_hdr; dev->hard_start_xmit = &if_send; dev->get_stats = &if_stats; - -#ifdef LINUX_2_4 dev->tx_timeout = &if_tx_timeout; dev->watchdog_timeo = TX_TIMEOUT; -#endif /* Initialize media-specific parameters */ -#if defined(LINUX_2_1) || defined(LINUX_2_4) dev->type = ARPHRD_PPP; /* ARP h/w type */ -#else - dev->family = AF_INET; /* address family */ - dev->type = ARPHRD_PPP; /* no x25 type */ -#endif dev->flags |= IFF_POINTOPOINT; dev->flags |= IFF_NOARP; @@ -1174,11 +1139,6 @@ /* Set transmit buffer queue length */ dev->tx_queue_len = 100; - /* Initialize socket buffers */ -#if !defined(LINUX_2_1) && !defined(LINUX_2_4) - for (i = 0; i < DEV_NUMBUFFS; ++i) - skb_queue_head_init(&dev->buffs[i]); -#endif /* FIXME Why are we doing this */ set_chan_state(dev, WAN_DISCONNECTED); return 0; @@ -1214,15 +1174,12 @@ struct timeval tv; unsigned long smp_flags; - if (is_dev_running(dev)) + if (netif_running(dev)) return -EBUSY; chan->tq_working = 0; /* Initialize the task queue */ -#ifndef LINUX_2_4 - chan->common.wanpipe_task.next = NULL; -#endif chan->common.wanpipe_task.sync = 0; chan->common.wanpipe_task.routine = (void *)(void *)x25api_bh; chan->common.wanpipe_task.data = dev; @@ -1276,13 +1233,8 @@ do_gettimeofday( &tv ); chan->router_start_time = tv.tv_sec; -#ifdef LINUX_2_4 netif_start_queue(dev); -#else - dev->interrupt = 0; - dev->tbusy = 0; - dev->start = 1; -#endif + return 0; } @@ -1314,10 +1266,7 @@ sdla_t* card = chan->card; unsigned long smp_flags; - stop_net_queue(dev); -#ifndef LINUX_2_4 - dev->start=0; -#endif + netif_stop_queue(dev); if ((chan->common.state == WAN_CONNECTED) || (chan->common.state == WAN_CONNECTING)){ @@ -1336,7 +1285,7 @@ for (i=0; i<(MAX_BH_BUFF+1); i++){ skb = ((bh_data_t *)&chan->bh_head[i])->skb; if (skb != NULL){ - wan_dev_kfree_skb(skb, FREE_READ); + dev_kfree_skb_any(skb); } } kfree(chan->bh_head); @@ -1405,7 +1354,6 @@ } -#ifdef LINUX_2_4 /*============================================================================ * Handle transmit timeout event from netif watchdog */ @@ -1425,7 +1373,6 @@ card->devname, dev->name); netif_wake_queue (dev); } -#endif /*========================================================================= @@ -1457,33 +1404,11 @@ ++chan->if_send_stat.if_send_entry; -#ifdef LINUX_2_4 netif_stop_queue(dev); -#endif /* No need to check frame length, since socket code * will perform the check for us */ -#ifndef LINUX_2_4 - if (dev->tbusy){ - netdevice_t *dev2; - - ++chan->if_send_stat.if_send_tbusy; - if ((jiffies - chan->tick_counter) < (5*HZ)){ - return 1; - } - printk(KERN_INFO "%s: Transmit time out %s!\n", - card->devname, dev->name); - - for( dev2 = card->wandev.dev; dev2; - dev2 = *((netdevice_t**)dev2->priv)){ - - dev2->tbusy = 0; - } - ++chan->if_send_stat.if_send_tbusy_timeout; - } -#endif - chan->tick_counter = jiffies; /* Critical region starts here */ @@ -1506,7 +1431,7 @@ chan->if_send_stat.if_send_PIPE_request++; } } - start_net_queue(dev); + netif_start_queue(dev); clear_bit(SEND_CRIT,(void*)&card->wandev.critical); S508_S514_unlock(card, &smp_flags); return 0; @@ -1518,7 +1443,7 @@ chan->transmit_length=0; atomic_set(&chan->common.driver_busy,0); }else{ - stop_net_queue(dev); + netif_stop_queue(dev); ++card->u.x.tx_interrupts_pending; status->imask |= INTR_ON_TX_FRAME; clear_bit(SEND_CRIT,(void*)&card->wandev.critical); @@ -1589,9 +1514,9 @@ if_send_crit_exit: - wan_dev_kfree_skb(skb, FREE_WRITE); + dev_kfree_skb_any(skb); - start_net_queue(dev); + netif_start_queue(dev); clear_bit(SEND_CRIT,(void*)&card->wandev.critical); S508_S514_unlock(card, &smp_flags); return 0; @@ -1787,14 +1712,12 @@ ++chan->ifstats.rx_dropped; ++card->wandev.stats.rx_dropped; ++chan->rx_intr_stat.rx_intr_bfr_not_passed_to_stack; - wan_dev_kfree_skb(skb, FREE_READ); + dev_kfree_skb_any(skb); return; } ++chan->ifstats.rx_packets; -#if defined(LINUX_2_1) || defined(LINUX_2_4) chan->ifstats.rx_bytes += skb->len; -#endif chan->rx_skb = NULL; @@ -1814,7 +1737,7 @@ /* Decapsulate packet, if necessary */ if (!skb->protocol && !wanrouter_type_trans(skb, dev)){ /* can't decapsulate packet */ - wan_dev_kfree_skb(skb, FREE_READ); + dev_kfree_skb_any(skb); ++chan->ifstats.rx_errors; ++chan->ifstats.rx_dropped; ++card->wandev.stats.rx_dropped; @@ -1829,7 +1752,7 @@ if(chan_send(dev, skb->data, skb->len,0)){ chan->tx_skb = skb; }else{ - wan_dev_kfree_skb(skb, FREE_WRITE); + dev_kfree_skb_any(skb); ++chan->rx_intr_stat.rx_intr_bfr_not_passed_to_stack; } }else{ @@ -1839,9 +1762,7 @@ } }else{ skb->mac.raw = skb->data; -#if defined(LINUX_2_1) || defined(LINUX_2_4) chan->ifstats.rx_bytes += skb->len; -#endif ++chan->ifstats.rx_packets; ++chan->rx_intr_stat.rx_intr_bfr_passed_to_stack; netif_rx(skb); @@ -1898,7 +1819,7 @@ if (skb_tailroom(new_skb) < len){ /* No room for the packet. Call off the whole thing! */ - wan_dev_kfree_skb(new_skb, FREE_READ); + dev_kfree_skb_any(new_skb); if (chan->common.usedby == WANPIPE){ chan->rx_skb = NULL; if (qdm & 0x01){ @@ -1985,12 +1906,12 @@ chan->transmit_length = 0; atomic_set(&chan->common.driver_busy,0); chan->tx_offset=0; - if (is_queue_stopped(dev)){ + if (netif_queue_stopped(dev)){ if (chan->common.usedby == API){ - start_net_queue(dev); + netif_start_queue(dev); wakeup_sk_bh(dev); }else{ - wake_net_dev(dev); + netif_wake_queue(dev); } } dev = move_dev_to_next(card,dev); @@ -2092,12 +2013,12 @@ /* If we are in API mode, wakeup the * sock BH handler, not the NET_BH */ - if (is_queue_stopped(dev)){ + if (netif_queue_stopped(dev)){ if (chan->common.usedby == API){ - start_net_queue(dev); + netif_start_queue(dev); wakeup_sk_bh(dev); }else{ - wake_net_dev(dev); + netif_wake_queue(dev); } } return 0; @@ -2342,11 +2263,7 @@ static void trigger_x25_poll(sdla_t *card) { -#ifdef LINUX_2_4 schedule_task(&card->u.x.x25_poll_task); -#else - queue_task(&card->u.x.x25_poll_task, &tq_scheduler); -#endif } /*==================================================================== @@ -3658,8 +3575,8 @@ chan->transmit_length=0; atomic_set(&chan->common.driver_busy,0); chan->tx_offset=0; - if (is_queue_stopped(dev)){ - wake_net_dev(dev); + if (netif_queue_stopped(dev)){ + netif_wake_queue(dev); } } atomic_set(&chan->common.command,0); @@ -3766,9 +3683,7 @@ case 0x00: /* success */ chan->i_timeout_sofar = jiffies; -#ifdef LINUX_2_4 dev->trans_start=jiffies; -#endif if ((qdm & M_BIT) && !card->u.x.LAPB_hdlc){ if (!tx_intr){ @@ -3780,9 +3695,7 @@ chan->tx_offset += len; ++chan->ifstats.tx_packets; -#if defined(LINUX_2_1) || defined(LINUX_2_4) chan->ifstats.tx_bytes += len; -#endif if (chan->tx_offset < orig_len){ setup_for_delayed_transmit (dev, buff, data_len); @@ -3795,9 +3708,7 @@ * be X number of times larger than max data size. */ ++chan->ifstats.tx_packets; -#if defined(LINUX_2_1) || defined(LINUX_2_4) chan->ifstats.tx_bytes += len; -#endif ++chan->if_send_stat.if_send_bfr_passed_to_adptr; chan->tx_offset += len; @@ -3817,9 +3728,7 @@ } }else{ ++chan->ifstats.tx_packets; -#if defined(LINUX_2_1) || defined(LINUX_2_4) chan->ifstats.tx_bytes += len; -#endif ++chan->if_send_stat.if_send_bfr_passed_to_adptr; res=0; } @@ -4288,7 +4197,7 @@ if (chan->common.sk == NULL || chan->common.func == NULL){ printk(KERN_INFO "%s: BH: Socket disconnected, dropping\n", card->devname); - wan_dev_kfree_skb(skb, FREE_READ); + dev_kfree_skb_any(skb); x25api_bh_cleanup(dev); ++chan->ifstats.rx_dropped; ++chan->rx_intr_stat.rx_intr_bfr_not_passed_to_stack; @@ -4745,7 +4654,7 @@ if (card->func(skb,card->sk) < 0){ printk(KERN_INFO "%s: MAJOR ERROR: Failed to send up place call \n",card->devname); - wan_dev_kfree_skb(skb, FREE_READ); + dev_kfree_skb_any(skb); return 1; } @@ -4912,7 +4821,7 @@ if (chan->common.func(skb,dev,chan->common.sk) < 0){ if (bh_enqueue(dev,skb)){ printk(KERN_INFO "%s: Dropping OOB MSG\n",card->devname); - wan_dev_kfree_skb(skb, FREE_READ); + dev_kfree_skb_any(skb); } } @@ -4940,7 +4849,7 @@ if (skb_tailroom(new_skb) < len){ /* No room for the packet. Call off the whole thing! */ - wan_dev_kfree_skb(new_skb, FREE_READ); + dev_kfree_skb_any(new_skb); printk(KERN_INFO "%s: Listen: unexpectedly long packet sequence\n" ,card->devname); *skb = NULL; @@ -5448,9 +5357,9 @@ } if(udp_pkt_src == UDP_PKT_FRM_STACK){ - wan_dev_kfree_skb(skb, FREE_WRITE); + dev_kfree_skb_any(skb); }else{ - wan_dev_kfree_skb(skb, FREE_READ); + dev_kfree_skb_any(skb); } return(udp_pkt_stored); diff -Nru a/drivers/net/wan/sdladrv.c b/drivers/net/wan/sdladrv.c --- a/drivers/net/wan/sdladrv.c Wed May 22 11:16:37 2002 +++ b/drivers/net/wan/sdladrv.c Sun Feb 16 16:22:42 2003 @@ -108,16 +108,8 @@ #define _OUTB(port, byte) (outb((byte),(port))) #define SYSTEM_TICK jiffies +#include -#if defined(LINUX_2_1) || defined(LINUX_2_4) - #include -#else - #include /* BIOS32, PCI BIOS functions and definitions */ - #define ioremap vremap - #define iounmap vfree - extern void * vremap (unsigned long offset, unsigned long size); - extern void vfree (void *addr); -#endif #elif defined(_SCO_UNIX_) /****** SCO Unix ****************************/ @@ -381,9 +373,7 @@ * < 0 error */ -#if defined(LINUX_2_1) || defined(LINUX_2_4) EXPORT_SYMBOL(sdla_setup); -#endif int sdla_setup (sdlahw_t* hw, void* sfm, unsigned len) { @@ -528,9 +518,7 @@ * Shut down SDLA: disable shared memory access and interrupts, stop CPU, etc. */ -#if defined(LINUX_2_1) || defined(LINUX_2_4) EXPORT_SYMBOL(sdla_down); -#endif int sdla_down (sdlahw_t* hw) { @@ -572,7 +560,6 @@ *(char *)hw->vector = S514_CPU_HALT; CPU_no = hw->S514_cpu_no[0]; -#if defined(LINUX_2_1) || defined(LINUX_2_4) /* disable the PCI IRQ and disable memory access */ pci_read_config_dword(hw->pci_dev, PCI_INT_CONFIG, &int_config); int_config &= (CPU_no == S514_CPU_A) ? ~PCI_DISABLE_IRQ_CPU_A : ~PCI_DISABLE_IRQ_CPU_B; @@ -585,22 +572,6 @@ else pci_write_config_dword(hw->pci_dev, PCI_MAP1_DWORD, PCI_CPU_B_MEM_DISABLE); -#else - /* disable the PCI IRQ and disable memory access */ - pcibios_read_config_dword(hw->pci_bus, hw->pci_dev_func, - PCI_INT_CONFIG, &int_config); - int_config &= (CPU_no == S514_CPU_A) ? ~PCI_DISABLE_IRQ_CPU_A : ~PCI_DISABLE_IRQ_CPU_B; - pcibios_write_config_dword(hw->pci_bus, hw->pci_dev_func, - PCI_INT_CONFIG, int_config); - read_S514_int_stat(hw, &int_status); - S514_intack(hw, int_status); - // disable PCI memory access - if(CPU_no == S514_CPU_A) - pcibios_write_config_dword(hw->pci_bus,hw->pci_dev_func, - PCI_MAP0_DWORD, PCI_CPU_A_MEM_DISABLE); - else - pcibios_write_config_dword(hw->pci_bus,hw->pci_dev_func, PCI_MAP1_DWORD, PCI_CPU_B_MEM_DISABLE); -#endif /* free up the allocated virtual memory */ iounmap((void *)hw->dpmbase); @@ -618,9 +589,7 @@ * Map shared memory window into SDLA address space. */ -#if defined(LINUX_2_1) || defined(LINUX_2_4) EXPORT_SYMBOL(sdla_mapmem); -#endif int sdla_mapmem (sdlahw_t* hw, unsigned long addr) { @@ -681,9 +650,7 @@ * Enable interrupt generation. */ -#if defined(LINUX_2_1) || defined(LINUX_2_4) EXPORT_SYMBOL(sdla_inten); -#endif int sdla_inten (sdlahw_t* hw) { @@ -739,9 +706,7 @@ * Disable interrupt generation. */ -#if defined(LINUX_2_1) || defined(LINUX_2_4) EXPORT_SYMBOL(sdla_intde); -#endif int sdla_intde (sdlahw_t* hw) { @@ -796,9 +761,7 @@ * Acknowledge SDLA hardware interrupt. */ -#if defined(LINUX_2_1) || defined(LINUX_2_4) EXPORT_SYMBOL(sdla_intack); -#endif int sdla_intack (sdlahw_t* hw) { @@ -848,18 +811,11 @@ * Acknowledge S514 hardware interrupt. */ -#if defined(LINUX_2_1) || defined(LINUX_2_4) EXPORT_SYMBOL(S514_intack); -#endif void S514_intack (sdlahw_t* hw, u32 int_status) { -#if defined(LINUX_2_1) || defined(LINUX_2_4) pci_write_config_dword(hw->pci_dev, PCI_INT_STATUS, int_status); -#else - pcibios_write_config_dword(hw->pci_bus, hw->pci_dev_func, - PCI_INT_STATUS, int_status); -#endif } @@ -867,18 +823,11 @@ * Read the S514 hardware interrupt status. */ -#if defined(LINUX_2_1) || defined(LINUX_2_4) EXPORT_SYMBOL(read_S514_int_stat); -#endif void read_S514_int_stat (sdlahw_t* hw, u32* int_status) { -#if defined(LINUX_2_1) || defined(LINUX_2_4) pci_read_config_dword(hw->pci_dev, PCI_INT_STATUS, int_status); -#else - pcibios_read_config_dword(hw->pci_bus, hw->pci_dev_func, PCI_INT_STATUS, - int_status); -#endif } @@ -886,9 +835,7 @@ * Generate an interrupt to adapter's CPU. */ -#if defined(LINUX_2_1) || defined(LINUX_2_4) EXPORT_SYMBOL(sdla_intr); -#endif int sdla_intr (sdlahw_t* hw) { @@ -932,9 +879,7 @@ * o Return number of loops made, or 0 if command timed out. */ -#if defined(LINUX_2_1) || defined(LINUX_2_4) EXPORT_SYMBOL(sdla_exec); -#endif int sdla_exec (void* opflag) { @@ -970,9 +915,7 @@ * interrupt routines are accessing adapter shared memory. */ -#if defined(LINUX_2_1) || defined(LINUX_2_4) EXPORT_SYMBOL(sdla_peek); -#endif int sdla_peek (sdlahw_t* hw, unsigned long addr, void* buf, unsigned len) { @@ -1054,9 +997,7 @@ * interrupt routines are accessing adapter shared memory. */ -#if defined(LINUX_2_1) || defined(LINUX_2_4) EXPORT_SYMBOL(sdla_poke); -#endif int sdla_poke (sdlahw_t* hw, unsigned long addr, void* buf, unsigned len) { @@ -1961,20 +1902,11 @@ int number_S514_cards = 0; u32 S514_mem_base_addr = 0; u32 ut_u32; - -#if defined(LINUX_2_1) || defined(LINUX_2_4) struct pci_dev *pci_dev; -#else - u8 ut_u8; -#endif #ifdef CONFIG_PCI -#if defined(LINUX_2_1) || defined(LINUX_2_4) if(!pci_present()) -#else - if(!pcibios_present()) -#endif { printk(KERN_INFO "%s: PCI BIOS not present!\n", modname); return 0; @@ -2029,26 +1961,12 @@ } } - #if defined(LINUX_2_4) pci_dev = hw->pci_dev; /* read the physical memory base address */ S514_mem_base_addr = (CPU_no == S514_CPU_A) ? (pci_dev->resource[1].start) : (pci_dev->resource[2].start); - #elif defined (LINUX_2_1) - pci_dev = hw->pci_dev; - /* read the physical memory base address */ - S514_mem_base_addr = (CPU_no == S514_CPU_A) ? - (pci_dev->base_address[1] & PCI_BASE_ADDRESS_MEM_MASK) : - (pci_dev->base_address[2] & PCI_BASE_ADDRESS_MEM_MASK); - - #else - pcibios_read_config_dword(hw->pci_bus, hw->pci_dev_func, - (CPU_no == S514_CPU_A) ? PCI_MEM_BASE0_DWORD : - PCI_MEM_BASE1_DWORD, &S514_mem_base_addr); - #endif - printk(KERN_INFO "%s: S514 PCI memory at 0x%X\n", modname, S514_mem_base_addr); if(!S514_mem_base_addr) { @@ -2060,24 +1978,14 @@ } /* enable the PCI memory */ -#if defined(LINUX_2_1) || defined(LINUX_2_4) pci_read_config_dword(pci_dev, (CPU_no == S514_CPU_A) ? PCI_MAP0_DWORD : PCI_MAP1_DWORD, &ut_u32); pci_write_config_dword(pci_dev, (CPU_no == S514_CPU_A) ? PCI_MAP0_DWORD : PCI_MAP1_DWORD, (ut_u32 | PCI_MEMORY_ENABLE)); -#else - pcibios_read_config_dword(hw->pci_bus, hw->pci_dev_func, - (CPU_no == S514_CPU_A) ? PCI_MAP0_DWORD : PCI_MAP1_DWORD, - &ut_u32); - pcibios_write_config_dword(hw->pci_bus, hw->pci_dev_func, - (CPU_no == S514_CPU_A) ? PCI_MAP0_DWORD : PCI_MAP1_DWORD, - (ut_u32 | PCI_MEMORY_ENABLE)); -#endif /* check the IRQ allocated and enable IRQ usage */ -#if defined(LINUX_2_1) || defined(LINUX_2_4) if(!(hw->irq = pci_dev->irq)) { printk(KERN_INFO "%s: IRQ not allocated to S514 adapter\n", modname); @@ -2099,29 +2007,6 @@ ut_u32 |= (CPU_no == S514_CPU_A) ? PCI_ENABLE_IRQ_CPU_A : PCI_ENABLE_IRQ_CPU_B; pci_write_config_dword(pci_dev, PCI_INT_CONFIG, ut_u32); -#else - /* the INTPIN must not be 0 - if it is, then the S514 adapter is not */ - /* configured for IRQ usage */ - pcibios_read_config_byte(hw->pci_bus, hw->pci_dev_func, - PCI_INT_PIN_BYTE, &ut_u8); - if(!ut_u8) { - printk(KERN_INFO "%s: invalid setting for INTPIN on S514 card\n", modname); - printk(KERN_INFO "Please contact your Sangoma representative\n"); - return 0; - } - pcibios_read_config_byte(hw->pci_bus, hw->pci_dev_func, - PCI_INT_LINE_BYTE, (unsigned char *)&hw->irq); - if(hw->irq == PCI_IRQ_NOT_ALLOCATED) { - printk(KERN_INFO "%s: IRQ not allocated to S514 adapter\n", - modname); - return 0; - } - pcibios_read_config_dword(hw->pci_bus, hw->pci_dev_func, PCI_INT_CONFIG, &ut_u32); - ut_u32 |= (CPU_no == S514_CPU_A) ? - PCI_ENABLE_IRQ_CPU_A : PCI_ENABLE_IRQ_CPU_B; - pcibios_write_config_dword(hw->pci_bus, hw->pci_dev_func, - PCI_INT_CONFIG, ut_u32); -#endif printk(KERN_INFO "%s: IRQ %d allocated to the S514 card\n", modname, hw->irq); @@ -2157,15 +2042,10 @@ char S514_found_in_slot = 0; u16 PCI_subsys_vendor; -#if defined(LINUX_2_1) || defined(LINUX_2_4) struct pci_dev *pci_dev = NULL; -#else - int pci_index; -#endif slot_no = hw->S514_slot_no; -#if defined(LINUX_2_1) || defined(LINUX_2_4) while ((pci_dev = pci_find_device(V3_VENDOR_ID, V3_DEVICE_ID, pci_dev)) != NULL) { @@ -2197,40 +2077,6 @@ } } -#else - //LINUX VERSION 2.0.X - for (pci_index = 0; pci_index < MAX_S514_CARDS; pci_index ++) { - if (pcibios_find_device(V3_VENDOR_ID, V3_DEVICE_ID, pci_index, - &hw->pci_bus, &hw->pci_dev_func)!=PCIBIOS_SUCCESSFUL) { - break; - } - - pcibios_read_config_word(hw->pci_bus, hw->pci_dev_func, - PCI_SUBSYS_VENDOR_WORD, &PCI_subsys_vendor); - - if (PCI_subsys_vendor != SANGOMA_SUBSYS_VENDOR) - continue; - - if (find_first_S514_card) - return(1); - - number_S514_cards ++; - - printk(KERN_INFO "%s: S514 card found, bus #%d, slot #%d\n", - modname, hw->pci_bus, - ((hw->pci_dev_func >> 3) & PCI_DEV_SLOT_MASK)); - - if (hw->auto_pci_cfg){ - hw->S514_slot_no = ((hw->pci_dev_func >> 3) & PCI_DEV_SLOT_MASK) - slot_no = hw->S514_slot_no; - - }else if (((hw->pci_dev_func >> 3) & PCI_DEV_SLOT_MASK) == slot_no) { - S514_found_in_slot = 1; - break; - } - } -#endif - /* if no S514 adapter has been found, then exit */ if (!number_S514_cards) { printk(KERN_INFO "%s: Error, no S514 adapters found\n", modname); @@ -2408,17 +2254,11 @@ u16 PCI_subsys_vendor; u16 PCI_card_type; -#if defined(LINUX_2_1) || defined(LINUX_2_4) struct pci_dev *pci_dev = NULL; struct pci_bus *bus = NULL; -#else - int pci_index; - u8 irq; -#endif slot_no = 0; -#if defined(LINUX_2_1) || defined(LINUX_2_4) while ((pci_dev = pci_find_device(V3_VENDOR_ID, V3_DEVICE_ID, pci_dev)) != NULL) { @@ -2453,52 +2293,13 @@ } } -#else - for (pci_index = 0; pci_index < MAX_S514_CARDS; pci_index ++) { - - if(pcibios_find_device(V3_VENDOR_ID, V3_DEVICE_ID, pci_index, - &hw->pci_bus, &hw->pci_dev_func)!=PCIBIOS_SUCCESSFUL) { - break; - } - pcibios_read_config_word(hw->pci_bus, hw->pci_dev_func, - PCI_SUBSYS_VENDOR_WORD, &PCI_subsys_vendor); - if(PCI_subsys_vendor != SANGOMA_SUBSYS_VENDOR) - continue; - - pcibios_read_config_word(hw->pci_bus,hw->pci_dev_func,PCI_CARD_TYPE, - &PCI_card_type); - - pcibios_read_config_byte(hw->pci_bus, hw->pci_dev_func, - PCI_INT_LINE_BYTE, &irq); - - /* A dual cpu card can support up to 4 physical connections, - * where a single cpu card can support up to 2 physical - * connections. The FT1 card can only support a single - * connection, however we cannot distinguish between a Single - * CPU card and an FT1 card. */ - if (PCI_card_type == S514_DUAL_CPU){ - number_S514_cards += 4; - printk(KERN_INFO "%s: S514-PCI card found, cpu(s) 2, bus #%d, slot #%d, irq #%d\n", - modname, hw->pci_bus, - ((hw->pci_dev_func >> 3) & PCI_DEV_SLOT_MASK),irq); - }else{ - printk(KERN_INFO "%s: S514-PCI card found, cpu(s) 1, bus #%d, slot #%d, irq #%d\n", - modname, hw->pci_bus, - ((hw->pci_dev_func >> 3) & PCI_DEV_SLOT_MASK),irq); - number_S514_cards += 2; - } - } -#endif - return number_S514_cards; } -#if defined(LINUX_2_1) || defined(LINUX_2_4) EXPORT_SYMBOL(wanpipe_hw_probe); -#endif unsigned wanpipe_hw_probe(void) { diff -Nru a/drivers/net/wan/sdlamain.c b/drivers/net/wan/sdlamain.c --- a/drivers/net/wan/sdlamain.c Tue Feb 25 11:05:23 2003 +++ b/drivers/net/wan/sdlamain.c Thu Mar 6 09:25:30 2003 @@ -64,26 +64,10 @@ #include #include -#if defined(LINUX_2_4) +#define netdevice_t struct net_device - #include /* kernel <-> user copy */ - #include - #define netdevice_t struct net_device - -#elif defined(LINUX_2_1) - - #include /* kernel <-> user copy */ - #include - #define netdevice_t struct device - -#else - - #include - #define devinet_ioctl(x,y) dev_ioctl(x,y) - #define netdevice_t struct device - #define test_and_set_bit set_bit - typedef unsigned long mm_segment_t; -#endif +#include /* kernel <-> user copy */ +#include #include #include @@ -240,23 +224,12 @@ * function, which will execute all pending, * tasks in wanpipe_tq_custom queue */ -#ifdef LINUX_2_4 DECLARE_TASK_QUEUE(wanpipe_tq_custom); static struct tq_struct wanpipe_tq_task = { .routine = (void (*)(void *)) run_wanpipe_tq, .data = &wanpipe_tq_custom }; -#else -static struct tq_struct *wanpipe_tq_custom = NULL; -static struct tq_struct wanpipe_tq_task = -{ - NULL, - 0, - (void *)(void *) run_wanpipe_tq, - &wanpipe_tq_custom -}; -#endif static int wanpipe_bh_critical=0; @@ -511,9 +484,7 @@ if (!card->configured){ /* Initialize the Spin lock */ -#if defined(__SMP__) || defined(LINUX_2_4) printk(KERN_INFO "%s: Initializing for SMP\n",wandev->name); -#endif /* Piggyback spin lock has already been initialized, * in check_s514/s508_conflicts() */ @@ -974,26 +945,13 @@ unsigned long smp_flags; int err = 0; - #if defined(LINUX_2_1) || defined(LINUX_2_4) if(copy_from_user((void*)&dump, (void*)u_dump, sizeof(sdla_dump_t))) return -EFAULT; - #else - if ((u_dump == NULL) || - verify_area(VERIFY_READ, u_dump, sizeof(sdla_dump_t))) - return -EFAULT; - memcpy_fromfs((void*)&dump, (void*)u_dump, sizeof(sdla_dump_t)); - #endif if ((dump.magic != WANPIPE_MAGIC) || (dump.offset + dump.length > card->hw.memory)) return -EINVAL; - #ifdef LINUX_2_0 - if ((dump.ptr == NULL) || - verify_area(VERIFY_WRITE, dump.ptr, dump.length)) - return -EFAULT; - #endif - winsize = card->hw.dpmsize; if(card->hw.type != SDLA_S514) { @@ -1014,17 +972,13 @@ break; } - #if defined(LINUX_2_1) || defined(LINUX_2_4) if(copy_to_user((void *)dump.ptr, (u8 *)card->hw.dpmbase + pos, len)){ unlock_adapter_irq(&card->wandev.lock, &smp_flags); return -EFAULT; } - #else - memcpy_tofs((void*)(dump.ptr), - (void*)(card->hw.dpmbase + pos), len); - #endif + dump.length -= len; dump.offset += len; (char*)dump.ptr += len; @@ -1035,15 +989,10 @@ }else { - #if defined(LINUX_2_1) || defined(LINUX_2_4) if(copy_to_user((void *)dump.ptr, (u8 *)card->hw.dpmbase + dump.offset, dump.length)){ return -EFAULT; } - #else - memcpy_tofs((void*)(dump.ptr), - (void*)(card->hw.dpmbase + dump.offset), dump.length); - #endif } return err; @@ -1064,15 +1013,8 @@ return -ENODEV; } - #if defined(LINUX_2_1) || defined(LINUX_2_4) if(copy_from_user((void*)&exec, (void*)u_exec, sizeof(sdla_exec_t))) return -EFAULT; - #else - if ((u_exec == NULL) || - verify_area(VERIFY_READ, u_exec, sizeof(sdla_exec_t))) - return -EFAULT; - memcpy_fromfs((void*)&exec, (void*)u_exec, sizeof(sdla_exec_t)); - #endif if ((exec.magic != WANPIPE_MAGIC) || (exec.cmd == NULL)) return -EINVAL; @@ -1345,60 +1287,33 @@ unsigned long get_ip_address (netdevice_t *dev, int option) { - #ifdef LINUX_2_4 struct in_ifaddr *ifaddr; struct in_device *in_dev; if ((in_dev = __in_dev_get(dev)) == NULL){ return 0; } - #elif defined(LINUX_2_1) - struct in_ifaddr *ifaddr; - struct in_device *in_dev; - - if ((in_dev = dev->ip_ptr) == NULL){ - return 0; - } - #endif - #if defined(LINUX_2_1) || defined(LINUX_2_4) if ((ifaddr = in_dev->ifa_list)== NULL ){ return 0; } - #endif switch (option){ case WAN_LOCAL_IP: - #ifdef LINUX_2_0 - return dev->pa_addr; - #else return ifaddr->ifa_local; - #endif break; case WAN_POINTOPOINT_IP: - #ifdef LINUX_2_0 - return dev->pa_dstaddr; - #else return ifaddr->ifa_address; - #endif break; case WAN_NETMASK_IP: - #ifdef LINUX_2_0 - return dev->pa_mask; - #else return ifaddr->ifa_mask; - #endif break; case WAN_BROADCAST_IP: - #ifdef LINUX_2_0 - return dev->pa_brdaddr; - #else return ifaddr->ifa_broadcast; - #endif break; default: return 0; @@ -1431,11 +1346,7 @@ oldfs = get_fs(); set_fs(get_ds()); - #if defined(LINUX_2_1) || defined(LINUX_2_4) res = ip_rt_ioctl(SIOCADDRT,&route); - #else - res = ip_rt_new(&route); - #endif set_fs(oldfs); if (res == 0){ diff -Nru a/drivers/net/wan/wanpipe_multppp.c b/drivers/net/wan/wanpipe_multppp.c --- a/drivers/net/wan/wanpipe_multppp.c Mon Feb 24 09:56:18 2003 +++ b/drivers/net/wan/wanpipe_multppp.c Thu Mar 6 09:25:30 2003 @@ -42,19 +42,11 @@ #include -#if defined(LINUX_2_1) || defined(LINUX_2_4) - #include - #include +#include +#include -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,3) - #include -#else - #include "syncppp.h" -#endif +#include -#else - #include /* Adding new route entries */ -#endif /****** Defines & Macros ****************************************************/ @@ -148,15 +140,9 @@ static int if_open (netdevice_t* dev); static int if_close (netdevice_t* dev); static int if_send (struct sk_buff* skb, netdevice_t* dev); -#if defined(LINUX_2_1) || defined(LINUX_2_4) static struct net_device_stats* if_stats (netdevice_t* dev); -#else -static struct enet_statistics* if_stats (netdevice_t* dev); -#endif -#ifdef LINUX_2_4 static void if_tx_timeout (netdevice_t *dev); -#endif /* CHDLC Firmware interface functions */ static int chdlc_configure (sdla_t* card, void* data); @@ -601,18 +587,8 @@ /* prepare network device data space for registration */ -#ifdef LINUX_2_4 strcpy(dev->name,card->u.c.if_name); -#else - dev->name = (char *)kmalloc(strlen(card->u.c.if_name) + 2, GFP_KERNEL); - if(dev->name == NULL) - { - kfree(chdlc_priv_area); - return -ENOMEM; - } - sprintf(dev->name, "%s", card->u.c.if_name); -#endif - + /* Attach PPP protocol layer to pppdev * The sppp_attach() will initilize the dev structure * and setup ppp layer protocols. @@ -620,11 +596,7 @@ * if_open(), if_close(), if_send() and get_stats() functions. */ sppp_attach(pppdev); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,16) dev = pppdev->dev; -#else - dev = &pppdev->dev; -#endif sp = &pppdev->sppp; /* Enable PPP Debugging */ @@ -684,9 +656,6 @@ chdlc_private_area_t* chdlc_priv_area = dev->priv; sdla_t* card = chdlc_priv_area->card; wan_device_t* wandev = &card->wandev; -#ifdef LINUX_2_0 - int i; -#endif /* NOTE: Most of the dev initialization was * done in sppp_attach(), called by new_if() @@ -699,16 +668,10 @@ dev->stop = &if_close; dev->hard_start_xmit = &if_send; dev->get_stats = &if_stats; -#ifdef LINUX_2_4 dev->tx_timeout = &if_tx_timeout; dev->watchdog_timeo = TX_TIMEOUT; -#endif -#ifdef LINUX_2_0 - dev->family = AF_INET; -#endif - /* Initialize hardware parameters */ dev->irq = wandev->irq; dev->dma = wandev->dma; @@ -724,17 +687,10 @@ */ dev->tx_queue_len = 100; - /* Initialize socket buffers */ -#if !defined(LINUX_2_1) && !defined(LINUX_2_4) - for (i = 0; i < DEV_NUMBUFFS; ++i) - skb_queue_head_init(&dev->buffs[i]); -#endif - return 0; } -#ifdef LINUX_2_4 /*============================================================================ * Handle transmit timeout event from netif watchdog */ @@ -754,8 +710,6 @@ printk (KERN_INFO "%s: Transmit timed out on %s\n", card->devname,dev->name); netif_wake_queue (dev); } -#endif - /*============================================================================ @@ -773,14 +727,8 @@ SHARED_MEMORY_INFO_STRUCT *flags = card->u.c.flags; /* Only one open per interface is allowed */ - -#ifdef LINUX_2_4 if (netif_running(dev)) return -EBUSY; -#else - if (dev->start) - return -EBUSY; /* only one open is allowed */ -#endif /* Start PPP Layer */ if (sppp_open(dev)){ @@ -790,13 +738,7 @@ do_gettimeofday(&tv); chdlc_priv_area->router_start_time = tv.tv_sec; -#ifdef LINUX_2_4 netif_start_queue(dev); -#else - dev->interrupt = 0; - dev->tbusy = 0; - dev->start = 1; -#endif wanpipe_open(card); @@ -817,11 +759,7 @@ /* Stop the PPP Layer */ sppp_close(dev); - stop_net_queue(dev); - -#ifndef LINUX_2_4 - dev->start=0; -#endif + netif_stop_queue(dev); wanpipe_close(card); @@ -855,9 +793,7 @@ unsigned long smp_flags; int err=0; -#ifdef LINUX_2_4 netif_stop_queue(dev); -#endif if (skb == NULL){ @@ -867,32 +803,10 @@ printk(KERN_INFO "%s: Received NULL skb buffer! interface %s got kicked!\n", card->devname, dev->name); - wake_net_dev(dev); + netif_wake_queue(dev); return 0; } -#ifndef LINUX_2_4 - if (dev->tbusy){ - - /* If our device stays busy for at least 5 seconds then we will - * kick start the device by making dev->tbusy = 0. We expect - * that our device never stays busy more than 5 seconds. So this - * is only used as a last resort. - */ - ++card->wandev.stats.collisions; - - if((jiffies - chdlc_priv_area->tick_counter) < (5 * HZ)) { - return 1; - } - - printk (KERN_INFO "%s: Transmit (tbusy) timeout !\n", - card->devname); - - /* unbusy the interface */ - dev->tbusy = 0; - } -#endif - if (ntohs(skb->protocol) != htons(PVC_PROT)){ /* check the udp packet type */ @@ -903,7 +817,7 @@ chdlc_int->interrupt_permission |= APP_INT_ON_TIMER; } - start_net_queue(dev); + netif_start_queue(dev); return 0; } } @@ -918,33 +832,29 @@ printk(KERN_INFO "%s: Critical in if_send: %lx\n", card->wandev.name,card->wandev.critical); ++card->wandev.stats.tx_dropped; - start_net_queue(dev); + netif_start_queue(dev); goto if_send_crit_exit; } if (card->wandev.state != WAN_CONNECTED){ ++card->wandev.stats.tx_dropped; - start_net_queue(dev); + netif_start_queue(dev); goto if_send_crit_exit; } if (chdlc_send(card, skb->data, skb->len)){ - stop_net_queue(dev); + netif_stop_queue(dev); }else{ ++card->wandev.stats.tx_packets; -#if defined(LINUX_2_1) || defined(LINUX_2_4) card->wandev.stats.tx_bytes += skb->len; -#endif -#ifdef LINUX_2_4 dev->trans_start = jiffies; -#endif - start_net_queue(dev); + netif_start_queue(dev); } if_send_crit_exit: - if (!(err=is_queue_stopped(dev))){ - wan_dev_kfree_skb(skb, FREE_WRITE); + if (!(err=netif_queue_stopped(dev))){ + dev_kfree_skb_any(skb); }else{ chdlc_priv_area->tick_counter = jiffies; chdlc_int->interrupt_permission |= APP_INT_ON_TX_FRAME; @@ -1063,7 +973,6 @@ * Get ethernet-style interface statistics. * Return a pointer to struct enet_statistics. */ -#if defined(LINUX_2_1) || defined(LINUX_2_4) static struct net_device_stats* if_stats (netdevice_t* dev) { sdla_t *my_card; @@ -1079,23 +988,7 @@ my_card = chdlc_priv_area->card; return &my_card->wandev.stats; } -#else -static struct enet_statistics* if_stats (netdevice_t* dev) -{ - sdla_t *my_card; - chdlc_private_area_t* chdlc_priv_area = dev->priv; - /* Shutdown bug fix. In del_if() we kill - * dev->priv pointer. This function, gets - * called after del_if(), thus check - * if pointer has been deleted */ - if ((chdlc_priv_area=dev->priv) == NULL) - return NULL; - - my_card = chdlc_priv_area->card; - return &my_card->wandev.stats; -} -#endif /****** Cisco HDLC Firmware Interface Functions *******************************/ @@ -1417,7 +1310,7 @@ flags->interrupt_info_struct.interrupt_permission &= ~APP_INT_ON_TX_FRAME; - wake_net_dev(dev); + netif_wake_queue(dev); break; case COMMAND_COMPLETE_APP_INT_PEND:/* 0x04: cmd cplt */ @@ -1505,15 +1398,9 @@ goto rx_exit; } -#ifdef LINUX_2_4 if (!netif_running(dev)){ goto rx_exit; } -#else - if (!dev->start){ - goto rx_exit; - } -#endif chdlc_priv_area = dev->priv; @@ -1555,9 +1442,7 @@ skb->protocol = htons(ETH_P_WAN_PPP); card->wandev.stats.rx_packets ++; -#if defined(LINUX_2_1) || defined(LINUX_2_4) card->wandev.stats.rx_bytes += skb->len; -#endif udp_type = udp_pkt_type( skb, card ); if(udp_type == UDP_CPIPE_TYPE) { @@ -1795,9 +1680,9 @@ } if(udp_pkt_src == UDP_PKT_FRM_STACK) - wan_dev_kfree_skb(skb, FREE_WRITE); + dev_kfree_skb_any(skb); else - wan_dev_kfree_skb(skb, FREE_READ); + dev_kfree_skb_any(skb); return(udp_pkt_stored); } @@ -2156,9 +2041,7 @@ if(chdlc_priv_area->udp_pkt_src == UDP_PKT_FRM_NETWORK) { if(!chdlc_send(card, chdlc_priv_area->udp_pkt_data, len)) { ++ card->wandev.stats.tx_packets; -#if defined(LINUX_2_1) || defined(LINUX_2_4) card->wandev.stats.tx_bytes += len; -#endif } } else { @@ -2360,28 +2243,20 @@ void s508_lock (sdla_t *card, unsigned long *smp_flags) { -#if defined(__SMP__) || defined(LINUX_2_4) spin_lock_irqsave(&card->wandev.lock, *smp_flags); if (card->next){ /* It is ok to use spin_lock here, since we * already turned off interrupts */ spin_lock(&card->next->wandev.lock); } -#else - disable_irq(card->hw.irq); -#endif } void s508_unlock (sdla_t *card, unsigned long *smp_flags) { -#if defined(__SMP__) || defined(LINUX_2_4) if (card->next){ spin_unlock(&card->next->wandev.lock); } spin_unlock_irqrestore(&card->wandev.lock, *smp_flags); -#else - enable_irq(card->hw.irq); -#endif } diff -Nru a/drivers/oprofile/buffer_sync.c b/drivers/oprofile/buffer_sync.c --- a/drivers/oprofile/buffer_sync.c Thu Feb 20 10:06:22 2003 +++ b/drivers/oprofile/buffer_sync.c Sun Mar 2 22:46:44 2003 @@ -277,10 +277,7 @@ */ static struct mm_struct * take_task_mm(struct task_struct * task) { - struct mm_struct * mm; - task_lock(task); - mm = task->mm; - task_unlock(task); + struct mm_struct * mm = task->mm; /* if task->mm !NULL, mm_count must be at least 1. It cannot * drop to 0 without the task exiting, which will have to sleep @@ -310,6 +307,32 @@ } +/* compute number of filled slots in cpu_buffer queue */ +static unsigned long nr_filled_slots(struct oprofile_cpu_buffer * b) +{ + unsigned long head = b->head_pos; + unsigned long tail = b->tail_pos; + + if (head >= tail) + return head - tail; + + return head + (b->buffer_size - tail); +} + + +static void increment_tail(struct oprofile_cpu_buffer * b) +{ + unsigned long new_tail = b->tail_pos + 1; + + rmb(); + + if (new_tail < (b->buffer_size)) + b->tail_pos = new_tail; + else + b->tail_pos = 0; +} + + /* Sync one of the CPU's buffers into the global event buffer. * Here we need to go through each batch of samples punctuated * by context switch notes, taking the task's mmap_sem and doing @@ -322,10 +345,14 @@ struct task_struct * new; unsigned long cookie; int in_kernel = 1; - int i; + unsigned int i; - for (i=0; i < cpu_buf->pos; ++i) { - struct op_sample * s = &cpu_buf->buffer[i]; + /* Remember, only we can modify tail_pos */ + + unsigned long const available_elements = nr_filled_slots(cpu_buf); + + for (i=0; i < available_elements; ++i) { + struct op_sample * s = &cpu_buf->buffer[cpu_buf->tail_pos]; if (is_ctx_switch(s->eip)) { if (s->event <= 1) { @@ -345,6 +372,8 @@ } else { add_sample(mm, s, in_kernel); } + + increment_tail(cpu_buf); } release_mm(mm); @@ -369,17 +398,8 @@ cpu_buf = &cpu_buffer[i]; - /* We take a spin lock even though we might - * sleep. It's OK because other users are try - * lockers only, and this region is already - * protected by buffer_sem. It's raw to prevent - * the preempt bogometer firing. Fruity, huh ? */ - if (cpu_buf->pos > 0) { - _raw_spin_lock(&cpu_buf->int_lock); - add_cpu_switch(i); - sync_buffer(cpu_buf); - _raw_spin_unlock(&cpu_buf->int_lock); - } + add_cpu_switch(i); + sync_buffer(cpu_buf); } up(&buffer_sem); diff -Nru a/drivers/oprofile/cpu_buffer.c b/drivers/oprofile/cpu_buffer.c --- a/drivers/oprofile/cpu_buffer.c Thu Jan 23 12:24:53 2003 +++ b/drivers/oprofile/cpu_buffer.c Wed Feb 26 18:28:36 2003 @@ -26,8 +26,6 @@ struct oprofile_cpu_buffer cpu_buffer[NR_CPUS] __cacheline_aligned; -static unsigned long buffer_size; - static void __free_cpu_buffers(int num) { int i; @@ -47,7 +45,7 @@ { int i; - buffer_size = fs_cpu_buffer_size; + unsigned long buffer_size = fs_cpu_buffer_size; for (i=0; i < NR_CPUS; ++i) { struct oprofile_cpu_buffer * b = &cpu_buffer[i]; @@ -59,12 +57,12 @@ if (!b->buffer) goto fail; - spin_lock_init(&b->int_lock); - b->pos = 0; b->last_task = 0; b->last_is_kernel = -1; + b->buffer_size = buffer_size; + b->tail_pos = 0; + b->head_pos = 0; b->sample_received = 0; - b->sample_lost_locked = 0; b->sample_lost_overflow = 0; b->sample_lost_task_exit = 0; } @@ -80,11 +78,41 @@ __free_cpu_buffers(NR_CPUS); } - -/* Note we can't use a semaphore here as this is supposed to - * be safe from any context. Instead we trylock the CPU's int_lock. - * int_lock is taken by the processing code in sync_cpu_buffers() - * so we avoid disturbing that. + +/* compute number of available slots in cpu_buffer queue */ +static unsigned long nr_available_slots(struct oprofile_cpu_buffer const * b) +{ + unsigned long head = b->head_pos; + unsigned long tail = b->tail_pos; + + if (tail == head) + return b->buffer_size; + + if (tail > head) + return tail - head; + + return tail + (b->buffer_size - head); +} + + +static void increment_head(struct oprofile_cpu_buffer * b) +{ + unsigned long new_head = b->head_pos + 1; + + /* Ensure anything written to the slot before we + * increment is visible */ + wmb(); + + if (new_head < (b->buffer_size)) + b->head_pos = new_head; + else + b->head_pos = 0; +} + + +/* This must be safe from any context. It's safe writing here + * because of the head/tail separation of the writer and reader + * of the CPU buffer. * * is_kernel is needed because on some architectures you cannot * tell if you are in kernel or user space simply by looking at @@ -101,14 +129,10 @@ cpu_buf->sample_received++; - if (!spin_trylock(&cpu_buf->int_lock)) { - cpu_buf->sample_lost_locked++; - return; - } - if (cpu_buf->pos > buffer_size - 2) { + if (nr_available_slots(cpu_buf) < 3) { cpu_buf->sample_lost_overflow++; - goto out; + return; } task = current; @@ -116,18 +140,18 @@ /* notice a switch from user->kernel or vice versa */ if (cpu_buf->last_is_kernel != is_kernel) { cpu_buf->last_is_kernel = is_kernel; - cpu_buf->buffer[cpu_buf->pos].eip = ~0UL; - cpu_buf->buffer[cpu_buf->pos].event = is_kernel; - cpu_buf->pos++; + cpu_buf->buffer[cpu_buf->head_pos].eip = ~0UL; + cpu_buf->buffer[cpu_buf->head_pos].event = is_kernel; + increment_head(cpu_buf); } /* notice a task switch */ if (cpu_buf->last_task != task) { cpu_buf->last_task = task; if (!(task->flags & PF_EXITING)) { - cpu_buf->buffer[cpu_buf->pos].eip = ~0UL; - cpu_buf->buffer[cpu_buf->pos].event = (unsigned long)task; - cpu_buf->pos++; + cpu_buf->buffer[cpu_buf->head_pos].eip = ~0UL; + cpu_buf->buffer[cpu_buf->head_pos].event = (unsigned long)task; + increment_head(cpu_buf); } } @@ -138,23 +162,20 @@ */ if (task->flags & PF_EXITING) { cpu_buf->sample_lost_task_exit++; - goto out; + return; } - cpu_buf->buffer[cpu_buf->pos].eip = eip; - cpu_buf->buffer[cpu_buf->pos].event = event; - cpu_buf->pos++; -out: - spin_unlock(&cpu_buf->int_lock); + cpu_buf->buffer[cpu_buf->head_pos].eip = eip; + cpu_buf->buffer[cpu_buf->head_pos].event = event; + increment_head(cpu_buf); } + /* resets the cpu buffer to a sane state - should be called with * cpu_buf->int_lock held */ void cpu_buffer_reset(struct oprofile_cpu_buffer *cpu_buf) { - cpu_buf->pos = 0; - /* reset these to invalid values; the next sample * collected will populate the buffer with proper * values to initialize the buffer @@ -162,4 +183,3 @@ cpu_buf->last_is_kernel = -1; cpu_buf->last_task = 0; } - diff -Nru a/drivers/oprofile/cpu_buffer.h b/drivers/oprofile/cpu_buffer.h --- a/drivers/oprofile/cpu_buffer.h Thu Jan 23 12:24:53 2003 +++ b/drivers/oprofile/cpu_buffer.h Wed Mar 5 13:56:22 2003 @@ -30,14 +30,13 @@ }; struct oprofile_cpu_buffer { - spinlock_t int_lock; - /* protected by int_lock */ - unsigned long pos; + volatile unsigned long head_pos; + volatile unsigned long tail_pos; + unsigned long buffer_size; struct task_struct * last_task; int last_is_kernel; struct op_sample * buffer; unsigned long sample_received; - unsigned long sample_lost_locked; unsigned long sample_lost_overflow; unsigned long sample_lost_task_exit; } ____cacheline_aligned; diff -Nru a/drivers/oprofile/oprofile_stats.c b/drivers/oprofile/oprofile_stats.c --- a/drivers/oprofile/oprofile_stats.c Sun Dec 22 04:53:01 2002 +++ b/drivers/oprofile/oprofile_stats.c Tue Feb 25 05:56:06 2003 @@ -27,7 +27,6 @@ cpu_buf = &cpu_buffer[i]; cpu_buf->sample_received = 0; - cpu_buf->sample_lost_locked = 0; cpu_buf->sample_lost_overflow = 0; cpu_buf->sample_lost_task_exit = 0; } @@ -63,8 +62,6 @@ */ oprofilefs_create_ro_ulong(sb, cpudir, "sample_received", &cpu_buf->sample_received); - oprofilefs_create_ro_ulong(sb, cpudir, "sample_lost_locked", - &cpu_buf->sample_lost_locked); oprofilefs_create_ro_ulong(sb, cpudir, "sample_lost_overflow", &cpu_buf->sample_lost_overflow); oprofilefs_create_ro_ulong(sb, cpudir, "sample_lost_task_exit", diff -Nru a/drivers/parport/ieee1284.c b/drivers/parport/ieee1284.c --- a/drivers/parport/ieee1284.c Mon Nov 18 14:18:05 2002 +++ b/drivers/parport/ieee1284.c Wed Mar 5 21:39:37 2003 @@ -170,7 +170,7 @@ { int ret; int usec; - long deadline; + unsigned long deadline; unsigned char status; usec = port->physport->spintime; /* usecs of fast polling */ diff -Nru a/drivers/parport/ieee1284_ops.c b/drivers/parport/ieee1284_ops.c --- a/drivers/parport/ieee1284_ops.c Sat Nov 23 06:29:46 2002 +++ b/drivers/parport/ieee1284_ops.c Wed Mar 5 21:39:37 2003 @@ -58,7 +58,7 @@ parport_write_control (port, ctl); parport_data_forward (port); while (count < len) { - long expire = jiffies + dev->timeout; + unsigned long expire = jiffies + dev->timeout; long wait = (HZ + 99) / 100; unsigned char mask = (PARPORT_STATUS_ERROR | PARPORT_STATUS_BUSY); @@ -431,7 +431,7 @@ | PARPORT_CONTROL_INIT, PARPORT_CONTROL_INIT); for (written = 0; written < len; written++, buf++) { - long expire = jiffies + port->cad->timeout; + unsigned long expire = jiffies + port->cad->timeout; unsigned char byte; byte = *buf; @@ -520,7 +520,7 @@ parport_write_control (port, ctl | PARPORT_CONTROL_AUTOFD); while (count < len) { - long expire = jiffies + dev->timeout; + unsigned long expire = jiffies + dev->timeout; unsigned char byte; int command; @@ -668,7 +668,7 @@ PARPORT_CONTROL_AUTOFD | PARPORT_CONTROL_INIT); for (written = 0; written < len; written++, buf++) { - long expire = jiffies + port->cad->timeout; + unsigned long expire = jiffies + port->cad->timeout; unsigned char byte; byte = *buf; diff -Nru a/drivers/pci/Makefile b/drivers/pci/Makefile --- a/drivers/pci/Makefile Tue Feb 18 18:58:56 2003 +++ b/drivers/pci/Makefile Sat Mar 1 07:41:20 2003 @@ -2,7 +2,7 @@ # Makefile for the PCI bus specific drivers. # -obj-y += access.o probe.o pci.o pool.o quirks.o \ +obj-y += access.o bus.o probe.o pci.o pool.o quirks.o \ names.o pci-driver.o search.o hotplug.o \ pci-sysfs.o obj-$(CONFIG_PM) += power.o diff -Nru a/drivers/pci/bus.c b/drivers/pci/bus.c --- /dev/null Wed Dec 31 16:00:00 1969 +++ b/drivers/pci/bus.c Mon Mar 3 13:26:41 2003 @@ -0,0 +1,127 @@ +/* + * drivers/pci/bus.c + * + * From setup-res.c, by: + * Dave Rusling (david.rusling@reo.mts.dec.com) + * David Mosberger (davidm@cs.arizona.edu) + * David Miller (davem@redhat.com) + * Ivan Kokshaysky (ink@jurassic.park.msu.ru) + */ +#include +#include +#include +#include +#include +#include +#include + +#include "pci.h" + +/** + * pci_bus_alloc_resource - allocate a resource from a parent bus + * @bus: PCI bus + * @res: resource to allocate + * @size: size of resource to allocate + * @align: alignment of resource to allocate + * @min: minimum /proc/iomem address to allocate + * @type_mask: IORESOURCE_* type flags + * @alignf: resource alignment function + * @alignf_data: data argument for resource alignment function + * + * Given the PCI bus a device resides on, the size, minimum address, + * alignment and type, try to find an acceptable resource allocation + * for a specific device resource. + */ +int +pci_bus_alloc_resource(struct pci_bus *bus, struct resource *res, + unsigned long size, unsigned long align, unsigned long min, + unsigned int type_mask, + void (*alignf)(void *, struct resource *, + unsigned long, unsigned long), + void *alignf_data) +{ + int i, ret = -ENOMEM; + + type_mask |= IORESOURCE_IO | IORESOURCE_MEM; + + for (i = 0; i < PCI_BUS_NUM_RESOURCES; i++) { + struct resource *r = bus->resource[i]; + if (!r) + continue; + + /* type_mask must match */ + if ((res->flags ^ r->flags) & type_mask) + continue; + + /* We cannot allocate a non-prefetching resource + from a pre-fetching area */ + if ((r->flags & IORESOURCE_PREFETCH) && + !(res->flags & IORESOURCE_PREFETCH)) + continue; + + /* Ok, try it out.. */ + ret = allocate_resource(r, res, size, min, -1, align, + alignf, alignf_data); + if (ret == 0) + break; + } + return ret; +} + +/** + * pci_bus_add_devices - insert newly discovered PCI devices + * @bus: bus to check for new devices + * + * Add newly discovered PCI devices (which are on the bus->devices + * list) to the global PCI device list, add the sysfs and procfs + * entries. Where a bridge is found, add the discovered bus to + * the parents list of child buses, and recurse. + * + * Call hotplug for each new devices. + */ +void __devinit pci_bus_add_devices(struct pci_bus *bus) +{ + struct pci_dev *dev; + + list_for_each_entry(dev, &bus->devices, bus_list) { + /* + * Skip already-present devices (which are on the + * global device list.) + */ + if (!list_empty(&dev->global_list)) + continue; + + device_register(&dev->dev); + list_add_tail(&dev->global_list, &pci_devices); +#ifdef CONFIG_PROC_FS + pci_proc_attach_device(dev); +#endif + pci_create_sysfs_dev_files(dev); + + /* + * If there is an unattached subordinate bus, attach + * it and then scan for unattached PCI devices. + */ + if (dev->subordinate && list_empty(&dev->subordinate->node)) { + list_add_tail(&dev->subordinate->node, &dev->bus->children); + pci_bus_add_devices(dev->subordinate); + } + } +} + +void pci_enable_bridges(struct pci_bus *bus) +{ + struct pci_dev *dev; + + list_for_each_entry(dev, &bus->devices, bus_list) { + if (dev->subordinate) { + pci_enable_device(dev); + pci_set_master(dev); + pci_enable_bridges(dev->subordinate); + } + } +} + +EXPORT_SYMBOL(pci_bus_alloc_resource); +EXPORT_SYMBOL(pci_bus_add_devices); +EXPORT_SYMBOL(pci_enable_bridges); diff -Nru a/drivers/pci/probe.c b/drivers/pci/probe.c --- a/drivers/pci/probe.c Mon Feb 24 08:17:19 2003 +++ b/drivers/pci/probe.c Tue Feb 25 15:47:51 2003 @@ -221,47 +221,64 @@ b = kmalloc(sizeof(*b), GFP_KERNEL); if (b) { memset(b, 0, sizeof(*b)); + INIT_LIST_HEAD(&b->node); INIT_LIST_HEAD(&b->children); INIT_LIST_HEAD(&b->devices); } return b; } -struct pci_bus * __devinit pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev, int busnr) +static struct pci_bus * __devinit +pci_alloc_child_bus(struct pci_bus *parent, struct pci_dev *bridge, int busnr) { struct pci_bus *child; - int i; /* * Allocate a new bus, and inherit stuff from the parent.. */ child = pci_alloc_bus(); - list_add_tail(&child->node, &parent->children); - child->self = dev; - dev->subordinate = child; - child->parent = parent; - child->ops = parent->ops; - child->sysdata = parent->sysdata; - child->dev = &dev->dev; + if (child) { + int i; - /* - * Set up the primary, secondary and subordinate - * bus numbers. - */ - child->number = child->secondary = busnr; - child->primary = parent->secondary; - child->subordinate = 0xff; - - /* Set up default resource pointers and names.. */ - for (i = 0; i < 4; i++) { - child->resource[i] = &dev->resource[PCI_BRIDGE_RESOURCES+i]; - child->resource[i]->name = child->name; + child->self = bridge; + child->parent = parent; + child->ops = parent->ops; + child->sysdata = parent->sysdata; + child->dev = &bridge->dev; + + /* + * Set up the primary, secondary and subordinate + * bus numbers. + */ + child->number = child->secondary = busnr; + child->primary = parent->secondary; + child->subordinate = 0xff; + + /* Set up default resource pointers and names.. */ + for (i = 0; i < 4; i++) { + child->resource[i] = &bridge->resource[PCI_BRIDGE_RESOURCES+i]; + child->resource[i]->name = child->name; + } + + bridge->subordinate = child; } return child; } +struct pci_bus * __devinit pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev, int busnr) +{ + struct pci_bus *child; + + child = pci_alloc_child_bus(parent, dev, busnr); + if (child) + list_add_tail(&child->node, &parent->children); + return child; +} + +static unsigned int __devinit pci_scan_child_bus(struct pci_bus *bus); + /* * If it's a bridge, configure it and scan the bus behind it. * For CardBus bridges, we don't scan behind as the devices will @@ -288,12 +305,12 @@ */ if (pass) return max; - child = pci_add_new_bus(bus, dev, 0); + child = pci_alloc_child_bus(bus, dev, 0); child->primary = buses & 0xFF; child->secondary = (buses >> 8) & 0xFF; child->subordinate = (buses >> 16) & 0xFF; child->number = child->secondary; - cmax = pci_do_scan_bus(child); + cmax = pci_scan_child_bus(child); if (cmax > max) max = cmax; } else { /* @@ -306,18 +323,27 @@ /* Clear errors */ pci_write_config_word(dev, PCI_STATUS, 0xffff); - child = pci_add_new_bus(bus, dev, ++max); + child = pci_alloc_child_bus(bus, dev, ++max); buses = (buses & 0xff000000) | ((unsigned int)(child->primary) << 0) | ((unsigned int)(child->secondary) << 8) | ((unsigned int)(child->subordinate) << 16); + + /* + * yenta.c forces a secondary latency timer of 176. + * Copy that behaviour here. + */ + if (is_cardbus) + buses = (buses & 0x00ffffff) | (176 << 24); + /* * We need to blast all three values with a single write. */ pci_write_config_dword(dev, PCI_PRIMARY_BUS, buses); + if (!is_cardbus) { /* Now we can scan all subordinate buses... */ - max = pci_do_scan_bus(child); + max = pci_scan_child_bus(child); } else { /* * For CardBus bridges, we leave 4 bus numbers @@ -374,7 +400,8 @@ dev->class = class; class >>= 8; - DBG("Found %02x:%02x [%04x/%04x] %06x %02x\n", dev->bus->number, dev->devfn, dev->vendor, dev->device, class, dev->hdr_type); + DBG("Found %02x:%02x [%04x/%04x] %06x %02x\n", dev->bus->number, dev->devfn, + dev->vendor, dev->device, class, dev->hdr_type); /* "Unknown power state" */ dev->current_state = 4; @@ -427,23 +454,35 @@ * Read the config data for a PCI device, sanity-check it * and fill in the dev structure... */ -struct pci_dev * __devinit pci_scan_device(struct pci_dev *temp) +static struct pci_dev * __devinit +pci_scan_device(struct pci_bus *bus, int devfn) { struct pci_dev *dev; u32 l; + u8 hdr_type; + + if (pci_bus_read_config_byte(bus, devfn, PCI_HEADER_TYPE, &hdr_type)) + return NULL; - if (pci_read_config_dword(temp, PCI_VENDOR_ID, &l)) + if (pci_bus_read_config_dword(bus, devfn, PCI_VENDOR_ID, &l)) return NULL; /* some broken boards return 0 or ~0 if a slot is empty: */ if (l == 0xffffffff || l == 0x00000000 || l == 0x0000ffff || l == 0xffff0000) return NULL; - dev = kmalloc(sizeof(*dev), GFP_KERNEL); + dev = kmalloc(sizeof(struct pci_dev), GFP_KERNEL); if (!dev) return NULL; - memcpy(dev, temp, sizeof(*dev)); + memset(dev, 0, sizeof(struct pci_dev)); + dev->bus = bus; + dev->sysdata = bus->sysdata; + dev->dev.parent = bus->dev; + dev->dev.bus = &pci_bus_type; + dev->devfn = devfn; + dev->hdr_type = hdr_type & 0x7f; + dev->multifunction = !!(hdr_type & 0x80); dev->vendor = l & 0xffff; dev->device = (l >> 16) & 0xffff; @@ -461,74 +500,63 @@ strcpy(dev->dev.bus_id,dev->slot_name); dev->dev.dma_mask = &dev->dma_mask; - device_register(&dev->dev); return dev; } -struct pci_dev * __devinit pci_scan_slot(struct pci_dev *temp) +/** + * pci_scan_slot - scan a PCI slot on a bus for devices. + * @bus: PCI bus to scan + * @devfn: slot number to scan (must have zero function.) + * + * Scan a PCI slot on the specified PCI bus for devices, adding + * discovered devices to the @bus->devices list. New devices + * will have an empty dev->global_list head. + */ +int __devinit pci_scan_slot(struct pci_bus *bus, int devfn) { - struct pci_bus *bus = temp->bus; - struct pci_dev *dev; - struct pci_dev *first_dev = NULL; - int func = 0; - int is_multi = 0; - u8 hdr_type; + int func, nr = 0; - for (func = 0; func < 8; func++, temp->devfn++) { - if (func && !is_multi) /* not a multi-function device */ - continue; - if (pci_read_config_byte(temp, PCI_HEADER_TYPE, &hdr_type)) - continue; - temp->hdr_type = hdr_type & 0x7f; + for (func = 0; func < 8; func++, devfn++) { + struct pci_dev *dev; - dev = pci_scan_device(temp); + dev = pci_scan_device(bus, devfn); if (!dev) continue; - if (!func) { - is_multi = hdr_type & 0x80; - first_dev = dev; - } - /* - * Link the device to both the global PCI device chain and - * the per-bus list of devices and add the /proc entry. - */ - pci_insert_device (dev, bus); + if (func != 0) + dev->multifunction = 1; /* Fix up broken headers */ pci_fixup_device(PCI_FIXUP_HEADER, dev); + + /* + * Add the device to our list of discovered devices + * and the bus list for fixup functions, etc. + */ + INIT_LIST_HEAD(&dev->global_list); + list_add_tail(&dev->bus_list, &bus->devices); + nr++; + + /* + * If this is a single function device, + * don't scan past the first function. + */ + if (!dev->multifunction) + break; } - return first_dev; + return nr; } -unsigned int __devinit pci_do_scan_bus(struct pci_bus *bus) +static unsigned int __devinit pci_scan_child_bus(struct pci_bus *bus) { - unsigned int devfn, max, pass; - struct list_head *ln; + unsigned int devfn, pass, max = bus->secondary; struct pci_dev *dev; - dev = kmalloc(sizeof(*dev), GFP_KERNEL); - if (!dev) { - printk(KERN_ERR "Out of memory in %s\n", __FUNCTION__); - return 0; - } - DBG("Scanning bus %02x\n", bus->number); - max = bus->secondary; - - /* Create a device template */ - memset(dev, 0, sizeof(*dev)); - dev->bus = bus; - dev->sysdata = bus->sysdata; - dev->dev.parent = bus->dev; - dev->dev.bus = &pci_bus_type; /* Go find them, Rover! */ - for (devfn = 0; devfn < 0x100; devfn += 8) { - dev->devfn = devfn; - pci_scan_slot(dev); - } - kfree(dev); + for (devfn = 0; devfn < 0x100; devfn += 8) + pci_scan_slot(bus, devfn); /* * After performing arch-dependent fixup of the bus, look behind @@ -537,9 +565,9 @@ DBG("Fixups for bus %02x\n", bus->number); pcibios_fixup_bus(bus); for (pass=0; pass < 2; pass++) - for (ln=bus->devices.next; ln != &bus->devices; ln=ln->next) { - dev = pci_dev_b(ln); - if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE || dev->hdr_type == PCI_HEADER_TYPE_CARDBUS) + list_for_each_entry(dev, &bus->devices, bus_list) { + if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE || + dev->hdr_type == PCI_HEADER_TYPE_CARDBUS) max = pci_scan_bridge(bus, dev, max, pass); } @@ -551,6 +579,20 @@ * Return how far we've got finding sub-buses. */ DBG("Bus scan for %02x returning with max=%02x\n", bus->number, max); + return max; +} + +unsigned int __devinit pci_do_scan_bus(struct pci_bus *bus) +{ + unsigned int max; + + max = pci_scan_child_bus(bus); + + /* + * Make the discovered devices available. + */ + pci_bus_add_devices(bus); + return max; } diff -Nru a/drivers/pci/quirks.c b/drivers/pci/quirks.c --- a/drivers/pci/quirks.c Sat Feb 15 04:56:07 2003 +++ b/drivers/pci/quirks.c Thu Feb 20 08:59:29 2003 @@ -167,6 +167,22 @@ } } +/* + * Ali Magik requires workarounds to be used by the drivers + * that DMA to AGP space. Latency must be set to 0xA and triton + * workaround applied too + * [Info kindly provided by ALi] + */ + +static void __init quirk_alimagik(struct pci_dev *dev) +{ + if((pci_pci_problems&PCIPCI_ALIMAGIK)==0) + { + printk(KERN_INFO "Limiting direct PCI/PCI transfers.\n"); + pci_pci_problems|=PCIPCI_ALIMAGIK|PCIPCI_TRITON; + } +} + /* * Natoma has some interesting boundary conditions with Zoran stuff @@ -219,7 +235,7 @@ static void __devinit quirk_ati_exploding_mce(struct pci_dev *dev) { printk(KERN_INFO "ATI Northbridge, reserving I/O ports 0x3b0 to 0x3bb.\n"); - /* Mae rhaid in i beidio a edrych ar y lleoliad I/O hyn */ + /* Mae rhaid i ni beidio ag edrych ar y lleoliadiau I/O hyn */ request_region(0x3b0, 0x0C, "RadeonIGP"); request_region(0x3d3, 0x01, "RadeonIGP"); } @@ -535,6 +551,92 @@ } } +/* + * As per PCI spec, ignore base address registers 0-3 of the IDE controllers + * running in Compatible mode (bits 0 and 2 in the ProgIf for primary and + * secondary channels respectively). If the device reports Compatible mode + * but does use BAR0-3 for address decoding, we assume that firmware has + * programmed these BARs with standard values (0x1f0,0x3f4 and 0x170,0x374). + * Exceptions (if they exist) must be handled in chip/architecture specific + * fixups. + * + * Note: for non x86 people. You may need an arch specific quirk to handle + * moving IDE devices to native mode as well. Some plug in card devices power + * up in compatible mode and assume the BIOS will adjust them. + * + * Q: should we load the 0x1f0,0x3f4 into the registers or zap them as + * we do now ? We don't want is pci_enable_device to come along + * and assign new resources. Both approaches work for that. + */ + +static void __devinit quirk_ide_bases(struct pci_dev *dev) +{ + struct resource *res; + int first_bar = 2, last_bar = 0; + + if ((dev->class >> 8) != PCI_CLASS_STORAGE_IDE) + return; + + res = &dev->resource[0]; + + /* primary channel: ProgIf bit 0, BAR0, BAR1 */ + if (!(dev->class & 1) && (res[0].flags || res[1].flags)) { + res[0].start = res[0].end = res[0].flags = 0; + res[1].start = res[1].end = res[1].flags = 0; + first_bar = 0; + last_bar = 1; + } + + /* secondary channel: ProgIf bit 2, BAR2, BAR3 */ + if (!(dev->class & 4) && (res[2].flags || res[3].flags)) { + res[2].start = res[2].end = res[2].flags = 0; + res[3].start = res[3].end = res[3].flags = 0; + last_bar = 3; + } + + if (!last_bar) + return; + + printk(KERN_INFO "PCI: Ignoring BAR%d-%d of IDE controller %s\n", + first_bar, last_bar, dev->slot_name); +} + +/* + * Ensure C0 rev restreaming is off. This is normally done by + * the BIOS but in the odd case it is not the results are corruption + * hence the presence of a Linux check + */ + +static void __init quirk_disable_pxb(struct pci_dev *pdev) +{ + u16 config; + u8 rev; + + pci_read_config_byte(pdev, PCI_REVISION_ID, &rev); + if(rev != 0x04) /* Only C0 requires this */ + return; + pci_read_config_word(pdev, 0x40, &config); + if(config & (1<<6)) + { + config &= ~(1<<6); + pci_write_config_word(pdev, 0x40, config); + printk(KERN_INFO "PCI: C0 revision 450NX. Disabling PCI restreaming.\n"); + } +} + +/* + * VIA northbridges care about PCI_INTERRUPT_LINE + */ + +int interrupt_line_quirk; + +static void __init quirk_via_bridge(struct pci_dev *pdev) +{ + if(pdev->devfn == 0) + interrupt_line_quirk = 1; +} + + /* This was originally an Alpha specific thing, but it really fits here. * The i82375 PCI/EISA bridge appears as non-classified. Fix that. */ @@ -559,7 +661,10 @@ { PCI_FIXUP_FINAL, PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C586_0, quirk_isa_dma_hangs }, { PCI_FIXUP_FINAL, PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C596, quirk_isa_dma_hangs }, { PCI_FIXUP_FINAL, PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371SB_0, quirk_isa_dma_hangs }, + { PCI_FIXUP_FINAL, PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82454NX, quirk_disable_pxb }, { PCI_FIXUP_FINAL, PCI_VENDOR_ID_NEC, PCI_DEVICE_ID_NEC_CBUS_1, quirk_isa_dma_hangs }, + { PCI_FIXUP_FINAL, PCI_VENDOR_ID_NEC, PCI_DEVICE_ID_NEC_CBUS_2, quirk_isa_dma_hangs }, + { PCI_FIXUP_FINAL, PCI_VENDOR_ID_NEC, PCI_DEVICE_ID_NEC_CBUS_3, quirk_isa_dma_hangs }, { PCI_FIXUP_HEADER, PCI_VENDOR_ID_S3, PCI_DEVICE_ID_S3_868, quirk_s3_64M }, { PCI_FIXUP_HEADER, PCI_VENDOR_ID_S3, PCI_DEVICE_ID_S3_968, quirk_s3_64M }, { PCI_FIXUP_FINAL, PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82437, quirk_triton }, @@ -574,6 +679,8 @@ { PCI_FIXUP_FINAL, PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82443BX_2, quirk_natoma }, { PCI_FIXUP_FINAL, PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_5597, quirk_nopcipci }, { PCI_FIXUP_FINAL, PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_496, quirk_nopcipci }, + { PCI_FIXUP_FINAL, PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M1647, quirk_alimagik }, + { PCI_FIXUP_FINAL, PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M1651, quirk_alimagik }, { PCI_FIXUP_FINAL, PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8363_0, quirk_vialatency }, { PCI_FIXUP_FINAL, PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8371_1, quirk_vialatency }, { PCI_FIXUP_FINAL, PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8361, quirk_vialatency }, @@ -586,6 +693,8 @@ { PCI_FIXUP_HEADER, PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M7101, quirk_ali7101_acpi }, { PCI_FIXUP_HEADER, PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371SB_2, quirk_piix3_usb }, { PCI_FIXUP_HEADER, PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371AB_2, quirk_piix3_usb }, + { PCI_FIXUP_HEADER, PCI_ANY_ID, PCI_ANY_ID, quirk_ide_bases }, + { PCI_FIXUP_HEADER, PCI_VENDOR_ID_VIA, PCI_ANY_ID, quirk_via_bridge }, { PCI_FIXUP_FINAL, PCI_ANY_ID, PCI_ANY_ID, quirk_cardbus_legacy }, #ifdef CONFIG_X86_IO_APIC diff -Nru a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c --- a/drivers/pci/setup-bus.c Tue Feb 18 03:27:06 2003 +++ b/drivers/pci/setup-bus.c Tue Feb 25 03:17:33 2003 @@ -350,6 +350,7 @@ { struct pci_bus *b; int found_vga = pbus_assign_resources_sorted(bus); + struct pci_dev *dev; if (found_vga) { /* Propagate presence of the VGA to upstream bridges */ @@ -357,9 +358,12 @@ b->resource[0]->flags |= IORESOURCE_BUS_HAS_VGA; } } - list_for_each_entry(b, &bus->children, node) { - pci_bus_assign_resources(b); - pci_setup_bridge(b); + list_for_each_entry(dev, &bus->devices, bus_list) { + b = dev->subordinate; + if (b) { + pci_bus_assign_resources(b); + pci_setup_bridge(b); + } } } EXPORT_SYMBOL(pci_bus_assign_resources); diff -Nru a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c --- a/drivers/pci/setup-res.c Tue Dec 10 01:15:16 2002 +++ b/drivers/pci/setup-res.c Sat Mar 1 02:11:51 2003 @@ -55,84 +55,47 @@ return err; } -/* - * Given the PCI bus a device resides on, try to - * find an acceptable resource allocation for a - * specific device resource.. - */ -static int pci_assign_bus_resource(const struct pci_bus *bus, - struct pci_dev *dev, - struct resource *res, - unsigned long size, - unsigned long min, - unsigned int type_mask, - int resno) +int pci_assign_resource(struct pci_dev *dev, int resno) { - unsigned long align; - int i; - - type_mask |= IORESOURCE_IO | IORESOURCE_MEM; - for (i = 0 ; i < PCI_BUS_NUM_RESOURCES; i++) { - struct resource *r = bus->resource[i]; - if (!r) - continue; - - /* type_mask must match */ - if ((res->flags ^ r->flags) & type_mask) - continue; - - /* We cannot allocate a non-prefetching resource - from a pre-fetching area */ - if ((r->flags & IORESOURCE_PREFETCH) && - !(res->flags & IORESOURCE_PREFETCH)) - continue; - - /* The bridge resources are special, as their - size != alignment. Sizing routines return - required alignment in the "start" field. */ - align = (resno < PCI_BRIDGE_RESOURCES) ? size : res->start; - - /* Ok, try it out.. */ - if (allocate_resource(r, res, size, min, -1, align, - pcibios_align_resource, dev) < 0) - continue; - - /* Update PCI config space. */ - pcibios_update_resource(dev, r, res, resno); - return 0; - } - return -EBUSY; -} - -int -pci_assign_resource(struct pci_dev *dev, int i) -{ - const struct pci_bus *bus = dev->bus; - struct resource *res = dev->resource + i; - unsigned long size, min; + struct pci_bus *bus = dev->bus; + struct resource *res = dev->resource + resno; + unsigned long size, min, align; + int ret; size = res->end - res->start + 1; min = (res->flags & IORESOURCE_IO) ? PCIBIOS_MIN_IO : PCIBIOS_MIN_MEM; + /* The bridge resources are special, as their + size != alignment. Sizing routines return + required alignment in the "start" field. */ + align = (resno < PCI_BRIDGE_RESOURCES) ? size : res->start; /* First, try exact prefetching match.. */ - if (pci_assign_bus_resource(bus, dev, res, size, min, IORESOURCE_PREFETCH, i) < 0) { + ret = pci_bus_alloc_resource(bus, res, size, align, min, + IORESOURCE_PREFETCH, + pcibios_align_resource, dev); + + if (ret < 0 && (res->flags & IORESOURCE_PREFETCH)) { /* * That failed. * * But a prefetching area can handle a non-prefetching * window (it will just not perform as well). */ - if (!(res->flags & IORESOURCE_PREFETCH) || pci_assign_bus_resource(bus, dev, res, size, min, 0, i) < 0) { - printk(KERN_ERR "PCI: Failed to allocate resource %d(%lx-%lx) for %s\n", - i, res->start, res->end, dev->slot_name); - return -EBUSY; - } + ret = pci_bus_alloc_resource(bus, res, size, align, min, 0, + pcibios_align_resource, dev); } - DBGC((KERN_ERR " got res[%lx:%lx] for resource %d of %s\n", res->start, - res->end, i, dev->dev.name)); + if (ret) { + printk(KERN_ERR "PCI: Failed to allocate resource %d(%lx-%lx) for %s\n", + resno, res->start, res->end, dev->slot_name); + } else { + DBGC((KERN_ERR " got res[%lx:%lx] for resource %d of %s\n", + res->start, res->end, i, dev->dev.name)); + /* Update PCI config space. */ + pcibios_update_resource(dev, res->parent, res, resno); + } - return 0; + return ret; } /* Sort resources by alignment */ diff -Nru a/drivers/pcmcia/hd64465_ss.c b/drivers/pcmcia/hd64465_ss.c --- a/drivers/pcmcia/hd64465_ss.c Fri Feb 21 13:05:18 2003 +++ b/drivers/pcmcia/hd64465_ss.c Tue Mar 4 22:35:34 2003 @@ -1070,8 +1070,8 @@ } /* hd64465_io_debug = 0; */ - platform_device_register(&hd64465_device); hd64465_device.dev.class_data = &hd64465_data; + platform_device_register(&hd64465_device); return 0; } diff -Nru a/drivers/pcmcia/i82365.c b/drivers/pcmcia/i82365.c --- a/drivers/pcmcia/i82365.c Tue Feb 25 11:50:51 2003 +++ b/drivers/pcmcia/i82365.c Tue Mar 4 22:35:34 2003 @@ -1628,11 +1628,11 @@ request_irq(cs_irq, pcic_interrupt, 0, "i82365", pcic_interrupt); #endif - platform_device_register(&i82365_device); - i82365_data.nsock = sockets; i82365_device.dev.class_data = &i82365_data; + platform_device_register(&i82365_device); + /* Finally, schedule a polling interrupt */ if (poll_interval != 0) { poll_timer.function = pcic_interrupt_wrapper; diff -Nru a/drivers/pcmcia/sa1100_generic.c b/drivers/pcmcia/sa1100_generic.c --- a/drivers/pcmcia/sa1100_generic.c Sun Mar 2 12:59:19 2003 +++ b/drivers/pcmcia/sa1100_generic.c Thu Mar 6 08:48:29 2003 @@ -47,7 +47,6 @@ #include #include #include -#include #include #include diff -Nru a/drivers/pcmcia/tcic.c b/drivers/pcmcia/tcic.c --- a/drivers/pcmcia/tcic.c Fri Feb 21 13:05:24 2003 +++ b/drivers/pcmcia/tcic.c Tue Mar 4 22:35:34 2003 @@ -452,8 +452,6 @@ sockets++; } - platform_device_register(&tcic_device); - switch (socket_table[0].id) { case TCIC_ID_DB86082: printk("DB86082"); break; @@ -526,6 +524,8 @@ tcic_data.nsock = sockets; tcic_device.dev.class_data = &tcic_data; + + platform_device_register(&tcic_device); return 0; diff -Nru a/drivers/s390/block/dasd_3990_erp.c b/drivers/s390/block/dasd_3990_erp.c --- a/drivers/s390/block/dasd_3990_erp.c Mon Feb 24 10:29:29 2003 +++ b/drivers/s390/block/dasd_3990_erp.c Thu Mar 6 09:25:58 2003 @@ -2445,7 +2445,7 @@ * - exit with permanent error * * PARAMETER - * erp ERP which is in progress wiht no retry left + * erp ERP which is in progress with no retry left * * RETURN VALUES * erp modified/additional ERP diff -Nru a/drivers/s390/char/con3215.c b/drivers/s390/char/con3215.c --- a/drivers/s390/char/con3215.c Tue Feb 25 10:27:52 2003 +++ b/drivers/s390/char/con3215.c Thu Mar 6 09:25:58 2003 @@ -862,7 +862,7 @@ spin_unlock_irqrestore(raw->lock, flags); } -static int __init +static int __init con3215_consetup(struct console *co, char *options) { return 0; @@ -884,7 +884,7 @@ * 3215 console initialization code called from console_init(). * NOTE: This is called before kmalloc is available. */ -void __init +static void __init con3215_init(void) { struct ccw_device *cdev; @@ -1122,6 +1122,7 @@ spin_unlock_irqrestore(raw->lock, flags); } } +console_initcall(con3215_init); /* * Disable writing to a 3215 tty diff -Nru a/drivers/s390/char/sclp_con.c b/drivers/s390/char/sclp_con.c --- a/drivers/s390/char/sclp_con.c Thu Dec 12 10:03:31 2002 +++ b/drivers/s390/char/sclp_con.c Fri Feb 14 15:23:21 2003 @@ -237,3 +237,5 @@ /* enable printk-access to this driver */ register_console(&sclp_console); } + +console_initcall(sclp_console_init); diff -Nru a/drivers/s390/char/sclp_tty.c b/drivers/s390/char/sclp_tty.c --- a/drivers/s390/char/sclp_tty.c Thu Feb 6 07:33:47 2003 +++ b/drivers/s390/char/sclp_tty.c Fri Feb 14 15:23:21 2003 @@ -797,3 +797,6 @@ if (tty_register_driver(&sclp_tty_driver)) panic("Couldn't register sclp_tty driver\n"); } + +console_initcall(sclp_tty_init); + diff -Nru a/drivers/s390/char/tuball.c b/drivers/s390/char/tuball.c --- a/drivers/s390/char/tuball.c Wed Oct 9 07:01:46 2002 +++ b/drivers/s390/char/tuball.c Fri Feb 14 15:24:00 2003 @@ -131,7 +131,7 @@ #else #define tub3270_con_devno console_device -void __init tub3270_con_init(void) +static void __init tub3270_con_init(void) { tub3270_con_bcb.bc_len = 65536; if (!CONSOLE_IS_3270) @@ -140,6 +140,8 @@ tub3270_con_bcb.bc_len); register_console(&tub3270_con); } +console_initcall(tub3270_con_init); + #endif static kdev_t diff -Nru a/drivers/scsi/aic7xxx/aicasm/Makefile b/drivers/scsi/aic7xxx/aicasm/Makefile --- a/drivers/scsi/aic7xxx/aicasm/Makefile Tue Dec 10 11:02:52 2002 +++ b/drivers/scsi/aic7xxx/aicasm/Makefile Thu Feb 20 08:39:57 2003 @@ -10,9 +10,10 @@ GENSRCS= $(YSRCS:.y=.c) $(LSRCS:.l=.c) SRCS= ${CSRCS} ${GENSRCS} +LIBS= -ldb CLEANFILES= ${GENSRCS} ${GENHDRS} $(YSRCS:.y=.output) # Override default kernel CFLAGS. This is a userland app. -AICASM_CFLAGS:= -I/usr/include -I. -ldb +AICASM_CFLAGS:= -I/usr/include -I. YFLAGS= -d NOMAN= noman @@ -30,7 +31,7 @@ endif $(PROG): ${GENHDRS} $(SRCS) - $(AICASM_CC) $(AICASM_CFLAGS) $(SRCS) -o $(PROG) + $(AICASM_CC) $(AICASM_CFLAGS) $(SRCS) -o $(PROG) $(LIBS) aicdb.h: @if [ -e "/usr/include/db3/db_185.h" ]; then \ @@ -45,8 +46,9 @@ echo "*** Install db development libraries"; \ fi +clean-files := $(CLEANFILES) $(PROG) clean: - rm -f $(CLEANFILES) $(PROG) + rm -f $(clean-files) aicasm_gram.c aicasm_gram.h: aicasm_gram.y $(YACC) $(YFLAGS) -b $(<:.y=) $< diff -Nru a/drivers/scsi/i91uscsi.h b/drivers/scsi/i91uscsi.h --- a/drivers/scsi/i91uscsi.h Mon Feb 4 23:52:37 2002 +++ b/drivers/scsi/i91uscsi.h Sun Feb 16 16:20:08 2003 @@ -70,12 +70,6 @@ #ifndef NULL #define NULL 0 /* zero */ #endif -#ifndef TRUE -#define TRUE (1) /* boolean true */ -#endif -#ifndef FALSE -#define FALSE (0) /* boolean false */ -#endif #ifndef FAILURE #define FAILURE (-1) #endif @@ -597,11 +591,9 @@ TCS HCS_Tcs[MAX_TARGETS]; /* 78 */ ULONG pSRB_head; /* SRB save queue header */ ULONG pSRB_tail; /* SRB save queue tail */ -#if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,95) spinlock_t HCS_AvailLock; spinlock_t HCS_SemaphLock; spinlock_t pSRB_lock; /* SRB queue lock */ -#endif } HCS; /* Bit Definition for HCB_Config */ diff -Nru a/drivers/scsi/imm.c b/drivers/scsi/imm.c --- a/drivers/scsi/imm.c Mon Feb 17 17:02:24 2003 +++ b/drivers/scsi/imm.c Thu Mar 6 15:50:31 2003 @@ -174,6 +174,7 @@ parport_unregister_device(imm_hosts[i].dev); continue; } + /* now the glue ... */ switch (imm_hosts[i].mode) { case IMM_NIBBLE: @@ -218,7 +219,7 @@ /* This is to give the imm driver a way to modify the timings (and other * parameters) by writing to the /proc/scsi/imm/0 file. - * Very simple method really... (To simple, no error checking :( ) + * Very simple method really... (Too simple, no error checking :( ) * Reason: Kernel hackers HATE having to unload and reload modules for * testing... * Also gives a method to use a script to obtain optimum timings (TODO) @@ -948,7 +949,7 @@ unsigned char l = 0, h = 0; int retv, x; - /* First check for any errors that may of occurred + /* First check for any errors that may have occurred * Here we check for internal errors */ if (tmp->failed) diff -Nru a/drivers/scsi/inia100.c b/drivers/scsi/inia100.c --- a/drivers/scsi/inia100.c Fri Jan 3 10:58:49 2003 +++ b/drivers/scsi/inia100.c Sun Feb 16 16:18:17 2003 @@ -67,12 +67,6 @@ * - Fix allocation of scsi host structs and private data **************************************************************************/ -#define CVT_LINUX_VERSION(V,P,S) (V * 65536 + P * 256 + S) - -#ifndef LINUX_VERSION_CODE -#include -#endif - #include #include diff -Nru a/drivers/scsi/inia100.h b/drivers/scsi/inia100.h --- a/drivers/scsi/inia100.h Tue Dec 10 12:28:32 2002 +++ b/drivers/scsi/inia100.h Sun Feb 16 16:18:17 2003 @@ -63,14 +63,6 @@ * merged them into a single header used by both .c files. ****************************************************************************/ -#ifndef CVT_LINUX_VERSION -#define CVT_LINUX_VERSION(V,P,S) (((V) * 65536) + ((P) * 256) + (S)) -#endif - -#ifndef LINUX_VERSION_CODE -#include -#endif - #include #include #include @@ -116,12 +108,6 @@ #ifndef NULL #define NULL 0 /* zero */ -#endif -#ifndef TRUE -#define TRUE (1) /* boolean true */ -#endif -#ifndef FALSE -#define FALSE (0) /* boolean false */ #endif #ifndef FAILURE #define FAILURE (-1) diff -Nru a/drivers/scsi/qlogicfc.c b/drivers/scsi/qlogicfc.c --- a/drivers/scsi/qlogicfc.c Tue Feb 25 02:46:27 2003 +++ b/drivers/scsi/qlogicfc.c Tue Mar 4 22:44:07 2003 @@ -694,7 +694,7 @@ int isp2x00_detect(Scsi_Host_Template * tmpt) { int hosts = 0; - int wait_time; + unsigned long wait_time; struct Scsi_Host *host = NULL; struct isp2x00_hostdata *hostdata; struct pci_dev *pdev; diff -Nru a/drivers/scsi/scsi.h b/drivers/scsi/scsi.h --- a/drivers/scsi/scsi.h Sun Feb 23 10:34:55 2003 +++ b/drivers/scsi/scsi.h Thu Mar 6 15:50:31 2003 @@ -280,26 +280,7 @@ #define SCSI_SET_IOCTL_LOGGING(LEVEL) \ SCSI_SET_LOGGING(SCSI_LOG_IOCTL_SHIFT, SCSI_LOG_IOCTL_BITS, LEVEL); -/* - * the return of the status word will be in the following format : - * The low byte is the status returned by the SCSI command, - * with vendor specific bits masked. - * - * The next byte is the message which followed the SCSI status. - * This allows a stos to be used, since the Intel is a little - * endian machine. - * - * The final byte is a host return code, which is one of the following. - * - * IE - * lsb msb - * status msg host code - * - * Our errors returned by OUR driver, NOT SCSI message. Or'd with - * SCSI message passed back to driver . - */ - - +/* host byte codes */ #define DID_OK 0x00 /* NO error */ #define DID_NO_CONNECT 0x01 /* Couldn't connect before timeout period */ #define DID_BUS_BUSY 0x02 /* BUS stayed busy through time out period */ diff -Nru a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c --- a/drivers/scsi/scsi_error.c Sat Feb 22 08:17:01 2003 +++ b/drivers/scsi/scsi_error.c Thu Mar 6 15:50:31 2003 @@ -92,10 +92,8 @@ * * Notes: * This should be turned into an inline function. Each scsi command - * has it's own timer, and as it is added to the queue, we set up the - * timer. When the command completes, we cancel the timer. Pretty - * simple, really, especially compared to the old way of handling this - * crap. + * has its own timer, and as it is added to the queue, we set up the + * timer. When the command completes, we cancel the timer. **/ void scsi_add_timer(struct scsi_cmnd *scmd, int timeout, void (*complete)(struct scsi_cmnd *)) @@ -249,6 +247,7 @@ { if (!SCSI_SENSE_VALID(scmd)) return FAILED; + if (scmd->sense_buffer[2] & 0xe0) return SUCCESS; @@ -1193,12 +1192,12 @@ * Notes: * This is *only* called when we are examining the status after sending * out the actual data command. any commands that are queued for error - * recovery (i.e. test_unit_ready) do *not* come through here. + * recovery (e.g. test_unit_ready) do *not* come through here. * * When this routine returns failed, it means the error handler thread - * is woken. in cases where the error code indicates an error that + * is woken. In cases where the error code indicates an error that * doesn't require the error handler read (i.e. we don't need to - * abort/reset), then this function should return SUCCESS. + * abort/reset), this function should return SUCCESS. **/ int scsi_decide_disposition(struct scsi_cmnd *scmd) { @@ -1214,11 +1213,11 @@ __FUNCTION__)); return SUCCESS; } + /* * first check the host byte, to see if there is anything in there * that would indicate what we need to do. */ - switch (host_byte(scmd->result)) { case DID_PASSTHROUGH: /* @@ -1296,11 +1295,11 @@ /* * next, check the message byte. */ - if (msg_byte(scmd->result) != COMMAND_COMPLETE) { + if (msg_byte(scmd->result) != COMMAND_COMPLETE) return FAILED; - } + /* - * now, check the status byte to see if this indicates anything special. + * check the status byte to see if this indicates anything special. */ switch (status_byte(scmd->result)) { case QUEUE_FULL: @@ -1321,10 +1320,11 @@ return SUCCESS; case CHECK_CONDITION: rtn = scsi_check_sense(scmd); - if (rtn == NEEDS_RETRY) { + if (rtn == NEEDS_RETRY) goto maybe_retry; - } - return rtn; + /* if rtn == FAILED, we have no sense information */ + /* was: return rtn; */ + return SUCCESS; case CONDITION_GOOD: case INTERMEDIATE_GOOD: case INTERMEDIATE_C_GOOD: @@ -1490,9 +1490,9 @@ struct list_head *work_q, struct list_head *done_q) { - if (scsi_eh_bus_device_reset(shost, work_q, done_q)) - if (scsi_eh_bus_reset(shost, work_q, done_q)) - if (scsi_eh_host_reset(work_q, done_q)) + if (!scsi_eh_bus_device_reset(shost, work_q, done_q)) + if (!scsi_eh_bus_reset(shost, work_q, done_q)) + if (!scsi_eh_host_reset(work_q, done_q)) scsi_eh_offline_sdevs(work_q, done_q); } diff -Nru a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c --- a/drivers/scsi/scsi_scan.c Fri Feb 28 12:45:00 2003 +++ b/drivers/scsi/scsi_scan.c Thu Mar 6 16:02:09 2003 @@ -960,7 +960,6 @@ SCSI_LOG_SCAN_BUS(3, printk(KERN_INFO "scsi scan: host %d channel %d" " id %d lun %d name/id: '%s'\n", sdev->host->host_no, sdev->channel, sdev->id, sdev->lun, sdev->sdev_driverfs_dev.name)); - return; } /** diff -Nru a/drivers/serial/21285.c b/drivers/serial/21285.c --- a/drivers/serial/21285.c Sat Feb 22 09:59:10 2003 +++ b/drivers/serial/21285.c Thu Mar 6 09:27:42 2003 @@ -501,11 +501,12 @@ .index = -1, }; -void __init rs285_console_init(void) +static void __init rs285_console_init(void) { serial21285_setup_ports(); register_console(&serial21285_console); } +console_initcall(rs285_console_init); #define SERIAL_21285_CONSOLE &serial21285_console #else diff -Nru a/drivers/serial/68328serial.c b/drivers/serial/68328serial.c --- a/drivers/serial/68328serial.c Sun Nov 17 23:09:28 2002 +++ b/drivers/serial/68328serial.c Fri Feb 14 15:26:21 2003 @@ -1691,8 +1691,9 @@ }; -void m68328_console_init(void) +static void __init m68328_console_init(void) { register_console(&m68328_driver); } +console_initcall(m68328_console_init); diff -Nru a/drivers/serial/8250.c b/drivers/serial/8250.c --- a/drivers/serial/8250.c Tue Feb 25 18:39:37 2003 +++ b/drivers/serial/8250.c Thu Mar 6 09:28:59 2003 @@ -1982,11 +1982,12 @@ .index = -1, }; -void __init serial8250_console_init(void) +static void __init serial8250_console_init(void) { serial8250_isa_init_ports(); register_console(&serial8250_console); } +console_initcall(serial8250_console_init); #define SERIAL8250_CONSOLE &serial8250_console #else diff -Nru a/drivers/serial/amba.c b/drivers/serial/amba.c --- a/drivers/serial/amba.c Sat Feb 22 09:59:10 2003 +++ b/drivers/serial/amba.c Thu Mar 6 09:28:07 2003 @@ -705,10 +705,11 @@ .index = -1, }; -void __init ambauart_console_init(void) +static void __init ambauart_console_init(void) { register_console(&amba_console); } +console_initcall(ambauart_console_init); #define AMBA_CONSOLE &amba_console #else diff -Nru a/drivers/serial/anakin.c b/drivers/serial/anakin.c --- a/drivers/serial/anakin.c Sat Feb 22 09:59:10 2003 +++ b/drivers/serial/anakin.c Thu Mar 6 09:28:07 2003 @@ -502,11 +502,12 @@ .index = -1, }; -void __init +static void __init anakin_console_init(void) { register_console(&anakin_console); } +console_initcall(anakin_console_init); #define ANAKIN_CONSOLE &anakin_console #else diff -Nru a/drivers/serial/clps711x.c b/drivers/serial/clps711x.c --- a/drivers/serial/clps711x.c Sat Feb 22 09:59:10 2003 +++ b/drivers/serial/clps711x.c Thu Mar 6 09:28:07 2003 @@ -567,10 +567,11 @@ .index = -1, }; -void __init clps711xuart_console_init(void) +static void __init clps711xuart_console_init(void) { register_console(&clps711x_console); } +console_initcall(clps711xuart_console_init); #define CLPS711X_CONSOLE &clps711x_console #else diff -Nru a/drivers/serial/core.c b/drivers/serial/core.c --- a/drivers/serial/core.c Mon Feb 24 15:32:22 2003 +++ b/drivers/serial/core.c Thu Mar 6 09:28:07 2003 @@ -1890,42 +1890,6 @@ return 0; } - -extern void ambauart_console_init(void); -extern void anakin_console_init(void); -extern void clps711xuart_console_init(void); -extern void rs285_console_init(void); -extern void sa1100_rs_console_init(void); -extern void serial8250_console_init(void); -extern void uart00_console_init(void); - -/* - * Central "initialise all serial consoles" container. Needs to be killed. - */ -void __init uart_console_init(void) -{ -#ifdef CONFIG_SERIAL_AMBA_CONSOLE - ambauart_console_init(); -#endif -#ifdef CONFIG_SERIAL_ANAKIN_CONSOLE - anakin_console_init(); -#endif -#ifdef CONFIG_SERIAL_CLPS711X_CONSOLE - clps711xuart_console_init(); -#endif -#ifdef CONFIG_SERIAL_21285_CONSOLE - rs285_console_init(); -#endif -#ifdef CONFIG_SERIAL_SA1100_CONSOLE - sa1100_rs_console_init(); -#endif -#ifdef CONFIG_SERIAL_8250_CONSOLE - serial8250_console_init(); -#endif -#ifdef CONFIG_SERIAL_UART00_CONSOLE - uart00_console_init(); -#endif -} #endif /* CONFIG_SERIAL_CORE_CONSOLE */ #ifdef CONFIG_PM diff -Nru a/drivers/serial/mcfserial.c b/drivers/serial/mcfserial.c --- a/drivers/serial/mcfserial.c Tue Feb 18 02:28:34 2003 +++ b/drivers/serial/mcfserial.c Mon Mar 3 12:25:14 2003 @@ -1853,9 +1853,11 @@ .index = -1, }; -void __init mcfrs_console_init(void) +static void __init mcfrs_console_init(void) { register_console(&mcfrs_console); } + +console_initcall(mcfrs_console_init); /****************************************************************************/ diff -Nru a/drivers/serial/sa1100.c b/drivers/serial/sa1100.c --- a/drivers/serial/sa1100.c Tue Feb 25 18:39:37 2003 +++ b/drivers/serial/sa1100.c Thu Mar 6 09:28:07 2003 @@ -835,11 +835,12 @@ .index = -1, }; -void __init sa1100_rs_console_init(void) +static void __init sa1100_rs_console_init(void) { sa1100_init_ports(); register_console(&sa1100_console); } +console_initcall(sa1100_rs_console_init); #define SA1100_CONSOLE &sa1100_console #else diff -Nru a/drivers/serial/uart00.c b/drivers/serial/uart00.c --- a/drivers/serial/uart00.c Sun Feb 16 11:33:25 2003 +++ b/drivers/serial/uart00.c Thu Mar 6 09:30:07 2003 @@ -645,10 +645,11 @@ .index = 0, }; -void __init uart00_console_init(void) +static void __init uart00_console_init(void) { register_console(&uart00_console); } +console_initcall(uart00_console_init); #define UART00_CONSOLE &uart00_console #else diff -Nru a/drivers/sgi/char/sgiserial.c b/drivers/sgi/char/sgiserial.c --- a/drivers/sgi/char/sgiserial.c Sun Nov 17 23:09:37 2002 +++ b/drivers/sgi/char/sgiserial.c Fri Feb 14 15:27:26 2003 @@ -2269,8 +2269,10 @@ /* * Register console. */ -void __init sgi_serial_console_init(void) +static void __init sgi_serial_console_init(void) { register_console(&sgi_console_driver); } +console_initcall(sgi_serial_console_init); + __initcall(rs_init); diff -Nru a/drivers/usb/class/usb-midi.h b/drivers/usb/class/usb-midi.h --- a/drivers/usb/class/usb-midi.h Fri Feb 21 03:06:06 2003 +++ b/drivers/usb/class/usb-midi.h Wed Mar 5 03:07:27 2003 @@ -54,6 +54,10 @@ #define USB_VENDOR_ID_STEINBERG 0x0763 #define USBMIDI_STEINBERG_USB2MIDI 0x1001 +/* Mark of the Unicorn MIDI Devices */ +#define USB_VENDOR_ID_MOTU 0x07fd +#define USBMIDI_MOTU_FASTLANE 0x0001 + /* ------------------------------------------------------------------------- */ /* Supported devices */ @@ -101,8 +105,15 @@ { /* Roland SC8850 */ "Roland SC8850", USB_VENDOR_ID_ROLAND, USBMIDI_ROLAND_SC8850, 2, -1, - { { 0x81, 15 }, {-1, -1} }, /** cables 0,1,2, and 3 **/ - { { 0x01, 15 }, {-1, -1} }, + { { 0x81, 0x3f }, {-1, -1} }, + { { 0x01, 0x3f }, {-1, -1} }, + }, + + { /* Roland SC8820 */ + "Roland SC8820", + USB_VENDOR_ID_ROLAND, USBMIDI_ROLAND_SC8820, 2, -1, + { { 0x81, 0x13 }, {-1, -1} }, + { { 0x01, 0x13 }, {-1, -1} }, }, { /* Roland SC8820 */ @@ -123,6 +134,12 @@ USB_VENDOR_ID_ROLAND, USBMIDI_ROLAND_PC300, 2, -1, { { 0x81, 1 }, {-1, -1} }, { { 0x01, 1 }, {-1, -1} }, + }, + { /* MOTU Fastlane USB */ + "MOTU Fastlane USB", + USB_VENDOR_ID_MOTU, USBMIDI_MOTU_FASTLANE, 1, 0, + { { 0x82, 3 }, {-1, -1} }, + { { 0x02, 3 }, {-1, -1} }, } }; @@ -138,7 +155,9 @@ { USB_DEVICE( USB_VENDOR_ID_ROLAND, USBMIDI_ROLAND_UA100G ) }, { USB_DEVICE( USB_VENDOR_ID_ROLAND, USBMIDI_ROLAND_PC300 ) }, { USB_DEVICE( USB_VENDOR_ID_ROLAND, USBMIDI_ROLAND_SC8850 ) }, + { USB_DEVICE( USB_VENDOR_ID_ROLAND, USBMIDI_ROLAND_SC8820 ) }, { USB_DEVICE( USB_VENDOR_ID_YAMAHA, USBMIDI_YAMAHA_MU1000 ) }, + { USB_DEVICE( USB_VENDOR_ID_MOTU, USBMIDI_MOTU_FASTLANE ) }, /* { USB_DEVICE( USB_VENDOR_ID_STEINBERG, USBMIDI_STEINBERG_USB2MIDI ) },*/ { } /* Terminating entry */ }; diff -Nru a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c --- a/drivers/usb/core/hub.c Wed Feb 26 03:17:57 2003 +++ b/drivers/usb/core/hub.c Wed Mar 5 07:24:34 2003 @@ -876,6 +876,7 @@ } hub->children[port] = dev; + dev->state = USB_STATE_POWERED; /* Reset the device, and detect its speed */ if (usb_hub_port_reset(hub, port, dev, delay)) { diff -Nru a/drivers/usb/core/message.c b/drivers/usb/core/message.c --- a/drivers/usb/core/message.c Sat Feb 15 04:07:33 2003 +++ b/drivers/usb/core/message.c Wed Mar 5 07:24:34 2003 @@ -904,17 +904,29 @@ break; } } - if (!cp) { + if ((!cp && configuration != 0) || (cp && configuration == 0)) { warn("selecting invalid configuration %d", configuration); return -EINVAL; } + /* if it's already configured, clear out old state first. */ + if (dev->state != USB_STATE_ADDRESS) { + /* FIXME unbind drivers from all "old" interfaces. + * handshake with hcd to reset cached hc endpoint state. + */ + } + if ((ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), USB_REQ_SET_CONFIGURATION, 0, configuration, 0, NULL, 0, HZ * USB_CTRL_SET_TIMEOUT)) < 0) return ret; - + if (configuration) + dev->state = USB_STATE_CONFIGURED; + else + dev->state = USB_STATE_ADDRESS; dev->actconfig = cp; + + /* reset more hc/hcd endpoint state */ dev->toggle[0] = 0; dev->toggle[1] = 0; usb_set_maxpacket(dev); diff -Nru a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c --- a/drivers/usb/core/urb.c Tue Feb 18 07:50:22 2003 +++ b/drivers/usb/core/urb.c Thu Mar 6 07:46:03 2003 @@ -195,7 +195,9 @@ if (!urb || urb->hcpriv || !urb->complete) return -EINVAL; - if (!(dev = urb->dev) || !dev->present || !dev->bus || dev->devnum <= 0) + if (!(dev = urb->dev) || + (dev->state < USB_STATE_DEFAULT) || + (!dev->bus) || (dev->devnum <= 0)) return -ENODEV; if (!(op = dev->bus->op) || !op->submit_urb) return -ENODEV; @@ -211,6 +213,9 @@ temp = usb_pipetype (pipe); is_out = usb_pipeout (pipe); + if (!usb_pipecontrol (pipe) && dev->state < USB_STATE_CONFIGURED) + return -ENODEV; + /* (actually HCDs may need to duplicate this, endpoint might yet * stall due to queued bulk/intr transactions that complete after * we check) @@ -376,7 +381,16 @@ */ int usb_unlink_urb(struct urb *urb) { - if (urb && urb->dev && urb->dev->present && urb->dev->bus && urb->dev->bus->op) + /* FIXME + * We should not care about the state here, but the host controllers + * die a horrible death if we submit a urb for a device that has been + * physically removed. + */ + if (urb && + urb->dev && + (urb->dev->state >= USB_STATE_DEFAULT) && + urb->dev->bus && + urb->dev->bus->op) return urb->dev->bus->op->unlink_urb(urb); else return -ENODEV; diff -Nru a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c --- a/drivers/usb/core/usb.c Tue Feb 18 07:50:22 2003 +++ b/drivers/usb/core/usb.c Wed Mar 5 07:29:53 2003 @@ -679,7 +679,7 @@ memset(dev, 0, sizeof(*dev)); device_initialize(&dev->dev); - dev->present = 1; + dev->state = USB_STATE_ATTACHED; usb_bus_get(bus); @@ -828,6 +828,11 @@ *pdev = NULL; + /* mark the device as inactive, so any further urb submissions for + * this device will fail. + */ + dev->state = USB_STATE_NOTATTACHED; + dev_info (&dev->dev, "USB disconnect, address %d\n", dev->devnum); /* Free up all the children before we remove this device */ @@ -855,10 +860,6 @@ } device_unregister(&dev->dev); - /* mark the device as not present so any further urb submissions for - * this device will fail. */ - dev->present = 0; - /* Decrement the reference count, it'll auto free everything when */ /* it hits 0 which could very well be now */ usb_put_dev(dev); @@ -906,9 +907,17 @@ // otherwise used internally, for usb_new_device() int usb_set_address(struct usb_device *dev) { - return usb_control_msg(dev, usb_snddefctrl(dev), USB_REQ_SET_ADDRESS, - // FIXME USB_CTRL_SET_TIMEOUT - 0, dev->devnum, 0, NULL, 0, HZ * USB_CTRL_GET_TIMEOUT); + int retval; + + if (dev->devnum == 0) + return -EINVAL; + if (dev->state != USB_STATE_DEFAULT && dev->state != USB_STATE_ADDRESS) + return -EINVAL; + retval = usb_control_msg(dev, usb_snddefctrl(dev), USB_REQ_SET_ADDRESS, + 0, dev->devnum, 0, NULL, 0, HZ * USB_CTRL_SET_TIMEOUT); + if (retval == 0) + dev->state = USB_STATE_ADDRESS; + return retval; } @@ -1014,7 +1023,8 @@ /* dma masks come from the controller; readonly, except to hcd */ dev->dev.dma_mask = parent->dma_mask; - /* USB device state == default ... it's not usable yet */ + /* it's not usable yet */ + dev->state = USB_STATE_DEFAULT; /* USB 2.0 section 5.5.3 talks about ep0 maxpacket ... * it's fixed size except for full speed devices. @@ -1049,6 +1059,7 @@ if (err < 0) { dev_err(&dev->dev, "USB device not accepting new address=%d (error=%d)\n", dev->devnum, err); + dev->state = USB_STATE_DEFAULT; clear_bit(dev->devnum, dev->bus->devmap.devicemap); dev->devnum = -1; return 1; diff -Nru a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c --- a/drivers/usb/serial/io_edgeport.c Tue Jan 7 06:50:11 2003 +++ b/drivers/usb/serial/io_edgeport.c Wed Mar 5 03:35:49 2003 @@ -522,7 +522,7 @@ case EDGE_DOWNLOAD_FILE_I930: BootMajorVersion = BootCodeImageVersion_GEN1.MajorVersion; BootMinorVersion = BootCodeImageVersion_GEN1.MinorVersion; - BootBuildNumber = BootCodeImageVersion_GEN1.BuildNumber; + BootBuildNumber = cpu_to_le16(BootCodeImageVersion_GEN1.BuildNumber); BootImage = &BootCodeImage_GEN1[0]; BootSize = sizeof( BootCodeImage_GEN1 ); break; @@ -530,7 +530,7 @@ case EDGE_DOWNLOAD_FILE_80251: BootMajorVersion = BootCodeImageVersion_GEN2.MajorVersion; BootMinorVersion = BootCodeImageVersion_GEN2.MinorVersion; - BootBuildNumber = BootCodeImageVersion_GEN2.BuildNumber; + BootBuildNumber = cpu_to_le16(BootCodeImageVersion_GEN2.BuildNumber); BootImage = &BootCodeImage_GEN2[0]; BootSize = sizeof( BootCodeImage_GEN2 ); break; @@ -542,26 +542,26 @@ // Check Boot Image Version BootCurVer = (edge_serial->boot_descriptor.MajorVersion << 24) + (edge_serial->boot_descriptor.MinorVersion << 16) + - edge_serial->boot_descriptor.BuildNumber; + le16_to_cpu(edge_serial->boot_descriptor.BuildNumber); BootNewVer = (BootMajorVersion << 24) + (BootMinorVersion << 16) + - BootBuildNumber; + le16_to_cpu(BootBuildNumber); dbg("Current Boot Image version %d.%d.%d", edge_serial->boot_descriptor.MajorVersion, edge_serial->boot_descriptor.MinorVersion, - edge_serial->boot_descriptor.BuildNumber); + le16_to_cpu(edge_serial->boot_descriptor.BuildNumber)); if (BootNewVer > BootCurVer) { dbg("**Update Boot Image from %d.%d.%d to %d.%d.%d", edge_serial->boot_descriptor.MajorVersion, edge_serial->boot_descriptor.MinorVersion, - edge_serial->boot_descriptor.BuildNumber, + le16_to_cpu(edge_serial->boot_descriptor.BuildNumber), BootMajorVersion, BootMinorVersion, - BootBuildNumber); + le16_to_cpu(BootBuildNumber)); dbg("Downloading new Boot Image"); @@ -570,12 +570,12 @@ for (;;) { record = (struct edge_firmware_image_record *)firmware; - response = rom_write (edge_serial->serial, record->ExtAddr, record->Addr, record->Len, &record->Data[0]); + response = rom_write (edge_serial->serial, le16_to_cpu(record->ExtAddr), le16_to_cpu(record->Addr), le16_to_cpu(record->Len), &record->Data[0]); if (response < 0) { - dev_err(&edge_serial->serial->dev->dev, "sram_write failed (%x, %x, %d)\n", record->ExtAddr, record->Addr, record->Len); + dev_err(&edge_serial->serial->dev->dev, "rom_write failed (%x, %x, %d)\n", le16_to_cpu(record->ExtAddr), le16_to_cpu(record->Addr), le16_to_cpu(record->Len)); break; } - firmware += sizeof (struct edge_firmware_image_record) + record->Len; + firmware += sizeof (struct edge_firmware_image_record) + le16_to_cpu(record->Len); if (firmware >= &BootImage[BootSize]) { break; } @@ -678,12 +678,12 @@ if (edge_serial->serial->dev->descriptor.idProduct & ION_DEVICE_ID_GENERATION_2) { product_info->FirmwareMajorVersion = OperationalCodeImageVersion_GEN2.MajorVersion; product_info->FirmwareMinorVersion = OperationalCodeImageVersion_GEN2.MinorVersion; - product_info->FirmwareBuildNumber = OperationalCodeImageVersion_GEN2.BuildNumber; + product_info->FirmwareBuildNumber = cpu_to_le16(OperationalCodeImageVersion_GEN2.BuildNumber); product_info->iDownloadFile = EDGE_DOWNLOAD_FILE_80251; } else { product_info->FirmwareMajorVersion = OperationalCodeImageVersion_GEN1.MajorVersion; product_info->FirmwareMinorVersion = OperationalCodeImageVersion_GEN1.MinorVersion; - product_info->FirmwareBuildNumber = OperationalCodeImageVersion_GEN1.BuildNumber; + product_info->FirmwareBuildNumber = cpu_to_le16(OperationalCodeImageVersion_GEN1.BuildNumber); product_info->iDownloadFile = EDGE_DOWNLOAD_FILE_I930; } @@ -729,10 +729,10 @@ dbg(" BoardRev %x", product_info->BoardRev); dbg(" BootMajorVersion %d.%d.%d", product_info->BootMajorVersion, product_info->BootMinorVersion, - product_info->BootBuildNumber); + le16_to_cpu(product_info->BootBuildNumber)); dbg(" FirmwareMajorVersion %d.%d.%d", product_info->FirmwareMajorVersion, product_info->FirmwareMinorVersion, - product_info->FirmwareBuildNumber); + le16_to_cpu(product_info->FirmwareBuildNumber)); dbg(" ManufactureDescDate %d/%d/%d", product_info->ManufactureDescDate[0], product_info->ManufactureDescDate[1], product_info->ManufactureDescDate[2]+1900); @@ -2326,7 +2326,7 @@ __u16 current_length; unsigned char *transfer_buffer; -// dbg("%s - %x, %x, %d", __FUNCTION__, extAddr, addr, length); + dbg("%s - %x, %x, %d", __FUNCTION__, extAddr, addr, length); transfer_buffer = kmalloc (64, GFP_KERNEL); if (!transfer_buffer) { @@ -2811,12 +2811,13 @@ * Turns a string from Unicode into ASCII. * Doesn't do a good job with any characters that are outside the normal * ASCII range, but it's only for debugging... + * NOTE: expects the unicode in LE format ****************************************************************************/ static void unicode_to_ascii (char *string, short *unicode, int unicode_size) { int i; for (i = 0; i < unicode_size; ++i) { - string[i] = (char)(unicode[i]); + string[i] = (char)(le16_to_cpu(unicode[i])); } string[unicode_size] = 0x00; } @@ -2880,11 +2881,11 @@ dev_err(&edge_serial->serial->dev->dev, "error in getting boot descriptor\n"); } else { dbg("**Boot Descriptor:"); - dbg(" BootCodeLength: %d", edge_serial->boot_descriptor.BootCodeLength); + dbg(" BootCodeLength: %d", le16_to_cpu(edge_serial->boot_descriptor.BootCodeLength)); dbg(" MajorVersion: %d", edge_serial->boot_descriptor.MajorVersion); dbg(" MinorVersion: %d", edge_serial->boot_descriptor.MinorVersion); - dbg(" BuildNumber: %d", edge_serial->boot_descriptor.BuildNumber); - dbg(" Capabilities: 0x%x", edge_serial->boot_descriptor.Capabilities); + dbg(" BuildNumber: %d", le16_to_cpu(edge_serial->boot_descriptor.BuildNumber)); + dbg(" Capabilities: 0x%x", le16_to_cpu(edge_serial->boot_descriptor.Capabilities)); dbg(" UConfig0: %d", edge_serial->boot_descriptor.UConfig0); dbg(" UConfig1: %d", edge_serial->boot_descriptor.UConfig1); } @@ -2936,12 +2937,12 @@ for (;;) { record = (struct edge_firmware_image_record *)firmware; - response = sram_write (edge_serial->serial, record->ExtAddr, record->Addr, record->Len, &record->Data[0]); + response = sram_write (edge_serial->serial, le16_to_cpu(record->ExtAddr), le16_to_cpu(record->Addr), le16_to_cpu(record->Len), &record->Data[0]); if (response < 0) { - dev_err(&edge_serial->serial->dev->dev, "sram_write failed (%x, %x, %d)\n", record->ExtAddr, record->Addr, record->Len); + dev_err(&edge_serial->serial->dev->dev, "sram_write failed (%x, %x, %d)\n", le16_to_cpu(record->ExtAddr), le16_to_cpu(record->Addr), record->Len); break; } - firmware += sizeof (struct edge_firmware_image_record) + record->Len; + firmware += sizeof (struct edge_firmware_image_record) + le16_to_cpu(record->Len); if (firmware >= &FirmwareImage[ImageSize]) { break; } diff -Nru a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c --- a/drivers/usb/serial/pl2303.c Fri Feb 21 09:00:54 2003 +++ b/drivers/usb/serial/pl2303.c Wed Mar 5 04:06:21 2003 @@ -75,6 +75,7 @@ { USB_DEVICE(MA620_VENDOR_ID, MA620_PRODUCT_ID) }, { USB_DEVICE(RATOC_VENDOR_ID, RATOC_PRODUCT_ID) }, { USB_DEVICE(TRIPP_VENDOR_ID, TRIPP_PRODUCT_ID) }, + { USB_DEVICE(RADIOSHACK_VENDOR_ID, RADIOSHACK_PRODUCT_ID) }, { } /* Terminating entry */ }; diff -Nru a/drivers/usb/serial/pl2303.h b/drivers/usb/serial/pl2303.h --- a/drivers/usb/serial/pl2303.h Tue Feb 4 06:10:14 2003 +++ b/drivers/usb/serial/pl2303.h Wed Mar 5 04:06:21 2003 @@ -31,3 +31,6 @@ #define TRIPP_VENDOR_ID 0x2478 #define TRIPP_PRODUCT_ID 0x2008 + +#define RADIOSHACK_VENDOR_ID 0x1453 +#define RADIOSHACK_PRODUCT_ID 0x4026 diff -Nru a/drivers/usb/serial/visor.c b/drivers/usb/serial/visor.c --- a/drivers/usb/serial/visor.c Fri Feb 21 09:00:45 2003 +++ b/drivers/usb/serial/visor.c Wed Mar 5 03:04:53 2003 @@ -12,6 +12,9 @@ * * See Documentation/usb/usb-serial.txt for more information on using this driver * + * (03/05/2003) gkh + * Think Treo support is now working. + * * (04/03/2002) gkh * Added support for the Sony OS 4.1 devices. Thanks to Hiroyuki ARAKI * for the information. @@ -156,7 +159,7 @@ /* * Version Information */ -#define DRIVER_VERSION "v2.0" +#define DRIVER_VERSION "v2.1" #define DRIVER_AUTHOR "Greg Kroah-Hartman " #define DRIVER_DESC "USB HandSpring Visor, Palm m50x, Sony Clié driver" @@ -177,6 +180,7 @@ static void visor_read_bulk_callback (struct urb *urb, struct pt_regs *regs); static void visor_read_int_callback (struct urb *urb, struct pt_regs *regs); static int clie_3_5_startup (struct usb_serial *serial); +static int treo_attach (struct usb_serial *serial); static int palm_os_3_probe (struct usb_serial *serial, const struct usb_device_id *id); static int palm_os_4_probe (struct usb_serial *serial, const struct usb_device_id *id); @@ -262,6 +266,7 @@ .close = visor_close, .throttle = visor_throttle, .unthrottle = visor_unthrottle, + .attach = treo_attach, .probe = visor_probe, .calc_num_ports = visor_calc_num_ports, .shutdown = visor_shutdown, @@ -797,6 +802,48 @@ if (result != 1) { dev_err(dev, "%s: get interface number bad return length: %d\n", __FUNCTION__, result); return -EIO; + } + + return 0; +} + +static int treo_attach (struct usb_serial *serial) +{ + struct usb_serial_port *port; + int i; + + /* Only do this endpoint hack for the Handspring devices with + * interrupt in endpoints, which for now are the Treo devices. */ + if ((serial->dev->descriptor.idVendor != HANDSPRING_VENDOR_ID) || + (serial->num_interrupt_in == 0)) + return 0; + + dbg("%s", __FUNCTION__); + + /* Ok, this is pretty ugly, but these devices want to use the + * interrupt endpoint as paired up with a bulk endpoint for a + * "virtual serial port". So let's force the endpoints to be + * where we want them to be. */ + for (i = serial->num_bulk_in; i < serial->num_ports; ++i) { + port = &serial->port[i]; + port->read_urb = serial->port[0].read_urb; + port->bulk_in_endpointAddress = serial->port[0].bulk_in_endpointAddress; + port->bulk_in_buffer = serial->port[0].bulk_in_buffer; + } + + for (i = serial->num_bulk_out; i < serial->num_ports; ++i) { + port = &serial->port[i]; + port->write_urb = serial->port[0].write_urb; + port->bulk_out_size = serial->port[0].bulk_out_size; + port->bulk_out_endpointAddress = serial->port[0].bulk_out_endpointAddress; + port->bulk_out_buffer = serial->port[0].bulk_out_buffer; + } + + for (i = serial->num_interrupt_in; i < serial->num_ports; ++i) { + port = &serial->port[i]; + port->interrupt_in_urb = serial->port[0].interrupt_in_urb; + port->interrupt_in_endpointAddress = serial->port[0].interrupt_in_endpointAddress; + port->interrupt_in_buffer = serial->port[0].interrupt_in_buffer; } return 0; diff -Nru a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c --- a/drivers/usb/storage/transport.c Wed Jan 22 03:55:34 2003 +++ b/drivers/usb/storage/transport.c Tue Mar 4 01:58:24 2003 @@ -582,20 +582,26 @@ unsigned short old_sg; unsigned old_request_bufflen; unsigned char old_sc_data_direction; + unsigned char old_cmd_len; unsigned char old_cmnd[MAX_COMMAND_SIZE]; US_DEBUGP("Issuing auto-REQUEST_SENSE\n"); /* save the old command */ memcpy(old_cmnd, srb->cmnd, MAX_COMMAND_SIZE); + old_cmd_len = srb->cmd_len; /* set the command and the LUN */ + memset(srb->cmnd, 0, MAX_COMMAND_SIZE); srb->cmnd[0] = REQUEST_SENSE; srb->cmnd[1] = old_cmnd[1] & 0xE0; - srb->cmnd[2] = 0; - srb->cmnd[3] = 0; srb->cmnd[4] = 18; - srb->cmnd[5] = 0; + + /* FIXME: we must do the protocol translation here */ + if (us->subclass == US_SC_RBC || us->subclass == US_SC_SCSI) + srb->cmd_len = 6; + else + srb->cmd_len = 12; /* set the transfer direction */ old_sc_data_direction = srb->sc_data_direction; @@ -621,6 +627,7 @@ srb->request_bufflen = old_request_bufflen; srb->use_sg = old_sg; srb->sc_data_direction = old_sc_data_direction; + srb->cmd_len = old_cmd_len; memcpy(srb->cmnd, old_cmnd, MAX_COMMAND_SIZE); if (atomic_read(&us->sm_state) == US_STATE_ABORTING) { diff -Nru a/drivers/video/bw2.c b/drivers/video/bw2.c --- a/drivers/video/bw2.c Thu Feb 27 12:32:45 2003 +++ b/drivers/video/bw2.c Tue Mar 4 09:55:26 2003 @@ -33,11 +33,11 @@ * Local functions. */ -static int bw2_check_var(struct fb_var_screeninfo *, struct fb_info *); -static int bw2_set_par(struct fb_info *); static int bw2_blank(int, struct fb_info *); static int bw2_mmap(struct fb_info *, struct file *, struct vm_area_struct *); +static int bw2_ioctl(struct inode *, struct file *, unsigned int, + unsigned long, struct fb_info *); /* * Frame buffer operations @@ -45,13 +45,12 @@ static struct fb_ops bw2_ops = { .owner = THIS_MODULE, - .fb_check_var = bw2_check_var, - .fb_set_par = bw2_set_par, .fb_blank = bw2_blank, .fb_fillrect = cfb_fillrect, .fb_copyarea = cfb_copyarea, .fb_imageblit = cfb_imageblit, .fb_mmap = bw2_mmap, + .fb_ioctl = bw2_ioctl, .fb_cursor = soft_cursor, }; @@ -124,39 +123,6 @@ }; /** - * bw2_check_var - Optional function. Validates a var passed in. - * @var: frame buffer variable screen structure - * @info: frame buffer structure that represents a single frame buffer - */ -static int bw2_check_var(struct fb_var_screeninfo *var, struct fb_info *info) -{ - if (var->bits_per_pixel != 8) - return -EINVAL; - - if (var->xres_virtual != var->xres || var->yres_virtual != var->yres) - return -EINVAL; - if (var->nonstd) - return -EINVAL; - if ((var->vmode & FB_VMODE_MASK) != FB_VMODE_NONINTERLACED) - return -EINVAL; - - if (var->xres != info->var.xres || var->yres != info->var.yres) - return -EINVAL; - - return 0; -} - -/** - * bw2_set_par - Optional function. Alters the hardware state. - * @info: frame buffer structure that represents a single frame buffer - */ -static int -bw2_set_par(struct fb_info *info) -{ - return 0; -} - -/** * bw2_blank - Optional function. Blanks the display. * @blank_mode: the blank mode we want. * @info: frame buffer structure that represents a single frame buffer @@ -212,6 +178,15 @@ vma); } +static int bw2_ioctl(struct inode *inode, struct file *file, unsigned int cmd, + unsigned long arg, struct fb_info *info) +{ + struct bw2_par *par = (struct bw2_par *) info->par; + + return sbusfb_ioctl_helper(cmd, arg, info, + FBTYPE_SUN2BW, 1, par->fbsize); +} + /* * Initialisation */ @@ -387,7 +362,6 @@ bw2_blank(0, &all->info); - bw2_set_par(&all->info); bw2_init_fix(&all->info, linebytes); if (register_framebuffer(&all->info) < 0) { diff -Nru a/drivers/video/cg14.c b/drivers/video/cg14.c --- a/drivers/video/cg14.c Sun Mar 2 22:28:03 2003 +++ b/drivers/video/cg14.c Tue Mar 4 09:55:26 2003 @@ -28,8 +28,6 @@ * Local functions. */ -static int cg14_check_var(struct fb_var_screeninfo *, struct fb_info *); -static int cg14_set_par(struct fb_info *); static int cg14_setcolreg(unsigned, unsigned, unsigned, unsigned, unsigned, struct fb_info *); @@ -43,8 +41,6 @@ static struct fb_ops cg14_ops = { .owner = THIS_MODULE, - .fb_check_var = cg14_check_var, - .fb_set_par = cg14_set_par, .fb_setcolreg = cg14_setcolreg, .fb_fillrect = cfb_fillrect, .fb_copyarea = cfb_copyarea, @@ -220,39 +216,6 @@ } /** - * cg14_check_var - Optional function. Validates a var passed in. - * @var: frame buffer variable screen structure - * @info: frame buffer structure that represents a single frame buffer - */ -static int cg14_check_var(struct fb_var_screeninfo *var, struct fb_info *info) -{ - if (var->bits_per_pixel != 8) - return -EINVAL; - - if (var->xres_virtual != var->xres || var->yres_virtual != var->yres) - return -EINVAL; - if (var->nonstd) - return -EINVAL; - if ((var->vmode & FB_VMODE_MASK) != FB_VMODE_NONINTERLACED) - return -EINVAL; - - if (var->xres != info->var.xres || var->yres != info->var.yres) - return -EINVAL; - - return 0; -} - -/** - * cg14_set_par - Optional function. Alters the hardware state. - * @info: frame buffer structure that represents a single frame buffer - */ -static int -cg14_set_par(struct fb_info *info) -{ - return 0; -} - -/** * cg14_setcolreg - Optional function. Sets a color register. * @regno: boolean, 0 copy local, 1 get_user() function * @red: frame buffer colormap structure @@ -358,7 +321,8 @@ break; default: - ret = -EINVAL; + ret = sbusfb_ioctl_helper(cmd, arg, info, + FBTYPE_MDICOLOR, 24, par->fbsize); break; }; @@ -523,7 +487,6 @@ return; } - cg14_set_par(&all->info); cg14_init_fix(&all->info, linebytes); if (register_framebuffer(&all->info) < 0) { diff -Nru a/drivers/video/cg3.c b/drivers/video/cg3.c --- a/drivers/video/cg3.c Thu Feb 27 12:32:45 2003 +++ b/drivers/video/cg3.c Tue Mar 4 09:55:26 2003 @@ -29,13 +29,13 @@ * Local functions. */ -static int cg3_check_var(struct fb_var_screeninfo *, struct fb_info *); -static int cg3_set_par(struct fb_info *); static int cg3_setcolreg(unsigned, unsigned, unsigned, unsigned, unsigned, struct fb_info *); static int cg3_blank(int, struct fb_info *); static int cg3_mmap(struct fb_info *, struct file *, struct vm_area_struct *); +static int cg3_ioctl(struct inode *, struct file *, unsigned int, + unsigned long, struct fb_info *); /* * Frame buffer operations @@ -43,14 +43,13 @@ static struct fb_ops cg3_ops = { .owner = THIS_MODULE, - .fb_check_var = cg3_check_var, - .fb_set_par = cg3_set_par, .fb_setcolreg = cg3_setcolreg, .fb_blank = cg3_blank, .fb_fillrect = cfb_fillrect, .fb_copyarea = cfb_copyarea, .fb_imageblit = cfb_imageblit, .fb_mmap = cg3_mmap, + .fb_ioctl = cg3_ioctl, .fb_cursor = soft_cursor, }; @@ -127,39 +126,6 @@ }; /** - * cg3_check_var - Optional function. Validates a var passed in. - * @var: frame buffer variable screen structure - * @info: frame buffer structure that represents a single frame buffer - */ -static int cg3_check_var(struct fb_var_screeninfo *var, struct fb_info *info) -{ - if (var->bits_per_pixel != 8) - return -EINVAL; - - if (var->xres_virtual != var->xres || var->yres_virtual != var->yres) - return -EINVAL; - if (var->nonstd) - return -EINVAL; - if ((var->vmode & FB_VMODE_MASK) != FB_VMODE_NONINTERLACED) - return -EINVAL; - - if (var->xres != info->var.xres || var->yres != info->var.yres) - return -EINVAL; - - return 0; -} - -/** - * cg3_set_par - Optional function. Alters the hardware state. - * @info: frame buffer structure that represents a single frame buffer - */ -static int -cg3_set_par(struct fb_info *info) -{ - return 0; -} - -/** * cg3_setcolreg - Optional function. Sets a color register. * @regno: boolean, 0 copy local, 1 get_user() function * @red: frame buffer colormap structure @@ -269,6 +235,15 @@ vma); } +static int cg3_ioctl(struct inode *inode, struct file *file, unsigned int cmd, + unsigned long arg, struct fb_info *info) +{ + struct cg3_par *par = (struct cg3_par *) info->par; + + return sbusfb_ioctl_helper(cmd, arg, info, + FBTYPE_SUN3COLOR, 8, par->fbsize); +} + /* * Initialisation */ @@ -445,7 +420,6 @@ return; } - cg3_set_par(&all->info); cg3_init_fix(&all->info, linebytes); if (register_framebuffer(&all->info) < 0) { diff -Nru a/drivers/video/cg6.c b/drivers/video/cg6.c --- a/drivers/video/cg6.c Thu Feb 27 12:32:45 2003 +++ b/drivers/video/cg6.c Tue Mar 4 09:55:26 2003 @@ -29,8 +29,6 @@ * Local functions. */ -static int cg6_check_var(struct fb_var_screeninfo *, struct fb_info *); -static int cg6_set_par(struct fb_info *); static int cg6_setcolreg(unsigned, unsigned, unsigned, unsigned, unsigned, struct fb_info *); static int cg6_blank(int, struct fb_info *); @@ -39,6 +37,8 @@ static void cg6_fillrect(struct fb_info *, struct fb_fillrect *); static int cg6_sync(struct fb_info *); static int cg6_mmap(struct fb_info *, struct file *, struct vm_area_struct *); +static int cg6_ioctl(struct inode *, struct file *, unsigned int, + unsigned long, struct fb_info *); /* * Frame buffer operations @@ -46,8 +46,6 @@ static struct fb_ops cg6_ops = { .owner = THIS_MODULE, - .fb_check_var = cg6_check_var, - .fb_set_par = cg6_set_par, .fb_setcolreg = cg6_setcolreg, .fb_blank = cg6_blank, .fb_fillrect = cg6_fillrect, @@ -55,6 +53,7 @@ .fb_imageblit = cg6_imageblit, .fb_sync = cg6_sync, .fb_mmap = cg6_mmap, + .fb_ioctl = cg6_ioctl, .fb_cursor = soft_cursor, }; @@ -406,39 +405,6 @@ } /** - * cg6_check_var - Optional function. Validates a var passed in. - * @var: frame buffer variable screen structure - * @info: frame buffer structure that represents a single frame buffer - */ -static int cg6_check_var(struct fb_var_screeninfo *var, struct fb_info *info) -{ - if (var->bits_per_pixel != 8) - return -EINVAL; - - if (var->xres_virtual != var->xres || var->yres_virtual != var->yres) - return -EINVAL; - if (var->nonstd) - return -EINVAL; - if ((var->vmode & FB_VMODE_MASK) != FB_VMODE_NONINTERLACED) - return -EINVAL; - - if (var->xres != info->var.xres || var->yres != info->var.yres) - return -EINVAL; - - return 0; -} - -/** - * cg6_set_par - Optional function. Alters the hardware state. - * @info: frame buffer structure that represents a single frame buffer - */ -static int -cg6_set_par(struct fb_info *info) -{ - return 0; -} - -/** * cg6_setcolreg - Optional function. Sets a color register. * @regno: boolean, 0 copy local, 1 get_user() function * @red: frame buffer colormap structure @@ -535,6 +501,15 @@ vma); } +static int cg6_ioctl(struct inode *inode, struct file *file, unsigned int cmd, + unsigned long arg, struct fb_info *info) +{ + struct cg6_par *par = (struct cg6_par *) info->par; + + return sbusfb_ioctl_helper(cmd, arg, info, + FBTYPE_SUNFAST_COLOR, 8, par->fbsize); +} + /* * Initialisation */ @@ -731,7 +706,6 @@ return; } - cg6_set_par(&all->info); cg6_init_fix(&all->info, linebytes); if (register_framebuffer(&all->info) < 0) { diff -Nru a/drivers/video/ffb.c b/drivers/video/ffb.c --- a/drivers/video/ffb.c Thu Feb 27 04:19:27 2003 +++ b/drivers/video/ffb.c Tue Mar 4 09:55:26 2003 @@ -20,6 +20,7 @@ #include #include #include +#include #include "sbuslib.h" @@ -27,8 +28,6 @@ * Local functions. */ -static int ffb_check_var(struct fb_var_screeninfo *, struct fb_info *); -static int ffb_set_par(struct fb_info *); static int ffb_setcolreg(unsigned, unsigned, unsigned, unsigned, unsigned, struct fb_info *); static int ffb_blank(int, struct fb_info *); @@ -39,6 +38,8 @@ static void ffb_copyarea(struct fb_info *, struct fb_copyarea *); static int ffb_sync(struct fb_info *); static int ffb_mmap(struct fb_info *, struct file *, struct vm_area_struct *); +static int ffb_ioctl(struct inode *, struct file *, unsigned int, + unsigned long, struct fb_info *); /* * Frame buffer operations @@ -46,8 +47,6 @@ static struct fb_ops ffb_ops = { .owner = THIS_MODULE, - .fb_check_var = ffb_check_var, - .fb_set_par = ffb_set_par, .fb_setcolreg = ffb_setcolreg, .fb_blank = ffb_blank, .fb_fillrect = ffb_fillrect, @@ -55,6 +54,7 @@ .fb_imageblit = ffb_imageblit, .fb_sync = ffb_sync, .fb_mmap = ffb_mmap, + .fb_ioctl = ffb_ioctl, /* XXX Use FFB hw cursor once fb cursor API is better understood... */ .fb_cursor = soft_cursor, @@ -673,41 +673,6 @@ } /** - * ffb_check_var - Optional function. Validates a var passed in. - * @var: frame buffer variable screen structure - * @info: frame buffer structure that represents a single frame buffer - */ -static int ffb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) -{ - if (var->bits_per_pixel != 32) - return -EINVAL; - - if (var->xres_virtual != var->xres || var->yres_virtual != var->yres) - return -EINVAL; - if (var->nonstd) - return -EINVAL; - if ((var->vmode & FB_VMODE_MASK) != FB_VMODE_NONINTERLACED) - return -EINVAL; - - if (var->xres != info->var.xres || var->yres != info->var.yres) - return -EINVAL; - - ffb_fixup_var_rgb(var); - - return 0; -} - -/** - * ffb_set_par - Optional function. Alters the hardware state. - * @info: frame buffer structure that represents a single frame buffer - */ -static int -ffb_set_par(struct fb_info *info) -{ - return 0; -} - -/** * ffb_setcolreg - Optional function. Sets a color register. * @regno: boolean, 0 copy local, 1 get_user() function * @red: frame buffer colormap structure @@ -818,6 +783,15 @@ 0, vma); } +static int ffb_ioctl(struct inode *inode, struct file *file, unsigned int cmd, + unsigned long arg, struct fb_info *info) +{ + struct ffb_par *par = (struct ffb_par *) info->par; + + return sbusfb_ioctl_helper(cmd, arg, info, + FBTYPE_CREATOR, 24, par->fbsize); +} + /* * Initialisation */ @@ -972,7 +946,6 @@ return; } - ffb_set_par(&all->info); ffb_init_fix(&all->info); if (register_framebuffer(&all->info) < 0) { diff -Nru a/drivers/video/p9100.c b/drivers/video/p9100.c --- a/drivers/video/p9100.c Sun Mar 2 22:51:11 2003 +++ b/drivers/video/p9100.c Tue Mar 4 09:55:26 2003 @@ -27,13 +27,13 @@ * Local functions. */ -static int p9100_check_var(struct fb_var_screeninfo *, struct fb_info *); -static int p9100_set_par(struct fb_info *); static int p9100_setcolreg(unsigned, unsigned, unsigned, unsigned, unsigned, struct fb_info *); static int p9100_blank(int, struct fb_info *); static int p9100_mmap(struct fb_info *, struct file *, struct vm_area_struct *); +static int p9100_ioctl(struct inode *, struct file *, unsigned int, + unsigned long, struct fb_info *); /* * Frame buffer operations @@ -41,14 +41,13 @@ static struct fb_ops p9100_ops = { .owner = THIS_MODULE, - .fb_check_var = p9100_check_var, - .fb_set_par = p9100_set_par, .fb_setcolreg = p9100_setcolreg, .fb_blank = p9100_blank, .fb_fillrect = cfb_fillrect, .fb_copyarea = cfb_copyarea, .fb_imageblit = cfb_imageblit, .fb_mmap = p9100_mmap, + .fb_ioctl = p9100_ioctl, .fb_cursor = soft_cursor, }; @@ -143,39 +142,6 @@ }; /** - * p9100_check_var - Optional function. Validates a var passed in. - * @var: frame buffer variable screen structure - * @info: frame buffer structure that represents a single frame buffer - */ -static int p9100_check_var(struct fb_var_screeninfo *var, struct fb_info *info) -{ - if (var->bits_per_pixel != 8) - return -EINVAL; - - if (var->xres_virtual != var->xres || var->yres_virtual != var->yres) - return -EINVAL; - if (var->nonstd) - return -EINVAL; - if ((var->vmode & FB_VMODE_MASK) != FB_VMODE_NONINTERLACED) - return -EINVAL; - - if (var->xres != info->var.xres || var->yres != info->var.yres) - return -EINVAL; - - return 0; -} - -/** - * p9100_set_par - Optional function. Alters the hardware state. - * @info: frame buffer structure that represents a single frame buffer - */ -static int -p9100_set_par(struct fb_info *info) -{ - return 0; -} - -/** * p9100_setcolreg - Optional function. Sets a color register. * @regno: boolean, 0 copy local, 1 get_user() function * @red: frame buffer colormap structure @@ -265,6 +231,16 @@ vma); } +static int p9100_ioctl(struct inode *inode, struct file *file, unsigned int cmd, + unsigned long arg, struct fb_info *info) +{ + struct p9100_par *par = (struct p9100_par *) info->par; + + /* Make it look like a cg3. */ + return sbusfb_ioctl_helper(cmd, arg, info, + FBTYPE_SUN3COLOR, 8, par->fbsize); +} + /* * Initialisation */ @@ -344,7 +320,6 @@ return; } - p9100_set_par(&all->info); p9100_init_fix(&all->info, linebytes); if (register_framebuffer(&all->info) < 0) { diff -Nru a/drivers/video/sa1100fb.c b/drivers/video/sa1100fb.c --- a/drivers/video/sa1100fb.c Tue Feb 25 02:46:52 2003 +++ b/drivers/video/sa1100fb.c Thu Mar 6 08:48:29 2003 @@ -1590,11 +1590,21 @@ struct sa1100fb_info *fbi = TO_INF(nb, freq_policy); struct cpufreq_policy *policy = data; - if (val == CPUFREQ_INCOMPATIBLE) { + switch (val) { + case CPUFREQ_ADJUST: + case CPUFREQ_INCOMPATIBLE: printk(KERN_DEBUG "min dma period: %d ps, " "new clock %d kHz\n", sa1100fb_min_dma_period(fbi), policy->max); /* todo: fill in min/max values */ + break; + case CPUFREQ_NOTIFY: + do {} while(0); + /* todo: panic if min/max values aren't fulfilled + * [can't really happen unless there's a bug in the + * CPU policy verififcation process * + */ + break; } return 0; } diff -Nru a/drivers/video/sbuslib.c b/drivers/video/sbuslib.c --- a/drivers/video/sbuslib.c Thu Feb 27 04:19:21 2003 +++ b/drivers/video/sbuslib.c Tue Mar 4 09:55:26 2003 @@ -9,6 +9,7 @@ #include #include +#include #include "sbuslib.h" @@ -83,3 +84,84 @@ return 0; } +EXPORT_SYMBOL(sbusfb_mmap_helper); + +int sbusfb_ioctl_helper(unsigned long cmd, unsigned long arg, + struct fb_info *info, + int type, int fb_depth, unsigned long fb_size) +{ + switch(cmd) { + case FBIOGTYPE: { + struct fbtype *f = (struct fbtype *) arg; + + if (put_user(type, &f->fb_type) || + __put_user(info->var.yres, &f->fb_height) || + __put_user(info->var.xres, &f->fb_width) || + __put_user(fb_depth, &f->fb_depth) || + __put_user(0, &f->fb_cmsize) || + __put_user(fb_size, &f->fb_cmsize)) + return -EFAULT; + return 0; + } + case FBIOPUTCMAP_SPARC: { + struct fbcmap *c = (struct fbcmap *) arg; + struct fb_cmap cmap; + u16 red, green, blue; + unsigned char *ured, *ugreen, *ublue; + int index, count, i; + + if (get_user(index, &c->index) || + __get_user(count, &c->count) || + __get_user(ured, &c->red) || + __get_user(ugreen, &c->green) || + __get_user(ublue, &c->blue)) + return -EFAULT; + + cmap.len = 1; + cmap.red = &red; + cmap.green = &green; + cmap.blue = &blue; + for (i = 0; i < count; i++) { + int err; + + if (get_user(red, &ured[i]) || + get_user(green, &ugreen[i]) || + get_user(blue, &ublue[i])) + return -EFAULT; + + cmap.start = index + i; + err = fb_set_cmap(&cmap, 0, info); + if (err) + return err; + } + return 0; + } + case FBIOGETCMAP_SPARC: { + struct fbcmap *c = (struct fbcmap *) arg; + unsigned char *ured, *ugreen, *ublue; + struct fb_cmap *cmap = &info->cmap; + int index, count, i; + + if (get_user(index, &c->index) || + __get_user(count, &c->count) || + __get_user(ured, &c->red) || + __get_user(ugreen, &c->green) || + __get_user(ublue, &c->blue)) + return -EFAULT; + + if (index + count > cmap->len) + return -EINVAL; + + for (i = 0; i < count; i++) { + if (put_user(cmap->red[index + i], &ured[i]) || + put_user(cmap->green[index + i], &ugreen[i]) || + put_user(cmap->blue[index + i], &ublue[i])) + return -EFAULT; + } + return 0; + } + default: + return -EINVAL; + }; +} +EXPORT_SYMBOL(sbusfb_ioctl_helper); diff -Nru a/drivers/video/sbuslib.h b/drivers/video/sbuslib.h --- a/drivers/video/sbuslib.h Thu Feb 27 04:19:22 2003 +++ b/drivers/video/sbuslib.h Tue Mar 4 09:55:26 2003 @@ -17,5 +17,8 @@ unsigned long physbase, unsigned long fbsize, unsigned long iospace, struct vm_area_struct *vma); +int sbusfb_ioctl_helper(unsigned long cmd, unsigned long arg, + struct fb_info *info, + int type, int fb_depth, unsigned long fb_size); #endif /* _SBUSLIB_H */ diff -Nru a/drivers/video/tcx.c b/drivers/video/tcx.c --- a/drivers/video/tcx.c Sun Mar 2 23:19:15 2003 +++ b/drivers/video/tcx.c Tue Mar 4 09:55:26 2003 @@ -29,13 +29,13 @@ * Local functions. */ -static int tcx_check_var(struct fb_var_screeninfo *, struct fb_info *); -static int tcx_set_par(struct fb_info *); static int tcx_setcolreg(unsigned, unsigned, unsigned, unsigned, unsigned, struct fb_info *); static int tcx_blank(int, struct fb_info *); static int tcx_mmap(struct fb_info *, struct file *, struct vm_area_struct *); +static int tcx_ioctl(struct inode *, struct file *, unsigned int, + unsigned long, struct fb_info *); /* * Frame buffer operations @@ -43,14 +43,13 @@ static struct fb_ops tcx_ops = { .owner = THIS_MODULE, - .fb_check_var = tcx_check_var, - .fb_set_par = tcx_set_par, .fb_setcolreg = tcx_setcolreg, .fb_blank = tcx_blank, .fb_fillrect = cfb_fillrect, .fb_copyarea = cfb_copyarea, .fb_imageblit = cfb_imageblit, .fb_mmap = tcx_mmap, + .fb_ioctl = tcx_ioctl, .fb_cursor = soft_cursor, }; @@ -155,39 +154,6 @@ } /** - * tcx_check_var - Optional function. Validates a var passed in. - * @var: frame buffer variable screen structure - * @info: frame buffer structure that represents a single frame buffer - */ -static int tcx_check_var(struct fb_var_screeninfo *var, struct fb_info *info) -{ - if (var->bits_per_pixel != 8) - return -EINVAL; - - if (var->xres_virtual != var->xres || var->yres_virtual != var->yres) - return -EINVAL; - if (var->nonstd) - return -EINVAL; - if ((var->vmode & FB_VMODE_MASK) != FB_VMODE_NONINTERLACED) - return -EINVAL; - - if (var->xres != info->var.xres || var->yres != info->var.yres) - return -EINVAL; - - return 0; -} - -/** - * tcx_set_par - Optional function. Alters the hardware state. - * @info: frame buffer structure that represents a single frame buffer - */ -static int -tcx_set_par(struct fb_info *info) -{ - return 0; -} - -/** * tcx_setcolreg - Optional function. Sets a color register. * @regno: boolean, 0 copy local, 1 get_user() function * @red: frame buffer colormap structure @@ -298,6 +264,17 @@ vma); } +static int tcx_ioctl(struct inode *inode, struct file *file, unsigned int cmd, + unsigned long arg, struct fb_info *info) +{ + struct tcx_par *par = (struct tcx_par *) info->par; + + return sbusfb_ioctl_helper(cmd, arg, info, + FBTYPE_TCXCOLOR, + (par->lowdepth ? 8 : 24), + par->fbsize); +} + /* * Initialisation */ @@ -431,7 +408,6 @@ return; } - tcx_set_par(&all->info); tcx_init_fix(&all->info, linebytes); if (register_framebuffer(&all->info) < 0) { diff -Nru a/fs/binfmt_elf.c b/fs/binfmt_elf.c --- a/fs/binfmt_elf.c Thu Feb 6 07:33:47 2003 +++ b/fs/binfmt_elf.c Thu Mar 6 08:19:16 2003 @@ -10,7 +10,7 @@ */ #include - +#include #include #include #include @@ -256,8 +256,8 @@ #ifndef elf_map -static inline unsigned long -elf_map (struct file *filep, unsigned long addr, struct elf_phdr *eppnt, int prot, int type) +static unsigned long elf_map(struct file *filep, unsigned long addr, + struct elf_phdr *eppnt, int prot, int type) { unsigned long map_addr; @@ -934,7 +934,7 @@ * * I think we should skip something. But I am not sure how. H.J. */ -static inline int maydump(struct vm_area_struct *vma) +static int maydump(struct vm_area_struct *vma) { /* * If we may not read the contents, don't allow us to dump @@ -1046,7 +1046,7 @@ return; } -static inline void fill_note(struct memelfnote *note, const char *name, int type, +static void fill_note(struct memelfnote *note, const char *name, int type, unsigned int sz, void *data) { note->name = name; @@ -1060,7 +1060,8 @@ * fill up all the fields in prstatus from the given task struct, except registers * which need to be filled up separately. */ -static inline void fill_prstatus(struct elf_prstatus *prstatus, struct task_struct *p, long signr) +static void fill_prstatus(struct elf_prstatus *prstatus, + struct task_struct *p, long signr) { prstatus->pr_info.si_signo = prstatus->pr_cursig = signr; prstatus->pr_sigpend = p->pending.signal.sig[0]; @@ -1075,7 +1076,7 @@ jiffies_to_timeval(p->cstime, &prstatus->pr_cstime); } -static inline void fill_psinfo(struct elf_prpsinfo *psinfo, struct task_struct *p) +static void fill_psinfo(struct elf_prpsinfo *psinfo, struct task_struct *p) { int i, len; @@ -1175,41 +1176,62 @@ */ static int elf_core_dump(long signr, struct pt_regs * regs, struct file * file) { +#define NUM_NOTES 5 int has_dumped = 0; mm_segment_t fs; int segs; size_t size = 0; int i; struct vm_area_struct *vma; - struct elfhdr elf; + struct elfhdr *elf = NULL; off_t offset = 0, dataoff; unsigned long limit = current->rlim[RLIMIT_CORE].rlim_cur; - int numnote = 5; - struct memelfnote notes[5]; - struct elf_prstatus prstatus; /* NT_PRSTATUS */ - struct elf_prpsinfo psinfo; /* NT_PRPSINFO */ + int numnote = NUM_NOTES; + struct memelfnote *notes = NULL; + struct elf_prstatus *prstatus = NULL; /* NT_PRSTATUS */ + struct elf_prpsinfo *psinfo = NULL; /* NT_PRPSINFO */ struct task_struct *g, *p; LIST_HEAD(thread_list); struct list_head *t; - elf_fpregset_t fpu; -#ifdef ELF_CORE_COPY_XFPREGS - elf_fpxregset_t xfpu; -#endif + elf_fpregset_t *fpu = NULL; + elf_fpxregset_t *xfpu = NULL; int thread_status_size = 0; - - /* We no longer stop all vm operations + + /* + * We no longer stop all VM operations. * - * This because those proceses that could possibly - * change map_count or the mmap / vma pages are now blocked in do_exit on current finishing + * This is because those proceses that could possibly change map_count or + * the mmap / vma pages are now blocked in do_exit on current finishing * this core dump. * * Only ptrace can touch these memory addresses, but it doesn't change - * the map_count or the pages allocated. So no possibility of crashing exists while dumping - * the mm->vm_next areas to the core file. - * + * the map_count or the pages allocated. So no possibility of crashing + * exists while dumping the mm->vm_next areas to the core file. */ - - /* capture the status of all other threads */ + + /* alloc memory for large data structures: too large to be on stack */ + elf = kmalloc(sizeof(*elf), GFP_KERNEL); + if (!elf) + goto cleanup; + prstatus = kmalloc(sizeof(*prstatus), GFP_KERNEL); + if (!prstatus) + goto cleanup; + psinfo = kmalloc(sizeof(*psinfo), GFP_KERNEL); + if (!psinfo) + goto cleanup; + notes = kmalloc(NUM_NOTES * sizeof(struct memelfnote), GFP_KERNEL); + if (!notes) + goto cleanup; + fpu = kmalloc(sizeof(*fpu), GFP_KERNEL); + if (!fpu) + goto cleanup; +#ifdef ELF_CORE_COPY_XFPREGS + xfpu = kmalloc(sizeof(*xfpu), GFP_KERNEL); + if (!xfpu) + goto cleanup; +#endif + + /* capture the status of all other threads */ if (signr) { read_lock(&tasklist_lock); do_each_thread(g,p) @@ -1226,14 +1248,14 @@ } /* now collect the dump for the current */ - memset(&prstatus, 0, sizeof(prstatus)); - fill_prstatus(&prstatus, current, signr); - elf_core_copy_regs(&prstatus.pr_reg, regs); + memset(prstatus, 0, sizeof(*prstatus)); + fill_prstatus(prstatus, current, signr); + elf_core_copy_regs(&prstatus->pr_reg, regs); segs = current->mm->map_count; /* Set up header */ - fill_elf_header(&elf, segs+1); /* including notes section*/ + fill_elf_header(elf, segs+1); /* including notes section */ has_dumped = 1; current->flags |= PF_DUMPCORE; @@ -1243,32 +1265,32 @@ * with info from their /proc. */ - fill_note(¬es[0], "CORE", NT_PRSTATUS, sizeof(prstatus), &prstatus); + fill_note(notes +0, "CORE", NT_PRSTATUS, sizeof(*prstatus), prstatus); - fill_psinfo(&psinfo, current->group_leader); - fill_note(¬es[1], "CORE", NT_PRPSINFO, sizeof(psinfo), &psinfo); + fill_psinfo(psinfo, current->group_leader); + fill_note(notes +1, "CORE", NT_PRPSINFO, sizeof(*psinfo), psinfo); - fill_note(¬es[2], "CORE", NT_TASKSTRUCT, sizeof(*current), current); + fill_note(notes +2, "CORE", NT_TASKSTRUCT, sizeof(*current), current); /* Try to dump the FPU. */ - if ((prstatus.pr_fpvalid = elf_core_copy_task_fpregs(current, &fpu))) - fill_note(¬es[3], "CORE", NT_PRFPREG, sizeof(fpu), &fpu); + if ((prstatus->pr_fpvalid = elf_core_copy_task_fpregs(current, fpu))) + fill_note(notes +3, "CORE", NT_PRFPREG, sizeof(*fpu), fpu); else --numnote; #ifdef ELF_CORE_COPY_XFPREGS - if (elf_core_copy_task_xfpregs(current, &xfpu)) - fill_note(¬es[4], "LINUX", NT_PRXFPREG, sizeof(xfpu), &xfpu); + if (elf_core_copy_task_xfpregs(current, xfpu)) + fill_note(notes +4, "LINUX", NT_PRXFPREG, sizeof(*xfpu), xfpu); else --numnote; #else - numnote --; + numnote--; #endif fs = get_fs(); set_fs(KERNEL_DS); - DUMP_WRITE(&elf, sizeof(elf)); - offset += sizeof(elf); /* Elf header */ + DUMP_WRITE(elf, sizeof(*elf)); + offset += sizeof(*elf); /* Elf header */ offset += (segs+1) * sizeof(struct elf_phdr); /* Program headers */ /* Write notes phdr entry */ @@ -1276,8 +1298,8 @@ struct elf_phdr phdr; int sz = 0; - for(i = 0; i < numnote; i++) - sz += notesize(¬es[i]); + for (i = 0; i < numnote; i++) + sz += notesize(notes + i); sz += thread_status_size; @@ -1290,7 +1312,7 @@ dataoff = offset = roundup(offset, ELF_EXEC_PAGESIZE); /* Write program headers for segments dump */ - for(vma = current->mm->mmap; vma != NULL; vma = vma->vm_next) { + for (vma = current->mm->mmap; vma != NULL; vma = vma->vm_next) { struct elf_phdr phdr; size_t sz; @@ -1312,8 +1334,8 @@ } /* write out the notes section */ - for(i = 0; i < numnote; i++) - if (!writenote(¬es[i], file)) + for (i = 0; i < numnote; i++) + if (!writenote(notes + i, file)) goto end_coredump; /* write out the thread status notes section */ @@ -1326,7 +1348,7 @@ DUMP_SEEK(dataoff); - for(vma = current->mm->mmap; vma != NULL; vma = vma->vm_next) { + for (vma = current->mm->mmap; vma != NULL; vma = vma->vm_next) { unsigned long addr; if (!maydump(vma)) @@ -1373,7 +1395,14 @@ kfree(list_entry(tmp, struct elf_thread_status, list)); } + kfree(elf); + kfree(prstatus); + kfree(psinfo); + kfree(notes); + kfree(fpu); + kfree(xfpu); return has_dumped; +#undef NUM_NOTES } #endif /* USE_ELF_CORE_DUMP */ diff -Nru a/fs/ext3/dir.c b/fs/ext3/dir.c --- a/fs/ext3/dir.c Mon Feb 24 23:13:19 2003 +++ b/fs/ext3/dir.c Tue Mar 4 08:34:07 2003 @@ -105,8 +105,10 @@ if (is_dx(inode)) { err = ext3_dx_readdir(filp, dirent, filldir); - if (err != ERR_BAD_DX_DIR) + if (err != ERR_BAD_DX_DIR) { + unlock_kernel(); return err; + } /* * We don't set the inode dirty flag since it's not * critical that it get flushed back to the disk. diff -Nru a/fs/ext3/super.c b/fs/ext3/super.c --- a/fs/ext3/super.c Mon Feb 10 19:42:01 2003 +++ b/fs/ext3/super.c Thu Mar 6 08:19:18 2003 @@ -1154,7 +1154,7 @@ if (!bh) { printk(KERN_ERR "EXT3-fs: Can't read superblock on 2nd try.\n"); - return -EINVAL; + goto failed_mount; } es = (struct ext3_super_block *)(((char *)bh->b_data) + offset); sbi->s_es = es; diff -Nru a/fs/filesystems.c b/fs/filesystems.c --- a/fs/filesystems.c Tue Mar 4 10:13:12 2003 +++ b/fs/filesystems.c Wed Mar 5 15:38:04 2003 @@ -125,9 +125,7 @@ if (!res) { /* we implicitly possess reference to @fs during registration, * so it cannot be unregister from under us. */ - if (register_fs_subsys(fs)) - printk(KERN_WARNING "Failed to register '%s' in sysfs\n", - fs->name); + register_fs_subsys(fs); } return res; } diff -Nru a/fs/inode.c b/fs/inode.c --- a/fs/inode.c Tue Mar 4 14:30:07 2003 +++ b/fs/inode.c Thu Mar 6 08:18:38 2003 @@ -453,8 +453,13 @@ } /* - * This is called from kswapd when we think we need some - * more memory. + * shrink_icache_memory() will attempt to reclaim some unused inodes. Here, + * "unused" means that no dentries are referring to the inodes: the files are + * not open and the dcache references to those inodes have already been + * reclaimed. + * + * This function is passed the number of inodes to scan, and it returns the + * total number of remaining possibly-reclaimable inodes. */ static int shrink_icache_memory(int nr, unsigned int gfp_mask) { @@ -467,7 +472,7 @@ if (gfp_mask & __GFP_FS) prune_icache(nr); } - return inodes_stat.nr_inodes; + return inodes_stat.nr_unused; } /* diff -Nru a/fs/intermezzo/cache.c b/fs/intermezzo/cache.c --- a/fs/intermezzo/cache.c Fri Dec 13 17:27:18 2002 +++ b/fs/intermezzo/cache.c Sun Feb 16 16:14:54 2003 @@ -22,7 +22,6 @@ #define __NO_VERSION__ #include -#include #include #include #include diff -Nru a/fs/intermezzo/dir.c b/fs/intermezzo/dir.c --- a/fs/intermezzo/dir.c Fri Dec 13 17:27:18 2002 +++ b/fs/intermezzo/dir.c Sun Feb 16 16:14:54 2003 @@ -22,8 +22,6 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include - #include #include #include diff -Nru a/fs/intermezzo/file.c b/fs/intermezzo/file.c --- a/fs/intermezzo/file.c Fri Dec 13 17:27:18 2002 +++ b/fs/intermezzo/file.c Sun Feb 16 16:14:54 2003 @@ -29,8 +29,6 @@ * */ -#include - #include #include #include diff -Nru a/fs/intermezzo/fileset.c b/fs/intermezzo/fileset.c --- a/fs/intermezzo/fileset.c Fri Dec 13 17:27:18 2002 +++ b/fs/intermezzo/fileset.c Sun Feb 16 16:14:54 2003 @@ -23,7 +23,6 @@ */ #define __NO_VERSION__ -#include #include #include diff -Nru a/fs/intermezzo/intermezzo_lib.h b/fs/intermezzo/intermezzo_lib.h --- a/fs/intermezzo/intermezzo_lib.h Fri Dec 13 17:17:29 2002 +++ b/fs/intermezzo/intermezzo_lib.h Sun Feb 16 16:14:54 2003 @@ -32,12 +32,6 @@ # include #endif -#undef MIN -#define MIN(a,b) (((a)<(b)) ? (a): (b)) -#undef MAX -#define MAX(a,b) (((a)>(b)) ? (a): (b)) -#define MKSTR(ptr) ((ptr))? (ptr) : "" - static inline int size_round (int val) { return (val + 3) & (~0x3); diff -Nru a/fs/intermezzo/methods.c b/fs/intermezzo/methods.c --- a/fs/intermezzo/methods.c Fri Dec 13 17:27:19 2002 +++ b/fs/intermezzo/methods.c Sun Feb 16 16:14:54 2003 @@ -25,8 +25,6 @@ * */ -#include - #include #include #include diff -Nru a/fs/intermezzo/replicator.c b/fs/intermezzo/replicator.c --- a/fs/intermezzo/replicator.c Fri Dec 13 17:27:19 2002 +++ b/fs/intermezzo/replicator.c Sun Feb 16 16:14:54 2003 @@ -25,7 +25,6 @@ #define __NO_VERSION__ #include -#include #include #include diff -Nru a/fs/intermezzo/super.c b/fs/intermezzo/super.c --- a/fs/intermezzo/super.c Sun Mar 2 18:13:30 2003 +++ b/fs/intermezzo/super.c Thu Mar 6 09:33:04 2003 @@ -26,8 +26,6 @@ static char rcsid[] __attribute ((unused)) = "$Id: super.c,v 1.4 2002/10/12 02:16:19 rread Exp $"; #define INTERMEZZO_VERSION "$Revision: 1.4 $" -#include - #include #include #include diff -Nru a/fs/namei.c b/fs/namei.c --- a/fs/namei.c Fri Feb 14 18:23:59 2003 +++ b/fs/namei.c Thu Mar 6 21:29:30 2003 @@ -342,8 +342,18 @@ * * FIXME! This could use version numbering or similar to * avoid unnecessary cache lookups. + * + * The "dcache_lock" is purely to protect the RCU list walker + * from concurrent renames at this point (we mustn't get false + * negatives from the RCU list walk here, unlike the optimistic + * fast walk). + * + * We really should do a sequence number thing to avoid this + * all. */ + spin_lock(&dcache_lock); result = d_lookup(parent, name); + spin_unlock(&dcache_lock); if (!result) { struct dentry * dentry = d_alloc(parent, name); result = ERR_PTR(-ENOMEM); diff -Nru a/fs/sysfs/mount.c b/fs/sysfs/mount.c --- a/fs/sysfs/mount.c Tue Mar 4 10:17:14 2003 +++ b/fs/sysfs/mount.c Wed Mar 5 15:26:59 2003 @@ -33,7 +33,7 @@ sb->s_op = &sysfs_ops; sysfs_sb = sb; - inode = sysfs_new_inode(S_IFDIR | S_IRUGO | S_IWUSR); + inode = sysfs_new_inode(S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO); if (inode) { inode->i_op = &simple_dir_inode_operations; inode->i_fop = &simple_dir_operations; diff -Nru a/include/asm-alpha/core_cia.h b/include/asm-alpha/core_cia.h --- a/include/asm-alpha/core_cia.h Sun Dec 8 03:50:30 2002 +++ b/include/asm-alpha/core_cia.h Sun Feb 16 16:35:48 2003 @@ -293,7 +293,7 @@ #ifdef __KERNEL__ #ifndef __EXTERN_INLINE -#define __EXTERN_INLINE extern inline +#define __EXTERN_INLINE static inline #define __IO_EXTERN_INLINE #endif diff -Nru a/include/asm-alpha/pgtable.h b/include/asm-alpha/pgtable.h --- a/include/asm-alpha/pgtable.h Mon Dec 30 07:03:59 2002 +++ b/include/asm-alpha/pgtable.h Thu Mar 6 08:19:03 2003 @@ -273,7 +273,6 @@ /* to find an entry in a page-table-directory. */ #define pgd_index(address) ((address >> PGDIR_SHIFT) & (PTRS_PER_PGD - 1)) -#define __pgd_offset(address) pgd_index(address) #define pgd_offset(mm, address) ((mm)->pgd+pgd_index(address)) /* Find an entry in the second-level page table.. */ diff -Nru a/include/asm-arm/arch-anakin/time.h b/include/asm-arm/arch-anakin/time.h --- a/include/asm-arm/arch-anakin/time.h Mon Feb 25 11:43:22 2002 +++ b/include/asm-arm/arch-anakin/time.h Thu Mar 6 05:40:54 2003 @@ -23,7 +23,6 @@ void __init time_init(void) { timer_irq.handler = anakin_timer_interrupt; - timer_irq.flags = SA_INTERRUPT; setup_irq(IRQ_TICK, &timer_irq); } diff -Nru a/include/asm-arm/arch-sa1100/time.h b/include/asm-arm/arch-sa1100/time.h --- a/include/asm-arm/arch-sa1100/time.h Sat Feb 15 11:11:56 2003 +++ b/include/asm-arm/arch-sa1100/time.h Thu Mar 6 05:40:54 2003 @@ -75,15 +75,12 @@ static void sa1100_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs) { unsigned int next_match; - unsigned long flags; do { do_leds(); - local_irq_save(flags); do_timer(regs); OSSR = OSSR_M0; /* Clear match on timer 0 */ next_match = (OSMR0 += LATCH); - local_irq_restore(flags); do_set_rtc(); } while ((signed long)(next_match - OSCR) <= 0); diff -Nru a/include/asm-arm/arch-shark/time.h b/include/asm-arm/arch-shark/time.h --- a/include/asm-arm/arch-shark/time.h Mon Feb 25 15:24:09 2002 +++ b/include/asm-arm/arch-shark/time.h Thu Mar 6 05:40:55 2003 @@ -34,6 +34,5 @@ xtime.tv_sec = 0; timer_irq.handler = timer_interrupt; - timer_irq.flags = SA_INTERRUPT; /* FIXME: really? */ setup_irq(IRQ_TIMER, &timer_irq); } diff -Nru a/include/asm-arm/ecard.h b/include/asm-arm/ecard.h --- a/include/asm-arm/ecard.h Sun Jan 26 06:44:21 2003 +++ b/include/asm-arm/ecard.h Thu Mar 6 05:14:05 2003 @@ -267,6 +267,7 @@ struct ecard_driver { int (*probe)(struct expansion_card *, const struct ecard_id *id); void (*remove)(struct expansion_card *); + void (*shutdown)(struct expansion_card *); const struct ecard_id *id_table; unsigned int id; struct device_driver drv; diff -Nru a/include/asm-arm/ide.h b/include/asm-arm/ide.h --- a/include/asm-arm/ide.h Tue Jan 14 15:31:20 2003 +++ b/include/asm-arm/ide.h Thu Mar 6 06:43:42 2003 @@ -26,16 +26,10 @@ #define ide_default_io_base(i) ((ide_ioreg_t)0) #define ide_default_irq(b) (0) -#define ide_request_irq(irq,hand,flg,dev,id) request_irq((irq),(hand),(flg),(dev),(id)) -#define ide_free_irq(irq,dev_id) free_irq((irq), (dev_id)) -#define ide_check_region(from,extent) check_region((from), (extent)) -#define ide_request_region(from,extent,name) request_region((from), (extent), (name)) -#define ide_release_region(from,extent) release_region((from), (extent)) - -/* - * The following are not needed for the non-m68k ports - */ -#define ide_ack_intr(hwif) (1) +#define __ide_mm_insw(port,addr,len) readsw(port,addr,len) +#define __ide_mm_insl(port,addr,len) readsl(port,addr,len) +#define __ide_mm_outsw(port,addr,len) writesw(port,addr,len) +#define __ide_mm_outsl(port,addr,len) writesl(port,addr,len) #endif /* __KERNEL__ */ diff -Nru a/include/asm-arm/pci.h b/include/asm-arm/pci.h --- a/include/asm-arm/pci.h Fri Jan 10 13:40:12 2003 +++ b/include/asm-arm/pci.h Thu Mar 6 06:02:22 2003 @@ -131,7 +131,10 @@ /* * Return the index of the PCI controller for device PDEV. */ -#define pci_controller_num(PDEV) (0) +static inline int pci_controller_num(struct pci_dev *dev) +{ + return 0; +} #if defined(CONFIG_SA1111) && !defined(CONFIG_PCI) diff -Nru a/include/asm-arm/pgtable.h b/include/asm-arm/pgtable.h --- a/include/asm-arm/pgtable.h Sun Oct 13 03:46:44 2002 +++ b/include/asm-arm/pgtable.h Thu Mar 6 08:19:03 2003 @@ -110,13 +110,13 @@ #define pgd_bad(pgd) (0) #define pgd_present(pgd) (1) #define pgd_clear(pgdp) do { } while (0) +#define set_pgd(pgd,pgdp) do { } while (0) #define page_pte_prot(page,prot) mk_pte(page, prot) #define page_pte(page) mk_pte(page, __pgprot(0)) /* to find an entry in a page-table-directory */ #define pgd_index(addr) ((addr) >> PGDIR_SHIFT) -#define __pgd_offset(addr) pgd_index(addr) #define pgd_offset(mm, addr) ((mm)->pgd+pgd_index(addr)) diff -Nru a/include/asm-arm/posix_types.h b/include/asm-arm/posix_types.h --- a/include/asm-arm/posix_types.h Tue Feb 5 09:39:52 2002 +++ b/include/asm-arm/posix_types.h Thu Mar 6 05:53:11 2003 @@ -34,6 +34,8 @@ typedef long __kernel_time_t; typedef long __kernel_suseconds_t; typedef long __kernel_clock_t; +typedef int __kernel_timer_t; +typedef int __kernel_clockid_t; typedef int __kernel_daddr_t; typedef char * __kernel_caddr_t; typedef unsigned short __kernel_uid16_t; diff -Nru a/include/asm-arm/proc-armv/tlbflush.h b/include/asm-arm/proc-armv/tlbflush.h --- a/include/asm-arm/proc-armv/tlbflush.h Sun Oct 13 03:46:44 2002 +++ b/include/asm-arm/proc-armv/tlbflush.h Thu Mar 6 06:52:18 2003 @@ -1,7 +1,7 @@ /* * linux/include/asm-arm/proc-armv/tlbflush.h * - * Copyright (C) 1999-2002 Russell King + * Copyright (C) 1999-2003 Russell King * * 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 @@ -38,21 +38,31 @@ #define v3_tlb_flags (TLB_V3_FULL | TLB_V3_PAGE) #if defined(CONFIG_CPU_ARM610) || defined(CONFIG_CPU_ARM710) +# define v3_possible_flags v3_tlb_flags +# define v3_always_flags v3_tlb_flags # ifdef _TLB # define MULTI_TLB 1 # else # define _TLB v3 # endif +#else +# define v3_possible_flags 0 +# define v3_always_flags (-1UL) #endif #define v4_tlb_flags (TLB_V4_U_FULL | TLB_V4_U_PAGE) #if defined(CONFIG_CPU_ARM720T) +# define v4_possible_flags v4_tlb_flags +# define v4_always_flags v4_tlb_flags # ifdef _TLB # define MULTI_TLB 1 # else # define _TLB v4 # endif +#else +# define v4_possible_flags 0 +# define v4_always_flags (-1UL) #endif #define v4wbi_tlb_flags (TLB_WB | \ @@ -62,11 +72,16 @@ #if defined(CONFIG_CPU_ARM920T) || defined(CONFIG_CPU_ARM922T) || \ defined(CONFIG_CPU_ARM926T) || defined(CONFIG_CPU_ARM1020) || \ defined(CONFIG_CPU_XSCALE) +# define v4wbi_possible_flags v4wbi_tlb_flags +# define v4wbi_always_flags v4wbi_tlb_flags # ifdef _TLB # define MULTI_TLB 1 # else # define _TLB v4wbi # endif +#else +# define v4wbi_possible_flags 0 +# define v4wbi_always_flags (-1UL) #endif #define v4wb_tlb_flags (TLB_WB | \ @@ -74,11 +89,16 @@ TLB_V4_D_PAGE) #if defined(CONFIG_CPU_SA110) || defined(CONFIG_CPU_SA1100) +# define v4wb_possible_flags v4wb_tlb_flags +# define v4wb_always_flags v4wb_tlb_flags # ifdef _TLB # define MULTI_TLB 1 # else # define _TLB v4wb # endif +#else +# define v4wb_possible_flags 0 +# define v4wb_always_flags (-1UL) #endif #ifndef _TLB @@ -98,23 +118,23 @@ */ #ifdef MULTI_TLB -extern struct cpu_tlb_fns cpu_tlb; - #define __cpu_flush_user_tlb_range cpu_tlb.flush_user_range #define __cpu_flush_kern_tlb_range cpu_tlb.flush_kern_range -#define __cpu_tlb_flags cpu_tlb.tlb_flags #else #define __cpu_flush_user_tlb_range __glue(_TLB,_flush_user_tlb_range) #define __cpu_flush_kern_tlb_range __glue(_TLB,_flush_kern_tlb_range) -#define __cpu_tlb_flags __glue(_TLB,_tlb_flags) extern void __cpu_flush_user_tlb_range(unsigned long, unsigned long, struct vm_area_struct *); extern void __cpu_flush_kern_tlb_range(unsigned long, unsigned long); #endif +extern struct cpu_tlb_fns cpu_tlb; + +#define __cpu_tlb_flags cpu_tlb.tlb_flags + /* * TLB Management * ============== @@ -158,11 +178,34 @@ * - kaddr - Kernel virtual memory address */ -#define tlb_flag(f) (__cpu_tlb_flags & (f)) +/* + * We optimise the code below by: + * - building a set of TLB flags that might be set in __cpu_tlb_flags + * - building a set of TLB flags that will always be set in __cpu_tlb_flags + * - if we're going to need __cpu_tlb_flags, access it once and only once + * + * This allows us to build optimal assembly for the single-CPU type case, + * and as close to optimal given the compiler constrants for multi-CPU + * case. We could do better for the multi-CPU case if the compiler + * implemented the "%?" method, but this has been discontinued due to too + * many people getting it wrong. + */ +#define possible_tlb_flags (v3_possible_flags | \ + v4_possible_flags | \ + v4wbi_possible_flags | \ + v4wb_possible_flags) + +#define always_tlb_flags (v3_always_flags & \ + v4_always_flags & \ + v4wbi_always_flags & \ + v4wb_always_flags) + +#define tlb_flag(f) ((always_tlb_flags & (f)) || (__tlb_flag & possible_tlb_flags & (f))) static inline void flush_tlb_all(void) { const int zero = 0; + const unsigned int __tlb_flag = __cpu_tlb_flags; if (tlb_flag(TLB_WB)) asm("mcr%? p15, 0, %0, c7, c10, 4" : : "r" (zero)); @@ -180,6 +223,7 @@ static inline void flush_tlb_mm(struct mm_struct *mm) { const int zero = 0; + const unsigned int __tlb_flag = __cpu_tlb_flags; if (tlb_flag(TLB_WB)) asm("mcr%? p15, 0, %0, c7, c10, 4" : : "r" (zero)); @@ -200,6 +244,7 @@ flush_tlb_page(struct vm_area_struct *vma, unsigned long uaddr) { const int zero = 0; + const unsigned int __tlb_flag = __cpu_tlb_flags; uaddr &= PAGE_MASK; @@ -223,6 +268,7 @@ static inline void flush_tlb_kernel_page(unsigned long kaddr) { const int zero = 0; + const unsigned int __tlb_flag = __cpu_tlb_flags; kaddr &= PAGE_MASK; @@ -240,6 +286,10 @@ if (!tlb_flag(TLB_V4_I_PAGE) && tlb_flag(TLB_V4_I_FULL)) asm("mcr%? p15, 0, %0, c8, c5, 0" : : "r" (zero)); } + +#undef tlb_flag +#undef always_tlb_flags +#undef possible_tlb_flags /* * Convert calls to our calling convention. diff -Nru a/include/asm-arm/proc-fns.h b/include/asm-arm/proc-fns.h --- a/include/asm-arm/proc-fns.h Tue Feb 25 02:23:37 2003 +++ b/include/asm-arm/proc-fns.h Thu Mar 6 06:06:19 2003 @@ -122,15 +122,4 @@ #include CPU_INCLUDE_NAME #endif /* __KERNEL__ */ - -#if 0 - * The following is to fool mkdep into generating the correct - * dependencies. Without this, it can't figure out that this - * file does indeed depend on the cpu-*.h files. -#include -#include -#include - * -#endif - #endif /* __ASM_PROCFNS_H */ diff -Nru a/include/asm-arm/system.h b/include/asm-arm/system.h --- a/include/asm-arm/system.h Wed Oct 30 03:55:14 2002 +++ b/include/asm-arm/system.h Thu Mar 6 08:26:25 2003 @@ -14,16 +14,6 @@ extern unsigned int system_serial_high; extern unsigned int mem_fclk_21285; -/* - * This tells us if we have an ISA bridge - * present in a PCI system. - */ -#ifdef CONFIG_PCI -extern int have_isa_bridge; -#else -#define have_isa_bridge (0) -#endif - struct pt_regs; void die(const char *msg, struct pt_regs *regs, int err) @@ -75,7 +65,7 @@ * The `mb' is to tell GCC not to cache `current' across this call. */ struct thread_info; -extern struct task_struct *__switch_to(struct thread_info *, struct thread_info *); +extern struct thread_info *__switch_to(struct thread_info *, struct thread_info *); #define switch_to(prev,next,last) \ do { \ diff -Nru a/include/asm-i386/bug.h b/include/asm-i386/bug.h --- a/include/asm-i386/bug.h Tue Feb 26 05:19:26 2002 +++ b/include/asm-i386/bug.h Sun Feb 16 15:52:20 2003 @@ -4,8 +4,7 @@ #include /* - * Tell the user there is some problem. Beep too, so we can - * see^H^H^Hhear bugs in early bootup as well! + * Tell the user there is some problem. * The offending file and line are encoded after the "officially * undefined" opcode for parsing in the trap handler. */ diff -Nru a/include/asm-i386/hdreg.h b/include/asm-i386/hdreg.h --- a/include/asm-i386/hdreg.h Wed Sep 11 00:06:00 2002 +++ b/include/asm-i386/hdreg.h Tue Feb 18 06:32:42 2003 @@ -7,6 +7,5 @@ #ifndef __ASMi386_HDREG_H #define __ASMi386_HDREG_H -typedef unsigned long ide_ioreg_t; #endif /* __ASMi386_HDREG_H */ diff -Nru a/include/asm-i386/pgtable-3level.h b/include/asm-i386/pgtable-3level.h --- a/include/asm-i386/pgtable-3level.h Mon Feb 3 23:46:49 2003 +++ b/include/asm-i386/pgtable-3level.h Thu Mar 6 08:19:07 2003 @@ -69,7 +69,7 @@ /* Find an entry in the second-level page table.. */ #define pmd_offset(dir, address) ((pmd_t *) pgd_page(*(dir)) + \ - __pmd_offset(address)) + pmd_index(address)) static inline pte_t ptep_get_and_clear(pte_t *ptep) { diff -Nru a/include/asm-i386/pgtable.h b/include/asm-i386/pgtable.h --- a/include/asm-i386/pgtable.h Tue Feb 18 18:58:46 2003 +++ b/include/asm-i386/pgtable.h Thu Mar 6 17:44:46 2003 @@ -49,8 +49,6 @@ #endif -#define __beep() asm("movb $0x3,%al; outb %al,$0x61") - #define PMD_SIZE (1UL << PMD_SHIFT) #define PMD_MASK (~(PMD_SIZE-1)) #define PGDIR_SIZE (1UL << PGDIR_SHIFT) @@ -236,32 +234,30 @@ /* to find an entry in a page-table-directory. */ #define pgd_index(address) (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD-1)) -#define __pgd_offset(address) pgd_index(address) - #define pgd_offset(mm, address) ((mm)->pgd+pgd_index(address)) /* to find an entry in a kernel page-table-directory */ #define pgd_offset_k(address) pgd_offset(&init_mm, address) -#define __pmd_offset(address) \ +#define pmd_index(address) \ (((address) >> PMD_SHIFT) & (PTRS_PER_PMD-1)) /* Find an entry in the third-level page table.. */ -#define __pte_offset(address) \ +#define pte_index(address) \ (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1)) #define pte_offset_kernel(dir, address) \ - ((pte_t *) pmd_page_kernel(*(dir)) + __pte_offset(address)) + ((pte_t *) pmd_page_kernel(*(dir)) + pte_index(address)) #if defined(CONFIG_HIGHPTE) #define pte_offset_map(dir, address) \ - ((pte_t *)kmap_atomic(pmd_page(*(dir)),KM_PTE0) + __pte_offset(address)) + ((pte_t *)kmap_atomic(pmd_page(*(dir)),KM_PTE0) + pte_index(address)) #define pte_offset_map_nested(dir, address) \ - ((pte_t *)kmap_atomic(pmd_page(*(dir)),KM_PTE1) + __pte_offset(address)) + ((pte_t *)kmap_atomic(pmd_page(*(dir)),KM_PTE1) + pte_index(address)) #define pte_unmap(pte) kunmap_atomic(pte, KM_PTE0) #define pte_unmap_nested(pte) kunmap_atomic(pte, KM_PTE1) #else #define pte_offset_map(dir, address) \ - ((pte_t *)page_address(pmd_page(*(dir))) + __pte_offset(address)) + ((pte_t *)page_address(pmd_page(*(dir))) + pte_index(address)) #define pte_offset_map_nested(dir, address) pte_offset_map(dir, address) #define pte_unmap(pte) do { } while (0) #define pte_unmap_nested(pte) do { } while (0) diff -Nru a/include/asm-i386/serial.h b/include/asm-i386/serial.h --- a/include/asm-i386/serial.h Mon Feb 4 23:43:09 2002 +++ b/include/asm-i386/serial.h Thu Feb 20 08:30:58 2003 @@ -50,12 +50,19 @@ #define C_P(card,port) (((card)<<6|(port)<<3) + 1) +#ifndef CONFIG_X86_PC9800 #define STD_SERIAL_PORT_DEFNS \ /* UART CLK PORT IRQ FLAGS */ \ { 0, BASE_BAUD, 0x3F8, 4, STD_COM_FLAGS }, /* ttyS0 */ \ { 0, BASE_BAUD, 0x2F8, 3, STD_COM_FLAGS }, /* ttyS1 */ \ { 0, BASE_BAUD, 0x3E8, 4, STD_COM_FLAGS }, /* ttyS2 */ \ { 0, BASE_BAUD, 0x2E8, 3, STD_COM4_FLAGS }, /* ttyS3 */ +#else +#define STD_SERIAL_PORT_DEFNS \ + /* UART CLK PORT IRQ FLAGS */ \ + { 0, BASE_BAUD, 0x30, 4, STD_COM_FLAGS }, /* ttyS0 */ \ + { 0, BASE_BAUD, 0x238, 5, STD_COM_FLAGS }, /* ttyS1 */ +#endif /* CONFIG_X86_PC9800 */ #ifdef CONFIG_SERIAL_MANY_PORTS diff -Nru a/include/asm-ia64/pgtable.h b/include/asm-ia64/pgtable.h --- a/include/asm-ia64/pgtable.h Thu Oct 31 21:45:22 2002 +++ b/include/asm-ia64/pgtable.h Thu Mar 6 08:19:09 2003 @@ -317,8 +317,8 @@ * Find an entry in the third-level page table. This looks more complicated than it * should be because some platforms place page tables in high memory. */ -#define __pte_offset(addr) (((addr) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1)) -#define pte_offset_kernel(dir,addr) ((pte_t *) pmd_page_kernel(*(dir)) + __pte_offset(addr)) +#define pte_index(addr) (((addr) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1)) +#define pte_offset_kernel(dir,addr) ((pte_t *) pmd_page_kernel(*(dir)) + pte_index(addr)) #define pte_offset_map(dir,addr) pte_offset_kernel(dir, addr) #define pte_offset_map_nested(dir,addr) pte_offset_map(dir, addr) #define pte_unmap(pte) do { } while (0) diff -Nru a/include/asm-m68k/sun3_pgtable.h b/include/asm-m68k/sun3_pgtable.h --- a/include/asm-m68k/sun3_pgtable.h Mon May 20 06:43:35 2002 +++ b/include/asm-m68k/sun3_pgtable.h Thu Mar 6 08:19:09 2003 @@ -196,10 +196,10 @@ } /* Find an entry in the third-level pagetable. */ -#define __pte_offset(address) ((address >> PAGE_SHIFT) & (PTRS_PER_PTE-1)) -#define pte_offset_kernel(pmd, address) ((pte_t *) __pmd_page(*pmd) + __pte_offset(address)) +#define pte_index(address) ((address >> PAGE_SHIFT) & (PTRS_PER_PTE-1)) +#define pte_offset_kernel(pmd, address) ((pte_t *) __pmd_page(*pmd) + pte_index(address)) /* FIXME: should we bother with kmap() here? */ -#define pte_offset_map(pmd, address) ((pte_t *)kmap(pmd_page(*pmd)) + __pte_offset(address)) +#define pte_offset_map(pmd, address) ((pte_t *)kmap(pmd_page(*pmd)) + pte_index(address)) #define pte_offset_map_nested(pmd, address) pte_offset_map(pmd, address) #define pte_unmap(pte) kunmap(pte) #define pte_unmap_nested(pte) kunmap(pte) diff -Nru a/include/asm-parisc/bug.h b/include/asm-parisc/bug.h --- a/include/asm-parisc/bug.h Sun Jan 6 03:51:59 2002 +++ b/include/asm-parisc/bug.h Sun Feb 16 15:52:20 2003 @@ -2,10 +2,7 @@ #define _PARISC_BUG_H /* - * Tell the user there is some problem. Beep too, so we can - * see^H^H^Hhear bugs in early bootup as well! - * - * We don't beep yet. prumpf + * Tell the user there is some problem. */ #define BUG() do { \ printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \ diff -Nru a/include/asm-parisc/pgtable.h b/include/asm-parisc/pgtable.h --- a/include/asm-parisc/pgtable.h Tue Feb 18 10:12:35 2003 +++ b/include/asm-parisc/pgtable.h Thu Mar 6 08:19:09 2003 @@ -329,9 +329,9 @@ #endif /* Find an entry in the third-level page table.. */ -#define __pte_offset(address) (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE-1)) +#define pte_index(address) (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE-1)) #define pte_offset_kernel(pmd, address) \ - ((pte_t *) pmd_page_kernel(*(pmd)) + __pte_offset(address)) + ((pte_t *) pmd_page_kernel(*(pmd)) + pte_index(address)) #define pte_offset_map(pmd, address) pte_offset_kernel(pmd, address) #define pte_offset_map_nested(pmd, address) pte_offset_kernel(pmd, address) #define pte_unmap(pte) do { } while (0) diff -Nru a/include/asm-ppc/pgtable.h b/include/asm-ppc/pgtable.h --- a/include/asm-ppc/pgtable.h Mon Oct 7 15:51:14 2002 +++ b/include/asm-ppc/pgtable.h Thu Mar 6 08:19:09 2003 @@ -494,14 +494,14 @@ } /* Find an entry in the third-level page table.. */ -#define __pte_offset(address) \ +#define pte_index(address) \ (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1)) #define pte_offset_kernel(dir, addr) \ - ((pte_t *) pmd_page_kernel(*(dir)) + __pte_offset(addr)) + ((pte_t *) pmd_page_kernel(*(dir)) + pte_index(addr)) #define pte_offset_map(dir, addr) \ - ((pte_t *) kmap_atomic(pmd_page(*(dir)), KM_PTE0) + __pte_offset(addr)) + ((pte_t *) kmap_atomic(pmd_page(*(dir)), KM_PTE0) + pte_index(addr)) #define pte_offset_map_nested(dir, addr) \ - ((pte_t *) kmap_atomic(pmd_page(*(dir)), KM_PTE1) + __pte_offset(addr)) + ((pte_t *) kmap_atomic(pmd_page(*(dir)), KM_PTE1) + pte_index(addr)) #define pte_unmap(pte) kunmap_atomic(pte, KM_PTE0) #define pte_unmap_nested(pte) kunmap_atomic(pte, KM_PTE1) diff -Nru a/include/asm-s390/pgtable.h b/include/asm-s390/pgtable.h --- a/include/asm-s390/pgtable.h Mon Nov 18 12:11:53 2002 +++ b/include/asm-s390/pgtable.h Thu Mar 6 08:19:09 2003 @@ -467,9 +467,9 @@ } /* Find an entry in the third-level page table.. */ -#define __pte_offset(address) (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE-1)) +#define pte_index(address) (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE-1)) #define pte_offset_kernel(pmd, address) \ - ((pte_t *) pmd_page_kernel(*(pmd)) + __pte_offset(address)) + ((pte_t *) pmd_page_kernel(*(pmd)) + pte_index(address)) #define pte_offset_map(pmd, address) pte_offset_kernel(pmd, address) #define pte_offset_map_nested(pmd, address) pte_offset_kernel(pmd, address) #define pte_unmap(pte) do { } while (0) diff -Nru a/include/asm-s390x/pgtable.h b/include/asm-s390x/pgtable.h --- a/include/asm-s390x/pgtable.h Mon Feb 24 10:25:00 2003 +++ b/include/asm-s390x/pgtable.h Thu Mar 6 08:19:09 2003 @@ -488,14 +488,14 @@ #define pgd_offset_k(address) pgd_offset(&init_mm, address) /* Find an entry in the second-level page table.. */ -#define __pmd_offset(address) (((address) >> PMD_SHIFT) & (PTRS_PER_PMD-1)) +#define pmd_index(address) (((address) >> PMD_SHIFT) & (PTRS_PER_PMD-1)) #define pmd_offset(dir,addr) \ - ((pmd_t *) pgd_page_kernel(*(dir)) + __pmd_offset(addr)) + ((pmd_t *) pgd_page_kernel(*(dir)) + pmd_index(addr)) /* Find an entry in the third-level page table.. */ -#define __pte_offset(address) (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE-1)) +#define pte_index(address) (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE-1)) #define pte_offset_kernel(pmd, address) \ - ((pte_t *) pmd_page_kernel(*(pmd)) + __pte_offset(address)) + ((pte_t *) pmd_page_kernel(*(pmd)) + pte_index(address)) #define pte_offset_map(pmd, address) pte_offset_kernel(pmd, address) #define pte_offset_map_nested(pmd, address) pte_offset_kernel(pmd, address) #define pte_unmap(pte) do { } while (0) diff -Nru a/include/asm-sh/pgtable.h b/include/asm-sh/pgtable.h --- a/include/asm-sh/pgtable.h Mon Sep 9 14:01:14 2002 +++ b/include/asm-sh/pgtable.h Thu Mar 6 17:44:46 2003 @@ -98,8 +98,6 @@ #endif /* !__ASSEMBLY__ */ -#define __beep() asm("") - #define PMD_SIZE (1UL << PMD_SHIFT) #define PMD_MASK (~(PMD_SIZE-1)) #define PGDIR_SIZE (1UL << PGDIR_SHIFT) @@ -274,17 +272,16 @@ /* to find an entry in a page-table-directory. */ #define pgd_index(address) (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD-1)) -#define __pgd_offset(address) pgd_index(address) #define pgd_offset(mm, address) ((mm)->pgd+pgd_index(address)) /* to find an entry in a kernel page-table-directory */ #define pgd_offset_k(address) pgd_offset(&init_mm, address) /* Find an entry in the third-level page table.. */ -#define __pte_offset(address) \ +#define pte_index(address) \ ((address >> PAGE_SHIFT) & (PTRS_PER_PTE - 1)) #define pte_offset(dir, address) ((pte_t *) pmd_page(*(dir)) + \ - __pte_offset(address)) + pte_index(address)) extern void update_mmu_cache(struct vm_area_struct * vma, unsigned long address, pte_t pte); diff -Nru a/include/asm-sparc64/pgtable.h b/include/asm-sparc64/pgtable.h --- a/include/asm-sparc64/pgtable.h Thu Oct 3 11:02:09 2002 +++ b/include/asm-sparc64/pgtable.h Thu Mar 6 08:19:09 2003 @@ -273,11 +273,11 @@ ((address >> PMD_SHIFT) & (REAL_PTRS_PER_PMD-1))) /* Find an entry in the third-level page table.. */ -#define __pte_offset(dir, address) ((pte_t *) __pmd_page(*(dir)) + \ +#define pte_index(dir, address) ((pte_t *) __pmd_page(*(dir)) + \ ((address >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))) -#define pte_offset_kernel __pte_offset -#define pte_offset_map __pte_offset -#define pte_offset_map_nested __pte_offset +#define pte_offset_kernel pte_index +#define pte_offset_map pte_index +#define pte_offset_map_nested pte_index #define pte_unmap(pte) do { } while (0) #define pte_unmap_nested(pte) do { } while (0) diff -Nru a/include/asm-um/pgtable.h b/include/asm-um/pgtable.h --- a/include/asm-um/pgtable.h Tue Feb 25 01:39:17 2003 +++ b/include/asm-um/pgtable.h Thu Mar 6 08:19:09 2003 @@ -357,7 +357,6 @@ /* to find an entry in a page-table-directory. */ #define pgd_index(address) ((address >> PGDIR_SHIFT) & (PTRS_PER_PGD-1)) -#define __pgd_offset(address) pgd_index(address) /* to find an entry in a page-table-directory */ #define pgd_offset(mm, address) \ @@ -366,7 +365,7 @@ /* to find an entry in a kernel page-table-directory */ #define pgd_offset_k(address) pgd_offset(&init_mm, address) -#define __pmd_offset(address) \ +#define pmd_index(address) \ (((address) >> PMD_SHIFT) & (PTRS_PER_PMD-1)) /* Find an entry in the second-level page table.. */ @@ -376,13 +375,13 @@ } /* Find an entry in the third-level page table.. */ -#define __pte_offset(address) (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1)) +#define pte_index(address) (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1)) #define pte_offset_kernel(dir, address) \ - ((pte_t *) pmd_page_kernel(*(dir)) + __pte_offset(address)) + ((pte_t *) pmd_page_kernel(*(dir)) + pte_index(address)) #define pte_offset_map(dir, address) \ - ((pte_t *)kmap_atomic(pmd_page(*(dir)),KM_PTE0) + __pte_offset(address)) + ((pte_t *)kmap_atomic(pmd_page(*(dir)),KM_PTE0) + pte_index(address)) #define pte_offset_map_nested(dir, address) \ - ((pte_t *)kmap_atomic(pmd_page(*(dir)),KM_PTE1) + __pte_offset(address)) + ((pte_t *)kmap_atomic(pmd_page(*(dir)),KM_PTE1) + pte_index(address)) #define pte_unmap(pte) kunmap_atomic((pte), KM_PTE0) #define pte_unmap_nested(pte) kunmap_atomic((pte), KM_PTE1) diff -Nru a/include/asm-x86_64/pgtable.h b/include/asm-x86_64/pgtable.h --- a/include/asm-x86_64/pgtable.h Sat Feb 15 03:05:09 2003 +++ b/include/asm-x86_64/pgtable.h Thu Mar 6 08:19:09 2003 @@ -321,9 +321,9 @@ #define pmd_page_kernel(pmd) ((unsigned long) __va(pmd_val(pmd) & PTE_MASK)) #define pmd_page(pmd) (pfn_to_page(pmd_val(pmd) >> PAGE_SHIFT)) -#define __pmd_offset(address) (((address) >> PMD_SHIFT) & (PTRS_PER_PMD-1)) +#define pmd_index(address) (((address) >> PMD_SHIFT) & (PTRS_PER_PMD-1)) #define pmd_offset(dir, address) ((pmd_t *) pgd_page(*(dir)) + \ - __pmd_offset(address)) + pmd_index(address)) #define pmd_none(x) (!pmd_val(x)) #define pmd_present(x) (pmd_val(x) & _PAGE_PRESENT) #define pmd_clear(xp) do { set_pmd(xp, __pmd(0)); } while (0) @@ -353,10 +353,10 @@ return pte; } -#define __pte_offset(address) \ +#define pte_index(address) \ ((address >> PAGE_SHIFT) & (PTRS_PER_PTE - 1)) #define pte_offset_kernel(dir, address) ((pte_t *) pmd_page_kernel(*(dir)) + \ - __pte_offset(address)) + pte_index(address)) /* x86-64 always has all page tables mapped. */ #define pte_offset_map(dir,address) pte_offset_kernel(dir,address) diff -Nru a/include/linux/efs_fs.h b/include/linux/efs_fs.h --- a/include/linux/efs_fs.h Tue Dec 31 17:17:28 2002 +++ b/include/linux/efs_fs.h Sun Feb 16 16:16:32 2003 @@ -15,14 +15,6 @@ #include -#ifndef LINUX_VERSION_CODE -#include -#endif - -#if LINUX_VERSION_CODE < 0x20200 -#error This code is only for linux-2.2 and later. -#endif - /* 1 block is 512 bytes */ #define EFS_BLOCKSIZE_BITS 9 #define EFS_BLOCKSIZE (1 << EFS_BLOCKSIZE_BITS) @@ -31,13 +23,6 @@ #include #include #include - -#ifndef MIN -#define MIN(a, b) (((a) < (b)) ? (a) : (b)) -#endif -#ifndef MAX -#define MAX(a, b) (((a) > (b)) ? (a) : (b)) -#endif static inline struct efs_inode_info *INODE_INFO(struct inode *inode) { diff -Nru a/include/linux/elf.h b/include/linux/elf.h --- a/include/linux/elf.h Mon Feb 24 10:24:54 2003 +++ b/include/linux/elf.h Mon Mar 3 13:04:56 2003 @@ -83,6 +83,8 @@ #define EM_V850 87 /* NEC v850 */ +#define EM_H8_300H 47 /* Hitachi H8/300H */ +#define EM_H8S 48 /* Hitachi H8S */ /* * This is an interim value that we will use until the committee comes diff -Nru a/include/linux/if_shaper.h b/include/linux/if_shaper.h --- a/include/linux/if_shaper.h Tue Feb 5 09:39:42 2002 +++ b/include/linux/if_shaper.h Tue Mar 4 22:44:07 2003 @@ -21,7 +21,7 @@ __u32 bitspersec; __u32 shapelatency; __u32 shapeclock; - __u32 recovery; /* Time we can next clock a packet out on + unsigned long recovery; /* Time we can next clock a packet out on an empty queue */ unsigned long locked; struct net_device_stats stats; diff -Nru a/include/linux/if_wanpipe.h b/include/linux/if_wanpipe.h --- a/include/linux/if_wanpipe.h Sun Mar 17 20:03:30 2002 +++ b/include/linux/if_wanpipe.h Sun Feb 16 16:22:42 2003 @@ -100,13 +100,9 @@ #define WAN_PACKET_MR_ALLMULTI 2 #ifdef __KERNEL__ + #ifndef netdevice_t -#include -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,0) - #define netdevice_t struct net_device -#else - #define netdevice_t struct device -#endif +#define netdevice_t struct net_device #endif /* Private wanpipe socket structures. */ diff -Nru a/include/linux/if_wanpipe_common.h b/include/linux/if_wanpipe_common.h --- a/include/linux/if_wanpipe_common.h Sun Dec 8 05:42:07 2002 +++ b/include/linux/if_wanpipe_common.h Sun Feb 16 16:22:42 2003 @@ -19,11 +19,7 @@ #include -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,0) - #define netdevice_t struct net_device -#else - #define netdevice_t struct device -#endif +#define netdevice_t struct net_device typedef struct { diff -Nru a/include/linux/init.h b/include/linux/init.h --- a/include/linux/init.h Tue Feb 18 10:25:13 2003 +++ b/include/linux/init.h Mon Mar 3 13:05:26 2003 @@ -62,8 +62,10 @@ */ typedef int (*initcall_t)(void); typedef void (*exitcall_t)(void); -#endif +extern initcall_t __con_initcall_start, __con_initcall_end; +#endif + #ifndef MODULE #ifndef __ASSEMBLY__ @@ -90,6 +92,9 @@ #define __exitcall(fn) \ static exitcall_t __exitcall_##fn __exit_call = fn + +#define console_initcall(fn) \ + static initcall_t __initcall_##fn __attribute__ ((unused,__section__ (".con_initcall.init")))=fn struct obs_kernel_param { const char *str; diff -Nru a/include/linux/ipv6.h b/include/linux/ipv6.h --- a/include/linux/ipv6.h Thu Oct 24 03:26:49 2002 +++ b/include/linux/ipv6.h Wed Mar 5 15:45:36 2003 @@ -74,6 +74,21 @@ #define rt0_type rt_hdr.type; }; +struct ipv6_auth_hdr { + __u8 nexthdr; + __u8 hdrlen; /* This one is measured in 32 bit units! */ + __u16 reserved; + __u32 spi; + __u32 seq_no; /* Sequence number */ + __u8 auth_data[4]; /* Length variable but >=4. Mind the 64 bit alignment! */ +}; + +struct ipv6_esp_hdr { + __u32 spi; + __u32 seq_no; /* Sequence number */ + __u8 enc_data[8]; /* Length variable but >=8. Mind the 64 bit alignment! */ +}; + /* * IPv6 fixed header * diff -Nru a/include/linux/jiffies.h b/include/linux/jiffies.h --- a/include/linux/jiffies.h Tue Feb 25 02:08:56 2003 +++ b/include/linux/jiffies.h Wed Mar 5 21:22:52 2003 @@ -1,6 +1,7 @@ #ifndef _LINUX_JIFFIES_H #define _LINUX_JIFFIES_H +#include #include #include #include @@ -37,10 +38,16 @@ * good compiler would generate better code (and a really good compiler * wouldn't care). Gcc is currently neither. */ -#define time_after(a,b) ((long)(b) - (long)(a) < 0) +#define time_after(a,b) \ + (typecheck(unsigned long, a) && \ + typecheck(unsigned long, b) && \ + ((long)(b) - (long)(a) < 0)) #define time_before(a,b) time_after(b,a) -#define time_after_eq(a,b) ((long)(a) - (long)(b) >= 0) +#define time_after_eq(a,b) \ + (typecheck(unsigned long, a) && \ + typecheck(unsigned long, b) && \ + ((long)(a) - (long)(b) >= 0)) #define time_before_eq(a,b) time_after_eq(b,a) #endif diff -Nru a/include/linux/kernel.h b/include/linux/kernel.h --- a/include/linux/kernel.h Mon Nov 18 02:03:05 2002 +++ b/include/linux/kernel.h Wed Mar 5 21:21:32 2003 @@ -188,6 +188,17 @@ const typeof( ((type *)0)->member ) *__mptr = (ptr); \ (type *)( (char *)__mptr - offsetof(type,member) );}) +/* + * Check at compile time that something is of a particular type. + * Always evaluates to 1 so you may use it easily in conparisons. + */ +#define typecheck(type,x) \ +({ type __dummy; \ + typeof(x) __dummy2; \ + (void)(&__dummy == &__dummy2); \ + 1; \ +}) + #endif /* __KERNEL__ */ #define SI_LOAD_SHIFT 16 diff -Nru a/include/linux/list.h b/include/linux/list.h --- a/include/linux/list.h Tue Mar 4 05:50:39 2003 +++ b/include/linux/list.h Wed Mar 5 22:31:27 2003 @@ -4,6 +4,7 @@ #ifdef __KERNEL__ #include +#include #include /* diff -Nru a/include/linux/netfilter_bridge/ebt_ip.h b/include/linux/netfilter_bridge/ebt_ip.h --- a/include/linux/netfilter_bridge/ebt_ip.h Mon Oct 28 04:58:32 2002 +++ b/include/linux/netfilter_bridge/ebt_ip.h Mon Mar 3 04:41:09 2003 @@ -25,7 +25,7 @@ EBT_IP_SPORT | EBT_IP_DPORT ) #define EBT_IP_MATCH "ip" -// the same values are used for the invflags +/* the same values are used for the invflags */ struct ebt_ip_info { uint32_t saddr; diff -Nru a/include/linux/netfilter_bridge/ebt_log.h b/include/linux/netfilter_bridge/ebt_log.h --- a/include/linux/netfilter_bridge/ebt_log.h Sun Sep 22 20:14:05 2002 +++ b/include/linux/netfilter_bridge/ebt_log.h Mon Mar 3 04:41:09 2003 @@ -1,7 +1,7 @@ #ifndef __LINUX_BRIDGE_EBT_LOG_H #define __LINUX_BRIDGE_EBT_LOG_H -#define EBT_LOG_IP 0x01 // if the frame is made by ip, log the ip information +#define EBT_LOG_IP 0x01 /* if the frame is made by ip, log the ip information */ #define EBT_LOG_ARP 0x02 #define EBT_LOG_MASK (EBT_LOG_IP | EBT_LOG_ARP) #define EBT_LOG_PREFIX_SIZE 30 diff -Nru a/include/linux/netfilter_bridge/ebt_mark_t.h b/include/linux/netfilter_bridge/ebt_mark_t.h --- a/include/linux/netfilter_bridge/ebt_mark_t.h Sun Sep 22 20:14:05 2002 +++ b/include/linux/netfilter_bridge/ebt_mark_t.h Mon Mar 3 04:41:09 2003 @@ -4,7 +4,7 @@ struct ebt_mark_t_info { unsigned long mark; - // EBT_ACCEPT, EBT_DROP or EBT_CONTINUE or EBT_RETURN + /* EBT_ACCEPT, EBT_DROP, EBT_CONTINUE or EBT_RETURN */ int target; }; #define EBT_MARK_TARGET "mark" diff -Nru a/include/linux/netfilter_bridge/ebt_nat.h b/include/linux/netfilter_bridge/ebt_nat.h --- a/include/linux/netfilter_bridge/ebt_nat.h Sun Sep 22 20:14:05 2002 +++ b/include/linux/netfilter_bridge/ebt_nat.h Mon Mar 3 04:41:09 2003 @@ -4,7 +4,7 @@ struct ebt_nat_info { unsigned char mac[ETH_ALEN]; - // EBT_ACCEPT, EBT_DROP, EBT_CONTINUE or EBT_RETURN + /* EBT_ACCEPT, EBT_DROP, EBT_CONTINUE or EBT_RETURN */ int target; }; #define EBT_SNAT_TARGET "snat" diff -Nru a/include/linux/netfilter_bridge/ebt_redirect.h b/include/linux/netfilter_bridge/ebt_redirect.h --- a/include/linux/netfilter_bridge/ebt_redirect.h Sun Sep 22 20:14:05 2002 +++ b/include/linux/netfilter_bridge/ebt_redirect.h Mon Mar 3 04:41:09 2003 @@ -3,7 +3,7 @@ struct ebt_redirect_info { - // EBT_ACCEPT, EBT_DROP or EBT_CONTINUE or EBT_RETURN + /* EBT_ACCEPT, EBT_DROP, EBT_CONTINUE or EBT_RETURN */ int target; }; #define EBT_REDIRECT_TARGET "redirect" diff -Nru a/include/linux/netfilter_bridge/ebtables.h b/include/linux/netfilter_bridge/ebtables.h --- a/include/linux/netfilter_bridge/ebtables.h Mon Oct 28 05:00:13 2002 +++ b/include/linux/netfilter_bridge/ebtables.h Mon Mar 3 04:41:09 2003 @@ -2,7 +2,7 @@ * ebtables * * Authors: - * Bart De Schuymer + * Bart De Schuymer * * ebtables.c,v 2.0, April, 2002 * @@ -20,7 +20,7 @@ #define EBT_CHAIN_MAXNAMELEN EBT_TABLE_MAXNAMELEN #define EBT_FUNCTION_MAXNAMELEN EBT_TABLE_MAXNAMELEN -// verdicts >0 are "branches" +/* verdicts >0 are "branches" */ #define EBT_ACCEPT -1 #define EBT_DROP -2 #define EBT_CONTINUE -3 @@ -34,33 +34,34 @@ }; struct ebt_entries { - // this field is always set to zero - // See EBT_ENTRY_OR_ENTRIES. - // Must be same size as ebt_entry.bitmask + /* this field is always set to zero + * See EBT_ENTRY_OR_ENTRIES. + * Must be same size as ebt_entry.bitmask */ unsigned int distinguisher; - // the chain name + /* the chain name */ char name[EBT_CHAIN_MAXNAMELEN]; - // counter offset for this chain + /* counter offset for this chain */ unsigned int counter_offset; - // one standard (accept, drop, return) per hook + /* one standard (accept, drop, return) per hook */ int policy; - // nr. of entries + /* nr. of entries */ unsigned int nentries; - // entry list + /* entry list */ char data[0]; }; -// used for the bitmask of struct ebt_entry +/* used for the bitmask of struct ebt_entry */ -// This is a hack to make a difference between an ebt_entry struct and an -// ebt_entries struct when traversing the entries from start to end. -// Using this simplifies the code alot, while still being able to use -// ebt_entries. -// Contrary, iptables doesn't use something like ebt_entries and therefore uses -// different techniques for naming the policy and such. So, iptables doesn't -// need a hack like this. +/* This is a hack to make a difference between an ebt_entry struct and an + * ebt_entries struct when traversing the entries from start to end. + * Using this simplifies the code alot, while still being able to use + * ebt_entries. + * Contrary, iptables doesn't use something like ebt_entries and therefore uses + * different techniques for naming the policy and such. So, iptables doesn't + * need a hack like this. + */ #define EBT_ENTRY_OR_ENTRIES 0x01 -// these are the normal masks +/* these are the normal masks */ #define EBT_NOPROTO 0x02 #define EBT_802_3 0x04 #define EBT_SOURCEMAC 0x08 @@ -84,7 +85,7 @@ char name[EBT_FUNCTION_MAXNAMELEN]; struct ebt_match *match; } u; - // size of data + /* size of data */ unsigned int match_size; unsigned char data[0]; }; @@ -95,7 +96,7 @@ char name[EBT_FUNCTION_MAXNAMELEN]; struct ebt_watcher *watcher; } u; - // size of data + /* size of data */ unsigned int watcher_size; unsigned char data[0]; }; @@ -106,7 +107,7 @@ char name[EBT_FUNCTION_MAXNAMELEN]; struct ebt_target *target; } u; - // size of data + /* size of data */ unsigned int target_size; unsigned char data[0]; }; @@ -118,29 +119,29 @@ int verdict; }; -// one entry +/* one entry */ struct ebt_entry { - // this needs to be the first field + /* this needs to be the first field */ unsigned int bitmask; unsigned int invflags; uint16_t ethproto; - // the physical in-dev + /* the physical in-dev */ char in[IFNAMSIZ]; - // the logical in-dev + /* the logical in-dev */ char logical_in[IFNAMSIZ]; - // the physical out-dev + /* the physical out-dev */ char out[IFNAMSIZ]; - // the logical out-dev + /* the logical out-dev */ char logical_out[IFNAMSIZ]; unsigned char sourcemac[ETH_ALEN]; unsigned char sourcemsk[ETH_ALEN]; unsigned char destmac[ETH_ALEN]; unsigned char destmsk[ETH_ALEN]; - // sizeof ebt_entry + matches + /* sizeof ebt_entry + matches */ unsigned int watchers_offset; - // sizeof ebt_entry + matches + watchers + /* sizeof ebt_entry + matches + watchers */ unsigned int target_offset; - // sizeof ebt_entry + matches + watchers + target + /* sizeof ebt_entry + matches + watchers + target */ unsigned int next_offset; unsigned char elems[0]; }; @@ -149,20 +150,20 @@ { char name[EBT_TABLE_MAXNAMELEN]; unsigned int valid_hooks; - // nr of rules in the table + /* nr of rules in the table */ unsigned int nentries; - // total size of the entries + /* total size of the entries */ unsigned int entries_size; - // start of the chains + /* start of the chains */ struct ebt_entries *hook_entry[NF_BR_NUMHOOKS]; - // nr of counters userspace expects back + /* nr of counters userspace expects back */ unsigned int num_counters; - // where the kernel will put the old counters + /* where the kernel will put the old counters */ struct ebt_counter *counters; char *entries; }; -// [gs]etsockopt numbers +/* {g,s}etsockopt numbers */ #define EBT_BASE_CTL 128 #define EBT_SO_SET_ENTRIES (EBT_BASE_CTL) @@ -177,7 +178,7 @@ #ifdef __KERNEL__ -// return values for match() functions +/* return values for match() functions */ #define EBT_MATCH 0 #define EBT_NOMATCH 1 @@ -185,11 +186,11 @@ { struct list_head list; const char name[EBT_FUNCTION_MAXNAMELEN]; - // 0 == it matches + /* 0 == it matches */ int (*match)(const struct sk_buff *skb, const struct net_device *in, const struct net_device *out, const void *matchdata, unsigned int datalen); - // 0 == let it in + /* 0 == let it in */ int (*check)(const char *tablename, unsigned int hookmask, const struct ebt_entry *e, void *matchdata, unsigned int datalen); void (*destroy)(void *matchdata, unsigned int datalen); @@ -203,7 +204,7 @@ void (*watcher)(const struct sk_buff *skb, const struct net_device *in, const struct net_device *out, const void *watcherdata, unsigned int datalen); - // 0 == let it in + /* 0 == let it in */ int (*check)(const char *tablename, unsigned int hookmask, const struct ebt_entry *e, void *watcherdata, unsigned int datalen); void (*destroy)(void *watcherdata, unsigned int datalen); @@ -214,33 +215,33 @@ { struct list_head list; const char name[EBT_FUNCTION_MAXNAMELEN]; - // returns one of the standard verdicts + /* returns one of the standard verdicts */ int (*target)(struct sk_buff **pskb, unsigned int hooknr, const struct net_device *in, const struct net_device *out, const void *targetdata, unsigned int datalen); - // 0 == let it in + /* 0 == let it in */ int (*check)(const char *tablename, unsigned int hookmask, const struct ebt_entry *e, void *targetdata, unsigned int datalen); void (*destroy)(void *targetdata, unsigned int datalen); struct module *me; }; -// used for jumping from and into user defined chains (udc) +/* used for jumping from and into user defined chains (udc) */ struct ebt_chainstack { - struct ebt_entries *chaininfo; // pointer to chain data - struct ebt_entry *e; // pointer to entry data - unsigned int n; // n'th entry + struct ebt_entries *chaininfo; /* pointer to chain data */ + struct ebt_entry *e; /* pointer to entry data */ + unsigned int n; /* n'th entry */ }; struct ebt_table_info { - // total size of the entries + /* total size of the entries */ unsigned int entries_size; unsigned int nentries; - // pointers to the start of the chains + /* pointers to the start of the chains */ struct ebt_entries *hook_entry[NF_BR_NUMHOOKS]; - // room to maintain the stack used for jumping from and into udc + /* room to maintain the stack used for jumping from and into udc */ struct ebt_chainstack **chainstack; char *entries; struct ebt_counter counters[0] ____cacheline_aligned; @@ -253,11 +254,11 @@ struct ebt_replace *table; unsigned int valid_hooks; rwlock_t lock; - // e.g. could be the table explicitly only allows certain - // matches, targets, ... 0 == let it in + /* e.g. could be the table explicitly only allows certain + * matches, targets, ... 0 == let it in */ int (*check)(const struct ebt_table_info *info, unsigned int valid_hooks); - // the data used by the kernel + /* the data used by the kernel */ struct ebt_table_info *private; }; @@ -273,20 +274,20 @@ const struct net_device *in, const struct net_device *out, struct ebt_table *table); - // Used in the kernel match() functions +/* Used in the kernel match() functions */ #define FWINV(bool,invflg) ((bool) ^ !!(info->invflags & invflg)) -// True if the hook mask denotes that the rule is in a base chain, -// used in the check() functions +/* True if the hook mask denotes that the rule is in a base chain, + * used in the check() functions */ #define BASE_CHAIN (hookmask & (1 << NF_BR_NUMHOOKS)) -// Clear the bit in the hook mask that tells if the rule is on a base chain +/* Clear the bit in the hook mask that tells if the rule is on a base chain */ #define CLEAR_BASE_CHAIN_BIT (hookmask &= ~(1 << NF_BR_NUMHOOKS)) -// True if the target is not a standard target +/* True if the target is not a standard target */ #define INVALID_TARGET (info->target < -NUM_STANDARD_TARGETS || info->target >= 0) #endif /* __KERNEL__ */ -// blatently stolen from ip_tables.h -// fn returns 0 to continue iteration +/* blatently stolen from ip_tables.h + * fn returns 0 to continue iteration */ #define EBT_MATCH_ITERATE(e, fn, args...) \ ({ \ unsigned int __i; \ diff -Nru a/include/linux/netfilter_ipv4/ipchains_core.h b/include/linux/netfilter_ipv4/ipchains_core.h --- a/include/linux/netfilter_ipv4/ipchains_core.h Tue Feb 5 09:39:43 2002 +++ b/include/linux/netfilter_ipv4/ipchains_core.h Sun Feb 16 16:16:10 2003 @@ -178,12 +178,8 @@ #include #include -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,0) #include extern void ip_fw_init(void) __init; -#else /* 2.0.x */ -extern void ip_fw_init(void); -#endif /* 2.1.x */ extern int ip_fw_ctl(int, void *, int); #ifdef CONFIG_IP_MASQUERADE extern int ip_masq_uctl(int, char *, int); diff -Nru a/include/linux/pci.h b/include/linux/pci.h --- a/include/linux/pci.h Mon Feb 24 08:17:50 2003 +++ b/include/linux/pci.h Tue Feb 25 15:37:27 2003 @@ -413,6 +413,7 @@ /* These fields are used by common fixups */ unsigned int transparent:1; /* Transparent PCI bridge */ + unsigned int multifunction:1;/* Part of multi-function device */ }; #define pci_dev_g(n) list_entry(n, struct pci_dev, global_list) @@ -548,7 +549,8 @@ { return pci_alloc_primary_bus_parented(NULL, bus); } -struct pci_dev *pci_scan_slot(struct pci_dev *temp); +int pci_scan_slot(struct pci_bus *bus, int devfn); +void pci_bus_add_devices(struct pci_bus *bus); int pci_proc_attach_device(struct pci_dev *dev); int pci_proc_detach_device(struct pci_dev *dev); int pci_proc_attach_bus(struct pci_bus *bus); @@ -641,6 +643,16 @@ int pci_request_region(struct pci_dev *, int, char *); void pci_release_region(struct pci_dev *, int); +/* drivers/pci/bus.c */ + +int pci_bus_alloc_resource(struct pci_bus *bus, struct resource *res, + unsigned long size, unsigned long align, + unsigned long min, unsigned int type_mask, + void (*alignf)(void *, struct resource *, + unsigned long, unsigned long), + void *alignf_data); +void pci_enable_bridges(struct pci_bus *bus); + /* New-style probing supporting hot-pluggable devices */ int pci_register_driver(struct pci_driver *); void pci_unregister_driver(struct pci_driver *); @@ -844,7 +856,7 @@ #define PCIPCI_NATOMA 4 #define PCIPCI_VIAETBF 8 #define PCIPCI_VSFX 16 - +#define PCIPCI_ALIMAGIK 32 #endif /* __KERNEL__ */ #endif /* LINUX_PCI_H */ diff -Nru a/include/linux/profile.h b/include/linux/profile.h --- a/include/linux/profile.h Tue Feb 18 18:59:01 2003 +++ b/include/linux/profile.h Wed Feb 26 18:41:10 2003 @@ -2,15 +2,15 @@ #define _LINUX_PROFILE_H #ifdef __KERNEL__ - + #include #include #include #include - + /* parse command line */ int __init profile_setup(char * str); - + /* init basic kernel profiler */ void __init profile_init(void); @@ -27,14 +27,14 @@ }; #ifdef CONFIG_PROFILING - + struct notifier_block; struct task_struct; struct mm_struct; - + /* task is in do_exit() */ void profile_exit_task(struct task_struct * task); - + /* change of vma mappings */ void profile_exec_unmap(struct mm_struct * mm); @@ -44,10 +44,10 @@ int profile_event_register(enum profile_type, struct notifier_block * n); int profile_event_unregister(enum profile_type, struct notifier_block * n); - + int register_profile_notifier(struct notifier_block * nb); int unregister_profile_notifier(struct notifier_block * nb); - + /* profiling hook activated on each timer interrupt */ void profile_hook(struct pt_regs * regs); @@ -57,12 +57,12 @@ { return -ENOSYS; } - + static inline int profile_event_unregister(enum profile_type t, struct notifier_block * n) { return -ENOSYS; } - + #define profile_exit_task(a) do { } while (0) #define profile_exec_unmap(a) do { } while (0) #define profile_exit_mmap(a) do { } while (0) @@ -80,7 +80,7 @@ #define profile_hook(regs) do { } while (0) #endif /* CONFIG_PROFILING */ - + #endif /* __KERNEL__ */ - + #endif /* _LINUX_PROFILE_H */ diff -Nru a/include/linux/sched.h b/include/linux/sched.h --- a/include/linux/sched.h Mon Feb 24 09:40:34 2003 +++ b/include/linux/sched.h Wed Mar 5 16:00:00 2003 @@ -328,7 +328,7 @@ prio_array_t *array; unsigned long sleep_avg; - unsigned long sleep_timestamp; + unsigned long last_run; unsigned long policy; unsigned long cpus_allowed; diff -Nru a/include/linux/sdladrv.h b/include/linux/sdladrv.h --- a/include/linux/sdladrv.h Mon Feb 4 23:39:17 2002 +++ b/include/linux/sdladrv.h Sun Feb 16 16:22:42 2003 @@ -19,19 +19,6 @@ #ifndef _SDLADRV_H #define _SDLADRV_H -#include - -#ifndef KERNEL_VERSION - #define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) -#endif - -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,0) -#define LINUX_2_4 -#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,0) -#define LINUX_2_1 -#else -#define LINUX_2_0 -#endif #define SDLA_MAXIORANGE 4 /* maximum I/O port range */ #define SDLA_WINDOWSIZE 0x2000 /* default dual-port memory window size */ @@ -50,12 +37,7 @@ char S514_cpu_no[1]; /* PCI CPU Number */ unsigned char S514_slot_no; /* PCI Slot Number */ char auto_pci_cfg; /* Autodetect PCI Slot */ -#if defined(LINUX_2_1) || defined(LINUX_2_4) struct pci_dev *pci_dev; /* PCI device */ -#else - unsigned char pci_bus; /* PCI bus number */ - unsigned char pci_dev_func; /* PCI device/function number */ -#endif void * dpmbase; /* dual-port memory base */ unsigned dpmsize; /* dual-port memory size */ unsigned pclk; /* CPU clock rate, kHz */ diff -Nru a/include/linux/tty.h b/include/linux/tty.h --- a/include/linux/tty.h Sun Dec 29 23:18:11 2002 +++ b/include/linux/tty.h Thu Mar 6 21:27:16 2003 @@ -294,7 +294,7 @@ unsigned char lnext:1, erasing:1, raw:1, real_raw:1, icanon:1; unsigned char closing:1; unsigned short minimum_to_wake; - unsigned overrun_time; + unsigned long overrun_time; int num_overrun; unsigned long process_char_map[256/(8*sizeof(unsigned long))]; char *read_buf; @@ -348,7 +348,6 @@ extern int kmsg_redirect; -extern void con_init(void); extern void console_init(void); extern int lp_init(void); diff -Nru a/include/linux/usb.h b/include/linux/usb.h --- a/include/linux/usb.h Wed Feb 26 08:29:24 2003 +++ b/include/linux/usb.h Wed Mar 5 07:24:34 2003 @@ -213,7 +213,7 @@ struct usb_device { int devnum; /* Address on USB bus */ char devpath [16]; /* Use in messages: /port/port/... */ - + enum usb_device_state state; /* configured, not attached, etc */ enum usb_device_speed speed; /* high/full/low (or error) */ struct usb_tt *tt; /* low/full speed dev, highspeed hub */ @@ -240,7 +240,6 @@ int have_langid; /* whether string_langid is valid yet */ int string_langid; /* language ID for strings */ - int present; /* if device is present or not */ void *hcpriv; /* Host Controller private data */ diff -Nru a/include/linux/usb_ch9.h b/include/linux/usb_ch9.h --- a/include/linux/usb_ch9.h Tue Oct 29 15:14:57 2002 +++ b/include/linux/usb_ch9.h Wed Mar 5 07:28:25 2003 @@ -291,4 +291,25 @@ USB_SPEED_HIGH /* usb 2.0 */ }; +enum usb_device_state { + /* NOTATTACHED isn't in the USB spec, and this state acts + * the same as ATTACHED ... but it's clearer this way. + */ + USB_STATE_NOTATTACHED = 0, + + /* the chapter 9 device states */ + USB_STATE_ATTACHED, + USB_STATE_POWERED, + USB_STATE_DEFAULT, /* limited function */ + USB_STATE_ADDRESS, + USB_STATE_CONFIGURED, /* most functions */ + + USB_STATE_SUSPENDED + + /* NOTE: there are actually four different SUSPENDED + * states, returning to POWERED, DEFAULT, ADDRESS, or + * CONFIGURED respectively when SOF tokens flow again. + */ +}; + #endif /* __LINUX_USB_CH9_H */ diff -Nru a/include/linux/wanpipe.h b/include/linux/wanpipe.h --- a/include/linux/wanpipe.h Sun Dec 8 05:52:12 2002 +++ b/include/linux/wanpipe.h Sun Feb 16 16:22:42 2003 @@ -39,59 +39,7 @@ #ifndef _WANPIPE_H #define _WANPIPE_H -#include - -#ifndef KERNEL_VERSION - #define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) -#endif - -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,0) - - #define LINUX_2_4 - #define netdevice_t struct net_device - - #define FREE_READ 1 - #define FREE_WRITE 0 - - #define stop_net_queue(a) netif_stop_queue(a) - #define start_net_queue(a) netif_start_queue(a) - #define is_queue_stopped(a) netif_queue_stopped(a) - #define wake_net_dev(a) netif_wake_queue(a) - #define is_dev_running(a) netif_running(a) - #define wan_dev_kfree_skb(a,b) dev_kfree_skb_any(a) - - -#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,0) - - #define LINUX_2_1 - #define netdevice_t struct device - #define FREE_READ 1 - #define FREE_WRITE 0 - - #define stop_net_queue(a) (set_bit(0, &##a->tbusy)) - #define start_net_queue(a) (clear_bit(0,&##a->tbusy)) - #define is_queue_stopped(a) (##a->tbusy) - #define wake_net_dev(a) {clear_bit(0,&##a->tbusy);mark_bh(NET_BH);} - #define is_dev_running(a) (test_bit(0,&##a->start)) - #define wan_dev_kfree_skb(a,b) dev_kfree_skb(a) - -#else - #define LINUX_2_0 - #define netdevice_t struct device - - #define test_and_set_bit set_bit - #define net_ratelimit() 1 - - #define stop_net_queue(a) (set_bit(0, &##a->tbusy)) - #define start_net_queue(a) (clear_bit(0,&##a->tbusy)) - #define is_queue_stopped(a) (##a->tbusy) - #define wake_net_dev(a) {clear_bit(0,&##a->tbusy);mark_bh(NET_BH);} - #define is_dev_running(a) (test_bit(0,(void*)&##a->start)) - #define wan_dev_kfree_skb(a,b) dev_kfree_skb(a,b) - #define spin_lock_init(a) - #define spin_lock(a) - #define spin_unlock(a) -#endif +#define netdevice_t struct net_device #include @@ -121,21 +69,11 @@ #define MAX_LCN_NUM 4095 /* Maximum lcn number */ #define MAX_FT1_RETRY 100 -#ifdef LINUX_2_4 - #ifndef AF_WANPIPE +#ifndef AF_WANPIPE #define AF_WANPIPE 25 #ifndef PF_WANPIPE #define PF_WANPIPE AF_WANPIPE #endif - #endif - -#else - #ifndef AF_WANPIPE - #define AF_WANPIPE 24 - #ifndef PF_WANPIPE - #define PF_WANPIPE AF_WANPIPE - #endif - #endif #endif @@ -321,12 +259,10 @@ #include /* SDLA support module API definitions */ #include /* SDLA firmware module definitions */ #include -#ifdef LINUX_2_4 - #include - #include - #include - #include -#endif +#include +#include +#include +#include #include #include #include diff -Nru a/include/linux/wanrouter.h b/include/linux/wanrouter.h --- a/include/linux/wanrouter.h Wed Apr 24 10:11:41 2002 +++ b/include/linux/wanrouter.h Sun Feb 16 16:22:42 2003 @@ -43,27 +43,10 @@ * Jan 16, 1997 Gene Kozin router_devlist made public * Jan 02, 1997 Gene Kozin Initial version (based on wanpipe.h). *****************************************************************************/ -#include -#ifndef KERNEL_VERSION - #define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) -#endif - -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,0) - #define LINUX_2_4 - #define netdevice_t struct net_device - #include /* Support for SMP Locking */ - -#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,0) - #define LINUX_2_1 - #define netdevice_t struct device - #include /* Support for SMP Locking */ - -#else - #define LINUX_2_0 - #define netdevice_t struct device - #define spinlock_t int -#endif +#define netdevice_t struct net_device + +#include /* Support for SMP Locking */ #ifndef _ROUTER_H #define _ROUTER_H @@ -512,11 +495,7 @@ /****** status and statistics *******/ char state; /* device state */ char api_status; /* device api status */ -#if defined(LINUX_2_1) || defined(LINUX_2_4) struct net_device_stats stats; /* interface statistics */ -#else - struct enet_statistics stats; /* interface statistics */ -#endif unsigned reserved[16]; /* reserved for future use */ unsigned long critical; /* critical section flag */ spinlock_t lock; /* Support for SMP Locking */ @@ -534,11 +513,7 @@ struct wan_device* next; /* -> next device */ netdevice_t* dev; /* list of network interfaces */ unsigned ndev; /* number of interfaces */ -#ifdef LINUX_2_4 struct proc_dir_entry *dent; /* proc filesystem entry */ -#else - struct proc_dir_entry dent; /* proc filesystem entry */ -#endif } wan_device_t; /* Public functions available for device drivers */ diff -Nru a/include/net/ah.h b/include/net/ah.h --- /dev/null Wed Dec 31 16:00:00 1969 +++ b/include/net/ah.h Thu Mar 6 16:15:33 2003 @@ -0,0 +1,35 @@ +#ifndef _NET_AH_H +#define _NET_AH_H + +#include + +struct ah_data +{ + u8 *key; + int key_len; + u8 *work_icv; + int icv_full_len; + int icv_trunc_len; + + void (*icv)(struct ah_data*, + struct sk_buff *skb, u8 *icv); + + struct crypto_tfm *tfm; +}; + +extern void skb_ah_walk(const struct sk_buff *skb, + struct crypto_tfm *tfm, icv_update_fn_t icv_update); + +static inline void +ah_hmac_digest(struct ah_data *ahp, struct sk_buff *skb, u8 *auth_data) +{ + struct crypto_tfm *tfm = ahp->tfm; + + memset(auth_data, 0, ahp->icv_trunc_len); + crypto_hmac_init(tfm, ahp->key, &ahp->key_len); + skb_ah_walk(skb, tfm, crypto_hmac_update); + crypto_hmac_final(tfm, ahp->key, &ahp->key_len, ahp->work_icv); + memcpy(auth_data, ahp->work_icv, ahp->icv_trunc_len); +} + +#endif diff -Nru a/include/net/dn_route.h b/include/net/dn_route.h --- a/include/net/dn_route.h Wed Feb 19 13:55:33 2003 +++ b/include/net/dn_route.h Mon Mar 3 04:56:52 2003 @@ -134,7 +134,7 @@ } sk->err = EHOSTUNREACH; - if (!sk->dead) + if (!test_bit(SOCK_DEAD, &sk->flags)) sk->state_change(sk); } diff -Nru a/include/net/dst.h b/include/net/dst.h --- a/include/net/dst.h Sun Dec 22 23:29:59 2002 +++ b/include/net/dst.h Wed Mar 5 15:45:36 2003 @@ -247,7 +247,10 @@ struct flowi; extern int xfrm_lookup(struct dst_entry **dst_p, struct flowi *fl, struct sock *sk, int flags); +extern int xfrm6_lookup(struct dst_entry **dst_p, struct flowi *fl, + struct sock *sk, int flags); extern void xfrm_init(void); +extern void xfrm6_init(void); #endif diff -Nru a/include/net/esp.h b/include/net/esp.h --- /dev/null Wed Dec 31 16:00:00 1969 +++ b/include/net/esp.h Thu Mar 6 16:15:34 2003 @@ -0,0 +1,56 @@ +#ifndef _NET_ESP_H +#define _NET_ESP_H + +#include + +struct esp_data +{ + /* Confidentiality */ + struct { + u8 *key; /* Key */ + int key_len; /* Key length */ + u8 *ivec; /* ivec buffer */ + /* ivlen is offset from enc_data, where encrypted data start. + * It is logically different of crypto_tfm_alg_ivsize(tfm). + * We assume that it is either zero (no ivec), or + * >= crypto_tfm_alg_ivsize(tfm). */ + int ivlen; + int padlen; /* 0..255 */ + struct crypto_tfm *tfm; /* crypto handle */ + } conf; + + /* Integrity. It is active when icv_full_len != 0 */ + struct { + u8 *key; /* Key */ + int key_len; /* Length of the key */ + u8 *work_icv; + int icv_full_len; + int icv_trunc_len; + void (*icv)(struct esp_data*, + struct sk_buff *skb, + int offset, int len, u8 *icv); + struct crypto_tfm *tfm; + } auth; +}; + +extern void skb_icv_walk(const struct sk_buff *skb, struct crypto_tfm *tfm, + int offset, int len, icv_update_fn_t icv_update); +extern int skb_to_sgvec(struct sk_buff *skb, struct scatterlist *sg, int offset, int len); +extern int skb_cow_data(struct sk_buff *skb, int tailbits, struct sk_buff **trailer); +extern void *pskb_put(struct sk_buff *skb, struct sk_buff *tail, int len); + +static inline void +esp_hmac_digest(struct esp_data *esp, struct sk_buff *skb, int offset, + int len, u8 *auth_data) +{ + struct crypto_tfm *tfm = esp->auth.tfm; + char *icv = esp->auth.work_icv; + + memset(auth_data, 0, esp->auth.icv_trunc_len); + crypto_hmac_init(tfm, esp->auth.key, &esp->auth.key_len); + skb_icv_walk(skb, tfm, offset, len, crypto_hmac_update); + crypto_hmac_final(tfm, esp->auth.key, &esp->auth.key_len, icv); + memcpy(auth_data, icv, esp->auth.icv_trunc_len); +} + +#endif diff -Nru a/include/net/ip6_route.h b/include/net/ip6_route.h --- a/include/net/ip6_route.h Sun Feb 23 22:41:51 2003 +++ b/include/net/ip6_route.h Wed Mar 5 15:45:36 2003 @@ -57,6 +57,8 @@ struct in6_addr *saddr, int oif, int flags); +extern struct rt6_info *ndisc_get_dummy_rt(void); + /* * support functions for ND * diff -Nru a/include/net/sock.h b/include/net/sock.h --- a/include/net/sock.h Fri Feb 7 01:48:38 2003 +++ b/include/net/sock.h Mon Mar 3 04:56:52 2003 @@ -29,6 +29,8 @@ * protocol specific parts were moved to * respective headers and ipv4/v6, etc now * use private slabcaches for its socks + * Pedro Hortas : New flags field for socket options + * * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -60,6 +62,18 @@ * the other protocols. */ +/* Sock flags */ +enum { + SOCK_DEAD, + SOCK_DONE, + SOCK_URGINLINE, + SOCK_KEEPOPEN, + SOCK_LINGER, + SOCK_DESTROY, + SOCK_BROADCAST, + SOCK_BSDISM, +}; + /* Define this to get the sk->debug debugging facility. */ #define SOCK_DEBUGGING #ifdef SOCK_DEBUGGING @@ -120,18 +134,8 @@ int sndbuf; /* Size of send buffer in bytes */ struct sock *prev; - /* Not all are volatile, but some are, so we might as well say they all are. - * XXX Make this a flag word -DaveM - */ - volatile char dead, - done, - urginline, - keepopen, - linger, - destroy, - no_check, - broadcast, - bsdism; + unsigned long flags; + char no_check; unsigned char debug; unsigned char rcvtstamp; unsigned char no_largesend; @@ -605,7 +609,7 @@ static inline void sock_orphan(struct sock *sk) { write_lock_bh(&sk->callback_lock); - sk->dead = 1; + __set_bit(SOCK_DEAD, &sk->flags); sk->socket = NULL; sk->sleep = NULL; write_unlock_bh(&sk->callback_lock); @@ -769,7 +773,7 @@ skb->dev = NULL; skb_set_owner_r(skb, sk); skb_queue_tail(&sk->receive_queue, skb); - if (!sk->dead) + if (!test_bit(SOCK_DEAD, &sk->flags)) sk->data_ready(sk,skb->len); out: return err; @@ -784,7 +788,7 @@ return -ENOMEM; skb_set_owner_r(skb, sk); skb_queue_tail(&sk->error_queue,skb); - if (!sk->dead) + if (!test_bit(SOCK_DEAD, &sk->flags)) sk->data_ready(sk,skb->len); return 0; } @@ -895,6 +899,14 @@ remove_wait_queue((sk)->sleep, &wait); \ lock_sock(sk); \ } + +static inline void sock_valbool_flag(struct sock *sk, int bit, int valbool) +{ + if (valbool) + __set_bit(bit, &sk->flags); + else + __clear_bit(bit, &sk->flags); +} extern __u32 sysctl_wmem_max; extern __u32 sysctl_rmem_max; diff -Nru a/include/net/tcp.h b/include/net/tcp.h --- a/include/net/tcp.h Mon Feb 10 14:44:43 2003 +++ b/include/net/tcp.h Mon Mar 3 04:56:52 2003 @@ -1422,7 +1422,7 @@ sk->shutdown = SHUTDOWN_MASK; - if (!sk->dead) + if (!test_bit(SOCK_DEAD, &sk->flags)) sk->state_change(sk); else tcp_destroy_sock(sk); diff -Nru a/include/net/xfrm.h b/include/net/xfrm.h --- a/include/net/xfrm.h Thu Feb 13 01:26:32 2003 +++ b/include/net/xfrm.h Thu Mar 6 16:16:15 2003 @@ -12,6 +12,7 @@ #include #include +#include #define XFRM_ALIGN8(len) (((len) + 7) & ~7) @@ -223,7 +224,7 @@ char *id; int (*notify)(struct xfrm_state *x, int event); int (*acquire)(struct xfrm_state *x, struct xfrm_tmpl *, struct xfrm_policy *xp, int dir); - struct xfrm_policy *(*compile_policy)(int opt, u8 *data, int len, int *dir); + struct xfrm_policy *(*compile_policy)(u16 family, int opt, u8 *data, int len, int *dir); }; extern int xfrm_register_km(struct xfrm_mgr *km); @@ -282,6 +283,7 @@ struct xfrm_dst *next; struct dst_entry dst; struct rtable rt; + struct rt6_info rt6; } u; }; @@ -308,26 +310,42 @@ if (sp && atomic_dec_and_test(&sp->refcnt)) __secpath_destroy(sp); } - -extern int __xfrm_policy_check(struct sock *, int dir, struct sk_buff *skb); +extern int __xfrm_policy_check(struct sock *, int dir, struct sk_buff *skb, unsigned short family); static inline int xfrm_policy_check(struct sock *sk, int dir, struct sk_buff *skb) { if (sk && sk->policy[XFRM_POLICY_IN]) - return __xfrm_policy_check(sk, dir, skb); + return __xfrm_policy_check(sk, dir, skb, AF_INET); + + return !xfrm_policy_list[dir] || + (skb->dst->flags & DST_NOPOLICY) || + __xfrm_policy_check(sk, dir, skb, AF_INET); +} + +static inline int xfrm6_policy_check(struct sock *sk, int dir, struct sk_buff *skb) +{ + if (sk && sk->policy[XFRM_POLICY_IN]) + return __xfrm_policy_check(sk, dir, skb, AF_INET6); return !xfrm_policy_list[dir] || (skb->dst->flags & DST_NOPOLICY) || - __xfrm_policy_check(sk, dir, skb); + __xfrm_policy_check(sk, dir, skb, AF_INET6); } -extern int __xfrm_route_forward(struct sk_buff *skb); +extern int __xfrm_route_forward(struct sk_buff *skb, unsigned short family); static inline int xfrm_route_forward(struct sk_buff *skb) { return !xfrm_policy_list[XFRM_POLICY_OUT] || (skb->dst->flags & DST_NOXFRM) || - __xfrm_route_forward(skb); + __xfrm_route_forward(skb, AF_INET); +} + +static inline int xfrm6_route_forward(struct sk_buff *skb) +{ + return !xfrm_policy_list[XFRM_POLICY_OUT] || + (skb->dst->flags & DST_NOXFRM) || + __xfrm_route_forward(skb, AF_INET6); } extern int __xfrm_sk_clone_policy(struct sock *sk); @@ -380,12 +398,16 @@ extern void xfrm_input_init(void); extern int xfrm_state_walk(u8 proto, int (*func)(struct xfrm_state *, int, void*), void *); extern struct xfrm_state *xfrm_state_alloc(void); -extern struct xfrm_state *xfrm_state_find(u32 daddr, u32 saddr, struct flowi *fl, struct xfrm_tmpl *tmpl, - struct xfrm_policy *pol, int *err); +extern struct xfrm_state *xfrm4_state_find(u32 daddr, u32 saddr, struct flowi *fl, struct xfrm_tmpl *tmpl, + struct xfrm_policy *pol, int *err); +extern struct xfrm_state *xfrm6_state_find(struct in6_addr *daddr, struct in6_addr *saddr, + struct flowi *fl, struct xfrm_tmpl *tmpl, + struct xfrm_policy *pol, int *err); extern int xfrm_state_check_expire(struct xfrm_state *x); extern void xfrm_state_insert(struct xfrm_state *x); extern int xfrm_state_check_space(struct xfrm_state *x, struct sk_buff *skb); -extern struct xfrm_state *xfrm_state_lookup(u32 daddr, u32 spi, u8 proto); +extern struct xfrm_state *xfrm4_state_lookup(u32 daddr, u32 spi, u8 proto); +extern struct xfrm_state *xfrm6_state_lookup(struct in6_addr *daddr, u32 spi, u8 proto); extern struct xfrm_state *xfrm_find_acq_byseq(u32 seq); extern void xfrm_state_delete(struct xfrm_state *x); extern void xfrm_state_flush(u8 proto); @@ -393,17 +415,21 @@ extern void xfrm_replay_advance(struct xfrm_state *x, u32 seq); extern int xfrm_check_selectors(struct xfrm_state **x, int n, struct flowi *fl); extern int xfrm4_rcv(struct sk_buff *skb); +extern int xfrm6_rcv(struct sk_buff *skb); +extern int xfrm6_clear_mutable_options(struct sk_buff *skb, u16 *nh_offset, int dir); extern int xfrm_user_policy(struct sock *sk, int optname, u8 *optval, int optlen); struct xfrm_policy *xfrm_policy_alloc(int gfp); extern int xfrm_policy_walk(int (*func)(struct xfrm_policy *, int, int, void*), void *); -struct xfrm_policy *xfrm_policy_lookup(int dir, struct flowi *fl); +struct xfrm_policy *xfrm_policy_lookup(int dir, struct flowi *fl, unsigned short family); int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl); struct xfrm_policy *xfrm_policy_delete(int dir, struct xfrm_selector *sel); struct xfrm_policy *xfrm_policy_byid(int dir, u32 id, int delete); void xfrm_policy_flush(void); void xfrm_alloc_spi(struct xfrm_state *x, u32 minspi, u32 maxspi); struct xfrm_state * xfrm_find_acq(u8 mode, u16 reqid, u8 proto, u32 daddr, u32 saddr, int create); +struct xfrm_state * xfrm6_find_acq(u8 mode, u16 reqid, u8 proto, struct in6_addr *daddr, + struct in6_addr *saddr, int create); extern void xfrm_policy_flush(void); extern void xfrm_policy_kill(struct xfrm_policy *); extern int xfrm_sk_policy_insert(struct sock *sk, int dir, struct xfrm_policy *pol); @@ -425,23 +451,52 @@ extern struct xfrm_algo_desc *xfrm_aalg_get_byname(char *name); extern struct xfrm_algo_desc *xfrm_ealg_get_byname(char *name); +static __inline__ int addr_match(void *token1, void *token2, int prefixlen) +{ + __u32 *a1 = token1; + __u32 *a2 = token2; + int pdw; + int pbi; + + pdw = prefixlen >> 5; /* num of whole __u32 in prefix */ + pbi = prefixlen & 0x1f; /* num of bits in incomplete u32 in prefix */ + + if (pdw) + if (memcmp(a1, a2, pdw << 2)) + return 0; + + if (pbi) { + __u32 mask; + + mask = htonl((0xffffffff) << (32 - pbi)); + + if ((a1[pdw] ^ a2[pdw]) & mask) + return 0; + } + + return 1; +} + static inline int xfrm6_selector_match(struct xfrm_selector *sel, struct flowi *fl) { - return !memcmp(fl->fl6_dst, sel->daddr.a6, sizeof(struct in6_addr)) && - !((fl->uli_u.ports.dport^sel->dport)&sel->dport_mask) && - !((fl->uli_u.ports.sport^sel->sport)&sel->sport_mask) && - (fl->proto == sel->proto || !sel->proto) && - (fl->oif == sel->ifindex || !sel->ifindex) && - !memcmp(fl->fl6_src, sel->saddr.a6, sizeof(struct in6_addr)); + return addr_match(fl->fl6_dst, &sel->daddr, sel->prefixlen_d) && + addr_match(fl->fl6_src, &sel->saddr, sel->prefixlen_s) && + !((fl->uli_u.ports.dport^sel->dport)&sel->dport_mask) && + !((fl->uli_u.ports.sport^sel->sport)&sel->sport_mask) && + (fl->proto == sel->proto || !sel->proto) && + (fl->oif == sel->ifindex || !sel->ifindex); } extern int xfrm6_register_type(struct xfrm_type *type); extern int xfrm6_unregister_type(struct xfrm_type *type); extern struct xfrm_type *xfrm6_get_type(u8 proto); -extern struct xfrm_state *xfrm6_state_lookup(struct in6_addr *daddr, u32 spi, u8 proto); -struct xfrm_state * xfrm6_find_acq(u8 mode, u16 reqid, u8 proto, struct in6_addr *daddr, struct in6_addr *saddr, int create); -void xfrm6_alloc_spi(struct xfrm_state *x, u32 minspi, u32 maxspi); +struct crypto_tfm; +typedef void (icv_update_fn_t)(struct crypto_tfm *, struct scatterlist *, unsigned int); + +typedef int (xfrm_dst_lookup_t)(struct xfrm_dst **dst, struct flowi *fl); +int xfrm_dst_lookup_register(xfrm_dst_lookup_t *dst_lookup, unsigned short family); +void xfrm_dst_lookup_unregister(unsigned short family); #endif /* _NET_XFRM_H */ diff -Nru a/init/do_mounts.c b/init/do_mounts.c --- a/init/do_mounts.c Sat Mar 1 11:25:53 2003 +++ b/init/do_mounts.c Thu Mar 6 16:27:25 2003 @@ -17,7 +17,7 @@ int __initdata rd_doload; /* 1 = load RAM disk, 0 = don't load */ int root_mountflags = MS_RDONLY | MS_VERBOSE; -static char * __initdata root_device_name; +char * __initdata root_device_name; static char __initdata saved_root_name[64]; /* this is initialized in init/main.c */ diff -Nru a/init/do_mounts.h b/init/do_mounts.h --- a/init/do_mounts.h Fri Feb 21 23:12:30 2003 +++ b/init/do_mounts.h Thu Mar 6 16:27:25 2003 @@ -27,6 +27,7 @@ void mount_block_root(char *name, int flags); void mount_root(void); extern int root_mountflags; +extern char *root_device_name; #ifdef CONFIG_DEVFS_FS diff -Nru a/init/do_mounts_rd.c b/init/do_mounts_rd.c --- a/init/do_mounts_rd.c Fri Feb 21 23:12:30 2003 +++ b/init/do_mounts_rd.c Thu Mar 6 16:27:25 2003 @@ -242,6 +242,7 @@ { if (rd_prompt) change_floppy("root floppy disk to be loaded into RAM disk"); + create_dev("/dev/root", ROOT_DEV, root_device_name); create_dev("/dev/ram", MKDEV(RAMDISK_MAJOR, n), NULL); return rd_load_image("/dev/root"); } diff -Nru a/kernel/cpufreq.c b/kernel/cpufreq.c --- a/kernel/cpufreq.c Mon Mar 3 14:38:51 2003 +++ b/kernel/cpufreq.c Thu Mar 6 12:33:33 2003 @@ -354,6 +354,13 @@ &cpufreq_driver->policy[cpu], sizeof(struct cpufreq_policy)); + /* 2.4-API init for this CPU */ +#ifdef CONFIG_CPU_FREQ_24_API + cpu_min_freq[cpu] = cpufreq_driver->policy[cpu].cpuinfo.min_freq; + cpu_max_freq[cpu] = cpufreq_driver->policy[cpu].cpuinfo.max_freq; + cpu_cur_freq[cpu] = cpufreq_driver->cpu_cur_freq[cpu]; +#endif + if (cpufreq_driver->target) cpufreq_governor(cpu, CPUFREQ_GOV_START); diff -Nru a/kernel/fork.c b/kernel/fork.c --- a/kernel/fork.c Thu Feb 27 23:02:30 2003 +++ b/kernel/fork.c Wed Mar 5 16:00:00 2003 @@ -916,7 +916,7 @@ */ p->first_time_slice = 1; current->time_slice >>= 1; - p->sleep_timestamp = jiffies; + p->last_run = jiffies; if (!current->time_slice) { /* * This case is rare, it happens when the parent has only diff -Nru a/kernel/sched.c b/kernel/sched.c --- a/kernel/sched.c Thu Feb 20 20:33:52 2003 +++ b/kernel/sched.c Thu Mar 6 13:13:56 2003 @@ -54,20 +54,19 @@ /* * These are the 'tuning knobs' of the scheduler: * - * Minimum timeslice is 10 msecs, default timeslice is 150 msecs, - * maximum timeslice is 300 msecs. Timeslices get refilled after + * Minimum timeslice is 10 msecs, default timeslice is 100 msecs, + * maximum timeslice is 200 msecs. Timeslices get refilled after * they expire. */ #define MIN_TIMESLICE ( 10 * HZ / 1000) -#define MAX_TIMESLICE (300 * HZ / 1000) -#define CHILD_PENALTY 95 +#define MAX_TIMESLICE (200 * HZ / 1000) +#define CHILD_PENALTY 50 #define PARENT_PENALTY 100 #define EXIT_WEIGHT 3 #define PRIO_BONUS_RATIO 25 #define INTERACTIVE_DELTA 2 -#define MAX_SLEEP_AVG (2*HZ) -#define STARVATION_LIMIT (2*HZ) -#define NODE_THRESHOLD 125 +#define MAX_SLEEP_AVG (10*HZ) +#define STARVATION_LIMIT (10*HZ) /* * If a task is 'interactive' then we reinsert it in the active @@ -323,26 +322,36 @@ * Also update all the scheduling statistics stuff. (sleep average * calculation, priority modifiers, etc.) */ +static inline void __activate_task(task_t *p, runqueue_t *rq) +{ + enqueue_task(p, rq->active); + rq->nr_running++; +} + static inline void activate_task(task_t *p, runqueue_t *rq) { - unsigned long sleep_time = jiffies - p->sleep_timestamp; - prio_array_t *array = rq->active; + unsigned long sleep_time = jiffies - p->last_run; if (!rt_task(p) && sleep_time) { /* * This code gives a bonus to interactive tasks. We update * an 'average sleep time' value here, based on - * sleep_timestamp. The more time a task spends sleeping, + * ->last_run. The more time a task spends sleeping, * the higher the average gets - and the higher the priority * boost gets as well. */ p->sleep_avg += sleep_time; - if (p->sleep_avg > MAX_SLEEP_AVG) + if (p->sleep_avg > MAX_SLEEP_AVG) { + int ticks = p->sleep_avg - MAX_SLEEP_AVG + current->sleep_avg; p->sleep_avg = MAX_SLEEP_AVG; + if (ticks > MAX_SLEEP_AVG) + ticks = MAX_SLEEP_AVG; + if (!in_interrupt()) + current->sleep_avg = ticks; + } p->prio = effective_prio(p); } - enqueue_task(p, array); - nr_running_inc(rq); + __activate_task(p, rq); } /* @@ -479,10 +488,13 @@ } if (old_state == TASK_UNINTERRUPTIBLE) rq->nr_uninterruptible--; - activate_task(p, rq); - - if (p->prio < rq->curr->prio) - resched_task(rq->curr); + if (sync) + __activate_task(p, rq); + else { + activate_task(p, rq); + if (p->prio < rq->curr->prio) + resched_task(rq->curr); + } success = 1; } p->state = TASK_RUNNING; @@ -525,8 +537,16 @@ p->prio = effective_prio(p); } set_task_cpu(p, smp_processor_id()); - activate_task(p, rq); + if (unlikely(!current->array)) + __activate_task(p, rq); + else { + p->prio = current->prio; + list_add_tail(&p->run_list, ¤t->run_list); + p->array = current->array; + p->array->nr_active++; + rq->nr_running++; + } task_rq_unlock(rq, &flags); } @@ -953,6 +973,11 @@ */ if (p->prio < this_rq->curr->prio) set_need_resched(); + else { + if (p->prio == this_rq->curr->prio && + p->time_slice > this_rq->curr->time_slice) + set_need_resched(); + } } /* @@ -1016,7 +1041,7 @@ */ #define CAN_MIGRATE_TASK(p,rq,this_cpu) \ - ((jiffies - (p)->sleep_timestamp > cache_decay_ticks) && \ + ((jiffies - (p)->last_run > cache_decay_ticks) && \ !task_running(rq, p) && \ ((p)->cpus_allowed & (1UL << (this_cpu)))) @@ -1076,9 +1101,9 @@ * increasing number of running tasks: */ #define EXPIRED_STARVING(rq) \ - ((rq)->expired_timestamp && \ + (STARVATION_LIMIT && ((rq)->expired_timestamp && \ (jiffies - (rq)->expired_timestamp >= \ - STARVATION_LIMIT * ((rq)->nr_running) + 1)) + STARVATION_LIMIT * ((rq)->nr_running) + 1))) /* * This function gets called by the timer code, with HZ frequency. @@ -1201,7 +1226,7 @@ rq = this_rq(); release_kernel_lock(prev); - prev->sleep_timestamp = jiffies; + prev->last_run = jiffies; spin_lock_irq(&rq->lock); /* @@ -1701,7 +1726,7 @@ else p->prio = p->static_prio; if (array) - activate_task(p, task_rq(p)); + __activate_task(p, task_rq(p)); out_unlock: task_rq_unlock(rq, &flags); diff -Nru a/mm/fremap.c b/mm/fremap.c --- a/mm/fremap.c Wed Feb 5 20:05:09 2003 +++ b/mm/fremap.c Thu Feb 20 08:38:13 2003 @@ -1,5 +1,5 @@ /* - * linux/mm/mpopulate.c + * linux/mm/fremap.c * * Explicit pagetable population and nonlinear (random) mappings support. * diff -Nru a/mm/mremap.c b/mm/mremap.c --- a/mm/mremap.c Wed Feb 5 20:05:32 2003 +++ b/mm/mremap.c Thu Feb 20 08:37:02 2003 @@ -1,5 +1,5 @@ /* - * mm/remap.c + * mm/mremap.c * * (C) Copyright 1996 Linus Torvalds * diff -Nru a/net/appletalk/ddp.c b/net/appletalk/ddp.c --- a/net/appletalk/ddp.c Fri Oct 11 19:45:27 2002 +++ b/net/appletalk/ddp.c Mon Mar 3 04:56:53 2003 @@ -190,7 +190,7 @@ struct sock *sk = (struct sock *)data; if (!atomic_read(&sk->wmem_alloc) && - !atomic_read(&sk->rmem_alloc) && sk->dead) { + !atomic_read(&sk->rmem_alloc) && test_bit(SOCK_DEAD, &sk->flags)) { sock_put(sk); MOD_DEC_USE_COUNT; } else { @@ -205,7 +205,7 @@ skb_queue_purge(&sk->receive_queue); if (!atomic_read(&sk->wmem_alloc) && - !atomic_read(&sk->rmem_alloc) && sk->dead) { + !atomic_read(&sk->rmem_alloc) && test_bit(SOCK_DEAD, &sk->flags)) { sock_put(sk); MOD_DEC_USE_COUNT; } else { @@ -1016,9 +1016,9 @@ struct sock *sk = sock->sk; if (sk) { - if (!sk->dead) + if (!test_bit(SOCK_DEAD, &sk->flags)) sk->state_change(sk); - sk->dead = 1; + __set_bit(SOCK_DEAD, &sk->flags); sock->sk = NULL; atalk_destroy_socket(sk); } @@ -1158,7 +1158,8 @@ if (addr->sat_family != AF_APPLETALK) return -EAFNOSUPPORT; - if (addr->sat_addr.s_node == ATADDR_BCAST && !sk->broadcast) { + if (addr->sat_addr.s_node == ATADDR_BCAST && + !test_bit(SOCK_BROADCAST, &sk->flags)) { #if 1 printk(KERN_WARNING "%s is broken and did not set " "SO_BROADCAST. It will break when 2.2 is " @@ -1523,7 +1524,8 @@ return -EINVAL; /* netatalk doesn't implement this check */ - if (usat->sat_addr.s_node == ATADDR_BCAST && !sk->broadcast) { + if (usat->sat_addr.s_node == ATADDR_BCAST && + !test_bit(SOCK_BROADCAST, &sk->flags)) { printk(KERN_INFO "SO_BROADCAST: Fix your netatalk as " "it will break before 2.2\n"); #if 0 diff -Nru a/net/ax25/af_ax25.c b/net/ax25/af_ax25.c --- a/net/ax25/af_ax25.c Sun Dec 29 02:00:21 2002 +++ b/net/ax25/af_ax25.c Mon Mar 3 04:56:53 2003 @@ -330,7 +330,7 @@ ax25_cb *sax25 = ax25_sk(skb->sk); /* Queue the unaccepted socket for death */ - skb->sk->dead = 1; + __set_bit(SOCK_DEAD, &skb->sk->flags); ax25_start_heartbeat(sax25); sax25->state = AX25_STATE_0; @@ -984,8 +984,8 @@ sk->state = TCP_CLOSE; sk->shutdown |= SEND_SHUTDOWN; sk->state_change(sk); - sk->dead = 1; - sk->destroy = 1; + __set_bit(SOCK_DEAD, &sk->flags); + __set_bit(SOCK_DESTROY, &sk->flags); break; default: @@ -995,7 +995,7 @@ sk->state = TCP_CLOSE; sk->shutdown |= SEND_SHUTDOWN; sk->state_change(sk); - sk->dead = 1; + __set_bit(SOCK_DEAD, &sk->flags); ax25_destroy_socket(ax25); } diff -Nru a/net/ax25/ax25_ds_in.c b/net/ax25/ax25_ds_in.c --- a/net/ax25/ax25_ds_in.c Mon Aug 5 06:20:38 2002 +++ b/net/ax25/ax25_ds_in.c Mon Mar 3 04:56:53 2003 @@ -67,7 +67,7 @@ if (ax25->sk != NULL) { ax25->sk->state = TCP_ESTABLISHED; /* For WAIT_SABM connections we will produce an accept ready socket here */ - if (!ax25->sk->dead) + if (!test_bit(SOCK_DEAD, &ax25->sk->flags)) ax25->sk->state_change(ax25->sk); } ax25_dama_on(ax25); diff -Nru a/net/ax25/ax25_ds_timer.c b/net/ax25/ax25_ds_timer.c --- a/net/ax25/ax25_ds_timer.c Mon Aug 5 09:23:19 2002 +++ b/net/ax25/ax25_ds_timer.c Mon Mar 3 04:56:53 2003 @@ -103,7 +103,7 @@ case AX25_STATE_0: /* Magic here: If we listen() and a new link dies before it is accepted() it isn't 'dead' so doesn't get removed. */ - if (ax25->sk == NULL || ax25->sk->destroy || (ax25->sk->state == TCP_LISTEN && ax25->sk->dead)) { + if (ax25->sk == NULL || test_bit(SOCK_DESTROY, &ax25->sk->flags) || (ax25->sk->state == TCP_LISTEN && test_bit(SOCK_DEAD, &ax25->sk->flags))) { ax25_destroy_socket(ax25); return; } @@ -157,9 +157,9 @@ ax25->sk->state = TCP_CLOSE; ax25->sk->err = 0; ax25->sk->shutdown |= SEND_SHUTDOWN; - if (!ax25->sk->dead) + if (!test_bit(SOCK_DEAD, &ax25->sk->flags)) ax25->sk->state_change(ax25->sk); - ax25->sk->dead = 1; + __set_bit(SOCK_DEAD, &ax25->sk->flags); } } diff -Nru a/net/ax25/ax25_in.c b/net/ax25/ax25_in.c --- a/net/ax25/ax25_in.c Mon Aug 5 06:20:38 2002 +++ b/net/ax25/ax25_in.c Mon Mar 3 04:56:53 2003 @@ -434,7 +434,7 @@ ax25_start_idletimer(ax25); if (sk != NULL) { - if (!sk->dead) + if (!test_bit(SOCK_DEAD, &sk->flags)) sk->data_ready(sk, skb->len); } else { kfree_skb(skb); diff -Nru a/net/ax25/ax25_std_in.c b/net/ax25/ax25_std_in.c --- a/net/ax25/ax25_std_in.c Mon Aug 5 06:20:38 2002 +++ b/net/ax25/ax25_std_in.c Mon Mar 3 04:56:53 2003 @@ -75,7 +75,7 @@ if (ax25->sk != NULL) { ax25->sk->state = TCP_ESTABLISHED; /* For WAIT_SABM connections we will produce an accept ready socket here */ - if (!ax25->sk->dead) + if (!test_bit(SOCK_DEAD, &ax25->sk->flags)) ax25->sk->state_change(ax25->sk); } } diff -Nru a/net/ax25/ax25_std_timer.c b/net/ax25/ax25_std_timer.c --- a/net/ax25/ax25_std_timer.c Mon Aug 5 06:20:38 2002 +++ b/net/ax25/ax25_std_timer.c Mon Mar 3 04:56:53 2003 @@ -37,7 +37,7 @@ case AX25_STATE_0: /* Magic here: If we listen() and a new link dies before it is accepted() it isn't 'dead' so doesn't get removed. */ - if (ax25->sk == NULL || ax25->sk->destroy || (ax25->sk->state == TCP_LISTEN && ax25->sk->dead)) { + if (ax25->sk == NULL || test_bit(SOCK_DESTROY, &ax25->sk->flags) || (ax25->sk->state == TCP_LISTEN && test_bit(SOCK_DEAD, &ax25->sk->flags))) { ax25_destroy_socket(ax25); return; } @@ -94,9 +94,9 @@ ax25->sk->state = TCP_CLOSE; ax25->sk->err = 0; ax25->sk->shutdown |= SEND_SHUTDOWN; - if (!ax25->sk->dead) + if (!test_bit(SOCK_DEAD, &ax25->sk->flags)) ax25->sk->state_change(ax25->sk); - ax25->sk->dead = 1; + __set_bit(SOCK_DEAD, &ax25->sk->flags); } } diff -Nru a/net/ax25/ax25_subr.c b/net/ax25/ax25_subr.c --- a/net/ax25/ax25_subr.c Mon Aug 5 06:20:38 2002 +++ b/net/ax25/ax25_subr.c Mon Mar 3 04:56:53 2003 @@ -285,8 +285,8 @@ ax25->sk->state = TCP_CLOSE; ax25->sk->err = reason; ax25->sk->shutdown |= SEND_SHUTDOWN; - if (!ax25->sk->dead) + if (!test_bit(SOCK_DEAD, &ax25->sk->flags)) ax25->sk->state_change(ax25->sk); - ax25->sk->dead = 1; + __set_bit(SOCK_DEAD, &ax25->sk->flags); } } diff -Nru a/net/bluetooth/l2cap.c b/net/bluetooth/l2cap.c --- a/net/bluetooth/l2cap.c Wed Feb 19 21:05:12 2003 +++ b/net/bluetooth/l2cap.c Mon Mar 3 04:56:53 2003 @@ -272,7 +272,7 @@ /* Kill poor orphan */ bt_sock_unlink(&l2cap_sk_list, sk); - sk->dead = 1; + __set_bit(SOCK_DEAD, &sk->flags); sock_put(sk); } diff -Nru a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c --- a/net/bluetooth/rfcomm/sock.c Wed Feb 19 21:05:12 2003 +++ b/net/bluetooth/rfcomm/sock.c Mon Mar 3 04:56:53 2003 @@ -212,7 +212,7 @@ /* Kill poor orphan */ bt_sock_unlink(&rfcomm_sk_list, sk); - sk->dead = 1; + __set_bit(SOCK_DEAD, &sk->flags); sock_put(sk); } diff -Nru a/net/bluetooth/sco.c b/net/bluetooth/sco.c --- a/net/bluetooth/sco.c Wed Feb 19 21:05:12 2003 +++ b/net/bluetooth/sco.c Mon Mar 3 04:56:53 2003 @@ -377,7 +377,7 @@ /* Kill poor orphan */ bt_sock_unlink(&sco_sk_list, sk); - sk->dead = 1; + __set_bit(SOCK_DEAD, &sk->flags); sock_put(sk); } diff -Nru a/net/bridge/netfilter/ebt_arp.c b/net/bridge/netfilter/ebt_arp.c --- a/net/bridge/netfilter/ebt_arp.c Mon Sep 16 16:11:26 2002 +++ b/net/bridge/netfilter/ebt_arp.c Mon Mar 3 04:41:09 2003 @@ -2,7 +2,7 @@ * ebt_arp * * Authors: - * Bart De Schuymer + * Bart De Schuymer * Tim Gardner * * April, 2002 @@ -37,10 +37,10 @@ uint32_t dst; uint32_t src; - // Make sure the packet is long enough. + /* Make sure the packet is long enough */ if ((((*skb).nh.raw) + arp_len) > (*skb).tail) return EBT_NOMATCH; - // IPv4 addresses are always 4 bytes. + /* IPv4 addresses are always 4 bytes */ if (((*skb).nh.arph)->ar_pln != sizeof(uint32_t)) return EBT_NOMATCH; @@ -82,8 +82,10 @@ static struct ebt_match filter_arp = { - {NULL, NULL}, EBT_ARP_MATCH, ebt_filter_arp, ebt_arp_check, NULL, - THIS_MODULE + .name = EBT_ARP_MATCH, + .match = ebt_filter_arp, + .check = ebt_arp_check, + .me = THIS_MODULE, }; static int __init init(void) diff -Nru a/net/bridge/netfilter/ebt_dnat.c b/net/bridge/netfilter/ebt_dnat.c --- a/net/bridge/netfilter/ebt_dnat.c Mon Sep 16 16:11:26 2002 +++ b/net/bridge/netfilter/ebt_dnat.c Mon Mar 3 04:41:09 2003 @@ -2,7 +2,7 @@ * ebt_dnat * * Authors: - * Bart De Schuymer + * Bart De Schuymer * * June, 2002 * @@ -45,8 +45,10 @@ static struct ebt_target dnat = { - {NULL, NULL}, EBT_DNAT_TARGET, ebt_target_dnat, ebt_target_dnat_check, - NULL, THIS_MODULE + .name = EBT_DNAT_TARGET, + .target = ebt_target_dnat, + .check = ebt_target_dnat_check, + .me = THIS_MODULE, }; static int __init init(void) diff -Nru a/net/bridge/netfilter/ebt_ip.c b/net/bridge/netfilter/ebt_ip.c --- a/net/bridge/netfilter/ebt_ip.c Mon Oct 28 04:58:32 2002 +++ b/net/bridge/netfilter/ebt_ip.c Mon Mar 3 04:41:09 2003 @@ -2,7 +2,7 @@ * ebt_ip * * Authors: - * Bart De Schuymer + * Bart De Schuymer * * April, 2002 * @@ -86,7 +86,7 @@ if (info->bitmask & ~EBT_IP_MASK || info->invflags & ~EBT_IP_MASK) return -EINVAL; if (info->bitmask & (EBT_IP_DPORT | EBT_IP_SPORT)) { - if (!info->bitmask & EBT_IPROTO) + if (!(info->bitmask & EBT_IPROTO)) return -EINVAL; if (info->protocol != IPPROTO_TCP && info->protocol != IPPROTO_UDP) @@ -101,8 +101,10 @@ static struct ebt_match filter_ip = { - {NULL, NULL}, EBT_IP_MATCH, ebt_filter_ip, ebt_ip_check, NULL, - THIS_MODULE + .name = EBT_IP_MATCH, + .match = ebt_filter_ip, + .check = ebt_ip_check, + .me = THIS_MODULE, }; static int __init init(void) diff -Nru a/net/bridge/netfilter/ebt_log.c b/net/bridge/netfilter/ebt_log.c --- a/net/bridge/netfilter/ebt_log.c Mon Jan 13 17:12:01 2003 +++ b/net/bridge/netfilter/ebt_log.c Mon Mar 3 04:41:09 2003 @@ -2,7 +2,7 @@ * ebt_log * * Authors: - * Bart De Schuymer + * Bart De Schuymer * * April, 2002 * @@ -80,8 +80,10 @@ static struct ebt_watcher log = { - {NULL, NULL}, EBT_LOG_WATCHER, ebt_log, ebt_log_check, NULL, - THIS_MODULE + .name = EBT_LOG_WATCHER, + .watcher = ebt_log, + .check = ebt_log_check, + .me = THIS_MODULE, }; static int __init init(void) diff -Nru a/net/bridge/netfilter/ebt_mark.c b/net/bridge/netfilter/ebt_mark.c --- a/net/bridge/netfilter/ebt_mark.c Mon Sep 16 16:11:27 2002 +++ b/net/bridge/netfilter/ebt_mark.c Mon Mar 3 04:41:09 2003 @@ -2,15 +2,16 @@ * ebt_mark * * Authors: - * Bart De Schuymer + * Bart De Schuymer * * July, 2002 * */ -// The mark target can be used in any chain -// I believe adding a mangle table just for marking is total overkill -// Marking a frame doesn't really change anything in the frame anyway +/* The mark target can be used in any chain, + * I believe adding a mangle table just for marking is total overkill. + * Marking a frame doesn't really change anything in the frame anyway. + */ #include #include @@ -46,8 +47,10 @@ static struct ebt_target mark_target = { - {NULL, NULL}, EBT_MARK_TARGET, ebt_target_mark, - ebt_target_mark_check, NULL, THIS_MODULE + .name = EBT_MARK_TARGET, + .target = ebt_target_mark, + .check = ebt_target_mark_check, + .me = THIS_MODULE, }; static int __init init(void) diff -Nru a/net/bridge/netfilter/ebt_mark_m.c b/net/bridge/netfilter/ebt_mark_m.c --- a/net/bridge/netfilter/ebt_mark_m.c Mon Sep 16 16:11:27 2002 +++ b/net/bridge/netfilter/ebt_mark_m.c Mon Mar 3 04:41:09 2003 @@ -2,7 +2,7 @@ * ebt_mark_m * * Authors: - * Bart De Schuymer + * Bart De Schuymer * * July, 2002 * @@ -41,8 +41,10 @@ static struct ebt_match filter_mark = { - {NULL, NULL}, EBT_MARK_MATCH, ebt_filter_mark, ebt_mark_check, NULL, - THIS_MODULE + .name = EBT_MARK_MATCH, + .match = ebt_filter_mark, + .check = ebt_mark_check, + .me = THIS_MODULE, }; static int __init init(void) diff -Nru a/net/bridge/netfilter/ebt_redirect.c b/net/bridge/netfilter/ebt_redirect.c --- a/net/bridge/netfilter/ebt_redirect.c Mon Sep 16 16:11:27 2002 +++ b/net/bridge/netfilter/ebt_redirect.c Mon Mar 3 04:41:09 2003 @@ -2,7 +2,7 @@ * ebt_redirect * * Authors: - * Bart De Schuymer + * Bart De Schuymer * * April, 2002 * @@ -51,8 +51,10 @@ static struct ebt_target redirect_target = { - {NULL, NULL}, EBT_REDIRECT_TARGET, ebt_target_redirect, - ebt_target_redirect_check, NULL, THIS_MODULE + .name = EBT_REDIRECT_TARGET, + .target = ebt_target_redirect, + .check = ebt_target_redirect_check, + .me = THIS_MODULE, }; static int __init init(void) diff -Nru a/net/bridge/netfilter/ebt_snat.c b/net/bridge/netfilter/ebt_snat.c --- a/net/bridge/netfilter/ebt_snat.c Mon Sep 16 16:11:27 2002 +++ b/net/bridge/netfilter/ebt_snat.c Mon Mar 3 04:41:09 2003 @@ -2,7 +2,7 @@ * ebt_snat * * Authors: - * Bart De Schuymer + * Bart De Schuymer * * June, 2002 * @@ -44,8 +44,10 @@ static struct ebt_target snat = { - {NULL, NULL}, EBT_SNAT_TARGET, ebt_target_snat, ebt_target_snat_check, - NULL, THIS_MODULE + .name = EBT_SNAT_TARGET, + .target = ebt_target_snat, + .check = ebt_target_snat_check, + .me = THIS_MODULE, }; static int __init init(void) diff -Nru a/net/bridge/netfilter/ebt_vlan.c b/net/bridge/netfilter/ebt_vlan.c --- a/net/bridge/netfilter/ebt_vlan.c Thu Dec 5 13:15:16 2002 +++ b/net/bridge/netfilter/ebt_vlan.c Mon Mar 3 04:41:09 2003 @@ -1,7 +1,7 @@ /* * Description: EBTables 802.1Q match extension kernelspace module. * Authors: Nick Fedchik - * Bart De Schuymer + * Bart De Schuymer * * 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 @@ -226,12 +226,10 @@ } static struct ebt_match filter_vlan = { - {NULL, NULL}, - EBT_VLAN_MATCH, - ebt_filter_vlan, - ebt_check_vlan, - NULL, - THIS_MODULE + .name = EBT_VLAN_MATCH, + .match = ebt_filter_vlan, + .check = ebt_check_vlan, + .me = THIS_MODULE, }; /* diff -Nru a/net/bridge/netfilter/ebtable_broute.c b/net/bridge/netfilter/ebtable_broute.c --- a/net/bridge/netfilter/ebtable_broute.c Mon Mar 3 01:43:37 2003 +++ b/net/bridge/netfilter/ebtable_broute.c Mon Mar 3 04:41:09 2003 @@ -2,7 +2,7 @@ * ebtable_broute * * Authors: - * Bart De Schuymer + * Bart De Schuymer * * April, 2002 * @@ -16,11 +16,12 @@ #include #include -// EBT_ACCEPT means the frame will be bridged -// EBT_DROP means the frame will be routed +/* EBT_ACCEPT means the frame will be bridged + * EBT_DROP means the frame will be routed + */ static struct ebt_entries initial_chain = { - .name = "BROUTING", - .policy = EBT_ACCEPT, + .name = "BROUTING", + .policy = EBT_ACCEPT, }; static struct ebt_replace initial_table = @@ -31,7 +32,7 @@ .hook_entry = { [NF_BR_BROUTING] = &initial_chain, }, - .entries = (char *)&initial_chain + .entries = (char *)&initial_chain, }; static int check(const struct ebt_table_info *info, unsigned int valid_hooks) @@ -57,8 +58,8 @@ ret = ebt_do_table(NF_BR_BROUTING, pskb, (*pskb)->dev, NULL, &broute_table); if (ret == NF_DROP) - return 1; // route it - return 0; // bridge it + return 1; /* route it */ + return 0; /* bridge it */ } static int __init init(void) @@ -69,7 +70,7 @@ if (ret < 0) return ret; br_write_lock_bh(BR_NETPROTO_LOCK); - // see br_input.c + /* see br_input.c */ br_should_route_hook = ebt_broute; br_write_unlock_bh(BR_NETPROTO_LOCK); return ret; diff -Nru a/net/bridge/netfilter/ebtable_filter.c b/net/bridge/netfilter/ebtable_filter.c --- a/net/bridge/netfilter/ebtable_filter.c Mon Mar 3 01:43:37 2003 +++ b/net/bridge/netfilter/ebtable_filter.c Mon Mar 3 04:41:09 2003 @@ -2,7 +2,7 @@ * ebtable_filter * * Authors: - * Bart De Schuymer + * Bart De Schuymer * * April, 2002 * @@ -27,7 +27,7 @@ { .name = "OUTPUT", .policy = EBT_ACCEPT, - } + }, }; static struct ebt_replace initial_table = @@ -35,12 +35,12 @@ .name = "filter", .valid_hooks = FILTER_VALID_HOOKS, .entries_size = 3 * sizeof(struct ebt_entries), - .hook_entry = { + .hook_entry = { [NF_BR_LOCAL_IN] = &initial_chains[0], [NF_BR_FORWARD] = &initial_chains[1], - [NF_BR_LOCAL_OUT] = &initial_chains[2], + [NF_BR_LOCAL_OUT] = &initial_chains[2], }, - .entries = (char *)initial_chains + .entries = (char *)initial_chains, }; static int check(const struct ebt_table_info *info, unsigned int valid_hooks) @@ -77,14 +77,14 @@ .hook = ebt_hook, .pf = PF_BRIDGE, .hooknum = NF_BR_FORWARD, - .priority = NF_BR_PRI_FILTER_BRIDGED + .priority = NF_BR_PRI_FILTER_BRIDGED, }, { .hook = ebt_hook, .pf = PF_BRIDGE, .hooknum = NF_BR_LOCAL_OUT, - .priority = NF_BR_PRI_FILTER_OTHER - } + .priority = NF_BR_PRI_FILTER_OTHER, + }, }; static int __init init(void) diff -Nru a/net/bridge/netfilter/ebtable_nat.c b/net/bridge/netfilter/ebtable_nat.c --- a/net/bridge/netfilter/ebtable_nat.c Mon Mar 3 01:43:37 2003 +++ b/net/bridge/netfilter/ebtable_nat.c Mon Mar 3 04:41:09 2003 @@ -2,7 +2,7 @@ * ebtable_nat * * Authors: - * Bart De Schuymer + * Bart De Schuymer * * April, 2002 * @@ -39,7 +39,7 @@ [NF_BR_LOCAL_OUT] = &initial_chains[1], [NF_BR_POST_ROUTING] = &initial_chains[2], }, - .entries = (char *)initial_chains + .entries = (char *)initial_chains, }; static int check(const struct ebt_table_info *info, unsigned int valid_hooks) @@ -77,19 +77,19 @@ .hook = ebt_nat_dst, .pf = PF_BRIDGE, .hooknum = NF_BR_LOCAL_OUT, - .priority = NF_BR_PRI_NAT_DST_OTHER + .priority = NF_BR_PRI_NAT_DST_OTHER, }, { .hook = ebt_nat_src, .pf = PF_BRIDGE, .hooknum = NF_BR_POST_ROUTING, - .priority = NF_BR_PRI_NAT_SRC + .priority = NF_BR_PRI_NAT_SRC, }, { .hook = ebt_nat_dst, .pf = PF_BRIDGE, .hooknum = NF_BR_PRE_ROUTING, - .priority = NF_BR_PRI_NAT_DST_BRIDGED + .priority = NF_BR_PRI_NAT_DST_BRIDGED, }, }; diff -Nru a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c --- a/net/bridge/netfilter/ebtables.c Mon Jan 13 00:16:09 2003 +++ b/net/bridge/netfilter/ebtables.c Mon Mar 3 04:41:09 2003 @@ -365,7 +365,7 @@ m->u.match = match; if (!try_module_get(match->me)) { up(&ebt_mutex); - return -EINVAL; + return -ENOENT; } up(&ebt_mutex); if (match->check && @@ -394,7 +394,7 @@ w->u.watcher = watcher; if (!try_module_get(watcher->me)) { up(&ebt_mutex); - return -EINVAL; + return -ENOENT; } up(&ebt_mutex); if (watcher->check && @@ -634,6 +634,7 @@ goto cleanup_watchers; if (!try_module_get(target->me)) { up(&ebt_mutex); + ret = -ENOENT; goto cleanup_watchers; } up(&ebt_mutex); diff -Nru a/net/core/skbuff.c b/net/core/skbuff.c --- a/net/core/skbuff.c Fri Jan 10 12:07:06 2003 +++ b/net/core/skbuff.c Mon Mar 3 08:51:51 2003 @@ -196,40 +196,6 @@ goto nodata; /* XXX: does not include slab overhead */ - skb->truesize = size + sizeof(struct sk_buff); - - /* Load the data pointers. */ - skb->head = skb->data = skb->tail = data; - skb->end = data + size; - - /* Set up other state */ - skb->len = 0; - skb->cloned = 0; - skb->data_len = 0; - - atomic_set(&skb->users, 1); - atomic_set(&(skb_shinfo(skb)->dataref), 1); - skb_shinfo(skb)->nr_frags = 0; - skb_shinfo(skb)->tso_size = 0; - skb_shinfo(skb)->tso_segs = 0; - skb_shinfo(skb)->frag_list = NULL; -out: - return skb; -nodata: - skb_head_to_pool(skb); - skb = NULL; - goto out; -} - - -/* - * Slab constructor for a skb head. - */ -static void skb_headerinit(void *p, kmem_cache_t *cache, - unsigned long flags) -{ - struct sk_buff *skb = p; - skb->next = skb->prev = NULL; skb->list = NULL; skb->sk = NULL; @@ -238,27 +204,50 @@ skb->dst = NULL; skb->sp = NULL; memset(skb->cb, 0, sizeof(skb->cb)); + /* Set up other state */ + skb->len = 0; + skb->data_len = 0; + skb->csum = 0; + skb->cloned = 0; skb->pkt_type = PACKET_HOST; /* Default type */ skb->ip_summed = 0; skb->priority = 0; + atomic_set(&skb->users, 1); skb->security = 0; /* By default packets are insecure */ - skb->destructor = NULL; + skb->truesize = size + sizeof(struct sk_buff); + + /* Load the data pointers. */ + skb->head = skb->data = skb->tail = data; + skb->end = data + size; + skb->destructor = NULL; #ifdef CONFIG_NETFILTER - skb->nfmark = skb->nfcache = 0; - skb->nfct = NULL; + skb->nfmark = skb->nfcache = 0; + skb->nfct = NULL; #ifdef CONFIG_NETFILTER_DEBUG - skb->nf_debug = 0; + skb->nf_debug = 0; #endif #if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE) - skb->nf_bridge = NULL; + skb->nf_bridge = NULL; #endif #endif #ifdef CONFIG_NET_SCHED - skb->tc_index = 0; -#endif + skb->tc_index = 0; +#endif + atomic_set(&(skb_shinfo(skb)->dataref), 1); + skb_shinfo(skb)->nr_frags = 0; + skb_shinfo(skb)->tso_size = 0; + skb_shinfo(skb)->tso_segs = 0; + skb_shinfo(skb)->frag_list = NULL; +out: + return skb; +nodata: + skb_head_to_pool(skb); + skb = NULL; + goto out; } + static void skb_drop_fraglist(struct sk_buff *skb) { struct sk_buff *list = skb_shinfo(skb)->frag_list; @@ -339,7 +328,6 @@ nf_bridge_put(skb->nf_bridge); #endif #endif - skb_headerinit(skb, NULL, 0); /* clean state */ kfree_skbmem(skb); } @@ -1261,7 +1249,7 @@ sizeof(struct sk_buff), 0, SLAB_HWCACHE_ALIGN, - skb_headerinit, NULL); + NULL, NULL); if (!skbuff_head_cache) panic("cannot create skbuff cache"); diff -Nru a/net/core/sock.c b/net/core/sock.c --- a/net/core/sock.c Fri Oct 18 17:45:16 2002 +++ b/net/core/sock.c Mon Mar 3 04:56:53 2003 @@ -178,7 +178,7 @@ switch(optname) { case SO_DONTLINGER: - sk->linger=0; + __clear_bit(SOCK_LINGER, &sk->flags); return 0; } #endif @@ -214,7 +214,7 @@ sk->localroute=valbool; break; case SO_BROADCAST: - sk->broadcast=valbool; + sock_valbool_flag(sk, SOCK_BROADCAST, valbool); break; case SO_SNDBUF: /* Don't error on this BSD doesn't and if you think @@ -262,11 +262,11 @@ tcp_set_keepalive(sk, valbool); } #endif - sk->keepopen = valbool; + sock_valbool_flag(sk, SOCK_KEEPOPEN, valbool); break; case SO_OOBINLINE: - sk->urginline = valbool; + sock_valbool_flag(sk, SOCK_URGINLINE, valbool); break; case SO_NO_CHECK: @@ -290,7 +290,7 @@ break; } if(ling.l_onoff==0) { - sk->linger=0; + __clear_bit(SOCK_LINGER, &sk->flags); } else { #if (BITS_PER_LONG == 32) if (ling.l_linger >= MAX_SCHEDULE_TIMEOUT/HZ) @@ -298,12 +298,12 @@ else #endif sk->lingertime=ling.l_linger*HZ; - sk->linger=1; + __set_bit(SOCK_LINGER, &sk->flags); } break; case SO_BSDCOMPAT: - sk->bsdism = valbool; + sock_valbool_flag(sk, SOCK_BSDISM, valbool); break; case SO_PASSCRED: @@ -443,7 +443,7 @@ break; case SO_BROADCAST: - v.val= sk->broadcast; + v.val= test_bit(SOCK_BROADCAST, &sk->flags); break; case SO_SNDBUF: @@ -459,7 +459,7 @@ break; case SO_KEEPALIVE: - v.val = sk->keepopen; + v.val = test_bit(SOCK_KEEPOPEN, &sk->flags); break; case SO_TYPE: @@ -473,7 +473,7 @@ break; case SO_OOBINLINE: - v.val = sk->urginline; + v.val = test_bit(SOCK_URGINLINE, &sk->flags); break; case SO_NO_CHECK: @@ -486,12 +486,12 @@ case SO_LINGER: lv=sizeof(v.ling); - v.ling.l_onoff=sk->linger; + v.ling.l_onoff = test_bit(SOCK_LINGER, &sk->flags); v.ling.l_linger=sk->lingertime/HZ; break; case SO_BSDCOMPAT: - v.val = sk->bsdism; + v.val = test_bit(SOCK_BSDISM, &sk->flags); break; case SO_TIMESTAMP: @@ -806,6 +806,7 @@ page = alloc_pages(sk->allocation, 0); if (!page) { err = -ENOBUFS; + skb_shinfo(skb)->nr_frags = i; kfree_skb(skb); goto failure; } diff -Nru a/net/decnet/dn_nsp_in.c b/net/decnet/dn_nsp_in.c --- a/net/decnet/dn_nsp_in.c Fri Feb 7 01:48:38 2003 +++ b/net/decnet/dn_nsp_in.c Mon Mar 3 04:56:53 2003 @@ -118,7 +118,7 @@ break; } - if (wakeup && !sk->dead) + if (wakeup && !test_bit(SOCK_DEAD, &sk->flags)) sk->state_change(sk); } @@ -367,7 +367,7 @@ } } dn_nsp_send_link(sk, DN_NOCHANGE, 0); - if (!sk->dead) + if (!test_bit(SOCK_DEAD, &sk->flags)) sk->state_change(sk); } @@ -428,7 +428,7 @@ break; } - if (!sk->dead) { + if (!test_bit(SOCK_DEAD, &sk->flags)) { if (sk->socket->state != SS_UNCONNECTED) sk->socket->state = SS_DISCONNECTING; sk->state_change(sk); @@ -477,7 +477,7 @@ scp->state = DN_CN; } - if (!sk->dead) { + if (!test_bit(SOCK_DEAD, &sk->flags)) { if (sk->socket->state != SS_UNCONNECTED) sk->socket->state = SS_DISCONNECTING; sk->state_change(sk); @@ -549,7 +549,7 @@ } break; } - if (wake_up && !sk->dead) + if (wake_up && !test_bit(SOCK_DEAD, &sk->flags)) sk->state_change(sk); } @@ -587,7 +587,7 @@ * Therefore the plain read_lock is ok here. -DaveM */ read_lock(&sk->callback_lock); - if (!sk->dead) { + if (!test_bit(SOCK_DEAD, &sk->flags)) { struct socket *sock = sk->socket; wake_up_interruptible(sk->sleep); if (sock && sock->fasync_list && @@ -671,7 +671,7 @@ if (scp->state == DN_CI) { scp->state = DN_NC; sk->state = TCP_CLOSE; - if (!sk->dead) + if (!test_bit(SOCK_DEAD, &sk->flags)) sk->state_change(sk); } @@ -861,7 +861,7 @@ int other = 1; /* both data and ack frames can kick a CC socket into RUN */ - if ((scp->state == DN_CC) && !sk->dead) { + if ((scp->state == DN_CC) && !test_bit(SOCK_DEAD, &sk->flags)) { scp->state = DN_RUN; sk->state = TCP_ESTABLISHED; sk->state_change(sk); diff -Nru a/net/econet/af_econet.c b/net/econet/af_econet.c --- a/net/econet/af_econet.c Tue Feb 11 03:38:22 2003 +++ b/net/econet/af_econet.c Mon Mar 3 04:56:53 2003 @@ -533,7 +533,7 @@ sock->sk = NULL; sk->socket = NULL; - sk->dead = 1; + __set_bit(SOCK_DEAD, &sk->flags); /* Purge queues */ diff -Nru a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c --- a/net/ipv4/af_inet.c Wed Feb 19 23:27:40 2003 +++ b/net/ipv4/af_inet.c Mon Mar 3 04:56:53 2003 @@ -146,7 +146,7 @@ sk); return; } - if (!sk->dead) { + if (!test_bit(SOCK_DEAD, &sk->flags)) { printk("Attempt to release alive inet socket %p\n", sk); return; } @@ -454,7 +454,8 @@ * linger.. */ timeout = 0; - if (sk->linger && !(current->flags & PF_EXITING)) + if (test_bit(SOCK_LINGER, &sk->flags) && + !(current->flags & PF_EXITING)) timeout = sk->lingertime; sock->sk = NULL; sk->prot->close(sk, timeout); diff -Nru a/net/ipv4/ah.c b/net/ipv4/ah.c --- a/net/ipv4/ah.c Sun Feb 2 23:19:14 2003 +++ b/net/ipv4/ah.c Thu Mar 6 16:16:15 2003 @@ -2,30 +2,14 @@ #include #include #include +#include #include #include #include #include -#define AH_HLEN_NOICV 12 - -typedef void (icv_update_fn_t)(struct crypto_tfm *, - struct scatterlist *, unsigned int); - -struct ah_data -{ - u8 *key; - int key_len; - u8 *work_icv; - int icv_full_len; - int icv_trunc_len; - - void (*icv)(struct ah_data*, - struct sk_buff *skb, u8 *icv); - - struct crypto_tfm *tfm; -}; +#define AH_HLEN_NOICV 12 /* Clear mutable options and find final destination to substitute * into IP header for icv calculation. Options are already checked @@ -71,92 +55,6 @@ return 0; } -static void skb_ah_walk(const struct sk_buff *skb, - struct crypto_tfm *tfm, icv_update_fn_t icv_update) -{ - int offset = 0; - int len = skb->len; - int start = skb->len - skb->data_len; - int i, copy = start - offset; - struct scatterlist sg; - - /* Checksum header. */ - if (copy > 0) { - if (copy > len) - copy = len; - - sg.page = virt_to_page(skb->data + offset); - sg.offset = (unsigned long)(skb->data + offset) % PAGE_SIZE; - sg.length = copy; - - icv_update(tfm, &sg, 1); - - if ((len -= copy) == 0) - return; - offset += copy; - } - - for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { - int end; - - BUG_TRAP(start <= offset + len); - - end = start + skb_shinfo(skb)->frags[i].size; - if ((copy = end - offset) > 0) { - skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; - - if (copy > len) - copy = len; - - sg.page = frag->page; - sg.offset = frag->page_offset + offset-start; - sg.length = copy; - - icv_update(tfm, &sg, 1); - - if (!(len -= copy)) - return; - offset += copy; - } - start = end; - } - - if (skb_shinfo(skb)->frag_list) { - struct sk_buff *list = skb_shinfo(skb)->frag_list; - - for (; list; list = list->next) { - int end; - - BUG_TRAP(start <= offset + len); - - end = start + list->len; - if ((copy = end - offset) > 0) { - if (copy > len) - copy = len; - skb_ah_walk(list, tfm, icv_update); - if ((len -= copy) == 0) - return; - offset += copy; - } - start = end; - } - } - if (len) - BUG(); -} - -static void -ah_hmac_digest(struct ah_data *ahp, struct sk_buff *skb, u8 *auth_data) -{ - struct crypto_tfm *tfm = ahp->tfm; - - memset(auth_data, 0, ahp->icv_trunc_len); - crypto_hmac_init(tfm, ahp->key, &ahp->key_len); - skb_ah_walk(skb, tfm, crypto_hmac_update); - crypto_hmac_final(tfm, ahp->key, &ahp->key_len, ahp->work_icv); - memcpy(auth_data, ahp->work_icv, ahp->icv_trunc_len); -} - static int ah_output(struct sk_buff *skb) { int err; @@ -330,7 +228,7 @@ skb->h.icmph->code != ICMP_FRAG_NEEDED) return; - x = xfrm_state_lookup(iph->daddr, ah->spi, IPPROTO_AH); + x = xfrm4_state_lookup(iph->daddr, ah->spi, IPPROTO_AH); if (!x) return; printk(KERN_DEBUG "pmtu discvovery on SA AH/%08x/%08x\n", diff -Nru a/net/ipv4/esp.c b/net/ipv4/esp.c --- a/net/ipv4/esp.c Mon Mar 3 01:45:23 2003 +++ b/net/ipv4/esp.c Thu Mar 6 16:16:15 2003 @@ -2,318 +2,15 @@ #include #include #include +#include #include #include #include #include #include -#define MAX_SG_ONSTACK 4 - -typedef void (icv_update_fn_t)(struct crypto_tfm *, - struct scatterlist *, unsigned int); - -/* BUGS: - * - we assume replay seqno is always present. - */ - -struct esp_data -{ - /* Confidentiality */ - struct { - u8 *key; /* Key */ - int key_len; /* Key length */ - u8 *ivec; /* ivec buffer */ - /* ivlen is offset from enc_data, where encrypted data start. - * It is logically different of crypto_tfm_alg_ivsize(tfm). - * We assume that it is either zero (no ivec), or - * >= crypto_tfm_alg_ivsize(tfm). */ - int ivlen; - int padlen; /* 0..255 */ - struct crypto_tfm *tfm; /* crypto handle */ - } conf; - - /* Integrity. It is active when icv_full_len != 0 */ - struct { - u8 *key; /* Key */ - int key_len; /* Length of the key */ - u8 *work_icv; - int icv_full_len; - int icv_trunc_len; - void (*icv)(struct esp_data*, - struct sk_buff *skb, - int offset, int len, u8 *icv); - struct crypto_tfm *tfm; - } auth; -}; - -/* Move to common area: it is shared with AH. */ - -void skb_icv_walk(const struct sk_buff *skb, struct crypto_tfm *tfm, - int offset, int len, icv_update_fn_t icv_update) -{ - int start = skb->len - skb->data_len; - int i, copy = start - offset; - struct scatterlist sg; - - /* Checksum header. */ - if (copy > 0) { - if (copy > len) - copy = len; - - sg.page = virt_to_page(skb->data + offset); - sg.offset = (unsigned long)(skb->data + offset) % PAGE_SIZE; - sg.length = copy; - - icv_update(tfm, &sg, 1); - - if ((len -= copy) == 0) - return; - offset += copy; - } - - for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { - int end; - - BUG_TRAP(start <= offset + len); - - end = start + skb_shinfo(skb)->frags[i].size; - if ((copy = end - offset) > 0) { - skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; - - if (copy > len) - copy = len; - - sg.page = frag->page; - sg.offset = frag->page_offset + offset-start; - sg.length = copy; - - icv_update(tfm, &sg, 1); - - if (!(len -= copy)) - return; - offset += copy; - } - start = end; - } - - if (skb_shinfo(skb)->frag_list) { - struct sk_buff *list = skb_shinfo(skb)->frag_list; - - for (; list; list = list->next) { - int end; - - BUG_TRAP(start <= offset + len); - - end = start + list->len; - if ((copy = end - offset) > 0) { - if (copy > len) - copy = len; - skb_icv_walk(list, tfm, offset-start, copy, icv_update); - if ((len -= copy) == 0) - return; - offset += copy; - } - start = end; - } - } - if (len) - BUG(); -} - - -/* Looking generic it is not used in another places. */ - -int -skb_to_sgvec(struct sk_buff *skb, struct scatterlist *sg, int offset, int len) -{ - int start = skb->len - skb->data_len; - int i, copy = start - offset; - int elt = 0; - - if (copy > 0) { - if (copy > len) - copy = len; - sg[elt].page = virt_to_page(skb->data + offset); - sg[elt].offset = (unsigned long)(skb->data + offset) % PAGE_SIZE; - sg[elt].length = copy; - elt++; - if ((len -= copy) == 0) - return elt; - offset += copy; - } - - for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { - int end; - - BUG_TRAP(start <= offset + len); - - end = start + skb_shinfo(skb)->frags[i].size; - if ((copy = end - offset) > 0) { - skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; - - if (copy > len) - copy = len; - sg[elt].page = frag->page; - sg[elt].offset = frag->page_offset+offset-start; - sg[elt].length = copy; - elt++; - if (!(len -= copy)) - return elt; - offset += copy; - } - start = end; - } - if (skb_shinfo(skb)->frag_list) { - struct sk_buff *list = skb_shinfo(skb)->frag_list; - - for (; list; list = list->next) { - int end; - - BUG_TRAP(start <= offset + len); - - end = start + list->len; - if ((copy = end - offset) > 0) { - if (copy > len) - copy = len; - elt += skb_to_sgvec(list, sg+elt, offset - start, copy); - if ((len -= copy) == 0) - return elt; - offset += copy; - } - start = end; - } - } - if (len) - BUG(); - return elt; -} - -/* Common with AH after some work on arguments. */ - -static void -esp_hmac_digest(struct esp_data *esp, struct sk_buff *skb, int offset, - int len, u8 *auth_data) -{ - struct crypto_tfm *tfm = esp->auth.tfm; - char *icv = esp->auth.work_icv; - - memset(auth_data, 0, esp->auth.icv_trunc_len); - crypto_hmac_init(tfm, esp->auth.key, &esp->auth.key_len); - skb_icv_walk(skb, tfm, offset, len, crypto_hmac_update); - crypto_hmac_final(tfm, esp->auth.key, &esp->auth.key_len, icv); - memcpy(auth_data, icv, esp->auth.icv_trunc_len); -} - -/* Check that skb data bits are writable. If they are not, copy data - * to newly created private area. If "tailbits" is given, make sure that - * tailbits bytes beyond current end of skb are writable. - * - * Returns amount of elements of scatterlist to load for subsequent - * transformations and pointer to writable trailer skb. - */ - -int skb_cow_data(struct sk_buff *skb, int tailbits, struct sk_buff **trailer) -{ - int copyflag; - int elt; - struct sk_buff *skb1, **skb_p; - - /* If skb is cloned or its head is paged, reallocate - * head pulling out all the pages (pages are considered not writable - * at the moment even if they are anonymous). - */ - if ((skb_cloned(skb) || skb_shinfo(skb)->nr_frags) && - __pskb_pull_tail(skb, skb_pagelen(skb)-skb_headlen(skb)) == NULL) - return -ENOMEM; - - /* Easy case. Most of packets will go this way. */ - if (!skb_shinfo(skb)->frag_list) { - /* A little of trouble, not enough of space for trailer. - * This should not happen, when stack is tuned to generate - * good frames. OK, on miss we reallocate and reserve even more - * space, 128 bytes is fair. */ - - if (skb_tailroom(skb) < tailbits && - pskb_expand_head(skb, 0, tailbits-skb_tailroom(skb)+128, GFP_ATOMIC)) - return -ENOMEM; - - /* Voila! */ - *trailer = skb; - return 1; - } - - /* Misery. We are in troubles, going to mincer fragments... */ - - elt = 1; - skb_p = &skb_shinfo(skb)->frag_list; - copyflag = 0; - - while ((skb1 = *skb_p) != NULL) { - int ntail = 0; - - /* The fragment is partially pulled by someone, - * this can happen on input. Copy it and everything - * after it. */ - - if (skb_shared(skb1)) - copyflag = 1; - - /* If the skb is the last, worry about trailer. */ - - if (skb1->next == NULL && tailbits) { - if (skb_shinfo(skb1)->nr_frags || - skb_shinfo(skb1)->frag_list || - skb_tailroom(skb1) < tailbits) - ntail = tailbits + 128; - } - - if (copyflag || - skb_cloned(skb1) || - ntail || - skb_shinfo(skb1)->nr_frags || - skb_shinfo(skb1)->frag_list) { - struct sk_buff *skb2; - - /* Fuck, we are miserable poor guys... */ - if (ntail == 0) - skb2 = skb_copy(skb1, GFP_ATOMIC); - else - skb2 = skb_copy_expand(skb1, - skb_headroom(skb1), - ntail, - GFP_ATOMIC); - if (unlikely(skb2 == NULL)) - return -ENOMEM; - - if (skb1->sk) - skb_set_owner_w(skb, skb1->sk); - - /* Looking around. Are we still alive? - * OK, link new skb, drop old one */ - - skb2->next = skb1->next; - *skb_p = skb2; - kfree_skb(skb1); - skb1 = skb2; - } - elt++; - *trailer = skb1; - skb_p = &skb1->next; - } - - return elt; -} - -void *pskb_put(struct sk_buff *skb, struct sk_buff *tail, int len) -{ - if (tail != skb) { - skb->data_len += len; - skb->len += len; - } - return skb_put(tail, len); -} +#define MAX_SG_ONSTACK 4 int esp_output(struct sk_buff *skb) { @@ -575,7 +272,7 @@ skb->h.icmph->code != ICMP_FRAG_NEEDED) return; - x = xfrm_state_lookup(iph->daddr, esph->spi, IPPROTO_ESP); + x = xfrm4_state_lookup(iph->daddr, esph->spi, IPPROTO_ESP); if (!x) return; printk(KERN_DEBUG "pmtu discvovery on SA ESP/%08x/%08x\n", diff -Nru a/net/ipv4/igmp.c b/net/ipv4/igmp.c --- a/net/ipv4/igmp.c Wed Feb 19 13:55:33 2003 +++ b/net/ipv4/igmp.c Thu Mar 6 09:08:40 2003 @@ -606,7 +606,7 @@ static struct in_device * ip_mc_find_dev(struct ip_mreqn *imr) { struct flowi fl = { .nl_u = { .ip4_u = - { .daddr = imr->imr_address.s_addr } } }; + { .daddr = imr->imr_multiaddr.s_addr } } }; struct rtable *rt; struct net_device *dev = NULL; struct in_device *idev = NULL; diff -Nru a/net/ipv4/raw.c b/net/ipv4/raw.c --- a/net/ipv4/raw.c Sun Jan 12 08:52:15 2003 +++ b/net/ipv4/raw.c Mon Mar 3 04:56:53 2003 @@ -450,7 +450,8 @@ goto done; err = -EACCES; - if (rt->rt_flags & RTCF_BROADCAST && !sk->broadcast) + if (rt->rt_flags & RTCF_BROADCAST && + !test_bit(SOCK_BROADCAST, &sk->flags)) goto done; if (msg->msg_flags & MSG_CONFIRM) diff -Nru a/net/ipv4/route.c b/net/ipv4/route.c --- a/net/ipv4/route.c Wed Feb 19 23:24:57 2003 +++ b/net/ipv4/route.c Wed Mar 5 15:45:36 2003 @@ -96,6 +96,7 @@ #include #include #include +#include #ifdef CONFIG_SYSCTL #include #endif @@ -930,7 +931,7 @@ rth->u.dst.dev != dev) break; - dst_clone(&rth->u.dst); + dst_hold(&rth->u.dst); rcu_read_unlock(); rt = dst_alloc(&ipv4_dst_ops); @@ -2599,6 +2600,13 @@ #endif /* CONFIG_PROC_FS */ #endif /* CONFIG_NET_CLS_ROUTE */ +int xfrm_dst_lookup(struct xfrm_dst **dst, struct flowi *fl) +{ + int err = 0; + err = __ip_route_output_key((struct rtable**)dst, fl); + return err; +} + int __init ip_rt_init(void) { int i, order, goal, rc = 0; @@ -2680,6 +2688,7 @@ ip_rt_gc_interval; add_timer(&rt_periodic_timer); + xfrm_dst_lookup_register(xfrm_dst_lookup, AF_INET); #ifdef CONFIG_PROC_FS if (rt_cache_proc_init()) goto out_enomem; diff -Nru a/net/ipv4/tcp.c b/net/ipv4/tcp.c --- a/net/ipv4/tcp.c Tue Feb 25 11:05:23 2003 +++ b/net/ipv4/tcp.c Mon Mar 3 04:56:53 2003 @@ -441,7 +441,7 @@ if ((tp->rcv_nxt != tp->copied_seq) && (tp->urg_seq != tp->copied_seq || tp->rcv_nxt != tp->copied_seq + 1 || - sk->urginline || !tp->urg_data)) + test_bit(SOCK_URGINLINE, &sk->flags) || !tp->urg_data)) mask |= POLLIN | POLLRDNORM; if (!(sk->shutdown & SEND_SHUTDOWN)) { @@ -497,7 +497,8 @@ lock_sock(sk); if ((1 << sk->state) & (TCPF_SYN_SENT | TCPF_SYN_RECV)) answ = 0; - else if (sk->urginline || !tp->urg_data || + else if (test_bit(SOCK_URGINLINE, &sk->flags) || + !tp->urg_data || before(tp->urg_seq, tp->copied_seq) || !before(tp->urg_seq, tp->rcv_nxt)) { answ = tp->rcv_nxt - tp->copied_seq; @@ -1254,10 +1255,11 @@ struct tcp_opt *tp = tcp_sk(sk); /* No URG data to read. */ - if (sk->urginline || !tp->urg_data || tp->urg_data == TCP_URG_READ) + if (test_bit(SOCK_URGINLINE, &sk->flags) || !tp->urg_data || + tp->urg_data == TCP_URG_READ) return -EINVAL; /* Yes this is right ! */ - if (sk->state == TCP_CLOSE && !sk->done) + if (sk->state == TCP_CLOSE && !test_bit(SOCK_DONE, &sk->flags)) return -ENOTCONN; if (tp->urg_data & TCP_URG_VALID) { @@ -1588,7 +1590,7 @@ (flags & MSG_PEEK)) break; } else { - if (sk->done) + if (test_bit(SOCK_DONE, &sk->flags)) break; if (sk->err) { @@ -1600,7 +1602,7 @@ break; if (sk->state == TCP_CLOSE) { - if (!sk->done) { + if (!test_bit(SOCK_DONE, &sk->flags)) { /* This occurs when user tries to read * from never connected socket. */ @@ -1713,7 +1715,8 @@ u32 urg_offset = tp->urg_seq - *seq; if (urg_offset < used) { if (!urg_offset) { - if (!sk->urginline) { + if (!test_bit(SOCK_URGINLINE, + &sk->flags)) { ++*seq; offset++; used--; @@ -1837,7 +1840,7 @@ /* * Shutdown the sending side of a connection. Much like close except - * that we don't receive shut down or set sk->dead. + * that we don't receive shut down or set SOCK_DEAD in sk->flags. */ void tcp_shutdown(struct sock *sk, int how) @@ -1902,7 +1905,7 @@ void tcp_destroy_sock(struct sock *sk) { BUG_TRAP(sk->state == TCP_CLOSE); - BUG_TRAP(sk->dead); + BUG_TRAP(test_bit(SOCK_DEAD, &sk->flags)); /* It cannot be in hash table! */ BUG_TRAP(!sk->pprev); @@ -1979,7 +1982,7 @@ NET_INC_STATS_USER(TCPAbortOnClose); tcp_set_state(sk, TCP_CLOSE); tcp_send_active_reset(sk, GFP_KERNEL); - } else if (sk->linger && !sk->lingertime) { + } else if (test_bit(SOCK_LINGER, &sk->flags) && !sk->lingertime) { /* Check zero linger _after_ checking for unread data. */ sk->prot->disconnect(sk, 0); NET_INC_STATS_USER(TCPAbortOnData); @@ -2157,7 +2160,7 @@ } sk->shutdown = 0; - sk->done = 0; + __clear_bit(SOCK_DONE, &sk->flags); tp->srtt = 0; if ((tp->write_seq += tp->max_window + 2) == 0) tp->write_seq = 1; @@ -2358,7 +2361,7 @@ err = -EINVAL; else { tp->keepalive_time = val * HZ; - if (sk->keepopen && + if (test_bit(SOCK_KEEPOPEN, &sk->flags) && !((1 << sk->state) & (TCPF_CLOSE | TCPF_LISTEN))) { __u32 elapsed = tcp_time_stamp - tp->rcv_tstamp; if (tp->keepalive_time > elapsed) diff -Nru a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c --- a/net/ipv4/tcp_input.c Wed Jan 8 01:03:24 2003 +++ b/net/ipv4/tcp_input.c Mon Mar 3 04:56:53 2003 @@ -2352,7 +2352,7 @@ sk->err = ECONNRESET; } - if (!sk->dead) + if (!test_bit(SOCK_DEAD, &sk->flags)) sk->error_report(sk); tcp_done(sk); @@ -2379,7 +2379,7 @@ tcp_schedule_ack(tp); sk->shutdown |= RCV_SHUTDOWN; - sk->done = 1; + __clear_bit(SOCK_DONE, &sk->flags); switch(sk->state) { case TCP_SYN_RECV: @@ -2428,7 +2428,7 @@ tcp_sack_reset(tp); tcp_mem_reclaim(sk); - if (!sk->dead) { + if (!test_bit(SOCK_DEAD, &sk->flags)) { sk->state_change(sk); /* Do not send POLL_HUP for half duplex close. */ @@ -2745,7 +2745,7 @@ if (eaten > 0) { __kfree_skb(skb); - } else if (!sk->dead) + } else if (!test_bit(SOCK_DEAD, &sk->flags)) sk->data_ready(sk, 0); return; } @@ -3247,7 +3247,7 @@ * buggy users. */ if (tp->urg_seq == tp->copied_seq && tp->urg_data && - !sk->urginline && + !test_bit(SOCK_URGINLINE, &sk->flags) && tp->copied_seq != tp->rcv_nxt) { struct sk_buff *skb = skb_peek(&sk->receive_queue); tp->copied_seq++; @@ -3284,7 +3284,7 @@ if (skb_copy_bits(skb, ptr, &tmp, 1)) BUG(); tp->urg_data = TCP_URG_VALID | tmp; - if (!sk->dead) + if (!test_bit(SOCK_DEAD, &sk->flags)) sk->data_ready(sk,0); } } @@ -3699,7 +3699,7 @@ tcp_init_metrics(sk); tcp_init_buffer_space(sk); - if (sk->keepopen) + if (test_bit(SOCK_KEEPOPEN, &sk->flags)) tcp_reset_keepalive_timer(sk, keepalive_time_when(tp)); if (!tp->snd_wscale) @@ -3714,7 +3714,7 @@ mb(); tcp_set_state(sk, TCP_ESTABLISHED); - if(!sk->dead) { + if(!test_bit(SOCK_DEAD, &sk->flags)) { sk->state_change(sk); sk_wake_async(sk, 0, POLL_OUT); } @@ -3977,7 +3977,7 @@ sk->shutdown |= SEND_SHUTDOWN; dst_confirm(sk->dst_cache); - if (!sk->dead) { + if (!test_bit(SOCK_DEAD, &sk->flags)) { /* Wake up lingering close() */ sk->state_change(sk); } else { diff -Nru a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c --- a/net/ipv4/tcp_minisocks.c Thu Jan 30 23:22:09 2003 +++ b/net/ipv4/tcp_minisocks.c Mon Mar 3 04:56:53 2003 @@ -676,7 +676,7 @@ newsk->wmem_queued = 0; newsk->forward_alloc = 0; - newsk->done = 0; + __clear_bit(SOCK_DONE, &newsk->flags); newsk->userlocks = sk->userlocks & ~SOCK_BINDPORT_LOCK; newsk->backlog.head = newsk->backlog.tail = NULL; newsk->callback_lock = RW_LOCK_UNLOCKED; @@ -761,7 +761,7 @@ #endif atomic_inc(&tcp_sockets_allocated); - if (newsk->keepopen) + if (test_bit(SOCK_KEEPOPEN, &newsk->flags)) tcp_reset_keepalive_timer(newsk, keepalive_time_when(newtp)); newsk->socket = NULL; newsk->sleep = NULL; diff -Nru a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c --- a/net/ipv4/tcp_output.c Tue Feb 11 22:36:47 2003 +++ b/net/ipv4/tcp_output.c Mon Mar 3 04:56:53 2003 @@ -1276,7 +1276,7 @@ tp->rcv_ssthresh = tp->rcv_wnd; sk->err = 0; - sk->done = 0; + __clear_bit(SOCK_DONE, &sk->flags); tp->snd_wnd = 0; tcp_init_wl(tp, tp->write_seq, 0); tp->snd_una = tp->write_seq; diff -Nru a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c --- a/net/ipv4/tcp_timer.c Tue Jan 7 02:19:05 2003 +++ b/net/ipv4/tcp_timer.c Mon Mar 3 04:56:53 2003 @@ -189,7 +189,7 @@ } retry_until = sysctl_tcp_retries2; - if (sk->dead) { + if (test_bit(SOCK_DEAD, &sk->flags)) { int alive = (tp->rto < TCP_RTO_MAX); retry_until = tcp_orphan_retries(sk, alive); @@ -297,7 +297,7 @@ */ max_probes = sysctl_tcp_retries2; - if (sk->dead) { + if (test_bit(SOCK_DEAD, &sk->flags)) { int alive = ((tp->rto<backoff) < TCP_RTO_MAX); max_probes = tcp_orphan_retries(sk, alive); @@ -327,7 +327,7 @@ BUG_TRAP(!skb_queue_empty(&sk->write_queue)); - if (tp->snd_wnd == 0 && !sk->dead && + if (tp->snd_wnd == 0 && !test_bit(SOCK_DEAD, &sk->flags) && !((1<state)&(TCPF_SYN_SENT|TCPF_SYN_RECV))) { /* Receiver dastardly shrinks window. Our retransmits * become zero probes, but we should not timeout this @@ -571,7 +571,7 @@ if ((1<state)&(TCPF_CLOSE|TCPF_LISTEN)) return; - if (val && !sk->keepopen) + if (val && !test_bit(SOCK_KEEPOPEN, &sk->flags)) tcp_reset_keepalive_timer(sk, keepalive_time_when(tcp_sk(sk))); else if (!val) tcp_delete_keepalive_timer(sk); @@ -597,7 +597,7 @@ goto out; } - if (sk->state == TCP_FIN_WAIT2 && sk->dead) { + if (sk->state == TCP_FIN_WAIT2 && test_bit(SOCK_DEAD, &sk->flags)) { if (tp->linger2 >= 0) { int tmo = tcp_fin_time(tp) - TCP_TIMEWAIT_LEN; @@ -610,7 +610,7 @@ goto death; } - if (!sk->keepopen || sk->state == TCP_CLOSE) + if (!test_bit(SOCK_KEEPOPEN, &sk->flags) || sk->state == TCP_CLOSE) goto out; elapsed = keepalive_time_when(tp); diff -Nru a/net/ipv4/udp.c b/net/ipv4/udp.c --- a/net/ipv4/udp.c Tue Jan 7 02:19:05 2003 +++ b/net/ipv4/udp.c Mon Mar 3 04:56:53 2003 @@ -606,7 +606,8 @@ goto out; err = -EACCES; - if (rt->rt_flags&RTCF_BROADCAST && !sk->broadcast) + if (rt->rt_flags&RTCF_BROADCAST && + !test_bit(SOCK_BROADCAST, &sk->flags)) goto out; if (connected) sk_dst_set(sk, dst_clone(&rt->u.dst)); @@ -887,7 +888,8 @@ inet->sport, usin->sin_port, sk); if (err) return err; - if ((rt->rt_flags&RTCF_BROADCAST) && !sk->broadcast) { + if ((rt->rt_flags&RTCF_BROADCAST) && + !test_bit(SOCK_BROADCAST, &sk->flags)) { ip_rt_put(rt); return -EACCES; } diff -Nru a/net/ipv4/xfrm_algo.c b/net/ipv4/xfrm_algo.c --- a/net/ipv4/xfrm_algo.c Thu Jan 9 22:55:54 2003 +++ b/net/ipv4/xfrm_algo.c Thu Mar 6 16:16:15 2003 @@ -8,9 +8,17 @@ * Software Foundation; either version 2 of the License, or (at your option) * any later version. */ +#include #include #include #include +#if defined(CONFIG_INET_AH) || defined(CONFIG_INET_AH_MODULE) || defined(CONFIG_INET6_AH) || defined(CONFIG_INET6_AH_MODULE) +#include +#endif +#if defined(CONFIG_INET_ESP) || defined(CONFIG_INET_ESP_MODULE) || defined(CONFIG_INET6_ESP) || defined(CONFIG_INET6_ESP_MODULE) +#include +#endif +#include /* * Algorithms supported by IPsec. These entries contain properties which @@ -348,3 +356,333 @@ n++; return n; } + +#if defined(CONFIG_INET_AH) || defined(CONFIG_INET_AH_MODULE) || defined(CONFIG_INET6_AH) || defined(CONFIG_INET6_AH_MODULE) +void skb_ah_walk(const struct sk_buff *skb, + struct crypto_tfm *tfm, icv_update_fn_t icv_update) +{ + int offset = 0; + int len = skb->len; + int start = skb->len - skb->data_len; + int i, copy = start - offset; + struct scatterlist sg; + + /* Checksum header. */ + if (copy > 0) { + if (copy > len) + copy = len; + + sg.page = virt_to_page(skb->data + offset); + sg.offset = (unsigned long)(skb->data + offset) % PAGE_SIZE; + sg.length = copy; + + icv_update(tfm, &sg, 1); + + if ((len -= copy) == 0) + return; + offset += copy; + } + + for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { + int end; + + BUG_TRAP(start <= offset + len); + + end = start + skb_shinfo(skb)->frags[i].size; + if ((copy = end - offset) > 0) { + skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; + + if (copy > len) + copy = len; + + sg.page = frag->page; + sg.offset = frag->page_offset + offset-start; + sg.length = copy; + + icv_update(tfm, &sg, 1); + + if (!(len -= copy)) + return; + offset += copy; + } + start = end; + } + + if (skb_shinfo(skb)->frag_list) { + struct sk_buff *list = skb_shinfo(skb)->frag_list; + + for (; list; list = list->next) { + int end; + + BUG_TRAP(start <= offset + len); + + end = start + list->len; + if ((copy = end - offset) > 0) { + if (copy > len) + copy = len; + skb_ah_walk(list, tfm, icv_update); + if ((len -= copy) == 0) + return; + offset += copy; + } + start = end; + } + } + if (len) + BUG(); +} +#endif + +#if defined(CONFIG_INET_ESP) || defined(CONFIG_INET_ESP_MODULE) || defined(CONFIG_INET6_ESP) || defined(CONFIG_INET6_ESP_MODULE) +/* Move to common area: it is shared with AH. */ + +void skb_icv_walk(const struct sk_buff *skb, struct crypto_tfm *tfm, + int offset, int len, icv_update_fn_t icv_update) +{ + int start = skb->len - skb->data_len; + int i, copy = start - offset; + struct scatterlist sg; + + /* Checksum header. */ + if (copy > 0) { + if (copy > len) + copy = len; + + sg.page = virt_to_page(skb->data + offset); + sg.offset = (unsigned long)(skb->data + offset) % PAGE_SIZE; + sg.length = copy; + + icv_update(tfm, &sg, 1); + + if ((len -= copy) == 0) + return; + offset += copy; + } + + for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { + int end; + + BUG_TRAP(start <= offset + len); + + end = start + skb_shinfo(skb)->frags[i].size; + if ((copy = end - offset) > 0) { + skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; + + if (copy > len) + copy = len; + + sg.page = frag->page; + sg.offset = frag->page_offset + offset-start; + sg.length = copy; + + icv_update(tfm, &sg, 1); + + if (!(len -= copy)) + return; + offset += copy; + } + start = end; + } + + if (skb_shinfo(skb)->frag_list) { + struct sk_buff *list = skb_shinfo(skb)->frag_list; + + for (; list; list = list->next) { + int end; + + BUG_TRAP(start <= offset + len); + + end = start + list->len; + if ((copy = end - offset) > 0) { + if (copy > len) + copy = len; + skb_icv_walk(list, tfm, offset-start, copy, icv_update); + if ((len -= copy) == 0) + return; + offset += copy; + } + start = end; + } + } + if (len) + BUG(); +} + + +/* Looking generic it is not used in another places. */ + +int +skb_to_sgvec(struct sk_buff *skb, struct scatterlist *sg, int offset, int len) +{ + int start = skb->len - skb->data_len; + int i, copy = start - offset; + int elt = 0; + + if (copy > 0) { + if (copy > len) + copy = len; + sg[elt].page = virt_to_page(skb->data + offset); + sg[elt].offset = (unsigned long)(skb->data + offset) % PAGE_SIZE; + sg[elt].length = copy; + elt++; + if ((len -= copy) == 0) + return elt; + offset += copy; + } + + for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { + int end; + + BUG_TRAP(start <= offset + len); + + end = start + skb_shinfo(skb)->frags[i].size; + if ((copy = end - offset) > 0) { + skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; + + if (copy > len) + copy = len; + sg[elt].page = frag->page; + sg[elt].offset = frag->page_offset+offset-start; + sg[elt].length = copy; + elt++; + if (!(len -= copy)) + return elt; + offset += copy; + } + start = end; + } + + if (skb_shinfo(skb)->frag_list) { + struct sk_buff *list = skb_shinfo(skb)->frag_list; + + for (; list; list = list->next) { + int end; + + BUG_TRAP(start <= offset + len); + + end = start + list->len; + if ((copy = end - offset) > 0) { + if (copy > len) + copy = len; + elt += skb_to_sgvec(list, sg+elt, offset - start, copy); + if ((len -= copy) == 0) + return elt; + offset += copy; + } + start = end; + } + } + if (len) + BUG(); + return elt; +} + +/* Check that skb data bits are writable. If they are not, copy data + * to newly created private area. If "tailbits" is given, make sure that + * tailbits bytes beyond current end of skb are writable. + * + * Returns amount of elements of scatterlist to load for subsequent + * transformations and pointer to writable trailer skb. + */ + +int skb_cow_data(struct sk_buff *skb, int tailbits, struct sk_buff **trailer) +{ + int copyflag; + int elt; + struct sk_buff *skb1, **skb_p; + + /* If skb is cloned or its head is paged, reallocate + * head pulling out all the pages (pages are considered not writable + * at the moment even if they are anonymous). + */ + if ((skb_cloned(skb) || skb_shinfo(skb)->nr_frags) && + __pskb_pull_tail(skb, skb_pagelen(skb)-skb_headlen(skb)) == NULL) + return -ENOMEM; + + /* Easy case. Most of packets will go this way. */ + if (!skb_shinfo(skb)->frag_list) { + /* A little of trouble, not enough of space for trailer. + * This should not happen, when stack is tuned to generate + * good frames. OK, on miss we reallocate and reserve even more + * space, 128 bytes is fair. */ + + if (skb_tailroom(skb) < tailbits && + pskb_expand_head(skb, 0, tailbits-skb_tailroom(skb)+128, GFP_ATOMIC)) + return -ENOMEM; + + /* Voila! */ + *trailer = skb; + return 1; + } + + /* Misery. We are in troubles, going to mincer fragments... */ + + elt = 1; + skb_p = &skb_shinfo(skb)->frag_list; + copyflag = 0; + + while ((skb1 = *skb_p) != NULL) { + int ntail = 0; + + /* The fragment is partially pulled by someone, + * this can happen on input. Copy it and everything + * after it. */ + + if (skb_shared(skb1)) + copyflag = 1; + + /* If the skb is the last, worry about trailer. */ + + if (skb1->next == NULL && tailbits) { + if (skb_shinfo(skb1)->nr_frags || + skb_shinfo(skb1)->frag_list || + skb_tailroom(skb1) < tailbits) + ntail = tailbits + 128; + } + + if (copyflag || + skb_cloned(skb1) || + ntail || + skb_shinfo(skb1)->nr_frags || + skb_shinfo(skb1)->frag_list) { + struct sk_buff *skb2; + + /* Fuck, we are miserable poor guys... */ + if (ntail == 0) + skb2 = skb_copy(skb1, GFP_ATOMIC); + else + skb2 = skb_copy_expand(skb1, + skb_headroom(skb1), + ntail, + GFP_ATOMIC); + if (unlikely(skb2 == NULL)) + return -ENOMEM; + + if (skb1->sk) + skb_set_owner_w(skb, skb1->sk); + + /* Looking around. Are we still alive? + * OK, link new skb, drop old one */ + + skb2->next = skb1->next; + *skb_p = skb2; + kfree_skb(skb1); + skb1 = skb2; + } + elt++; + *trailer = skb1; + skb_p = &skb1->next; + } + + return elt; +} + +void *pskb_put(struct sk_buff *skb, struct sk_buff *tail, int len) +{ + if (tail != skb) { + skb->data_len += len; + skb->len += len; + } + return skb_put(tail, len); +} +#endif diff -Nru a/net/ipv4/xfrm_input.c b/net/ipv4/xfrm_input.c --- a/net/ipv4/xfrm_input.c Tue Nov 12 14:35:26 2002 +++ b/net/ipv4/xfrm_input.c Wed Mar 5 15:45:36 2003 @@ -1,4 +1,14 @@ +/* Changes + * + * Mitsuru KANDA @USAGI : IPv6 Support + * Kazunori MIYAZAWA @USAGI : + * YOSHIFUJI Hideaki @USAGI : + * Kunihiro Ishiguro : + * + */ + #include +#include #include static kmem_cache_t *secpath_cachep; @@ -64,7 +74,7 @@ if (xfrm_nr == XFRM_MAX_DEPTH) goto drop; - x = xfrm_state_lookup(iph->daddr, spi, iph->protocol); + x = xfrm4_state_lookup(iph->daddr, spi, iph->protocol); if (x == NULL) goto drop; @@ -157,3 +167,288 @@ if (!secpath_cachep) panic("IP: failed to allocate secpath_cache\n"); } + +#if defined (CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) + +/* Fetch spi and seq frpm ipsec header */ + +static int xfrm6_parse_spi(struct sk_buff *skb, u8 nexthdr, u32 *spi, u32 *seq) +{ + int offset, offset_seq; + + switch (nexthdr) { + case IPPROTO_AH: + offset = offsetof(struct ip_auth_hdr, spi); + offset_seq = offsetof(struct ip_auth_hdr, seq_no); + break; + case IPPROTO_ESP: + offset = offsetof(struct ip_esp_hdr, spi); + offset_seq = offsetof(struct ip_esp_hdr, seq_no); + break; + case IPPROTO_COMP: + if (!pskb_may_pull(skb, 4)) + return -EINVAL; + *spi = *(u16*)(skb->h.raw + 2); + *seq = 0; + return 0; + default: + return 1; + } + + if (!pskb_may_pull(skb, 16)) + return -EINVAL; + + *spi = *(u32*)(skb->h.raw + offset); + *seq = *(u32*)(skb->h.raw + offset_seq); + return 0; +} + +static int zero_out_mutable_opts(struct ipv6_opt_hdr *opthdr) +{ + u8 *opt = (u8 *)opthdr; + int len = ipv6_optlen(opthdr); + int off = 0; + int optlen = 0; + + off += 2; + len -= 2; + + while (len > 0) { + + switch (opt[off]) { + + case IPV6_TLV_PAD0: + optlen = 1; + break; + default: + if (len < 2) + goto bad; + optlen = opt[off+1]+2; + if (len < optlen) + goto bad; + if (opt[off] & 0x20) + memset(&opt[off+2], 0, opt[off+1]); + break; + } + + off += optlen; + len -= optlen; + } + if (len == 0) + return 1; + +bad: + return 0; +} + +int xfrm6_clear_mutable_options(struct sk_buff *skb, u16 *nh_offset, int dir) +{ + u16 offset = sizeof(struct ipv6hdr); + struct ipv6_opt_hdr *exthdr = (struct ipv6_opt_hdr*)(skb->nh.raw + offset); + unsigned int packet_len = skb->tail - skb->nh.raw; + u8 nexthdr = skb->nh.ipv6h->nexthdr; + u8 nextnexthdr = 0; + + *nh_offset = ((unsigned char *)&skb->nh.ipv6h->nexthdr) - skb->nh.raw; + + while (offset + 1 <= packet_len) { + + switch (nexthdr) { + + case NEXTHDR_HOP: + *nh_offset = offset; + offset += ipv6_optlen(exthdr); + if (!zero_out_mutable_opts(exthdr)) { + if (net_ratelimit()) + printk(KERN_WARNING "overrun hopopts\n"); + return 0; + } + nexthdr = exthdr->nexthdr; + exthdr = (struct ipv6_opt_hdr*)(skb->nh.raw + offset); + break; + + case NEXTHDR_ROUTING: + *nh_offset = offset; + offset += ipv6_optlen(exthdr); + ((struct ipv6_rt_hdr*)exthdr)->segments_left = 0; + nexthdr = exthdr->nexthdr; + exthdr = (struct ipv6_opt_hdr*)(skb->nh.raw + offset); + break; + + case NEXTHDR_DEST: + *nh_offset = offset; + offset += ipv6_optlen(exthdr); + if (!zero_out_mutable_opts(exthdr)) { + if (net_ratelimit()) + printk(KERN_WARNING "overrun destopt\n"); + return 0; + } + nexthdr = exthdr->nexthdr; + exthdr = (struct ipv6_opt_hdr*)(skb->nh.raw + offset); + break; + + case NEXTHDR_AUTH: + if (dir == XFRM_POLICY_OUT) { + memset(((struct ipv6_auth_hdr*)exthdr)->auth_data, 0, + (((struct ipv6_auth_hdr*)exthdr)->hdrlen - 1) << 2); + } + if (exthdr->nexthdr == NEXTHDR_DEST) { + offset += (((struct ipv6_auth_hdr*)exthdr)->hdrlen + 2) << 2; + exthdr = (struct ipv6_opt_hdr*)(skb->nh.raw + offset); + nextnexthdr = exthdr->nexthdr; + if (!zero_out_mutable_opts(exthdr)) { + if (net_ratelimit()) + printk(KERN_WARNING "overrun destopt\n"); + return 0; + } + } + return nexthdr; + default : + return nexthdr; + } + } + + return nexthdr; +} + +int xfrm6_rcv(struct sk_buff *skb) +{ + int err; + u32 spi, seq; + struct xfrm_state *xfrm_vec[XFRM_MAX_DEPTH]; + struct xfrm_state *x; + int xfrm_nr = 0; + int decaps = 0; + struct ipv6hdr *hdr = skb->nh.ipv6h; + unsigned char *tmp_hdr = NULL; + int hdr_len = 0; + u16 nh_offset = 0; + u8 nexthdr = 0; + + if (hdr->nexthdr == IPPROTO_AH || hdr->nexthdr == IPPROTO_ESP) { + nh_offset = ((unsigned char*)&skb->nh.ipv6h->nexthdr) - skb->nh.raw; + hdr_len = sizeof(struct ipv6hdr); + } else { + hdr_len = skb->h.raw - skb->nh.raw; + } + + tmp_hdr = kmalloc(hdr_len, GFP_ATOMIC); + if (!tmp_hdr) + goto drop; + memcpy(tmp_hdr, skb->nh.raw, hdr_len); + + nexthdr = xfrm6_clear_mutable_options(skb, &nh_offset, XFRM_POLICY_IN); + hdr->priority = 0; + hdr->flow_lbl[0] = 0; + hdr->flow_lbl[1] = 0; + hdr->flow_lbl[2] = 0; + hdr->hop_limit = 0; + + if ((err = xfrm6_parse_spi(skb, nexthdr, &spi, &seq)) != 0) + goto drop; + + do { + struct ipv6hdr *iph = skb->nh.ipv6h; + + if (xfrm_nr == XFRM_MAX_DEPTH) + goto drop; + + x = xfrm6_state_lookup(&iph->daddr, spi, nexthdr); + if (x == NULL) + goto drop; + spin_lock(&x->lock); + if (unlikely(x->km.state != XFRM_STATE_VALID)) + goto drop_unlock; + + if (x->props.replay_window && xfrm_replay_check(x, seq)) + goto drop_unlock; + + nexthdr = x->type->input(x, skb); + if (nexthdr <= 0) + goto drop_unlock; + + if (x->props.replay_window) + xfrm_replay_advance(x, seq); + + x->curlft.bytes += skb->len; + x->curlft.packets++; + + spin_unlock(&x->lock); + + xfrm_vec[xfrm_nr++] = x; + + iph = skb->nh.ipv6h; /* ??? */ + + if (nexthdr == NEXTHDR_DEST) { + if (!pskb_may_pull(skb, (skb->h.raw-skb->data)+8) || + !pskb_may_pull(skb, (skb->h.raw-skb->data)+((skb->h.raw[1]+1)<<3))) { + err = -EINVAL; + goto drop; + } + nexthdr = skb->h.raw[0]; + nh_offset = skb->h.raw - skb->nh.raw; + skb_pull(skb, (skb->h.raw[1]+1)<<3); + skb->h.raw = skb->data; + } + + if (x->props.mode) { /* XXX */ + if (iph->nexthdr != IPPROTO_IPV6) + goto drop; + skb->nh.raw = skb->data; + iph = skb->nh.ipv6h; + decaps = 1; + break; + } + + if ((err = xfrm6_parse_spi(skb, nexthdr, &spi, &seq)) < 0) + goto drop; + } while (!err); + + memcpy(skb->nh.raw, tmp_hdr, hdr_len); + skb->nh.raw[nh_offset] = nexthdr; + skb->nh.ipv6h->payload_len = htons(hdr_len + skb->len - sizeof(struct ipv6hdr)); + + /* Allocate new secpath or COW existing one. */ + if (!skb->sp || atomic_read(&skb->sp->refcnt) != 1) { + struct sec_path *sp; + sp = kmem_cache_alloc(secpath_cachep, SLAB_ATOMIC); + if (!sp) + goto drop; + if (skb->sp) { + memcpy(sp, skb->sp, sizeof(struct sec_path)); + secpath_put(skb->sp); + } else + sp->len = 0; + atomic_set(&sp->refcnt, 1); + skb->sp = sp; + } + + if (xfrm_nr + skb->sp->len > XFRM_MAX_DEPTH) + goto drop; + + memcpy(skb->sp->xvec+skb->sp->len, xfrm_vec, xfrm_nr*sizeof(void*)); + skb->sp->len += xfrm_nr; + + if (decaps) { + if (!(skb->dev->flags&IFF_LOOPBACK)) { + dst_release(skb->dst); + skb->dst = NULL; + } + netif_rx(skb); + return 0; + } else { + return -nexthdr; + } + +drop_unlock: + spin_unlock(&x->lock); + xfrm_state_put(x); +drop: + if (tmp_hdr) kfree(tmp_hdr); + while (--xfrm_nr >= 0) + xfrm_state_put(xfrm_vec[xfrm_nr]); + kfree_skb(skb); + return 0; +} + +#endif /* CONFIG_IPV6 || CONFIG_IPV6_MODULE */ diff -Nru a/net/ipv4/xfrm_policy.c b/net/ipv4/xfrm_policy.c --- a/net/ipv4/xfrm_policy.c Wed Feb 19 14:32:20 2003 +++ b/net/ipv4/xfrm_policy.c Wed Mar 5 15:45:36 2003 @@ -1,6 +1,16 @@ +/* Changes + * + * Mitsuru KANDA @USAGI : IPv6 Support + * Kazunori MIYAZAWA @USAGI : + * Kunihiro Ishiguro : + * + */ + #include #include #include +#include +#include DECLARE_MUTEX(xfrm_cfg_sem); @@ -10,6 +20,11 @@ struct xfrm_policy *xfrm_policy_list[XFRM_POLICY_MAX*2]; extern struct dst_ops xfrm4_dst_ops; +#if defined (CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) +extern struct dst_ops xfrm6_dst_ops; +#endif + +static inline int xfrm_dst_lookup(struct xfrm_dst **dst, struct flowi *fl, unsigned short family); /* Limited flow cache. Its function now is to accelerate search for * policy rules. @@ -48,6 +63,24 @@ return hash & (FLOWCACHE_HASH_SIZE-1); } +#if defined (CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) +static inline u32 flow_hash6(struct flowi *fl) +{ + u32 hash = fl->fl6_src->s6_addr32[2] ^ + fl->fl6_src->s6_addr32[3] ^ + fl->uli_u.ports.sport; + + hash = ((hash & 0xF0F0F0F0) >> 4) | ((hash & 0x0F0F0F0F) << 4); + + hash ^= fl->fl6_dst->s6_addr32[2] ^ + fl->fl6_dst->s6_addr32[3] ^ + fl->uli_u.ports.dport; + hash ^= (hash >> 10); + hash ^= (hash >> 20); + return hash & (FLOWCACHE_HASH_SIZE-1); +} +#endif + static int flow_lwm = 2*FLOWCACHE_HASH_SIZE; static int flow_hwm = 4*FLOWCACHE_HASH_SIZE; @@ -77,13 +110,27 @@ } } -struct xfrm_policy *flow_lookup(int dir, struct flowi *fl) +struct xfrm_policy *flow_lookup(int dir, struct flowi *fl, + unsigned short family) { - struct xfrm_policy *pol; + struct xfrm_policy *pol = NULL; struct flow_entry *fle; - u32 hash = flow_hash(fl); + u32 hash; int cpu; + switch (family) { + case AF_INET: + hash = flow_hash(fl); + break; +#if defined (CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) + case AF_INET6: + hash = flow_hash6(fl); + break; +#endif + default: + return NULL; + } + local_bh_disable(); cpu = smp_processor_id(); @@ -101,7 +148,7 @@ } } - pol = xfrm_policy_lookup(dir, fl); + pol = xfrm_policy_lookup(dir, fl, family); if (fle) { /* Stale flow entry found. Update it. */ @@ -199,6 +246,46 @@ return type; } +static xfrm_dst_lookup_t *__xfrm_dst_lookup[AF_MAX]; +rwlock_t xdl_lock = RW_LOCK_UNLOCKED; + +int xfrm_dst_lookup_register(xfrm_dst_lookup_t *dst_lookup, + unsigned short family) +{ + int err = 0; + + write_lock(&xdl_lock); + if (__xfrm_dst_lookup[family]) + err = -ENOBUFS; + else { + __xfrm_dst_lookup[family] = dst_lookup; + } + write_unlock(&xdl_lock); + + return err; +} + +void xfrm_dst_lookup_unregister(unsigned short family) +{ + write_lock(&xdl_lock); + if (__xfrm_dst_lookup[family]) + __xfrm_dst_lookup[family] = 0; + write_unlock(&xdl_lock); +} + +static inline int xfrm_dst_lookup(struct xfrm_dst **dst, struct flowi *fl, + unsigned short family) +{ + int err = 0; + read_lock(&xdl_lock); + if (__xfrm_dst_lookup[family]) + err = __xfrm_dst_lookup[family](dst, fl); + else + err = -EINVAL; + read_unlock(&xdl_lock); + return err; +} + #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) static struct xfrm_type *xfrm6_type_map[256]; static rwlock_t xfrm6_type_lock = RW_LOCK_UNLOCKED; @@ -506,15 +593,32 @@ /* Find policy to apply to this flow. */ -struct xfrm_policy *xfrm_policy_lookup(int dir, struct flowi *fl) +struct xfrm_policy *xfrm_policy_lookup(int dir, struct flowi *fl, + unsigned short family) { struct xfrm_policy *pol; read_lock_bh(&xfrm_policy_lock); for (pol = xfrm_policy_list[dir]; pol; pol = pol->next) { struct xfrm_selector *sel = &pol->selector; + int match; + + if (pol->family != family) + continue; - if (xfrm4_selector_match(sel, fl)) { + switch (family) { + case AF_INET: + match = xfrm4_selector_match(sel, fl); + break; +#if defined (CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) + case AF_INET6: + match = xfrm6_selector_match(sel, fl); + break; +#endif + default: + match = 0; + } + if (match) { atomic_inc(&pol->refcnt); break; } @@ -529,7 +633,21 @@ read_lock_bh(&xfrm_policy_lock); if ((pol = sk->policy[dir]) != NULL) { - if (xfrm4_selector_match(&pol->selector, fl)) + int match; + + switch (sk->family) { + case AF_INET: + match = xfrm4_selector_match(&pol->selector, fl); + break; +#if defined (CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) + case AF_INET6: + match = xfrm6_selector_match(&pol->selector, fl); + break; +#endif + default: + match = 0; + } + if (match) atomic_inc(&pol->refcnt); else pol = NULL; @@ -630,8 +748,8 @@ /* Resolve list of templates for the flow, given policy. */ static int -xfrm_tmpl_resolve(struct xfrm_policy *policy, struct flowi *fl, - struct xfrm_state **xfrm) +xfrm4_tmpl_resolve(struct xfrm_policy *policy, struct flowi *fl, + struct xfrm_state **xfrm) { int nx; int i, error; @@ -649,7 +767,7 @@ local = tmpl->saddr.xfrm4_addr; } - x = xfrm_state_find(remote, local, fl, tmpl, policy, &error); + x = xfrm4_state_find(remote, local, fl, tmpl, policy, &error); if (x && x->km.state == XFRM_STATE_VALID) { xfrm[nx++] = x; @@ -674,6 +792,53 @@ return error; } +#if defined (CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) +static int +xfrm6_tmpl_resolve(struct xfrm_policy *policy, struct flowi *fl, + struct xfrm_state **xfrm) +{ + int nx; + int i, error; + struct in6_addr *daddr = fl->fl6_dst; + struct in6_addr *saddr = fl->fl6_src; + + for (nx=0, i = 0; i < policy->xfrm_nr; i++) { + struct xfrm_state *x=NULL; + struct in6_addr *remote = daddr; + struct in6_addr *local = saddr; + struct xfrm_tmpl *tmpl = &policy->xfrm_vec[i]; + + if (tmpl->mode) { + remote = (struct in6_addr*)&tmpl->id.daddr; + local = (struct in6_addr*)&tmpl->saddr; + } + + x = xfrm6_state_find(remote, local, fl, tmpl, policy, &error); + + if (x && x->km.state == XFRM_STATE_VALID) { + xfrm[nx++] = x; + daddr = remote; + saddr = local; + continue; + } + if (x) { + error = (x->km.state == XFRM_STATE_ERROR ? + -EINVAL : -EAGAIN); + xfrm_state_put(x); + } + + if (!tmpl->optional) + goto fail; + } + return nx; + +fail: + for (nx--; nx>=0; nx--) + xfrm_state_put(xfrm[nx]); + return error; +} +#endif + /* Check that the bundle accepts the flow and its components are * still valid. */ @@ -694,6 +859,24 @@ return 0; } +#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) +static int xfrm6_bundle_ok(struct xfrm_dst *xdst, struct flowi *fl) +{ + do { + if (xdst->u.dst.ops != &xfrm6_dst_ops) + return 1; + + if (!xfrm6_selector_match(&xdst->u.dst.xfrm->sel, fl)) + return 0; + if (xdst->u.dst.xfrm->km.state != XFRM_STATE_VALID || + xdst->u.dst.path->obsolete > 0) + return 0; + xdst = (struct xfrm_dst*)xdst->u.dst.child; + } while (xdst); + return 0; +} +#endif + /* Allocate chain of dst_entry's, attach known xfrm's, calculate * all the metrics... Shortly, bundle a bundle. @@ -728,7 +911,7 @@ else { dst_prev->child = dst1; dst1->flags |= DST_NOHASH; - dst_clone(dst1); + dst_hold(dst1); } dst_prev = dst1; if (xfrm[i]->props.mode) { @@ -744,11 +927,11 @@ .saddr = local } } }; - err = __ip_route_output_key(&rt, &fl_tunnel); + err = xfrm_dst_lookup((struct xfrm_dst**)&rt, &fl_tunnel, AF_INET); if (err) goto error; } else { - dst_clone(&rt->u.dst); + dst_hold(&rt->u.dst); } dst_prev->child = &rt->u.dst; for (dst_prev = dst; dst_prev != &rt->u.dst; dst_prev = dst_prev->child) { @@ -791,6 +974,97 @@ return err; } +#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) +static int +xfrm6_bundle_create(struct xfrm_policy *policy, struct xfrm_state **xfrm, int nx, + struct flowi *fl, struct dst_entry **dst_p) +{ + struct dst_entry *dst, *dst_prev; + struct rt6_info *rt0 = (struct rt6_info*)(*dst_p); + struct rt6_info *rt = rt0; + struct in6_addr *remote = fl->fl6_dst; + struct in6_addr *local = fl->fl6_src; + int i; + int err = 0; + int header_len = 0; + + dst = dst_prev = NULL; + + for (i = 0; i < nx; i++) { + struct dst_entry *dst1 = dst_alloc(&xfrm6_dst_ops); + + if (unlikely(dst1 == NULL)) { + err = -ENOBUFS; + goto error; + } + + dst1->xfrm = xfrm[i]; + if (!dst) + dst = dst1; + else { + dst_prev->child = dst1; + dst1->flags |= DST_NOHASH; + dst_clone(dst1); + } + dst_prev = dst1; + if (xfrm[i]->props.mode) { + remote = (struct in6_addr*)&xfrm[i]->id.daddr; + local = (struct in6_addr*)&xfrm[i]->props.saddr; + } + header_len += xfrm[i]->props.header_len; + } + + if (ipv6_addr_cmp(remote, fl->fl6_dst)) { + struct flowi fl_tunnel = { .nl_u = { .ip6_u = + { .daddr = remote, + .saddr = local } + } + }; + err = xfrm_dst_lookup((struct xfrm_dst**)&dst, &fl_tunnel, AF_INET6); + if (err) + goto error; + } else { + dst_clone(&rt->u.dst); + } + dst_prev->child = &rt->u.dst; + for (dst_prev = dst; dst_prev != &rt->u.dst; dst_prev = dst_prev->child) { + struct xfrm_dst *x = (struct xfrm_dst*)dst_prev; + x->u.rt.fl = *fl; + + dst_prev->dev = rt->u.dst.dev; + if (rt->u.dst.dev) + dev_hold(rt->u.dst.dev); + dst_prev->obsolete = -1; + dst_prev->flags |= DST_HOST; + dst_prev->lastuse = jiffies; + dst_prev->header_len = header_len; + memcpy(&dst_prev->metrics, &rt->u.dst.metrics, sizeof(dst_prev->metrics)); + dst_prev->path = &rt->u.dst; + + /* Copy neighbout for reachability confirmation */ + dst_prev->neighbour = neigh_clone(rt->u.dst.neighbour); + dst_prev->input = rt->u.dst.input; + dst_prev->output = dst_prev->xfrm->type->output; + /* Sheit... I remember I did this right. Apparently, + * it was magically lost, so this code needs audit */ + x->u.rt6.rt6i_flags = rt0->rt6i_flags&(RTCF_BROADCAST|RTCF_MULTICAST|RTCF_LOCAL); + x->u.rt6.rt6i_metric = rt0->rt6i_metric; + x->u.rt6.rt6i_node = rt0->rt6i_node; + x->u.rt6.rt6i_hoplimit = rt0->rt6i_hoplimit; + x->u.rt6.rt6i_gateway = rt0->rt6i_gateway; + memcpy(&x->u.rt6.rt6i_gateway, &rt0->rt6i_gateway, sizeof(x->u.rt6.rt6i_gateway)); + header_len -= x->u.dst.xfrm->props.header_len; + } + *dst_p = dst; + return 0; + +error: + if (dst) + dst_free(dst); + return err; +} +#endif + /* Main function: finds/creates a bundle for given flow. * * At the moment we eat a raw IP route. Mostly to speed up lookups @@ -806,9 +1080,7 @@ int nx = 0; int err; u32 genid; - - fl->oif = rt->u.dst.dev->ifindex; - fl->fl4_src = rt->rt_src; + u16 family = (*dst_p)->ops->family; restart: genid = xfrm_policy_genid; @@ -821,11 +1093,12 @@ if ((rt->u.dst.flags & DST_NOXFRM) || !xfrm_policy_list[XFRM_POLICY_OUT]) return 0; - policy = flow_lookup(XFRM_POLICY_OUT, fl); - if (!policy) - return 0; + policy = flow_lookup(XFRM_POLICY_OUT, fl, family); } + if (!policy) + return 0; + policy->curlft.use_time = (unsigned long)xtime.tv_sec; switch (policy->action) { @@ -846,23 +1119,48 @@ * LATER: help from flow cache. It is optional, this * is required only for output policy. */ - read_lock_bh(&policy->lock); - for (dst = policy->bundles; dst; dst = dst->next) { - struct xfrm_dst *xdst = (struct xfrm_dst*)dst; - if (xdst->u.rt.fl.fl4_dst == fl->fl4_dst && - xdst->u.rt.fl.fl4_src == fl->fl4_src && - xdst->u.rt.fl.oif == fl->oif && - xfrm_bundle_ok(xdst, fl)) { - dst_clone(dst); + if (family == AF_INET) { + fl->oif = rt->u.dst.dev->ifindex; + fl->fl4_src = rt->rt_src; + read_lock_bh(&policy->lock); + for (dst = policy->bundles; dst; dst = dst->next) { + struct xfrm_dst *xdst = (struct xfrm_dst*)dst; + if (xdst->u.rt.fl.fl4_dst == fl->fl4_dst && + xdst->u.rt.fl.fl4_src == fl->fl4_src && + xdst->u.rt.fl.oif == fl->oif && + xfrm_bundle_ok(xdst, fl)) { + dst_clone(dst); + break; + } + } + read_unlock_bh(&policy->lock); + if (dst) break; + nx = xfrm4_tmpl_resolve(policy, fl, xfrm); +#if defined (CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) + } else if (family == AF_INET6) { + read_lock_bh(&policy->lock); + for (dst = policy->bundles; dst; dst = dst->next) { + struct xfrm_dst *xdst = (struct xfrm_dst*)dst; + if (!ipv6_addr_cmp(&xdst->u.rt6.rt6i_dst.addr, fl->fl6_dst) && + !ipv6_addr_cmp(&xdst->u.rt6.rt6i_src.addr, fl->fl6_src) && + xfrm6_bundle_ok(xdst, fl)) { + dst_clone(dst); + break; + } } + read_unlock_bh(&policy->lock); + if (dst) + break; + nx = xfrm6_tmpl_resolve(policy, fl, xfrm); +#endif + } else { + return -EINVAL; } - read_unlock_bh(&policy->lock); if (dst) break; - nx = xfrm_tmpl_resolve(policy, fl, xfrm); if (unlikely(nx<0)) { err = nx; if (err == -EAGAIN) { @@ -873,7 +1171,18 @@ __set_task_state(tsk, TASK_INTERRUPTIBLE); add_wait_queue(&km_waitq, &wait); - err = xfrm_tmpl_resolve(policy, fl, xfrm); + switch (family) { + case AF_INET: + err = xfrm4_tmpl_resolve(policy, fl, xfrm); + break; +#if defined (CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) + case AF_INET6: + err = xfrm6_tmpl_resolve(policy, fl, xfrm); + break; +#endif + default: + err = -EINVAL; + } if (err == -EAGAIN) schedule(); __set_task_state(tsk, TASK_RUNNING); @@ -896,7 +1205,19 @@ } dst = &rt->u.dst; - err = xfrm_bundle_create(policy, xfrm, nx, fl, &dst); + switch (family) { + case AF_INET: + err = xfrm_bundle_create(policy, xfrm, nx, fl, &dst); + break; +#if defined (CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) + case AF_INET6: + err = xfrm6_bundle_create(policy, xfrm, nx, fl, &dst); + break; +#endif + default: + err = -EINVAL; + } + if (unlikely(err)) { int i; for (i=0; inext = policy->bundles; policy->bundles = dst; - dst_clone(dst); + dst_hold(dst); write_unlock_bh(&policy->lock); } *dst_p = dst; @@ -962,7 +1283,7 @@ } static void -_decode_session(struct sk_buff *skb, struct flowi *fl) +_decode_session4(struct sk_buff *skb, struct flowi *fl) { struct iphdr *iph = skb->nh.iph; u8 *xprth = skb->nh.raw + iph->ihl*4; @@ -1008,18 +1329,109 @@ fl->fl4_src = iph->saddr; } -int __xfrm_policy_check(struct sock *sk, int dir, struct sk_buff *skb) +#if defined (CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) +static inline int +xfrm6_state_ok(struct xfrm_tmpl *tmpl, struct xfrm_state *x) +{ + return x->id.proto == tmpl->id.proto && + (x->id.spi == tmpl->id.spi || !tmpl->id.spi) && + x->props.mode == tmpl->mode && + (tmpl->aalgos & (1<props.aalgo)) && + (!x->props.mode || !ipv6_addr_any((struct in6_addr*)&x->props.saddr) || + !ipv6_addr_cmp((struct in6_addr *)&tmpl->saddr, (struct in6_addr*)&x->props.saddr)); +} + +static inline int +xfrm6_policy_ok(struct xfrm_tmpl *tmpl, struct sec_path *sp, int idx) +{ + for (; idx < sp->len; idx++) { + if (xfrm6_state_ok(tmpl, sp->xvec[idx])) + return ++idx; + } + return -1; +} + +static inline void +_decode_session6(struct sk_buff *skb, struct flowi *fl) +{ + u16 offset = sizeof(struct ipv6hdr); + struct ipv6hdr *hdr = skb->nh.ipv6h; + struct ipv6_opt_hdr *exthdr = (struct ipv6_opt_hdr*)(skb->nh.raw + offset); + u8 nexthdr = skb->nh.ipv6h->nexthdr; + + fl->fl6_dst = &hdr->daddr; + fl->fl6_src = &hdr->saddr; + + while (pskb_may_pull(skb, skb->nh.raw + offset + 1 - skb->data)) { + switch (nexthdr) { + case NEXTHDR_ROUTING: + case NEXTHDR_HOP: + case NEXTHDR_DEST: + offset += ipv6_optlen(exthdr); + nexthdr = exthdr->nexthdr; + exthdr = (struct ipv6_opt_hdr*)(skb->nh.raw + offset); + break; + + case IPPROTO_UDP: + case IPPROTO_TCP: + case IPPROTO_SCTP: + if (pskb_may_pull(skb, skb->nh.raw + offset + 4 - skb->data)) { + u16 *ports = (u16 *)exthdr; + + fl->uli_u.ports.sport = ports[0]; + fl->uli_u.ports.dport = ports[1]; + } + return; + + /* XXX Why are there these headers? */ + case IPPROTO_AH: + case IPPROTO_ESP: + default: + fl->uli_u.spi = 0; + return; + }; + } +} +#endif + +int __xfrm_policy_check(struct sock *sk, int dir, struct sk_buff *skb, + unsigned short family) { struct xfrm_policy *pol; struct flowi fl; - _decode_session(skb, &fl); + switch (family) { + case AF_INET: + _decode_session4(skb, &fl); + break; +#if defined (CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) + case AF_INET6: + _decode_session6(skb, &fl); + break; +#endif + default : + return 0; + } /* First, check used SA against their selectors. */ if (skb->sp) { int i; + for (i=skb->sp->len-1; i>=0; i--) { - if (!xfrm4_selector_match(&skb->sp->xvec[i]->sel, &fl)) + int match; + switch (family) { + case AF_INET: + match = xfrm4_selector_match(&skb->sp->xvec[i]->sel, &fl); + break; +#if defined (CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) + case AF_INET6: + match = xfrm6_selector_match(&skb->sp->xvec[i]->sel, &fl); + break; +#endif + default: + match = 0; + } + if (!match) return 0; } } @@ -1029,7 +1441,7 @@ pol = xfrm_sk_policy_lookup(sk, dir, &fl); if (!pol) - pol = flow_lookup(dir, &fl); + pol = flow_lookup(dir, &fl, family); if (!pol) return 1; @@ -1050,7 +1462,18 @@ * are implied between each two transformations. */ for (i = pol->xfrm_nr-1, k = 0; i >= 0; i--) { - k = xfrm_policy_ok(pol->xfrm_vec+i, sp, k); + switch (family) { + case AF_INET: + k = xfrm_policy_ok(pol->xfrm_vec+i, sp, k); + break; +#if defined (CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) + case AF_INET6: + k = xfrm6_policy_ok(pol->xfrm_vec+i, sp, k); + break; +#endif + default: + k = -1; + } if (k < 0) goto reject; } @@ -1064,18 +1487,29 @@ return 0; } -int __xfrm_route_forward(struct sk_buff *skb) +int __xfrm_route_forward(struct sk_buff *skb, unsigned short family) { struct flowi fl; - _decode_session(skb, &fl); + switch (family) { + case AF_INET: + _decode_session4(skb, &fl); + break; +#if defined (CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) + case AF_INET6: + _decode_session6(skb, &fl); + break; +#endif + default: + return 0; + } return xfrm_lookup(&skb->dst, &fl, NULL, 0) == 0; } /* Optimize later using cookies and generation ids. */ -static struct dst_entry *xfrm4_dst_check(struct dst_entry *dst, u32 cookie) +static struct dst_entry *xfrm_dst_check(struct dst_entry *dst, u32 cookie) { struct dst_entry *child = dst; @@ -1091,19 +1525,19 @@ return dst; } -static void xfrm4_dst_destroy(struct dst_entry *dst) +static void xfrm_dst_destroy(struct dst_entry *dst) { xfrm_state_put(dst->xfrm); dst->xfrm = NULL; } -static void xfrm4_link_failure(struct sk_buff *skb) +static void xfrm_link_failure(struct sk_buff *skb) { /* Impossible. Such dst must be popped before reaches point of failure. */ return; } -static struct dst_entry *xfrm4_negative_advice(struct dst_entry *dst) +static struct dst_entry *xfrm_negative_advice(struct dst_entry *dst) { if (dst) { if (dst->obsolete) { @@ -1114,8 +1548,7 @@ return dst; } - -static int xfrm4_garbage_collect(void) +static void __xfrm_garbage_collect(void) { int i; struct xfrm_policy *pol; @@ -1145,10 +1578,22 @@ gc_list = dst->next; dst_free(dst); } +} +static inline int xfrm4_garbage_collect(void) +{ + __xfrm_garbage_collect(); return (atomic_read(&xfrm4_dst_ops.entries) > xfrm4_dst_ops.gc_thresh*2); } +#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) +static inline int xfrm6_garbage_collect(void) +{ + __xfrm_garbage_collect(); + return (atomic_read(&xfrm6_dst_ops.entries) > xfrm6_dst_ops.gc_thresh*2); +} +#endif + static int bundle_depends_on(struct dst_entry *dst, struct xfrm_state *x) { do { @@ -1192,7 +1637,7 @@ return 0; } - + static void xfrm4_update_pmtu(struct dst_entry *dst, u32 mtu) { struct dst_entry *path = dst->path; @@ -1203,6 +1648,18 @@ path->ops->update_pmtu(path, mtu); } +#if defined (CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) +static void xfrm6_update_pmtu(struct dst_entry *dst, u32 mtu) +{ + struct dst_entry *path = dst->path; + + if (mtu >= 1280 && mtu < dst_pmtu(dst)) + return; + + path->ops->update_pmtu(path, mtu); +} +#endif + /* Well... that's _TASK_. We need to scan through transformation * list and figure out what mss tcp should generate in order to * final datagram fit to mtu. Mama mia... :-) @@ -1212,7 +1669,7 @@ * * Consider this function as something like dark humour. :-) */ -static int xfrm4_get_mss(struct dst_entry *dst, u32 mtu) +static int xfrm_get_mss(struct dst_entry *dst, u32 mtu) { int res = mtu - dst->header_len; @@ -1247,16 +1704,32 @@ .family = AF_INET, .protocol = __constant_htons(ETH_P_IP), .gc = xfrm4_garbage_collect, - .check = xfrm4_dst_check, - .destroy = xfrm4_dst_destroy, - .negative_advice = xfrm4_negative_advice, - .link_failure = xfrm4_link_failure, + .check = xfrm_dst_check, + .destroy = xfrm_dst_destroy, + .negative_advice = xfrm_negative_advice, + .link_failure = xfrm_link_failure, .update_pmtu = xfrm4_update_pmtu, - .get_mss = xfrm4_get_mss, + .get_mss = xfrm_get_mss, .gc_thresh = 1024, .entry_size = sizeof(struct xfrm_dst), }; +#if defined (CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) +struct dst_ops xfrm6_dst_ops = { + .family = AF_INET6, + .protocol = __constant_htons(ETH_P_IPV6), + .gc = xfrm6_garbage_collect, + .check = xfrm_dst_check, + .destroy = xfrm_dst_destroy, + .negative_advice = xfrm_negative_advice, + .link_failure = xfrm_link_failure, + .update_pmtu = xfrm6_update_pmtu, + .get_mss = xfrm_get_mss, + .gc_thresh = 1024, + .entry_size = sizeof(struct xfrm_dst), +}; +#endif /* CONFIG_IPV6 || CONFIG_IPV6_MODULE */ + void __init xfrm_init(void) { xfrm4_dst_ops.kmem_cachep = kmem_cache_create("xfrm4_dst_cache", @@ -1267,8 +1740,12 @@ if (!xfrm4_dst_ops.kmem_cachep) panic("IP: failed to allocate xfrm4_dst_cache\n"); - flow_cache_init(); +#if defined (CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) + xfrm6_dst_ops.kmem_cachep = xfrm4_dst_ops.kmem_cachep; +#endif + flow_cache_init(); xfrm_state_init(); xfrm_input_init(); } + diff -Nru a/net/ipv4/xfrm_state.c b/net/ipv4/xfrm_state.c --- a/net/ipv4/xfrm_state.c Thu Feb 13 01:26:32 2003 +++ b/net/ipv4/xfrm_state.c Wed Mar 5 15:45:36 2003 @@ -1,3 +1,11 @@ +/* Changes + * + * Mitsuru KANDA @USAGI : IPv6 Support + * Kazunori MIYAZAWA @USAGI : + * Kunihiro Ishiguro : + * + */ + #include #include #include @@ -207,8 +215,8 @@ } struct xfrm_state * -xfrm_state_find(u32 daddr, u32 saddr, struct flowi *fl, struct xfrm_tmpl *tmpl, - struct xfrm_policy *pol, int *err) +xfrm4_state_find(u32 daddr, u32 saddr, struct flowi *fl, struct xfrm_tmpl *tmpl, + struct xfrm_policy *pol, int *err) { unsigned h = ntohl(daddr); struct xfrm_state *x; @@ -290,6 +298,7 @@ x->props.saddr.xfrm4_addr = saddr; x->props.mode = tmpl->mode; x->props.reqid = tmpl->reqid; + x->props.family = AF_INET; if (km_query(x, tmpl, pol) == 0) { x->km.state = XFRM_STATE_ACQ; @@ -318,14 +327,133 @@ return x; } +#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) +struct xfrm_state * +xfrm6_state_find(struct in6_addr *daddr, struct in6_addr *saddr, struct flowi *fl, struct xfrm_tmpl *tmpl, + struct xfrm_policy *pol, int *err) +{ + unsigned h = ntohl(daddr->s6_addr32[2]^daddr->s6_addr32[3]); + struct xfrm_state *x; + int acquire_in_progress = 0; + int error = 0; + struct xfrm_state *best = NULL; + + h = (h ^ (h>>16)) % XFRM_DST_HSIZE; + + spin_lock_bh(&xfrm_state_lock); + list_for_each_entry(x, xfrm_state_bydst+h, bydst) { + if (x->props.family == AF_INET6&& + !ipv6_addr_cmp(daddr, (struct in6_addr *)&x->id.daddr) && + x->props.reqid == tmpl->reqid && + (!ipv6_addr_cmp(saddr, (struct in6_addr *)&x->props.saddr)|| ipv6_addr_any(saddr)) && + tmpl->mode == x->props.mode && + tmpl->id.proto == x->id.proto) { + /* Resolution logic: + 1. There is a valid state with matching selector. + Done. + 2. Valid state with inappropriate selector. Skip. + + Entering area of "sysdeps". + + 3. If state is not valid, selector is temporary, + it selects only session which triggered + previous resolution. Key manager will do + something to install a state with proper + selector. + */ + if (x->km.state == XFRM_STATE_VALID) { + if (!xfrm6_selector_match(&x->sel, fl)) + continue; + if (!best || + best->km.dying > x->km.dying || + (best->km.dying == x->km.dying && + best->curlft.add_time < x->curlft.add_time)) + best = x; + } else if (x->km.state == XFRM_STATE_ACQ) { + acquire_in_progress = 1; + } else if (x->km.state == XFRM_STATE_ERROR || + x->km.state == XFRM_STATE_EXPIRED) { + if (xfrm6_selector_match(&x->sel, fl)) + error = 1; + } + } + } + + if (best) { + atomic_inc(&best->refcnt); + spin_unlock_bh(&xfrm_state_lock); + return best; + } + x = NULL; + if (!error && !acquire_in_progress && + ((x = xfrm_state_alloc()) != NULL)) { + /* Initialize temporary selector matching only + * to current session. */ + memcpy(&x->sel.daddr, fl->fl6_dst, sizeof(struct in6_addr)); + memcpy(&x->sel.saddr, fl->fl6_src, sizeof(struct in6_addr)); + x->sel.dport = fl->uli_u.ports.dport; + x->sel.dport_mask = ~0; + x->sel.sport = fl->uli_u.ports.sport; + x->sel.sport_mask = ~0; + x->sel.prefixlen_d = 128; + x->sel.prefixlen_s = 128; + x->sel.proto = fl->proto; + x->sel.ifindex = fl->oif; + x->id = tmpl->id; + if (ipv6_addr_any((struct in6_addr*)&x->id.daddr)) + memcpy(&x->id.daddr, daddr, sizeof(x->sel.daddr)); + memcpy(&x->props.saddr, &tmpl->saddr, sizeof(x->props.saddr)); + if (ipv6_addr_any((struct in6_addr*)&x->props.saddr)) + memcpy(&x->props.saddr, &saddr, sizeof(x->sel.saddr)); + x->props.mode = tmpl->mode; + x->props.reqid = tmpl->reqid; + x->props.family = AF_INET6; + + if (km_query(x, tmpl, pol) == 0) { + x->km.state = XFRM_STATE_ACQ; + list_add_tail(&x->bydst, xfrm_state_bydst+h); + atomic_inc(&x->refcnt); + if (x->id.spi) { + struct in6_addr *addr = (struct in6_addr*)&x->id.daddr; + h = ntohl((addr->s6_addr32[2]^addr->s6_addr32[3])^x->id.spi^x->id.proto); + h = (h ^ (h>>10) ^ (h>>20)) % XFRM_DST_HSIZE; + list_add(&x->byspi, xfrm_state_byspi+h); + atomic_inc(&x->refcnt); + } + x->lft.hard_add_expires_seconds = ACQ_EXPIRES; + atomic_inc(&x->refcnt); + mod_timer(&x->timer, ACQ_EXPIRES*HZ); + } else { + x->km.state = XFRM_STATE_DEAD; + xfrm_state_put(x); + x = NULL; + error = 1; + } + } + spin_unlock_bh(&xfrm_state_lock); + if (!x) + *err = acquire_in_progress ? -EAGAIN : + (error ? -ESRCH : -ENOMEM); + return x; +} +#endif /* CONFIG_IPV6 || CONFIG_IPV6_MODULE */ + void xfrm_state_insert(struct xfrm_state *x) { unsigned h = 0; - if (x->props.family == AF_INET) + switch (x->props.family) { + case AF_INET: h = ntohl(x->id.daddr.xfrm4_addr); - else if (x->props.family == AF_INET6) + break; +#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) + case AF_INET6: h = ntohl(x->id.daddr.a6[2]^x->id.daddr.a6[3]); + break; +#endif + default: + return; + } h = (h ^ (h>>16)) % XFRM_DST_HSIZE; @@ -384,7 +512,7 @@ } struct xfrm_state * -xfrm_state_lookup(u32 daddr, u32 spi, u8 proto) +xfrm4_state_lookup(u32 daddr, u32 spi, u8 proto) { unsigned h = ntohl(daddr^spi^proto); struct xfrm_state *x; @@ -406,6 +534,31 @@ return NULL; } +#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) +struct xfrm_state * +xfrm6_state_lookup(struct in6_addr *daddr, u32 spi, u8 proto) +{ + unsigned h = ntohl(daddr->s6_addr32[2]^daddr->s6_addr32[3]^spi^proto); + struct xfrm_state *x; + + h = (h ^ (h>>10) ^ (h>>20)) % XFRM_DST_HSIZE; + + spin_lock_bh(&xfrm_state_lock); + list_for_each_entry(x, xfrm_state_byspi+h, byspi) { + if (x->props.family == AF_INET6 && + spi == x->id.spi && + !ipv6_addr_cmp(daddr, (struct in6_addr *)x->id.daddr.a6) && + proto == x->id.proto) { + atomic_inc(&x->refcnt); + spin_unlock_bh(&xfrm_state_lock); + return x; + } + } + spin_unlock_bh(&xfrm_state_lock); + return NULL; +} +#endif + struct xfrm_state * xfrm_find_acq(u8 mode, u16 reqid, u8 proto, u32 daddr, u32 saddr, int create) { @@ -445,7 +598,59 @@ x0->km.state = XFRM_STATE_ACQ; x0->id.daddr.xfrm4_addr = daddr; x0->id.proto = proto; + x0->props.mode = mode; + x0->props.reqid = reqid; x0->props.family = AF_INET; + x0->lft.hard_add_expires_seconds = ACQ_EXPIRES; + atomic_inc(&x0->refcnt); + mod_timer(&x0->timer, jiffies + ACQ_EXPIRES*HZ); + atomic_inc(&x0->refcnt); + list_add_tail(&x0->bydst, xfrm_state_bydst+h); + wake_up(&km_waitq); + } + spin_unlock_bh(&xfrm_state_lock); + return x0; +} + +#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) +struct xfrm_state * +xfrm6_find_acq(u8 mode, u16 reqid, u8 proto, struct in6_addr *daddr, struct in6_addr *saddr, int create) +{ + struct xfrm_state *x, *x0; + unsigned h = ntohl(daddr->s6_addr32[2]^daddr->s6_addr32[3]); + + h = (h ^ (h>>16)) % XFRM_DST_HSIZE; + x0 = NULL; + + spin_lock_bh(&xfrm_state_lock); + list_for_each_entry(x, xfrm_state_bydst+h, bydst) { + if (x->props.family == AF_INET6 && + !ipv6_addr_cmp(daddr, (struct in6_addr *)x->id.daddr.a6) && + mode == x->props.mode && + proto == x->id.proto && + !ipv6_addr_cmp(saddr, (struct in6_addr *)x->props.saddr.a6) && + reqid == x->props.reqid && + x->km.state == XFRM_STATE_ACQ) { + if (!x0) + x0 = x; + if (x->id.spi) + continue; + x0 = x; + break; + } + } + if (x0) { + atomic_inc(&x0->refcnt); + } else if (create && (x0 = xfrm_state_alloc()) != NULL) { + memcpy(x0->sel.daddr.a6, daddr, sizeof(struct in6_addr)); + memcpy(x0->sel.saddr.a6, saddr, sizeof(struct in6_addr)); + x0->sel.prefixlen_d = 128; + x0->sel.prefixlen_s = 128; + memcpy(x0->props.saddr.a6, saddr, sizeof(struct in6_addr)); + x0->km.state = XFRM_STATE_ACQ; + memcpy(x0->id.daddr.a6, daddr, sizeof(struct in6_addr)); + x0->id.proto = proto; + x0->props.family = AF_INET6; x0->props.mode = mode; x0->props.reqid = reqid; x0->lft.hard_add_expires_seconds = ACQ_EXPIRES; @@ -458,6 +663,7 @@ spin_unlock_bh(&xfrm_state_lock); return x0; } +#endif /* Silly enough, but I'm lazy to build resolution list */ @@ -491,7 +697,18 @@ return; if (minspi == maxspi) { - x0 = xfrm_state_lookup(x->id.daddr.xfrm4_addr, minspi, x->id.proto); + switch(x->props.family) { + case AF_INET: + x0 = xfrm4_state_lookup(x->id.daddr.xfrm4_addr, minspi, x->id.proto); + break; +#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) + case AF_INET6: + x0 = xfrm6_state_lookup((struct in6_addr*)x->id.daddr.a6, minspi, x->id.proto); + break; +#endif + default: + x0 = NULL; + } if (x0) { xfrm_state_put(x0); return; @@ -503,7 +720,18 @@ maxspi = ntohl(maxspi); for (h=0; hid.daddr.xfrm4_addr, htonl(spi), x->id.proto); + switch(x->props.family) { + case AF_INET: + x0 = xfrm4_state_lookup(x->id.daddr.xfrm4_addr, minspi, x->id.proto); + break; +#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) + case AF_INET6: + x0 = xfrm6_state_lookup((struct in6_addr*)x->id.daddr.a6, minspi, x->id.proto); + break; +#endif + default: + x0 = NULL; + } if (x0 == NULL) break; xfrm_state_put(x0); @@ -512,7 +740,18 @@ } if (x->id.spi) { spin_lock_bh(&xfrm_state_lock); - h = ntohl(x->id.daddr.xfrm4_addr^x->id.spi^x->id.proto); + switch(x->props.family) { + case AF_INET: + h = ntohl(x->id.daddr.xfrm4_addr^x->id.spi^x->id.proto); + break; +#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) + case AF_INET6: + h = ntohl(x->id.daddr.a6[2]^x->id.daddr.a6[3]^x->id.spi^x->id.proto); + break; +#endif + default: + h = 0; /* XXX */ + } h = (h ^ (h>>10) ^ (h>>20)) % XFRM_DST_HSIZE; list_add(&x->byspi, xfrm_state_byspi+h); atomic_inc(&x->refcnt); @@ -605,14 +844,21 @@ int i; for (i=0; iprops.family == AF_INET && - !xfrm4_selector_match(&x[i]->sel, fl)) - return -EINVAL; + int match; + switch(x[i]->props.family) { + case AF_INET: + match = xfrm4_selector_match(&x[i]->sel, fl); + break; #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) - if (x[i]->props.family == AF_INET6 && - !xfrm6_selector_match(&x[i]->sel, fl)) - return -EINVAL; + case AF_INET6: + match = xfrm6_selector_match(&x[i]->sel, fl); + break; #endif + default: + match = 0; + } + if (!match) + return -EINVAL; } return 0; } @@ -680,7 +926,7 @@ err = -EINVAL; read_lock(&xfrm_km_lock); list_for_each_entry(km, &xfrm_km_list, list) { - pol = km->compile_policy(optname, data, optlen, &err); + pol = km->compile_policy(sk->family, optname, data, optlen, &err); if (err >= 0) break; } @@ -722,118 +968,3 @@ } } -#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) -struct xfrm_state * -xfrm6_state_lookup(struct in6_addr *daddr, u32 spi, u8 proto) -{ - unsigned h = ntohl(daddr->s6_addr32[2]^daddr->s6_addr32[3]^spi^proto); - struct xfrm_state *x; - - h = (h ^ (h>>10) ^ (h>>20)) % XFRM_DST_HSIZE; - - spin_lock_bh(&xfrm_state_lock); - list_for_each_entry(x, xfrm_state_byspi+h, byspi) { - if (x->props.family == AF_INET6 && - spi == x->id.spi && - !ipv6_addr_cmp(daddr, (struct in6_addr *)x->id.daddr.a6) && - proto == x->id.proto) { - atomic_inc(&x->refcnt); - spin_unlock_bh(&xfrm_state_lock); - return x; - } - } - spin_unlock_bh(&xfrm_state_lock); - return NULL; -} - -struct xfrm_state * -xfrm6_find_acq(u8 mode, u16 reqid, u8 proto, struct in6_addr *daddr, struct in6_addr *saddr, int create) -{ - struct xfrm_state *x, *x0; - unsigned h = ntohl(daddr->s6_addr32[2]^daddr->s6_addr32[3]); - - h = (h ^ (h>>16)) % XFRM_DST_HSIZE; - x0 = NULL; - - spin_lock_bh(&xfrm_state_lock); - list_for_each_entry(x, xfrm_state_bydst+h, bydst) { - if (x->props.family == AF_INET6 && - !memcmp(daddr, x->id.daddr.a6, sizeof(struct in6_addr)) && - mode == x->props.mode && - proto == x->id.proto && - !memcmp(saddr, x->props.saddr.a6, sizeof(struct in6_addr)) && - reqid == x->props.reqid && - x->km.state == XFRM_STATE_ACQ) { - if (!x0) - x0 = x; - if (x->id.spi) - continue; - x0 = x; - break; - } - } - if (x0) { - atomic_inc(&x0->refcnt); - } else if (create && (x0 = xfrm_state_alloc()) != NULL) { - memcpy(x0->sel.daddr.a6, daddr, sizeof(struct in6_addr)); - memcpy(x0->sel.saddr.a6, saddr, sizeof(struct in6_addr)); - x0->sel.prefixlen_d = 128; - x0->sel.prefixlen_s = 128; - memcpy(x0->props.saddr.a6, saddr, sizeof(struct in6_addr)); - x0->km.state = XFRM_STATE_ACQ; - memcpy(x0->id.daddr.a6, daddr, sizeof(struct in6_addr)); - x0->id.proto = proto; - x0->props.family = AF_INET6; - x0->props.mode = mode; - x0->props.reqid = reqid; - x0->lft.hard_add_expires_seconds = ACQ_EXPIRES; - atomic_inc(&x0->refcnt); - mod_timer(&x0->timer, jiffies + ACQ_EXPIRES*HZ); - atomic_inc(&x0->refcnt); - list_add_tail(&x0->bydst, xfrm_state_bydst+h); - wake_up(&km_waitq); - } - spin_unlock_bh(&xfrm_state_lock); - return x0; -} - -void -xfrm6_alloc_spi(struct xfrm_state *x, u32 minspi, u32 maxspi) -{ - u32 h; - struct xfrm_state *x0; - - if (x->id.spi) - return; - - if (minspi == maxspi) { - x0 = xfrm6_state_lookup((struct in6_addr*)x->id.daddr.a6, minspi, x->id.proto); - if (x0) { - xfrm_state_put(x0); - return; - } - x->id.spi = minspi; - } else { - u32 spi = 0; - minspi = ntohl(minspi); - maxspi = ntohl(maxspi); - for (h=0; hid.daddr.a6, htonl(spi), x->id.proto); - if (x0 == NULL) - break; - xfrm_state_put(x0); - } - x->id.spi = htonl(spi); - } - if (x->id.spi) { - spin_lock_bh(&xfrm_state_lock); - h = ntohl(x->id.daddr.a6[2]^x->id.daddr.a6[3]^x->id.spi^x->id.proto); - h = (h ^ (h>>10) ^ (h>>20)) % XFRM_DST_HSIZE; - list_add(&x->byspi, xfrm_state_byspi+h); - atomic_inc(&x->refcnt); - spin_unlock_bh(&xfrm_state_lock); - wake_up(&km_waitq); - } -} -#endif /* CONFIG_IPV6 || CONFIG_IPV6_MODULE */ diff -Nru a/net/ipv4/xfrm_user.c b/net/ipv4/xfrm_user.c --- a/net/ipv4/xfrm_user.c Wed Feb 19 14:02:51 2003 +++ b/net/ipv4/xfrm_user.c Wed Mar 5 15:45:36 2003 @@ -234,8 +234,8 @@ switch (x->props.family) { case AF_INET: - x1 = xfrm_state_lookup(x->props.saddr.xfrm4_addr, - x->id.spi, x->id.proto); + x1 = xfrm4_state_lookup(x->props.saddr.xfrm4_addr, + x->id.spi, x->id.proto); break; #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) case AF_INET6: @@ -265,7 +265,7 @@ switch (p->family) { case AF_INET: - x = xfrm_state_lookup(p->saddr.xfrm4_addr, p->spi, p->proto); + x = xfrm4_state_lookup(p->saddr.xfrm4_addr, p->spi, p->proto); break; #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) case AF_INET6: @@ -395,7 +395,7 @@ switch (p->family) { case AF_INET: - x = xfrm_state_lookup(p->saddr.xfrm4_addr, p->spi, p->proto); + x = xfrm4_state_lookup(p->saddr.xfrm4_addr, p->spi, p->proto); break; #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) case AF_INET6: @@ -538,6 +538,21 @@ return -EINVAL; }; + switch (p->family) { + case AF_INET: + break; + + case AF_INET6: +#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) + break; +#else + return -EAFNOSUPPORT; +#endif + + default: + return -EINVAL; + }; + return verify_policy_dir(p->dir); } @@ -1057,7 +1072,8 @@ /* User gives us xfrm_user_policy_info followed by an array of 0 * or more templates. */ -struct xfrm_policy *xfrm_compile_policy(int opt, u8 *data, int len, int *dir) +struct xfrm_policy *xfrm_compile_policy(u16 family, int opt, + u8 *data, int len, int *dir) { struct xfrm_userpolicy_info *p = (struct xfrm_userpolicy_info *)data; struct xfrm_user_tmpl *ut = (struct xfrm_user_tmpl *) (p + 1); diff -Nru a/net/ipv6/Kconfig b/net/ipv6/Kconfig --- a/net/ipv6/Kconfig Sun Feb 23 22:46:32 2003 +++ b/net/ipv6/Kconfig Wed Mar 5 15:45:36 2003 @@ -17,5 +17,20 @@ See for details. -source "net/ipv6/netfilter/Kconfig" +config INET6_AH + tristate "IPv6: AH transformation" + depends on IPV6 + ---help--- + Support for IPsec AH. + + If unsure, say Y. + +config INET6_ESP + tristate "IPv6: ESP transformation" + depends on IPV6 + ---help--- + Support for IPsec ESP. + If unsure, say Y. + +source "net/ipv6/netfilter/Kconfig" diff -Nru a/net/ipv6/Makefile b/net/ipv6/Makefile --- a/net/ipv6/Makefile Wed Feb 19 14:32:20 2003 +++ b/net/ipv6/Makefile Wed Mar 5 15:45:36 2003 @@ -10,4 +10,6 @@ exthdrs.o sysctl_net_ipv6.o datagram.o proc.o \ ip6_flowlabel.o ipv6_syms.o +obj-$(CONFIG_INET6_AH) += ah6.o +obj-$(CONFIG_INET6_ESP) += esp6.o obj-$(CONFIG_NETFILTER) += netfilter/ diff -Nru a/net/ipv6/ah6.c b/net/ipv6/ah6.c --- /dev/null Wed Dec 31 16:00:00 1969 +++ b/net/ipv6/ah6.c Thu Mar 6 16:16:15 2003 @@ -0,0 +1,362 @@ +/* + * Copyright (C)2002 USAGI/WIDE Project + * + * 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. + * + * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Authors + * + * Mitsuru KANDA @USAGI : IPv6 Support + * Kazunori MIYAZAWA @USAGI : + * Kunihiro Ishiguro : + * + * This file is derived from net/ipv4/ah.c. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define AH_HLEN_NOICV 12 + +/* XXX no ipv6 ah specific */ +#define NIP6(addr) \ + ntohs((addr).s6_addr16[0]),\ + ntohs((addr).s6_addr16[1]),\ + ntohs((addr).s6_addr16[2]),\ + ntohs((addr).s6_addr16[3]),\ + ntohs((addr).s6_addr16[4]),\ + ntohs((addr).s6_addr16[5]),\ + ntohs((addr).s6_addr16[6]),\ + ntohs((addr).s6_addr16[7]) + +int ah6_output(struct sk_buff *skb) +{ + int err; + int hdr_len = sizeof(struct ipv6hdr); + struct dst_entry *dst = skb->dst; + struct xfrm_state *x = dst->xfrm; + struct ipv6hdr *iph = NULL; + struct ip_auth_hdr *ah; + struct ah_data *ahp; + u16 nh_offset = 0; + u8 nexthdr; +printk(KERN_DEBUG "%s\n", __FUNCTION__); + if (skb->ip_summed == CHECKSUM_HW && skb_checksum_help(skb) == NULL) + return -EINVAL; + + spin_lock_bh(&x->lock); + if ((err = xfrm_state_check_expire(x)) != 0) + goto error; + if ((err = xfrm_state_check_space(x, skb)) != 0) + goto error; + + if (x->props.mode) { + iph = skb->nh.ipv6h; + skb->nh.ipv6h = (struct ipv6hdr*)skb_push(skb, x->props.header_len); + skb->nh.ipv6h->version = 6; + skb->nh.ipv6h->payload_len = htons(skb->len - sizeof(struct ipv6hdr)); + skb->nh.ipv6h->nexthdr = IPPROTO_AH; + memcpy(&skb->nh.ipv6h->saddr, &x->props.saddr, sizeof(struct in6_addr)); + memcpy(&skb->nh.ipv6h->daddr, &x->id.daddr, sizeof(struct in6_addr)); + ah = (struct ip_auth_hdr*)(skb->nh.ipv6h+1); + ah->nexthdr = IPPROTO_IPV6; + } else { + hdr_len = skb->h.raw - skb->nh.raw; + iph = kmalloc(hdr_len, GFP_ATOMIC); + if (!iph) { + err = -ENOMEM; + goto error; + } + memcpy(iph, skb->data, hdr_len); + skb->nh.ipv6h = (struct ipv6hdr*)skb_push(skb, x->props.header_len); + memcpy(skb->nh.ipv6h, iph, hdr_len); + nexthdr = xfrm6_clear_mutable_options(skb, &nh_offset, XFRM_POLICY_OUT); + if (nexthdr == 0) + goto error; + + skb->nh.raw[nh_offset] = IPPROTO_AH; + skb->nh.ipv6h->payload_len = htons(skb->len - sizeof(struct ipv6hdr)); + ah = (struct ip_auth_hdr*)(skb->nh.raw+hdr_len); + skb->h.raw = (unsigned char*) ah; + ah->nexthdr = nexthdr; + } + + skb->nh.ipv6h->priority = 0; + skb->nh.ipv6h->flow_lbl[0] = 0; + skb->nh.ipv6h->flow_lbl[1] = 0; + skb->nh.ipv6h->flow_lbl[2] = 0; + skb->nh.ipv6h->hop_limit = 0; + + ahp = x->data; + ah->hdrlen = (XFRM_ALIGN8(ahp->icv_trunc_len + + AH_HLEN_NOICV) >> 2) - 2; + + ah->reserved = 0; + ah->spi = x->id.spi; + ah->seq_no = htonl(++x->replay.oseq); + ahp->icv(ahp, skb, ah->auth_data); + + if (x->props.mode) { + skb->nh.ipv6h->hop_limit = iph->hop_limit; + skb->nh.ipv6h->priority = iph->priority; + skb->nh.ipv6h->flow_lbl[0] = iph->flow_lbl[0]; + skb->nh.ipv6h->flow_lbl[1] = iph->flow_lbl[1]; + skb->nh.ipv6h->flow_lbl[2] = iph->flow_lbl[2]; + } else { + memcpy(skb->nh.ipv6h, iph, hdr_len); + skb->nh.raw[nh_offset] = IPPROTO_AH; + skb->nh.ipv6h->payload_len = htons(skb->len - sizeof(struct ipv6hdr)); + kfree (iph); + } + + skb->nh.raw = skb->data; + + x->curlft.bytes += skb->len; + x->curlft.packets++; + spin_unlock_bh(&x->lock); + if ((skb->dst = dst_pop(dst)) == NULL) + goto error_nolock; + return NET_XMIT_BYPASS; +error: + spin_unlock_bh(&x->lock); +error_nolock: + kfree_skb(skb); + return err; +} + +int ah6_input(struct xfrm_state *x, struct sk_buff *skb) +{ + int ah_hlen; + struct ipv6hdr *iph; + struct ipv6_auth_hdr *ah; + struct ah_data *ahp; + unsigned char *tmp_hdr = NULL; + int hdr_len = skb->h.raw - skb->nh.raw; + u8 nexthdr = 0; + + if (!pskb_may_pull(skb, sizeof(struct ip_auth_hdr))) + goto out; + + ah = (struct ipv6_auth_hdr*)skb->data; + ahp = x->data; + ah_hlen = (ah->hdrlen + 2) << 2; + + if (ah_hlen != XFRM_ALIGN8(ahp->icv_full_len + AH_HLEN_NOICV) && + ah_hlen != XFRM_ALIGN8(ahp->icv_trunc_len + AH_HLEN_NOICV)) + goto out; + + if (!pskb_may_pull(skb, ah_hlen)) + goto out; + + /* We are going to _remove_ AH header to keep sockets happy, + * so... Later this can change. */ + if (skb_cloned(skb) && + pskb_expand_head(skb, 0, 0, GFP_ATOMIC)) + goto out; + + tmp_hdr = kmalloc(hdr_len, GFP_ATOMIC); + if (!tmp_hdr) + goto out; + memcpy(tmp_hdr, skb->nh.raw, hdr_len); + ah = (struct ipv6_auth_hdr*)skb->data; + iph = skb->nh.ipv6h; + + { + u8 auth_data[ahp->icv_trunc_len]; + + memcpy(auth_data, ah->auth_data, ahp->icv_trunc_len); + skb_push(skb, skb->data - skb->nh.raw); + ahp->icv(ahp, skb, ah->auth_data); + if (memcmp(ah->auth_data, auth_data, ahp->icv_trunc_len)) { + if (net_ratelimit()) + printk(KERN_WARNING "ipsec ah authentication error\n"); + x->stats.integrity_failed++; + goto free_out; + } + } + + nexthdr = ah->nexthdr; + skb->nh.raw = skb_pull(skb, (ah->hdrlen+2)<<2); + memcpy(skb->nh.raw, tmp_hdr, hdr_len); + skb->nh.ipv6h->payload_len = htons(skb->len - sizeof(struct ipv6hdr)); + skb_pull(skb, hdr_len); + skb->h.raw = skb->data; + + + kfree(tmp_hdr); + + return nexthdr; + +free_out: + kfree(tmp_hdr); +out: + return -EINVAL; +} + +void ah6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, + int type, int code, int offset, __u32 info) +{ + struct ipv6hdr *iph = (struct ipv6hdr*)skb->data; + struct ip_auth_hdr *ah = (struct ip_auth_hdr*)(skb->data+offset); + struct xfrm_state *x; + + if (type != ICMPV6_DEST_UNREACH || + type != ICMPV6_PKT_TOOBIG) + return; + + x = xfrm6_state_lookup(&iph->daddr, ah->spi, IPPROTO_AH); + if (!x) + return; + + printk(KERN_DEBUG "pmtu discvovery on SA AH/%08x/" + "%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n", + ntohl(ah->spi), NIP6(iph->daddr)); + + xfrm_state_put(x); +} + +static int ah6_init_state(struct xfrm_state *x, void *args) +{ + struct ah_data *ahp = NULL; + struct xfrm_algo_desc *aalg_desc; + + /* null auth can use a zero length key */ + if (x->aalg->alg_key_len > 512) + goto error; + + ahp = kmalloc(sizeof(*ahp), GFP_KERNEL); + if (ahp == NULL) + return -ENOMEM; + + memset(ahp, 0, sizeof(*ahp)); + + ahp->key = x->aalg->alg_key; + ahp->key_len = (x->aalg->alg_key_len+7)/8; + ahp->tfm = crypto_alloc_tfm(x->aalg->alg_name, 0); + if (!ahp->tfm) + goto error; + ahp->icv = ah_hmac_digest; + + /* + * Lookup the algorithm description maintained by xfrm_algo, + * verify crypto transform properties, and store information + * we need for AH processing. This lookup cannot fail here + * after a successful crypto_alloc_tfm(). + */ + aalg_desc = xfrm_aalg_get_byname(x->aalg->alg_name); + BUG_ON(!aalg_desc); + + if (aalg_desc->uinfo.auth.icv_fullbits/8 != + crypto_tfm_alg_digestsize(ahp->tfm)) { + printk(KERN_INFO "AH: %s digestsize %u != %hu\n", + x->aalg->alg_name, crypto_tfm_alg_digestsize(ahp->tfm), + aalg_desc->uinfo.auth.icv_fullbits/8); + goto error; + } + + ahp->icv_full_len = aalg_desc->uinfo.auth.icv_fullbits/8; + ahp->icv_trunc_len = aalg_desc->uinfo.auth.icv_truncbits/8; + + ahp->work_icv = kmalloc(ahp->icv_full_len, GFP_KERNEL); + if (!ahp->work_icv) + goto error; + + x->props.header_len = XFRM_ALIGN8(ahp->icv_trunc_len + AH_HLEN_NOICV); + if (x->props.mode) + x->props.header_len += 20; + x->data = ahp; + + return 0; + +error: + if (ahp) { + if (ahp->work_icv) + kfree(ahp->work_icv); + if (ahp->tfm) + crypto_free_tfm(ahp->tfm); + kfree(ahp); + } + return -EINVAL; +} + +static void ah6_destroy(struct xfrm_state *x) +{ + struct ah_data *ahp = x->data; + + if (ahp->work_icv) { + kfree(ahp->work_icv); + ahp->work_icv = NULL; + } + if (ahp->tfm) { + crypto_free_tfm(ahp->tfm); + ahp->tfm = NULL; + } +} + +static struct xfrm_type ah6_type = +{ + .description = "AH6", + .proto = IPPROTO_AH, + .init_state = ah6_init_state, + .destructor = ah6_destroy, + .input = ah6_input, + .output = ah6_output +}; + +static struct inet6_protocol ah6_protocol = { + .handler = xfrm6_rcv, + .err_handler = ah6_err, +}; + +int __init ah6_init(void) +{ + SET_MODULE_OWNER(&ah6_type); + + if (xfrm6_register_type(&ah6_type) < 0) { + printk(KERN_INFO "ipv6 ah init: can't add xfrm type\n"); + return -EAGAIN; + } + + if (inet6_add_protocol(&ah6_protocol, IPPROTO_AH) < 0) { + printk(KERN_INFO "ipv6 ah init: can't add protocol\n"); + xfrm6_unregister_type(&ah6_type); + return -EAGAIN; + } + + return 0; +} + +static void __exit ah6_fini(void) +{ + if (inet6_del_protocol(&ah6_protocol, IPPROTO_AH) < 0) + printk(KERN_INFO "ipv6 ah close: can't remove protocol\n"); + + if (xfrm6_unregister_type(&ah6_type) < 0) + printk(KERN_INFO "ipv6 ah close: can't remove xfrm type\n"); + +} + +module_init(ah6_init); +module_exit(ah6_fini); + +MODULE_LICENSE("GPL"); diff -Nru a/net/ipv6/esp6.c b/net/ipv6/esp6.c --- /dev/null Wed Dec 31 16:00:00 1969 +++ b/net/ipv6/esp6.c Thu Mar 6 16:16:15 2003 @@ -0,0 +1,527 @@ +/* + * Copyright (C)2002 USAGI/WIDE Project + * + * 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. + * + * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Authors + * + * Mitsuru KANDA @USAGI : IPv6 Support + * Kazunori MIYAZAWA @USAGI : + * Kunihiro Ishiguro : + * + * This file is derived from net/ipv4/esp.c + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define MAX_SG_ONSTACK 4 + +/* BUGS: + * - we assume replay seqno is always present. + */ + +/* Move to common area: it is shared with AH. */ +/* Common with AH after some work on arguments. */ + +/* XXX no ipv6 esp specific */ +#define NIP6(addr) \ + ntohs((addr).s6_addr16[0]),\ + ntohs((addr).s6_addr16[1]),\ + ntohs((addr).s6_addr16[2]),\ + ntohs((addr).s6_addr16[3]),\ + ntohs((addr).s6_addr16[4]),\ + ntohs((addr).s6_addr16[5]),\ + ntohs((addr).s6_addr16[6]),\ + ntohs((addr).s6_addr16[7]) + +static int get_offset(u8 *packet, u32 packet_len, u8 *nexthdr, struct ipv6_opt_hdr **prevhdr) +{ + u16 offset = sizeof(struct ipv6hdr); + struct ipv6_opt_hdr *exthdr = (struct ipv6_opt_hdr*)(packet + offset); + u8 nextnexthdr; + + *nexthdr = ((struct ipv6hdr*)packet)->nexthdr; + + while (offset + 1 < packet_len) { + + switch (*nexthdr) { + + case NEXTHDR_HOP: + case NEXTHDR_ROUTING: + offset += ipv6_optlen(exthdr); + *nexthdr = exthdr->nexthdr; + *prevhdr = exthdr; + exthdr = (struct ipv6_opt_hdr*)(packet + offset); + break; + + case NEXTHDR_DEST: + nextnexthdr = + ((struct ipv6_opt_hdr*)(packet + offset + ipv6_optlen(exthdr)))->nexthdr; + /* XXX We know the option is inner dest opt + with next next header check. */ + if (nextnexthdr != NEXTHDR_HOP && + nextnexthdr != NEXTHDR_ROUTING && + nextnexthdr != NEXTHDR_DEST) { + return offset; + } + offset += ipv6_optlen(exthdr); + *nexthdr = exthdr->nexthdr; + *prevhdr = exthdr; + exthdr = (struct ipv6_opt_hdr*)(packet + offset); + break; + + default : + return offset; + } + } + + return offset; +} + +int esp6_output(struct sk_buff *skb) +{ + int err; + int hdr_len = 0; + struct dst_entry *dst = skb->dst; + struct xfrm_state *x = dst->xfrm; + struct ipv6hdr *iph = NULL, *top_iph; + struct ip_esp_hdr *esph; + struct crypto_tfm *tfm; + struct esp_data *esp; + struct sk_buff *trailer; + struct ipv6_opt_hdr *prevhdr = NULL; + int blksize; + int clen; + int alen; + int nfrags; + u8 nexthdr; +printk(KERN_DEBUG "%s\n", __FUNCTION__); + /* First, if the skb is not checksummed, complete checksum. */ + if (skb->ip_summed == CHECKSUM_HW && skb_checksum_help(skb) == NULL) + return -EINVAL; + + spin_lock_bh(&x->lock); + if ((err = xfrm_state_check_expire(x)) != 0) + goto error; + if ((err = xfrm_state_check_space(x, skb)) != 0) + goto error; + + err = -ENOMEM; + + /* Strip IP header in transport mode. Save it. */ + + if (!x->props.mode) { + hdr_len = get_offset(skb->nh.raw, skb->len, &nexthdr, &prevhdr); + iph = kmalloc(hdr_len, GFP_ATOMIC); + if (!iph) { + err = -ENOMEM; + goto error; + } + memcpy(iph, skb->nh.raw, hdr_len); + __skb_pull(skb, hdr_len); + } + + /* Now skb is pure payload to encrypt */ + + /* Round to block size */ + clen = skb->len; + + esp = x->data; + alen = esp->auth.icv_trunc_len; + tfm = esp->conf.tfm; + blksize = crypto_tfm_alg_blocksize(tfm); + clen = (clen + 2 + blksize-1)&~(blksize-1); + if (esp->conf.padlen) + clen = (clen + esp->conf.padlen-1)&~(esp->conf.padlen-1); + + if ((nfrags = skb_cow_data(skb, clen-skb->len+alen, &trailer)) < 0) { + if (!x->props.mode && iph) kfree(iph); + goto error; + } + + /* Fill padding... */ + do { + int i; + for (i=0; ilen - 2; i++) + *(u8*)(trailer->tail + i) = i+1; + } while (0); + *(u8*)(trailer->tail + clen-skb->len - 2) = (clen - skb->len)-2; + pskb_put(skb, trailer, clen - skb->len); + + if (x->props.mode) { + iph = skb->nh.ipv6h; + top_iph = (struct ipv6hdr*)skb_push(skb, x->props.header_len); + esph = (struct ip_esp_hdr*)(top_iph+1); + *(u8*)(trailer->tail - 1) = IPPROTO_IPV6; + top_iph->version = 6; + top_iph->priority = iph->priority; + top_iph->flow_lbl[0] = iph->flow_lbl[0]; + top_iph->flow_lbl[1] = iph->flow_lbl[1]; + top_iph->flow_lbl[2] = iph->flow_lbl[2]; + top_iph->nexthdr = IPPROTO_ESP; + top_iph->payload_len = htons(skb->len + alen); + top_iph->hop_limit = iph->hop_limit; + memcpy(&top_iph->saddr, (struct in6_addr *)&x->props.saddr, sizeof(struct ipv6hdr)); + memcpy(&top_iph->daddr, (struct in6_addr *)&x->id.daddr, sizeof(struct ipv6hdr)); + } else { + /* XXX exthdr */ + esph = (struct ip_esp_hdr*)skb_push(skb, x->props.header_len); + skb->h.raw = (unsigned char*)esph; + top_iph = (struct ipv6hdr*)skb_push(skb, hdr_len); + memcpy(top_iph, iph, hdr_len); + kfree(iph); + top_iph->payload_len = htons(skb->len + alen - sizeof(struct ipv6hdr)); + if (prevhdr) { + prevhdr->nexthdr = IPPROTO_ESP; + } else { + top_iph->nexthdr = IPPROTO_ESP; + } + *(u8*)(trailer->tail - 1) = nexthdr; + } + + esph->spi = x->id.spi; + esph->seq_no = htonl(++x->replay.oseq); + + if (esp->conf.ivlen) + crypto_cipher_set_iv(tfm, esp->conf.ivec, crypto_tfm_alg_ivsize(tfm)); + + do { + struct scatterlist sgbuf[nfrags>MAX_SG_ONSTACK ? 0 : nfrags]; + struct scatterlist *sg = sgbuf; + + if (unlikely(nfrags > MAX_SG_ONSTACK)) { + sg = kmalloc(sizeof(struct scatterlist)*nfrags, GFP_ATOMIC); + if (!sg) + goto error; + } + skb_to_sgvec(skb, sg, esph->enc_data+esp->conf.ivlen-skb->data, clen); + crypto_cipher_encrypt(tfm, sg, sg, clen); + if (unlikely(sg != sgbuf)) + kfree(sg); + } while (0); + + if (esp->conf.ivlen) { + memcpy(esph->enc_data, esp->conf.ivec, crypto_tfm_alg_ivsize(tfm)); + crypto_cipher_get_iv(tfm, esp->conf.ivec, crypto_tfm_alg_ivsize(tfm)); + } + + if (esp->auth.icv_full_len) { + esp->auth.icv(esp, skb, (u8*)esph-skb->data, + 8+esp->conf.ivlen+clen, trailer->tail); + pskb_put(skb, trailer, alen); + } + + skb->nh.raw = skb->data; + + x->curlft.bytes += skb->len; + x->curlft.packets++; + spin_unlock_bh(&x->lock); + if ((skb->dst = dst_pop(dst)) == NULL) + goto error_nolock; + return NET_XMIT_BYPASS; + +error: + spin_unlock_bh(&x->lock); +error_nolock: + kfree_skb(skb); + return err; +} + +int esp6_input(struct xfrm_state *x, struct sk_buff *skb) +{ + struct ipv6hdr *iph; + struct ip_esp_hdr *esph; + struct esp_data *esp = x->data; + struct sk_buff *trailer; + int blksize = crypto_tfm_alg_blocksize(esp->conf.tfm); + int alen = esp->auth.icv_trunc_len; + int elen = skb->len - 8 - esp->conf.ivlen - alen; + + int hdr_len = skb->h.raw - skb->nh.raw; + int nfrags; + u8 ret_nexthdr = 0; + unsigned char *tmp_hdr = NULL; + + if (!pskb_may_pull(skb, sizeof(struct ip_esp_hdr))) + goto out; + + if (elen <= 0 || (elen & (blksize-1))) + goto out; + + tmp_hdr = kmalloc(hdr_len, GFP_ATOMIC); + if (!tmp_hdr) + goto out; + memcpy(tmp_hdr, skb->nh.raw, hdr_len); + + /* If integrity check is required, do this. */ + if (esp->auth.icv_full_len) { + u8 sum[esp->auth.icv_full_len]; + u8 sum1[alen]; + + esp->auth.icv(esp, skb, 0, skb->len-alen, sum); + + if (skb_copy_bits(skb, skb->len-alen, sum1, alen)) + BUG(); + + if (unlikely(memcmp(sum, sum1, alen))) { + x->stats.integrity_failed++; + goto out; + } + } + + if ((nfrags = skb_cow_data(skb, 0, &trailer)) < 0) + goto out; + + skb->ip_summed = CHECKSUM_NONE; + + esph = (struct ip_esp_hdr*)skb->data; + iph = skb->nh.ipv6h; + + /* Get ivec. This can be wrong, check against another impls. */ + if (esp->conf.ivlen) + crypto_cipher_set_iv(esp->conf.tfm, esph->enc_data, crypto_tfm_alg_ivsize(esp->conf.tfm)); + + { + u8 nexthdr[2]; + struct scatterlist sgbuf[nfrags>MAX_SG_ONSTACK ? 0 : nfrags]; + struct scatterlist *sg = sgbuf; + u8 padlen; + + if (unlikely(nfrags > MAX_SG_ONSTACK)) { + sg = kmalloc(sizeof(struct scatterlist)*nfrags, GFP_ATOMIC); + if (!sg) + goto out; + } + skb_to_sgvec(skb, sg, 8+esp->conf.ivlen, elen); + crypto_cipher_decrypt(esp->conf.tfm, sg, sg, elen); + if (unlikely(sg != sgbuf)) + kfree(sg); + + if (skb_copy_bits(skb, skb->len-alen-2, nexthdr, 2)) + BUG(); + + padlen = nexthdr[0]; + if (padlen+2 >= elen) { + if (net_ratelimit()) { + printk(KERN_WARNING "ipsec esp packet is garbage padlen=%d, elen=%d\n", padlen+2, elen); + } + goto out; + } + /* ... check padding bits here. Silly. :-) */ + + ret_nexthdr = nexthdr[1]; + pskb_trim(skb, skb->len - alen - padlen - 2); + skb->h.raw = skb_pull(skb, 8 + esp->conf.ivlen); + skb->nh.raw += 8 + esp->conf.ivlen; + memcpy(skb->nh.raw, tmp_hdr, hdr_len); + } + kfree(tmp_hdr); + return ret_nexthdr; + +out: + return -EINVAL; +} + +static u32 esp6_get_max_size(struct xfrm_state *x, int mtu) +{ + struct esp_data *esp = x->data; + u32 blksize = crypto_tfm_alg_blocksize(esp->conf.tfm); + + if (x->props.mode) { + mtu = (mtu + 2 + blksize-1)&~(blksize-1); + } else { + /* The worst case. */ + mtu += 2 + blksize; + } + if (esp->conf.padlen) + mtu = (mtu + esp->conf.padlen-1)&~(esp->conf.padlen-1); + + return mtu + x->props.header_len + esp->auth.icv_full_len; +} + +void esp6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, + int type, int code, int offset, __u32 info) +{ + struct ipv6hdr *iph = (struct ipv6hdr*)skb->data; + struct ip_esp_hdr *esph = (struct ip_esp_hdr*)(skb->data+offset); + struct xfrm_state *x; + + if (type != ICMPV6_DEST_UNREACH || + type != ICMPV6_PKT_TOOBIG) + return; + + x = xfrm6_state_lookup(&iph->daddr, esph->spi, IPPROTO_ESP); + if (!x) + return; + printk(KERN_DEBUG "pmtu discvovery on SA ESP/%08x/" + "%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n", + ntohl(esph->spi), NIP6(iph->daddr)); + xfrm_state_put(x); +} + +void esp6_destroy(struct xfrm_state *x) +{ + struct esp_data *esp = x->data; + + if (esp->conf.tfm) { + crypto_free_tfm(esp->conf.tfm); + esp->conf.tfm = NULL; + } + if (esp->conf.ivec) { + kfree(esp->conf.ivec); + esp->conf.ivec = NULL; + } + if (esp->auth.tfm) { + crypto_free_tfm(esp->auth.tfm); + esp->auth.tfm = NULL; + } + if (esp->auth.work_icv) { + kfree(esp->auth.work_icv); + esp->auth.work_icv = NULL; + } +} + +int esp6_init_state(struct xfrm_state *x, void *args) +{ + struct esp_data *esp = NULL; + + if (x->aalg) { + if (x->aalg->alg_key_len == 0 || x->aalg->alg_key_len > 512) + goto error; + } + if (x->ealg == NULL || x->ealg->alg_key_len == 0) + goto error; + + esp = kmalloc(sizeof(*esp), GFP_KERNEL); + if (esp == NULL) + return -ENOMEM; + + memset(esp, 0, sizeof(*esp)); + + if (x->aalg) { + struct xfrm_algo_desc *aalg_desc; + + esp->auth.key = x->aalg->alg_key; + esp->auth.key_len = (x->aalg->alg_key_len+7)/8; + esp->auth.tfm = crypto_alloc_tfm(x->aalg->alg_name, 0); + if (esp->auth.tfm == NULL) + goto error; + esp->auth.icv = esp_hmac_digest; + + aalg_desc = xfrm_aalg_get_byname(x->aalg->alg_name); + BUG_ON(!aalg_desc); + + if (aalg_desc->uinfo.auth.icv_fullbits/8 != + crypto_tfm_alg_digestsize(esp->auth.tfm)) { + printk(KERN_INFO "ESP: %s digestsize %u != %hu\n", + x->aalg->alg_name, + crypto_tfm_alg_digestsize(esp->auth.tfm), + aalg_desc->uinfo.auth.icv_fullbits/8); + goto error; + } + + esp->auth.icv_full_len = aalg_desc->uinfo.auth.icv_fullbits/8; + esp->auth.icv_trunc_len = aalg_desc->uinfo.auth.icv_truncbits/8; + + esp->auth.work_icv = kmalloc(esp->auth.icv_full_len, GFP_KERNEL); + if (!esp->auth.work_icv) + goto error; + } + esp->conf.key = x->ealg->alg_key; + esp->conf.key_len = (x->ealg->alg_key_len+7)/8; + esp->conf.tfm = crypto_alloc_tfm(x->ealg->alg_name, CRYPTO_TFM_MODE_CBC); + if (esp->conf.tfm == NULL) + goto error; + esp->conf.ivlen = crypto_tfm_alg_ivsize(esp->conf.tfm); + esp->conf.padlen = 0; + if (esp->conf.ivlen) { + esp->conf.ivec = kmalloc(esp->conf.ivlen, GFP_KERNEL); + get_random_bytes(esp->conf.ivec, esp->conf.ivlen); + } + crypto_cipher_setkey(esp->conf.tfm, esp->conf.key, esp->conf.key_len); + x->props.header_len = 8 + esp->conf.ivlen; + if (x->props.mode) + x->props.header_len += 40; /* XXX ext hdr */ + x->data = esp; + return 0; + +error: + if (esp) { + if (esp->auth.tfm) + crypto_free_tfm(esp->auth.tfm); + if (esp->auth.work_icv) + kfree(esp->auth.work_icv); + if (esp->conf.tfm) + crypto_free_tfm(esp->conf.tfm); + kfree(esp); + } + return -EINVAL; +} + +static struct xfrm_type esp6_type = +{ + .description = "ESP6", + .proto = IPPROTO_ESP, + .init_state = esp6_init_state, + .destructor = esp6_destroy, + .get_max_size = esp6_get_max_size, + .input = esp6_input, + .output = esp6_output +}; + +static struct inet6_protocol esp6_protocol = { + .handler = xfrm6_rcv, + .err_handler = esp6_err, +}; + +int __init esp6_init(void) +{ + SET_MODULE_OWNER(&esp6_type); + if (xfrm6_register_type(&esp6_type) < 0) { + printk(KERN_INFO "ipv6 esp init: can't add xfrm type\n"); + return -EAGAIN; + } + if (inet6_add_protocol(&esp6_protocol, IPPROTO_ESP) < 0) { + printk(KERN_INFO "ipv6 esp init: can't add protocol\n"); + xfrm6_unregister_type(&esp6_type); + return -EAGAIN; + } + + return 0; +} + +static void __exit esp6_fini(void) +{ + if (inet6_del_protocol(&esp6_protocol, IPPROTO_ESP) < 0) + printk(KERN_INFO "ipv6 esp close: can't remove protocol\n"); + if (xfrm6_unregister_type(&esp6_type) < 0) + printk(KERN_INFO "ipv6 esp close: can't remove xfrm type\n"); +} + +module_init(esp6_init); +module_exit(esp6_fini); + +MODULE_LICENSE("GPL"); diff -Nru a/net/ipv6/ip6_input.c b/net/ipv6/ip6_input.c --- a/net/ipv6/ip6_input.c Wed Feb 19 13:55:33 2003 +++ b/net/ipv6/ip6_input.c Wed Mar 5 15:45:36 2003 @@ -150,7 +150,8 @@ It would be stupid to detect for optional headers, which are missing with probability of 200% */ - if (nexthdr != IPPROTO_TCP && nexthdr != IPPROTO_UDP) { + if (nexthdr != IPPROTO_TCP && nexthdr != IPPROTO_UDP && + nexthdr != NEXTHDR_AUTH && nexthdr != NEXTHDR_ESP) { nhoff = ipv6_parse_exthdrs(&skb, nhoff); if (nhoff < 0) return 0; diff -Nru a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c --- a/net/ipv6/ip6_output.c Sun Feb 23 22:41:51 2003 +++ b/net/ipv6/ip6_output.c Wed Mar 5 15:45:36 2003 @@ -192,6 +192,11 @@ int seg_len = skb->len; int hlimit; u32 mtu; + int err = 0; + + if ((err = xfrm_lookup(&skb->dst, fl, sk, 0)) < 0) { + return err; + } if (opt) { int head_room; @@ -550,7 +555,7 @@ || (fl->oif && fl->oif != dst->dev->ifindex)) { dst = NULL; } else - dst_clone(dst); + dst_hold(dst); } if (dst == NULL) @@ -576,6 +581,13 @@ } pktlength = length; + if (dst) { + if ((err = xfrm_lookup(&dst, fl, sk, 0)) < 0) { + dst_release(dst); + return -ENETUNREACH; + } + } + if (hlimit < 0) { if (ipv6_addr_is_multicast(fl->fl6_dst)) hlimit = np->mcast_hops; @@ -630,10 +642,8 @@ err = 0; if (flags&MSG_PROBE) goto out; - - skb = sock_alloc_send_skb(sk, pktlength + 15 + - dev->hard_header_len, - flags & MSG_DONTWAIT, &err); + /* alloc skb with mtu as we do in the IPv4 stack for IPsec */ + skb = sock_alloc_send_skb(sk, mtu, flags & MSG_DONTWAIT, &err); if (skb == NULL) { IP6_INC_STATS(Ip6OutDiscards); @@ -663,6 +673,8 @@ err = getfrag(data, &hdr->saddr, ((char *) hdr) + (pktlength - length), 0, length); + if (!opt || !opt->dst1opt) + skb->h.raw = ((char *) hdr) + (pktlength - length); if (!err) { IP6_INC_STATS(Ip6OutRequests); diff -Nru a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c --- a/net/ipv6/ndisc.c Tue Feb 25 09:45:41 2003 +++ b/net/ipv6/ndisc.c Wed Mar 5 15:45:36 2003 @@ -71,6 +71,7 @@ #include #include +#include #include #include @@ -335,8 +336,6 @@ unsigned char ha[MAX_ADDR_LEN]; unsigned char *h_dest = NULL; - skb_reserve(skb, (dev->hard_header_len + 15) & ~15); - if (dev->hard_header) { if (ipv6_addr_type(daddr) & IPV6_ADDR_MULTICAST) { ndisc_mc_map(daddr, ha, dev, 1); @@ -373,10 +372,50 @@ * Send a Neighbour Advertisement */ +int ndisc_output(struct sk_buff *skb) +{ + if (skb) { + struct neighbour *neigh = (skb->dst ? skb->dst->neighbour : NULL); + if (ndisc_build_ll_hdr(skb, skb->dev, &skb->nh.ipv6h->daddr, neigh, skb->len) == 0) { + kfree_skb(skb); + return -EINVAL; + } + dev_queue_xmit(skb); + return 0; + } + return -EINVAL; +} + +static inline void ndisc_rt_init(struct rt6_info *rt, struct net_device *dev, + struct neighbour *neigh) +{ + rt->rt6i_dev = dev; + rt->rt6i_nexthop = neigh; + rt->rt6i_expires = 0; + rt->rt6i_flags = RTF_LOCAL; + rt->rt6i_metric = 0; + rt->rt6i_hoplimit = 255; + rt->u.dst.output = ndisc_output; +} + +static inline void ndisc_flow_init(struct flowi *fl, u8 type, + struct in6_addr *saddr, struct in6_addr *daddr) +{ + memset(fl, 0, sizeof(*fl)); + fl->fl6_src = saddr; + fl->fl6_dst = daddr; + fl->proto = IPPROTO_ICMPV6; + fl->uli_u.icmpt.type = type; + fl->uli_u.icmpt.code = 0; +} + static void ndisc_send_na(struct net_device *dev, struct neighbour *neigh, struct in6_addr *daddr, struct in6_addr *solicited_addr, - int router, int solicited, int override, int inc_opt) + int router, int solicited, int override, int inc_opt) { + struct flowi fl; + struct rt6_info *rt = NULL; + struct dst_entry* dst; struct sock *sk = ndisc_socket->sk; struct nd_msg *msg; int len; @@ -385,6 +424,22 @@ len = sizeof(struct icmp6hdr) + sizeof(struct in6_addr); + rt = ndisc_get_dummy_rt(); + if (!rt) + return; + + ndisc_flow_init(&fl, NDISC_NEIGHBOUR_ADVERTISEMENT, solicited_addr, daddr); + ndisc_rt_init(rt, dev, neigh); + + dst = (struct dst_entry*)rt; + dst_clone(dst); + + err = xfrm_lookup(&dst, &fl, NULL, 0); + if (err < 0) { + dst_release(dst); + return; + } + if (inc_opt) { if (dev->addr_len) len += NDISC_OPT_SPACE(dev->addr_len); @@ -400,14 +455,10 @@ return; } - if (ndisc_build_ll_hdr(skb, dev, daddr, neigh, len) == 0) { - kfree_skb(skb); - return; - } - + skb_reserve(skb, (dev->hard_header_len + 15) & ~15); ip6_nd_hdr(sk, skb, dev, solicited_addr, daddr, IPPROTO_ICMPV6, len); - msg = (struct nd_msg *) skb_put(skb, len); + skb->h.raw = (unsigned char*) msg = (struct nd_msg *) skb_put(skb, len); msg->icmph.icmp6_type = NDISC_NEIGHBOUR_ADVERTISEMENT; msg->icmph.icmp6_code = 0; @@ -430,7 +481,9 @@ csum_partial((__u8 *) msg, len, 0)); - dev_queue_xmit(skb); + dst_clone(dst); + skb->dst = dst; + dst_output(skb); ICMP6_INC_STATS(Icmp6OutNeighborAdvertisements); ICMP6_INC_STATS(Icmp6OutMsgs); @@ -440,6 +493,9 @@ struct in6_addr *solicit, struct in6_addr *daddr, struct in6_addr *saddr) { + struct flowi fl; + struct rt6_info *rt = NULL; + struct dst_entry* dst; struct sock *sk = ndisc_socket->sk; struct sk_buff *skb; struct nd_msg *msg; @@ -454,6 +510,22 @@ saddr = &addr_buf; } + rt = ndisc_get_dummy_rt(); + if (!rt) + return; + + ndisc_flow_init(&fl, NDISC_NEIGHBOUR_SOLICITATION, saddr, daddr); + ndisc_rt_init(rt, dev, neigh); + + dst = (struct dst_entry*)rt; + dst_clone(dst); + + err = xfrm_lookup(&dst, &fl, NULL, 0); + if (err < 0) { + dst_release(dst); + return; + } + len = sizeof(struct icmp6hdr) + sizeof(struct in6_addr); send_llinfo = dev->addr_len && ipv6_addr_type(saddr) != IPV6_ADDR_ANY; if (send_llinfo) @@ -466,14 +538,10 @@ return; } - if (ndisc_build_ll_hdr(skb, dev, daddr, neigh, len) == 0) { - kfree_skb(skb); - return; - } - + skb_reserve(skb, (dev->hard_header_len + 15) & ~15); ip6_nd_hdr(sk, skb, dev, saddr, daddr, IPPROTO_ICMPV6, len); - msg = (struct nd_msg *)skb_put(skb, len); + skb->h.raw = (unsigned char*) msg = (struct nd_msg *)skb_put(skb, len); msg->icmph.icmp6_type = NDISC_NEIGHBOUR_SOLICITATION; msg->icmph.icmp6_code = 0; msg->icmph.icmp6_cksum = 0; @@ -492,7 +560,9 @@ csum_partial((__u8 *) msg, len, 0)); /* send it! */ - dev_queue_xmit(skb); + dst_clone(dst); + skb->dst = dst; + dst_output(skb); ICMP6_INC_STATS(Icmp6OutNeighborSolicits); ICMP6_INC_STATS(Icmp6OutMsgs); @@ -501,6 +571,9 @@ void ndisc_send_rs(struct net_device *dev, struct in6_addr *saddr, struct in6_addr *daddr) { + struct flowi fl; + struct rt6_info *rt = NULL; + struct dst_entry* dst; struct sock *sk = ndisc_socket->sk; struct sk_buff *skb; struct icmp6hdr *hdr; @@ -508,6 +581,22 @@ int len; int err; + rt = ndisc_get_dummy_rt(); + if (!rt) + return; + + ndisc_flow_init(&fl, NDISC_ROUTER_SOLICITATION, saddr, daddr); + ndisc_rt_init(rt, dev, NULL); + + dst = (struct dst_entry*)rt; + dst_clone(dst); + + err = xfrm_lookup(&dst, &fl, NULL, 0); + if (err < 0) { + dst_release(dst); + return; + } + len = sizeof(struct icmp6hdr); if (dev->addr_len) len += NDISC_OPT_SPACE(dev->addr_len); @@ -519,14 +608,10 @@ return; } - if (ndisc_build_ll_hdr(skb, dev, daddr, NULL, len) == 0) { - kfree_skb(skb); - return; - } - + skb_reserve(skb, (dev->hard_header_len + 15) & ~15); ip6_nd_hdr(sk, skb, dev, saddr, daddr, IPPROTO_ICMPV6, len); - hdr = (struct icmp6hdr *) skb_put(skb, len); + skb->h.raw = (unsigned char*) hdr = (struct icmp6hdr *) skb_put(skb, len); hdr->icmp6_type = NDISC_ROUTER_SOLICITATION; hdr->icmp6_code = 0; hdr->icmp6_cksum = 0; @@ -543,7 +628,9 @@ csum_partial((__u8 *) hdr, len, 0)); /* send it! */ - dev_queue_xmit(skb); + dst_clone(dst); + skb->dst = dst; + dst_output(skb); ICMP6_INC_STATS(Icmp6OutRouterSolicits); ICMP6_INC_STATS(Icmp6OutMsgs); @@ -1125,6 +1212,8 @@ struct in6_addr *addrp; struct net_device *dev; struct rt6_info *rt; + struct dst_entry *dst; + struct flowi fl; u8 *opt; int rd_len; int err; @@ -1136,6 +1225,22 @@ if (rt == NULL) return; + dst = (struct dst_entry*)rt; + + if (ipv6_get_lladdr(dev, &saddr_buf)) { + ND_PRINTK1("redirect: no link_local addr for dev\n"); + return; + } + + ndisc_flow_init(&fl, NDISC_REDIRECT, &saddr_buf, &skb->nh.ipv6h->saddr); + + dst_clone(dst); + err = xfrm_lookup(&dst, &fl, NULL, 0); + if (err) { + dst_release(dst); + return; + } + if (rt->rt6i_flags & RTF_GATEWAY) { ND_PRINTK1("ndisc_send_redirect: not a neighbour\n"); dst_release(&rt->u.dst); @@ -1164,11 +1269,6 @@ rd_len &= ~0x7; len += rd_len; - if (ipv6_get_lladdr(dev, &saddr_buf)) { - ND_PRINTK1("redirect: no link_local addr for dev\n"); - return; - } - buff = sock_alloc_send_skb(sk, MAX_HEADER + len + dev->hard_header_len + 15, 0, &err); if (buff == NULL) { @@ -1178,15 +1278,11 @@ hlen = 0; - if (ndisc_build_ll_hdr(buff, dev, &skb->nh.ipv6h->saddr, NULL, len) == 0) { - kfree_skb(buff); - return; - } - + skb_reserve(skb, (dev->hard_header_len + 15) & ~15); ip6_nd_hdr(sk, buff, dev, &saddr_buf, &skb->nh.ipv6h->saddr, IPPROTO_ICMPV6, len); - icmph = (struct icmp6hdr *) skb_put(buff, len); + skb->h.raw = (unsigned char*) icmph = (struct icmp6hdr *) skb_put(buff, len); memset(icmph, 0, sizeof(struct icmp6hdr)); icmph->icmp6_type = NDISC_REDIRECT; @@ -1224,7 +1320,8 @@ len, IPPROTO_ICMPV6, csum_partial((u8 *) icmph, len, 0)); - dev_queue_xmit(buff); + skb->dst = dst; + dst_output(skb); ICMP6_INC_STATS(Icmp6OutRedirects); ICMP6_INC_STATS(Icmp6OutMsgs); diff -Nru a/net/ipv6/netfilter/ip6t_ah.c b/net/ipv6/netfilter/ip6t_ah.c --- a/net/ipv6/netfilter/ip6t_ah.c Mon Mar 3 01:40:34 2003 +++ b/net/ipv6/netfilter/ip6t_ah.c Thu Mar 6 09:11:12 2003 @@ -9,7 +9,6 @@ #include #include -EXPORT_NO_SYMBOLS; MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("IPv6 AH match"); MODULE_AUTHOR("Andras Kis-Szabo "); diff -Nru a/net/ipv6/netfilter/ip6t_dst.c b/net/ipv6/netfilter/ip6t_dst.c --- a/net/ipv6/netfilter/ip6t_dst.c Mon Mar 3 01:40:34 2003 +++ b/net/ipv6/netfilter/ip6t_dst.c Thu Mar 6 09:11:12 2003 @@ -15,7 +15,6 @@ #define HOPBYHOP 0 -EXPORT_NO_SYMBOLS; MODULE_LICENSE("GPL"); #if HOPBYHOP MODULE_DESCRIPTION("IPv6 HbH match"); diff -Nru a/net/ipv6/netfilter/ip6t_esp.c b/net/ipv6/netfilter/ip6t_esp.c --- a/net/ipv6/netfilter/ip6t_esp.c Mon Mar 3 01:40:34 2003 +++ b/net/ipv6/netfilter/ip6t_esp.c Thu Mar 6 09:11:12 2003 @@ -9,7 +9,6 @@ #include #include -EXPORT_NO_SYMBOLS; MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("IPv6 ESP match"); MODULE_AUTHOR("Andras Kis-Szabo "); diff -Nru a/net/ipv6/netfilter/ip6t_frag.c b/net/ipv6/netfilter/ip6t_frag.c --- a/net/ipv6/netfilter/ip6t_frag.c Mon Mar 3 01:40:34 2003 +++ b/net/ipv6/netfilter/ip6t_frag.c Thu Mar 6 09:11:12 2003 @@ -11,7 +11,6 @@ #include #include -EXPORT_NO_SYMBOLS; MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("IPv6 FRAG match"); MODULE_AUTHOR("Andras Kis-Szabo "); diff -Nru a/net/ipv6/netfilter/ip6t_hbh.c b/net/ipv6/netfilter/ip6t_hbh.c --- a/net/ipv6/netfilter/ip6t_hbh.c Mon Mar 3 01:40:34 2003 +++ b/net/ipv6/netfilter/ip6t_hbh.c Thu Mar 6 09:11:12 2003 @@ -15,7 +15,6 @@ #define HOPBYHOP 1 -EXPORT_NO_SYMBOLS; MODULE_LICENSE("GPL"); #if HOPBYHOP MODULE_DESCRIPTION("IPv6 HbH match"); diff -Nru a/net/ipv6/netfilter/ip6t_ipv6header.c b/net/ipv6/netfilter/ip6t_ipv6header.c --- a/net/ipv6/netfilter/ip6t_ipv6header.c Mon Mar 3 01:40:34 2003 +++ b/net/ipv6/netfilter/ip6t_ipv6header.c Thu Mar 6 09:11:12 2003 @@ -14,7 +14,6 @@ #include #include -EXPORT_NO_SYMBOLS; MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("IPv6 headers match"); MODULE_AUTHOR("Andras Kis-Szabo "); diff -Nru a/net/ipv6/netfilter/ip6t_rt.c b/net/ipv6/netfilter/ip6t_rt.c --- a/net/ipv6/netfilter/ip6t_rt.c Mon Mar 3 01:40:34 2003 +++ b/net/ipv6/netfilter/ip6t_rt.c Thu Mar 6 09:11:12 2003 @@ -11,7 +11,6 @@ #include #include -EXPORT_NO_SYMBOLS; MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("IPv6 RT match"); MODULE_AUTHOR("Andras Kis-Szabo "); diff -Nru a/net/ipv6/raw.c b/net/ipv6/raw.c --- a/net/ipv6/raw.c Mon Oct 28 04:53:45 2002 +++ b/net/ipv6/raw.c Wed Mar 5 15:45:36 2003 @@ -45,6 +45,7 @@ #include #include +#include struct sock *raw_v6_htable[RAWV6_HTABLE_SIZE]; rwlock_t raw_v6_lock = RW_LOCK_UNLOCKED; @@ -303,6 +304,11 @@ { struct inet_opt *inet = inet_sk(sk); struct raw6_opt *raw_opt = raw6_sk(sk); + + if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) { + kfree_skb(skb); + return NET_RX_DROP; + } if (!raw_opt->checksum) skb->ip_summed = CHECKSUM_UNNECESSARY; diff -Nru a/net/ipv6/route.c b/net/ipv6/route.c --- a/net/ipv6/route.c Mon Mar 3 01:47:43 2003 +++ b/net/ipv6/route.c Wed Mar 5 15:45:36 2003 @@ -49,6 +49,8 @@ #include #include #include +#include +#include #include @@ -128,6 +130,12 @@ rwlock_t rt6_lock = RW_LOCK_UNLOCKED; +/* Dummy rt for ndisc */ +struct rt6_info *ndisc_get_dummy_rt() +{ + return dst_alloc(&ip6_dst_ops); +} + /* * Route lookup. Any rt6_lock is implied. */ @@ -356,7 +364,7 @@ rt->rt6i_nexthop = ndisc_get_neigh(rt->rt6i_dev, &rt->rt6i_gateway); - dst_clone(&rt->u.dst); + dst_hold(&rt->u.dst); err = rt6_ins(rt); if (err == 0) @@ -366,7 +374,7 @@ return rt; } - dst_clone(&ip6_null_entry.u.dst); + dst_hold(&ip6_null_entry.u.dst); return &ip6_null_entry; } @@ -374,7 +382,7 @@ if (rt == &ip6_null_entry && strict) { \ while ((fn = fn->parent) != NULL) { \ if (fn->fn_flags & RTN_ROOT) { \ - dst_clone(&rt->u.dst); \ + dst_hold(&rt->u.dst); \ goto out; \ } \ if (fn->fn_flags & RTN_RTINFO) \ @@ -404,7 +412,7 @@ if ((rt->rt6i_flags & RTF_CACHE)) { rt = rt6_device_match(rt, skb->dev->ifindex, strict); BACKTRACK(); - dst_clone(&rt->u.dst); + dst_hold(&rt->u.dst); goto out; } @@ -424,7 +432,7 @@ */ goto relookup; } - dst_clone(&rt->u.dst); + dst_hold(&rt->u.dst); out: read_unlock_bh(&rt6_lock); @@ -455,7 +463,7 @@ if ((rt->rt6i_flags & RTF_CACHE)) { rt = rt6_device_match(rt, fl->oif, strict); BACKTRACK(); - dst_clone(&rt->u.dst); + dst_hold(&rt->u.dst); goto out; } if (rt->rt6i_flags & RTF_DEFAULT) { @@ -480,7 +488,7 @@ */ goto relookup; } - dst_clone(&rt->u.dst); + dst_hold(&rt->u.dst); out: read_unlock_bh(&rt6_lock); @@ -815,7 +823,7 @@ if (rtmsg->rtmsg_metric && rtmsg->rtmsg_metric != rt->rt6i_metric) continue; - dst_clone(&rt->u.dst); + dst_hold(&rt->u.dst); read_unlock_bh(&rt6_lock); return ip6_del_rt(rt); @@ -878,7 +886,7 @@ read_lock(&rt6_lock); for (rt1 = ip6_routing_table.leaf; rt1; rt1 = rt1->u.next) { if (!ipv6_addr_cmp(saddr, &rt1->rt6i_gateway)) { - dst_clone(&rt1->u.dst); + dst_hold(&rt1->u.dst); dst_release(&rt->u.dst); read_unlock(&rt6_lock); rt = rt1; @@ -1065,7 +1073,7 @@ break; } if (rt) - dst_clone(&rt->u.dst); + dst_hold(&rt->u.dst); write_unlock_bh(&rt6_lock); return rt; } @@ -1859,6 +1867,14 @@ #endif +int xfrm6_dst_lookup(struct xfrm_dst **dst, struct flowi *fl) +{ + int err = 0; + *dst = (struct xfrm_dst*)ip6_route_output(NULL, fl); + if (!*dst) + err = -ENETUNREACH; + return err; +} void __init ip6_route_init(void) { @@ -1867,6 +1883,7 @@ 0, SLAB_HWCACHE_ALIGN, NULL, NULL); fib6_init(); + xfrm_dst_lookup_register(xfrm6_dst_lookup, AF_INET6); #ifdef CONFIG_PROC_FS proc_net_create("ipv6_route", 0, rt6_proc_info); proc_net_create("rt6_stats", 0, rt6_proc_stats); @@ -1880,7 +1897,7 @@ proc_net_remove("ipv6_route"); proc_net_remove("rt6_stats"); #endif - + xfrm_dst_lookup_unregister(AF_INET6); rt6_ifdown(NULL); fib6_gc_cleanup(); } diff -Nru a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c --- a/net/ipv6/tcp_ipv6.c Sat Feb 22 16:15:34 2003 +++ b/net/ipv6/tcp_ipv6.c Wed Mar 5 15:45:36 2003 @@ -50,6 +50,7 @@ #include #include #include +#include #include @@ -677,6 +678,9 @@ fl.nl_u.ip6_u.daddr = rt0->addr; } + if (!fl.fl6_src) + fl.fl6_src = &np->saddr; + dst = ip6_route_output(sk, &fl); if ((err = dst->error) != 0) { @@ -800,7 +804,7 @@ dst = ip6_route_output(sk, &fl); } else - dst_clone(dst); + dst_hold(dst); if (dst->error) { sk->err_soft = -dst->error; @@ -1637,6 +1641,9 @@ if (sk_filter(sk, skb, 0)) goto discard_and_relse; + if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) + goto discard_it; + skb->dev = NULL; bh_lock_sock(sk); @@ -1652,6 +1659,9 @@ return ret; no_tcp_socket: + if (!xfrm6_policy_check(NULL, XFRM_POLICY_IN, skb)) + goto discard_and_relse; + if (skb->len < (th->doff<<2) || tcp_checksum_complete(skb)) { bad_packet: TCP_INC_STATS_BH(TcpInErrs); @@ -1671,8 +1681,11 @@ discard_and_relse: sock_put(sk); goto discard_it; - + do_time_wait: + if (!xfrm6_policy_check(NULL, XFRM_POLICY_IN, skb)) + goto discard_and_relse; + if (skb->len < (th->doff<<2) || tcp_checksum_complete(skb)) { TCP_INC_STATS_BH(TcpInErrs); sock_put(sk); diff -Nru a/net/ipv6/udp.c b/net/ipv6/udp.c --- a/net/ipv6/udp.c Tue Jan 7 02:19:42 2003 +++ b/net/ipv6/udp.c Wed Mar 5 15:45:36 2003 @@ -50,6 +50,7 @@ #include #include +#include DEFINE_SNMP_STAT(struct udp_mib, udp_stats_in6); @@ -541,6 +542,11 @@ static inline int udpv6_queue_rcv_skb(struct sock * sk, struct sk_buff *skb) { + if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) { + kfree_skb(skb); + return -1; + } + #if defined(CONFIG_FILTER) if (sk->filter && skb->ip_summed != CHECKSUM_UNNECESSARY) { if ((unsigned short)csum_fold(skb_checksum(skb, 0, skb->len, skb->csum))) { @@ -645,6 +651,9 @@ if (!pskb_may_pull(skb, sizeof(struct udphdr))) goto short_packet; + + if (!xfrm6_policy_check(NULL, XFRM_POLICY_IN, skb)) + goto discard; saddr = &skb->nh.ipv6h->saddr; daddr = &skb->nh.ipv6h->daddr; diff -Nru a/net/ipx/af_ipx.c b/net/ipx/af_ipx.c --- a/net/ipx/af_ipx.c Tue Feb 25 11:05:23 2003 +++ b/net/ipx/af_ipx.c Mon Mar 3 04:56:53 2003 @@ -1719,10 +1719,10 @@ if (!sk) goto out; - if (!sk->dead) + if (!test_bit(SOCK_DEAD, &sk->flags)) sk->state_change(sk); - sk->dead = 1; + __set_bit(SOCK_DEAD, &sk->flags); sock->sk = NULL; ipx_destroy_socket(sk); diff -Nru a/net/irda/af_irda.c b/net/irda/af_irda.c --- a/net/irda/af_irda.c Thu Nov 14 09:20:05 2002 +++ b/net/irda/af_irda.c Mon Mar 3 04:56:53 2003 @@ -133,13 +133,13 @@ } /* Prevent race conditions with irda_release() and irda_shutdown() */ - if ((!sk->dead) && (sk->state != TCP_CLOSE)) { + if ((!test_bit(SOCK_DEAD, &sk->flags)) && (sk->state != TCP_CLOSE)) { sk->state = TCP_CLOSE; sk->err = ECONNRESET; sk->shutdown |= SEND_SHUTDOWN; sk->state_change(sk); - sk->dead = 1; /* Uh-oh... Should use sock_orphan ? */ + __set_bit(SOCK_DEAD, &sk->flags); /* Uh-oh... Should use sock_orphan ? */ /* Close our TSAP. * If we leave it open, IrLMP put it back into the list of @@ -163,7 +163,7 @@ /* Note : once we are there, there is not much you want to do * with the socket anymore, apart from closing it. * For example, bind() and connect() won't reset sk->err, - * sk->shutdown and sk->dead to valid values... + * sk->shutdown and sk->flags to valid values... * Jean II */ } diff -Nru a/net/key/af_key.c b/net/key/af_key.c --- a/net/key/af_key.c Wed Feb 19 13:45:59 2003 +++ b/net/key/af_key.c Wed Mar 5 15:45:36 2003 @@ -51,7 +51,7 @@ { skb_queue_purge(&sk->receive_queue); - if (!sk->dead) { + if (!test_bit(SOCK_DEAD, &sk->flags)) { printk("Attempt to release alive pfkey socket: %p\n", sk); return; } @@ -550,8 +550,8 @@ switch (((struct sockaddr *)(addr + 1))->sa_family) { case AF_INET: - x = xfrm_state_lookup(((struct sockaddr_in *)(addr + 1))->sin_addr.s_addr, - sa->sadb_sa_spi, proto); + x = xfrm4_state_lookup(((struct sockaddr_in *)(addr + 1))->sin_addr.s_addr, + sa->sadb_sa_spi, proto); break; #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) case AF_INET6: @@ -1097,18 +1097,7 @@ min_spi = htonl(0x100); max_spi = htonl(0x0fffffff); } - switch (x->props.family) { - case AF_INET: - xfrm_alloc_spi(x, min_spi, max_spi); - break; -#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) - case AF_INET6: - xfrm6_alloc_spi(x, min_spi, max_spi); - break; -#endif - default: - break; - } + xfrm_alloc_spi(x, min_spi, max_spi); if (x->id.spi) resp_skb = pfkey_xfrm_state2msg(x, 0, 3); } @@ -2420,7 +2409,8 @@ return pfkey_broadcast(skb, GFP_ATOMIC, BROADCAST_REGISTERED, NULL); } -static struct xfrm_policy *pfkey_compile_policy(int opt, u8 *data, int len, int *dir) +static struct xfrm_policy *pfkey_compile_policy(u16 family, int opt, + u8 *data, int len, int *dir) { struct xfrm_policy *xp; struct sadb_x_policy *pol = (struct sadb_x_policy*)data; @@ -2451,6 +2441,7 @@ xp->lft.hard_byte_limit = XFRM_INF; xp->lft.soft_packet_limit = XFRM_INF; xp->lft.hard_packet_limit = XFRM_INF; + xp->family = family; xp->xfrm_nr = 0; if (pol->sadb_x_policy_type == IPSEC_POLICY_IPSEC && diff -Nru a/net/llc/llc_conn.c b/net/llc/llc_conn.c --- a/net/llc/llc_conn.c Mon Sep 30 12:17:03 2002 +++ b/net/llc/llc_conn.c Mon Mar 3 04:56:53 2003 @@ -119,9 +119,9 @@ sk->shutdown = SHUTDOWN_MASK; sk->socket->state = SS_UNCONNECTED; sk->state = TCP_CLOSE; - if (!sk->dead) { + if (!test_bit(SOCK_DEAD, &sk->flags)) { sk->state_change(sk); - sk->dead = 1; + __set_bit(SOCK_DEAD, &sk->flags); } } kfree_skb(skb); diff -Nru a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c --- a/net/netlink/af_netlink.c Sun Feb 23 22:14:05 2003 +++ b/net/netlink/af_netlink.c Mon Mar 3 04:56:53 2003 @@ -90,7 +90,7 @@ { skb_queue_purge(&sk->receive_queue); - if (!sk->dead) { + if (!test_bit(SOCK_DEAD, &sk->flags)) { printk("Freeing alive netlink socket %p\n", sk); return; } @@ -457,7 +457,7 @@ if ((atomic_read(&sk->rmem_alloc) > sk->rcvbuf || test_bit(0, &nlk->state)) && - !sk->dead) + !test_bit(SOCK_DEAD, &sk->flags)) timeo = schedule_timeout(timeo); __set_current_state(TASK_RUNNING); diff -Nru a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c --- a/net/netrom/af_netrom.c Tue Oct 8 07:02:41 2002 +++ b/net/netrom/af_netrom.c Mon Mar 3 04:56:53 2003 @@ -285,7 +285,7 @@ while ((skb = skb_dequeue(&sk->receive_queue)) != NULL) { if (skb->sk != sk) { /* A pending connection */ - skb->sk->dead = 1; /* Queue the unaccepted socket for death */ + __set_bit(SOCK_DEAD, &skb->sk->flags); /* Queue the unaccepted socket for death */ nr_start_heartbeat(skb->sk); nr_sk(skb->sk)->state = NR_STATE_0; } @@ -545,8 +545,8 @@ sk->state = TCP_CLOSE; sk->shutdown |= SEND_SHUTDOWN; sk->state_change(sk); - sk->dead = 1; - sk->destroy = 1; + __set_bit(SOCK_DEAD, &sk->flags); + __set_bit(SOCK_DESTROY, &sk->flags); sk->socket = NULL; break; @@ -960,7 +960,7 @@ nr_start_heartbeat(make); nr_start_idletimer(make); - if (!sk->dead) + if (!test_bit(SOCK_DEAD, &sk->flags)) sk->data_ready(sk, skb->len); return 1; diff -Nru a/net/netrom/nr_in.c b/net/netrom/nr_in.c --- a/net/netrom/nr_in.c Mon Aug 5 08:44:44 2002 +++ b/net/netrom/nr_in.c Mon Mar 3 04:56:53 2003 @@ -90,7 +90,7 @@ nr->n2count = 0; nr->window = skb->data[20]; sk->state = TCP_ESTABLISHED; - if (!sk->dead) + if (!test_bit(SOCK_DEAD, &sk->flags)) sk->state_change(sk); break; } diff -Nru a/net/netrom/nr_subr.c b/net/netrom/nr_subr.c --- a/net/netrom/nr_subr.c Mon Aug 5 08:44:44 2002 +++ b/net/netrom/nr_subr.c Mon Mar 3 04:56:53 2003 @@ -276,8 +276,8 @@ sk->err = reason; sk->shutdown |= SEND_SHUTDOWN; - if (!sk->dead) + if (!test_bit(SOCK_DEAD, &sk->flags)) sk->state_change(sk); - sk->dead = 1; + __set_bit(SOCK_DEAD, &sk->flags); } diff -Nru a/net/netrom/nr_timer.c b/net/netrom/nr_timer.c --- a/net/netrom/nr_timer.c Mon Aug 5 09:14:03 2002 +++ b/net/netrom/nr_timer.c Mon Mar 3 04:56:53 2003 @@ -141,7 +141,9 @@ case NR_STATE_0: /* Magic here: If we listen() and a new link dies before it is accepted() it isn't 'dead' so doesn't get removed. */ - if (sk->destroy || (sk->state == TCP_LISTEN && sk->dead)) { + if (test_bit(SOCK_DESTROY, &sk->flags) || + (sk->state == TCP_LISTEN && + test_bit(SOCK_DEAD, &sk->flags))) { nr_destroy_socket(sk); return; } @@ -209,10 +211,10 @@ sk->err = 0; sk->shutdown |= SEND_SHUTDOWN; - if (!sk->dead) + if (!test_bit(SOCK_DEAD, &sk->flags)) sk->state_change(sk); - sk->dead = 1; + __set_bit(SOCK_DEAD, &sk->flags); bh_unlock_sock(sk); } diff -Nru a/net/netsyms.c b/net/netsyms.c --- a/net/netsyms.c Tue Feb 25 18:56:15 2003 +++ b/net/netsyms.c Thu Mar 6 16:16:15 2003 @@ -54,6 +54,12 @@ #include #include #include +#if defined(CONFIG_INET_AH) || defined(CONFIG_INET_AH_MODULE) || defined(CONFIG_INET6_AH) || defined(CONFIG_INET6_AH_MODULE) +#include +#endif +#if defined(CONFIG_INET_ESP) || defined(CONFIG_INET_ESP_MODULE) || defined(CONFIG_INET6_ESP) || defined(CONFIG_INET6_ESP_MODULE) +#include +#endif extern struct net_proto_family inet_family_ops; @@ -296,11 +302,11 @@ EXPORT_SYMBOL(__xfrm_route_forward); EXPORT_SYMBOL(xfrm_state_alloc); EXPORT_SYMBOL(__xfrm_state_destroy); -EXPORT_SYMBOL(xfrm_state_find); +EXPORT_SYMBOL(xfrm4_state_find); EXPORT_SYMBOL(xfrm_state_insert); EXPORT_SYMBOL(xfrm_state_check_expire); EXPORT_SYMBOL(xfrm_state_check_space); -EXPORT_SYMBOL(xfrm_state_lookup); +EXPORT_SYMBOL(xfrm4_state_lookup); EXPORT_SYMBOL(xfrm_replay_check); EXPORT_SYMBOL(xfrm_replay_advance); EXPORT_SYMBOL(xfrm_check_selectors); @@ -324,13 +330,17 @@ EXPORT_SYMBOL(xfrm_policy_flush); EXPORT_SYMBOL(xfrm_policy_byid); EXPORT_SYMBOL(xfrm_policy_list); +EXPORT_SYMBOL(xfrm_dst_lookup_register); +EXPORT_SYMBOL(xfrm_dst_lookup_unregister); #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) +EXPORT_SYMBOL(xfrm6_state_find); +EXPORT_SYMBOL(xfrm6_rcv); EXPORT_SYMBOL(xfrm6_state_lookup); EXPORT_SYMBOL(xfrm6_find_acq); -EXPORT_SYMBOL(xfrm6_alloc_spi); EXPORT_SYMBOL(xfrm6_register_type); EXPORT_SYMBOL(xfrm6_unregister_type); EXPORT_SYMBOL(xfrm6_get_type); +EXPORT_SYMBOL(xfrm6_clear_mutable_options); #endif EXPORT_SYMBOL_GPL(xfrm_probe_algs); @@ -342,6 +352,15 @@ EXPORT_SYMBOL_GPL(xfrm_ealg_get_byid); EXPORT_SYMBOL_GPL(xfrm_aalg_get_byname); EXPORT_SYMBOL_GPL(xfrm_ealg_get_byname); +#if defined(CONFIG_INET_AH) || defined(CONFIG_INET_AH_MODULE) || defined(CONFIG_INET6_AH) || defined(CONFIG_INET6_AH_MODULE) +EXPORT_SYMBOL_GPL(skb_ah_walk); +#endif +#if defined(CONFIG_INET_ESP) || defined(CONFIG_INET_ESP_MODULE) || defined(CONFIG_INET6_ESP) || defined(CONFIG_INET6_ESP_MODULE) +EXPORT_SYMBOL_GPL(skb_cow_data); +EXPORT_SYMBOL_GPL(pskb_put); +EXPORT_SYMBOL_GPL(skb_icv_walk); +EXPORT_SYMBOL_GPL(skb_to_sgvec); +#endif #if defined (CONFIG_IPV6_MODULE) || defined (CONFIG_IP_SCTP_MODULE) /* inet functions common to v4 and v6 */ diff -Nru a/net/packet/af_packet.c b/net/packet/af_packet.c --- a/net/packet/af_packet.c Sat Nov 2 02:29:53 2002 +++ b/net/packet/af_packet.c Mon Mar 3 04:56:53 2003 @@ -198,7 +198,7 @@ BUG_TRAP(atomic_read(&sk->rmem_alloc)==0); BUG_TRAP(atomic_read(&sk->wmem_alloc)==0); - if (!sk->dead) { + if (!test_bit(SOCK_DEAD, &sk->flags)) { printk("Attempt to release alive packet socket: %p\n", sk); return; } @@ -852,7 +852,7 @@ po->running = 1; } else { sk->err = ENETDOWN; - if (!sk->dead) + if (!test_bit(SOCK_DEAD, &sk->flags)) sk->error_report(sk); } } else { @@ -1392,7 +1392,7 @@ __sock_put(sk); po->running = 0; sk->err = ENETDOWN; - if (!sk->dead) + if (!test_bit(SOCK_DEAD, &sk->flags)) sk->error_report(sk); } if (msg == NETDEV_UNREGISTER) { diff -Nru a/net/rose/af_rose.c b/net/rose/af_rose.c --- a/net/rose/af_rose.c Tue Oct 8 07:02:41 2002 +++ b/net/rose/af_rose.c Mon Mar 3 04:56:53 2003 @@ -365,7 +365,7 @@ while ((skb = skb_dequeue(&sk->receive_queue)) != NULL) { if (skb->sk != sk) { /* A pending connection */ - skb->sk->dead = 1; /* Queue the unaccepted socket for death */ + __set_bit(SOCK_DEAD, &skb->sk->flags); /* Queue the unaccepted socket for death */ rose_start_heartbeat(skb->sk); rose_sk(skb->sk)->state = ROSE_STATE_0; } @@ -646,8 +646,8 @@ sk->state = TCP_CLOSE; sk->shutdown |= SEND_SHUTDOWN; sk->state_change(sk); - sk->dead = 1; - sk->destroy = 1; + __set_bit(SOCK_DEAD, &sk->flags); + __set_bit(SOCK_DESTROY, &sk->flags); break; default: @@ -1019,7 +1019,7 @@ rose_start_heartbeat(make); - if (!sk->dead) + if (!test_bit(SOCK_DEAD, &sk->flags)) sk->data_ready(sk, skb->len); return 1; diff -Nru a/net/rose/rose_in.c b/net/rose/rose_in.c --- a/net/rose/rose_in.c Mon Aug 5 08:44:44 2002 +++ b/net/rose/rose_in.c Mon Mar 3 04:56:53 2003 @@ -54,7 +54,7 @@ rose->vl = 0; rose->state = ROSE_STATE_3; sk->state = TCP_ESTABLISHED; - if (!sk->dead) + if (!test_bit(SOCK_DEAD, &sk->flags)) sk->state_change(sk); break; diff -Nru a/net/rose/rose_route.c b/net/rose/rose_route.c --- a/net/rose/rose_route.c Mon Aug 5 09:23:19 2002 +++ b/net/rose/rose_route.c Mon Mar 3 04:56:53 2003 @@ -910,9 +910,9 @@ sk->state = TCP_CLOSE; sk->err = 0; sk->shutdown |= SEND_SHUTDOWN; - if (!sk->dead) + if (!test_bit(SOCK_DEAD, &sk->flags)) sk->state_change(sk); - sk->dead = 1; + __set_bit(SOCK_DEAD, &sk->flags); } else { skb->h.raw = skb->data; diff -Nru a/net/rose/rose_subr.c b/net/rose/rose_subr.c --- a/net/rose/rose_subr.c Mon Aug 5 08:44:45 2002 +++ b/net/rose/rose_subr.c Mon Mar 3 04:56:53 2003 @@ -510,8 +510,8 @@ sk->err = reason; sk->shutdown |= SEND_SHUTDOWN; - if (!sk->dead) + if (!test_bit(SOCK_DEAD, &sk->flags)) sk->state_change(sk); - sk->dead = 1; + __set_bit(SOCK_DEAD, &sk->flags); } diff -Nru a/net/rose/rose_timer.c b/net/rose/rose_timer.c --- a/net/rose/rose_timer.c Mon Aug 5 09:14:03 2002 +++ b/net/rose/rose_timer.c Mon Mar 3 04:56:53 2003 @@ -136,7 +136,9 @@ case ROSE_STATE_0: /* Magic here: If we listen() and a new link dies before it is accepted() it isn't 'dead' so doesn't get removed. */ - if (sk->destroy || (sk->state == TCP_LISTEN && sk->dead)) { + if (test_bit(SOCK_DESTROY, &sk->flags) || + (sk->state == TCP_LISTEN && + test_bit(SOCK_DEAD, &sk->flags))) { rose_destroy_socket(sk); return; } @@ -207,9 +209,9 @@ sk->err = 0; sk->shutdown |= SEND_SHUTDOWN; - if (!sk->dead) + if (!test_bit(SOCK_DEAD, &sk->flags)) sk->state_change(sk); - sk->dead = 1; + __set_bit(SOCK_DEAD, &sk->flags); bh_unlock_sock(sk); } diff -Nru a/net/sctp/ulpqueue.c b/net/sctp/ulpqueue.c --- a/net/sctp/ulpqueue.c Mon Mar 3 01:00:55 2003 +++ b/net/sctp/ulpqueue.c Mon Mar 3 04:56:53 2003 @@ -189,7 +189,7 @@ /* If the socket is just going to throw this away, do not * even try to deliver it. */ - if (sk->dead || (sk->shutdown & RCV_SHUTDOWN)) + if (test_bit(SOCK_DEAD, &sk->flags) || (sk->shutdown & RCV_SHUTDOWN)) goto out_free; /* Check if the user wishes to receive this event. */ diff -Nru a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c --- a/net/sunrpc/clnt.c Sat Feb 15 12:05:02 2003 +++ b/net/sunrpc/clnt.c Thu Mar 6 08:17:17 2003 @@ -208,7 +208,8 @@ rpcauth_destroy(clnt->cl_auth); clnt->cl_auth = NULL; } - rpc_rmdir(clnt->cl_pathname); + if (clnt->cl_pathname[0]) + rpc_rmdir(clnt->cl_pathname); if (clnt->cl_xprt) { xprt_destroy(clnt->cl_xprt); clnt->cl_xprt = NULL; diff -Nru a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c --- a/net/sunrpc/xprt.c Thu Feb 13 05:17:10 2003 +++ b/net/sunrpc/xprt.c Mon Mar 3 04:56:53 2003 @@ -967,7 +967,7 @@ dprintk("RPC: tcp_state_change client %p...\n", xprt); dprintk("RPC: state %x conn %d dead %d zapped %d\n", sk->state, xprt_connected(xprt), - sk->dead, sk->zapped); + test_bit(SOCK_DEAD, &sk->flags), sk->zapped); switch (sk->state) { case TCP_ESTABLISHED: diff -Nru a/net/unix/af_unix.c b/net/unix/af_unix.c --- a/net/unix/af_unix.c Fri Feb 7 01:50:37 2003 +++ b/net/unix/af_unix.c Mon Mar 3 04:56:53 2003 @@ -331,7 +331,8 @@ * we signal error. Messages are lost. Do not make this, * when peer was not connected to us. */ - if (!other->dead && unix_peer(other) == sk) { + if (!test_bit(SOCK_DEAD, &other->flags) && + unix_peer(other) == sk) { other->err = ECONNRESET; other->error_report(other); } @@ -347,7 +348,7 @@ BUG_TRAP(atomic_read(&sk->wmem_alloc) == 0); BUG_TRAP(!u->list); BUG_TRAP(sk->socket==NULL); - if (sk->dead==0) { + if (!test_bit(SOCK_DEAD, &sk->flags)) { printk("Attempt to release alive unix socket: %p\n", sk); return; } @@ -863,7 +864,7 @@ __set_current_state(TASK_INTERRUPTIBLE); add_wait_queue_exclusive(&u->peer_wait, &wait); - sched = (!other->dead && + sched = (!test_bit(SOCK_DEAD, &other->flags) && !(other->shutdown&RCV_SHUTDOWN) && skb_queue_len(&other->receive_queue) > other->max_ack_backlog); @@ -928,7 +929,7 @@ unix_state_rlock(other); /* Apparently VFS overslept socket death. Retry. */ - if (other->dead) { + if (test_bit(SOCK_DEAD, &other->flags)) { unix_state_runlock(other); sock_put(other); goto restart; @@ -1261,7 +1262,7 @@ if (!unix_may_send(sk, other)) goto out_unlock; - if (other->dead) { + if (test_bit(SOCK_DEAD, &other->flags)) { /* * Check with 1003.1g - what should * datagram error @@ -1403,7 +1404,8 @@ unix_state_rlock(other); - if (other->dead || (other->shutdown & RCV_SHUTDOWN)) + if (test_bit(SOCK_DEAD, &other->flags) || + (other->shutdown & RCV_SHUTDOWN)) goto pipe_err_free; skb_queue_tail(&other->receive_queue, skb); diff -Nru a/net/wanrouter/af_wanpipe.c b/net/wanrouter/af_wanpipe.c --- a/net/wanrouter/af_wanpipe.c Mon Feb 24 12:51:23 2003 +++ b/net/wanrouter/af_wanpipe.c Thu Mar 6 17:44:46 2003 @@ -76,14 +76,7 @@ #define DBG_PRINTK(format, a...) #endif -#if defined(LINUX_2_1) - #define dev_put(a) - #define __sock_put(a) - #define sock_hold(a) - #define DECLARE_WAITQUEUE(a,b) \ - struct wait_queue a = { b, NULL } -#endif - + /* SECURE SOCKET IMPLEMENTATION * * TRANSMIT: @@ -599,17 +592,8 @@ return -EMSGSIZE; } - #ifndef LINUX_2_4 - dev_lock_list(); - #endif - - #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,3) skb = sock_alloc_send_skb(sk, len+dev->hard_header_len+15, msg->msg_flags & MSG_DONTWAIT, &err); - #else - skb = sock_alloc_send_skb(sk, len+dev->hard_header_len+15, 0, - msg->msg_flags & MSG_DONTWAIT, &err); - #endif if (skb==NULL){ goto out_unlock; @@ -642,10 +626,6 @@ if (!(dev->flags & IFF_UP)) goto out_free; - #ifndef LINUX_2_4 - dev_unlock_list(); - #endif - if (atomic_read(&sk->wmem_alloc) + skb->truesize > (unsigned int)sk->sndbuf){ kfree_skb(skb); return -ENOBUFS; @@ -665,9 +645,6 @@ out_free: kfree_skb(skb); out_unlock: -#ifndef LINUX_2_4 - dev_unlock_list(); -#endif return err; } @@ -862,16 +839,12 @@ kfree(wp); wp_sk(sk) = NULL; - #ifdef LINUX_2_4 if (atomic_read(&sk->refcnt) != 1){ atomic_set(&sk->refcnt,1); DBG_PRINTK(KERN_INFO "wansock: Error, wrong reference count: %i ! :delay.\n", atomic_read(&sk->refcnt)); } sock_put(sk); - #else - sk_free(sk); - #endif atomic_dec(&wanpipe_socks_nr); MOD_DEC_USE_COUNT; return; @@ -970,16 +943,8 @@ * protocol entry in the device list. *===========================================================*/ -#ifdef LINUX_2_4 static int wanpipe_release(struct socket *sock) -#else -static int wanpipe_release(struct socket *sock, struct socket *peersock) -#endif { - -#ifndef LINUX_2_4 - struct sk_buff *skb; -#endif wanpipe_opt *wp; struct sock *sk = sock->sk; struct sock **skp; @@ -1039,25 +1004,13 @@ sock->sk = NULL; sk->socket = NULL; - sk->dead = 1; + __set_bit(SOCK_DEAD, &sk->flags); /* Purge queues */ -#ifdef LINUX_2_4 skb_queue_purge(&sk->receive_queue); skb_queue_purge(&sk->write_queue); skb_queue_purge(&sk->error_queue); -#else - while ((skb=skb_dequeue(&sk->receive_queue))!=NULL){ - kfree_skb(skb); - } - while ((skb=skb_dequeue(&sk->error_queue))!=NULL){ - kfree_skb(skb); - } - while ((skb=skb_dequeue(&sk->write_queue))!=NULL){ - kfree_skb(skb); - } -#endif if (atomic_read(&sk->rmem_alloc) || atomic_read(&sk->wmem_alloc)) { del_timer(&sk->timer); printk(KERN_INFO "wansock: Killing in Timer R %i , W %i\n", @@ -1072,16 +1025,12 @@ kfree(wp); wp_sk(sk) = NULL; - #ifdef LINUX_2_4 if (atomic_read(&sk->refcnt) != 1){ DBG_PRINTK(KERN_INFO "wansock: Error, wrong reference count: %i !:release.\n", atomic_read(&sk->refcnt)); atomic_set(&sk->refcnt,1); } sock_put(sk); - #else - sk_free(sk); - #endif atomic_dec(&wanpipe_socks_nr); MOD_DEC_USE_COUNT; return 0; @@ -1128,7 +1077,7 @@ while ((skb=skb_dequeue(&sk->receive_queue))!=NULL){ if ((deadsk = get_newsk_from_skb(skb))){ DBG_PRINTK (KERN_INFO "wansock: RELEASE: FOUND DEAD SOCK\n"); - deadsk->dead=1; + __set_bit(SOCK_DEAD, &deadsk->flags); start_cleanup_timer(deadsk); } kfree_skb(skb); @@ -1181,10 +1130,6 @@ { struct sock *sk = (struct sock *)data; -#ifndef LINUX_2_4 - struct sk_buff *skb; -#endif - struct sock **skp; if (!sk) @@ -1226,21 +1171,9 @@ sk->socket = NULL; /* Purge queues */ -#ifdef LINUX_2_4 skb_queue_purge(&sk->receive_queue); skb_queue_purge(&sk->write_queue); skb_queue_purge(&sk->error_queue); -#else - while ((skb=skb_dequeue(&sk->receive_queue)) != NULL){ - kfree_skb(skb); - } - while ((skb=skb_dequeue(&sk->write_queue)) != NULL) { - kfree_skb(skb); - } - while ((skb=skb_dequeue(&sk->error_queue)) != NULL){ - kfree_skb(skb); - } -#endif if (atomic_read(&sk->rmem_alloc) || atomic_read(&sk->wmem_alloc)) { del_timer(&sk->timer); @@ -1257,16 +1190,12 @@ wp_sk(sk) = NULL; } - #ifdef LINUX_2_4 if (atomic_read(&sk->refcnt) != 1){ atomic_set(&sk->refcnt,1); DBG_PRINTK(KERN_INFO "wansock: Error, wrong reference count: %i ! :timer.\n", atomic_read(&sk->refcnt)); } sock_put(sk); - #else - sk_free(sk); - #endif atomic_dec(&wanpipe_socks_nr); MOD_DEC_USE_COUNT; return; @@ -1301,16 +1230,12 @@ wp_sk(sk) = NULL; } - #ifdef LINUX_2_4 if (atomic_read(&sk->refcnt) != 1){ atomic_set(&sk->refcnt,1); DBG_PRINTK(KERN_INFO "wansock: Error, wrong reference count: %i ! :timer.\n", atomic_read(&sk->refcnt)); } sock_put(sk); - #else - sk_free(sk); - #endif atomic_dec(&wanpipe_socks_nr); MOD_DEC_USE_COUNT; return; @@ -1330,16 +1255,12 @@ wp_sk(sk) = NULL; } - #ifdef LINUX_2_4 if (atomic_read(&sk->refcnt) != 1){ atomic_set(&sk->refcnt,1); DBG_PRINTK(KERN_INFO "wansock: Error, wrong reference count: %i !:listen.\n", atomic_read(&sk->refcnt)); } sock_put(sk); - #else - sk_free(sk); - #endif atomic_dec(&wanpipe_socks_nr); MOD_DEC_USE_COUNT; return; @@ -1494,11 +1415,7 @@ */ strncpy(name,sll->sll_device,14); name[14]=0; -#ifdef LINUX_2_4 dev = dev_get_by_name(name); -#else - dev = dev_get(name); -#endif if (dev == NULL){ printk(KERN_INFO "wansock: Failed to get Dev from name: %s,\n", name); @@ -1706,11 +1623,7 @@ if (err) goto out_free; -#ifdef LINUX_2_1 - sk->stamp=skb->stamp; -#else sock_recv_timestamp(msg, sk, skb); -#endif if (msg->msg_name) memcpy(msg->msg_name, skb->cb, msg->msg_namelen); @@ -2212,11 +2125,7 @@ if (sock_writeable(sk)){ mask |= POLLOUT | POLLWRNORM | POLLWRBAND; }else{ - #ifdef LINUX_2_4 set_bit(SOCK_ASYNC_NOSPACE, &sk->socket->flags); - #else - sk->socket->flags |= SO_NOSPACE; - #endif } return mask; @@ -2649,7 +2558,6 @@ return 0; } -#ifdef LINUX_2_4 struct proto_ops wanpipe_ops = { .family = PF_WANPIPE, @@ -2668,29 +2576,6 @@ .sendmsg = wanpipe_sendmsg, .recvmsg = wanpipe_recvmsg }; -#else -struct proto_ops wanpipe_ops = { - PF_WANPIPE, - - sock_no_dup, - wanpipe_release, - wanpipe_bind, - wanpipe_connect, - sock_no_socketpair, - wanpipe_accept, - wanpipe_getname, - wanpipe_poll, - wanpipe_ioctl, - wanpipe_listen, - sock_no_shutdown, - sock_no_setsockopt, - sock_no_getsockopt, - sock_no_fcntl, - wanpipe_sendmsg, - wanpipe_recvmsg -}; -#endif - static struct net_proto_family wanpipe_family_ops = { .family =PF_WANPIPE, diff -Nru a/net/x25/af_x25.c b/net/x25/af_x25.c --- a/net/x25/af_x25.c Tue Oct 8 07:03:35 2002 +++ b/net/x25/af_x25.c Mon Mar 3 04:56:53 2003 @@ -344,7 +344,7 @@ /* * Queue the unaccepted socket for death */ - skb->sk->dead = 1; + __set_bit(SOCK_DEAD, &skb->sk->flags); x25_start_heartbeat(skb->sk); x25_sk(skb->sk)->state = X25_STATE_0; } @@ -580,8 +580,8 @@ sk->state = TCP_CLOSE; sk->shutdown |= SEND_SHUTDOWN; sk->state_change(sk); - sk->dead = 1; - sk->destroy = 1; + __set_bit(SOCK_DEAD, &sk->flags); + __set_bit(SOCK_DESTROY, &sk->flags); break; } @@ -902,7 +902,7 @@ x25_start_heartbeat(make); - if (!sk->dead) + if (!test_bit(SOCK_DEAD, &sk->flags)) sk->data_ready(sk, skb->len); rc = 1; sock_put(sk); @@ -1112,7 +1112,8 @@ if (flags & MSG_OOB) { rc = -EINVAL; - if (sk->urginline || !skb_peek(&x25->interrupt_in_queue)) + if (test_bit(SOCK_URGINLINE, &sk->flags) || + !skb_peek(&x25->interrupt_in_queue)) goto out; skb = skb_dequeue(&x25->interrupt_in_queue); diff -Nru a/net/x25/x25_in.c b/net/x25/x25_in.c --- a/net/x25/x25_in.c Sat Sep 28 02:28:53 2002 +++ b/net/x25/x25_in.c Mon Mar 3 04:56:53 2003 @@ -86,7 +86,7 @@ skb_set_owner_r(skbn, sk); skb_queue_tail(&sk->receive_queue, skbn); - if (!sk->dead) + if (!test_bit(SOCK_DEAD, &sk->flags)) sk->data_ready(sk, skbn->len); return 0; @@ -129,7 +129,7 @@ skb->len); x25->calluserdata.cudlength = skb->len; } - if (!sk->dead) + if (!test_bit(SOCK_DEAD, &sk->flags)) sk->state_change(sk); break; } @@ -277,7 +277,7 @@ break; case X25_INTERRUPT: - if (sk->urginline) { + if (test_bit(SOCK_URGINLINE, &sk->flags)) { queued = (sock_queue_rcv_skb(sk, skb) == 0); } else { skb_set_owner_r(skb, sk); diff -Nru a/net/x25/x25_subr.c b/net/x25/x25_subr.c --- a/net/x25/x25_subr.c Sat Sep 28 02:28:53 2002 +++ b/net/x25/x25_subr.c Mon Mar 3 04:56:53 2003 @@ -344,10 +344,10 @@ sk->err = reason; sk->shutdown |= SEND_SHUTDOWN; - if (!sk->dead) + if (!test_bit(SOCK_DEAD, &sk->flags)) sk->state_change(sk); - sk->dead = 1; + __set_bit(SOCK_DEAD, &sk->flags); } /* diff -Nru a/net/x25/x25_timer.c b/net/x25/x25_timer.c --- a/net/x25/x25_timer.c Tue Oct 8 17:45:17 2002 +++ b/net/x25/x25_timer.c Mon Mar 3 04:56:53 2003 @@ -139,7 +139,7 @@ case X25_STATE_0: /* Magic here: If we listen() and a new link dies before it is accepted() it isn't 'dead' so doesn't get removed. */ - if (sk->destroy || (sk->state == TCP_LISTEN && sk->dead)) { + if (test_bit(SOCK_DESTROY, &sk->flags) || (sk->state == TCP_LISTEN && test_bit(SOCK_DEAD, &sk->flags))) { x25_destroy_socket(sk); goto unlock; } diff -Nru a/scripts/Makefile.build b/scripts/Makefile.build --- a/scripts/Makefile.build Wed Feb 19 14:42:13 2003 +++ b/scripts/Makefile.build Wed Mar 5 18:09:44 2003 @@ -163,12 +163,12 @@ # Single-part modules are special since we need to mark them in $(MODVERDIR) $(single-used-m): %.o: %.c FORCE - $(touch-module) ifdef CONFIG_MODVERSIONS $(call if_changed_rule,vcc_o_c) else $(call if_changed_dep,cc_o_c) endif + $(touch-module) quiet_cmd_cc_lst_c = MKLST $@ cmd_cc_lst_c = $(CC) $(c_flags) -g -c -o $*.o $< && \ @@ -262,8 +262,8 @@ $(call if_changed,link_multi-y) $(multi-used-m) : %.o: $(multi-objs-m) FORCE - $(touch-module) $(call if_changed,link_multi-m) + $(touch-module) targets += $(multi-used-y) $(multi-used-m) diff -Nru a/scripts/Makefile.modpost b/scripts/Makefile.modpost --- a/scripts/Makefile.modpost Sun Mar 2 20:55:31 2003 +++ b/scripts/Makefile.modpost Wed Mar 5 17:51:30 2003 @@ -37,7 +37,7 @@ quiet_cmd_cc_o_c = CC $@ cmd_cc_o_c = $(CC) $(CFLAGS) $(CFLAGS_MODULE) -c -o $@ $< -$(modules:.ko=.mod.o): %.mod.o: %.mod.c +$(modules:.ko=.mod.o): %.mod.o: %.mod.c FORCE $(call if_changed,cc_o_c) targets += $(modules:.ko=.mod.o) @@ -51,9 +51,9 @@ # Extract all checksums for all exported symbols quiet_cmd_modpost = MODPOST - cmd_modpost = scripts/modpost $^ + cmd_modpost = scripts/modpost $(filter-out FORCE,$^) -__modpost: $(wildcard vmlinux) $(modules:.ko=.o) +__modpost: $(wildcard vmlinux) $(modules:.ko=.o) FORCE $(call if_changed,modpost) targets += __modpost diff -Nru a/scripts/modpost.c b/scripts/modpost.c --- a/scripts/modpost.c Fri Feb 21 19:50:41 2003 +++ b/scripts/modpost.c Wed Mar 5 18:07:11 2003 @@ -293,6 +293,9 @@ /* undefined symbol */ if (ELF_ST_BIND(sym->st_info) != STB_GLOBAL) break; + /* ignore global offset table */ + if (strcmp(symname, "_GLOBAL_OFFSET_TABLE_") == 0) + break; if (memcmp(symname, MODULE_SYMBOL_PREFIX, strlen(MODULE_SYMBOL_PREFIX)) == 0) { diff -Nru a/scripts/per-cpu-check.awk b/scripts/per-cpu-check.awk --- a/scripts/per-cpu-check.awk Fri Jan 24 12:27:01 2003 +++ b/scripts/per-cpu-check.awk Wed Mar 5 17:53:22 2003 @@ -6,7 +6,7 @@ IN_PER_CPU=0 } -/__per_cpu$$/ && ! ( / __ksymtab_/ || / __kstrtab_/ || / __kcrctab_/ ) { +/__per_cpu$$/ && ! ( / __ksymtab_/ || / __kstrtab_/ || / __kcrctab_/ || / __crc_/ ) { if (!IN_PER_CPU) { print $$3 " not in per-cpu section" > "/dev/stderr"; FOUND=1; diff -Nru a/sound/oss/trident.c b/sound/oss/trident.c --- a/sound/oss/trident.c Fri Feb 28 17:14:13 2003 +++ b/sound/oss/trident.c Thu Mar 6 09:38:03 2003 @@ -221,7 +221,7 @@ #define TRIDENT_STATE_MAGIC 0x63657373 /* "cess" */ #define TRIDENT_DMA_MASK 0x3fffffff /* DMA buffer mask for pci_alloc_consist */ -#define ALI_DMA_MASK 0xffffffff /* ALI Tridents lack the 30-bit limitation */ +#define ALI_DMA_MASK 0x7fffffff /* ALI Tridents have 31-bit DMA. Wow. */ #define NR_HW_CH 32 diff -Nru a/sound/pci/ac97/ac97_codec.c b/sound/pci/ac97/ac97_codec.c --- a/sound/pci/ac97/ac97_codec.c Fri Feb 21 18:52:09 2003 +++ b/sound/pci/ac97/ac97_codec.c Wed Mar 5 21:39:37 2003 @@ -1808,7 +1808,7 @@ */ static int ac97_reset_wait(ac97_t *ac97, int timeout, int with_modem) { - signed long end_time; + unsigned long end_time; end_time = jiffies + timeout; do { unsigned short ext_mid; @@ -1866,7 +1866,7 @@ int err; ac97_t *ac97; char name[64]; - signed long end_time; + unsigned long end_time; static snd_device_ops_t ops = { .dev_free = snd_ac97_dev_free, }; diff -Nru a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c --- a/sound/pci/intel8x0.c Sun Feb 16 05:47:43 2003 +++ b/sound/pci/intel8x0.c Wed Mar 5 21:39:37 2003 @@ -1741,7 +1741,7 @@ static int snd_intel8x0_ich_chip_init(intel8x0_t *chip) { - signed long end_time; + unsigned long end_time; unsigned int cnt, status, nstatus; /* put logic to right state */