diff options
34 files changed, 735 insertions, 624 deletions
diff --git a/MAINTAINERS b/MAINTAINERS index dcfcccc606a4..3663d2b25579 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -535,6 +535,12 @@ M: Remy.Card@linux.org L: linux-kernel@vger.kernel.org S: Maintained +EXT3 FILE SYSTEM +P: Remy Card, Stephen Tweedie +M: sct@redhat.com, akpm@zip.com.au, adilger@turbolinux.com +L: ext3-users@redhat.com +S: Maintained + FARSYNC SYNCHRONOUS DRIVER P: Bob Dunlop M: rjd@xyzzy.clara.co.uk @@ -1038,7 +1044,7 @@ S: Maintained NETWORK DEVICE DRIVERS P: Andrew Morton -M: andrewm@uow.edu.au +M: akpm@zip.com.au P: Jeff Garzik M: jgarzik@mandrakesoft.com L: linux-net@vger.kernel.org @@ -1,7 +1,7 @@ VERSION = 2 PATCHLEVEL = 4 SUBLEVEL = 15 -EXTRAVERSION =-pre5 +EXTRAVERSION =-pre6 KERNELRELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION) diff --git a/arch/alpha/kernel/setup.c b/arch/alpha/kernel/setup.c index 54495b1d0824..442550c6575b 100644 --- a/arch/alpha/kernel/setup.c +++ b/arch/alpha/kernel/setup.c @@ -1064,8 +1064,6 @@ show_cpuinfo(struct seq_file *f, void *slot) char *sysvariation_name; int nr_processors; - if (!cpu) - return 1; cpu_index = (unsigned) (cpu->type - 1); cpu_name = "Unknown"; if (cpu_index < N(cpu_names)) diff --git a/arch/alpha/kernel/time.c b/arch/alpha/kernel/time.c index faa29910df30..01bf82bd8f0f 100644 --- a/arch/alpha/kernel/time.c +++ b/arch/alpha/kernel/time.c @@ -186,8 +186,8 @@ validate_cc_value(unsigned long cc) [EV4_CPU] = { 150000000, 300000000 }, [LCA4_CPU] = { 150000000, 300000000 }, /* guess */ [EV45_CPU] = { 200000000, 300000000 }, - [EV5_CPU] = { 266000000, 333333333 }, - [EV56_CPU] = { 366000000, 667000000 }, + [EV5_CPU] = { 250000000, 433000000 }, + [EV56_CPU] = { 333000000, 667000000 }, [PCA56_CPU] = { 400000000, 600000000 }, /* guess */ [PCA57_CPU] = { 500000000, 600000000 }, /* guess */ [EV6_CPU] = { 466000000, 600000000 }, diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c index 9fee22468cca..f7a26043c1c1 100644 --- a/arch/arm/kernel/setup.c +++ b/arch/arm/kernel/setup.c @@ -1,7 +1,7 @@ /* * linux/arch/arm/kernel/setup.c * - * Copyright (C) 1995-2000 Russell King + * Copyright (C) 1995-2001 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 @@ -16,6 +16,7 @@ #include <linux/blk.h> #include <linux/console.h> #include <linux/bootmem.h> +#include <linux/seq_file.h> #include <linux/init.h> #include <asm/elf.h> @@ -532,58 +533,53 @@ static const char *hwcap_str[] = { NULL }; -/* - * get_cpuinfo - Get information on one CPU for use by the procfs. - * - * Prints info on the next CPU into buffer. Beware, doesn't check for - * buffer overflow. Current implementation of procfs assumes that the - * resulting data is <= 1K. - * - * Args: - * buffer -- you guessed it, the data buffer - * cpu_np -- Input: next cpu to get (start at 0). Output: Updated. - * - * Returns number of bytes written to buffer. - */ - -int get_cpuinfo(char *buffer, unsigned *cpu_np) +static int c_show(struct seq_file *m, void *v) { - char *p = buffer; - unsigned n; int i; - /* No SMP at the moment, so just toggle 0/1 */ - n = *cpu_np; - *cpu_np = 1; - if (n != 0) { - return (0); - } - - p += sprintf(p, "Processor\t: %s %s rev %d (%s)\n", - proc_info.manufacturer, proc_info.cpu_name, - (int)processor_id & 15, elf_platform); + seq_printf(m, "Processor\t: %s %s rev %d (%s)\n", + proc_info.manufacturer, proc_info.cpu_name, + (int)processor_id & 15, elf_platform); - p += sprintf(p, "BogoMIPS\t: %lu.%02lu\n", - loops_per_jiffy / (500000/HZ), - (loops_per_jiffy / (5000/HZ)) % 100); + seq_printf(m, "BogoMIPS\t: %lu.%02lu\n", + loops_per_jiffy / (500000/HZ), + (loops_per_jiffy / (5000/HZ)) % 100); /* dump out the processor features */ - p += sprintf(p, "Features\t: "); + seq_puts(m, "Features\t: "); for (i = 0; hwcap_str[i]; i++) if (elf_hwcap & (1 << i)) - p += sprintf(p, "%s ", hwcap_str[i]); + seq_printf(m, "%s ", hwcap_str[i]); + + seq_puts(m, "\n\n"); - p += sprintf(p, "\n\n"); + seq_printf(m, "Hardware\t: %s\n", machine_name); + seq_printf(m, "Revision\t: %04x\n", system_rev); + seq_printf(m, "Serial\t\t: %08x%08x\n", + system_serial_high, system_serial_low); - p += sprintf(p, "Hardware\t: %s\n", machine_name); + return 0; +} - p += sprintf(p, "Revision\t: %04x\n", - system_rev); +static void *c_start(struct seq_file *m, loff_t *pos) +{ + return *pos < 1 ? (void *)1 : NULL; +} - p += sprintf(p, "Serial\t\t: %08x%08x\n", - system_serial_high, - system_serial_low); +static void *c_next(struct seq_file *m, void *v, loff_t *pos) +{ + ++*pos; + return NULL; +} - return p - buffer; +static void c_stop(struct seq_file *m, void *v) +{ } + +struct seq_operations cpuinfo_op = { + start: c_start, + next: c_next, + stop: c_stop, + show: c_show +}; diff --git a/arch/ppc/config.in b/arch/ppc/config.in index d1b0f88675be..3545adc66875 100644 --- a/arch/ppc/config.in +++ b/arch/ppc/config.in @@ -1,4 +1,4 @@ -# BK Id: SCCS/s.config.in 1.43 10/16/01 15:18:50 trini +# BK Id: SCCS/s.config.in 1.45 11/08/01 07:57:40 paulus # # For a description of the syntax of this configuration file, # see Documentation/kbuild/config-language.txt. @@ -6,6 +6,7 @@ define_bool CONFIG_UID16 n define_bool CONFIG_RWSEM_GENERIC_SPINLOCK n define_bool CONFIG_RWSEM_XCHGADD_ALGORITHM y +define_bool CONFIG_HAVE_DEC_LOCK y mainmenu_name "Linux/PowerPC Kernel Configuration" diff --git a/arch/ppc/kernel/apus_setup.c b/arch/ppc/kernel/apus_setup.c index db4f6e4173a8..e1f8cf807212 100644 --- a/arch/ppc/kernel/apus_setup.c +++ b/arch/ppc/kernel/apus_setup.c @@ -1,5 +1,5 @@ /* - * BK Id: SCCS/s.apus_setup.c 1.22 10/18/01 11:16:27 trini + * BK Id: SCCS/s.apus_setup.c 1.24 11/13/01 21:26:07 paulus */ /* * linux/arch/ppc/kernel/apus_setup.c @@ -25,6 +25,7 @@ #include <linux/hdreg.h> #include <linux/blk.h> #include <linux/pci.h> +#include <linux/seq_file.h> #ifdef CONFIG_APUS #include <asm/logging.h> @@ -263,24 +264,20 @@ void __init apus_setup_arch(void) } int -apus_get_cpuinfo(char *buffer) +apus_show_cpuinfo(struct seq_file *m) { -#ifdef CONFIG_APUS extern int __map_without_bats; extern unsigned long powerup_PCI_present; - int len; - - len = sprintf(buffer, "machine\t\t: Amiga\n"); - len += sprintf(buffer+len, "bus speed\t: %d%s", __bus_speed, - (__speed_test_failed) ? " [failed]\n" : "\n"); - len += sprintf(buffer+len, "using BATs\t: %s\n", - (__map_without_bats) ? "No" : "Yes"); - len += sprintf(buffer+len, "ram speed\t: %dns\n", - (__60nsram) ? 60 : 70); - len += sprintf(buffer+len, "PCI bridge\t: %s\n", - (powerup_PCI_present) ? "Yes" : "No"); - return len; -#endif + + seq_printf(m, "machine\t\t: Amiga\n"); + seq_printf(m, "bus speed\t: %d%s", __bus_speed, + (__speed_test_failed) ? " [failed]\n" : "\n"); + seq_printf(m, "using BATs\t: %s\n", + (__map_without_bats) ? "No" : "Yes"); + seq_printf(m, "ram speed\t: %dns\n", (__60nsram) ? 60 : 70); + seq_printf(m, "PCI bridge\t: %s\n", + (powerup_PCI_present) ? "Yes" : "No"); + return 0; } static void get_current_tb(unsigned long long *time) @@ -1069,8 +1066,7 @@ void platform_init(unsigned long r3, unsigned long r4, unsigned long r5, ISA_DMA_THRESHOLD = 0x00ffffff; ppc_md.setup_arch = apus_setup_arch; - ppc_md.setup_residual = NULL; - ppc_md.get_cpuinfo = apus_get_cpuinfo; + ppc_md.show_cpuinfo = apus_show_cpuinfo; ppc_md.irq_cannonicalize = apus_irq_cannonicalize; ppc_md.init_IRQ = apus_init_IRQ; ppc_md.get_irq = apus_get_irq; diff --git a/arch/ppc/kernel/chrp_setup.c b/arch/ppc/kernel/chrp_setup.c index 1511045b3d3a..6fd574cbae84 100644 --- a/arch/ppc/kernel/chrp_setup.c +++ b/arch/ppc/kernel/chrp_setup.c @@ -1,5 +1,5 @@ /* - * BK Id: SCCS/s.chrp_setup.c 1.36 09/08/01 15:47:42 paulus + * BK Id: SCCS/s.chrp_setup.c 1.38 11/13/01 21:26:07 paulus */ /* * linux/arch/ppc/kernel/setup.c @@ -38,6 +38,7 @@ #include <linux/module.h> #include <linux/delay.h> #include <linux/ide.h> +#include <linux/seq_file.h> #include <asm/mmu.h> #include <asm/processor.h> @@ -81,6 +82,7 @@ extern void pckbd_leds(unsigned char leds); extern void pckbd_init_hw(void); extern unsigned char pckbd_sysrq_xlate[128]; extern void select_adb_keyboard(void); +extern int of_show_percpuinfo(struct seq_file *, int); extern kdev_t boot_dev; @@ -110,9 +112,9 @@ static const char *gg2_cachemodes[4] = { }; int __chrp -chrp_get_cpuinfo(char *buffer) +chrp_show_cpuinfo(struct seq_file *m) { - int i, len, sdramen; + int i, sdramen; unsigned int t; struct device_node *root; const char *model = ""; @@ -120,11 +122,10 @@ chrp_get_cpuinfo(char *buffer) root = find_path_device("/"); if (root) model = get_property(root, "model", NULL); - len = sprintf(buffer,"machine\t\t: CHRP %s\n", model); + seq_printf(m, "machine\t\t: CHRP %s\n", model); /* longtrail (goldengate) stuff */ - if ( !strncmp( model, "IBM,LongTrail", 13 ) ) - { + if (!strncmp(model, "IBM,LongTrail", 13)) { /* VLSI VAS96011/12 `Golden Gate 2' */ /* Memory banks */ sdramen = (in_le32((unsigned *)(GG2_PCI_CONFIG_BASE+ @@ -159,17 +160,17 @@ chrp_get_cpuinfo(char *buffer) model = "Reserved"; break; } - len += sprintf(buffer+len, "memory bank %d\t: %s %s\n", i, model, - gg2_memtypes[sdramen ? 1 : ((t>>1) & 3)]); + seq_printf(m, "memory bank %d\t: %s %s\n", i, model, + gg2_memtypes[sdramen ? 1 : ((t>>1) & 3)]); } /* L2 cache */ t = in_le32((unsigned *)(GG2_PCI_CONFIG_BASE+GG2_PCI_CC_CTRL)); - len += sprintf(buffer+len, "board l2\t: %s %s (%s)\n", - gg2_cachesizes[(t>>7) & 3], - gg2_cachetypes[(t>>2) & 3], - gg2_cachemodes[t & 3]); + seq_printf(m, "board l2\t: %s %s (%s)\n", + gg2_cachesizes[(t>>7) & 3], + gg2_cachetypes[(t>>2) & 3], + gg2_cachemodes[t & 3]); } - return len; + return 0; } /* @@ -341,13 +342,8 @@ u_int __chrp chrp_irq_cannonicalize(u_int irq) { if (irq == 2) - { return 9; - } - else - { - return irq; - } + return irq; } void __init chrp_init_IRQ(void) @@ -513,8 +509,8 @@ chrp_init(unsigned long r3, unsigned long r4, unsigned long r5, isa_io_base = CHRP_ISA_IO_BASE; /* default value */ ppc_md.setup_arch = chrp_setup_arch; - ppc_md.setup_residual = NULL; - ppc_md.get_cpuinfo = chrp_get_cpuinfo; + ppc_md.show_percpuinfo = of_show_percpuinfo; + ppc_md.show_cpuinfo = chrp_show_cpuinfo; ppc_md.irq_cannonicalize = chrp_irq_cannonicalize; #ifndef CONFIG_POWER4 ppc_md.init_IRQ = chrp_init_IRQ; diff --git a/arch/ppc/kernel/gemini_setup.c b/arch/ppc/kernel/gemini_setup.c index 104d90b8a7fe..e390a83db0e4 100644 --- a/arch/ppc/kernel/gemini_setup.c +++ b/arch/ppc/kernel/gemini_setup.c @@ -24,6 +24,7 @@ #include <linux/major.h> #include <linux/blk.h> #include <linux/console.h> +#include <linux/seq_file.h> #include <asm/system.h> #include <asm/pgtable.h> @@ -82,9 +83,8 @@ prom_init(void) } int -gemini_get_cpuinfo(char *buffer) +gemini_show_cpuinfo(struct seq_file *m) { - int len; unsigned char reg, rev; char *family; unsigned int type; @@ -100,22 +100,20 @@ gemini_get_cpuinfo(char *buffer) reg = readb(GEMINI_BECO); - len = sprintf( buffer, "machine\t\t: Gemini %s%d, rev %c, eco %d\n", - family, type, (rev + 'A'), (reg & 0xf)); + seq_printf(m, "machine\t\t: Gemini %s%d, rev %c, eco %d\n", + family, type, (rev + 'A'), (reg & 0xf)); - len = sprintf(buffer, "board\t\t: Gemini %s", family); + seq_printf(m, "board\t\t: Gemini %s", family); if (type > 9) - len += sprintf(buffer+len, "%c", (type - 10) + 'A'); + seq_printf(m, "%c", (type - 10) + 'A'); else - len += sprintf(buffer+len, "%d", type); + seq_printf(m, "%d", type); - len += sprintf(buffer+len, ", rev %c, eco %d\n", - (rev + 'A'), (reg & 0xf)); + seq_printf(m, ", rev %c, eco %d\n", (rev + 'A'), (reg & 0xf)); - len += sprintf(buffer+len, "clock\t\t: %dMhz\n", - gemini_get_clock_speed()); + seq_printf(m, "clock\t\t: %dMhz\n", gemini_get_clock_speed()); - return len; + return 0; } static u_char gemini_openpic_initsenses[] = { @@ -150,11 +148,12 @@ extern char cmd_line[]; void gemini_heartbeat(void) { - /* We only want to do this on 1 CPU */ - if ( smp_processor_id() ) - return; static unsigned long led = GEMINI_LEDBASE+(4*8); static char direction = 8; + + /* We only want to do this on 1 CPU */ + if (smp_processor_id()) + return; *(char *)led = 0; if ( (led + direction) > (GEMINI_LEDBASE+(7*8)) || (led + direction) < (GEMINI_LEDBASE+(4*8)) ) @@ -551,8 +550,7 @@ void __init platform_init(unsigned long r3, unsigned long r4, unsigned long r5, #endif ppc_md.setup_arch = gemini_setup_arch; - ppc_md.setup_residual = NULL; - ppc_md.get_cpuinfo = gemini_get_cpuinfo; + ppc_md.show_cpuinfo = gemini_show_cpuinfo; ppc_md.irq_cannonicalize = NULL; ppc_md.init_IRQ = gemini_init_IRQ; ppc_md.get_irq = openpic_get_irq; diff --git a/arch/ppc/kernel/m8260_setup.c b/arch/ppc/kernel/m8260_setup.c index 873e8b732f37..dfdfb004dadd 100644 --- a/arch/ppc/kernel/m8260_setup.c +++ b/arch/ppc/kernel/m8260_setup.c @@ -1,5 +1,5 @@ /* - * BK Id: SCCS/s.m8260_setup.c 1.28 10/18/01 11:16:28 trini + * BK Id: SCCS/s.m8260_setup.c 1.30 11/13/01 21:26:07 paulus */ /* * linux/arch/ppc/kernel/setup.c @@ -34,6 +34,7 @@ #include <linux/blk.h> #include <linux/ioport.h> #include <linux/ide.h> +#include <linux/seq_file.h> #include <asm/mmu.h> #include <asm/processor.h> @@ -144,21 +145,20 @@ m8260_halt(void) static int -m8260_setup_residual(char *buffer) +m8260_show_percpuinfo(struct seq_file *m, int i) { - int len = 0; bd_t *bp; bp = (bd_t *)__res; - len += sprintf(len+buffer,"core clock\t: %d MHz\n" - "CPM clock\t: %d MHz\n" - "bus clock\t: %d MHz\n", - bp->bi_intfreq / 1000000, - bp->bi_cpmfreq / 1000000, - bp->bi_busfreq / 1000000); - - return len; + seq_printf(m, "core clock\t: %d MHz\n" + "CPM clock\t: %d MHz\n" + "bus clock\t: %d MHz\n", + bp->bi_intfreq / 1000000, + bp->bi_cpmfreq / 1000000, + bp->bi_busfreq / 1000000); + + return 0; } /* Initialize the internal interrupt controller. The number of @@ -240,8 +240,7 @@ platform_init(unsigned long r3, unsigned long r4, unsigned long r5, } ppc_md.setup_arch = m8260_setup_arch; - ppc_md.setup_residual = m8260_setup_residual; - ppc_md.get_cpuinfo = NULL; + ppc_md.show_percpuinfo = m8260_show_percpuinfo; ppc_md.irq_cannonicalize = NULL; ppc_md.init_IRQ = m8260_init_IRQ; ppc_md.get_irq = m8260_get_irq; diff --git a/arch/ppc/kernel/m8xx_setup.c b/arch/ppc/kernel/m8xx_setup.c index 87c6efafd19e..37bd3b1368b2 100644 --- a/arch/ppc/kernel/m8xx_setup.c +++ b/arch/ppc/kernel/m8xx_setup.c @@ -1,5 +1,5 @@ /* - * BK Id: SCCS/s.m8xx_setup.c 1.38 10/18/01 11:16:28 trini + * BK Id: SCCS/s.m8xx_setup.c 1.40 11/13/01 21:26:07 paulus * * linux/arch/ppc/kernel/setup.c * @@ -33,6 +33,7 @@ #include <linux/blk.h> #include <linux/ioport.h> #include <linux/bootmem.h> +#include <linux/seq_file.h> #include <asm/mmu.h> #include <asm/processor.h> @@ -240,19 +241,18 @@ m8xx_halt(void) static int -m8xx_setup_residual(char *buffer) +m8xx_show_percpuinfo(struct seq_file *m, int i) { - int len = 0; bd_t *bp; bp = (bd_t *)__res; - len += sprintf(len+buffer,"clock\t\t: %ldMHz\n" - "bus clock\t: %ldMHz\n", - bp->bi_intfreq / 1000000, - bp->bi_busfreq / 1000000); + seq_printf(m, "clock\t\t: %ldMHz\n" + "bus clock\t: %ldMHz\n", + bp->bi_intfreq / 1000000, + bp->bi_busfreq / 1000000); - return len; + return 0; } /* Initialize the internal interrupt controller. The number of @@ -372,8 +372,7 @@ platform_init(unsigned long r3, unsigned long r4, unsigned long r5, } ppc_md.setup_arch = m8xx_setup_arch; - ppc_md.setup_residual = m8xx_setup_residual; - ppc_md.get_cpuinfo = NULL; + ppc_md.show_percpuinfo = m8xx_show_percpuinfo; ppc_md.irq_cannonicalize = NULL; ppc_md.init_IRQ = m8xx_init_IRQ; ppc_md.get_irq = m8xx_get_irq; diff --git a/arch/ppc/kernel/oak_setup.c b/arch/ppc/kernel/oak_setup.c index 58bc682f9943..8d49dbbefff5 100644 --- a/arch/ppc/kernel/oak_setup.c +++ b/arch/ppc/kernel/oak_setup.c @@ -1,5 +1,5 @@ /* - * BK Id: SCCS/s.oak_setup.c 1.10 10/18/01 11:16:28 trini + * BK Id: SCCS/s.oak_setup.c 1.12 11/13/01 21:26:07 paulus */ /* * @@ -23,6 +23,7 @@ #include <linux/param.h> #include <linux/string.h> #include <linux/blk.h> +#include <linux/seq_file.h> #include <asm/processor.h> #include <asm/board.h> @@ -106,8 +107,7 @@ platform_init(unsigned long r3, unsigned long r4, unsigned long r5, /* Initialize machine-dependency vectors */ ppc_md.setup_arch = oak_setup_arch; - ppc_md.setup_residual = oak_setup_residual; - ppc_md.get_cpuinfo = NULL; + ppc_md.show_percpuinfo = oak_show_percpuinfo; ppc_md.irq_cannonicalize = NULL; ppc_md.init_IRQ = oak_init_IRQ; ppc_md.get_irq = oak_get_irq; @@ -141,7 +141,7 @@ oak_setup_arch(void) } /* - * int oak_setup_residual() + * int oak_show_percpuinfo() * * Description: * This routine pretty-prints the platform's internal CPU and bus clock @@ -159,18 +159,16 @@ oak_setup_arch(void) * on error. */ int -oak_setup_residual(char *buffer) +oak_show_percpuinfo(struct seq_file *m, int i) { - int len = 0; bd_t *bp = (bd_t *)__res; - len += sprintf(len + buffer, - "clock\t\t: %dMHz\n" - "bus clock\t\t: %dMHz\n", - bp->bi_intfreq / 1000000, - bp->bi_busfreq / 1000000); + seq_printf(m, "clock\t\t: %dMHz\n" + "bus clock\t\t: %dMHz\n", + bp->bi_intfreq / 1000000, + bp->bi_busfreq / 1000000); - return (len); + return 0; } /* diff --git a/arch/ppc/kernel/pci.c b/arch/ppc/kernel/pci.c index c45cd28bc586..141fa9131f46 100644 --- a/arch/ppc/kernel/pci.c +++ b/arch/ppc/kernel/pci.c @@ -1,5 +1,5 @@ /* - * BK Id: SCCS/s.pci.c 1.31 11/01/01 12:24:55 trini + * BK Id: SCCS/s.pci.c 1.35 11/13/01 08:19:57 trini */ /* * Common pmac/prep/chrp pci routines. -- Cort @@ -44,6 +44,7 @@ void pcibios_make_OF_bus_map(void); static void pcibios_fixup_resources(struct pci_dev* dev); static void fixup_broken_pcnet32(struct pci_dev* dev); +static void fixup_rev1_53c810(struct pci_dev* dev); #ifdef CONFIG_ALL_PPC static void pcibios_fixup_cardbus(struct pci_dev* dev); static u8* pci_to_OF_bus_map; @@ -60,16 +61,30 @@ struct pci_controller** hose_tail = &hose_head; static int pci_bus_count; struct pci_fixup pcibios_fixups[] = { - { PCI_FIXUP_HEADER, PCI_VENDOR_ID_TRIDENT, PCI_ANY_ID, fixup_broken_pcnet32 }, - { PCI_FIXUP_HEADER, PCI_ANY_ID, PCI_ANY_ID, pcibios_fixup_resources }, + { PCI_FIXUP_HEADER, PCI_VENDOR_ID_TRIDENT, PCI_ANY_ID, fixup_broken_pcnet32 }, + { PCI_FIXUP_HEADER, PCI_VENDOR_ID_NCR, PCI_DEVICE_ID_NCR_53C810, fixup_rev1_53c810 }, + { PCI_FIXUP_HEADER, PCI_ANY_ID, PCI_ANY_ID, pcibios_fixup_resources }, #ifdef CONFIG_ALL_PPC /* We should add per-machine fixup support in xxx_setup.c or xxx_pci.c */ - { PCI_FIXUP_FINAL, PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1211, pcibios_fixup_cardbus }, + { PCI_FIXUP_FINAL, PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1211, pcibios_fixup_cardbus }, #endif /* CONFIG_ALL_PPC */ { 0 } }; static void +fixup_rev1_53c810(struct pci_dev* dev) +{ + /* rev 1 ncr53c810 chips don't set the class at all which means + * they don't get their resources remapped. Fix that here. + */ + + if ((dev->class == PCI_CLASS_NOT_DEFINED)) { + printk("NCR 53c810 rev 1 detected, setting PCI class.\n"); + dev->class = PCI_CLASS_STORAGE_SCSI; + } +} + +static void fixup_broken_pcnet32(struct pci_dev* dev) { if ((dev->class>>8 == PCI_CLASS_NETWORK_ETHERNET)) { diff --git a/arch/ppc/kernel/pmac_setup.c b/arch/ppc/kernel/pmac_setup.c index aebe0e56b046..ad11963bda86 100644 --- a/arch/ppc/kernel/pmac_setup.c +++ b/arch/ppc/kernel/pmac_setup.c @@ -1,5 +1,5 @@ /* - * BK Id: SCCS/s.pmac_setup.c 1.41 10/18/01 11:16:28 trini + * BK Id: SCCS/s.pmac_setup.c 1.43 11/13/01 21:26:07 paulus */ /* * linux/arch/ppc/kernel/setup.c @@ -49,6 +49,7 @@ #include <linux/adb.h> #include <linux/cuda.h> #include <linux/pmu.h> +#include <linux/seq_file.h> #include <asm/processor.h> #include <asm/sections.h> @@ -157,36 +158,56 @@ core99_init_l2(void) } #endif /* CONFIG_SMP */ +/* + * Assume here that all clock rates are the same in a + * smp system. -- Cort + */ +int __openfirmware +of_show_percpuinfo(struct seq_file *m, int i) +{ + struct device_node *cpu_node; + int *fp, s; + + cpu_node = find_type_devices("cpu"); + if (!cpu_node) + return 0; + for (s = 0; s < i && cpu_node->next; s++) + cpu_node = cpu_node->next; + fp = (int *) get_property(cpu_node, "clock-frequency", NULL); + if (fp) + seq_printf(m, "clock\t\t: %dMHz\n", *fp / 1000000); + return 0; +} + int __pmac -pmac_get_cpuinfo(char *buffer) +pmac_show_cpuinfo(struct seq_file *m) { - int len; struct device_node *np; char *pp; int plen; /* find motherboard type */ - len = sprintf(buffer, "machine\t\t: "); + seq_printf(m, "machine\t\t: "); np = find_devices("device-tree"); if (np != NULL) { pp = (char *) get_property(np, "model", NULL); if (pp != NULL) - len += sprintf(buffer+len, "%s\n", pp); + seq_printf(m, "%s\n", pp); else - len += sprintf(buffer+len, "PowerMac\n"); + seq_printf(m, "PowerMac\n"); pp = (char *) get_property(np, "compatible", &plen); if (pp != NULL) { - len += sprintf(buffer+len, "motherboard\t:"); + seq_printf(m, "motherboard\t:"); while (plen > 0) { int l = strlen(pp) + 1; - len += sprintf(buffer+len, " %s", pp); + seq_printf(m, " %s", pp); plen -= l; pp += l; } - buffer[len++] = '\n'; + seq_printf(m, "\n"); } } else - len += sprintf(buffer+len, "PowerMac\n"); + seq_printf(m, "PowerMac\n"); /* find l2 cache info */ np = find_devices("l2-cache"); @@ -197,22 +218,21 @@ pmac_get_cpuinfo(char *buffer) get_property(np, "i-cache-size", NULL); unsigned int *dc = (unsigned int *) get_property(np, "d-cache-size", NULL); - len += sprintf(buffer+len, "L2 cache\t:"); + seq_printf(m, "L2 cache\t:"); has_l2cache = 1; if (get_property(np, "cache-unified", NULL) != 0 && dc) { - len += sprintf(buffer+len, " %dK unified", *dc / 1024); + seq_printf(m, " %dK unified", *dc / 1024); } else { if (ic) - len += sprintf(buffer+len, " %dK instruction", - *ic / 1024); + seq_printf(m, " %dK instruction", *ic / 1024); if (dc) - len += sprintf(buffer+len, "%s %dK data", - (ic? " +": ""), *dc / 1024); + seq_printf(m, "%s %dK data", + (ic? " +": ""), *dc / 1024); } pp = get_property(np, "ram-type", NULL); if (pp) - len += sprintf(buffer+len, " %s", pp); - buffer[len++] = '\n'; + seq_printf(m, " %s", pp); + seq_printf(m, "\n"); } /* find ram info */ @@ -227,8 +247,7 @@ pmac_get_cpuinfo(char *buffer) for (n /= sizeof(struct reg_property); n > 0; --n) total += (reg++)->size; - len += sprintf(buffer+len, "memory\t\t: %luMB\n", - total >> 20); + seq_printf(m, "memory\t\t: %luMB\n", total >> 20); } } @@ -240,16 +259,16 @@ pmac_get_cpuinfo(char *buffer) unsigned int *l2cr = (unsigned int *) get_property(np, "l2cr-value", NULL); if (l2cr != 0) { - len += sprintf(buffer+len, "l2cr override\t: 0x%x\n", *l2cr); + seq_printf(m, "l2cr override\t: 0x%x\n", *l2cr); } } /* Indicate newworld/oldworld */ - len += sprintf(buffer+len, "pmac-generation\t: %s\n", - pmac_newworld ? "NewWorld" : "OldWorld"); + seq_printf(m, "pmac-generation\t: %s\n", + pmac_newworld ? "NewWorld" : "OldWorld"); - return len; + return 0; } #ifdef CONFIG_SCSI @@ -765,8 +784,8 @@ pmac_init(unsigned long r3, unsigned long r4, unsigned long r5, DMA_MODE_WRITE = 2; ppc_md.setup_arch = pmac_setup_arch; - ppc_md.setup_residual = NULL; - ppc_md.get_cpuinfo = pmac_get_cpuinfo; + ppc_md.show_cpuinfo = pmac_show_cpuinfo; + ppc_md.show_percpuinfo = of_show_percpuinfo; ppc_md.irq_cannonicalize = NULL; ppc_md.init_IRQ = pmac_pic_init; ppc_md.get_irq = pmac_get_irq; /* Changed later on ... */ diff --git a/arch/ppc/kernel/ppc_ksyms.c b/arch/ppc/kernel/ppc_ksyms.c index 4a69bb5cd5cd..805c7fbd1383 100644 --- a/arch/ppc/kernel/ppc_ksyms.c +++ b/arch/ppc/kernel/ppc_ksyms.c @@ -1,5 +1,5 @@ /* - * BK Id: SCCS/s.ppc_ksyms.c 1.57 10/16/01 15:58:42 trini + * BK Id: SCCS/s.ppc_ksyms.c 1.59 11/04/01 22:58:20 paulus */ #include <linux/config.h> #include <linux/module.h> @@ -58,6 +58,7 @@ /* Tell string.h we don't want memcpy etc. as cpp defines */ #define EXPORT_SYMTAB_STROPS +extern void ppc_generic_ide_fix_driveid(struct hd_driveid *id); extern void transfer_to_handler(void); extern void syscall_trace(void); extern void do_IRQ(struct pt_regs *regs); @@ -167,6 +168,7 @@ EXPORT_SYMBOL(iopa); EXPORT_SYMBOL(mm_ptov); EXPORT_SYMBOL(ppc_ide_md); +EXPORT_SYMBOL(ppc_generic_ide_fix_driveid); #ifdef CONFIG_PCI EXPORT_SYMBOL_NOVERS(isa_io_base); diff --git a/arch/ppc/kernel/prep_setup.c b/arch/ppc/kernel/prep_setup.c index 59e8d790a8ba..4f4f5ad30b09 100644 --- a/arch/ppc/kernel/prep_setup.c +++ b/arch/ppc/kernel/prep_setup.c @@ -1,5 +1,5 @@ /* - * BK Id: SCCS/s.prep_setup.c 1.41 10/18/01 11:16:28 trini + * BK Id: SCCS/s.prep_setup.c 1.44 11/13/01 21:26:07 paulus */ /* * linux/arch/ppc/kernel/setup.c @@ -40,6 +40,7 @@ #include <linux/timex.h> #include <linux/pci.h> #include <linux/ide.h> +#include <linux/seq_file.h> #include <asm/sections.h> #include <asm/mmu.h> @@ -122,107 +123,107 @@ EXPORT_SYMBOL(ppc_cs4232_dma2); #endif static int __prep -prep_get_cpuinfo(char *buffer) +prep_show_cpuinfo(struct seq_file *m) { extern char *Motherboard_map_name; - int len; + int cachew; #ifdef CONFIG_PREP_RESIDUAL int i; #endif -#ifdef CONFIG_SMP -#define CD(X) (cpu_data[n].X) -#else -#define CD(X) (X) -#endif + seq_printf(m, "machine\t\t: PReP %s\n", Motherboard_map_name); - len = sprintf(buffer,"machine\t\t: PReP %s\n",Motherboard_map_name); - - - switch ( _prep_type ) - { + switch ( _prep_type ) { case _PREP_IBM: - if ((*(unsigned char *)0x8000080c) & (1<<6)) - len += sprintf(buffer+len,"Upgrade CPU\n"); - len += sprintf(buffer+len,"L2\t\t: "); - if ((*(unsigned char *)0x8000080c) & (1<<7)) - { - len += sprintf(buffer+len,"not present\n"); + cachew = inw(0x80c); + if (cachew & (1<<6)) + seq_printf(m, "Upgrade CPU\n"); + seq_printf(m, "L2\t\t: "); + if (cachew & (1<<7)) { + seq_printf(m, "not present\n"); goto no_l2; } - len += sprintf(buffer+len,"%sKb,", - (((*(unsigned char *)0x8000080d)>>2)&1) - ? "512" : "256"); - len += sprintf(buffer+len,"%ssync\n", - ((*(unsigned char *)0x8000080d)>>7) ? "" : "a"); + seq_printf(m, "%sKb,", (cachew & (1 << 10))? "512" : "256"); + seq_printf(m, "%ssync\n", (cachew & (1 << 15))? "" : "a"); break; case _PREP_Motorola: - len += sprintf(buffer+len,"L2\t\t: "); - switch(*((unsigned char *)CACHECRBA) & L2CACHE_MASK) - { + cachew = *((unsigned char *)CACHECRBA); + seq_printf(m, "L2\t\t: "); + switch (cachew & L2CACHE_MASK) { case L2CACHE_512KB: - len += sprintf(buffer+len,"512Kb"); + seq_printf(m, "512Kb"); break; case L2CACHE_256KB: - len += sprintf(buffer+len,"256Kb"); + seq_printf(m, "256Kb"); break; case L2CACHE_1MB: - len += sprintf(buffer+len,"1MB"); + seq_printf(m, "1MB"); break; case L2CACHE_NONE: - len += sprintf(buffer+len,"none\n"); + seq_printf(m, "none\n"); goto no_l2; break; default: - len += sprintf(buffer+len, "%x\n", - *((unsigned char *)CACHECRBA)); + seq_printf(m, "%x\n", cachew); } - len += sprintf(buffer+len,",parity %s", - (*((unsigned char *)CACHECRBA) & L2CACHE_PARITY) - ? "enabled" : "disabled"); + seq_printf(m, ", parity %s", + (cachew & L2CACHE_PARITY)? "enabled" : "disabled"); - len += sprintf(buffer+len, " SRAM:"); + seq_printf(m, " SRAM:"); - switch ( ((*((unsigned char *)CACHECRBA) & 0xf0) >> 4) & ~(0x3) ) - { - case 1: len += sprintf(buffer+len, - "synchronous,parity,flow-through\n"); + switch ( ((cachew & 0xf0) >> 4) & ~(0x3) ) { + case 1: seq_printf(m, "synchronous,parity,flow-through\n"); break; - case 2: len += sprintf(buffer+len,"asynchronous,no parity\n"); + case 2: seq_printf(m, "asynchronous,no parity\n"); break; - case 3: len += sprintf(buffer+len,"asynchronous,parity\n"); + case 3: seq_printf(m, "asynchronous,parity\n"); break; - default:len += sprintf(buffer+len, - "synchronous,pipelined,no parity\n"); + default:seq_printf(m, "synchronous,pipelined,no parity\n"); break; } break; default: break; } - - + no_l2: -#ifndef CONFIG_PREP_RESIDUAL - return len; -#else - if ( res->ResidualLength == 0 ) - return len; - - /* print info about SIMMs */ - len += sprintf(buffer+len,"simms\t\t: "); - for ( i = 0 ; (res->ActualNumMemories) && (i < MAX_MEMS) ; i++ ) - { - if ( res->Memories[i].SIMMSize != 0 ) - len += sprintf(buffer+len,"%d:%ldM ", i, +#ifdef CONFIG_PREP_RESIDUAL + if (res->ResidualLength == 0) { + /* print info about SIMMs */ + seq_printf(m, "simms\t\t: "); + for (i = 0; (res->ActualNumMemories) && (i < MAX_MEMS); i++) { + if (res->Memories[i].SIMMSize != 0) + seq_printf(m, "%d:%ldM ", i, (res->Memories[i].SIMMSize > 1024) ? res->Memories[i].SIMMSize>>20 : res->Memories[i].SIMMSize); + } + seq_printf(m, "\n"); } - len += sprintf(buffer+len,"\n"); - return len; #endif + + return 0; +} + +static int __prep +prep_show_percpuinfo(struct seq_file *m, int i) +{ + int len = 0; + + /* PREP's without residual data will give incorrect values here */ + seq_printf(m, "clock\t\t: "); +#ifdef CONFIG_PREP_RESIDUAL + if (res->ResidualLength) + seq_printf(m, "%ldMHz\n", + (res->VitalProductData.ProcessorHz > 1024) ? + res->VitalProductData.ProcessorHz>>20 : + res->VitalProductData.ProcessorHz); + else +#endif /* CONFIG_PREP_RESIDUAL */ + seq_printf(m, "???\n"); + + return 0; } static void __init @@ -628,26 +629,6 @@ prep_power_off(void) } } -static int __prep -prep_setup_residual(char *buffer) -{ - int len = 0; - - /* PREP's without residual data will give incorrect values here */ - len += sprintf(len+buffer, "clock\t\t: "); -#ifdef CONFIG_PREP_RESIDUAL - if ( res->ResidualLength ) - len += sprintf(len+buffer, "%ldMHz\n", - (res->VitalProductData.ProcessorHz > 1024) ? - res->VitalProductData.ProcessorHz>>20 : - res->VitalProductData.ProcessorHz); - else -#endif /* CONFIG_PREP_RESIDUAL */ - len += sprintf(len+buffer, "???\n"); - - return len; -} - static unsigned int __prep prep_irq_cannonicalize(u_int irq) { @@ -852,11 +833,8 @@ prep_init(unsigned long r3, unsigned long r4, unsigned long r5, unsigned long r6, unsigned long r7) { #ifdef CONFIG_PREP_RESIDUAL - RESIDUAL *old_res = (RESIDUAL *)(r3 + KERNELBASE); - /* make a copy of residual data */ - if ( r3 ) - { + if ( r3 ) { memcpy((void *)res,(void *)(r3+KERNELBASE), sizeof(RESIDUAL)); } @@ -900,8 +878,8 @@ prep_init(unsigned long r3, unsigned long r4, unsigned long r5, } ppc_md.setup_arch = prep_setup_arch; - ppc_md.setup_residual = prep_setup_residual; - ppc_md.get_cpuinfo = prep_get_cpuinfo; + ppc_md.show_percpuinfo = prep_show_percpuinfo; + ppc_md.show_cpuinfo = prep_show_cpuinfo; ppc_md.irq_cannonicalize = prep_irq_cannonicalize; ppc_md.init_IRQ = prep_init_IRQ; /* this gets changed later on if we have an OpenPIC -- Cort */ diff --git a/arch/ppc/kernel/setup.c b/arch/ppc/kernel/setup.c index ec0c8c96f877..b69f593bc41b 100644 --- a/arch/ppc/kernel/setup.c +++ b/arch/ppc/kernel/setup.c @@ -1,5 +1,5 @@ /* - * BK Id: SCCS/s.setup.c 1.61 10/12/01 16:35:34 trini + * BK Id: SCCS/s.setup.c 1.63 11/13/01 21:26:07 paulus */ /* * Common prep/pmac/chrp boot and setup code. @@ -16,6 +16,7 @@ #include <linux/ide.h> #include <linux/tty.h> #include <linux/bootmem.h> +#include <linux/seq_file.h> #include <asm/residual.h> #include <asm/io.h> @@ -136,150 +137,128 @@ extern u32 cpu_temp(unsigned long cpu); extern u32 cpu_temp_both(unsigned long cpu); #endif /* CONFIG_TAU */ -int get_cpuinfo(char *buffer) +int show_cpuinfo(struct seq_file *m, void *v) { - unsigned long len = 0; - unsigned long bogosum = 0; - unsigned long i; + int i = (int) v - 1; + int err = 0; unsigned int pvr; unsigned short maj, min; + unsigned long lpj; + if (i >= NR_CPUS) { + /* Show summary information */ #ifdef CONFIG_SMP -#define CPU_PRESENT(x) (cpu_callin_map[(x)]) -#define GET_PVR ((long int)(cpu_data[i].pvr)) -#define CD(x) (cpu_data[i].x) + unsigned long bogosum = 0; + for (i = 0; i < smp_num_cpus; ++i) + if (cpu_online_map & (1 << i)) + bogosum += cpu_data[i].loops_per_jiffy; + seq_printf(m, "total bogomips\t: %lu.%02lu\n", + bogosum/(500000/HZ), bogosum/(5000/HZ) % 100); +#endif /* CONFIG_SMP */ + + if (ppc_md.show_cpuinfo != NULL) + err = ppc_md.show_cpuinfo(m); + return err; + } + +#ifdef CONFIG_SMP + if (!(cpu_online_map & (1 << i))) + return 0; + pvr = cpu_data[i].pvr; + lpj = cpu_data[i].loops_per_jiffy; + seq_printf(m, "processor\t: %lu\n", i); #else -#define CPU_PRESENT(x) ((x)==0) -#define smp_num_cpus 1 -#define GET_PVR (mfspr(PVR)) -#define CD(x) (x) -#endif + pvr = mfspr(PVR); + lpj = loops_per_jiffy; +#endif - for ( i = 0; i < smp_num_cpus ; i++ ) - { - if ( !CPU_PRESENT(i) ) - continue; - if ( i ) - len += sprintf(len+buffer,"\n"); - len += sprintf(len+buffer,"processor\t: %lu\n",i); - len += sprintf(len+buffer,"cpu\t\t: "); - - pvr = GET_PVR; - - if (cur_cpu_spec[i]->pvr_mask) - len += sprintf(len+buffer, "%s", cur_cpu_spec[i]->cpu_name); - else - len += sprintf(len+buffer, "unknown (%08x)", pvr); + seq_printf(m, "cpu\t\t: "); + + if (cur_cpu_spec[i]->pvr_mask) + seq_printf(m, "%s", cur_cpu_spec[i]->cpu_name); + else + seq_printf(m, "unknown (%08x)", pvr); #ifdef CONFIG_ALTIVEC - if (cur_cpu_spec[i]->cpu_features & CPU_FTR_ALTIVEC) - len += sprintf(len+buffer, ", altivec supported"); -#endif - len += sprintf(len+buffer, "\n"); + if (cur_cpu_spec[i]->cpu_features & CPU_FTR_ALTIVEC) + seq_printf(m, ", altivec supported"); +#endif + seq_printf(m, "\n"); + #ifdef CONFIG_TAU - if (cur_cpu_spec[i]->cpu_features & CPU_FTR_TAU) { -#ifdef CONFIG_TAU_AVERAGE /* more straightforward, but potentially misleading */ - len += sprintf(len+buffer, "temperature \t: %u C (uncalibrated)\n", - cpu_temp(i)); + if (cur_cpu_spec[i]->cpu_features & CPU_FTR_TAU) { +#ifdef CONFIG_TAU_AVERAGE + /* more straightforward, but potentially misleading */ + seq_printf(m, "temperature \t: %u C (uncalibrated)\n", + cpu_temp(i)); #else - /* show the actual temp sensor range */ - u32 temp; - temp = cpu_temp_both(i); - len += sprintf(len+buffer, "temperature \t: %u-%u C (uncalibrated)\n", - temp & 0xff, temp >> 16); -#endif - } + /* show the actual temp sensor range */ + u32 temp; + temp = cpu_temp_both(i); + seq_printf(m, "temperature \t: %u-%u C (uncalibrated)\n", + temp & 0xff, temp >> 16); #endif + } +#endif /* CONFIG_TAU */ - /* - * Assume here that all clock rates are the same in a - * smp system. -- Cort - */ -#if defined(CONFIG_ALL_PPC) - if ( have_of ) - { - struct device_node *cpu_node; - int *fp; - - cpu_node = find_type_devices("cpu"); - if ( !cpu_node ) break; - { - int s; - for ( s = 0; (s < i) && cpu_node->next ; - s++, cpu_node = cpu_node->next ) - /* nothing */ ; -#if 0 /* SMP Pmacs don't have all cpu nodes -- Cort */ - if ( s != i ) - printk("get_cpuinfo(): ran out of " - "cpu nodes.\n"); -#endif - } - fp = (int *) get_property(cpu_node, "clock-frequency", NULL); - if ( !fp ) break; - len += sprintf(len+buffer, "clock\t\t: %dMHz\n", - *fp / 1000000); - } -#endif /* CONFIG_ALL_PPC */ + if (ppc_md.show_percpuinfo != NULL) { + err = ppc_md.show_percpuinfo(m, i); + if (err) + return err; + } - if (ppc_md.setup_residual != NULL) - { - len += ppc_md.setup_residual(buffer + len); - } - - switch (PVR_VER(pvr)) - { - case 0x0020: - maj = PVR_MAJ(pvr) + 1; - min = PVR_MIN(pvr); - break; - case 0x1008: - maj = ((pvr >> 8) & 0xFF) - 1; - min = pvr & 0xFF; - break; - default: - maj = (pvr >> 8) & 0xFF; - min = pvr & 0xFF; - break; - } + switch (PVR_VER(pvr)) { + case 0x0020: /* 403 family */ + maj = PVR_MAJ(pvr) + 1; + min = PVR_MIN(pvr); + break; + case 0x1008: /* 740P/750P ?? */ + maj = ((pvr >> 8) & 0xFF) - 1; + min = pvr & 0xFF; + break; + default: + maj = (pvr >> 8) & 0xFF; + min = pvr & 0xFF; + break; + } - len += sprintf(len+buffer, "revision\t: %hd.%hd (pvr %04x %04x)\n", - maj, min, PVR_VER(pvr), PVR_REV(pvr)); + seq_printf(m, "revision\t: %hd.%hd (pvr %04x %04x)\n", + maj, min, PVR_VER(pvr), PVR_REV(pvr)); - len += sprintf(buffer+len, "bogomips\t: %lu.%02lu\n", - CD(loops_per_jiffy)/(500000/HZ), - CD(loops_per_jiffy)/(5000/HZ) % 100); - bogosum += CD(loops_per_jiffy); - } + seq_printf(m, "bogomips\t: %lu.%02lu\n", + lpj / (500000/HZ), (lpj / (5000/HZ)) % 100); #ifdef CONFIG_SMP - if ( i && smp_num_cpus > 1) - len += sprintf(buffer+len, "\n"); - len += sprintf(buffer+len,"total bogomips\t: %lu.%02lu\n", - bogosum/(500000/HZ), - bogosum/(5000/HZ) % 100); -#endif /* CONFIG_SMP */ + seq_printf(m, "\n"); +#endif - /* - * Ooh's and aah's info about zero'd pages in idle task - */ - len += sprintf(buffer+len,"zero pages\t: total: %u (%luKb) " - "current: %u (%luKb) hits: %u/%u (%u%%)\n", - atomic_read(&zero_cache_total), - (atomic_read(&zero_cache_total)*PAGE_SIZE)>>10, - atomic_read(&zero_cache_sz), - (atomic_read(&zero_cache_sz)*PAGE_SIZE)>>10, - atomic_read(&zero_cache_hits),atomic_read(&zero_cache_calls), - /* : 1 below is so we don't div by zero */ - (atomic_read(&zero_cache_hits)*100) / - ((atomic_read(&zero_cache_calls))?atomic_read(&zero_cache_calls):1)); - - if (ppc_md.get_cpuinfo != NULL) - { - len += ppc_md.get_cpuinfo(buffer+len); - } + return 0; +} + + +static void *c_start(struct seq_file *m, loff_t *pos) +{ + int i = *pos; - return len; + return i <= NR_CPUS? (void *) (i + 1): NULL; +} + +static void *c_next(struct seq_file *m, void *v, loff_t *pos) +{ + ++*pos; + return c_start(m, pos); } +static void c_stop(struct seq_file *m, void *v) +{ +} + +struct seq_operations cpuinfo_op = { + start: c_start, + next: c_next, + stop: c_stop, + show: show_cpuinfo, +}; + /* * We're called here very early in the boot. We determine the machine * type and call the appropriate low-level setup functions. @@ -468,8 +447,7 @@ int parse_bootinfo(void) extern char __bss_start[]; rec = (struct bi_record *)_ALIGN((ulong)__bss_start+(1<<20)-1,(1<<20)); - if ( rec->tag != BI_FIRST ) - { + if ( rec->tag != BI_FIRST ) { /* * This 0x10000 offset is a terrible hack but it will go away when * we have the bootloader handle all the relocation and @@ -483,8 +461,7 @@ int parse_bootinfo(void) rec = (struct bi_record *)((ulong)rec + rec->size) ) { ulong *data = rec->data; - switch (rec->tag) - { + switch (rec->tag) { case BI_CMD_LINE: memcpy(cmd_line, (void *)data, rec->size); break; diff --git a/arch/ppc/kernel/walnut_setup.c b/arch/ppc/kernel/walnut_setup.c index daeb62794a7e..99bdcf7a38f1 100644 --- a/arch/ppc/kernel/walnut_setup.c +++ b/arch/ppc/kernel/walnut_setup.c @@ -1,5 +1,5 @@ /* - * BK Id: SCCS/s.walnut_setup.c 1.8 10/18/01 11:16:28 trini + * BK Id: SCCS/s.walnut_setup.c 1.10 11/13/01 21:26:07 paulus */ /* * @@ -23,6 +23,7 @@ #include <linux/param.h> #include <linux/string.h> #include <linux/blk.h> +#include <linux/seq_file.h> #include <asm/processor.h> #include <asm/board.h> @@ -101,8 +102,7 @@ walnut_init(unsigned long r3, unsigned long r4, unsigned long r5, /* Initialize machine-dependency vectors */ ppc_md.setup_arch = walnut_setup_arch; - ppc_md.setup_residual = walnut_setup_residual; - ppc_md.get_cpuinfo = NULL; + ppc_md.show_percpuinfo = walnut_show_percpuinfo; ppc_md.irq_cannonicalize = NULL; ppc_md.init_IRQ = walnut_init_IRQ; ppc_md.get_irq = walnut_get_irq; @@ -136,7 +136,7 @@ walnut_setup_arch(void) } /* - * int walnut_setup_residual() + * int walnut_show_percpuinfo() * * Description: * This routine pretty-prints the platform's internal CPU and bus clock @@ -154,18 +154,16 @@ walnut_setup_arch(void) * on error. */ int -walnut_setup_residual(char *buffer) +walnut_show_percpuinfo(struct seq_file *m) { - int len = 0; bd_t *bp = (bd_t *)__res; - len += sprintf(len + buffer, - "clock\t\t: %dMHz\n" - "bus clock\t\t: %dMHz\n", - bp->bi_intfreq / 1000000, - bp->bi_busfreq / 1000000); + seq_printf(m, "clock\t\t: %dMHz\n" + "bus clock\t\t: %dMHz\n", + bp->bi_intfreq / 1000000, + bp->bi_busfreq / 1000000); - return (len); + return 0; } /* diff --git a/arch/ppc/lib/Makefile b/arch/ppc/lib/Makefile index add27a05d61a..6a73123b384e 100644 --- a/arch/ppc/lib/Makefile +++ b/arch/ppc/lib/Makefile @@ -1,4 +1,4 @@ -# BK Id: SCCS/s.Makefile 1.7 05/17/01 18:14:22 cort +# BK Id: SCCS/s.Makefile 1.10 11/08/01 07:57:40 paulus # # # Makefile for ppc-specific library files.. @@ -8,7 +8,9 @@ USE_STANDARD_AS_RULE := true O_TARGET := lib.o -obj-y := checksum.o string.o strcase.o +export-objs := dec_and_lock.o + +obj-y := checksum.o string.o strcase.o dec_and_lock.o obj-$(CONFIG_SMP) += locks.o diff --git a/arch/ppc/lib/dec_and_lock.c b/arch/ppc/lib/dec_and_lock.c new file mode 100644 index 000000000000..252beec6377d --- /dev/null +++ b/arch/ppc/lib/dec_and_lock.c @@ -0,0 +1,46 @@ +#include <linux/module.h> +#include <linux/spinlock.h> +#include <asm/atomic.h> +#include <asm/system.h> + +/* + * This is an implementation of the notion of "decrement a + * reference count, and return locked if it decremented to zero". + * + * This implementation can be used on any architecture that + * has a cmpxchg, and where atomic->value is an int holding + * the value of the atomic (i.e. the high bits aren't used + * for a lock or anything like that). + * + * N.B. ATOMIC_DEC_AND_LOCK gets defined in include/linux/spinlock.h + * if spinlocks are empty and thus atomic_dec_and_lock is defined + * to be atomic_dec_and_test - in that case we don't need it + * defined here as well. + */ + +#ifndef ATOMIC_DEC_AND_LOCK +int atomic_dec_and_lock(atomic_t *atomic, spinlock_t *lock) +{ + int counter; + int newcount; + + for (;;) { + counter = atomic_read(atomic); + newcount = counter - 1; + if (!newcount) + break; /* do it the slow way */ + + newcount = cmpxchg(&atomic->counter, counter, newcount); + if (newcount == counter) + return 0; + } + + spin_lock(lock); + if (atomic_dec_and_test(atomic)) + return 1; + spin_unlock(lock); + return 0; +} + +EXPORT_SYMBOL(atomic_dec_and_lock); +#endif /* ATOMIC_DEC_AND_LOCK */ diff --git a/arch/s390/kernel/setup.c b/arch/s390/kernel/setup.c index 981027de04bf..34c24d6d9851 100644 --- a/arch/s390/kernel/setup.c +++ b/arch/s390/kernel/setup.c @@ -34,6 +34,7 @@ #endif #include <linux/bootmem.h> #include <linux/console.h> +#include <linux/seq_file.h> #include <asm/uaccess.h> #include <asm/system.h> #include <asm/smp.h> @@ -478,49 +479,48 @@ void print_cpu_info(struct cpuinfo_S390 *cpuinfo) } /* - * get_cpuinfo - Get information on one CPU for use by procfs. - * - * Prints info on the next CPU into buffer. Beware, doesn't check for - * buffer overflow. Current implementation of procfs assumes that the - * resulting data is <= 1K. - * - * Args: - * buffer -- you guessed it, the data buffer - * cpu_np -- Input: next cpu to get (start at 0). Output: Updated. - * - * Returns number of bytes written to buffer. + * show_cpuinfo - Get information on one CPU for use by procfs. */ -int get_cpuinfo(char *buffer, unsigned *cpu_np) +static int show_cpuinfo(struct seq_file *m, void *v) { struct cpuinfo_S390 *cpuinfo; - char *p = buffer; - unsigned n; - - n = *cpu_np; - while (n < NR_CPUS && (cpu_online_map & (1 << n)) == 0) - n++; - if (n >= NR_CPUS) { - *cpu_np = NR_CPUS; - return (0); - } - *cpu_np = n + 1; + unsigned n = v; - if (n == 0) { - p += sprintf(p,"vendor_id : IBM/S390\n" + if (!n--) { + seq_printf(m, "vendor_id : IBM/S390\n" "# processors : %i\n" "bogomips per cpu: %lu.%02lu\n", smp_num_cpus, loops_per_jiffy/(500000/HZ), (loops_per_jiffy/(5000/HZ))%100); + } else if (cpu_online_map & (1 << n)) { + cpuinfo = &safe_get_cpu_lowcore(n).cpu_data; + seq_printf(m, "processor %i: " + "version = %02X, " + "identification = %06X, " + "machine = %04X\n", + n, cpuinfo->cpu_id.version, + cpuinfo->cpu_id.ident, + cpuinfo->cpu_id.machine); } - cpuinfo = &safe_get_cpu_lowcore(n).cpu_data; - p += sprintf(p,"processor %i: " - "version = %02X, " - "identification = %06X, " - "machine = %04X\n", - n, cpuinfo->cpu_id.version, - cpuinfo->cpu_id.ident, - cpuinfo->cpu_id.machine); - return p - buffer; + return 0; } +static void *c_start(struct seq_file *m, loff_t *pos) +{ + return *pos <= NR_CPUS ? (void)(*pos+1) : NULL; +} +static void *c_next(struct seq_file *m, void *v, loff_t *pos) +{ + ++*pos; + return c_start(m, pos); +} +static void c_stop(struct seq_file *m, void *v) +{ +} +struct seq_operations cpuinfo_op = { + start: c_start, + next: c_next, + stop: c_stop, + show: show_cpuinfo, +}; diff --git a/arch/s390x/kernel/setup.c b/arch/s390x/kernel/setup.c index f2731a24b3da..f3c77f9de536 100644 --- a/arch/s390x/kernel/setup.c +++ b/arch/s390x/kernel/setup.c @@ -34,6 +34,7 @@ #endif #include <linux/bootmem.h> #include <linux/console.h> +#include <linux/seq_file.h> #include <asm/uaccess.h> #include <asm/system.h> #include <asm/smp.h> @@ -467,49 +468,48 @@ void print_cpu_info(struct cpuinfo_S390 *cpuinfo) } /* - * get_cpuinfo - Get information on one CPU for use by procfs. - * - * Prints info on the next CPU into buffer. Beware, doesn't check for - * buffer overflow. Current implementation of procfs assumes that the - * resulting data is <= 1K. - * - * Args: - * buffer -- you guessed it, the data buffer - * cpu_np -- Input: next cpu to get (start at 0). Output: Updated. - * - * Returns number of bytes written to buffer. + * show_cpuinfo - Get information on one CPU for use by procfs. */ -int get_cpuinfo(char *buffer, unsigned *cpu_np) +static int show_cpuinfo(struct seq_file *m, void *v) { struct cpuinfo_S390 *cpuinfo; - char *p = buffer; - unsigned n; - - n = *cpu_np; - while (n < NR_CPUS && (cpu_online_map & (1 << n)) == 0) - n++; - if (n >= NR_CPUS) { - *cpu_np = NR_CPUS; - return (0); - } - *cpu_np = n + 1; + unsigned n = v; - if (n == 0) { - p += sprintf(p, "vendor_id : IBM/S390\n" + if (!n--) { + seq_printf(m, "vendor_id : IBM/S390\n" "# processors : %i\n" "bogomips per cpu: %lu.%02lu\n", smp_num_cpus, loops_per_jiffy/(500000/HZ), (loops_per_jiffy/(5000/HZ))%100); + } else if (cpu_online_map & (1 << n)) { + cpuinfo = &safe_get_cpu_lowcore(n).cpu_data; + seq_printf(m, "processor %i: " + "version = %02X, " + "identification = %06X, " + "machine = %04X\n", + n, cpuinfo->cpu_id.version, + cpuinfo->cpu_id.ident, + cpuinfo->cpu_id.machine); } - cpuinfo = &safe_get_cpu_lowcore(n).cpu_data; - p += sprintf(p, "processor %i: " - "version = %02X, " - "identification = %06X, " - "machine = %04X\n", - n, cpuinfo->cpu_id.version, - cpuinfo->cpu_id.ident, - cpuinfo->cpu_id.machine); - return p - buffer; + return 0; } +static void *c_start(struct seq_file *m, loff_t *pos) +{ + return *pos <= NR_CPUS ? (void)(*pos+1) : NULL; +} +static void *c_next(struct seq_file *m, void *v, loff_t *pos) +{ + ++*pos; + return c_start(m, pos); +} +static void c_stop(struct seq_file *m, void *v) +{ +} +struct seq_operations cpuinfo_op = { + start: c_start, + next: c_next, + stop: c_stop, + show: show_cpuinfo, +}; diff --git a/arch/sh/kernel/setup.c b/arch/sh/kernel/setup.c index e7906b28ec20..a6ce692e6c75 100644 --- a/arch/sh/kernel/setup.c +++ b/arch/sh/kernel/setup.c @@ -31,6 +31,7 @@ #include <linux/bootmem.h> #include <linux/console.h> #include <linux/ctype.h> +#include <linux/seq_file.h> #include <asm/processor.h> #include <asm/page.h> #include <asm/pgtable.h> @@ -517,24 +518,22 @@ struct sh_machine_vector* __init get_mv_byname(const char* name) * Get CPU information for use by the procfs. */ #ifdef CONFIG_PROC_FS -int get_cpuinfo(char *buffer) +static int show_cpuinfo(struct seq_file *m, void *v) { - char *p = buffer; - #if defined(__sh3__) - p += sprintf(p,"cpu family\t: SH-3\n" - "cache size\t: 8K-byte\n"); + seq_printf(m, "cpu family\t: SH-3\n" + "cache size\t: 8K-byte\n"); #elif defined(__SH4__) - p += sprintf(p,"cpu family\t: SH-4\n" - "cache size\t: 8K-byte/16K-byte\n"); + seq_printf(m, "cpu family\t: SH-4\n" + "cache size\t: 8K-byte/16K-byte\n"); #endif - p += sprintf(p, "bogomips\t: %lu.%02lu\n\n", + seq_printf(m, "bogomips\t: %lu.%02lu\n\n", loops_per_jiffy/(500000/HZ), (loops_per_jiffy/(5000/HZ)) % 100); - p += sprintf(p, "Machine: %s\n", sh_mv.mv_name); + seq_printf(m, "Machine: %s\n", sh_mv.mv_name); #define PRINT_CLOCK(name, value) \ - p += sprintf(p, name " clock: %d.%02dMHz\n", \ + seq_printf(m, name " clock: %d.%02dMHz\n", \ ((value) / 1000000), ((value) % 1000000)/10000) PRINT_CLOCK("CPU", boot_cpu_data.cpu_clock); @@ -544,6 +543,24 @@ int get_cpuinfo(char *buffer) #endif PRINT_CLOCK("Peripheral module", boot_cpu_data.module_clock); - return p - buffer; + return 0; +} + +static void *c_start(struct seq_file *m, loff_t *pos) +{ + return (void*)(*pos == 0); } +static void *c_next(struct seq_file *m, void *v, loff_t *pos) +{ + return NULL; +} +static void c_stop(struct seq_file *m, void *v) +{ +} +struct seq_operations cpuinfo_op = { + start: c_start, + next: c_next, + stop: c_stop, + show: show_cpuinfo, +}; #endif diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c index 54fbc98bb0d2..f23e0a4f2ee9 100644 --- a/drivers/cdrom/cdrom.c +++ b/drivers/cdrom/cdrom.c @@ -2625,7 +2625,8 @@ static int __init cdrom_init(void) #ifdef CONFIG_SYSCTL cdrom_sysctl_register(); #endif - devfs_handle = devfs_mk_dir(NULL, "cdroms", NULL); + if (!devfs_handle) + devfs_handle = devfs_mk_dir(NULL, "cdroms", NULL); return 0; } diff --git a/drivers/char/agp/agpgart_be.c b/drivers/char/agp/agpgart_be.c index 7595677f15a5..8e507bcd48a7 100644 --- a/drivers/char/agp/agpgart_be.c +++ b/drivers/char/agp/agpgart_be.c @@ -1462,7 +1462,7 @@ static void intel_8xx_tlbflush(agp_memory * mem) pci_read_config_dword(agp_bridge.dev, INTEL_AGPCTRL, &temp); pci_write_config_dword(agp_bridge.dev, INTEL_AGPCTRL, temp & ~(1 << 7)); pci_read_config_dword(agp_bridge.dev, INTEL_AGPCTRL, &temp); - pci_write_config_dword(agp_bridge.dev, INTEL_AGPCTRL, temp & (1 << 7)); + pci_write_config_dword(agp_bridge.dev, INTEL_AGPCTRL, temp | (1 << 7)); } diff --git a/drivers/char/vt.c b/drivers/char/vt.c index 36b496bbbdb2..01a68557e759 100644 --- a/drivers/char/vt.c +++ b/drivers/char/vt.c @@ -24,7 +24,6 @@ #include <linux/major.h> #include <linux/fs.h> #include <linux/console.h> -#include <linux/irq.h> #include <asm/io.h> #include <asm/uaccess.h> diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c index 0cb5e5e14eea..3516d445e340 100644 --- a/drivers/pci/proc.c +++ b/drivers/pci/proc.c @@ -11,6 +11,7 @@ #include <linux/pci.h> #include <linux/proc_fs.h> #include <linux/init.h> +#include <linux/seq_file.h> #include <asm/uaccess.h> #include <asm/byteorder.h> @@ -302,53 +303,72 @@ static struct file_operations proc_bus_pci_operations = { #define LONG_FORMAT "\t%16lx" #endif -static int -get_pci_dev_info(char *buf, char **start, off_t pos, int count) +/* iterator */ +static void *pci_seq_start(struct seq_file *m, loff_t *pos) { + struct list_head *p = &pci_devices; + loff_t n = *pos; + + /* XXX: surely we need some locking for traversing the list? */ + while (n--) { + p = p->next; + if (p == &pci_devices) + return NULL; + } + return p; +} +static void *pci_seq_next(struct seq_file *m, void *v, loff_t *pos) +{ + struct list_head *p = v; + (*pos)++; + return p->next != &pci_devices ? p->next : NULL; +} +static void pci_seq_stop(struct seq_file *m, void *v) +{ + /* release whatever locks we need */ +} + +static int show_device(struct seq_file *m, void *v) +{ + struct list_head *p = v; const struct pci_dev *dev; - off_t at = 0; - int len, i, cnt; + const struct pci_driver *drv; + int i; - cnt = 0; - pci_for_each_dev(dev) { - const struct pci_driver *drv = pci_dev_driver(dev); - len = sprintf(buf, "%02x%02x\t%04x%04x\t%x", + if (p == &pci_devices) + return 0; + + dev = pci_dev_g(p); + drv = pci_dev_driver(dev); + seq_printf(m, "%02x%02x\t%04x%04x\t%x", dev->bus->number, dev->devfn, dev->vendor, dev->device, dev->irq); - /* Here should be 7 and not PCI_NUM_RESOURCES as we need to preserve compatibility */ - for(i=0; i<7; i++) - len += sprintf(buf+len, LONG_FORMAT, - dev->resource[i].start | (dev->resource[i].flags & PCI_REGION_FLAG_MASK)); - for(i=0; i<7; i++) - len += sprintf(buf+len, LONG_FORMAT, dev->resource[i].start < dev->resource[i].end ? - dev->resource[i].end - dev->resource[i].start + 1 : 0); - buf[len++] = '\t'; - if (drv) - len += sprintf(buf+len, "%s", drv->name); - buf[len++] = '\n'; - at += len; - if (at >= pos) { - if (!*start) { - *start = buf + (pos - (at - len)); - cnt = at - pos; - } else - cnt += len; - buf += len; - if (cnt >= count) - /* - * proc_file_read() gives us 1KB of slack so it's OK if the - * above printfs write a little beyond the buffer end (we - * never write more than 1KB beyond the buffer end). - */ - break; - } - } - return (count > cnt) ? cnt : count; + /* Here should be 7 and not PCI_NUM_RESOURCES as we need to preserve compatibility */ + for(i=0; i<7; i++) + seq_printf(m, LONG_FORMAT, + dev->resource[i].start | + (dev->resource[i].flags & PCI_REGION_FLAG_MASK)); + for(i=0; i<7; i++) + seq_printf(m, LONG_FORMAT, + dev->resource[i].start < dev->resource[i].end ? + dev->resource[i].end - dev->resource[i].start + 1 : 0); + seq_putc(m, '\t'); + if (drv) + seq_printf(m, "%s", drv->name); + seq_putc(m, '\n'); + return 0; } +static struct seq_operations proc_bus_pci_devices_op = { + start: pci_seq_start, + next: pci_seq_next, + stop: pci_seq_stop, + show: show_device +}; + static struct proc_dir_entry *proc_bus_pci_dir; int pci_proc_attach_device(struct pci_dev *dev) @@ -388,10 +408,10 @@ int pci_proc_detach_device(struct pci_dev *dev) int pci_proc_attach_bus(struct pci_bus* bus) { - struct proc_dir_entry *de; - char name[16]; + struct proc_dir_entry *de = bus->procdir; - if (!(de = bus->procdir)) { + if (!de) { + char name[16]; sprintf(name, "%02x", bus->number); de = bus->procdir = proc_mkdir(name, proc_bus_pci_dir); if (!de) @@ -402,11 +422,9 @@ int pci_proc_attach_bus(struct pci_bus* bus) int pci_proc_detach_bus(struct pci_bus* bus) { - struct proc_dir_entry *de; - - if (!(de = bus->procdir)) { + struct proc_dir_entry *de = bus->procdir; + if (de) remove_proc_entry(de->name, proc_bus_pci_dir); - } return 0; } @@ -421,54 +439,56 @@ int pci_proc_detach_bus(struct pci_bus* bus) * The configuration string is stored starting at buf[len]. If the * string would exceed the size of the buffer (SIZE), 0 is returned. */ -static int sprint_dev_config(struct pci_dev *dev, char *buf, int size) +static int show_dev_config(struct seq_file *m, void *v) { + struct list_head *p = v; + struct pci_dev *dev; + struct pci_driver *drv; u32 class_rev; unsigned char latency, min_gnt, max_lat, *class; - int reg, len = 0; + int reg; + + if (p == &pci_devices) { + seq_puts(m, "PCI devices found:\n"); + return 0; + } + + dev = pci_dev_g(p); + drv = pci_dev_driver(dev); pci_read_config_dword(dev, PCI_CLASS_REVISION, &class_rev); pci_read_config_byte (dev, PCI_LATENCY_TIMER, &latency); pci_read_config_byte (dev, PCI_MIN_GNT, &min_gnt); pci_read_config_byte (dev, PCI_MAX_LAT, &max_lat); - if (len + 160 > size) - return -1; - len += sprintf(buf + len, " Bus %2d, device %3d, function %2d:\n", - dev->bus->number, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn)); + seq_printf(m, " Bus %2d, device %3d, function %2d:\n", + dev->bus->number, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn)); class = pci_class_name(class_rev >> 16); if (class) - len += sprintf(buf+len, " %s", class); + seq_printf(m, " %s", class); else - len += sprintf(buf+len, " Class %04x", class_rev >> 16); - len += sprintf(buf+len, ": %s (rev %d).\n", dev->name, class_rev & 0xff); + seq_printf(m, " Class %04x", class_rev >> 16); + seq_printf(m, ": %s (rev %d).\n", dev->name, class_rev & 0xff); - if (dev->irq) { - if (len + 40 > size) - return -1; - len += sprintf(buf + len, " IRQ %d.\n", dev->irq); - } + if (dev->irq) + seq_printf(m, " IRQ %d.\n", dev->irq); if (latency || min_gnt || max_lat) { - if (len + 80 > size) - return -1; - len += sprintf(buf + len, " Master Capable. "); + seq_printf(m, " Master Capable. "); if (latency) - len += sprintf(buf + len, "Latency=%d. ", latency); + seq_printf(m, "Latency=%d. ", latency); else - len += sprintf(buf + len, "No bursts. "); + seq_puts(m, "No bursts. "); if (min_gnt) - len += sprintf(buf + len, "Min Gnt=%d.", min_gnt); + seq_printf(m, "Min Gnt=%d.", min_gnt); if (max_lat) - len += sprintf(buf + len, "Max Lat=%d.", max_lat); - len += sprintf(buf + len, "\n"); + seq_printf(m, "Max Lat=%d.", max_lat); + seq_putc(m, '\n'); } for (reg = 0; reg < 6; reg++) { struct resource *res = dev->resource + reg; unsigned long base, end, flags; - if (len + 40 > size) - return -1; base = res->start; end = res->end; flags = res->flags; @@ -476,9 +496,8 @@ static int sprint_dev_config(struct pci_dev *dev, char *buf, int size) continue; if (flags & PCI_BASE_ADDRESS_SPACE_IO) { - len += sprintf(buf + len, - " I/O at 0x%lx [0x%lx].\n", - base, end); + seq_printf(m, " I/O at 0x%lx [0x%lx].\n", + base, end); } else { const char *pref, *type = "unknown"; @@ -494,65 +513,58 @@ static int sprint_dev_config(struct pci_dev *dev, char *buf, int size) case PCI_BASE_ADDRESS_MEM_TYPE_64: type = "64 bit"; break; } - len += sprintf(buf + len, - " %srefetchable %s memory at " + seq_printf(m, " %srefetchable %s memory at " "0x%lx [0x%lx].\n", pref, type, base, end); } } - - return len; + return 0; } -/* - * Return list of PCI devices as a character string for /proc/pci. - * BUF is a buffer that is PAGE_SIZE bytes long. - */ -static int pci_read_proc(char *buf, char **start, off_t off, - int count, int *eof, void *data) -{ - int nprinted, len, begin = 0; - struct pci_dev *dev; - - len = sprintf(buf, "PCI devices found:\n"); +static struct seq_operations proc_pci_op = { + start: pci_seq_start, + next: pci_seq_next, + stop: pci_seq_stop, + show: show_dev_config +}; - *eof = 1; - pci_for_each_dev(dev) { - nprinted = sprint_dev_config(dev, buf + len, PAGE_SIZE - len); - if (nprinted < 0) { - *eof = 0; - break; - } - len += nprinted; - if (len+begin < off) { - begin += len; - len = 0; - } - if (len+begin >= off+count) - break; - } - off -= begin; - *start = buf + off; - len -= off; - if (len>count) - len = count; - if (len<0) - len = 0; - return len; +static int proc_bus_pci_dev_open(struct inode *inode, struct file *file) +{ + return seq_open(file, &proc_bus_pci_devices_op); } +static struct file_operations proc_bus_pci_dev_operations = { + open: proc_bus_pci_dev_open, + read: seq_read, + llseek: seq_lseek, + release: seq_release, +}; +static int proc_pci_open(struct inode *inode, struct file *file) +{ + return seq_open(file, &proc_pci_op); +} +static struct file_operations proc_pci_operations = { + open: proc_pci_open, + read: seq_read, + llseek: seq_lseek, + release: seq_release, +}; static int __init pci_proc_init(void) { if (pci_present()) { + struct proc_dir_entry *entry; struct pci_dev *dev; proc_bus_pci_dir = proc_mkdir("pci", proc_bus); - create_proc_info_entry("devices", 0, proc_bus_pci_dir, - get_pci_dev_info); + entry = create_proc_entry("devices", 0, proc_bus_pci_dir); + if (entry) + entry->proc_fops = &proc_bus_pci_dev_operations; pci_for_each_dev(dev) { pci_proc_attach_device(dev); } - create_proc_read_entry("pci", 0, NULL, pci_read_proc, NULL); + entry = create_proc_entry("pci", 0, NULL); + if (entry) + entry->proc_fops = &proc_pci_operations; } return 0; } diff --git a/fs/inode.c b/fs/inode.c index 29466a625965..38b147dff924 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -66,7 +66,7 @@ static LIST_HEAD(anon_hash_chain); /* for inodes with NULL i_sb */ * NOTE! You also have to own the lock if you change * the i_state of an inode while it is in use.. */ -spinlock_t inode_lock = SPIN_LOCK_UNLOCKED; +static spinlock_t inode_lock = SPIN_LOCK_UNLOCKED; /* * Statistics gathering.. diff --git a/fs/proc/inode.c b/fs/proc/inode.c index 48734c6c75ef..8af8a6868e92 100644 --- a/fs/proc/inode.c +++ b/fs/proc/inode.c @@ -160,14 +160,12 @@ printk("proc_iget: using deleted entry %s, count=%d\n", de->name, atomic_read(&d inode->i_nlink = de->nlink; if (de->owner) __MOD_INC_USE_COUNT(de->owner); - if (S_ISBLK(de->mode)||S_ISCHR(de->mode)||S_ISFIFO(de->mode)) + if (de->proc_iops) + inode->i_op = de->proc_iops; + if (de->proc_fops) + inode->i_fop = de->proc_fops; + else if (S_ISBLK(de->mode)||S_ISCHR(de->mode)||S_ISFIFO(de->mode)) init_special_inode(inode,de->mode,kdev_t_to_nr(de->rdev)); - else { - if (de->proc_iops) - inode->i_op = de->proc_iops; - if (de->proc_fops) - inode->i_fop = de->proc_fops; - } } out: diff --git a/fs/proc/proc_misc.c b/fs/proc/proc_misc.c index ae01df6796f6..504232b00ec2 100644 --- a/fs/proc/proc_misc.c +++ b/fs/proc/proc_misc.c @@ -519,6 +519,14 @@ static struct file_operations proc_mounts_operations = { struct proc_dir_entry *proc_root_kcore; +static void create_seq_entry(char *name, mode_t mode, struct file_operations *f) +{ + struct proc_dir_entry *entry; + entry = create_proc_entry(name, mode, NULL); + if (entry) + entry->proc_fops = f; +} + void __init proc_misc_init(void) { struct proc_dir_entry *entry; @@ -568,16 +576,10 @@ void __init proc_misc_init(void) entry = create_proc_entry("kmsg", S_IRUSR, &proc_root); if (entry) entry->proc_fops = &proc_kmsg_operations; - entry = create_proc_entry("mounts", 0, NULL); - if (entry) - entry->proc_fops = &proc_mounts_operations; - entry = create_proc_entry("cpuinfo", 0, NULL); - if (entry) - entry->proc_fops = &proc_cpuinfo_operations; + create_seq_entry("mounts", 0, &proc_mounts_operations); + create_seq_entry("cpuinfo", 0, &proc_cpuinfo_operations); #ifdef CONFIG_MODULES - entry = create_proc_entry("ksyms", 0, NULL); - if (entry) - entry->proc_fops = &proc_ksyms_operations; + create_seq_entry("ksyms", 0, &proc_ksyms_operations); #endif proc_root_kcore = create_proc_entry("kcore", S_IRUSR, NULL); if (proc_root_kcore) { diff --git a/fs/seq_file.c b/fs/seq_file.c index 8929a841ab37..db6d59acb37d 100644 --- a/fs/seq_file.c +++ b/fs/seq_file.c @@ -73,13 +73,13 @@ ssize_t seq_read(struct file *file, char *buf, size_t size, loff_t *ppos) buf += n; copied += n; if (!m->count) - (*ppos)++; + m->index++; if (!size) goto Done; } /* we need at least one record in buffer */ while (1) { - pos = *ppos; + pos = m->index; p = m->op->start(m, &pos); err = PTR_ERR(p); if (!p || IS_ERR(p)) @@ -125,10 +125,12 @@ Fill: m->from = n; else pos++; - *ppos = pos; + m->index = pos; Done: if (!copied) copied = err; + else + *ppos += copied; up(&m->sem); return copied; Enomem: @@ -139,6 +141,54 @@ Efault: goto Done; } +static int traverse(struct seq_file *m, loff_t offset) +{ + loff_t pos = 0; + int error = 0; + void *p; + + m->index = 0; + m->count = m->from = 0; + if (!offset) + return 0; + if (!m->buf) { + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL); + if (!m->buf) + return -ENOMEM; + } + p = m->op->start(m, &m->index); + while (p) { + error = PTR_ERR(p); + if (IS_ERR(p)) + break; + error = m->op->show(m, p); + if (error) + break; + if (m->count == m->size) + goto Eoverflow; + if (pos + m->count > offset) { + m->from = offset - pos; + m->count -= m->from; + break; + } + pos += m->count; + m->count = 0; + if (pos == offset) { + m->index++; + break; + } + p = m->op->next(m, p, &m->index); + } + m->op->stop(m, p); + return error; + +Eoverflow: + m->op->stop(m, p); + kfree(m->buf); + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL); + return !m->buf ? -ENOMEM : -EAGAIN; +} + /** * seq_lseek - ->llseek() method for sequential files. * @file, @offset, @origin: see file_operations method @@ -157,11 +207,19 @@ loff_t seq_lseek(struct file *file, loff_t offset, int origin) case 0: if (offset < 0) break; + retval = offset; if (offset != file->f_pos) { - file->f_pos = offset; - m->count = 0; + while ((retval=traverse(m, offset)) == -EAGAIN) + ; + if (retval) { + /* with extreme perjudice... */ + file->f_pos = 0; + m->index = 0; + m->count = 0; + } else { + retval = file->f_pos = offset; + } } - retval = offset; } up(&m->sem); return retval; diff --git a/include/asm-ppc/machdep.h b/include/asm-ppc/machdep.h index 1515807a276f..184e7cc8d1af 100644 --- a/include/asm-ppc/machdep.h +++ b/include/asm-ppc/machdep.h @@ -1,5 +1,5 @@ /* - * BK Id: SCCS/s.machdep.h 1.23 10/18/01 11:16:28 trini + * BK Id: SCCS/s.machdep.h 1.25 11/13/01 21:26:07 paulus */ #ifdef __KERNEL__ #ifndef _PPC_MACHDEP_H @@ -14,13 +14,13 @@ struct pt_regs; struct pci_bus; struct pci_dev; +struct seq_file; struct machdep_calls { void (*setup_arch)(void); /* Optional, may be NULL. */ - int (*setup_residual)(char *buffer); - /* Optional, may be NULL. */ - int (*get_cpuinfo)(char *buffer); + int (*show_cpuinfo)(struct seq_file *m); + int (*show_percpuinfo)(struct seq_file *m, int i); /* Optional, may be NULL. */ unsigned int (*irq_cannonicalize)(unsigned int irq); void (*init_IRQ)(void); diff --git a/include/linux/wait.h b/include/linux/wait.h index 52906444f233..3503fd2226c5 100644 --- a/include/linux/wait.h +++ b/include/linux/wait.h @@ -109,12 +109,12 @@ typedef struct __wait_queue_head wait_queue_head_t; } while (0) #define WQ_CHECK_LIST_HEAD(list) \ do { \ - if (!list->next || !list->prev) \ + if (!(list)->next || !(list)->prev) \ WQ_BUG(); \ } while(0) #define WQ_NOTE_WAKER(tsk) \ do { \ - tsk->__waker = (long)__builtin_return_address(0); \ + (tsk)->__waker = (long)__builtin_return_address(0); \ } while (0) #else #define WQ_BUG() diff --git a/scripts/Lindent b/scripts/Lindent index 3980cff2d9d9..0bababd002ae 100644 --- a/scripts/Lindent +++ b/scripts/Lindent @@ -1,2 +1,2 @@ -#!/bin/bash -indent -kr -i8 -ts8 -sob -l80 -ss -bs -psl $@ +#!/bin/sh +indent -kr -i8 -ts8 -sob -l80 -ss -bs -psl "$@" |
