aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CREDITS10
-rw-r--r--Documentation/RCU/whatisRCU.txt5
-rw-r--r--Documentation/SubmitChecklist76
-rw-r--r--Documentation/drivers/edac/edac.txt152
-rw-r--r--Documentation/feature-removal-schedule.txt11
-rw-r--r--Documentation/filesystems/Locking4
-rw-r--r--Documentation/filesystems/vfs.txt4
-rw-r--r--Documentation/nfsroot.txt275
-rw-r--r--MAINTAINERS14
-rw-r--r--arch/alpha/kernel/alpha_ksyms.c1
-rw-r--r--arch/alpha/kernel/process.c1
-rw-r--r--arch/alpha/kernel/setup.c2
-rw-r--r--arch/alpha/kernel/sys_sio.c2
-rw-r--r--arch/arm/kernel/setup.c2
-rw-r--r--arch/arm26/kernel/setup.c2
-rw-r--r--arch/cris/arch-v10/drivers/eeprom.c4
-rw-r--r--arch/cris/arch-v10/drivers/gpio.c2
-rw-r--r--arch/cris/arch-v32/drivers/cryptocop.c2
-rw-r--r--arch/cris/arch-v32/drivers/gpio.c2
-rw-r--r--arch/cris/arch-v32/drivers/pcf8563.c2
-rw-r--r--arch/cris/arch-v32/drivers/sync_serial.c12
-rw-r--r--arch/cris/kernel/setup.c2
-rw-r--r--arch/frv/kernel/asm-offsets.c116
-rw-r--r--arch/frv/kernel/break.S34
-rw-r--r--arch/frv/kernel/debug-stub.c13
-rw-r--r--arch/frv/kernel/entry.S1
-rw-r--r--arch/frv/kernel/gdb-stub.c159
-rw-r--r--arch/frv/kernel/head.S1
-rw-r--r--arch/frv/kernel/local.h3
-rw-r--r--arch/frv/kernel/pm.c5
-rw-r--r--arch/frv/kernel/process.c15
-rw-r--r--arch/frv/kernel/switch_to.S3
-rw-r--r--arch/frv/kernel/traps.c25
-rw-r--r--arch/frv/mb93090-mb00/pci-vdk.c11
-rw-r--r--arch/i386/defconfig2
-rw-r--r--arch/i386/kernel/setup.c2
-rw-r--r--arch/i386/kernel/time.c5
-rw-r--r--arch/i386/kernel/traps.c4
-rw-r--r--arch/i386/oprofile/nmi_int.c5
-rw-r--r--arch/ia64/dig/setup.c2
-rw-r--r--arch/ia64/kernel/efi.c2
-rw-r--r--arch/ia64/kernel/setup.c2
-rw-r--r--arch/ia64/pci/pci.c2
-rw-r--r--arch/ia64/sn/kernel/setup.c2
-rw-r--r--arch/m32r/kernel/setup.c2
-rw-r--r--arch/mips/kernel/irixelf.c2
-rw-r--r--arch/mips/kernel/setup.c2
-rw-r--r--arch/mips/mips-boards/malta/malta_setup.c2
-rw-r--r--arch/mips/sibyte/swarm/setup.c2
-rw-r--r--arch/mips/sni/setup.c2
-rw-r--r--arch/parisc/kernel/pdc_cons.c2
-rw-r--r--arch/powerpc/kernel/ibmebus.c2
-rw-r--r--arch/powerpc/kernel/irq.c47
-rw-r--r--arch/powerpc/kernel/pci_32.c36
-rw-r--r--arch/powerpc/kernel/pci_64.c36
-rw-r--r--arch/powerpc/kernel/ppc_ksyms.c2
-rw-r--r--arch/powerpc/kernel/prom_parse.c2
-rw-r--r--arch/powerpc/kernel/setup-common.c2
-rw-r--r--arch/powerpc/platforms/cell/interrupt.c4
-rw-r--r--arch/powerpc/platforms/cell/spider-pic.c70
-rw-r--r--arch/powerpc/platforms/cell/spu_base.c6
-rw-r--r--arch/powerpc/platforms/iseries/irq.c4
-rw-r--r--arch/powerpc/platforms/powermac/backlight.c31
-rw-r--r--arch/powerpc/platforms/powermac/pci.c13
-rw-r--r--arch/powerpc/platforms/powermac/pic.c8
-rw-r--r--arch/powerpc/platforms/pseries/ras.c3
-rw-r--r--arch/powerpc/platforms/pseries/xics.c34
-rw-r--r--arch/powerpc/sysdev/i8259.c4
-rw-r--r--arch/powerpc/sysdev/mpic.c210
-rw-r--r--arch/ppc/kernel/ppc_ksyms.c2
-rw-r--r--arch/ppc/kernel/setup.c2
-rw-r--r--arch/ppc/platforms/prep_setup.c2
-rw-r--r--arch/s390/Kconfig7
-rw-r--r--arch/s390/kernel/Makefile4
-rw-r--r--arch/sh/kernel/setup.c2
-rw-r--r--arch/sh64/kernel/setup.c2
-rw-r--r--arch/sh64/kernel/sh_ksyms.c2
-rw-r--r--arch/sparc/kernel/setup.c2
-rw-r--r--arch/sparc64/Kconfig2
-rw-r--r--arch/sparc64/kernel/setup.c2
-rw-r--r--arch/um/Kconfig.debug9
-rw-r--r--arch/um/defconfig1
-rw-r--r--arch/um/drivers/mconsole_user.c7
-rw-r--r--arch/um/drivers/net_user.c80
-rw-r--r--arch/um/drivers/tty.c31
-rw-r--r--arch/um/drivers/ubd_kern.c1
-rw-r--r--arch/um/include/irq_user.h9
-rw-r--r--arch/um/include/kern_util.h2
-rw-r--r--arch/um/include/os.h6
-rw-r--r--arch/um/include/skas/mode_kern_skas.h3
-rw-r--r--arch/um/include/tt/mode_kern_tt.h3
-rw-r--r--arch/um/kernel/Makefile10
-rw-r--r--arch/um/kernel/exec.c (renamed from arch/um/kernel/exec_kern.c)13
-rw-r--r--arch/um/kernel/irq.c62
-rw-r--r--arch/um/kernel/ksyms.c6
-rw-r--r--arch/um/kernel/mem.c11
-rw-r--r--arch/um/kernel/physmem.c2
-rw-r--r--arch/um/kernel/sigio.c (renamed from arch/um/kernel/sigio_kern.c)16
-rw-r--r--arch/um/kernel/signal.c (renamed from arch/um/kernel/signal_kern.c)10
-rw-r--r--arch/um/kernel/skas/mem.c24
-rw-r--r--arch/um/kernel/skas/process_kern.c2
-rw-r--r--arch/um/kernel/skas/syscall.c7
-rw-r--r--arch/um/kernel/syscall.c174
-rw-r--r--arch/um/kernel/syscall_kern.c166
-rw-r--r--arch/um/kernel/time.c (renamed from arch/um/kernel/time_kern.c)84
-rw-r--r--arch/um/kernel/trap.c (renamed from arch/um/kernel/trap_kern.c)18
-rw-r--r--arch/um/kernel/tt/exec_kern.c2
-rw-r--r--arch/um/kernel/tt/mem.c21
-rw-r--r--arch/um/kernel/tt/process_kern.c2
-rw-r--r--arch/um/kernel/tt/syscall_kern.c12
-rw-r--r--arch/um/kernel/tt/tracer.c22
-rw-r--r--arch/um/kernel/um_arch.c9
-rw-r--r--arch/um/kernel/uml.lds.S13
-rw-r--r--arch/um/os-Linux/file.c143
-rw-r--r--arch/um/os-Linux/irq.c16
-rw-r--r--arch/um/os-Linux/process.c19
-rw-r--r--arch/um/os-Linux/sigio.c33
-rw-r--r--arch/um/os-Linux/signal.c23
-rw-r--r--arch/um/os-Linux/skas/process.c2
-rw-r--r--arch/um/os-Linux/time.c23
-rw-r--r--arch/x86_64/defconfig36
-rw-r--r--arch/x86_64/ia32/ia32_binfmt.c2
-rw-r--r--arch/x86_64/ia32/ptrace32.c13
-rw-r--r--arch/x86_64/kernel/e820.c1
-rw-r--r--arch/x86_64/kernel/early_printk.c2
-rw-r--r--arch/x86_64/kernel/mce_amd.c2
-rw-r--r--arch/x86_64/kernel/pci-calgary.c6
-rw-r--r--arch/x86_64/kernel/setup.c2
-rw-r--r--arch/x86_64/kernel/smpboot.c4
-rw-r--r--arch/x86_64/kernel/tce.c6
-rw-r--r--arch/x86_64/kernel/traps.c4
-rw-r--r--arch/xtensa/kernel/setup.c2
-rw-r--r--drivers/acpi/thermal.c17
-rw-r--r--drivers/base/Kconfig2
-rw-r--r--drivers/block/aoe/aoechr.c2
-rw-r--r--drivers/bluetooth/bcm203x.c1
-rw-r--r--drivers/cdrom/cdrom.c2
-rw-r--r--drivers/char/hvsi.c2
-rw-r--r--drivers/char/ip2/ip2main.c7
-rw-r--r--drivers/char/mem.c4
-rw-r--r--drivers/char/pc8736x_gpio.c46
-rw-r--r--drivers/char/rtc.c41
-rw-r--r--drivers/char/snsc_event.c15
-rw-r--r--drivers/char/specialix.c6
-rw-r--r--drivers/edac/edac_mc.c687
-rw-r--r--drivers/isdn/hisax/asuscom.c6
-rw-r--r--drivers/isdn/hisax/avm_a1.c2
-rw-r--r--drivers/isdn/hisax/avm_pci.c8
-rw-r--r--drivers/isdn/hisax/bkm_a4t.c4
-rw-r--r--drivers/isdn/hisax/bkm_a8.c16
-rw-r--r--drivers/isdn/hisax/config.c2
-rw-r--r--drivers/isdn/hisax/diva.c14
-rw-r--r--drivers/isdn/hisax/enternow_pci.c4
-rw-r--r--drivers/isdn/hisax/gazel.c8
-rw-r--r--drivers/isdn/hisax/hfc4s8s_l1.c2
-rw-r--r--drivers/isdn/hisax/hfc_2bds0.c4
-rw-r--r--drivers/isdn/hisax/hfc_2bs0.c4
-rw-r--r--drivers/isdn/hisax/hfc_pci.c6
-rw-r--r--drivers/isdn/hisax/hfcscard.c6
-rw-r--r--drivers/isdn/hisax/icc.c8
-rw-r--r--drivers/isdn/hisax/icc.h2
-rw-r--r--drivers/isdn/hisax/ipacx.c18
-rw-r--r--drivers/isdn/hisax/isurf.c4
-rw-r--r--drivers/isdn/hisax/ix1_micro.c6
-rw-r--r--drivers/isdn/hisax/jade.c6
-rw-r--r--drivers/isdn/hisax/mic.c2
-rw-r--r--drivers/isdn/hisax/netjet.c2
-rw-r--r--drivers/isdn/hisax/niccy.c4
-rw-r--r--drivers/isdn/hisax/nj_s.c4
-rw-r--r--drivers/isdn/hisax/nj_u.c4
-rw-r--r--drivers/isdn/hisax/s0box.c2
-rw-r--r--drivers/isdn/hisax/saphir.c2
-rw-r--r--drivers/isdn/hisax/sportster.c4
-rw-r--r--drivers/isdn/hisax/teleint.c2
-rw-r--r--drivers/isdn/hisax/teles0.c2
-rw-r--r--drivers/isdn/hisax/telespci.c4
-rw-r--r--drivers/isdn/hisax/w6692.c10
-rw-r--r--drivers/isdn/i4l/isdn_common.c12
-rw-r--r--drivers/isdn/i4l/isdn_ppp.c2
-rw-r--r--drivers/leds/Kconfig7
-rw-r--r--drivers/leds/Makefile1
-rw-r--r--drivers/leds/leds-net48xx.c115
-rw-r--r--drivers/macintosh/Kconfig5
-rw-r--r--drivers/macintosh/macio_asic.c2
-rw-r--r--drivers/macintosh/smu.c53
-rw-r--r--drivers/md/md.c86
-rw-r--r--drivers/md/raid1.c5
-rw-r--r--drivers/md/raid10.c4
-rw-r--r--drivers/md/raid5.c84
-rw-r--r--drivers/media/dvb/frontends/nxt200x.c4
-rw-r--r--drivers/media/dvb/frontends/or51211.c2
-rw-r--r--drivers/media/dvb/frontends/sp8870.c2
-rw-r--r--drivers/media/dvb/frontends/sp887x.c2
-rw-r--r--drivers/media/video/cx88/cx88-blackbird.c3
-rw-r--r--drivers/message/i2o/core.h3
-rw-r--r--drivers/message/i2o/i2o_config.c4
-rw-r--r--drivers/net/hamradio/bpqether.c7
-rw-r--r--drivers/net/wireless/spectrum_cs.c37
-rw-r--r--drivers/pci/hotplug/Kconfig3
-rw-r--r--drivers/pci/probe.c1
-rw-r--r--drivers/pcmcia/Kconfig2
-rw-r--r--drivers/s390/net/claw.c2
-rw-r--r--drivers/s390/net/netiucv.c2
-rw-r--r--drivers/s390/net/qeth_main.c2
-rw-r--r--drivers/scsi/aic7xxx/aic79xx_osm.h1
-rw-r--r--drivers/usb/storage/transport.c2
-rw-r--r--drivers/video/68328fb.c1
-rw-r--r--drivers/video/S3triofb.c1
-rw-r--r--drivers/video/amifb.c1
-rw-r--r--drivers/video/arcfb.c1
-rw-r--r--drivers/video/asiliantfb.c1
-rw-r--r--drivers/video/atafb.c1
-rw-r--r--drivers/video/aty/aty128fb.c67
-rw-r--r--drivers/video/aty/atyfb_base.c53
-rw-r--r--drivers/video/aty/radeon_base.c1
-rw-r--r--drivers/video/chipsfb.c4
-rw-r--r--drivers/video/cirrusfb.c1
-rw-r--r--drivers/video/console/dummycon.c2
-rw-r--r--drivers/video/console/fbcon.c1
-rw-r--r--drivers/video/console/mdacon.c1
-rw-r--r--drivers/video/console/newport_con.c1
-rw-r--r--drivers/video/console/promcon.c1
-rw-r--r--drivers/video/console/softcursor.c1
-rw-r--r--drivers/video/console/sticon.c1
-rw-r--r--drivers/video/console/vgacon.c2
-rw-r--r--drivers/video/controlfb.c1
-rw-r--r--drivers/video/cyber2000fb.c1
-rw-r--r--drivers/video/cyberfb.c1
-rw-r--r--drivers/video/dnfb.c1
-rw-r--r--drivers/video/epson1355fb.c1
-rw-r--r--drivers/video/fbcmap.c1
-rw-r--r--drivers/video/fbmem.c2
-rw-r--r--drivers/video/fbmon.c1
-rw-r--r--drivers/video/g364fb.c1
-rw-r--r--drivers/video/geode/gx1fb_core.c1
-rw-r--r--drivers/video/geode/gxfb_core.c1
-rw-r--r--drivers/video/hgafb.c1
-rw-r--r--drivers/video/hitfb.c1
-rw-r--r--drivers/video/hpfb.c1
-rw-r--r--drivers/video/i810/i810_main.c1
-rw-r--r--drivers/video/igafb.c1
-rw-r--r--drivers/video/imacfb.c2
-rw-r--r--drivers/video/imsttfb.c1
-rw-r--r--drivers/video/intelfb/intelfbdrv.c2
-rw-r--r--drivers/video/intelfb/intelfbhw.c1
-rw-r--r--drivers/video/kyro/fbdev.c1
-rw-r--r--drivers/video/macfb.c1
-rw-r--r--drivers/video/matrox/matroxfb_base.h1
-rw-r--r--drivers/video/maxinefb.c1
-rw-r--r--drivers/video/modedb.c1
-rw-r--r--drivers/video/neofb.c1
-rw-r--r--drivers/video/nvidia/nv_backlight.c32
-rw-r--r--drivers/video/nvidia/nv_proto.h2
-rw-r--r--drivers/video/nvidia/nvidia.c12
-rw-r--r--drivers/video/offb.c1
-rw-r--r--drivers/video/platinumfb.c1
-rw-r--r--drivers/video/pm2fb.c1
-rw-r--r--drivers/video/pm3fb.c1
-rw-r--r--drivers/video/pmag-aa-fb.c1
-rw-r--r--drivers/video/pvr2fb.c1
-rw-r--r--drivers/video/q40fb.c1
-rw-r--r--drivers/video/retz3fb.c1
-rw-r--r--drivers/video/riva/fbdev.c45
-rw-r--r--drivers/video/s3c2410fb.c1
-rw-r--r--drivers/video/savage/savagefb_driver.c1
-rw-r--r--drivers/video/sis/sis_main.c6
-rw-r--r--drivers/video/skeletonfb.c1
-rw-r--r--drivers/video/sun3fb.c1
-rw-r--r--drivers/video/tdfxfb.c1
-rw-r--r--drivers/video/tgafb.c1
-rw-r--r--drivers/video/tx3912fb.c1
-rw-r--r--drivers/video/valkyriefb.c1
-rw-r--r--drivers/video/vesafb.c2
-rw-r--r--drivers/video/vfb.c1
-rw-r--r--drivers/video/vga16fb.c2
-rw-r--r--drivers/video/virgefb.c1
-rw-r--r--fs/binfmt_elf.c2
-rw-r--r--fs/binfmt_elf_fdpic.c980
-rw-r--r--fs/ext3/acl.h3
-rw-r--r--fs/file.c10
-rw-r--r--fs/hugetlbfs/inode.c4
-rw-r--r--fs/nfsd/nfs4proc.c8
-rw-r--r--fs/nfsd/stats.c10
-rw-r--r--fs/partitions/check.c1
-rw-r--r--fs/proc/kcore.c2
-rw-r--r--fs/ramfs/file-nommu.c4
-rw-r--r--fs/read_write.c2
-rw-r--r--fs/reiserfs/file.c6
-rw-r--r--fs/xfs/linux-2.6/xfs_linux.h1
-rw-r--r--include/asm-frv/elf.h6
-rw-r--r--include/asm-frv/gdb-stub.h22
-rw-r--r--include/asm-frv/ptrace.h12
-rw-r--r--include/asm-frv/registers.h97
-rw-r--r--include/asm-frv/thread_info.h24
-rw-r--r--include/asm-h8300/page.h1
-rw-r--r--include/asm-ia64/io.h2
-rw-r--r--include/asm-mips/mach-dec/mc146818rtc.h2
-rw-r--r--include/asm-powerpc/backlight.h12
-rw-r--r--include/asm-powerpc/irq.h38
-rw-r--r--include/asm-x86_64/calgary.h6
-rw-r--r--include/asm-x86_64/tce.h8
-rw-r--r--include/linux/bootmem.h2
-rw-r--r--include/linux/completion.h5
-rw-r--r--include/linux/console_struct.h1
-rw-r--r--include/linux/elfcore.h10
-rw-r--r--include/linux/fb.h1
-rw-r--r--include/linux/fs.h4
-rw-r--r--include/linux/kernel.h1
-rw-r--r--include/linux/lockdep.h2
-rw-r--r--include/linux/mc146818rtc.h7
-rw-r--r--include/linux/nfs4.h6
-rw-r--r--include/linux/nfsd/stats.h6
-rw-r--r--include/linux/raid/md_k.h3
-rw-r--r--include/linux/rwsem.h17
-rw-r--r--include/linux/tty.h12
-rw-r--r--include/linux/vmstat.h11
-rw-r--r--include/linux/vt.h10
-rw-r--r--include/linux/vt_kern.h1
-rw-r--r--include/linux/wait.h12
-rw-r--r--kernel/fork.c4
-rw-r--r--kernel/futex.c6
-rw-r--r--kernel/lockdep.c136
-rw-r--r--kernel/panic.c2
-rw-r--r--kernel/power/snapshot.c10
-rw-r--r--kernel/power/swap.c26
-rw-r--r--kernel/printk.c4
-rw-r--r--kernel/sched.c19
-rw-r--r--kernel/softirq.c2
-rw-r--r--kernel/timer.c85
-rw-r--r--kernel/wait.c8
-rw-r--r--mm/bootmem.c4
-rw-r--r--mm/fadvise.c12
-rw-r--r--mm/memory.c2
-rw-r--r--mm/mmzone.c6
-rw-r--r--mm/vmstat.c1
-rw-r--r--net/ax25/ax25_in.c2
-rw-r--r--net/dccp/proto.c4
-rw-r--r--net/ipv4/Kconfig10
-rw-r--r--net/ipv4/Makefile1
-rw-r--r--net/ipv4/inetpeer.c2
-rw-r--r--net/ipv4/tcp_compound.c448
-rw-r--r--security/selinux/hooks.c129
-rw-r--r--security/selinux/include/objsec.h3
-rw-r--r--sound/aoa/Makefile4
-rw-r--r--sound/aoa/codecs/snd-aoa-codec-tas-basstreble.h134
-rw-r--r--sound/aoa/codecs/snd-aoa-codec-tas.c331
-rw-r--r--sound/aoa/codecs/snd-aoa-codec-tas.h8
-rw-r--r--sound/aoa/core/snd-aoa-gpio-pmf.c14
-rw-r--r--sound/aoa/fabrics/snd-aoa-fabric-layout.c26
-rw-r--r--sound/aoa/soundbus/core.c22
-rw-r--r--sound/aoa/soundbus/i2sbus/i2sbus-control.c79
-rw-r--r--sound/aoa/soundbus/i2sbus/i2sbus-control.h37
-rw-r--r--sound/aoa/soundbus/i2sbus/i2sbus-core.c129
-rw-r--r--sound/aoa/soundbus/i2sbus/i2sbus.h18
354 files changed, 4199 insertions, 3387 deletions
diff --git a/CREDITS b/CREDITS
index 66b9e7a9abff..29be6d1fdf49 100644
--- a/CREDITS
+++ b/CREDITS
@@ -528,11 +528,11 @@ S: Oxford
528S: United Kingdom 528S: United Kingdom
529 529
530N: Luiz Fernando N. Capitulino 530N: Luiz Fernando N. Capitulino
531E: lcapitulino@terra.com.br 531E: lcapitulino@mandriva.com.br
532E: lcapitulino@prefeitura.sp.gov.br 532E: lcapitulino@gmail.com
533W: http://www.telecentros.sp.gov.br 533W: http://www.cpu.eti.br
534D: Little fixes and a lot of janitorial work 534D: misc kernel hacking
535S: E-GOV Telecentros SP 535S: Mandriva
536S: Brazil 536S: Brazil
537 537
538N: Remy Card 538N: Remy Card
diff --git a/Documentation/RCU/whatisRCU.txt b/Documentation/RCU/whatisRCU.txt
index 4f41a60e5111..318df44259b3 100644
--- a/Documentation/RCU/whatisRCU.txt
+++ b/Documentation/RCU/whatisRCU.txt
@@ -687,8 +687,9 @@ diff shows how closely related RCU and reader-writer locking can be.
687 + spin_lock(&listmutex); 687 + spin_lock(&listmutex);
688 list_for_each_entry(p, head, lp) { 688 list_for_each_entry(p, head, lp) {
689 if (p->key == key) { 689 if (p->key == key) {
690 list_del(&p->list); 690 - list_del(&p->list);
691 - write_unlock(&listmutex); 691 - write_unlock(&listmutex);
692 + list_del_rcu(&p->list);
692 + spin_unlock(&listmutex); 693 + spin_unlock(&listmutex);
693 + synchronize_rcu(); 694 + synchronize_rcu();
694 kfree(p); 695 kfree(p);
@@ -736,7 +737,7 @@ Or, for those who prefer a side-by-side listing:
736 5 write_lock(&listmutex); 5 spin_lock(&listmutex); 737 5 write_lock(&listmutex); 5 spin_lock(&listmutex);
737 6 list_for_each_entry(p, head, lp) { 6 list_for_each_entry(p, head, lp) { 738 6 list_for_each_entry(p, head, lp) { 6 list_for_each_entry(p, head, lp) {
738 7 if (p->key == key) { 7 if (p->key == key) { 739 7 if (p->key == key) { 7 if (p->key == key) {
739 8 list_del(&p->list); 8 list_del(&p->list); 740 8 list_del(&p->list); 8 list_del_rcu(&p->list);
740 9 write_unlock(&listmutex); 9 spin_unlock(&listmutex); 741 9 write_unlock(&listmutex); 9 spin_unlock(&listmutex);
741 10 synchronize_rcu(); 742 10 synchronize_rcu();
74210 kfree(p); 11 kfree(p); 74310 kfree(p); 11 kfree(p);
diff --git a/Documentation/SubmitChecklist b/Documentation/SubmitChecklist
index 8230098da529..a10bfb6ecd9f 100644
--- a/Documentation/SubmitChecklist
+++ b/Documentation/SubmitChecklist
@@ -1,57 +1,63 @@
1Linux Kernel patch sumbittal checklist 1Linux Kernel patch sumbittal checklist
2~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3 3
4Here are some basic things that developers should do if they 4Here are some basic things that developers should do if they want to see their
5want to see their kernel patch submittals accepted quicker. 5kernel patch submissions accepted more quickly.
6 6
7These are all above and beyond the documentation that is provided 7These are all above and beyond the documentation that is provided in
8in Documentation/SubmittingPatches and elsewhere about submitting 8Documentation/SubmittingPatches and elsewhere regarding submitting Linux
9Linux kernel patches. 9kernel patches.
10 10
11 11
12 12
13- Builds cleanly with applicable or modified CONFIG options =y, =m, and =n. 131: Builds cleanly with applicable or modified CONFIG options =y, =m, and
14 No gcc warnings/errors, no linker warnings/errors. 14 =n. No gcc warnings/errors, no linker warnings/errors.
15 15
16- Passes allnoconfig, allmodconfig 162: Passes allnoconfig, allmodconfig
17 17
18- Builds on multiple CPU arch-es by using local cross-compile tools 183: Builds on multiple CPU architectures by using local cross-compile tools
19 or something like PLM at OSDL. 19 or something like PLM at OSDL.
20 20
21- ppc64 is a good architecture for cross-compilation checking because it 214: ppc64 is a good architecture for cross-compilation checking because it
22 tends to use `unsigned long' for 64-bit quantities. 22 tends to use `unsigned long' for 64-bit quantities.
23 23
24- Matches kernel coding style(!) 245: Matches kernel coding style(!)
25 25
26- Any new or modified CONFIG options don't muck up the config menu. 266: Any new or modified CONFIG options don't muck up the config menu.
27 27
28- All new Kconfig options have help text. 287: All new Kconfig options have help text.
29 29
30- Has been carefully reviewed with respect to relevant Kconfig 308: Has been carefully reviewed with respect to relevant Kconfig
31 combinations. This is very hard to get right with testing -- 31 combinations. This is very hard to get right with testing -- brainpower
32 brainpower pays off here. 32 pays off here.
33 33
34- Check cleanly with sparse. 349: Check cleanly with sparse.
35 35
36- Use 'make checkstack' and 'make namespacecheck' and fix any 3610: Use 'make checkstack' and 'make namespacecheck' and fix any problems
37 problems that they find. Note: checkstack does not point out 37 that they find. Note: checkstack does not point out problems explicitly,
38 problems explicitly, but any one function that uses more than 38 but any one function that uses more than 512 bytes on the stack is a
39 512 bytes on the stack is a candidate for change. 39 candidate for change.
40 40
41- Include kernel-doc to document global kernel APIs. (Not required 4111: Include kernel-doc to document global kernel APIs. (Not required for
42 for static functions, but OK there also.) Use 'make htmldocs' 42 static functions, but OK there also.) Use 'make htmldocs' or 'make
43 or 'make mandocs' to check the kernel-doc and fix any issues. 43 mandocs' to check the kernel-doc and fix any issues.
44 44
45- Has been tested with CONFIG_PREEMPT, CONFIG_DEBUG_PREEMPT, 4512: Has been tested with CONFIG_PREEMPT, CONFIG_DEBUG_PREEMPT,
46 CONFIG_DEBUG_SLAB, CONFIG_DEBUG_PAGEALLOC, CONFIG_DEBUG_MUTEXES, 46 CONFIG_DEBUG_SLAB, CONFIG_DEBUG_PAGEALLOC, CONFIG_DEBUG_MUTEXES,
47 CONFIG_DEBUG_SPINLOCK, CONFIG_DEBUG_SPINLOCK_SLEEP all simultaneously 47 CONFIG_DEBUG_SPINLOCK, CONFIG_DEBUG_SPINLOCK_SLEEP all simultaneously
48 enabled. 48 enabled.
49 49
50- Has been build- and runtime tested with and without CONFIG_SMP and 5013: Has been build- and runtime tested with and without CONFIG_SMP and
51 CONFIG_PREEMPT. 51 CONFIG_PREEMPT.
52 52
53- If the patch affects IO/Disk, etc: has been tested with and without 5314: If the patch affects IO/Disk, etc: has been tested with and without
54 CONFIG_LBD. 54 CONFIG_LBD.
55 55
5615: All codepaths have been exercised with all lockdep features enabled.
56 57
572006-APR-27 5816: All new /proc entries are documented under Documentation/
59
6017: All new kernel boot parameters are documented in
61 Documentation/kernel-parameters.txt.
62
6318: All new module parameters are documented with MODULE_PARM_DESC()
diff --git a/Documentation/drivers/edac/edac.txt b/Documentation/drivers/edac/edac.txt
index 70d96a62e5e1..7b3d969d2964 100644
--- a/Documentation/drivers/edac/edac.txt
+++ b/Documentation/drivers/edac/edac.txt
@@ -35,15 +35,14 @@ the vendor should tie the parity status bits to 0 if they do not intend
35to generate parity. Some vendors do not do this, and thus the parity bit 35to generate parity. Some vendors do not do this, and thus the parity bit
36can "float" giving false positives. 36can "float" giving false positives.
37 37
38The PCI Parity EDAC device has the ability to "skip" known flaky 38[There are patches in the kernel queue which will allow for storage of
39cards during the parity scan. These are set by the parity "blacklist" 39quirks of PCI devices reporting false parity positives. The 2.6.18
40interface in the sysfs for PCI Parity. (See the PCI section in the sysfs 40kernel should have those patches included. When that becomes available,
41section below.) There is also a parity "whitelist" which is used as 41then EDAC will be patched to utilize that information to "skip" such
42an explicit list of devices to scan, while the blacklist is a list 42devices.]
43of devices to skip.
44 43
45EDAC will have future error detectors that will be added or integrated 44EDAC will have future error detectors that will be integrated with
46into EDAC in the following list: 45EDAC or added to it, in the following list:
47 46
48 MCE Machine Check Exception 47 MCE Machine Check Exception
49 MCA Machine Check Architecture 48 MCA Machine Check Architecture
@@ -93,22 +92,24 @@ EDAC lives in the /sys/devices/system/edac directory. Within this directory
93there currently reside 2 'edac' components: 92there currently reside 2 'edac' components:
94 93
95 mc memory controller(s) system 94 mc memory controller(s) system
96 pci PCI status system 95 pci PCI control and status system
97 96
98 97
99============================================================================ 98============================================================================
100Memory Controller (mc) Model 99Memory Controller (mc) Model
101 100
102First a background on the memory controller's model abstracted in EDAC. 101First a background on the memory controller's model abstracted in EDAC.
103Each mc device controls a set of DIMM memory modules. These modules are 102Each 'mc' device controls a set of DIMM memory modules. These modules are
104laid out in a Chip-Select Row (csrowX) and Channel table (chX). There can 103laid out in a Chip-Select Row (csrowX) and Channel table (chX). There can
105be multiple csrows and two channels. 104be multiple csrows and multiple channels.
106 105
107Memory controllers allow for several csrows, with 8 csrows being a typical value. 106Memory controllers allow for several csrows, with 8 csrows being a typical value.
108Yet, the actual number of csrows depends on the electrical "loading" 107Yet, the actual number of csrows depends on the electrical "loading"
109of a given motherboard, memory controller and DIMM characteristics. 108of a given motherboard, memory controller and DIMM characteristics.
110 109
111Dual channels allows for 128 bit data transfers to the CPU from memory. 110Dual channels allows for 128 bit data transfers to the CPU from memory.
111Some newer chipsets allow for more than 2 channels, like Fully Buffered DIMMs
112(FB-DIMMs). The following example will assume 2 channels:
112 113
113 114
114 Channel 0 Channel 1 115 Channel 0 Channel 1
@@ -234,23 +235,15 @@ Polling period control file:
234 The time period, in milliseconds, for polling for error information. 235 The time period, in milliseconds, for polling for error information.
235 Too small a value wastes resources. Too large a value might delay 236 Too small a value wastes resources. Too large a value might delay
236 necessary handling of errors and might loose valuable information for 237 necessary handling of errors and might loose valuable information for
237 locating the error. 1000 milliseconds (once each second) is about 238 locating the error. 1000 milliseconds (once each second) is the current
238 right for most uses. 239 default. Systems which require all the bandwidth they can get, may
240 increase this.
239 241
240 LOAD TIME: module/kernel parameter: poll_msec=[0|1] 242 LOAD TIME: module/kernel parameter: poll_msec=[0|1]
241 243
242 RUN TIME: echo "1000" >/sys/devices/system/edac/mc/poll_msec 244 RUN TIME: echo "1000" >/sys/devices/system/edac/mc/poll_msec
243 245
244 246
245Module Version read-only attribute file:
246
247 'mc_version'
248
249 The EDAC CORE module's version and compile date are shown here to
250 indicate what EDAC is running.
251
252
253
254============================================================================ 247============================================================================
255'mcX' DIRECTORIES 248'mcX' DIRECTORIES
256 249
@@ -284,35 +277,6 @@ Seconds since last counter reset control file:
284 277
285 278
286 279
287DIMM capability attribute file:
288
289 'edac_capability'
290
291 The EDAC (Error Detection and Correction) capabilities/modes of
292 the memory controller hardware.
293
294
295DIMM Current Capability attribute file:
296
297 'edac_current_capability'
298
299 The EDAC capabilities available with the hardware
300 configuration. This may not be the same as "EDAC capability"
301 if the correct memory is not used. If a memory controller is
302 capable of EDAC, but DIMMs without check bits are in use, then
303 Parity, SECDED, S4ECD4ED capabilities will not be available
304 even though the memory controller might be capable of those
305 modes with the proper memory loaded.
306
307
308Memory Type supported on this controller attribute file:
309
310 'supported_mem_type'
311
312 This attribute file displays the memory type, usually
313 buffered and unbuffered DIMMs.
314
315
316Memory Controller name attribute file: 280Memory Controller name attribute file:
317 281
318 'mc_name' 282 'mc_name'
@@ -321,16 +285,6 @@ Memory Controller name attribute file:
321 that is being utilized. 285 that is being utilized.
322 286
323 287
324Memory Controller Module name attribute file:
325
326 'module_name'
327
328 This attribute file displays the memory controller module name,
329 version and date built. The name of the memory controller
330 hardware - some drivers work with multiple controllers and
331 this field shows which hardware is present.
332
333
334Total memory managed by this memory controller attribute file: 288Total memory managed by this memory controller attribute file:
335 289
336 'size_mb' 290 'size_mb'
@@ -432,6 +386,9 @@ Memory Type attribute file:
432 386
433 This attribute file will display what type of memory is currently 387 This attribute file will display what type of memory is currently
434 on this csrow. Normally, either buffered or unbuffered memory. 388 on this csrow. Normally, either buffered or unbuffered memory.
389 Examples:
390 Registered-DDR
391 Unbuffered-DDR
435 392
436 393
437EDAC Mode of operation attribute file: 394EDAC Mode of operation attribute file:
@@ -446,8 +403,13 @@ Device type attribute file:
446 403
447 'dev_type' 404 'dev_type'
448 405
449 This attribute file will display what type of DIMM device is 406 This attribute file will display what type of DRAM device is
450 being utilized. Example: x4 407 being utilized on this DIMM.
408 Examples:
409 x1
410 x2
411 x4
412 x8
451 413
452 414
453Channel 0 CE Count attribute file: 415Channel 0 CE Count attribute file:
@@ -522,10 +484,10 @@ SYSTEM LOGGING
522If logging for UEs and CEs are enabled then system logs will have 484If logging for UEs and CEs are enabled then system logs will have
523error notices indicating errors that have been detected: 485error notices indicating errors that have been detected:
524 486
525MC0: CE page 0x283, offset 0xce0, grain 8, syndrome 0x6ec3, row 0, 487EDAC MC0: CE page 0x283, offset 0xce0, grain 8, syndrome 0x6ec3, row 0,
526channel 1 "DIMM_B1": amd76x_edac 488channel 1 "DIMM_B1": amd76x_edac
527 489
528MC0: CE page 0x1e5, offset 0xfb0, grain 8, syndrome 0xb741, row 0, 490EDAC MC0: CE page 0x1e5, offset 0xfb0, grain 8, syndrome 0xb741, row 0,
529channel 1 "DIMM_B1": amd76x_edac 491channel 1 "DIMM_B1": amd76x_edac
530 492
531 493
@@ -610,64 +572,4 @@ Parity Count:
610 572
611 573
612 574
613PCI Device Whitelist:
614
615 'pci_parity_whitelist'
616
617 This control file allows for an explicit list of PCI devices to be
618 scanned for parity errors. Only devices found on this list will
619 be examined. The list is a line of hexadecimal VENDOR and DEVICE
620 ID tuples:
621
622 1022:7450,1434:16a6
623
624 One or more can be inserted, separated by a comma.
625
626 To write the above list doing the following as one command line:
627
628 echo "1022:7450,1434:16a6"
629 > /sys/devices/system/edac/pci/pci_parity_whitelist
630
631
632
633 To display what the whitelist is, simply 'cat' the same file.
634
635
636PCI Device Blacklist:
637
638 'pci_parity_blacklist'
639
640 This control file allows for a list of PCI devices to be
641 skipped for scanning.
642 The list is a line of hexadecimal VENDOR and DEVICE ID tuples:
643
644 1022:7450,1434:16a6
645
646 One or more can be inserted, separated by a comma.
647
648 To write the above list doing the following as one command line:
649
650 echo "1022:7450,1434:16a6"
651 > /sys/devices/system/edac/pci/pci_parity_blacklist
652
653
654 To display what the whitelist currently contains,
655 simply 'cat' the same file.
656
657======================================================================= 575=======================================================================
658
659PCI Vendor and Devices IDs can be obtained with the lspci command. Using
660the -n option lspci will display the vendor and device IDs. The system
661administrator will have to determine which devices should be scanned or
662skipped.
663
664
665
666The two lists (white and black) are prioritized. blacklist is the lower
667priority and will NOT be utilized when a whitelist has been set.
668Turn OFF a whitelist by an empty echo command:
669
670 echo > /sys/devices/system/edac/pci/pci_parity_whitelist
671
672and any previous blacklist will be utilized.
673
diff --git a/Documentation/feature-removal-schedule.txt b/Documentation/feature-removal-schedule.txt
index 99f219a01e0e..ee287988934e 100644
--- a/Documentation/feature-removal-schedule.txt
+++ b/Documentation/feature-removal-schedule.txt
@@ -166,17 +166,6 @@ Who: Arjan van de Ven <arjan@linux.intel.com>
166 166
167--------------------------- 167---------------------------
168 168
169What: remove EXPORT_SYMBOL(tasklist_lock)
170When: August 2006
171Files: kernel/fork.c
172Why: tasklist_lock protects the kernel internal task list. Modules have
173 no business looking at it, and all instances in drivers have been due
174 to use of too-lowlevel APIs. Having this symbol exported prevents
175 moving to more scalable locking schemes for the task list.
176Who: Christoph Hellwig <hch@lst.de>
177
178---------------------------
179
180What: mount/umount uevents 169What: mount/umount uevents
181When: February 2007 170When: February 2007
182Why: These events are not correct, and do not properly let userspace know 171Why: These events are not correct, and do not properly let userspace know
diff --git a/Documentation/filesystems/Locking b/Documentation/filesystems/Locking
index d31efbbdfe50..247d7f619aa2 100644
--- a/Documentation/filesystems/Locking
+++ b/Documentation/filesystems/Locking
@@ -142,8 +142,8 @@ see also dquot_operations section.
142 142
143--------------------------- file_system_type --------------------------- 143--------------------------- file_system_type ---------------------------
144prototypes: 144prototypes:
145 struct int (*get_sb) (struct file_system_type *, int, 145 int (*get_sb) (struct file_system_type *, int,
146 const char *, void *, struct vfsmount *); 146 const char *, void *, struct vfsmount *);
147 void (*kill_sb) (struct super_block *); 147 void (*kill_sb) (struct super_block *);
148locking rules: 148locking rules:
149 may block BKL 149 may block BKL
diff --git a/Documentation/filesystems/vfs.txt b/Documentation/filesystems/vfs.txt
index 9d3aed628bc1..1cb7e8be927a 100644
--- a/Documentation/filesystems/vfs.txt
+++ b/Documentation/filesystems/vfs.txt
@@ -113,8 +113,8 @@ members are defined:
113struct file_system_type { 113struct file_system_type {
114 const char *name; 114 const char *name;
115 int fs_flags; 115 int fs_flags;
116 struct int (*get_sb) (struct file_system_type *, int, 116 int (*get_sb) (struct file_system_type *, int,
117 const char *, void *, struct vfsmount *); 117 const char *, void *, struct vfsmount *);
118 void (*kill_sb) (struct super_block *); 118 void (*kill_sb) (struct super_block *);
119 struct module *owner; 119 struct module *owner;
120 struct file_system_type * next; 120 struct file_system_type * next;
diff --git a/Documentation/nfsroot.txt b/Documentation/nfsroot.txt
index d56dc71d9430..3cc953cb288f 100644
--- a/Documentation/nfsroot.txt
+++ b/Documentation/nfsroot.txt
@@ -4,15 +4,16 @@ Mounting the root filesystem via NFS (nfsroot)
4Written 1996 by Gero Kuhlmann <gero@gkminix.han.de> 4Written 1996 by Gero Kuhlmann <gero@gkminix.han.de>
5Updated 1997 by Martin Mares <mj@atrey.karlin.mff.cuni.cz> 5Updated 1997 by Martin Mares <mj@atrey.karlin.mff.cuni.cz>
6Updated 2006 by Nico Schottelius <nico-kernel-nfsroot@schottelius.org> 6Updated 2006 by Nico Schottelius <nico-kernel-nfsroot@schottelius.org>
7Updated 2006 by Horms <horms@verge.net.au>
7 8
8 9
9 10
10If you want to use a diskless system, as an X-terminal or printer 11In order to use a diskless system, such as an X-terminal or printer server
11server for example, you have to put your root filesystem onto a 12for example, it is necessary for the root filesystem to be present on a
12non-disk device. This can either be a ramdisk (see initrd.txt in 13non-disk device. This may be an initramfs (see Documentation/filesystems/
13this directory for further information) or a filesystem mounted 14ramfs-rootfs-initramfs.txt), a ramdisk (see Documenation/initrd.txt) or a
14via NFS. The following text describes on how to use NFS for the 15filesystem mounted via NFS. The following text describes on how to use NFS
15root filesystem. For the rest of this text 'client' means the 16for the root filesystem. For the rest of this text 'client' means the
16diskless system, and 'server' means the NFS server. 17diskless system, and 'server' means the NFS server.
17 18
18 19
@@ -21,11 +22,13 @@ diskless system, and 'server' means the NFS server.
211.) Enabling nfsroot capabilities 221.) Enabling nfsroot capabilities
22 ----------------------------- 23 -----------------------------
23 24
24In order to use nfsroot you have to select support for NFS during 25In order to use nfsroot, NFS client support needs to be selected as
25kernel configuration. Note that NFS cannot be loaded as a module 26built-in during configuration. Once this has been selected, the nfsroot
26in this case. The configuration script will then ask you whether 27option will become available, which should also be selected.
27you want to use nfsroot, and if yes what kind of auto configuration 28
28system you want to use. Selecting both BOOTP and RARP is safe. 29In the networking options, kernel level autoconfiguration can be selected,
30along with the types of autoconfiguration to support. Selecting all of
31DHCP, BOOTP and RARP is safe.
29 32
30 33
31 34
@@ -33,11 +36,10 @@ system you want to use. Selecting both BOOTP and RARP is safe.
332.) Kernel command line 362.) Kernel command line
34 ------------------- 37 -------------------
35 38
36When the kernel has been loaded by a boot loader (either by loadlin, 39When the kernel has been loaded by a boot loader (see below) it needs to be
37LILO or a network boot program) it has to be told what root fs device 40told what root fs device to use. And in the case of nfsroot, where to find
38to use, and where to find the server and the name of the directory 41both the server and the name of the directory on the server to mount as root.
39on the server to mount as root. This can be established by a couple 42This can be established using the following kernel command line parameters:
40of kernel command line parameters:
41 43
42 44
43root=/dev/nfs 45root=/dev/nfs
@@ -49,23 +51,21 @@ root=/dev/nfs
49 51
50nfsroot=[<server-ip>:]<root-dir>[,<nfs-options>] 52nfsroot=[<server-ip>:]<root-dir>[,<nfs-options>]
51 53
52 If the `nfsroot' parameter is NOT given on the command line, the default 54 If the `nfsroot' parameter is NOT given on the command line,
53 "/tftpboot/%s" will be used. 55 the default "/tftpboot/%s" will be used.
54 56
55 <server-ip> Specifies the IP address of the NFS server. If this field 57 <server-ip> Specifies the IP address of the NFS server.
56 is not given, the default address as determined by the 58 The default address is determined by the `ip' parameter
57 `ip' variable (see below) is used. One use of this 59 (see below). This parameter allows the use of different
58 parameter is for example to allow using different servers 60 servers for IP autoconfiguration and NFS.
59 for RARP and NFS. Usually you can leave this blank.
60 61
61 <root-dir> Name of the directory on the server to mount as root. If 62 <root-dir> Name of the directory on the server to mount as root.
62 there is a "%s" token in the string, the token will be 63 If there is a "%s" token in the string, it will be
63 replaced by the ASCII-representation of the client's IP 64 replaced by the ASCII-representation of the client's
64 address. 65 IP address.
65 66
66 <nfs-options> Standard NFS options. All options are separated by commas. 67 <nfs-options> Standard NFS options. All options are separated by commas.
67 If the options field is not given, the following defaults 68 The following defaults are used:
68 will be used:
69 port = as given by server portmap daemon 69 port = as given by server portmap daemon
70 rsize = 1024 70 rsize = 1024
71 wsize = 1024 71 wsize = 1024
@@ -81,129 +81,174 @@ nfsroot=[<server-ip>:]<root-dir>[,<nfs-options>]
81ip=<client-ip>:<server-ip>:<gw-ip>:<netmask>:<hostname>:<device>:<autoconf> 81ip=<client-ip>:<server-ip>:<gw-ip>:<netmask>:<hostname>:<device>:<autoconf>
82 82
83 This parameter tells the kernel how to configure IP addresses of devices 83 This parameter tells the kernel how to configure IP addresses of devices
84 and also how to set up the IP routing table. It was originally called `nfsaddrs', 84 and also how to set up the IP routing table. It was originally called
85 but now the boot-time IP configuration works independently of NFS, so it 85 `nfsaddrs', but now the boot-time IP configuration works independently of
86 was renamed to `ip' and the old name remained as an alias for compatibility 86 NFS, so it was renamed to `ip' and the old name remained as an alias for
87 reasons. 87 compatibility reasons.
88 88
89 If this parameter is missing from the kernel command line, all fields are 89 If this parameter is missing from the kernel command line, all fields are
90 assumed to be empty, and the defaults mentioned below apply. In general 90 assumed to be empty, and the defaults mentioned below apply. In general
91 this means that the kernel tries to configure everything using both 91 this means that the kernel tries to configure everything using
92 RARP and BOOTP (depending on what has been enabled during kernel confi- 92 autoconfiguration.
93 guration, and if both what protocol answer got in first). 93
94 The <autoconf> parameter can appear alone as the value to the `ip'
95 parameter (without all the ':' characters before) in which case auto-
96 configuration is used.
97
98 <client-ip> IP address of the client.
94 99
95 <client-ip> IP address of the client. If empty, the address will either 100 Default: Determined using autoconfiguration.
96 be determined by RARP or BOOTP. What protocol is used de-
97 pends on what has been enabled during kernel configuration
98 and on the <autoconf> parameter. If this parameter is not
99 empty, neither RARP nor BOOTP will be used.
100 101
101 <server-ip> IP address of the NFS server. If RARP is used to determine 102 <server-ip> IP address of the NFS server. If RARP is used to determine
102 the client address and this parameter is NOT empty only 103 the client address and this parameter is NOT empty only
103 replies from the specified server are accepted. To use 104 replies from the specified server are accepted.
104 different RARP and NFS server, specify your RARP server 105
105 here (or leave it blank), and specify your NFS server in 106 Only required for for NFS root. That is autoconfiguration
106 the `nfsroot' parameter (see above). If this entry is blank 107 will not be triggered if it is missing and NFS root is not
107 the address of the server is used which answered the RARP 108 in operation.
108 or BOOTP request. 109
109 110 Default: Determined using autoconfiguration.
110 <gw-ip> IP address of a gateway if the server is on a different 111 The address of the autoconfiguration server is used.
111 subnet. If this entry is empty no gateway is used and the 112
112 server is assumed to be on the local network, unless a 113 <gw-ip> IP address of a gateway if the server is on a different subnet.
113 value has been received by BOOTP. 114
114 115 Default: Determined using autoconfiguration.
115 <netmask> Netmask for local network interface. If this is empty, 116
117 <netmask> Netmask for local network interface. If unspecified
116 the netmask is derived from the client IP address assuming 118 the netmask is derived from the client IP address assuming
117 classful addressing, unless overridden in BOOTP reply. 119 classful addressing.
118 120
119 <hostname> Name of the client. If empty, the client IP address is 121 Default: Determined using autoconfiguration.
120 used in ASCII notation, or the value received by BOOTP.
121 122
122 <device> Name of network device to use. If this is empty, all 123 <hostname> Name of the client. May be supplied by autoconfiguration,
123 devices are used for RARP and BOOTP requests, and the 124 but its absence will not trigger autoconfiguration.
124 first one we receive a reply on is configured. If you have
125 only one device, you can safely leave this blank.
126 125
127 <autoconf> Method to use for autoconfiguration. If this is either 126 Default: Client IP address is used in ASCII notation.
128 'rarp' or 'bootp', the specified protocol is used.
129 If the value is 'both' or empty, both protocols are used
130 so far as they have been enabled during kernel configura-
131 tion. 'off' means no autoconfiguration.
132 127
133 The <autoconf> parameter can appear alone as the value to the `ip' 128 <device> Name of network device to use.
134 parameter (without all the ':' characters before) in which case auto- 129
135 configuration is used. 130 Default: If the host only has one device, it is used.
131 Otherwise the device is determined using
132 autoconfiguration. This is done by sending
133 autoconfiguration requests out of all devices,
134 and using the device that received the first reply.
136 135
136 <autoconf> Method to use for autoconfiguration. In the case of options
137 which specify multiple autoconfiguration protocols,
138 requests are sent using all protocols, and the first one
139 to reply is used.
137 140
141 Only autoconfiguration protocols that have been compiled
142 into the kernel will be used, regardless of the value of
143 this option.
138 144
145 off or none: don't use autoconfiguration (default)
146 on or any: use any protocol available in the kernel
147 dhcp: use DHCP
148 bootp: use BOOTP
149 rarp: use RARP
150 both: use both BOOTP and RARP but not DHCP
151 (old option kept for backwards compatibility)
139 152
1403.) Kernel loader 153 Default: any
141 -------------
142 154
143To get the kernel into memory different approaches can be used. They
144depend on what facilities are available:
145 155
146 156
1473.1) Writing the kernel onto a floppy using dd:
148 As always you can just write the kernel onto a floppy using dd,
149 but then it's not possible to use kernel command lines at all.
150 To substitute the 'root=' parameter, create a dummy device on any
151 linux system with major number 0 and minor number 255 using mknod:
152 157
153 mknod /dev/boot255 c 0 255 1583.) Boot Loader
159 ----------
154 160
155 Then copy the kernel zImage file onto a floppy using dd: 161To get the kernel into memory different approaches can be used.
162They depend on various facilities being available:
156 163
157 dd if=/usr/src/linux/arch/i386/boot/zImage of=/dev/fd0
158 164
159 And finally use rdev to set the root device: 1653.1) Booting from a floppy using syslinux
160 166
161 rdev /dev/fd0 /dev/boot255 167 When building kernels, an easy way to create a boot floppy that uses
168 syslinux is to use the zdisk or bzdisk make targets which use
169 and bzimage images respectively. Both targets accept the
170 FDARGS parameter which can be used to set the kernel command line.
162 171
163 You can then remove the dummy device /dev/boot255 again. There 172 e.g.
164 is no real device available for it. 173 make bzdisk FDARGS="root=/dev/nfs"
165 The other two kernel command line parameters cannot be substi- 174
166 tuted with rdev. Therefore, using this method the kernel will 175 Note that the user running this command will need to have
167 by default use RARP and/or BOOTP, and if it gets an answer via 176 access to the floppy drive device, /dev/fd0
168 RARP will mount the directory /tftpboot/<client-ip>/ as its 177
169 root. If it got a BOOTP answer the directory name in that answer 178 For more information on syslinux, including how to create bootdisks
170 is used. 179 for prebuilt kernels, see http://syslinux.zytor.com/
180
181 N.B: Previously it was possible to write a kernel directly to
182 a floppy using dd, configure the boot device using rdev, and
183 boot using the resulting floppy. Linux no longer supports this
184 method of booting.
185
1863.2) Booting from a cdrom using isolinux
187
188 When building kernels, an easy way to create a bootable cdrom that
189 uses isolinux is to use the isoimage target which uses a bzimage
190 image. Like zdisk and bzdisk, this target accepts the FDARGS
191 parameter which can be used to set the kernel command line.
192
193 e.g.
194 make isoimage FDARGS="root=/dev/nfs"
195
196 The resulting iso image will be arch/<ARCH>/boot/image.iso
197 This can be written to a cdrom using a variety of tools including
198 cdrecord.
199
200 e.g.
201 cdrecord dev=ATAPI:1,0,0 arch/i386/boot/image.iso
202
203 For more information on isolinux, including how to create bootdisks
204 for prebuilt kernels, see http://syslinux.zytor.com/
171 205
1723.2) Using LILO 2063.2) Using LILO
173 When using LILO you can specify all necessary command line 207 When using LILO all the necessary command line parameters may be
174 parameters with the 'append=' command in the LILO configuration 208 specified using the 'append=' directive in the LILO configuration
175 file. However, to use the 'root=' command you also need to 209 file.
176 set up a dummy device as described in 3.1 above. For how to use 210
177 LILO and its 'append=' command please refer to the LILO 211 However, to use the 'root=' directive you also need to create
178 documentation. 212 a dummy root device, which may be removed after LILO is run.
213
214 mknod /dev/boot255 c 0 255
215
216 For information on configuring LILO, please refer to its documentation.
179 217
1803.3) Using GRUB 2183.3) Using GRUB
181 When you use GRUB, you simply append the parameters after the kernel 219 When using GRUB, kernel parameter are simply appended after the kernel
182 specification: "kernel <kernel> <parameters>" (without the quotes). 220 specification: kernel <kernel> <parameters>
183 221
1843.4) Using loadlin 2223.4) Using loadlin
185 When you want to boot Linux from a DOS command prompt without 223 loadlin may be used to boot Linux from a DOS command prompt without
186 having a local hard disk to mount as root, you can use loadlin. 224 requiring a local hard disk to mount as root. This has not been
187 I was told that it works, but haven't used it myself yet. In 225 thoroughly tested by the authors of this document, but in general
188 general you should be able to create a kernel command line simi- 226 it should be possible configure the kernel command line similarly
189 lar to how LILO is doing it. Please refer to the loadlin docu- 227 to the configuration of LILO.
190 mentation for further information. 228
229 Please refer to the loadlin documentation for further information.
191 230
1923.5) Using a boot ROM 2313.5) Using a boot ROM
193 This is probably the most elegant way of booting a diskless 232 This is probably the most elegant way of booting a diskless client.
194 client. With a boot ROM the kernel gets loaded using the TFTP 233 With a boot ROM the kernel is loaded using the TFTP protocol. The
195 protocol. As far as I know, no commercial boot ROMs yet 234 authors of this document are not aware of any no commercial boot
196 support booting Linux over the network, but there are two 235 ROMs that support booting Linux over the network. However, there
197 free implementations of a boot ROM available on sunsite.unc.edu 236 are two free implementations of a boot ROM, netboot-nfs and
198 and its mirrors. They are called 'netboot-nfs' and 'etherboot'. 237 etherboot, both of which are available on sunsite.unc.edu, and both
199 Both contain everything you need to boot a diskless Linux client. 238 of which contain everything you need to boot a diskless Linux client.
200 239
2013.6) Using pxelinux 2403.6) Using pxelinux
202 Using pxelinux you specify the kernel you built with 241 Pxelinux may be used to boot linux using the PXE boot loader
242 which is present on many modern network cards.
243
244 When using pxelinux, the kernel image is specified using
203 "kernel <relative-path-below /tftpboot>". The nfsroot parameters 245 "kernel <relative-path-below /tftpboot>". The nfsroot parameters
204 are passed to the kernel by adding them to the "append" line. 246 are passed to the kernel by adding them to the "append" line.
205 You may perhaps also want to fine tune the console output, 247 It is common to use serial console in conjunction with pxeliunx,
206 see Documentation/serial-console.txt for serial console help. 248 see Documentation/serial-console.txt for more information.
249
250 For more information on isolinux, including how to create bootdisks
251 for prebuilt kernels, see http://syslinux.zytor.com/
207 252
208 253
209 254
diff --git a/MAINTAINERS b/MAINTAINERS
index 196a31c97524..645a9f85f33f 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -601,6 +601,15 @@ W: http://linuxtv.org
601T: git kernel.org:/pub/scm/linux/kernel/git/mchehab/v4l-dvb.git 601T: git kernel.org:/pub/scm/linux/kernel/git/mchehab/v4l-dvb.git
602S: Maintained 602S: Maintained
603 603
604CALGARY x86-64 IOMMU
605P: Muli Ben-Yehuda
606M: muli@il.ibm.com
607P: Jon D. Mason
608M: jdmason@us.ibm.com
609L: linux-kernel@vger.kernel.org
610L: discuss@x86-64.org
611S: Maintained
612
604COMMON INTERNET FILE SYSTEM (CIFS) 613COMMON INTERNET FILE SYSTEM (CIFS)
605P: Steve French 614P: Steve French
606M: sfrench@samba.org 615M: sfrench@samba.org
@@ -2666,6 +2675,11 @@ M: shemminger@osdl.org
2666L: netdev@vger.kernel.org 2675L: netdev@vger.kernel.org
2667S: Maintained 2676S: Maintained
2668 2677
2678SOEKRIS NET48XX LED SUPPORT
2679P: Chris Boot
2680M: bootc@bootc.net
2681S: Maintained
2682
2669SPARC (sparc32): 2683SPARC (sparc32):
2670P: William L. Irwin 2684P: William L. Irwin
2671M: wli@holomorphy.com 2685M: wli@holomorphy.com
diff --git a/arch/alpha/kernel/alpha_ksyms.c b/arch/alpha/kernel/alpha_ksyms.c
index 425643762bf5..f042cc42b00f 100644
--- a/arch/alpha/kernel/alpha_ksyms.c
+++ b/arch/alpha/kernel/alpha_ksyms.c
@@ -14,6 +14,7 @@
14#include <linux/in.h> 14#include <linux/in.h>
15#include <linux/in6.h> 15#include <linux/in6.h>
16#include <linux/pci.h> 16#include <linux/pci.h>
17#include <linux/screen_info.h>
17#include <linux/tty.h> 18#include <linux/tty.h>
18#include <linux/mm.h> 19#include <linux/mm.h>
19#include <linux/delay.h> 20#include <linux/delay.h>
diff --git a/arch/alpha/kernel/process.c b/arch/alpha/kernel/process.c
index 41ebf51a107a..b3a8a2980365 100644
--- a/arch/alpha/kernel/process.c
+++ b/arch/alpha/kernel/process.c
@@ -25,6 +25,7 @@
25#include <linux/time.h> 25#include <linux/time.h>
26#include <linux/major.h> 26#include <linux/major.h>
27#include <linux/stat.h> 27#include <linux/stat.h>
28#include <linux/vt.h>
28#include <linux/mman.h> 29#include <linux/mman.h>
29#include <linux/elfcore.h> 30#include <linux/elfcore.h>
30#include <linux/reboot.h> 31#include <linux/reboot.h>
diff --git a/arch/alpha/kernel/setup.c b/arch/alpha/kernel/setup.c
index 254c507a608c..2cb9c4380113 100644
--- a/arch/alpha/kernel/setup.c
+++ b/arch/alpha/kernel/setup.c
@@ -19,7 +19,7 @@
19#include <linux/slab.h> 19#include <linux/slab.h>
20#include <linux/user.h> 20#include <linux/user.h>
21#include <linux/a.out.h> 21#include <linux/a.out.h>
22#include <linux/tty.h> 22#include <linux/screen_info.h>
23#include <linux/delay.h> 23#include <linux/delay.h>
24#include <linux/config.h> /* CONFIG_ALPHA_LCA etc */ 24#include <linux/config.h> /* CONFIG_ALPHA_LCA etc */
25#include <linux/mc146818rtc.h> 25#include <linux/mc146818rtc.h>
diff --git a/arch/alpha/kernel/sys_sio.c b/arch/alpha/kernel/sys_sio.c
index cd85ef725e0e..a654014d202a 100644
--- a/arch/alpha/kernel/sys_sio.c
+++ b/arch/alpha/kernel/sys_sio.c
@@ -16,7 +16,7 @@
16#include <linux/sched.h> 16#include <linux/sched.h>
17#include <linux/pci.h> 17#include <linux/pci.h>
18#include <linux/init.h> 18#include <linux/init.h>
19#include <linux/tty.h> 19#include <linux/screen_info.h>
20 20
21#include <asm/compiler.h> 21#include <asm/compiler.h>
22#include <asm/ptrace.h> 22#include <asm/ptrace.h>
diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
index ed1c4d62d999..0a722e77c143 100644
--- a/arch/arm/kernel/setup.c
+++ b/arch/arm/kernel/setup.c
@@ -17,7 +17,7 @@
17#include <linux/console.h> 17#include <linux/console.h>
18#include <linux/bootmem.h> 18#include <linux/bootmem.h>
19#include <linux/seq_file.h> 19#include <linux/seq_file.h>
20#include <linux/tty.h> 20#include <linux/screen_info.h>
21#include <linux/init.h> 21#include <linux/init.h>
22#include <linux/root_dev.h> 22#include <linux/root_dev.h>
23#include <linux/cpu.h> 23#include <linux/cpu.h>
diff --git a/arch/arm26/kernel/setup.c b/arch/arm26/kernel/setup.c
index 843c29fe9af5..e7eb070f794f 100644
--- a/arch/arm26/kernel/setup.c
+++ b/arch/arm26/kernel/setup.c
@@ -17,7 +17,7 @@
17#include <linux/console.h> 17#include <linux/console.h>
18#include <linux/bootmem.h> 18#include <linux/bootmem.h>
19#include <linux/seq_file.h> 19#include <linux/seq_file.h>
20#include <linux/tty.h> 20#include <linux/screen_info.h>
21#include <linux/init.h> 21#include <linux/init.h>
22#include <linux/root_dev.h> 22#include <linux/root_dev.h>
23 23
diff --git a/arch/cris/arch-v10/drivers/eeprom.c b/arch/cris/arch-v10/drivers/eeprom.c
index 037582028560..6e1f191a71e3 100644
--- a/arch/cris/arch-v10/drivers/eeprom.c
+++ b/arch/cris/arch-v10/drivers/eeprom.c
@@ -450,9 +450,9 @@ int __init eeprom_init(void)
450static int eeprom_open(struct inode * inode, struct file * file) 450static int eeprom_open(struct inode * inode, struct file * file)
451{ 451{
452 452
453 if(MINOR(inode->i_rdev) != EEPROM_MINOR_NR) 453 if(iminor(inode) != EEPROM_MINOR_NR)
454 return -ENXIO; 454 return -ENXIO;
455 if(MAJOR(inode->i_rdev) != EEPROM_MAJOR_NR) 455 if(imajor(inode) != EEPROM_MAJOR_NR)
456 return -ENXIO; 456 return -ENXIO;
457 457
458 if( eeprom.size > 0 ) 458 if( eeprom.size > 0 )
diff --git a/arch/cris/arch-v10/drivers/gpio.c b/arch/cris/arch-v10/drivers/gpio.c
index 48fd801792d1..fcba6632ed7b 100644
--- a/arch/cris/arch-v10/drivers/gpio.c
+++ b/arch/cris/arch-v10/drivers/gpio.c
@@ -435,7 +435,7 @@ static int
435gpio_open(struct inode *inode, struct file *filp) 435gpio_open(struct inode *inode, struct file *filp)
436{ 436{
437 struct gpio_private *priv; 437 struct gpio_private *priv;
438 int p = MINOR(inode->i_rdev); 438 int p = iminor(inode);
439 439
440 if (p > GPIO_MINOR_LAST) 440 if (p > GPIO_MINOR_LAST)
441 return -EINVAL; 441 return -EINVAL;
diff --git a/arch/cris/arch-v32/drivers/cryptocop.c b/arch/cris/arch-v32/drivers/cryptocop.c
index c59ee28a35f4..ba096ebb0b15 100644
--- a/arch/cris/arch-v32/drivers/cryptocop.c
+++ b/arch/cris/arch-v32/drivers/cryptocop.c
@@ -2302,7 +2302,7 @@ static int cryptocop_job_setup(struct cryptocop_prio_job **pj, struct cryptocop_
2302 2302
2303static int cryptocop_open(struct inode *inode, struct file *filp) 2303static int cryptocop_open(struct inode *inode, struct file *filp)
2304{ 2304{
2305 int p = MINOR(inode->i_rdev); 2305 int p = iminor(inode);
2306 2306
2307 if (p != CRYPTOCOP_MINOR) return -EINVAL; 2307 if (p != CRYPTOCOP_MINOR) return -EINVAL;
2308 2308
diff --git a/arch/cris/arch-v32/drivers/gpio.c b/arch/cris/arch-v32/drivers/gpio.c
index 00e9167de530..c3f876b4da6b 100644
--- a/arch/cris/arch-v32/drivers/gpio.c
+++ b/arch/cris/arch-v32/drivers/gpio.c
@@ -418,7 +418,7 @@ static int
418gpio_open(struct inode *inode, struct file *filp) 418gpio_open(struct inode *inode, struct file *filp)
419{ 419{
420 struct gpio_private *priv; 420 struct gpio_private *priv;
421 int p = MINOR(inode->i_rdev); 421 int p = iminor(inode);
422 422
423 if (p > GPIO_MINOR_LAST) 423 if (p > GPIO_MINOR_LAST)
424 return -EINVAL; 424 return -EINVAL;
diff --git a/arch/cris/arch-v32/drivers/pcf8563.c b/arch/cris/arch-v32/drivers/pcf8563.c
index ffc6d2572f2b..2fc7d75a35de 100644
--- a/arch/cris/arch-v32/drivers/pcf8563.c
+++ b/arch/cris/arch-v32/drivers/pcf8563.c
@@ -324,14 +324,12 @@ pcf8563_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, unsigned
324int 324int
325pcf8563_open(struct inode *inode, struct file *filp) 325pcf8563_open(struct inode *inode, struct file *filp)
326{ 326{
327 MOD_INC_USE_COUNT;
328 return 0; 327 return 0;
329} 328}
330 329
331int 330int
332pcf8563_release(struct inode *inode, struct file *filp) 331pcf8563_release(struct inode *inode, struct file *filp)
333{ 332{
334 MOD_DEC_USE_COUNT;
335 return 0; 333 return 0;
336} 334}
337 335
diff --git a/arch/cris/arch-v32/drivers/sync_serial.c b/arch/cris/arch-v32/drivers/sync_serial.c
index 7c29957f5f02..e067806b2208 100644
--- a/arch/cris/arch-v32/drivers/sync_serial.c
+++ b/arch/cris/arch-v32/drivers/sync_serial.c
@@ -340,7 +340,7 @@ static inline int sync_data_avail_to_end(struct sync_port *port)
340 340
341static int sync_serial_open(struct inode *inode, struct file *file) 341static int sync_serial_open(struct inode *inode, struct file *file)
342{ 342{
343 int dev = MINOR(inode->i_rdev); 343 int dev = iminor(inode);
344 sync_port* port; 344 sync_port* port;
345 reg_dma_rw_cfg cfg = {.en = regk_dma_yes}; 345 reg_dma_rw_cfg cfg = {.en = regk_dma_yes};
346 reg_dma_rw_intr_mask intr_mask = {.data = regk_dma_yes}; 346 reg_dma_rw_intr_mask intr_mask = {.data = regk_dma_yes};
@@ -486,7 +486,7 @@ static int sync_serial_open(struct inode *inode, struct file *file)
486 486
487static int sync_serial_release(struct inode *inode, struct file *file) 487static int sync_serial_release(struct inode *inode, struct file *file)
488{ 488{
489 int dev = MINOR(inode->i_rdev); 489 int dev = iminor(inode);
490 sync_port* port; 490 sync_port* port;
491 491
492 if (dev < 0 || dev >= NUMBER_OF_PORTS || !ports[dev].enabled) 492 if (dev < 0 || dev >= NUMBER_OF_PORTS || !ports[dev].enabled)
@@ -504,7 +504,7 @@ static int sync_serial_release(struct inode *inode, struct file *file)
504 504
505static unsigned int sync_serial_poll(struct file *file, poll_table *wait) 505static unsigned int sync_serial_poll(struct file *file, poll_table *wait)
506{ 506{
507 int dev = MINOR(file->f_dentry->d_inode->i_rdev); 507 int dev = iminor(file->f_dentry->d_inode);
508 unsigned int mask = 0; 508 unsigned int mask = 0;
509 sync_port* port; 509 sync_port* port;
510 DEBUGPOLL( static unsigned int prev_mask = 0; ); 510 DEBUGPOLL( static unsigned int prev_mask = 0; );
@@ -531,7 +531,7 @@ static int sync_serial_ioctl(struct inode *inode, struct file *file,
531 unsigned int cmd, unsigned long arg) 531 unsigned int cmd, unsigned long arg)
532{ 532{
533 int return_val = 0; 533 int return_val = 0;
534 int dev = MINOR(file->f_dentry->d_inode->i_rdev); 534 int dev = iminor(file->f_dentry->d_inode);
535 sync_port* port; 535 sync_port* port;
536 reg_sser_rw_tr_cfg tr_cfg; 536 reg_sser_rw_tr_cfg tr_cfg;
537 reg_sser_rw_rec_cfg rec_cfg; 537 reg_sser_rw_rec_cfg rec_cfg;
@@ -789,7 +789,7 @@ static int sync_serial_ioctl(struct inode *inode, struct file *file,
789static ssize_t sync_serial_write(struct file * file, const char * buf, 789static ssize_t sync_serial_write(struct file * file, const char * buf,
790 size_t count, loff_t *ppos) 790 size_t count, loff_t *ppos)
791{ 791{
792 int dev = MINOR(file->f_dentry->d_inode->i_rdev); 792 int dev = iminor(file->f_dentry->d_inode);
793 DECLARE_WAITQUEUE(wait, current); 793 DECLARE_WAITQUEUE(wait, current);
794 sync_port *port; 794 sync_port *port;
795 unsigned long c, c1; 795 unsigned long c, c1;
@@ -919,7 +919,7 @@ static ssize_t sync_serial_write(struct file * file, const char * buf,
919static ssize_t sync_serial_read(struct file * file, char * buf, 919static ssize_t sync_serial_read(struct file * file, char * buf,
920 size_t count, loff_t *ppos) 920 size_t count, loff_t *ppos)
921{ 921{
922 int dev = MINOR(file->f_dentry->d_inode->i_rdev); 922 int dev = iminor(file->f_dentry->d_inode);
923 int avail; 923 int avail;
924 sync_port *port; 924 sync_port *port;
925 unsigned char* start; 925 unsigned char* start;
diff --git a/arch/cris/kernel/setup.c b/arch/cris/kernel/setup.c
index 6d941fb9f379..7af3d5d43e43 100644
--- a/arch/cris/kernel/setup.c
+++ b/arch/cris/kernel/setup.c
@@ -15,7 +15,7 @@
15#include <linux/bootmem.h> 15#include <linux/bootmem.h>
16#include <asm/pgtable.h> 16#include <asm/pgtable.h>
17#include <linux/seq_file.h> 17#include <linux/seq_file.h>
18#include <linux/tty.h> 18#include <linux/screen_info.h>
19#include <linux/utsname.h> 19#include <linux/utsname.h>
20#include <linux/pfn.h> 20#include <linux/pfn.h>
21 21
diff --git a/arch/frv/kernel/asm-offsets.c b/arch/frv/kernel/asm-offsets.c
index 9e263112a6e2..fbb19fc1af40 100644
--- a/arch/frv/kernel/asm-offsets.c
+++ b/arch/frv/kernel/asm-offsets.c
@@ -1 +1,115 @@
1/* Dummy asm-offsets.c file. Required by kbuild and ready to be used - hint! */ 1/*
2 * Generate definitions needed by assembly language modules.
3 * This code generates raw asm output which is post-processed
4 * to extract and format the required data.
5 */
6
7#include <linux/sched.h>
8#include <linux/signal.h>
9#include <linux/personality.h>
10#include <asm/registers.h>
11#include <asm/ucontext.h>
12#include <asm/processor.h>
13#include <asm/thread_info.h>
14#include <asm/gdb-stub.h>
15
16#define DEFINE(sym, val) \
17 asm volatile("\n->" #sym " %0 " #val : : "i" (val))
18
19#define DEF_PTREG(sym, reg) \
20 asm volatile("\n->" #sym " %0 offsetof(struct pt_regs, " #reg ")" \
21 : : "i" (offsetof(struct pt_regs, reg)))
22
23#define DEF_IREG(sym, reg) \
24 asm volatile("\n->" #sym " %0 offsetof(struct user_context, " #reg ")" \
25 : : "i" (offsetof(struct user_context, reg)))
26
27#define DEF_FREG(sym, reg) \
28 asm volatile("\n->" #sym " %0 offsetof(struct user_context, " #reg ")" \
29 : : "i" (offsetof(struct user_context, reg)))
30
31#define DEF_0REG(sym, reg) \
32 asm volatile("\n->" #sym " %0 offsetof(struct frv_frame0, " #reg ")" \
33 : : "i" (offsetof(struct frv_frame0, reg)))
34
35#define BLANK() asm volatile("\n->" : : )
36
37#define OFFSET(sym, str, mem) \
38 DEFINE(sym, offsetof(struct str, mem));
39
40void foo(void)
41{
42 /* offsets into the thread_info structure */
43 OFFSET(TI_TASK, thread_info, task);
44 OFFSET(TI_EXEC_DOMAIN, thread_info, exec_domain);
45 OFFSET(TI_FLAGS, thread_info, flags);
46 OFFSET(TI_STATUS, thread_info, status);
47 OFFSET(TI_CPU, thread_info, cpu);
48 OFFSET(TI_PREEMPT_COUNT, thread_info, preempt_count);
49 OFFSET(TI_ADDR_LIMIT, thread_info, addr_limit);
50 OFFSET(TI_RESTART_BLOCK, thread_info, restart_block);
51 BLANK();
52
53 /* offsets into register file storage */
54 DEF_PTREG(REG_PSR, psr);
55 DEF_PTREG(REG_ISR, isr);
56 DEF_PTREG(REG_CCR, ccr);
57 DEF_PTREG(REG_CCCR, cccr);
58 DEF_PTREG(REG_LR, lr);
59 DEF_PTREG(REG_LCR, lcr);
60 DEF_PTREG(REG_PC, pc);
61 DEF_PTREG(REG__STATUS, __status);
62 DEF_PTREG(REG_SYSCALLNO, syscallno);
63 DEF_PTREG(REG_ORIG_GR8, orig_gr8);
64 DEF_PTREG(REG_GNER0, gner0);
65 DEF_PTREG(REG_GNER1, gner1);
66 DEF_PTREG(REG_IACC0, iacc0);
67 DEF_PTREG(REG_TBR, tbr);
68 DEF_PTREG(REG_GR0, tbr);
69 DEFINE(REG__END, sizeof(struct pt_regs));
70 BLANK();
71
72 DEF_0REG(REG_DCR, debug.dcr);
73 DEF_0REG(REG_IBAR0, debug.ibar[0]);
74 DEF_0REG(REG_DBAR0, debug.dbar[0]);
75 DEF_0REG(REG_DBDR00, debug.dbdr[0][0]);
76 DEF_0REG(REG_DBMR00, debug.dbmr[0][0]);
77 BLANK();
78
79 DEF_IREG(__INT_GR0, i.gr[0]);
80 DEF_FREG(__USER_FPMEDIA, f);
81 DEF_FREG(__FPMEDIA_FR0, f.fr[0]);
82 DEF_FREG(__FPMEDIA_FNER0, f.fner[0]);
83 DEF_FREG(__FPMEDIA_MSR0, f.msr[0]);
84 DEF_FREG(__FPMEDIA_ACC0, f.acc[0]);
85 DEF_FREG(__FPMEDIA_ACCG0, f.accg[0]);
86 DEF_FREG(__FPMEDIA_FSR0, f.fsr[0]);
87 BLANK();
88
89 DEFINE(NR_PT_REGS, sizeof(struct pt_regs) / 4);
90 DEFINE(NR_USER_INT_REGS, sizeof(struct user_int_regs) / 4);
91 DEFINE(NR_USER_FPMEDIA_REGS, sizeof(struct user_fpmedia_regs) / 4);
92 DEFINE(NR_USER_CONTEXT, sizeof(struct user_context) / 4);
93 DEFINE(FRV_FRAME0_SIZE, sizeof(struct frv_frame0));
94 BLANK();
95
96 /* offsets into thread_struct */
97 OFFSET(__THREAD_FRAME, thread_struct, frame);
98 OFFSET(__THREAD_CURR, thread_struct, curr);
99 OFFSET(__THREAD_SP, thread_struct, sp);
100 OFFSET(__THREAD_FP, thread_struct, fp);
101 OFFSET(__THREAD_LR, thread_struct, lr);
102 OFFSET(__THREAD_PC, thread_struct, pc);
103 OFFSET(__THREAD_GR16, thread_struct, gr[0]);
104 OFFSET(__THREAD_SCHED_LR, thread_struct, sched_lr);
105 OFFSET(__THREAD_FRAME0, thread_struct, frame0);
106 OFFSET(__THREAD_USER, thread_struct, user);
107 BLANK();
108
109 /* offsets into frv_debug_status */
110 OFFSET(DEBUG_BPSR, frv_debug_status, bpsr);
111 OFFSET(DEBUG_DCR, frv_debug_status, dcr);
112 OFFSET(DEBUG_BRR, frv_debug_status, brr);
113 OFFSET(DEBUG_NMAR, frv_debug_status, nmar);
114 BLANK();
115}
diff --git a/arch/frv/kernel/break.S b/arch/frv/kernel/break.S
index ea161f0ca427..dac4a5f68c2e 100644
--- a/arch/frv/kernel/break.S
+++ b/arch/frv/kernel/break.S
@@ -9,11 +9,11 @@
9 * 2 of the License, or (at your option) any later version. 9 * 2 of the License, or (at your option) any later version.
10 */ 10 */
11 11
12#include <linux/sys.h>
13#include <linux/linkage.h> 12#include <linux/linkage.h>
14#include <asm/setup.h> 13#include <asm/setup.h>
15#include <asm/segment.h> 14#include <asm/segment.h>
16#include <asm/ptrace.h> 15#include <asm/ptrace.h>
16#include <asm/thread_info.h>
17#include <asm/spr-regs.h> 17#include <asm/spr-regs.h>
18 18
19#include <asm/errno.h> 19#include <asm/errno.h>
@@ -23,13 +23,11 @@
23# 23#
24 .section .bss.stack 24 .section .bss.stack
25 .globl __break_user_context 25 .globl __break_user_context
26 .balign 8192 26 .balign THREAD_SIZE
27__break_stack: 27__break_stack:
28 .space (8192 - (USER_CONTEXT_SIZE + REG__DEBUG_XTRA)) & ~7 28 .space THREAD_SIZE - FRV_FRAME0_SIZE
29__break_stack_tos: 29__break_frame_0:
30 .space REG__DEBUG_XTRA 30 .space FRV_FRAME0_SIZE
31__break_user_context:
32 .space USER_CONTEXT_SIZE
33 31
34# 32#
35# miscellaneous variables 33# miscellaneous variables
@@ -74,8 +72,8 @@ __entry_break:
74#endif 72#endif
75 LEDS 0x1001,gr31 73 LEDS 0x1001,gr31
76 74
77 sethi.p %hi(__break_user_context),gr31 75 sethi.p %hi(__break_frame_0),gr31
78 setlo %lo(__break_user_context),gr31 76 setlo %lo(__break_frame_0),gr31
79 77
80 stdi gr2,@(gr31,#REG_GR(2)) 78 stdi gr2,@(gr31,#REG_GR(2))
81 movsg ccr,gr3 79 movsg ccr,gr3
@@ -585,8 +583,8 @@ __break_continue:
585 # set up the kernel stack pointer 583 # set up the kernel stack pointer
586 sti sp,@(gr31,#REG_SP) 584 sti sp,@(gr31,#REG_SP)
587 585
588 sethi.p %hi(__break_stack_tos),sp 586 sethi.p %hi(__break_frame_0),sp
589 setlo %lo(__break_stack_tos),sp 587 setlo %lo(__break_frame_0),sp
590 588
591 # finish building the exception frame 589 # finish building the exception frame
592 stdi gr4 ,@(gr31,#REG_GR(4)) 590 stdi gr4 ,@(gr31,#REG_GR(4))
@@ -651,9 +649,12 @@ __break_continue:
651 movsg nmar,gr5 649 movsg nmar,gr5
652 movsg dcr,gr6 650 movsg dcr,gr6
653 651
654 stdi gr4 ,@(gr31,#REG_BRR) 652 sethi.p %hi(__debug_status),gr7
655 sti gr19,@(gr31,#REG_BPSR) 653 setlo %lo(__debug_status),gr7
656 sti.p gr6 ,@(gr31,#REG_DCR) 654
655 stdi gr4 ,@(gr7,#DEBUG_BRR)
656 sti gr19,@(gr7,#DEBUG_BPSR)
657 sti.p gr6 ,@(gr7,#DEBUG_DCR)
657 658
658 # trap exceptions during break handling and disable h/w breakpoints/watchpoints 659 # trap exceptions during break handling and disable h/w breakpoints/watchpoints
659 sethi %hi(DCR_EBE),gr5 660 sethi %hi(DCR_EBE),gr5
@@ -698,7 +699,10 @@ __break_continue:
698 lddi @(gr31,#REG_PSR) ,gr22 699 lddi @(gr31,#REG_PSR) ,gr22
699 ldi @(gr31,#REG_PC) ,gr21 700 ldi @(gr31,#REG_PC) ,gr21
700 ldi @(gr31,#REG_TBR) ,gr20 701 ldi @(gr31,#REG_TBR) ,gr20
701 ldi.p @(gr31,#REG_DCR) ,gr6 702
703 sethi.p %hi(__debug_status),gr6
704 setlo %lo(__debug_status),gr6
705 ldi.p @(gr6,#DEBUG_DCR) ,gr6
702 706
703 andi gr22,#PSR_S,gr19 /* rebuild BPSR */ 707 andi gr22,#PSR_S,gr19 /* rebuild BPSR */
704 andi.p gr22,#PSR_ET,gr5 708 andi.p gr22,#PSR_ET,gr5
diff --git a/arch/frv/kernel/debug-stub.c b/arch/frv/kernel/debug-stub.c
index 4761cc4b4a90..2f6c60c921e0 100644
--- a/arch/frv/kernel/debug-stub.c
+++ b/arch/frv/kernel/debug-stub.c
@@ -39,10 +39,9 @@ do { \
39 gdbstub_do_rx(); \ 39 gdbstub_do_rx(); \
40} while(!FLOWCTL_QUERY(LINE)) 40} while(!FLOWCTL_QUERY(LINE))
41 41
42static void __init debug_stub_init(void); 42struct frv_debug_status __debug_status;
43 43
44extern asmlinkage void __break_hijack_kernel_event(void); 44static void __init debug_stub_init(void);
45extern asmlinkage void __break_hijack_kernel_event_breaks_here(void);
46 45
47/*****************************************************************************/ 46/*****************************************************************************/
48/* 47/*
@@ -67,7 +66,7 @@ asmlinkage void debug_stub(void)
67 __set_HSR(0, hsr0 & ~HSR0_ETMD); 66 __set_HSR(0, hsr0 & ~HSR0_ETMD);
68 67
69 /* disable single stepping */ 68 /* disable single stepping */
70 __debug_regs->dcr &= ~DCR_SE; 69 __debug_status.dcr &= ~DCR_SE;
71 70
72 /* kernel mode can propose an exception be handled in debug mode by jumping to a special 71 /* kernel mode can propose an exception be handled in debug mode by jumping to a special
73 * location */ 72 * location */
@@ -76,8 +75,8 @@ asmlinkage void debug_stub(void)
76 * the top kernel context */ 75 * the top kernel context */
77 *__debug_frame = *__frame; 76 *__debug_frame = *__frame;
78 __frame = __debug_frame->next_frame; 77 __frame = __debug_frame->next_frame;
79 __debug_regs->brr = (__debug_frame->tbr & TBR_TT) << 12; 78 __debug_status.brr = (__debug_frame->tbr & TBR_TT) << 12;
80 __debug_regs->brr |= BRR_EB; 79 __debug_status.brr |= BRR_EB;
81 } 80 }
82 81
83 if (__debug_frame->pc == (unsigned long) __debug_bug_trap + 4) { 82 if (__debug_frame->pc == (unsigned long) __debug_bug_trap + 4) {
@@ -124,7 +123,7 @@ static void __init debug_stub_init(void)
124 __debug_frame->pc = (unsigned long) start_kernel; 123 __debug_frame->pc = (unsigned long) start_kernel;
125 124
126 /* enable the debug events we want to trap */ 125 /* enable the debug events we want to trap */
127 __debug_regs->dcr = DCR_EBE; 126 __debug_status.dcr = DCR_EBE;
128 127
129#ifdef CONFIG_GDBSTUB 128#ifdef CONFIG_GDBSTUB
130 gdbstub_init(); 129 gdbstub_init();
diff --git a/arch/frv/kernel/entry.S b/arch/frv/kernel/entry.S
index 2a1ff1ff8692..940ac306e9a0 100644
--- a/arch/frv/kernel/entry.S
+++ b/arch/frv/kernel/entry.S
@@ -27,7 +27,6 @@
27 * 27 *
28 */ 28 */
29 29
30#include <linux/sys.h>
31#include <linux/linkage.h> 30#include <linux/linkage.h>
32#include <asm/thread_info.h> 31#include <asm/thread_info.h>
33#include <asm/setup.h> 32#include <asm/setup.h>
diff --git a/arch/frv/kernel/gdb-stub.c b/arch/frv/kernel/gdb-stub.c
index 508601fad079..9550f37fb62c 100644
--- a/arch/frv/kernel/gdb-stub.c
+++ b/arch/frv/kernel/gdb-stub.c
@@ -124,6 +124,7 @@
124#include <linux/slab.h> 124#include <linux/slab.h>
125#include <linux/nmi.h> 125#include <linux/nmi.h>
126 126
127#include <asm/asm-offsets.h>
127#include <asm/pgtable.h> 128#include <asm/pgtable.h>
128#include <asm/system.h> 129#include <asm/system.h>
129#include <asm/gdb-stub.h> 130#include <asm/gdb-stub.h>
@@ -136,7 +137,6 @@ extern void debug_to_serial(const char *p, int n);
136extern void gdbstub_console_write(struct console *co, const char *p, unsigned n); 137extern void gdbstub_console_write(struct console *co, const char *p, unsigned n);
137 138
138extern volatile uint32_t __break_error_detect[3]; /* ESFR1, ESR15, EAR15 */ 139extern volatile uint32_t __break_error_detect[3]; /* ESFR1, ESR15, EAR15 */
139extern struct user_context __break_user_context;
140 140
141struct __debug_amr { 141struct __debug_amr {
142 unsigned long L, P; 142 unsigned long L, P;
@@ -926,6 +926,7 @@ static int gdbstub_set_breakpoint(unsigned long type, unsigned long addr, unsign
926 if (!(__debug_regs->dcr & DCR_IBE0)) { 926 if (!(__debug_regs->dcr & DCR_IBE0)) {
927 //gdbstub_printk("set h/w break 0: %08lx\n", addr); 927 //gdbstub_printk("set h/w break 0: %08lx\n", addr);
928 __debug_regs->dcr |= DCR_IBE0; 928 __debug_regs->dcr |= DCR_IBE0;
929 __debug_regs->ibar[0] = addr;
929 asm volatile("movgs %0,ibar0" : : "r"(addr)); 930 asm volatile("movgs %0,ibar0" : : "r"(addr));
930 return 0; 931 return 0;
931 } 932 }
@@ -933,6 +934,7 @@ static int gdbstub_set_breakpoint(unsigned long type, unsigned long addr, unsign
933 if (!(__debug_regs->dcr & DCR_IBE1)) { 934 if (!(__debug_regs->dcr & DCR_IBE1)) {
934 //gdbstub_printk("set h/w break 1: %08lx\n", addr); 935 //gdbstub_printk("set h/w break 1: %08lx\n", addr);
935 __debug_regs->dcr |= DCR_IBE1; 936 __debug_regs->dcr |= DCR_IBE1;
937 __debug_regs->ibar[1] = addr;
936 asm volatile("movgs %0,ibar1" : : "r"(addr)); 938 asm volatile("movgs %0,ibar1" : : "r"(addr));
937 return 0; 939 return 0;
938 } 940 }
@@ -940,6 +942,7 @@ static int gdbstub_set_breakpoint(unsigned long type, unsigned long addr, unsign
940 if (!(__debug_regs->dcr & DCR_IBE2)) { 942 if (!(__debug_regs->dcr & DCR_IBE2)) {
941 //gdbstub_printk("set h/w break 2: %08lx\n", addr); 943 //gdbstub_printk("set h/w break 2: %08lx\n", addr);
942 __debug_regs->dcr |= DCR_IBE2; 944 __debug_regs->dcr |= DCR_IBE2;
945 __debug_regs->ibar[2] = addr;
943 asm volatile("movgs %0,ibar2" : : "r"(addr)); 946 asm volatile("movgs %0,ibar2" : : "r"(addr));
944 return 0; 947 return 0;
945 } 948 }
@@ -947,6 +950,7 @@ static int gdbstub_set_breakpoint(unsigned long type, unsigned long addr, unsign
947 if (!(__debug_regs->dcr & DCR_IBE3)) { 950 if (!(__debug_regs->dcr & DCR_IBE3)) {
948 //gdbstub_printk("set h/w break 3: %08lx\n", addr); 951 //gdbstub_printk("set h/w break 3: %08lx\n", addr);
949 __debug_regs->dcr |= DCR_IBE3; 952 __debug_regs->dcr |= DCR_IBE3;
953 __debug_regs->ibar[3] = addr;
950 asm volatile("movgs %0,ibar3" : : "r"(addr)); 954 asm volatile("movgs %0,ibar3" : : "r"(addr));
951 return 0; 955 return 0;
952 } 956 }
@@ -971,7 +975,14 @@ static int gdbstub_set_breakpoint(unsigned long type, unsigned long addr, unsign
971 if (!(__debug_regs->dcr & (DCR_DRBE0|DCR_DWBE0))) { 975 if (!(__debug_regs->dcr & (DCR_DRBE0|DCR_DWBE0))) {
972 //gdbstub_printk("set h/w watchpoint 0 type %ld: %08lx\n", type, addr); 976 //gdbstub_printk("set h/w watchpoint 0 type %ld: %08lx\n", type, addr);
973 tmp = type==2 ? DCR_DWBE0 : type==3 ? DCR_DRBE0 : DCR_DRBE0|DCR_DWBE0; 977 tmp = type==2 ? DCR_DWBE0 : type==3 ? DCR_DRBE0 : DCR_DRBE0|DCR_DWBE0;
978
974 __debug_regs->dcr |= tmp; 979 __debug_regs->dcr |= tmp;
980 __debug_regs->dbar[0] = addr;
981 __debug_regs->dbmr[0][0] = dbmr.mask0;
982 __debug_regs->dbmr[0][1] = dbmr.mask1;
983 __debug_regs->dbdr[0][0] = 0;
984 __debug_regs->dbdr[0][1] = 0;
985
975 asm volatile(" movgs %0,dbar0 \n" 986 asm volatile(" movgs %0,dbar0 \n"
976 " movgs %1,dbmr00 \n" 987 " movgs %1,dbmr00 \n"
977 " movgs %2,dbmr01 \n" 988 " movgs %2,dbmr01 \n"
@@ -984,7 +995,14 @@ static int gdbstub_set_breakpoint(unsigned long type, unsigned long addr, unsign
984 if (!(__debug_regs->dcr & (DCR_DRBE1|DCR_DWBE1))) { 995 if (!(__debug_regs->dcr & (DCR_DRBE1|DCR_DWBE1))) {
985 //gdbstub_printk("set h/w watchpoint 1 type %ld: %08lx\n", type, addr); 996 //gdbstub_printk("set h/w watchpoint 1 type %ld: %08lx\n", type, addr);
986 tmp = type==2 ? DCR_DWBE1 : type==3 ? DCR_DRBE1 : DCR_DRBE1|DCR_DWBE1; 997 tmp = type==2 ? DCR_DWBE1 : type==3 ? DCR_DRBE1 : DCR_DRBE1|DCR_DWBE1;
998
987 __debug_regs->dcr |= tmp; 999 __debug_regs->dcr |= tmp;
1000 __debug_regs->dbar[1] = addr;
1001 __debug_regs->dbmr[1][0] = dbmr.mask0;
1002 __debug_regs->dbmr[1][1] = dbmr.mask1;
1003 __debug_regs->dbdr[1][0] = 0;
1004 __debug_regs->dbdr[1][1] = 0;
1005
988 asm volatile(" movgs %0,dbar1 \n" 1006 asm volatile(" movgs %0,dbar1 \n"
989 " movgs %1,dbmr10 \n" 1007 " movgs %1,dbmr10 \n"
990 " movgs %2,dbmr11 \n" 1008 " movgs %2,dbmr11 \n"
@@ -1047,6 +1065,7 @@ int gdbstub_clear_breakpoint(unsigned long type, unsigned long addr, unsigned lo
1047 if (__debug_regs->dcr & DCR_IBE0 && __get_ibar(0) == addr) { 1065 if (__debug_regs->dcr & DCR_IBE0 && __get_ibar(0) == addr) {
1048 //gdbstub_printk("clear h/w break 0: %08lx\n", addr); 1066 //gdbstub_printk("clear h/w break 0: %08lx\n", addr);
1049 __debug_regs->dcr &= ~DCR_IBE0; 1067 __debug_regs->dcr &= ~DCR_IBE0;
1068 __debug_regs->ibar[0] = 0;
1050 asm volatile("movgs gr0,ibar0"); 1069 asm volatile("movgs gr0,ibar0");
1051 return 0; 1070 return 0;
1052 } 1071 }
@@ -1054,6 +1073,7 @@ int gdbstub_clear_breakpoint(unsigned long type, unsigned long addr, unsigned lo
1054 if (__debug_regs->dcr & DCR_IBE1 && __get_ibar(1) == addr) { 1073 if (__debug_regs->dcr & DCR_IBE1 && __get_ibar(1) == addr) {
1055 //gdbstub_printk("clear h/w break 1: %08lx\n", addr); 1074 //gdbstub_printk("clear h/w break 1: %08lx\n", addr);
1056 __debug_regs->dcr &= ~DCR_IBE1; 1075 __debug_regs->dcr &= ~DCR_IBE1;
1076 __debug_regs->ibar[1] = 0;
1057 asm volatile("movgs gr0,ibar1"); 1077 asm volatile("movgs gr0,ibar1");
1058 return 0; 1078 return 0;
1059 } 1079 }
@@ -1061,6 +1081,7 @@ int gdbstub_clear_breakpoint(unsigned long type, unsigned long addr, unsigned lo
1061 if (__debug_regs->dcr & DCR_IBE2 && __get_ibar(2) == addr) { 1081 if (__debug_regs->dcr & DCR_IBE2 && __get_ibar(2) == addr) {
1062 //gdbstub_printk("clear h/w break 2: %08lx\n", addr); 1082 //gdbstub_printk("clear h/w break 2: %08lx\n", addr);
1063 __debug_regs->dcr &= ~DCR_IBE2; 1083 __debug_regs->dcr &= ~DCR_IBE2;
1084 __debug_regs->ibar[2] = 0;
1064 asm volatile("movgs gr0,ibar2"); 1085 asm volatile("movgs gr0,ibar2");
1065 return 0; 1086 return 0;
1066 } 1087 }
@@ -1068,6 +1089,7 @@ int gdbstub_clear_breakpoint(unsigned long type, unsigned long addr, unsigned lo
1068 if (__debug_regs->dcr & DCR_IBE3 && __get_ibar(3) == addr) { 1089 if (__debug_regs->dcr & DCR_IBE3 && __get_ibar(3) == addr) {
1069 //gdbstub_printk("clear h/w break 3: %08lx\n", addr); 1090 //gdbstub_printk("clear h/w break 3: %08lx\n", addr);
1070 __debug_regs->dcr &= ~DCR_IBE3; 1091 __debug_regs->dcr &= ~DCR_IBE3;
1092 __debug_regs->ibar[3] = 0;
1071 asm volatile("movgs gr0,ibar3"); 1093 asm volatile("movgs gr0,ibar3");
1072 return 0; 1094 return 0;
1073 } 1095 }
@@ -1104,6 +1126,12 @@ int gdbstub_clear_breakpoint(unsigned long type, unsigned long addr, unsigned lo
1104 1126
1105 //gdbstub_printk("clear h/w watchpoint 0 type %ld: %08lx\n", type, addr); 1127 //gdbstub_printk("clear h/w watchpoint 0 type %ld: %08lx\n", type, addr);
1106 __debug_regs->dcr &= ~(DCR_DRBE0|DCR_DWBE0); 1128 __debug_regs->dcr &= ~(DCR_DRBE0|DCR_DWBE0);
1129 __debug_regs->dbar[0] = 0;
1130 __debug_regs->dbmr[0][0] = 0;
1131 __debug_regs->dbmr[0][1] = 0;
1132 __debug_regs->dbdr[0][0] = 0;
1133 __debug_regs->dbdr[0][1] = 0;
1134
1107 asm volatile(" movgs gr0,dbar0 \n" 1135 asm volatile(" movgs gr0,dbar0 \n"
1108 " movgs gr0,dbmr00 \n" 1136 " movgs gr0,dbmr00 \n"
1109 " movgs gr0,dbmr01 \n" 1137 " movgs gr0,dbmr01 \n"
@@ -1123,6 +1151,12 @@ int gdbstub_clear_breakpoint(unsigned long type, unsigned long addr, unsigned lo
1123 1151
1124 //gdbstub_printk("clear h/w watchpoint 1 type %ld: %08lx\n", type, addr); 1152 //gdbstub_printk("clear h/w watchpoint 1 type %ld: %08lx\n", type, addr);
1125 __debug_regs->dcr &= ~(DCR_DRBE1|DCR_DWBE1); 1153 __debug_regs->dcr &= ~(DCR_DRBE1|DCR_DWBE1);
1154 __debug_regs->dbar[1] = 0;
1155 __debug_regs->dbmr[1][0] = 0;
1156 __debug_regs->dbmr[1][1] = 0;
1157 __debug_regs->dbdr[1][0] = 0;
1158 __debug_regs->dbdr[1][1] = 0;
1159
1126 asm volatile(" movgs gr0,dbar1 \n" 1160 asm volatile(" movgs gr0,dbar1 \n"
1127 " movgs gr0,dbmr10 \n" 1161 " movgs gr0,dbmr10 \n"
1128 " movgs gr0,dbmr11 \n" 1162 " movgs gr0,dbmr11 \n"
@@ -1163,7 +1197,7 @@ static void gdbstub_check_breakpoint(void)
1163 */ 1197 */
1164static void __attribute__((unused)) gdbstub_show_regs(void) 1198static void __attribute__((unused)) gdbstub_show_regs(void)
1165{ 1199{
1166 uint32_t *reg; 1200 unsigned long *reg;
1167 int loop; 1201 int loop;
1168 1202
1169 gdbstub_printk("\n"); 1203 gdbstub_printk("\n");
@@ -1172,11 +1206,11 @@ static void __attribute__((unused)) gdbstub_show_regs(void)
1172 __debug_frame, 1206 __debug_frame,
1173 __debug_frame->psr & PSR_S ? "kernel" : "user"); 1207 __debug_frame->psr & PSR_S ? "kernel" : "user");
1174 1208
1175 reg = (uint32_t *) __debug_frame; 1209 reg = (unsigned long *) __debug_frame;
1176 for (loop = 0; loop < REG__END; loop++) { 1210 for (loop = 0; loop < NR_PT_REGS; loop++) {
1177 printk("%s %08x", regnames[loop + 0], reg[loop + 0]); 1211 printk("%s %08lx", regnames[loop + 0], reg[loop + 0]);
1178 1212
1179 if (loop == REG__END - 1 || loop % 5 == 4) 1213 if (loop == NR_PT_REGS - 1 || loop % 5 == 4)
1180 printk("\n"); 1214 printk("\n");
1181 else 1215 else
1182 printk(" | "); 1216 printk(" | ");
@@ -1191,13 +1225,8 @@ static void __attribute__((unused)) gdbstub_show_regs(void)
1191 */ 1225 */
1192static void __attribute__((unused)) gdbstub_dump_debugregs(void) 1226static void __attribute__((unused)) gdbstub_dump_debugregs(void)
1193{ 1227{
1194 unsigned long x; 1228 gdbstub_printk("DCR %08lx ", __debug_status.dcr);
1195 1229 gdbstub_printk("BRR %08lx\n", __debug_status.brr);
1196 x = __debug_regs->dcr;
1197 gdbstub_printk("DCR %08lx ", x);
1198
1199 x = __debug_regs->brr;
1200 gdbstub_printk("BRR %08lx\n", x);
1201 1230
1202 gdbstub_printk("IBAR0 %08lx ", __get_ibar(0)); 1231 gdbstub_printk("IBAR0 %08lx ", __get_ibar(0));
1203 gdbstub_printk("IBAR1 %08lx ", __get_ibar(1)); 1232 gdbstub_printk("IBAR1 %08lx ", __get_ibar(1));
@@ -1360,7 +1389,7 @@ void gdbstub(int sigval)
1360#endif 1389#endif
1361 } 1390 }
1362 1391
1363 save_user_regs(&__break_user_context); 1392 save_user_regs(&__debug_frame0->uc);
1364 1393
1365#if 0 1394#if 0
1366 gdbstub_printk("--> gdbstub() %08x %p %08x %08x\n", 1395 gdbstub_printk("--> gdbstub() %08x %p %08x %08x\n",
@@ -1389,8 +1418,8 @@ void gdbstub(int sigval)
1389 __debug_frame->psr &= ~PSR_S; 1418 __debug_frame->psr &= ~PSR_S;
1390 if (__debug_frame->psr & PSR_PS) 1419 if (__debug_frame->psr & PSR_PS)
1391 __debug_frame->psr |= PSR_S; 1420 __debug_frame->psr |= PSR_S;
1392 __debug_regs->brr = (__debug_frame->tbr & TBR_TT) << 12; 1421 __debug_status.brr = (__debug_frame->tbr & TBR_TT) << 12;
1393 __debug_regs->brr |= BRR_EB; 1422 __debug_status.brr |= BRR_EB;
1394 sigval = SIGINT; 1423 sigval = SIGINT;
1395 } 1424 }
1396 1425
@@ -1404,15 +1433,15 @@ void gdbstub(int sigval)
1404 __debug_frame->psr &= ~PSR_S; 1433 __debug_frame->psr &= ~PSR_S;
1405 if (__debug_frame->psr & PSR_PS) 1434 if (__debug_frame->psr & PSR_PS)
1406 __debug_frame->psr |= PSR_S; 1435 __debug_frame->psr |= PSR_S;
1407 __debug_regs->brr = (__debug_frame->tbr & TBR_TT) << 12; 1436 __debug_status.brr = (__debug_frame->tbr & TBR_TT) << 12;
1408 __debug_regs->brr |= BRR_EB; 1437 __debug_status.brr |= BRR_EB;
1409 sigval = SIGXCPU; 1438 sigval = SIGXCPU;
1410 } 1439 }
1411 1440
1412 LEDS(0x5002); 1441 LEDS(0x5002);
1413 1442
1414 /* after a BREAK insn, the PC lands on the far side of it */ 1443 /* after a BREAK insn, the PC lands on the far side of it */
1415 if (__debug_regs->brr & BRR_SB) 1444 if (__debug_status.brr & BRR_SB)
1416 gdbstub_check_breakpoint(); 1445 gdbstub_check_breakpoint();
1417 1446
1418 LEDS(0x5003); 1447 LEDS(0x5003);
@@ -1431,7 +1460,7 @@ void gdbstub(int sigval)
1431 } 1460 }
1432 1461
1433 if (!sigval) 1462 if (!sigval)
1434 sigval = gdbstub_compute_signal(__debug_regs->brr); 1463 sigval = gdbstub_compute_signal(__debug_status.brr);
1435 1464
1436 LEDS(0x5004); 1465 LEDS(0x5004);
1437 1466
@@ -1441,7 +1470,7 @@ void gdbstub(int sigval)
1441 if (sigval != SIGINT && sigval != SIGTRAP && sigval != SIGILL) { 1470 if (sigval != SIGINT && sigval != SIGTRAP && sigval != SIGILL) {
1442 static const char title[] = "Break "; 1471 static const char title[] = "Break ";
1443 static const char crlf[] = "\r\n"; 1472 static const char crlf[] = "\r\n";
1444 unsigned long brr = __debug_regs->brr; 1473 unsigned long brr = __debug_status.brr;
1445 char hx; 1474 char hx;
1446 1475
1447 ptr = output_buffer; 1476 ptr = output_buffer;
@@ -1565,28 +1594,24 @@ void gdbstub(int sigval)
1565 ptr = mem2hex(&zero, ptr, 4, 0); 1594 ptr = mem2hex(&zero, ptr, 4, 0);
1566 1595
1567 for (loop = 1; loop <= 27; loop++) 1596 for (loop = 1; loop <= 27; loop++)
1568 ptr = mem2hex((unsigned long *)__debug_frame + REG_GR(loop), 1597 ptr = mem2hex(&__debug_user_context->i.gr[loop], ptr, 4, 0);
1569 ptr, 4, 0);
1570 temp = (unsigned long) __frame; 1598 temp = (unsigned long) __frame;
1571 ptr = mem2hex(&temp, ptr, 4, 0); 1599 ptr = mem2hex(&temp, ptr, 4, 0);
1572 ptr = mem2hex((unsigned long *)__debug_frame + REG_GR(29), ptr, 4, 0); 1600 ptr = mem2hex(&__debug_user_context->i.gr[29], ptr, 4, 0);
1573 ptr = mem2hex((unsigned long *)__debug_frame + REG_GR(30), ptr, 4, 0); 1601 ptr = mem2hex(&__debug_user_context->i.gr[30], ptr, 4, 0);
1574#ifdef CONFIG_MMU 1602#ifdef CONFIG_MMU
1575 ptr = mem2hex((unsigned long *)__debug_frame + REG_GR(31), ptr, 4, 0); 1603 ptr = mem2hex(&__debug_user_context->i.gr[31], ptr, 4, 0);
1576#else 1604#else
1577 temp = (unsigned long) __debug_frame; 1605 temp = (unsigned long) __debug_frame;
1578 ptr = mem2hex(&temp, ptr, 4, 0); 1606 ptr = mem2hex(&temp, ptr, 4, 0);
1579#endif 1607#endif
1580 1608
1581 for (loop = 32; loop <= 63; loop++) 1609 for (loop = 32; loop <= 63; loop++)
1582 ptr = mem2hex((unsigned long *)__debug_frame + REG_GR(loop), 1610 ptr = mem2hex(&__debug_user_context->i.gr[loop], ptr, 4, 0);
1583 ptr, 4, 0);
1584 1611
1585 /* deal with FR0-FR63 */ 1612 /* deal with FR0-FR63 */
1586 for (loop = 0; loop <= 63; loop++) 1613 for (loop = 0; loop <= 63; loop++)
1587 ptr = mem2hex((unsigned long *)&__break_user_context + 1614 ptr = mem2hex(&__debug_user_context->f.fr[loop], ptr, 4, 0);
1588 __FPMEDIA_FR(loop),
1589 ptr, 4, 0);
1590 1615
1591 /* deal with special registers */ 1616 /* deal with special registers */
1592 ptr = mem2hex(&__debug_frame->pc, ptr, 4, 0); 1617 ptr = mem2hex(&__debug_frame->pc, ptr, 4, 0);
@@ -1597,7 +1622,7 @@ void gdbstub(int sigval)
1597 ptr = mem2hex(&zero, ptr, 4, 0); 1622 ptr = mem2hex(&zero, ptr, 4, 0);
1598 ptr = mem2hex(&zero, ptr, 4, 0); 1623 ptr = mem2hex(&zero, ptr, 4, 0);
1599 ptr = mem2hex(&__debug_frame->tbr, ptr, 4, 0); 1624 ptr = mem2hex(&__debug_frame->tbr, ptr, 4, 0);
1600 ptr = mem2hex(&__debug_regs->brr , ptr, 4, 0); 1625 ptr = mem2hex(&__debug_status.brr , ptr, 4, 0);
1601 1626
1602 asm volatile("movsg dbar0,%0" : "=r"(dbar)); 1627 asm volatile("movsg dbar0,%0" : "=r"(dbar));
1603 ptr = mem2hex(&dbar, ptr, 4, 0); 1628 ptr = mem2hex(&dbar, ptr, 4, 0);
@@ -1622,21 +1647,21 @@ void gdbstub(int sigval)
1622 1647
1623 ptr = mem2hex(&__debug_frame->iacc0, ptr, 8, 0); 1648 ptr = mem2hex(&__debug_frame->iacc0, ptr, 8, 0);
1624 1649
1625 ptr = mem2hex(&__break_user_context.f.fsr[0], ptr, 4, 0); 1650 ptr = mem2hex(&__debug_user_context->f.fsr[0], ptr, 4, 0);
1626 1651
1627 for (loop = 0; loop <= 7; loop++) 1652 for (loop = 0; loop <= 7; loop++)
1628 ptr = mem2hex(&__break_user_context.f.acc[loop], ptr, 4, 0); 1653 ptr = mem2hex(&__debug_user_context->f.acc[loop], ptr, 4, 0);
1629 1654
1630 ptr = mem2hex(&__break_user_context.f.accg, ptr, 8, 0); 1655 ptr = mem2hex(&__debug_user_context->f.accg, ptr, 8, 0);
1631 1656
1632 for (loop = 0; loop <= 1; loop++) 1657 for (loop = 0; loop <= 1; loop++)
1633 ptr = mem2hex(&__break_user_context.f.msr[loop], ptr, 4, 0); 1658 ptr = mem2hex(&__debug_user_context->f.msr[loop], ptr, 4, 0);
1634 1659
1635 ptr = mem2hex(&__debug_frame->gner0, ptr, 4, 0); 1660 ptr = mem2hex(&__debug_frame->gner0, ptr, 4, 0);
1636 ptr = mem2hex(&__debug_frame->gner1, ptr, 4, 0); 1661 ptr = mem2hex(&__debug_frame->gner1, ptr, 4, 0);
1637 1662
1638 ptr = mem2hex(&__break_user_context.f.fner[0], ptr, 4, 0); 1663 ptr = mem2hex(&__debug_user_context->f.fner[0], ptr, 4, 0);
1639 ptr = mem2hex(&__break_user_context.f.fner[1], ptr, 4, 0); 1664 ptr = mem2hex(&__debug_user_context->f.fner[1], ptr, 4, 0);
1640 1665
1641 break; 1666 break;
1642 1667
@@ -1648,8 +1673,7 @@ void gdbstub(int sigval)
1648 ptr = hex2mem(ptr, &temp, 4); 1673 ptr = hex2mem(ptr, &temp, 4);
1649 1674
1650 for (loop = 1; loop <= 27; loop++) 1675 for (loop = 1; loop <= 27; loop++)
1651 ptr = hex2mem(ptr, (unsigned long *)__debug_frame + REG_GR(loop), 1676 ptr = hex2mem(ptr, &__debug_user_context->i.gr[loop], 4);
1652 4);
1653 1677
1654 ptr = hex2mem(ptr, &temp, 4); 1678 ptr = hex2mem(ptr, &temp, 4);
1655 __frame = (struct pt_regs *) temp; 1679 __frame = (struct pt_regs *) temp;
@@ -1662,14 +1686,11 @@ void gdbstub(int sigval)
1662#endif 1686#endif
1663 1687
1664 for (loop = 32; loop <= 63; loop++) 1688 for (loop = 32; loop <= 63; loop++)
1665 ptr = hex2mem(ptr, (unsigned long *)__debug_frame + REG_GR(loop), 1689 ptr = hex2mem(ptr, &__debug_user_context->i.gr[loop], 4);
1666 4);
1667 1690
1668 /* deal with FR0-FR63 */ 1691 /* deal with FR0-FR63 */
1669 for (loop = 0; loop <= 63; loop++) 1692 for (loop = 0; loop <= 63; loop++)
1670 ptr = mem2hex((unsigned long *)&__break_user_context + 1693 ptr = mem2hex(&__debug_user_context->f.fr[loop], ptr, 4, 0);
1671 __FPMEDIA_FR(loop),
1672 ptr, 4, 0);
1673 1694
1674 /* deal with special registers */ 1695 /* deal with special registers */
1675 ptr = hex2mem(ptr, &__debug_frame->pc, 4); 1696 ptr = hex2mem(ptr, &__debug_frame->pc, 4);
@@ -1694,21 +1715,21 @@ void gdbstub(int sigval)
1694 1715
1695 ptr = hex2mem(ptr, &__debug_frame->iacc0, 8); 1716 ptr = hex2mem(ptr, &__debug_frame->iacc0, 8);
1696 1717
1697 ptr = hex2mem(ptr, &__break_user_context.f.fsr[0], 4); 1718 ptr = hex2mem(ptr, &__debug_user_context->f.fsr[0], 4);
1698 1719
1699 for (loop = 0; loop <= 7; loop++) 1720 for (loop = 0; loop <= 7; loop++)
1700 ptr = hex2mem(ptr, &__break_user_context.f.acc[loop], 4); 1721 ptr = hex2mem(ptr, &__debug_user_context->f.acc[loop], 4);
1701 1722
1702 ptr = hex2mem(ptr, &__break_user_context.f.accg, 8); 1723 ptr = hex2mem(ptr, &__debug_user_context->f.accg, 8);
1703 1724
1704 for (loop = 0; loop <= 1; loop++) 1725 for (loop = 0; loop <= 1; loop++)
1705 ptr = hex2mem(ptr, &__break_user_context.f.msr[loop], 4); 1726 ptr = hex2mem(ptr, &__debug_user_context->f.msr[loop], 4);
1706 1727
1707 ptr = hex2mem(ptr, &__debug_frame->gner0, 4); 1728 ptr = hex2mem(ptr, &__debug_frame->gner0, 4);
1708 ptr = hex2mem(ptr, &__debug_frame->gner1, 4); 1729 ptr = hex2mem(ptr, &__debug_frame->gner1, 4);
1709 1730
1710 ptr = hex2mem(ptr, &__break_user_context.f.fner[0], 4); 1731 ptr = hex2mem(ptr, &__debug_user_context->f.fner[0], 4);
1711 ptr = hex2mem(ptr, &__break_user_context.f.fner[1], 4); 1732 ptr = hex2mem(ptr, &__debug_user_context->f.fner[1], 4);
1712 1733
1713 gdbstub_strcpy(output_buffer,"OK"); 1734 gdbstub_strcpy(output_buffer,"OK");
1714 break; 1735 break;
@@ -1769,52 +1790,52 @@ void gdbstub(int sigval)
1769 case GDB_REG_GR(0): 1790 case GDB_REG_GR(0):
1770 break; 1791 break;
1771 case GDB_REG_GR(1) ... GDB_REG_GR(63): 1792 case GDB_REG_GR(1) ... GDB_REG_GR(63):
1772 __break_user_context.i.gr[addr - GDB_REG_GR(0)] = temp; 1793 __debug_user_context->i.gr[addr - GDB_REG_GR(0)] = temp;
1773 break; 1794 break;
1774 case GDB_REG_FR(0) ... GDB_REG_FR(63): 1795 case GDB_REG_FR(0) ... GDB_REG_FR(63):
1775 __break_user_context.f.fr[addr - GDB_REG_FR(0)] = temp; 1796 __debug_user_context->f.fr[addr - GDB_REG_FR(0)] = temp;
1776 break; 1797 break;
1777 case GDB_REG_PC: 1798 case GDB_REG_PC:
1778 __break_user_context.i.pc = temp; 1799 __debug_user_context->i.pc = temp;
1779 break; 1800 break;
1780 case GDB_REG_PSR: 1801 case GDB_REG_PSR:
1781 __break_user_context.i.psr = temp; 1802 __debug_user_context->i.psr = temp;
1782 break; 1803 break;
1783 case GDB_REG_CCR: 1804 case GDB_REG_CCR:
1784 __break_user_context.i.ccr = temp; 1805 __debug_user_context->i.ccr = temp;
1785 break; 1806 break;
1786 case GDB_REG_CCCR: 1807 case GDB_REG_CCCR:
1787 __break_user_context.i.cccr = temp; 1808 __debug_user_context->i.cccr = temp;
1788 break; 1809 break;
1789 case GDB_REG_BRR: 1810 case GDB_REG_BRR:
1790 __debug_regs->brr = temp; 1811 __debug_status.brr = temp;
1791 break; 1812 break;
1792 case GDB_REG_LR: 1813 case GDB_REG_LR:
1793 __break_user_context.i.lr = temp; 1814 __debug_user_context->i.lr = temp;
1794 break; 1815 break;
1795 case GDB_REG_LCR: 1816 case GDB_REG_LCR:
1796 __break_user_context.i.lcr = temp; 1817 __debug_user_context->i.lcr = temp;
1797 break; 1818 break;
1798 case GDB_REG_FSR0: 1819 case GDB_REG_FSR0:
1799 __break_user_context.f.fsr[0] = temp; 1820 __debug_user_context->f.fsr[0] = temp;
1800 break; 1821 break;
1801 case GDB_REG_ACC(0) ... GDB_REG_ACC(7): 1822 case GDB_REG_ACC(0) ... GDB_REG_ACC(7):
1802 __break_user_context.f.acc[addr - GDB_REG_ACC(0)] = temp; 1823 __debug_user_context->f.acc[addr - GDB_REG_ACC(0)] = temp;
1803 break; 1824 break;
1804 case GDB_REG_ACCG(0): 1825 case GDB_REG_ACCG(0):
1805 *(uint32_t *) &__break_user_context.f.accg[0] = temp; 1826 *(uint32_t *) &__debug_user_context->f.accg[0] = temp;
1806 break; 1827 break;
1807 case GDB_REG_ACCG(4): 1828 case GDB_REG_ACCG(4):
1808 *(uint32_t *) &__break_user_context.f.accg[4] = temp; 1829 *(uint32_t *) &__debug_user_context->f.accg[4] = temp;
1809 break; 1830 break;
1810 case GDB_REG_MSR(0) ... GDB_REG_MSR(1): 1831 case GDB_REG_MSR(0) ... GDB_REG_MSR(1):
1811 __break_user_context.f.msr[addr - GDB_REG_MSR(0)] = temp; 1832 __debug_user_context->f.msr[addr - GDB_REG_MSR(0)] = temp;
1812 break; 1833 break;
1813 case GDB_REG_GNER(0) ... GDB_REG_GNER(1): 1834 case GDB_REG_GNER(0) ... GDB_REG_GNER(1):
1814 __break_user_context.i.gner[addr - GDB_REG_GNER(0)] = temp; 1835 __debug_user_context->i.gner[addr - GDB_REG_GNER(0)] = temp;
1815 break; 1836 break;
1816 case GDB_REG_FNER(0) ... GDB_REG_FNER(1): 1837 case GDB_REG_FNER(0) ... GDB_REG_FNER(1):
1817 __break_user_context.f.fner[addr - GDB_REG_FNER(0)] = temp; 1838 __debug_user_context->f.fner[addr - GDB_REG_FNER(0)] = temp;
1818 break; 1839 break;
1819 default: 1840 default:
1820 temp2 = 0; 1841 temp2 = 0;
@@ -1850,6 +1871,7 @@ void gdbstub(int sigval)
1850 /* step to next instruction */ 1871 /* step to next instruction */
1851 case 's': 1872 case 's':
1852 __debug_regs->dcr |= DCR_SE; 1873 __debug_regs->dcr |= DCR_SE;
1874 __debug_status.dcr |= DCR_SE;
1853 goto done; 1875 goto done;
1854 1876
1855 /* set baud rate (bBB) */ 1877 /* set baud rate (bBB) */
@@ -1934,7 +1956,7 @@ void gdbstub(int sigval)
1934 } 1956 }
1935 1957
1936 done: 1958 done:
1937 restore_user_regs(&__break_user_context); 1959 restore_user_regs(&__debug_frame0->uc);
1938 1960
1939 //gdbstub_dump_debugregs(); 1961 //gdbstub_dump_debugregs();
1940 //gdbstub_printk("<-- gdbstub() %08x\n", __debug_frame->pc); 1962 //gdbstub_printk("<-- gdbstub() %08x\n", __debug_frame->pc);
@@ -1966,7 +1988,6 @@ void __init gdbstub_init(void)
1966#endif 1988#endif
1967 1989
1968 gdbstub_printk("%s", gdbstub_banner); 1990 gdbstub_printk("%s", gdbstub_banner);
1969 gdbstub_printk("DCR: %x\n", __debug_regs->dcr);
1970 1991
1971 gdbstub_io_init(); 1992 gdbstub_io_init();
1972 1993
diff --git a/arch/frv/kernel/head.S b/arch/frv/kernel/head.S
index 47c990af2e06..fecf751c5cae 100644
--- a/arch/frv/kernel/head.S
+++ b/arch/frv/kernel/head.S
@@ -11,6 +11,7 @@
11 11
12#include <linux/threads.h> 12#include <linux/threads.h>
13#include <linux/linkage.h> 13#include <linux/linkage.h>
14#include <asm/thread_info.h>
14#include <asm/ptrace.h> 15#include <asm/ptrace.h>
15#include <asm/page.h> 16#include <asm/page.h>
16#include <asm/spr-regs.h> 17#include <asm/spr-regs.h>
diff --git a/arch/frv/kernel/local.h b/arch/frv/kernel/local.h
index e9471761d78b..76606d13b1aa 100644
--- a/arch/frv/kernel/local.h
+++ b/arch/frv/kernel/local.h
@@ -51,6 +51,9 @@ extern void (*__power_switch_wake_cleanup)(void);
51/* time.c */ 51/* time.c */
52extern void time_divisor_init(void); 52extern void time_divisor_init(void);
53 53
54/* cmode.S */
55extern asmlinkage void frv_change_cmode(int);
56
54 57
55#endif /* __ASSEMBLY__ */ 58#endif /* __ASSEMBLY__ */
56#endif /* _FRV_LOCAL_H */ 59#endif /* _FRV_LOCAL_H */
diff --git a/arch/frv/kernel/pm.c b/arch/frv/kernel/pm.c
index e65a9f1c0c26..c1d9fc8f1a85 100644
--- a/arch/frv/kernel/pm.c
+++ b/arch/frv/kernel/pm.c
@@ -26,11 +26,6 @@
26 26
27#include "local.h" 27#include "local.h"
28 28
29void (*pm_power_off)(void);
30EXPORT_SYMBOL(pm_power_off);
31
32extern void frv_change_cmode(int);
33
34/* 29/*
35 * Debug macros 30 * Debug macros
36 */ 31 */
diff --git a/arch/frv/kernel/process.c b/arch/frv/kernel/process.c
index eeeb1e2641d5..515a5cea5469 100644
--- a/arch/frv/kernel/process.c
+++ b/arch/frv/kernel/process.c
@@ -10,6 +10,7 @@
10 * 2 of the License, or (at your option) any later version. 10 * 2 of the License, or (at your option) any later version.
11 */ 11 */
12 12
13#include <linux/module.h>
13#include <linux/errno.h> 14#include <linux/errno.h>
14#include <linux/sched.h> 15#include <linux/sched.h>
15#include <linux/kernel.h> 16#include <linux/kernel.h>
@@ -25,6 +26,7 @@
25#include <linux/reboot.h> 26#include <linux/reboot.h>
26#include <linux/interrupt.h> 27#include <linux/interrupt.h>
27 28
29#include <asm/asm-offsets.h>
28#include <asm/uaccess.h> 30#include <asm/uaccess.h>
29#include <asm/system.h> 31#include <asm/system.h>
30#include <asm/setup.h> 32#include <asm/setup.h>
@@ -38,6 +40,9 @@ asmlinkage void ret_from_fork(void);
38 40
39#include <asm/pgalloc.h> 41#include <asm/pgalloc.h>
40 42
43void (*pm_power_off)(void);
44EXPORT_SYMBOL(pm_power_off);
45
41struct task_struct *alloc_task_struct(void) 46struct task_struct *alloc_task_struct(void)
42{ 47{
43 struct task_struct *p = kmalloc(THREAD_SIZE, GFP_KERNEL); 48 struct task_struct *p = kmalloc(THREAD_SIZE, GFP_KERNEL);
@@ -203,7 +208,7 @@ int copy_thread(int nr, unsigned long clone_flags,
203 208
204 regs0 = __kernel_frame0_ptr; 209 regs0 = __kernel_frame0_ptr;
205 childregs0 = (struct pt_regs *) 210 childregs0 = (struct pt_regs *)
206 (task_stack_page(p) + THREAD_SIZE - USER_CONTEXT_SIZE); 211 (task_stack_page(p) + THREAD_SIZE - FRV_FRAME0_SIZE);
207 childregs = childregs0; 212 childregs = childregs0;
208 213
209 /* set up the userspace frame (the only place that the USP is stored) */ 214 /* set up the userspace frame (the only place that the USP is stored) */
@@ -367,3 +372,11 @@ int elf_check_arch(const struct elf32_hdr *hdr)
367 372
368 return 1; 373 return 1;
369} 374}
375
376int dump_fpu(struct pt_regs *regs, elf_fpregset_t *fpregs)
377{
378 memcpy(fpregs,
379 &current->thread.user->f,
380 sizeof(current->thread.user->f));
381 return 1;
382}
diff --git a/arch/frv/kernel/switch_to.S b/arch/frv/kernel/switch_to.S
index 9e5a583991a3..b5275fa9cd0d 100644
--- a/arch/frv/kernel/switch_to.S
+++ b/arch/frv/kernel/switch_to.S
@@ -11,6 +11,7 @@
11# 2 of the License, or (at your option) any later version. 11# 2 of the License, or (at your option) any later version.
12# 12#
13############################################################################### 13###############################################################################
14
14#include <linux/linkage.h> 15#include <linux/linkage.h>
15#include <asm/thread_info.h> 16#include <asm/thread_info.h>
16#include <asm/processor.h> 17#include <asm/processor.h>
@@ -30,7 +31,7 @@
30 # address of frame 0 (userspace) on current kernel stack 31 # address of frame 0 (userspace) on current kernel stack
31 .globl __kernel_frame0_ptr 32 .globl __kernel_frame0_ptr
32__kernel_frame0_ptr: 33__kernel_frame0_ptr:
33 .long init_thread_union + THREAD_SIZE - USER_CONTEXT_SIZE 34 .long init_thread_union + THREAD_SIZE - FRV_FRAME0_SIZE
34 35
35 # address of current task 36 # address of current task
36 .globl __kernel_current_task 37 .globl __kernel_current_task
diff --git a/arch/frv/kernel/traps.c b/arch/frv/kernel/traps.c
index 98ce3628ebde..2e6098c85578 100644
--- a/arch/frv/kernel/traps.c
+++ b/arch/frv/kernel/traps.c
@@ -20,6 +20,7 @@
20#include <linux/init.h> 20#include <linux/init.h>
21#include <linux/module.h> 21#include <linux/module.h>
22 22
23#include <asm/asm-offsets.h>
23#include <asm/setup.h> 24#include <asm/setup.h>
24#include <asm/fpu.h> 25#include <asm/fpu.h>
25#include <asm/system.h> 26#include <asm/system.h>
@@ -279,20 +280,20 @@ static const char *regnames[] = {
279 280
280void show_regs(struct pt_regs *regs) 281void show_regs(struct pt_regs *regs)
281{ 282{
282 uint32_t *reg; 283 unsigned long *reg;
283 int loop; 284 int loop;
284 285
285 printk("\n"); 286 printk("\n");
286 287
287 printk("Frame: @%08x [%s]\n", 288 printk("Frame: @%08lx [%s]\n",
288 (uint32_t) regs, 289 (unsigned long) regs,
289 regs->psr & PSR_S ? "kernel" : "user"); 290 regs->psr & PSR_S ? "kernel" : "user");
290 291
291 reg = (uint32_t *) regs; 292 reg = (unsigned long *) regs;
292 for (loop = 0; loop < REG__END; loop++) { 293 for (loop = 0; loop < NR_PT_REGS; loop++) {
293 printk("%s %08x", regnames[loop + 0], reg[loop + 0]); 294 printk("%s %08lx", regnames[loop + 0], reg[loop + 0]);
294 295
295 if (loop == REG__END - 1 || loop % 5 == 4) 296 if (loop == NR_PT_REGS - 1 || loop % 5 == 4)
296 printk("\n"); 297 printk("\n");
297 else 298 else
298 printk(" | "); 299 printk(" | ");
@@ -328,7 +329,7 @@ void die_if_kernel(const char *str, ...)
328 */ 329 */
329static void show_backtrace_regs(struct pt_regs *frame) 330static void show_backtrace_regs(struct pt_regs *frame)
330{ 331{
331 uint32_t *reg; 332 unsigned long *reg;
332 int loop; 333 int loop;
333 334
334 /* print the registers for this frame */ 335 /* print the registers for this frame */
@@ -336,11 +337,11 @@ static void show_backtrace_regs(struct pt_regs *frame)
336 frame->psr & PSR_S ? "Kernel Mode" : "User Mode", 337 frame->psr & PSR_S ? "Kernel Mode" : "User Mode",
337 frame); 338 frame);
338 339
339 reg = (uint32_t *) frame; 340 reg = (unsigned long *) frame;
340 for (loop = 0; loop < REG__END; loop++) { 341 for (loop = 0; loop < NR_PT_REGS; loop++) {
341 printk("%s %08x", regnames[loop + 0], reg[loop + 0]); 342 printk("%s %08lx", regnames[loop + 0], reg[loop + 0]);
342 343
343 if (loop == REG__END - 1 || loop % 5 == 4) 344 if (loop == NR_PT_REGS - 1 || loop % 5 == 4)
344 printk("\n"); 345 printk("\n");
345 else 346 else
346 printk(" | "); 347 printk(" | ");
diff --git a/arch/frv/mb93090-mb00/pci-vdk.c b/arch/frv/mb93090-mb00/pci-vdk.c
index fb98e90c5794..f7279d78995a 100644
--- a/arch/frv/mb93090-mb00/pci-vdk.c
+++ b/arch/frv/mb93090-mb00/pci-vdk.c
@@ -406,7 +406,9 @@ int __init pcibios_init(void)
406 ioport_resource.end = (__reg_MB86943_sl_pci_io_range << 9) | 0x3ff; 406 ioport_resource.end = (__reg_MB86943_sl_pci_io_range << 9) | 0x3ff;
407 ioport_resource.end += ioport_resource.start; 407 ioport_resource.end += ioport_resource.start;
408 408
409 printk("PCI IO window: %08lx-%08lx\n", ioport_resource.start, ioport_resource.end); 409 printk("PCI IO window: %08llx-%08llx\n",
410 (unsigned long long) ioport_resource.start,
411 (unsigned long long) ioport_resource.end);
410 412
411 iomem_resource.start = (__reg_MB86943_sl_pci_mem_base << 9) & 0xfffffc00; 413 iomem_resource.start = (__reg_MB86943_sl_pci_mem_base << 9) & 0xfffffc00;
412 414
@@ -416,8 +418,11 @@ int __init pcibios_init(void)
416 iomem_resource.end = (__reg_MB86943_sl_pci_mem_range << 9) | 0x3ff; 418 iomem_resource.end = (__reg_MB86943_sl_pci_mem_range << 9) | 0x3ff;
417 iomem_resource.end += iomem_resource.start; 419 iomem_resource.end += iomem_resource.start;
418 420
419 printk("PCI MEM window: %08lx-%08lx\n", iomem_resource.start, iomem_resource.end); 421 printk("PCI MEM window: %08llx-%08llx\n",
420 printk("PCI DMA memory: %08lx-%08lx\n", dma_coherent_mem_start, dma_coherent_mem_end); 422 (unsigned long long) iomem_resource.start,
423 (unsigned long long) iomem_resource.end);
424 printk("PCI DMA memory: %08lx-%08lx\n",
425 dma_coherent_mem_start, dma_coherent_mem_end);
421 426
422 if (!pci_probe) 427 if (!pci_probe)
423 return -ENXIO; 428 return -ENXIO;
diff --git a/arch/i386/defconfig b/arch/i386/defconfig
index 1629c3ac9bee..89ebb7a316ab 100644
--- a/arch/i386/defconfig
+++ b/arch/i386/defconfig
@@ -197,7 +197,7 @@ CONFIG_PM=y
197# CONFIG_PM_LEGACY is not set 197# CONFIG_PM_LEGACY is not set
198# CONFIG_PM_DEBUG is not set 198# CONFIG_PM_DEBUG is not set
199CONFIG_SOFTWARE_SUSPEND=y 199CONFIG_SOFTWARE_SUSPEND=y
200CONFIG_PM_STD_PARTITION="/dev/hda2" 200CONFIG_PM_STD_PARTITION=""
201 201
202# 202#
203# ACPI (Advanced Configuration and Power Interface) Support 203# ACPI (Advanced Configuration and Power Interface) Support
diff --git a/arch/i386/kernel/setup.c b/arch/i386/kernel/setup.c
index 08c00d20f162..7864395c1441 100644
--- a/arch/i386/kernel/setup.c
+++ b/arch/i386/kernel/setup.c
@@ -26,7 +26,7 @@
26#include <linux/sched.h> 26#include <linux/sched.h>
27#include <linux/mm.h> 27#include <linux/mm.h>
28#include <linux/mmzone.h> 28#include <linux/mmzone.h>
29#include <linux/tty.h> 29#include <linux/screen_info.h>
30#include <linux/ioport.h> 30#include <linux/ioport.h>
31#include <linux/acpi.h> 31#include <linux/acpi.h>
32#include <linux/apm_bios.h> 32#include <linux/apm_bios.h>
diff --git a/arch/i386/kernel/time.c b/arch/i386/kernel/time.c
index 316421a7f56f..8705c0f05788 100644
--- a/arch/i386/kernel/time.c
+++ b/arch/i386/kernel/time.c
@@ -206,15 +206,16 @@ irqreturn_t timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
206unsigned long get_cmos_time(void) 206unsigned long get_cmos_time(void)
207{ 207{
208 unsigned long retval; 208 unsigned long retval;
209 unsigned long flags;
209 210
210 spin_lock(&rtc_lock); 211 spin_lock_irqsave(&rtc_lock, flags);
211 212
212 if (efi_enabled) 213 if (efi_enabled)
213 retval = efi_get_time(); 214 retval = efi_get_time();
214 else 215 else
215 retval = mach_get_cmos_time(); 216 retval = mach_get_cmos_time();
216 217
217 spin_unlock(&rtc_lock); 218 spin_unlock_irqrestore(&rtc_lock, flags);
218 219
219 return retval; 220 return retval;
220} 221}
diff --git a/arch/i386/kernel/traps.c b/arch/i386/kernel/traps.c
index 2bf8b55b91f8..5cfd4f42eeba 100644
--- a/arch/i386/kernel/traps.c
+++ b/arch/i386/kernel/traps.c
@@ -100,13 +100,13 @@ int register_die_notifier(struct notifier_block *nb)
100 vmalloc_sync_all(); 100 vmalloc_sync_all();
101 return atomic_notifier_chain_register(&i386die_chain, nb); 101 return atomic_notifier_chain_register(&i386die_chain, nb);
102} 102}
103EXPORT_SYMBOL(register_die_notifier); 103EXPORT_SYMBOL(register_die_notifier); /* used modular by kdb */
104 104
105int unregister_die_notifier(struct notifier_block *nb) 105int unregister_die_notifier(struct notifier_block *nb)
106{ 106{
107 return atomic_notifier_chain_unregister(&i386die_chain, nb); 107 return atomic_notifier_chain_unregister(&i386die_chain, nb);
108} 108}
109EXPORT_SYMBOL(unregister_die_notifier); 109EXPORT_SYMBOL(unregister_die_notifier); /* used modular by kdb */
110 110
111static inline int valid_stack_ptr(struct thread_info *tinfo, void *p) 111static inline int valid_stack_ptr(struct thread_info *tinfo, void *p)
112{ 112{
diff --git a/arch/i386/oprofile/nmi_int.c b/arch/i386/oprofile/nmi_int.c
index fa8a37bcb391..c8c1df8ff2b4 100644
--- a/arch/i386/oprofile/nmi_int.c
+++ b/arch/i386/oprofile/nmi_int.c
@@ -13,6 +13,7 @@
13#include <linux/oprofile.h> 13#include <linux/oprofile.h>
14#include <linux/sysdev.h> 14#include <linux/sysdev.h>
15#include <linux/slab.h> 15#include <linux/slab.h>
16#include <linux/moduleparam.h>
16#include <asm/nmi.h> 17#include <asm/nmi.h>
17#include <asm/msr.h> 18#include <asm/msr.h>
18#include <asm/apic.h> 19#include <asm/apic.h>
@@ -296,12 +297,14 @@ static int nmi_create_files(struct super_block * sb, struct dentry * root)
296 return 0; 297 return 0;
297} 298}
298 299
300static int p4force;
301module_param(p4force, int, 0);
299 302
300static int __init p4_init(char ** cpu_type) 303static int __init p4_init(char ** cpu_type)
301{ 304{
302 __u8 cpu_model = boot_cpu_data.x86_model; 305 __u8 cpu_model = boot_cpu_data.x86_model;
303 306
304 if (cpu_model > 4) 307 if (!p4force && (cpu_model > 6 || cpu_model == 5))
305 return 0; 308 return 0;
306 309
307#ifndef CONFIG_SMP 310#ifndef CONFIG_SMP
diff --git a/arch/ia64/dig/setup.c b/arch/ia64/dig/setup.c
index 5ab12b8351d0..9196b330ff7f 100644
--- a/arch/ia64/dig/setup.c
+++ b/arch/ia64/dig/setup.c
@@ -14,7 +14,7 @@
14#include <linux/kernel.h> 14#include <linux/kernel.h>
15#include <linux/kdev_t.h> 15#include <linux/kdev_t.h>
16#include <linux/string.h> 16#include <linux/string.h>
17#include <linux/tty.h> 17#include <linux/screen_info.h>
18#include <linux/console.h> 18#include <linux/console.h>
19#include <linux/timex.h> 19#include <linux/timex.h>
20#include <linux/sched.h> 20#include <linux/sched.h>
diff --git a/arch/ia64/kernel/efi.c b/arch/ia64/kernel/efi.c
index b13c0555c3ba..e4bfa9dafbce 100644
--- a/arch/ia64/kernel/efi.c
+++ b/arch/ia64/kernel/efi.c
@@ -759,7 +759,7 @@ valid_phys_addr_range (unsigned long phys_addr, unsigned long size)
759} 759}
760 760
761int 761int
762valid_mmap_phys_addr_range (unsigned long phys_addr, unsigned long size) 762valid_mmap_phys_addr_range (unsigned long pfn, unsigned long size)
763{ 763{
764 /* 764 /*
765 * MMIO regions are often missing from the EFI memory map. 765 * MMIO regions are often missing from the EFI memory map.
diff --git a/arch/ia64/kernel/setup.c b/arch/ia64/kernel/setup.c
index 6a33f414de58..7ad0d9cc6db6 100644
--- a/arch/ia64/kernel/setup.c
+++ b/arch/ia64/kernel/setup.c
@@ -35,7 +35,7 @@
35#include <linux/seq_file.h> 35#include <linux/seq_file.h>
36#include <linux/string.h> 36#include <linux/string.h>
37#include <linux/threads.h> 37#include <linux/threads.h>
38#include <linux/tty.h> 38#include <linux/screen_info.h>
39#include <linux/dmi.h> 39#include <linux/dmi.h>
40#include <linux/serial.h> 40#include <linux/serial.h>
41#include <linux/serial_core.h> 41#include <linux/serial_core.h>
diff --git a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c
index 276512fd8922..60b45e79f080 100644
--- a/arch/ia64/pci/pci.c
+++ b/arch/ia64/pci/pci.c
@@ -650,7 +650,7 @@ pci_mmap_legacy_page_range(struct pci_bus *bus, struct vm_area_struct *vma)
650 * Avoid attribute aliasing. See Documentation/ia64/aliasing.txt 650 * Avoid attribute aliasing. See Documentation/ia64/aliasing.txt
651 * for more details. 651 * for more details.
652 */ 652 */
653 if (!valid_mmap_phys_addr_range(vma->vm_pgoff << PAGE_SHIFT, size)) 653 if (!valid_mmap_phys_addr_range(vma->vm_pgoff, size))
654 return -EINVAL; 654 return -EINVAL;
655 prot = phys_mem_access_prot(NULL, vma->vm_pgoff, size, 655 prot = phys_mem_access_prot(NULL, vma->vm_pgoff, size,
656 vma->vm_page_prot); 656 vma->vm_page_prot);
diff --git a/arch/ia64/sn/kernel/setup.c b/arch/ia64/sn/kernel/setup.c
index dd6bcf4d58bf..c119e8b620de 100644
--- a/arch/ia64/sn/kernel/setup.c
+++ b/arch/ia64/sn/kernel/setup.c
@@ -12,7 +12,7 @@
12#include <linux/kernel.h> 12#include <linux/kernel.h>
13#include <linux/kdev_t.h> 13#include <linux/kdev_t.h>
14#include <linux/string.h> 14#include <linux/string.h>
15#include <linux/tty.h> 15#include <linux/screen_info.h>
16#include <linux/console.h> 16#include <linux/console.h>
17#include <linux/timex.h> 17#include <linux/timex.h>
18#include <linux/sched.h> 18#include <linux/sched.h>
diff --git a/arch/m32r/kernel/setup.c b/arch/m32r/kernel/setup.c
index 0a6c6e677afe..3f35ab3d2dc2 100644
--- a/arch/m32r/kernel/setup.c
+++ b/arch/m32r/kernel/setup.c
@@ -21,7 +21,7 @@
21#include <linux/root_dev.h> 21#include <linux/root_dev.h>
22#include <linux/seq_file.h> 22#include <linux/seq_file.h>
23#include <linux/timex.h> 23#include <linux/timex.h>
24#include <linux/tty.h> 24#include <linux/screen_info.h>
25#include <linux/cpu.h> 25#include <linux/cpu.h>
26#include <linux/nodemask.h> 26#include <linux/nodemask.h>
27#include <linux/pfn.h> 27#include <linux/pfn.h>
diff --git a/arch/mips/kernel/irixelf.c b/arch/mips/kernel/irixelf.c
index 10d3644e3608..ab12c8f01518 100644
--- a/arch/mips/kernel/irixelf.c
+++ b/arch/mips/kernel/irixelf.c
@@ -999,8 +999,6 @@ static inline int maydump(struct vm_area_struct *vma)
999 return 1; 999 return 1;
1000} 1000}
1001 1001
1002#define roundup(x, y) ((((x)+((y)-1))/(y))*(y))
1003
1004/* An ELF note in memory. */ 1002/* An ELF note in memory. */
1005struct memelfnote 1003struct memelfnote
1006{ 1004{
diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
index 5edd8d4bb665..8c2b596a136f 100644
--- a/arch/mips/kernel/setup.c
+++ b/arch/mips/kernel/setup.c
@@ -24,7 +24,7 @@
24#include <linux/user.h> 24#include <linux/user.h>
25#include <linux/utsname.h> 25#include <linux/utsname.h>
26#include <linux/a.out.h> 26#include <linux/a.out.h>
27#include <linux/tty.h> 27#include <linux/screen_info.h>
28#include <linux/bootmem.h> 28#include <linux/bootmem.h>
29#include <linux/initrd.h> 29#include <linux/initrd.h>
30#include <linux/major.h> 30#include <linux/major.h>
diff --git a/arch/mips/mips-boards/malta/malta_setup.c b/arch/mips/mips-boards/malta/malta_setup.c
index bc4ac6f01877..7a54195c78fb 100644
--- a/arch/mips/mips-boards/malta/malta_setup.c
+++ b/arch/mips/mips-boards/malta/malta_setup.c
@@ -19,7 +19,7 @@
19#include <linux/sched.h> 19#include <linux/sched.h>
20#include <linux/ioport.h> 20#include <linux/ioport.h>
21#include <linux/pci.h> 21#include <linux/pci.h>
22#include <linux/tty.h> 22#include <linux/screen_info.h>
23 23
24#ifdef CONFIG_MTD 24#ifdef CONFIG_MTD
25#include <linux/mtd/partitions.h> 25#include <linux/mtd/partitions.h>
diff --git a/arch/mips/sibyte/swarm/setup.c b/arch/mips/sibyte/swarm/setup.c
index a9a6dbc06849..2996e338cfbd 100644
--- a/arch/mips/sibyte/swarm/setup.c
+++ b/arch/mips/sibyte/swarm/setup.c
@@ -27,7 +27,7 @@
27#include <linux/blkdev.h> 27#include <linux/blkdev.h>
28#include <linux/init.h> 28#include <linux/init.h>
29#include <linux/kernel.h> 29#include <linux/kernel.h>
30#include <linux/tty.h> 30#include <linux/screen_info.h>
31#include <linux/initrd.h> 31#include <linux/initrd.h>
32 32
33#include <asm/irq.h> 33#include <asm/irq.h>
diff --git a/arch/mips/sni/setup.c b/arch/mips/sni/setup.c
index 870486d6cd75..e5646b027f72 100644
--- a/arch/mips/sni/setup.c
+++ b/arch/mips/sni/setup.c
@@ -18,7 +18,7 @@
18#include <linux/pci.h> 18#include <linux/pci.h>
19#include <linux/console.h> 19#include <linux/console.h>
20#include <linux/fb.h> 20#include <linux/fb.h>
21#include <linux/tty.h> 21#include <linux/screen_info.h>
22 22
23#ifdef CONFIG_ARC 23#ifdef CONFIG_ARC
24#include <asm/arc/types.h> 24#include <asm/arc/types.h>
diff --git a/arch/parisc/kernel/pdc_cons.c b/arch/parisc/kernel/pdc_cons.c
index ce78f412ff2e..aab05767427c 100644
--- a/arch/parisc/kernel/pdc_cons.c
+++ b/arch/parisc/kernel/pdc_cons.c
@@ -89,6 +89,8 @@ static int pdc_console_setup(struct console *co, char *options)
89} 89}
90 90
91#if defined(CONFIG_PDC_CONSOLE) 91#if defined(CONFIG_PDC_CONSOLE)
92#include <linux/vt_kern.h>
93
92static struct tty_driver * pdc_console_device (struct console *c, int *index) 94static struct tty_driver * pdc_console_device (struct console *c, int *index)
93{ 95{
94 extern struct tty_driver console_driver; 96 extern struct tty_driver console_driver;
diff --git a/arch/powerpc/kernel/ibmebus.c b/arch/powerpc/kernel/ibmebus.c
index 97ddc02a3d42..68e5ab0443d2 100644
--- a/arch/powerpc/kernel/ibmebus.c
+++ b/arch/powerpc/kernel/ibmebus.c
@@ -323,7 +323,7 @@ int ibmebus_request_irq(struct ibmebus_dev *dev,
323 unsigned long irq_flags, const char * devname, 323 unsigned long irq_flags, const char * devname,
324 void *dev_id) 324 void *dev_id)
325{ 325{
326 unsigned int irq = irq_create_mapping(NULL, ist, 0); 326 unsigned int irq = irq_create_mapping(NULL, ist);
327 327
328 if (irq == NO_IRQ) 328 if (irq == NO_IRQ)
329 return -EINVAL; 329 return -EINVAL;
diff --git a/arch/powerpc/kernel/irq.c b/arch/powerpc/kernel/irq.c
index 8cf987809c66..01bdae35cb55 100644
--- a/arch/powerpc/kernel/irq.c
+++ b/arch/powerpc/kernel/irq.c
@@ -391,15 +391,14 @@ struct irq_host *irq_alloc_host(unsigned int revmap_type,
391 irq_map[i].host = host; 391 irq_map[i].host = host;
392 smp_wmb(); 392 smp_wmb();
393 393
394 /* Clear some flags */ 394 /* Clear norequest flags */
395 get_irq_desc(i)->status 395 get_irq_desc(i)->status &= ~IRQ_NOREQUEST;
396 &= ~(IRQ_NOREQUEST | IRQ_LEVEL);
397 396
398 /* Legacy flags are left to default at this point, 397 /* Legacy flags are left to default at this point,
399 * one can then use irq_create_mapping() to 398 * one can then use irq_create_mapping() to
400 * explicitely change them 399 * explicitely change them
401 */ 400 */
402 ops->map(host, i, i, 0); 401 ops->map(host, i, i);
403 } 402 }
404 break; 403 break;
405 case IRQ_HOST_MAP_LINEAR: 404 case IRQ_HOST_MAP_LINEAR:
@@ -457,13 +456,11 @@ void irq_set_virq_count(unsigned int count)
457} 456}
458 457
459unsigned int irq_create_mapping(struct irq_host *host, 458unsigned int irq_create_mapping(struct irq_host *host,
460 irq_hw_number_t hwirq, 459 irq_hw_number_t hwirq)
461 unsigned int flags)
462{ 460{
463 unsigned int virq, hint; 461 unsigned int virq, hint;
464 462
465 pr_debug("irq: irq_create_mapping(0x%p, 0x%lx, 0x%x)\n", 463 pr_debug("irq: irq_create_mapping(0x%p, 0x%lx)\n", host, hwirq);
466 host, hwirq, flags);
467 464
468 /* Look for default host if nececssary */ 465 /* Look for default host if nececssary */
469 if (host == NULL) 466 if (host == NULL)
@@ -482,7 +479,6 @@ unsigned int irq_create_mapping(struct irq_host *host,
482 virq = irq_find_mapping(host, hwirq); 479 virq = irq_find_mapping(host, hwirq);
483 if (virq != IRQ_NONE) { 480 if (virq != IRQ_NONE) {
484 pr_debug("irq: -> existing mapping on virq %d\n", virq); 481 pr_debug("irq: -> existing mapping on virq %d\n", virq);
485 host->ops->map(host, virq, hwirq, flags);
486 return virq; 482 return virq;
487 } 483 }
488 484
@@ -504,18 +500,18 @@ unsigned int irq_create_mapping(struct irq_host *host,
504 } 500 }
505 pr_debug("irq: -> obtained virq %d\n", virq); 501 pr_debug("irq: -> obtained virq %d\n", virq);
506 502
507 /* Clear some flags */ 503 /* Clear IRQ_NOREQUEST flag */
508 get_irq_desc(virq)->status &= ~(IRQ_NOREQUEST | IRQ_LEVEL); 504 get_irq_desc(virq)->status &= ~IRQ_NOREQUEST;
509 505
510 /* map it */ 506 /* map it */
511 if (host->ops->map(host, virq, hwirq, flags)) { 507 smp_wmb();
508 irq_map[virq].hwirq = hwirq;
509 smp_mb();
510 if (host->ops->map(host, virq, hwirq)) {
512 pr_debug("irq: -> mapping failed, freeing\n"); 511 pr_debug("irq: -> mapping failed, freeing\n");
513 irq_free_virt(virq, 1); 512 irq_free_virt(virq, 1);
514 return NO_IRQ; 513 return NO_IRQ;
515 } 514 }
516 smp_wmb();
517 irq_map[virq].hwirq = hwirq;
518 smp_mb();
519 return virq; 515 return virq;
520} 516}
521EXPORT_SYMBOL_GPL(irq_create_mapping); 517EXPORT_SYMBOL_GPL(irq_create_mapping);
@@ -525,25 +521,38 @@ extern unsigned int irq_create_of_mapping(struct device_node *controller,
525{ 521{
526 struct irq_host *host; 522 struct irq_host *host;
527 irq_hw_number_t hwirq; 523 irq_hw_number_t hwirq;
528 unsigned int flags = IRQ_TYPE_NONE; 524 unsigned int type = IRQ_TYPE_NONE;
525 unsigned int virq;
529 526
530 if (controller == NULL) 527 if (controller == NULL)
531 host = irq_default_host; 528 host = irq_default_host;
532 else 529 else
533 host = irq_find_host(controller); 530 host = irq_find_host(controller);
534 if (host == NULL) 531 if (host == NULL) {
532 printk(KERN_WARNING "irq: no irq host found for %s !\n",
533 controller->full_name);
535 return NO_IRQ; 534 return NO_IRQ;
535 }
536 536
537 /* If host has no translation, then we assume interrupt line */ 537 /* If host has no translation, then we assume interrupt line */
538 if (host->ops->xlate == NULL) 538 if (host->ops->xlate == NULL)
539 hwirq = intspec[0]; 539 hwirq = intspec[0];
540 else { 540 else {
541 if (host->ops->xlate(host, controller, intspec, intsize, 541 if (host->ops->xlate(host, controller, intspec, intsize,
542 &hwirq, &flags)) 542 &hwirq, &type))
543 return NO_IRQ; 543 return NO_IRQ;
544 } 544 }
545 545
546 return irq_create_mapping(host, hwirq, flags); 546 /* Create mapping */
547 virq = irq_create_mapping(host, hwirq);
548 if (virq == NO_IRQ)
549 return virq;
550
551 /* Set type if specified and different than the current one */
552 if (type != IRQ_TYPE_NONE &&
553 type != (get_irq_desc(virq)->status & IRQF_TRIGGER_MASK))
554 set_irq_type(virq, type);
555 return virq;
547} 556}
548EXPORT_SYMBOL_GPL(irq_create_of_mapping); 557EXPORT_SYMBOL_GPL(irq_create_of_mapping);
549 558
diff --git a/arch/powerpc/kernel/pci_32.c b/arch/powerpc/kernel/pci_32.c
index 898dae8ab6d9..09b1e1bbb29b 100644
--- a/arch/powerpc/kernel/pci_32.c
+++ b/arch/powerpc/kernel/pci_32.c
@@ -11,6 +11,7 @@
11#include <linux/sched.h> 11#include <linux/sched.h>
12#include <linux/errno.h> 12#include <linux/errno.h>
13#include <linux/bootmem.h> 13#include <linux/bootmem.h>
14#include <linux/irq.h>
14 15
15#include <asm/processor.h> 16#include <asm/processor.h>
16#include <asm/io.h> 17#include <asm/io.h>
@@ -18,7 +19,6 @@
18#include <asm/sections.h> 19#include <asm/sections.h>
19#include <asm/pci-bridge.h> 20#include <asm/pci-bridge.h>
20#include <asm/byteorder.h> 21#include <asm/byteorder.h>
21#include <asm/irq.h>
22#include <asm/uaccess.h> 22#include <asm/uaccess.h>
23#include <asm/machdep.h> 23#include <asm/machdep.h>
24 24
@@ -1420,15 +1420,37 @@ int pci_read_irq_line(struct pci_dev *pci_dev)
1420 1420
1421 DBG("Try to map irq for %s...\n", pci_name(pci_dev)); 1421 DBG("Try to map irq for %s...\n", pci_name(pci_dev));
1422 1422
1423 /* Try to get a mapping from the device-tree */
1423 if (of_irq_map_pci(pci_dev, &oirq)) { 1424 if (of_irq_map_pci(pci_dev, &oirq)) {
1424 DBG(" -> failed !\n"); 1425 u8 line, pin;
1425 return -1; 1426
1426 } 1427 /* If that fails, lets fallback to what is in the config
1428 * space and map that through the default controller. We
1429 * also set the type to level low since that's what PCI
1430 * interrupts are. If your platform does differently, then
1431 * either provide a proper interrupt tree or don't use this
1432 * function.
1433 */
1434 if (pci_read_config_byte(pci_dev, PCI_INTERRUPT_PIN, &pin))
1435 return -1;
1436 if (pin == 0)
1437 return -1;
1438 if (pci_read_config_byte(pci_dev, PCI_INTERRUPT_LINE, &line) ||
1439 line == 0xff) {
1440 return -1;
1441 }
1442 DBG(" -> no map ! Using irq line %d from PCI config\n", line);
1427 1443
1428 DBG(" -> got one, spec %d cells (0x%08x...) on %s\n", 1444 virq = irq_create_mapping(NULL, line);
1429 oirq.size, oirq.specifier[0], oirq.controller->full_name); 1445 if (virq != NO_IRQ)
1446 set_irq_type(virq, IRQ_TYPE_LEVEL_LOW);
1447 } else {
1448 DBG(" -> got one, spec %d cells (0x%08x...) on %s\n",
1449 oirq.size, oirq.specifier[0], oirq.controller->full_name);
1430 1450
1431 virq = irq_create_of_mapping(oirq.controller, oirq.specifier, oirq.size); 1451 virq = irq_create_of_mapping(oirq.controller, oirq.specifier,
1452 oirq.size);
1453 }
1432 if(virq == NO_IRQ) { 1454 if(virq == NO_IRQ) {
1433 DBG(" -> failed to map !\n"); 1455 DBG(" -> failed to map !\n");
1434 return -1; 1456 return -1;
diff --git a/arch/powerpc/kernel/pci_64.c b/arch/powerpc/kernel/pci_64.c
index efc0b5559ee0..2fce7738e9e2 100644
--- a/arch/powerpc/kernel/pci_64.c
+++ b/arch/powerpc/kernel/pci_64.c
@@ -21,13 +21,13 @@
21#include <linux/mm.h> 21#include <linux/mm.h>
22#include <linux/list.h> 22#include <linux/list.h>
23#include <linux/syscalls.h> 23#include <linux/syscalls.h>
24#include <linux/irq.h>
24 25
25#include <asm/processor.h> 26#include <asm/processor.h>
26#include <asm/io.h> 27#include <asm/io.h>
27#include <asm/prom.h> 28#include <asm/prom.h>
28#include <asm/pci-bridge.h> 29#include <asm/pci-bridge.h>
29#include <asm/byteorder.h> 30#include <asm/byteorder.h>
30#include <asm/irq.h>
31#include <asm/machdep.h> 31#include <asm/machdep.h>
32#include <asm/ppc-pci.h> 32#include <asm/ppc-pci.h>
33 33
@@ -1289,15 +1289,37 @@ int pci_read_irq_line(struct pci_dev *pci_dev)
1289 1289
1290 DBG("Try to map irq for %s...\n", pci_name(pci_dev)); 1290 DBG("Try to map irq for %s...\n", pci_name(pci_dev));
1291 1291
1292 /* Try to get a mapping from the device-tree */
1292 if (of_irq_map_pci(pci_dev, &oirq)) { 1293 if (of_irq_map_pci(pci_dev, &oirq)) {
1293 DBG(" -> failed !\n"); 1294 u8 line, pin;
1294 return -1; 1295
1295 } 1296 /* If that fails, lets fallback to what is in the config
1297 * space and map that through the default controller. We
1298 * also set the type to level low since that's what PCI
1299 * interrupts are. If your platform does differently, then
1300 * either provide a proper interrupt tree or don't use this
1301 * function.
1302 */
1303 if (pci_read_config_byte(pci_dev, PCI_INTERRUPT_PIN, &pin))
1304 return -1;
1305 if (pin == 0)
1306 return -1;
1307 if (pci_read_config_byte(pci_dev, PCI_INTERRUPT_LINE, &line) ||
1308 line == 0xff) {
1309 return -1;
1310 }
1311 DBG(" -> no map ! Using irq line %d from PCI config\n", line);
1296 1312
1297 DBG(" -> got one, spec %d cells (0x%08x...) on %s\n", 1313 virq = irq_create_mapping(NULL, line);
1298 oirq.size, oirq.specifier[0], oirq.controller->full_name); 1314 if (virq != NO_IRQ)
1315 set_irq_type(virq, IRQ_TYPE_LEVEL_LOW);
1316 } else {
1317 DBG(" -> got one, spec %d cells (0x%08x...) on %s\n",
1318 oirq.size, oirq.specifier[0], oirq.controller->full_name);
1299 1319
1300 virq = irq_create_of_mapping(oirq.controller, oirq.specifier, oirq.size); 1320 virq = irq_create_of_mapping(oirq.controller, oirq.specifier,
1321 oirq.size);
1322 }
1301 if(virq == NO_IRQ) { 1323 if(virq == NO_IRQ) {
1302 DBG(" -> failed to map !\n"); 1324 DBG(" -> failed to map !\n");
1303 return -1; 1325 return -1;
diff --git a/arch/powerpc/kernel/ppc_ksyms.c b/arch/powerpc/kernel/ppc_ksyms.c
index e3b80f71748e..f6a05f090b25 100644
--- a/arch/powerpc/kernel/ppc_ksyms.c
+++ b/arch/powerpc/kernel/ppc_ksyms.c
@@ -5,7 +5,7 @@
5#include <linux/elfcore.h> 5#include <linux/elfcore.h>
6#include <linux/string.h> 6#include <linux/string.h>
7#include <linux/interrupt.h> 7#include <linux/interrupt.h>
8#include <linux/tty.h> 8#include <linux/screen_info.h>
9#include <linux/vt_kern.h> 9#include <linux/vt_kern.h>
10#include <linux/nvram.h> 10#include <linux/nvram.h>
11#include <linux/console.h> 11#include <linux/console.h>
diff --git a/arch/powerpc/kernel/prom_parse.c b/arch/powerpc/kernel/prom_parse.c
index 21009b1f7869..6a7e997c401d 100644
--- a/arch/powerpc/kernel/prom_parse.c
+++ b/arch/powerpc/kernel/prom_parse.c
@@ -881,7 +881,7 @@ int of_irq_map_one(struct device_node *device, int index, struct of_irq *out_irq
881 intsize = *tmp; 881 intsize = *tmp;
882 882
883 /* Check index */ 883 /* Check index */
884 if (index * intsize >= intlen) 884 if ((index + 1) * intsize > intlen)
885 return -EINVAL; 885 return -EINVAL;
886 886
887 /* Get new specifier and map it */ 887 /* Get new specifier and map it */
diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c
index c6d7b98af7d5..499c3861074f 100644
--- a/arch/powerpc/kernel/setup-common.c
+++ b/arch/powerpc/kernel/setup-common.c
@@ -26,7 +26,7 @@
26#include <linux/ioport.h> 26#include <linux/ioport.h>
27#include <linux/console.h> 27#include <linux/console.h>
28#include <linux/utsname.h> 28#include <linux/utsname.h>
29#include <linux/tty.h> 29#include <linux/screen_info.h>
30#include <linux/root_dev.h> 30#include <linux/root_dev.h>
31#include <linux/notifier.h> 31#include <linux/notifier.h>
32#include <linux/cpu.h> 32#include <linux/cpu.h>
diff --git a/arch/powerpc/platforms/cell/interrupt.c b/arch/powerpc/platforms/cell/interrupt.c
index 9d5da7896892..d7bbb61109f9 100644
--- a/arch/powerpc/platforms/cell/interrupt.c
+++ b/arch/powerpc/platforms/cell/interrupt.c
@@ -159,7 +159,7 @@ static void iic_request_ipi(int ipi, const char *name)
159 if (iic_hosts[node] == NULL) 159 if (iic_hosts[node] == NULL)
160 continue; 160 continue;
161 virq = irq_create_mapping(iic_hosts[node], 161 virq = irq_create_mapping(iic_hosts[node],
162 iic_ipi_to_irq(ipi), 0); 162 iic_ipi_to_irq(ipi));
163 if (virq == NO_IRQ) { 163 if (virq == NO_IRQ) {
164 printk(KERN_ERR 164 printk(KERN_ERR
165 "iic: failed to map IPI %s on node %d\n", 165 "iic: failed to map IPI %s on node %d\n",
@@ -197,7 +197,7 @@ static int iic_host_match(struct irq_host *h, struct device_node *node)
197} 197}
198 198
199static int iic_host_map(struct irq_host *h, unsigned int virq, 199static int iic_host_map(struct irq_host *h, unsigned int virq,
200 irq_hw_number_t hw, unsigned int flags) 200 irq_hw_number_t hw)
201{ 201{
202 if (hw < IIC_IRQ_IPI0) 202 if (hw < IIC_IRQ_IPI0)
203 set_irq_chip_and_handler(virq, &iic_chip, handle_fasteoi_irq); 203 set_irq_chip_and_handler(virq, &iic_chip, handle_fasteoi_irq);
diff --git a/arch/powerpc/platforms/cell/spider-pic.c b/arch/powerpc/platforms/cell/spider-pic.c
index ae7ef88f1a37..15217bb0402f 100644
--- a/arch/powerpc/platforms/cell/spider-pic.c
+++ b/arch/powerpc/platforms/cell/spider-pic.c
@@ -85,9 +85,6 @@ static void spider_unmask_irq(unsigned int virq)
85 struct spider_pic *pic = spider_virq_to_pic(virq); 85 struct spider_pic *pic = spider_virq_to_pic(virq);
86 void __iomem *cfg = spider_get_irq_config(pic, irq_map[virq].hwirq); 86 void __iomem *cfg = spider_get_irq_config(pic, irq_map[virq].hwirq);
87 87
88 /* We use no locking as we should be covered by the descriptor lock
89 * for access to invidual source configuration registers
90 */
91 out_be32(cfg, in_be32(cfg) | 0x30000000u); 88 out_be32(cfg, in_be32(cfg) | 0x30000000u);
92} 89}
93 90
@@ -96,9 +93,6 @@ static void spider_mask_irq(unsigned int virq)
96 struct spider_pic *pic = spider_virq_to_pic(virq); 93 struct spider_pic *pic = spider_virq_to_pic(virq);
97 void __iomem *cfg = spider_get_irq_config(pic, irq_map[virq].hwirq); 94 void __iomem *cfg = spider_get_irq_config(pic, irq_map[virq].hwirq);
98 95
99 /* We use no locking as we should be covered by the descriptor lock
100 * for access to invidual source configuration registers
101 */
102 out_be32(cfg, in_be32(cfg) & ~0x30000000u); 96 out_be32(cfg, in_be32(cfg) & ~0x30000000u);
103} 97}
104 98
@@ -120,26 +114,14 @@ static void spider_ack_irq(unsigned int virq)
120 out_be32(pic->regs + TIR_EDC, 0x100 | (src & 0xf)); 114 out_be32(pic->regs + TIR_EDC, 0x100 | (src & 0xf));
121} 115}
122 116
123static struct irq_chip spider_pic = { 117static int spider_set_irq_type(unsigned int virq, unsigned int type)
124 .typename = " SPIDER ",
125 .unmask = spider_unmask_irq,
126 .mask = spider_mask_irq,
127 .ack = spider_ack_irq,
128};
129
130static int spider_host_match(struct irq_host *h, struct device_node *node)
131{
132 struct spider_pic *pic = h->host_data;
133 return node == pic->of_node;
134}
135
136static int spider_host_map(struct irq_host *h, unsigned int virq,
137 irq_hw_number_t hw, unsigned int flags)
138{ 118{
139 unsigned int sense = flags & IRQ_TYPE_SENSE_MASK; 119 unsigned int sense = type & IRQ_TYPE_SENSE_MASK;
140 struct spider_pic *pic = h->host_data; 120 struct spider_pic *pic = spider_virq_to_pic(virq);
121 unsigned int hw = irq_map[virq].hwirq;
141 void __iomem *cfg = spider_get_irq_config(pic, hw); 122 void __iomem *cfg = spider_get_irq_config(pic, hw);
142 int level = 0; 123 struct irq_desc *desc = get_irq_desc(virq);
124 u32 old_mask;
143 u32 ic; 125 u32 ic;
144 126
145 /* Note that only level high is supported for most interrupts */ 127 /* Note that only level high is supported for most interrupts */
@@ -157,29 +139,57 @@ static int spider_host_map(struct irq_host *h, unsigned int virq,
157 break; 139 break;
158 case IRQ_TYPE_LEVEL_LOW: 140 case IRQ_TYPE_LEVEL_LOW:
159 ic = 0x0; 141 ic = 0x0;
160 level = 1;
161 break; 142 break;
162 case IRQ_TYPE_LEVEL_HIGH: 143 case IRQ_TYPE_LEVEL_HIGH:
163 case IRQ_TYPE_NONE: 144 case IRQ_TYPE_NONE:
164 ic = 0x1; 145 ic = 0x1;
165 level = 1;
166 break; 146 break;
167 default: 147 default:
168 return -EINVAL; 148 return -EINVAL;
169 } 149 }
170 150
151 /* Update irq_desc */
152 desc->status &= ~(IRQ_TYPE_SENSE_MASK | IRQ_LEVEL);
153 desc->status |= type & IRQ_TYPE_SENSE_MASK;
154 if (type & (IRQ_TYPE_LEVEL_HIGH | IRQ_TYPE_LEVEL_LOW))
155 desc->status |= IRQ_LEVEL;
156
171 /* Configure the source. One gross hack that was there before and 157 /* Configure the source. One gross hack that was there before and
172 * that I've kept around is the priority to the BE which I set to 158 * that I've kept around is the priority to the BE which I set to
173 * be the same as the interrupt source number. I don't know wether 159 * be the same as the interrupt source number. I don't know wether
174 * that's supposed to make any kind of sense however, we'll have to 160 * that's supposed to make any kind of sense however, we'll have to
175 * decide that, but for now, I'm not changing the behaviour. 161 * decide that, but for now, I'm not changing the behaviour.
176 */ 162 */
177 out_be32(cfg, (ic << 24) | (0x7 << 16) | (pic->node_id << 4) | 0xe); 163 old_mask = in_be32(cfg) & 0x30000000u;
164 out_be32(cfg, old_mask | (ic << 24) | (0x7 << 16) |
165 (pic->node_id << 4) | 0xe);
178 out_be32(cfg + 4, (0x2 << 16) | (hw & 0xff)); 166 out_be32(cfg + 4, (0x2 << 16) | (hw & 0xff));
179 167
180 if (level) 168 return 0;
181 get_irq_desc(virq)->status |= IRQ_LEVEL; 169}
170
171static struct irq_chip spider_pic = {
172 .typename = " SPIDER ",
173 .unmask = spider_unmask_irq,
174 .mask = spider_mask_irq,
175 .ack = spider_ack_irq,
176 .set_type = spider_set_irq_type,
177};
178
179static int spider_host_match(struct irq_host *h, struct device_node *node)
180{
181 struct spider_pic *pic = h->host_data;
182 return node == pic->of_node;
183}
184
185static int spider_host_map(struct irq_host *h, unsigned int virq,
186 irq_hw_number_t hw)
187{
182 set_irq_chip_and_handler(virq, &spider_pic, handle_level_irq); 188 set_irq_chip_and_handler(virq, &spider_pic, handle_level_irq);
189
190 /* Set default irq type */
191 set_irq_type(virq, IRQ_TYPE_NONE);
192
183 return 0; 193 return 0;
184} 194}
185 195
@@ -283,7 +293,7 @@ static unsigned int __init spider_find_cascade_and_node(struct spider_pic *pic)
283 if (iic_host == NULL) 293 if (iic_host == NULL)
284 return NO_IRQ; 294 return NO_IRQ;
285 /* Manufacture an IIC interrupt number of class 2 */ 295 /* Manufacture an IIC interrupt number of class 2 */
286 virq = irq_create_mapping(iic_host, 0x20 | unit, 0); 296 virq = irq_create_mapping(iic_host, 0x20 | unit);
287 if (virq == NO_IRQ) 297 if (virq == NO_IRQ)
288 printk(KERN_ERR "spider_pic: failed to map cascade !"); 298 printk(KERN_ERR "spider_pic: failed to map cascade !");
289 return virq; 299 return virq;
diff --git a/arch/powerpc/platforms/cell/spu_base.c b/arch/powerpc/platforms/cell/spu_base.c
index 5d2313a6c82b..d06042deb021 100644
--- a/arch/powerpc/platforms/cell/spu_base.c
+++ b/arch/powerpc/platforms/cell/spu_base.c
@@ -583,9 +583,9 @@ static int __init spu_map_interrupts(struct spu *spu, struct device_node *np)
583 spu->isrc = isrc = tmp[0]; 583 spu->isrc = isrc = tmp[0];
584 584
585 /* Now map interrupts of all 3 classes */ 585 /* Now map interrupts of all 3 classes */
586 spu->irqs[0] = irq_create_mapping(host, 0x00 | isrc, 0); 586 spu->irqs[0] = irq_create_mapping(host, 0x00 | isrc);
587 spu->irqs[1] = irq_create_mapping(host, 0x10 | isrc, 0); 587 spu->irqs[1] = irq_create_mapping(host, 0x10 | isrc);
588 spu->irqs[2] = irq_create_mapping(host, 0x20 | isrc, 0); 588 spu->irqs[2] = irq_create_mapping(host, 0x20 | isrc);
589 589
590 /* Right now, we only fail if class 2 failed */ 590 /* Right now, we only fail if class 2 failed */
591 return spu->irqs[2] == NO_IRQ ? -EINVAL : 0; 591 return spu->irqs[2] == NO_IRQ ? -EINVAL : 0;
diff --git a/arch/powerpc/platforms/iseries/irq.c b/arch/powerpc/platforms/iseries/irq.c
index 2275e64f3152..e32446877e78 100644
--- a/arch/powerpc/platforms/iseries/irq.c
+++ b/arch/powerpc/platforms/iseries/irq.c
@@ -300,7 +300,7 @@ int __init iSeries_allocate_IRQ(HvBusNumber bus,
300 realirq = (((((sub_bus << 8) + (bus - 1)) << 3) + (idsel - 1)) << 3) 300 realirq = (((((sub_bus << 8) + (bus - 1)) << 3) + (idsel - 1)) << 3)
301 + function; 301 + function;
302 302
303 return irq_create_mapping(NULL, realirq, IRQ_TYPE_NONE); 303 return irq_create_mapping(NULL, realirq);
304} 304}
305 305
306#endif /* CONFIG_PCI */ 306#endif /* CONFIG_PCI */
@@ -341,7 +341,7 @@ unsigned int iSeries_get_irq(struct pt_regs *regs)
341} 341}
342 342
343static int iseries_irq_host_map(struct irq_host *h, unsigned int virq, 343static int iseries_irq_host_map(struct irq_host *h, unsigned int virq,
344 irq_hw_number_t hw, unsigned int flags) 344 irq_hw_number_t hw)
345{ 345{
346 set_irq_chip_and_handler(virq, &iseries_pic, handle_fasteoi_irq); 346 set_irq_chip_and_handler(virq, &iseries_pic, handle_fasteoi_irq);
347 347
diff --git a/arch/powerpc/platforms/powermac/backlight.c b/arch/powerpc/platforms/powermac/backlight.c
index 69f65e215a5c..74eed6b74cd6 100644
--- a/arch/powerpc/platforms/powermac/backlight.c
+++ b/arch/powerpc/platforms/powermac/backlight.c
@@ -15,6 +15,15 @@
15 15
16#define OLD_BACKLIGHT_MAX 15 16#define OLD_BACKLIGHT_MAX 15
17 17
18static void pmac_backlight_key_worker(void *data);
19static DECLARE_WORK(pmac_backlight_key_work, pmac_backlight_key_worker, NULL);
20
21/* Although this variable is used in interrupt context, it makes no sense to
22 * protect it. No user is able to produce enough key events per second and
23 * notice the errors that might happen.
24 */
25static int pmac_backlight_key_queued;
26
18/* Protect the pmac_backlight variable */ 27/* Protect the pmac_backlight variable */
19DEFINE_MUTEX(pmac_backlight_mutex); 28DEFINE_MUTEX(pmac_backlight_mutex);
20 29
@@ -71,7 +80,7 @@ int pmac_backlight_curve_lookup(struct fb_info *info, int value)
71 return level; 80 return level;
72} 81}
73 82
74static void pmac_backlight_key(int direction) 83static void pmac_backlight_key_worker(void *data)
75{ 84{
76 mutex_lock(&pmac_backlight_mutex); 85 mutex_lock(&pmac_backlight_mutex);
77 if (pmac_backlight) { 86 if (pmac_backlight) {
@@ -82,7 +91,8 @@ static void pmac_backlight_key(int direction)
82 props = pmac_backlight->props; 91 props = pmac_backlight->props;
83 92
84 brightness = props->brightness + 93 brightness = props->brightness +
85 ((direction?-1:1) * (props->max_brightness / 15)); 94 ((pmac_backlight_key_queued?-1:1) *
95 (props->max_brightness / 15));
86 96
87 if (brightness < 0) 97 if (brightness < 0)
88 brightness = 0; 98 brightness = 0;
@@ -97,14 +107,13 @@ static void pmac_backlight_key(int direction)
97 mutex_unlock(&pmac_backlight_mutex); 107 mutex_unlock(&pmac_backlight_mutex);
98} 108}
99 109
100void pmac_backlight_key_up() 110void pmac_backlight_key(int direction)
101{ 111{
102 pmac_backlight_key(0); 112 /* we can receive multiple interrupts here, but the scheduled work
103} 113 * will run only once, with the last value
104 114 */
105void pmac_backlight_key_down() 115 pmac_backlight_key_queued = direction;
106{ 116 schedule_work(&pmac_backlight_key_work);
107 pmac_backlight_key(1);
108} 117}
109 118
110int pmac_backlight_set_legacy_brightness(int brightness) 119int pmac_backlight_set_legacy_brightness(int brightness)
@@ -157,3 +166,7 @@ int pmac_backlight_get_legacy_brightness()
157 166
158 return result; 167 return result;
159} 168}
169
170EXPORT_SYMBOL_GPL(pmac_backlight);
171EXPORT_SYMBOL_GPL(pmac_backlight_mutex);
172EXPORT_SYMBOL_GPL(pmac_has_backlight_type);
diff --git a/arch/powerpc/platforms/powermac/pci.c b/arch/powerpc/platforms/powermac/pci.c
index 556b349797e8..205d04471161 100644
--- a/arch/powerpc/platforms/powermac/pci.c
+++ b/arch/powerpc/platforms/powermac/pci.c
@@ -16,6 +16,7 @@
16#include <linux/string.h> 16#include <linux/string.h>
17#include <linux/init.h> 17#include <linux/init.h>
18#include <linux/bootmem.h> 18#include <linux/bootmem.h>
19#include <linux/irq.h>
19 20
20#include <asm/sections.h> 21#include <asm/sections.h>
21#include <asm/io.h> 22#include <asm/io.h>
@@ -24,10 +25,7 @@
24#include <asm/machdep.h> 25#include <asm/machdep.h>
25#include <asm/pmac_feature.h> 26#include <asm/pmac_feature.h>
26#include <asm/grackle.h> 27#include <asm/grackle.h>
27#ifdef CONFIG_PPC64
28//#include <asm/iommu.h>
29#include <asm/ppc-pci.h> 28#include <asm/ppc-pci.h>
30#endif
31 29
32#undef DEBUG 30#undef DEBUG
33 31
@@ -46,7 +44,6 @@ static int has_uninorth;
46static struct pci_controller *u3_agp; 44static struct pci_controller *u3_agp;
47static struct pci_controller *u4_pcie; 45static struct pci_controller *u4_pcie;
48static struct pci_controller *u3_ht; 46static struct pci_controller *u3_ht;
49#define has_second_ohare 0
50#else 47#else
51static int has_second_ohare; 48static int has_second_ohare;
52#endif /* CONFIG_PPC64 */ 49#endif /* CONFIG_PPC64 */
@@ -993,6 +990,7 @@ void __init pmac_pcibios_fixup(void)
993 /* Read interrupt from the device-tree */ 990 /* Read interrupt from the device-tree */
994 pci_read_irq_line(dev); 991 pci_read_irq_line(dev);
995 992
993#ifdef CONFIG_PPC32
996 /* Fixup interrupt for the modem/ethernet combo controller. 994 /* Fixup interrupt for the modem/ethernet combo controller.
997 * on machines with a second ohare chip. 995 * on machines with a second ohare chip.
998 * The number in the device tree (27) is bogus (correct for 996 * The number in the device tree (27) is bogus (correct for
@@ -1002,8 +1000,11 @@ void __init pmac_pcibios_fixup(void)
1002 */ 1000 */
1003 if (has_second_ohare && 1001 if (has_second_ohare &&
1004 dev->vendor == PCI_VENDOR_ID_DEC && 1002 dev->vendor == PCI_VENDOR_ID_DEC &&
1005 dev->device == PCI_DEVICE_ID_DEC_TULIP_PLUS) 1003 dev->device == PCI_DEVICE_ID_DEC_TULIP_PLUS) {
1006 dev->irq = irq_create_mapping(NULL, 60, 0); 1004 dev->irq = irq_create_mapping(NULL, 60);
1005 set_irq_type(dev->irq, IRQ_TYPE_LEVEL_LOW);
1006 }
1007#endif /* CONFIG_PPC32 */
1007 } 1008 }
1008} 1009}
1009 1010
diff --git a/arch/powerpc/platforms/powermac/pic.c b/arch/powerpc/platforms/powermac/pic.c
index 3d328bc1f7e0..060789e31c67 100644
--- a/arch/powerpc/platforms/powermac/pic.c
+++ b/arch/powerpc/platforms/powermac/pic.c
@@ -291,7 +291,7 @@ static int pmac_pic_host_match(struct irq_host *h, struct device_node *node)
291} 291}
292 292
293static int pmac_pic_host_map(struct irq_host *h, unsigned int virq, 293static int pmac_pic_host_map(struct irq_host *h, unsigned int virq,
294 irq_hw_number_t hw, unsigned int flags) 294 irq_hw_number_t hw)
295{ 295{
296 struct irq_desc *desc = get_irq_desc(virq); 296 struct irq_desc *desc = get_irq_desc(virq);
297 int level; 297 int level;
@@ -318,6 +318,7 @@ static int pmac_pic_host_xlate(struct irq_host *h, struct device_node *ct,
318 unsigned int *out_flags) 318 unsigned int *out_flags)
319 319
320{ 320{
321 *out_flags = IRQ_TYPE_NONE;
321 *out_hwirq = *intspec; 322 *out_hwirq = *intspec;
322 return 0; 323 return 0;
323} 324}
@@ -434,7 +435,7 @@ static void __init pmac_pic_probe_oldstyle(void)
434 435
435 printk(KERN_INFO "irq: System has %d possible interrupts\n", max_irqs); 436 printk(KERN_INFO "irq: System has %d possible interrupts\n", max_irqs);
436#ifdef CONFIG_XMON 437#ifdef CONFIG_XMON
437 setup_irq(irq_create_mapping(NULL, 20, 0), &xmon_action); 438 setup_irq(irq_create_mapping(NULL, 20), &xmon_action);
438#endif 439#endif
439} 440}
440#endif /* CONFIG_PPC32 */ 441#endif /* CONFIG_PPC32 */
@@ -579,9 +580,10 @@ void __init pmac_pic_init(void)
579 flags |= OF_IMAP_OLDWORLD_MAC; 580 flags |= OF_IMAP_OLDWORLD_MAC;
580 if (get_property(of_chosen, "linux,bootx", NULL) != NULL) 581 if (get_property(of_chosen, "linux,bootx", NULL) != NULL)
581 flags |= OF_IMAP_NO_PHANDLE; 582 flags |= OF_IMAP_NO_PHANDLE;
582 of_irq_map_init(flags);
583#endif /* CONFIG_PPC_32 */ 583#endif /* CONFIG_PPC_32 */
584 584
585 of_irq_map_init(flags);
586
585 /* We first try to detect Apple's new Core99 chipset, since mac-io 587 /* We first try to detect Apple's new Core99 chipset, since mac-io
586 * is quite different on those machines and contains an IBM MPIC2. 588 * is quite different on those machines and contains an IBM MPIC2.
587 */ 589 */
diff --git a/arch/powerpc/platforms/pseries/ras.c b/arch/powerpc/platforms/pseries/ras.c
index 9df783088b61..c7ffde1a614e 100644
--- a/arch/powerpc/platforms/pseries/ras.c
+++ b/arch/powerpc/platforms/pseries/ras.c
@@ -93,8 +93,7 @@ static void request_ras_irqs(struct device_node *np,
93 for (i = 0; i < opicplen; i++) { 93 for (i = 0; i < opicplen; i++) {
94 if (count > 15) 94 if (count > 15)
95 break; 95 break;
96 virqs[count] = irq_create_mapping(NULL, *(opicprop++), 96 virqs[count] = irq_create_mapping(NULL, *(opicprop++));
97 IRQ_TYPE_NONE);
98 if (virqs[count] == NO_IRQ) 97 if (virqs[count] == NO_IRQ)
99 printk(KERN_ERR "Unable to allocate interrupt " 98 printk(KERN_ERR "Unable to allocate interrupt "
100 "number for %s\n", np->full_name); 99 "number for %s\n", np->full_name);
diff --git a/arch/powerpc/platforms/pseries/xics.c b/arch/powerpc/platforms/pseries/xics.c
index 716972aa9777..2d0da6f9e244 100644
--- a/arch/powerpc/platforms/pseries/xics.c
+++ b/arch/powerpc/platforms/pseries/xics.c
@@ -502,16 +502,9 @@ static int xics_host_match(struct irq_host *h, struct device_node *node)
502} 502}
503 503
504static int xics_host_map_direct(struct irq_host *h, unsigned int virq, 504static int xics_host_map_direct(struct irq_host *h, unsigned int virq,
505 irq_hw_number_t hw, unsigned int flags) 505 irq_hw_number_t hw)
506{ 506{
507 unsigned int sense = flags & IRQ_TYPE_SENSE_MASK; 507 pr_debug("xics: map_direct virq %d, hwirq 0x%lx\n", virq, hw);
508
509 pr_debug("xics: map_direct virq %d, hwirq 0x%lx, flags: 0x%x\n",
510 virq, hw, flags);
511
512 if (sense && sense != IRQ_TYPE_LEVEL_LOW)
513 printk(KERN_WARNING "xics: using unsupported sense 0x%x"
514 " for irq %d (h: 0x%lx)\n", flags, virq, hw);
515 508
516 get_irq_desc(virq)->status |= IRQ_LEVEL; 509 get_irq_desc(virq)->status |= IRQ_LEVEL;
517 set_irq_chip_and_handler(virq, &xics_pic_direct, handle_fasteoi_irq); 510 set_irq_chip_and_handler(virq, &xics_pic_direct, handle_fasteoi_irq);
@@ -519,16 +512,9 @@ static int xics_host_map_direct(struct irq_host *h, unsigned int virq,
519} 512}
520 513
521static int xics_host_map_lpar(struct irq_host *h, unsigned int virq, 514static int xics_host_map_lpar(struct irq_host *h, unsigned int virq,
522 irq_hw_number_t hw, unsigned int flags) 515 irq_hw_number_t hw)
523{ 516{
524 unsigned int sense = flags & IRQ_TYPE_SENSE_MASK; 517 pr_debug("xics: map_direct virq %d, hwirq 0x%lx\n", virq, hw);
525
526 pr_debug("xics: map_lpar virq %d, hwirq 0x%lx, flags: 0x%x\n",
527 virq, hw, flags);
528
529 if (sense && sense != IRQ_TYPE_LEVEL_LOW)
530 printk(KERN_WARNING "xics: using unsupported sense 0x%x"
531 " for irq %d (h: 0x%lx)\n", flags, virq, hw);
532 518
533 get_irq_desc(virq)->status |= IRQ_LEVEL; 519 get_irq_desc(virq)->status |= IRQ_LEVEL;
534 set_irq_chip_and_handler(virq, &xics_pic_lpar, handle_fasteoi_irq); 520 set_irq_chip_and_handler(virq, &xics_pic_lpar, handle_fasteoi_irq);
@@ -757,7 +743,7 @@ void xics_request_IPIs(void)
757{ 743{
758 unsigned int ipi; 744 unsigned int ipi;
759 745
760 ipi = irq_create_mapping(xics_host, XICS_IPI, 0); 746 ipi = irq_create_mapping(xics_host, XICS_IPI);
761 BUG_ON(ipi == NO_IRQ); 747 BUG_ON(ipi == NO_IRQ);
762 748
763 /* 749 /*
@@ -783,6 +769,14 @@ void xics_teardown_cpu(int secondary)
783 xics_set_cpu_priority(cpu, 0); 769 xics_set_cpu_priority(cpu, 0);
784 770
785 /* 771 /*
772 * Clear IPI
773 */
774 if (firmware_has_feature(FW_FEATURE_LPAR))
775 lpar_qirr_info(cpu, 0xff);
776 else
777 direct_qirr_info(cpu, 0xff);
778
779 /*
786 * we need to EOI the IPI if we got here from kexec down IPI 780 * we need to EOI the IPI if we got here from kexec down IPI
787 * 781 *
788 * probably need to check all the other interrupts too 782 * probably need to check all the other interrupts too
@@ -795,7 +789,7 @@ void xics_teardown_cpu(int secondary)
795 return; 789 return;
796 desc = get_irq_desc(ipi); 790 desc = get_irq_desc(ipi);
797 if (desc->chip && desc->chip->eoi) 791 if (desc->chip && desc->chip->eoi)
798 desc->chip->eoi(XICS_IPI); 792 desc->chip->eoi(ipi);
799 793
800 /* 794 /*
801 * Some machines need to have at least one cpu in the GIQ, 795 * Some machines need to have at least one cpu in the GIQ,
diff --git a/arch/powerpc/sysdev/i8259.c b/arch/powerpc/sysdev/i8259.c
index 72c73a6105cd..9855820b9548 100644
--- a/arch/powerpc/sysdev/i8259.c
+++ b/arch/powerpc/sysdev/i8259.c
@@ -169,7 +169,7 @@ static int i8259_host_match(struct irq_host *h, struct device_node *node)
169} 169}
170 170
171static int i8259_host_map(struct irq_host *h, unsigned int virq, 171static int i8259_host_map(struct irq_host *h, unsigned int virq,
172 irq_hw_number_t hw, unsigned int flags) 172 irq_hw_number_t hw)
173{ 173{
174 pr_debug("i8259_host_map(%d, 0x%lx)\n", virq, hw); 174 pr_debug("i8259_host_map(%d, 0x%lx)\n", virq, hw);
175 175
@@ -177,7 +177,7 @@ static int i8259_host_map(struct irq_host *h, unsigned int virq,
177 if (hw == 2) 177 if (hw == 2)
178 get_irq_desc(virq)->status |= IRQ_NOREQUEST; 178 get_irq_desc(virq)->status |= IRQ_NOREQUEST;
179 179
180 /* We use the level stuff only for now, we might want to 180 /* We use the level handler only for now, we might want to
181 * be more cautious here but that works for now 181 * be more cautious here but that works for now
182 */ 182 */
183 get_irq_desc(virq)->status |= IRQ_LEVEL; 183 get_irq_desc(virq)->status |= IRQ_LEVEL;
diff --git a/arch/powerpc/sysdev/mpic.c b/arch/powerpc/sysdev/mpic.c
index 9cecebaa0360..6e0281afa6c3 100644
--- a/arch/powerpc/sysdev/mpic.c
+++ b/arch/powerpc/sysdev/mpic.c
@@ -204,7 +204,7 @@ static void mpic_startup_ht_interrupt(struct mpic *mpic, unsigned int source,
204 if (fixup->base == NULL) 204 if (fixup->base == NULL)
205 return; 205 return;
206 206
207 DBG("startup_ht_interrupt(%u, %u) index: %d\n", 207 DBG("startup_ht_interrupt(0x%x, 0x%x) index: %d\n",
208 source, irqflags, fixup->index); 208 source, irqflags, fixup->index);
209 spin_lock_irqsave(&mpic->fixup_lock, flags); 209 spin_lock_irqsave(&mpic->fixup_lock, flags);
210 /* Enable and configure */ 210 /* Enable and configure */
@@ -227,7 +227,7 @@ static void mpic_shutdown_ht_interrupt(struct mpic *mpic, unsigned int source,
227 if (fixup->base == NULL) 227 if (fixup->base == NULL)
228 return; 228 return;
229 229
230 DBG("shutdown_ht_interrupt(%u, %u)\n", source, irqflags); 230 DBG("shutdown_ht_interrupt(0x%x, 0x%x)\n", source, irqflags);
231 231
232 /* Disable */ 232 /* Disable */
233 spin_lock_irqsave(&mpic->fixup_lock, flags); 233 spin_lock_irqsave(&mpic->fixup_lock, flags);
@@ -337,6 +337,17 @@ static void __init mpic_scan_ht_pics(struct mpic *mpic)
337 } 337 }
338} 338}
339 339
340#else /* CONFIG_MPIC_BROKEN_U3 */
341
342static inline int mpic_is_ht_interrupt(struct mpic *mpic, unsigned int source)
343{
344 return 0;
345}
346
347static void __init mpic_scan_ht_pics(struct mpic *mpic)
348{
349}
350
340#endif /* CONFIG_MPIC_BROKEN_U3 */ 351#endif /* CONFIG_MPIC_BROKEN_U3 */
341 352
342 353
@@ -405,11 +416,9 @@ static void mpic_unmask_irq(unsigned int irq)
405 unsigned int loops = 100000; 416 unsigned int loops = 100000;
406 struct mpic *mpic = mpic_from_irq(irq); 417 struct mpic *mpic = mpic_from_irq(irq);
407 unsigned int src = mpic_irq_to_hw(irq); 418 unsigned int src = mpic_irq_to_hw(irq);
408 unsigned long flags;
409 419
410 DBG("%p: %s: enable_irq: %d (src %d)\n", mpic, mpic->name, irq, src); 420 DBG("%p: %s: enable_irq: %d (src %d)\n", mpic, mpic->name, irq, src);
411 421
412 spin_lock_irqsave(&mpic_lock, flags);
413 mpic_irq_write(src, MPIC_IRQ_VECTOR_PRI, 422 mpic_irq_write(src, MPIC_IRQ_VECTOR_PRI,
414 mpic_irq_read(src, MPIC_IRQ_VECTOR_PRI) & 423 mpic_irq_read(src, MPIC_IRQ_VECTOR_PRI) &
415 ~MPIC_VECPRI_MASK); 424 ~MPIC_VECPRI_MASK);
@@ -420,7 +429,6 @@ static void mpic_unmask_irq(unsigned int irq)
420 break; 429 break;
421 } 430 }
422 } while(mpic_irq_read(src, MPIC_IRQ_VECTOR_PRI) & MPIC_VECPRI_MASK); 431 } while(mpic_irq_read(src, MPIC_IRQ_VECTOR_PRI) & MPIC_VECPRI_MASK);
423 spin_unlock_irqrestore(&mpic_lock, flags);
424} 432}
425 433
426static void mpic_mask_irq(unsigned int irq) 434static void mpic_mask_irq(unsigned int irq)
@@ -428,11 +436,9 @@ static void mpic_mask_irq(unsigned int irq)
428 unsigned int loops = 100000; 436 unsigned int loops = 100000;
429 struct mpic *mpic = mpic_from_irq(irq); 437 struct mpic *mpic = mpic_from_irq(irq);
430 unsigned int src = mpic_irq_to_hw(irq); 438 unsigned int src = mpic_irq_to_hw(irq);
431 unsigned long flags;
432 439
433 DBG("%s: disable_irq: %d (src %d)\n", mpic->name, irq, src); 440 DBG("%s: disable_irq: %d (src %d)\n", mpic->name, irq, src);
434 441
435 spin_lock_irqsave(&mpic_lock, flags);
436 mpic_irq_write(src, MPIC_IRQ_VECTOR_PRI, 442 mpic_irq_write(src, MPIC_IRQ_VECTOR_PRI,
437 mpic_irq_read(src, MPIC_IRQ_VECTOR_PRI) | 443 mpic_irq_read(src, MPIC_IRQ_VECTOR_PRI) |
438 MPIC_VECPRI_MASK); 444 MPIC_VECPRI_MASK);
@@ -444,7 +450,6 @@ static void mpic_mask_irq(unsigned int irq)
444 break; 450 break;
445 } 451 }
446 } while(!(mpic_irq_read(src, MPIC_IRQ_VECTOR_PRI) & MPIC_VECPRI_MASK)); 452 } while(!(mpic_irq_read(src, MPIC_IRQ_VECTOR_PRI) & MPIC_VECPRI_MASK));
447 spin_unlock_irqrestore(&mpic_lock, flags);
448} 453}
449 454
450static void mpic_end_irq(unsigned int irq) 455static void mpic_end_irq(unsigned int irq)
@@ -512,8 +517,7 @@ static void mpic_end_ht_irq(unsigned int irq)
512 mpic_ht_end_irq(mpic, src); 517 mpic_ht_end_irq(mpic, src);
513 mpic_eoi(mpic); 518 mpic_eoi(mpic);
514} 519}
515 520#endif /* !CONFIG_MPIC_BROKEN_U3 */
516#endif /* CONFIG_MPIC_BROKEN_U3 */
517 521
518#ifdef CONFIG_SMP 522#ifdef CONFIG_SMP
519 523
@@ -560,47 +564,74 @@ static void mpic_set_affinity(unsigned int irq, cpumask_t cpumask)
560 mpic_physmask(cpus_addr(tmp)[0])); 564 mpic_physmask(cpus_addr(tmp)[0]));
561} 565}
562 566
563static unsigned int mpic_flags_to_vecpri(unsigned int flags, int *level) 567static unsigned int mpic_type_to_vecpri(unsigned int type)
564{ 568{
565 unsigned int vecpri;
566
567 /* Now convert sense value */ 569 /* Now convert sense value */
568 switch(flags & IRQ_TYPE_SENSE_MASK) { 570 switch(type & IRQ_TYPE_SENSE_MASK) {
569 case IRQ_TYPE_EDGE_RISING: 571 case IRQ_TYPE_EDGE_RISING:
570 vecpri = MPIC_VECPRI_SENSE_EDGE | 572 return MPIC_VECPRI_SENSE_EDGE | MPIC_VECPRI_POLARITY_POSITIVE;
571 MPIC_VECPRI_POLARITY_POSITIVE;
572 *level = 0;
573 break;
574 case IRQ_TYPE_EDGE_FALLING: 573 case IRQ_TYPE_EDGE_FALLING:
575 vecpri = MPIC_VECPRI_SENSE_EDGE | 574 case IRQ_TYPE_EDGE_BOTH:
576 MPIC_VECPRI_POLARITY_NEGATIVE; 575 return MPIC_VECPRI_SENSE_EDGE | MPIC_VECPRI_POLARITY_NEGATIVE;
577 *level = 0;
578 break;
579 case IRQ_TYPE_LEVEL_HIGH: 576 case IRQ_TYPE_LEVEL_HIGH:
580 vecpri = MPIC_VECPRI_SENSE_LEVEL | 577 return MPIC_VECPRI_SENSE_LEVEL | MPIC_VECPRI_POLARITY_POSITIVE;
581 MPIC_VECPRI_POLARITY_POSITIVE;
582 *level = 1;
583 break;
584 case IRQ_TYPE_LEVEL_LOW: 578 case IRQ_TYPE_LEVEL_LOW:
585 default: 579 default:
586 vecpri = MPIC_VECPRI_SENSE_LEVEL | 580 return MPIC_VECPRI_SENSE_LEVEL | MPIC_VECPRI_POLARITY_NEGATIVE;
587 MPIC_VECPRI_POLARITY_NEGATIVE;
588 *level = 1;
589 } 581 }
590 return vecpri; 582}
583
584static int mpic_set_irq_type(unsigned int virq, unsigned int flow_type)
585{
586 struct mpic *mpic = mpic_from_irq(virq);
587 unsigned int src = mpic_irq_to_hw(virq);
588 struct irq_desc *desc = get_irq_desc(virq);
589 unsigned int vecpri, vold, vnew;
590
591 DBG("mpic: set_irq_type(mpic:@%p,virq:%d,src:0x%x,type:0x%x)\n",
592 mpic, virq, src, flow_type);
593
594 if (src >= mpic->irq_count)
595 return -EINVAL;
596
597 if (flow_type == IRQ_TYPE_NONE)
598 if (mpic->senses && src < mpic->senses_count)
599 flow_type = mpic->senses[src];
600 if (flow_type == IRQ_TYPE_NONE)
601 flow_type = IRQ_TYPE_LEVEL_LOW;
602
603 desc->status &= ~(IRQ_TYPE_SENSE_MASK | IRQ_LEVEL);
604 desc->status |= flow_type & IRQ_TYPE_SENSE_MASK;
605 if (flow_type & (IRQ_TYPE_LEVEL_HIGH | IRQ_TYPE_LEVEL_LOW))
606 desc->status |= IRQ_LEVEL;
607
608 if (mpic_is_ht_interrupt(mpic, src))
609 vecpri = MPIC_VECPRI_POLARITY_POSITIVE |
610 MPIC_VECPRI_SENSE_EDGE;
611 else
612 vecpri = mpic_type_to_vecpri(flow_type);
613
614 vold = mpic_irq_read(src, MPIC_IRQ_VECTOR_PRI);
615 vnew = vold & ~(MPIC_VECPRI_POLARITY_MASK | MPIC_VECPRI_SENSE_MASK);
616 vnew |= vecpri;
617 if (vold != vnew)
618 mpic_irq_write(src, MPIC_IRQ_VECTOR_PRI, vnew);
619
620 return 0;
591} 621}
592 622
593static struct irq_chip mpic_irq_chip = { 623static struct irq_chip mpic_irq_chip = {
594 .mask = mpic_mask_irq, 624 .mask = mpic_mask_irq,
595 .unmask = mpic_unmask_irq, 625 .unmask = mpic_unmask_irq,
596 .eoi = mpic_end_irq, 626 .eoi = mpic_end_irq,
627 .set_type = mpic_set_irq_type,
597}; 628};
598 629
599#ifdef CONFIG_SMP 630#ifdef CONFIG_SMP
600static struct irq_chip mpic_ipi_chip = { 631static struct irq_chip mpic_ipi_chip = {
601 .mask = mpic_mask_ipi, 632 .mask = mpic_mask_ipi,
602 .unmask = mpic_unmask_ipi, 633 .unmask = mpic_unmask_ipi,
603 .eoi = mpic_end_ipi, 634 .eoi = mpic_end_ipi,
604}; 635};
605#endif /* CONFIG_SMP */ 636#endif /* CONFIG_SMP */
606 637
@@ -611,6 +642,7 @@ static struct irq_chip mpic_irq_ht_chip = {
611 .mask = mpic_mask_irq, 642 .mask = mpic_mask_irq,
612 .unmask = mpic_unmask_ht_irq, 643 .unmask = mpic_unmask_ht_irq,
613 .eoi = mpic_end_ht_irq, 644 .eoi = mpic_end_ht_irq,
645 .set_type = mpic_set_irq_type,
614}; 646};
615#endif /* CONFIG_MPIC_BROKEN_U3 */ 647#endif /* CONFIG_MPIC_BROKEN_U3 */
616 648
@@ -624,26 +656,21 @@ static int mpic_host_match(struct irq_host *h, struct device_node *node)
624} 656}
625 657
626static int mpic_host_map(struct irq_host *h, unsigned int virq, 658static int mpic_host_map(struct irq_host *h, unsigned int virq,
627 irq_hw_number_t hw, unsigned int flags) 659 irq_hw_number_t hw)
628{ 660{
629 struct irq_desc *desc = get_irq_desc(virq);
630 struct irq_chip *chip;
631 struct mpic *mpic = h->host_data; 661 struct mpic *mpic = h->host_data;
632 u32 v, vecpri = MPIC_VECPRI_SENSE_LEVEL | 662 struct irq_chip *chip;
633 MPIC_VECPRI_POLARITY_NEGATIVE;
634 int level;
635 unsigned long iflags;
636 663
637 pr_debug("mpic: map virq %d, hwirq 0x%lx, flags: 0x%x\n", 664 DBG("mpic: map virq %d, hwirq 0x%lx\n", virq, hw);
638 virq, hw, flags);
639 665
640 if (hw == MPIC_VEC_SPURRIOUS) 666 if (hw == MPIC_VEC_SPURRIOUS)
641 return -EINVAL; 667 return -EINVAL;
668
642#ifdef CONFIG_SMP 669#ifdef CONFIG_SMP
643 else if (hw >= MPIC_VEC_IPI_0) { 670 else if (hw >= MPIC_VEC_IPI_0) {
644 WARN_ON(!(mpic->flags & MPIC_PRIMARY)); 671 WARN_ON(!(mpic->flags & MPIC_PRIMARY));
645 672
646 pr_debug("mpic: mapping as IPI\n"); 673 DBG("mpic: mapping as IPI\n");
647 set_irq_chip_data(virq, mpic); 674 set_irq_chip_data(virq, mpic);
648 set_irq_chip_and_handler(virq, &mpic->hc_ipi, 675 set_irq_chip_and_handler(virq, &mpic->hc_ipi,
649 handle_percpu_irq); 676 handle_percpu_irq);
@@ -654,44 +681,23 @@ static int mpic_host_map(struct irq_host *h, unsigned int virq,
654 if (hw >= mpic->irq_count) 681 if (hw >= mpic->irq_count)
655 return -EINVAL; 682 return -EINVAL;
656 683
657 /* If no sense provided, check default sense array */ 684 /* Default chip */
658 if (((flags & IRQ_TYPE_SENSE_MASK) == IRQ_TYPE_NONE) &&
659 mpic->senses && hw < mpic->senses_count)
660 flags |= mpic->senses[hw];
661
662 vecpri = mpic_flags_to_vecpri(flags, &level);
663 if (level)
664 desc->status |= IRQ_LEVEL;
665 chip = &mpic->hc_irq; 685 chip = &mpic->hc_irq;
666 686
667#ifdef CONFIG_MPIC_BROKEN_U3 687#ifdef CONFIG_MPIC_BROKEN_U3
668 /* Check for HT interrupts, override vecpri */ 688 /* Check for HT interrupts, override vecpri */
669 if (mpic_is_ht_interrupt(mpic, hw)) { 689 if (mpic_is_ht_interrupt(mpic, hw))
670 vecpri &= ~(MPIC_VECPRI_SENSE_MASK |
671 MPIC_VECPRI_POLARITY_MASK);
672 vecpri |= MPIC_VECPRI_POLARITY_POSITIVE;
673 chip = &mpic->hc_ht_irq; 690 chip = &mpic->hc_ht_irq;
674 } 691#endif /* CONFIG_MPIC_BROKEN_U3 */
675#endif
676 692
677 /* Reconfigure irq. We must preserve the mask bit as we can be called 693 DBG("mpic: mapping to irq chip @%p\n", chip);
678 * while the interrupt is still active (This may change in the future
679 * but for now, it is the case).
680 */
681 spin_lock_irqsave(&mpic_lock, iflags);
682 v = mpic_irq_read(hw, MPIC_IRQ_VECTOR_PRI);
683 vecpri = (v &
684 ~(MPIC_VECPRI_POLARITY_MASK | MPIC_VECPRI_SENSE_MASK)) |
685 vecpri;
686 if (vecpri != v)
687 mpic_irq_write(hw, MPIC_IRQ_VECTOR_PRI, vecpri);
688 spin_unlock_irqrestore(&mpic_lock, iflags);
689
690 pr_debug("mpic: mapping as IRQ, vecpri = 0x%08x (was 0x%08x)\n",
691 vecpri, v);
692 694
693 set_irq_chip_data(virq, mpic); 695 set_irq_chip_data(virq, mpic);
694 set_irq_chip_and_handler(virq, chip, handle_fasteoi_irq); 696 set_irq_chip_and_handler(virq, chip, handle_fasteoi_irq);
697
698 /* Set default irq type */
699 set_irq_type(virq, IRQ_TYPE_NONE);
700
695 return 0; 701 return 0;
696} 702}
697 703
@@ -708,11 +714,28 @@ static int mpic_host_xlate(struct irq_host *h, struct device_node *ct,
708 }; 714 };
709 715
710 *out_hwirq = intspec[0]; 716 *out_hwirq = intspec[0];
711 if (intsize > 1 && intspec[1] < 4) 717 if (intsize > 1) {
712 *out_flags = map_mpic_senses[intspec[1]]; 718 u32 mask = 0x3;
713 else 719
720 /* Apple invented a new race of encoding on machines with
721 * an HT APIC. They encode, among others, the index within
722 * the HT APIC. We don't care about it here since thankfully,
723 * it appears that they have the APIC already properly
724 * configured, and thus our current fixup code that reads the
725 * APIC config works fine. However, we still need to mask out
726 * bits in the specifier to make sure we only get bit 0 which
727 * is the level/edge bit (the only sense bit exposed by Apple),
728 * as their bit 1 means something else.
729 */
730 if (machine_is(powermac))
731 mask = 0x1;
732 *out_flags = map_mpic_senses[intspec[1] & mask];
733 } else
714 *out_flags = IRQ_TYPE_NONE; 734 *out_flags = IRQ_TYPE_NONE;
715 735
736 DBG("mpic: xlate (%d cells: 0x%08x 0x%08x) to line 0x%lx sense 0x%x\n",
737 intsize, intspec[0], intspec[1], *out_hwirq, *out_flags);
738
716 return 0; 739 return 0;
717} 740}
718 741
@@ -906,41 +929,16 @@ void __init mpic_init(struct mpic *mpic)
906 if (mpic->irq_count == 0) 929 if (mpic->irq_count == 0)
907 mpic->irq_count = mpic->num_sources; 930 mpic->irq_count = mpic->num_sources;
908 931
909#ifdef CONFIG_MPIC_BROKEN_U3
910 /* Do the HT PIC fixups on U3 broken mpic */ 932 /* Do the HT PIC fixups on U3 broken mpic */
911 DBG("MPIC flags: %x\n", mpic->flags); 933 DBG("MPIC flags: %x\n", mpic->flags);
912 if ((mpic->flags & MPIC_BROKEN_U3) && (mpic->flags & MPIC_PRIMARY)) 934 if ((mpic->flags & MPIC_BROKEN_U3) && (mpic->flags & MPIC_PRIMARY))
913 mpic_scan_ht_pics(mpic); 935 mpic_scan_ht_pics(mpic);
914#endif /* CONFIG_MPIC_BROKEN_U3 */
915 936
916 for (i = 0; i < mpic->num_sources; i++) { 937 for (i = 0; i < mpic->num_sources; i++) {
917 /* start with vector = source number, and masked */ 938 /* start with vector = source number, and masked */
918 u32 vecpri = MPIC_VECPRI_MASK | i | (8 << MPIC_VECPRI_PRIORITY_SHIFT); 939 u32 vecpri = MPIC_VECPRI_MASK | i |
919 int level = 1; 940 (8 << MPIC_VECPRI_PRIORITY_SHIFT);
920 941
921 /* do senses munging */
922 if (mpic->senses && i < mpic->senses_count)
923 vecpri |= mpic_flags_to_vecpri(mpic->senses[i],
924 &level);
925 else
926 vecpri |= MPIC_VECPRI_SENSE_LEVEL;
927
928 /* deal with broken U3 */
929 if (mpic->flags & MPIC_BROKEN_U3) {
930#ifdef CONFIG_MPIC_BROKEN_U3
931 if (mpic_is_ht_interrupt(mpic, i)) {
932 vecpri &= ~(MPIC_VECPRI_SENSE_MASK |
933 MPIC_VECPRI_POLARITY_MASK);
934 vecpri |= MPIC_VECPRI_POLARITY_POSITIVE;
935 }
936#else
937 printk(KERN_ERR "mpic: BROKEN_U3 set, but CONFIG doesn't match\n");
938#endif
939 }
940
941 DBG("setup source %d, vecpri: %08x, level: %d\n", i, vecpri,
942 (level != 0));
943
944 /* init hw */ 942 /* init hw */
945 mpic_irq_write(i, MPIC_IRQ_VECTOR_PRI, vecpri); 943 mpic_irq_write(i, MPIC_IRQ_VECTOR_PRI, vecpri);
946 mpic_irq_write(i, MPIC_IRQ_DESTINATION, 944 mpic_irq_write(i, MPIC_IRQ_DESTINATION,
@@ -1154,7 +1152,7 @@ void mpic_request_ipis(void)
1154 1152
1155 for (i = 0; i < 4; i++) { 1153 for (i = 0; i < 4; i++) {
1156 unsigned int vipi = irq_create_mapping(mpic->irqhost, 1154 unsigned int vipi = irq_create_mapping(mpic->irqhost,
1157 MPIC_VEC_IPI_0 + i, 0); 1155 MPIC_VEC_IPI_0 + i);
1158 if (vipi == NO_IRQ) { 1156 if (vipi == NO_IRQ) {
1159 printk(KERN_ERR "Failed to map IPI %d\n", i); 1157 printk(KERN_ERR "Failed to map IPI %d\n", i);
1160 break; 1158 break;
diff --git a/arch/ppc/kernel/ppc_ksyms.c b/arch/ppc/kernel/ppc_ksyms.c
index 50c1b4739ca7..d1735401384c 100644
--- a/arch/ppc/kernel/ppc_ksyms.c
+++ b/arch/ppc/kernel/ppc_ksyms.c
@@ -5,7 +5,7 @@
5#include <linux/elfcore.h> 5#include <linux/elfcore.h>
6#include <linux/string.h> 6#include <linux/string.h>
7#include <linux/interrupt.h> 7#include <linux/interrupt.h>
8#include <linux/tty.h> 8#include <linux/screen_info.h>
9#include <linux/vt_kern.h> 9#include <linux/vt_kern.h>
10#include <linux/nvram.h> 10#include <linux/nvram.h>
11#include <linux/console.h> 11#include <linux/console.h>
diff --git a/arch/ppc/kernel/setup.c b/arch/ppc/kernel/setup.c
index faf2940300b0..a74f46d9826f 100644
--- a/arch/ppc/kernel/setup.c
+++ b/arch/ppc/kernel/setup.c
@@ -11,7 +11,7 @@
11#include <linux/delay.h> 11#include <linux/delay.h>
12#include <linux/initrd.h> 12#include <linux/initrd.h>
13#include <linux/ide.h> 13#include <linux/ide.h>
14#include <linux/tty.h> 14#include <linux/screen_info.h>
15#include <linux/bootmem.h> 15#include <linux/bootmem.h>
16#include <linux/seq_file.h> 16#include <linux/seq_file.h>
17#include <linux/root_dev.h> 17#include <linux/root_dev.h>
diff --git a/arch/ppc/platforms/prep_setup.c b/arch/ppc/platforms/prep_setup.c
index 6436beffdc96..1cb75a1f825e 100644
--- a/arch/ppc/platforms/prep_setup.c
+++ b/arch/ppc/platforms/prep_setup.c
@@ -23,7 +23,7 @@
23#include <linux/slab.h> 23#include <linux/slab.h>
24#include <linux/user.h> 24#include <linux/user.h>
25#include <linux/a.out.h> 25#include <linux/a.out.h>
26#include <linux/tty.h> 26#include <linux/screen_info.h>
27#include <linux/major.h> 27#include <linux/major.h>
28#include <linux/interrupt.h> 28#include <linux/interrupt.h>
29#include <linux/reboot.h> 29#include <linux/reboot.h>
diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
index 224fbff79969..ae071a11ce71 100644
--- a/arch/s390/Kconfig
+++ b/arch/s390/Kconfig
@@ -118,13 +118,6 @@ config SYSVIPC_COMPAT
118 depends on COMPAT && SYSVIPC 118 depends on COMPAT && SYSVIPC
119 default y 119 default y
120 120
121config BINFMT_ELF32
122 tristate "Kernel support for 31 bit ELF binaries"
123 depends on COMPAT
124 help
125 This allows you to run 32-bit Linux/ELF binaries on your zSeries
126 in 64 bit mode. Everybody wants this; say Y.
127
128comment "Code generation options" 121comment "Code generation options"
129 122
130choice 123choice
diff --git a/arch/s390/kernel/Makefile b/arch/s390/kernel/Makefile
index eabf00a6f770..86601a945709 100644
--- a/arch/s390/kernel/Makefile
+++ b/arch/s390/kernel/Makefile
@@ -17,8 +17,8 @@ obj-$(CONFIG_MODULES) += s390_ksyms.o module.o
17obj-$(CONFIG_SMP) += smp.o 17obj-$(CONFIG_SMP) += smp.o
18 18
19obj-$(CONFIG_COMPAT) += compat_linux.o compat_signal.o \ 19obj-$(CONFIG_COMPAT) += compat_linux.o compat_signal.o \
20 compat_wrapper.o compat_exec_domain.o 20 compat_wrapper.o compat_exec_domain.o \
21obj-$(CONFIG_BINFMT_ELF32) += binfmt_elf32.o 21 binfmt_elf32.o
22 22
23obj-$(CONFIG_VIRT_TIMER) += vtime.o 23obj-$(CONFIG_VIRT_TIMER) += vtime.o
24obj-$(CONFIG_STACKTRACE) += stacktrace.o 24obj-$(CONFIG_STACKTRACE) += stacktrace.o
diff --git a/arch/sh/kernel/setup.c b/arch/sh/kernel/setup.c
index 9af22116c9a2..e75189cb1db7 100644
--- a/arch/sh/kernel/setup.c
+++ b/arch/sh/kernel/setup.c
@@ -10,7 +10,7 @@
10 * This file handles the architecture-dependent parts of initialization 10 * This file handles the architecture-dependent parts of initialization
11 */ 11 */
12 12
13#include <linux/tty.h> 13#include <linux/screen_info.h>
14#include <linux/ioport.h> 14#include <linux/ioport.h>
15#include <linux/init.h> 15#include <linux/init.h>
16#include <linux/initrd.h> 16#include <linux/initrd.h>
diff --git a/arch/sh64/kernel/setup.c b/arch/sh64/kernel/setup.c
index 0359fa647bbc..ffb310e33cef 100644
--- a/arch/sh64/kernel/setup.c
+++ b/arch/sh64/kernel/setup.c
@@ -36,7 +36,7 @@
36#include <linux/slab.h> 36#include <linux/slab.h>
37#include <linux/user.h> 37#include <linux/user.h>
38#include <linux/a.out.h> 38#include <linux/a.out.h>
39#include <linux/tty.h> 39#include <linux/screen_info.h>
40#include <linux/ioport.h> 40#include <linux/ioport.h>
41#include <linux/delay.h> 41#include <linux/delay.h>
42#include <linux/init.h> 42#include <linux/init.h>
diff --git a/arch/sh64/kernel/sh_ksyms.c b/arch/sh64/kernel/sh_ksyms.c
index 6efdfa2c3994..4b2df7247b59 100644
--- a/arch/sh64/kernel/sh_ksyms.c
+++ b/arch/sh64/kernel/sh_ksyms.c
@@ -18,7 +18,7 @@
18#include <linux/in6.h> 18#include <linux/in6.h>
19#include <linux/interrupt.h> 19#include <linux/interrupt.h>
20#include <linux/smp_lock.h> 20#include <linux/smp_lock.h>
21#include <linux/tty.h> 21#include <linux/screen_info.h>
22 22
23#include <asm/semaphore.h> 23#include <asm/semaphore.h>
24#include <asm/processor.h> 24#include <asm/processor.h>
diff --git a/arch/sparc/kernel/setup.c b/arch/sparc/kernel/setup.c
index 8606ef4e52e9..35488d6c7457 100644
--- a/arch/sparc/kernel/setup.c
+++ b/arch/sparc/kernel/setup.c
@@ -17,7 +17,7 @@
17#include <asm/smp.h> 17#include <asm/smp.h>
18#include <linux/user.h> 18#include <linux/user.h>
19#include <linux/a.out.h> 19#include <linux/a.out.h>
20#include <linux/tty.h> 20#include <linux/screen_info.h>
21#include <linux/delay.h> 21#include <linux/delay.h>
22#include <linux/fs.h> 22#include <linux/fs.h>
23#include <linux/seq_file.h> 23#include <linux/seq_file.h>
diff --git a/arch/sparc64/Kconfig b/arch/sparc64/Kconfig
index a7a111db25b2..8a36ba8868db 100644
--- a/arch/sparc64/Kconfig
+++ b/arch/sparc64/Kconfig
@@ -334,7 +334,7 @@ config COMPAT
334 default y 334 default y
335 335
336config BINFMT_ELF32 336config BINFMT_ELF32
337 tristate "Kernel support for 32-bit ELF binaries" 337 bool "Kernel support for 32-bit ELF binaries"
338 depends on SPARC32_COMPAT 338 depends on SPARC32_COMPAT
339 help 339 help
340 This allows you to run 32-bit Linux/ELF binaries on your Ultra. 340 This allows you to run 32-bit Linux/ELF binaries on your Ultra.
diff --git a/arch/sparc64/kernel/setup.c b/arch/sparc64/kernel/setup.c
index a73140466e01..958287448cfe 100644
--- a/arch/sparc64/kernel/setup.c
+++ b/arch/sparc64/kernel/setup.c
@@ -16,7 +16,7 @@
16#include <asm/smp.h> 16#include <asm/smp.h>
17#include <linux/user.h> 17#include <linux/user.h>
18#include <linux/a.out.h> 18#include <linux/a.out.h>
19#include <linux/tty.h> 19#include <linux/screen_info.h>
20#include <linux/delay.h> 20#include <linux/delay.h>
21#include <linux/fs.h> 21#include <linux/fs.h>
22#include <linux/seq_file.h> 22#include <linux/seq_file.h>
diff --git a/arch/um/Kconfig.debug b/arch/um/Kconfig.debug
index bab51d619173..09c1aca6339f 100644
--- a/arch/um/Kconfig.debug
+++ b/arch/um/Kconfig.debug
@@ -47,13 +47,4 @@ config GCOV
47 If you're involved in UML kernel development and want to use gcov, 47 If you're involved in UML kernel development and want to use gcov,
48 say Y. If you're unsure, say N. 48 say Y. If you're unsure, say N.
49 49
50config SYSCALL_DEBUG
51 bool "Enable system call debugging"
52 depends on DEBUG_INFO
53 help
54 This adds some system debugging to UML, including keeping a ring buffer
55 with recent system calls and some global and per-task statistics.
56
57 If unsure, say N
58
59endmenu 50endmenu
diff --git a/arch/um/defconfig b/arch/um/defconfig
index 402a74dc5026..780cc0a4a128 100644
--- a/arch/um/defconfig
+++ b/arch/um/defconfig
@@ -526,4 +526,3 @@ CONFIG_FORCED_INLINING=y
526# CONFIG_RCU_TORTURE_TEST is not set 526# CONFIG_RCU_TORTURE_TEST is not set
527# CONFIG_GPROF is not set 527# CONFIG_GPROF is not set
528# CONFIG_GCOV is not set 528# CONFIG_GCOV is not set
529# CONFIG_SYSCALL_DEBUG is not set
diff --git a/arch/um/drivers/mconsole_user.c b/arch/um/drivers/mconsole_user.c
index 4b109fe7fff8..9bfd405c3bd8 100644
--- a/arch/um/drivers/mconsole_user.c
+++ b/arch/um/drivers/mconsole_user.c
@@ -18,7 +18,12 @@
18#include "umid.h" 18#include "umid.h"
19 19
20static struct mconsole_command commands[] = { 20static struct mconsole_command commands[] = {
21 { "version", mconsole_version, MCONSOLE_INTR }, 21 /* With uts namespaces, uts information becomes process-specific, so
22 * we need a process context. If we try handling this in interrupt
23 * context, we may hit an exiting process without a valid uts
24 * namespace.
25 */
26 { "version", mconsole_version, MCONSOLE_PROC },
22 { "halt", mconsole_halt, MCONSOLE_PROC }, 27 { "halt", mconsole_halt, MCONSOLE_PROC },
23 { "reboot", mconsole_reboot, MCONSOLE_PROC }, 28 { "reboot", mconsole_reboot, MCONSOLE_PROC },
24 { "config", mconsole_config, MCONSOLE_PROC }, 29 { "config", mconsole_config, MCONSOLE_PROC },
diff --git a/arch/um/drivers/net_user.c b/arch/um/drivers/net_user.c
index 0a7786e00cfb..107c5e43fa00 100644
--- a/arch/um/drivers/net_user.c
+++ b/arch/um/drivers/net_user.c
@@ -22,13 +22,14 @@ int tap_open_common(void *dev, char *gate_addr)
22{ 22{
23 int tap_addr[4]; 23 int tap_addr[4];
24 24
25 if(gate_addr == NULL) return(0); 25 if(gate_addr == NULL)
26 return 0;
26 if(sscanf(gate_addr, "%d.%d.%d.%d", &tap_addr[0], 27 if(sscanf(gate_addr, "%d.%d.%d.%d", &tap_addr[0],
27 &tap_addr[1], &tap_addr[2], &tap_addr[3]) != 4){ 28 &tap_addr[1], &tap_addr[2], &tap_addr[3]) != 4){
28 printk("Invalid tap IP address - '%s'\n", gate_addr); 29 printk("Invalid tap IP address - '%s'\n", gate_addr);
29 return(-EINVAL); 30 return -EINVAL;
30 } 31 }
31 return(0); 32 return 0;
32} 33}
33 34
34void tap_check_ips(char *gate_addr, unsigned char *eth_addr) 35void tap_check_ips(char *gate_addr, unsigned char *eth_addr)
@@ -94,25 +95,25 @@ int net_read(int fd, void *buf, int len)
94 n = os_read_file(fd, buf, len); 95 n = os_read_file(fd, buf, len);
95 96
96 if(n == -EAGAIN) 97 if(n == -EAGAIN)
97 return(0); 98 return 0;
98 else if(n == 0) 99 else if(n == 0)
99 return(-ENOTCONN); 100 return -ENOTCONN;
100 return(n); 101 return n;
101} 102}
102 103
103int net_recvfrom(int fd, void *buf, int len) 104int net_recvfrom(int fd, void *buf, int len)
104{ 105{
105 int n; 106 int n;
106 107
107 while(((n = recvfrom(fd, buf, len, 0, NULL, NULL)) < 0) && 108 CATCH_EINTR(n = recvfrom(fd, buf, len, 0, NULL, NULL));
108 (errno == EINTR)) ;
109
110 if(n < 0){ 109 if(n < 0){
111 if(errno == EAGAIN) return(0); 110 if(errno == EAGAIN)
112 return(-errno); 111 return 0;
112 return -errno;
113 } 113 }
114 else if(n == 0) return(-ENOTCONN); 114 else if(n == 0)
115 return(n); 115 return -ENOTCONN;
116 return n;
116} 117}
117 118
118int net_write(int fd, void *buf, int len) 119int net_write(int fd, void *buf, int len)
@@ -122,37 +123,41 @@ int net_write(int fd, void *buf, int len)
122 n = os_write_file(fd, buf, len); 123 n = os_write_file(fd, buf, len);
123 124
124 if(n == -EAGAIN) 125 if(n == -EAGAIN)
125 return(0); 126 return 0;
126 else if(n == 0) 127 else if(n == 0)
127 return(-ENOTCONN); 128 return -ENOTCONN;
128 return(n); 129 return n;
129} 130}
130 131
131int net_send(int fd, void *buf, int len) 132int net_send(int fd, void *buf, int len)
132{ 133{
133 int n; 134 int n;
134 135
135 while(((n = send(fd, buf, len, 0)) < 0) && (errno == EINTR)) ; 136 CATCH_EINTR(n = send(fd, buf, len, 0));
136 if(n < 0){ 137 if(n < 0){
137 if(errno == EAGAIN) return(0); 138 if(errno == EAGAIN)
138 return(-errno); 139 return 0;
140 return -errno;
139 } 141 }
140 else if(n == 0) return(-ENOTCONN); 142 else if(n == 0)
141 return(n); 143 return -ENOTCONN;
144 return n;
142} 145}
143 146
144int net_sendto(int fd, void *buf, int len, void *to, int sock_len) 147int net_sendto(int fd, void *buf, int len, void *to, int sock_len)
145{ 148{
146 int n; 149 int n;
147 150
148 while(((n = sendto(fd, buf, len, 0, (struct sockaddr *) to, 151 CATCH_EINTR(n = sendto(fd, buf, len, 0, (struct sockaddr *) to,
149 sock_len)) < 0) && (errno == EINTR)) ; 152 sock_len));
150 if(n < 0){ 153 if(n < 0){
151 if(errno == EAGAIN) return(0); 154 if(errno == EAGAIN)
152 return(-errno); 155 return 0;
156 return -errno;
153 } 157 }
154 else if(n == 0) return(-ENOTCONN); 158 else if(n == 0)
155 return(n); 159 return -ENOTCONN;
160 return n;
156} 161}
157 162
158struct change_pre_exec_data { 163struct change_pre_exec_data {
@@ -176,7 +181,7 @@ static int change_tramp(char **argv, char *output, int output_len)
176 err = os_pipe(fds, 1, 0); 181 err = os_pipe(fds, 1, 0);
177 if(err < 0){ 182 if(err < 0){
178 printk("change_tramp - pipe failed, err = %d\n", -err); 183 printk("change_tramp - pipe failed, err = %d\n", -err);
179 return(err); 184 return err;
180 } 185 }
181 pe_data.close_me = fds[0]; 186 pe_data.close_me = fds[0];
182 pe_data.stdout = fds[1]; 187 pe_data.stdout = fds[1];
@@ -190,7 +195,7 @@ static int change_tramp(char **argv, char *output, int output_len)
190 195
191 if (pid > 0) 196 if (pid > 0)
192 CATCH_EINTR(err = waitpid(pid, NULL, 0)); 197 CATCH_EINTR(err = waitpid(pid, NULL, 0));
193 return(pid); 198 return pid;
194} 199}
195 200
196static void change(char *dev, char *what, unsigned char *addr, 201static void change(char *dev, char *what, unsigned char *addr,
@@ -241,26 +246,15 @@ char *split_if_spec(char *str, ...)
241 va_start(ap, str); 246 va_start(ap, str);
242 while((arg = va_arg(ap, char **)) != NULL){ 247 while((arg = va_arg(ap, char **)) != NULL){
243 if(*str == '\0') 248 if(*str == '\0')
244 return(NULL); 249 return NULL;
245 end = strchr(str, ','); 250 end = strchr(str, ',');
246 if(end != str) 251 if(end != str)
247 *arg = str; 252 *arg = str;
248 if(end == NULL) 253 if(end == NULL)
249 return(NULL); 254 return NULL;
250 *end++ = '\0'; 255 *end++ = '\0';
251 str = end; 256 str = end;
252 } 257 }
253 va_end(ap); 258 va_end(ap);
254 return(str); 259 return str;
255} 260}
256
257/*
258 * Overrides for Emacs so that we follow Linus's tabbing style.
259 * Emacs will notice this stuff at the end of the file and automatically
260 * adjust the settings for this buffer only. This must remain at the end
261 * of the file.
262 * ---------------------------------------------------------------------------
263 * Local variables:
264 * c-file-style: "linux"
265 * End:
266 */
diff --git a/arch/um/drivers/tty.c b/arch/um/drivers/tty.c
index 94c9265a4f2c..9f70edf5d8ef 100644
--- a/arch/um/drivers/tty.c
+++ b/arch/um/drivers/tty.c
@@ -1,4 +1,4 @@
1/* 1/*
2 * Copyright (C) 2001 Jeff Dike (jdike@karaya.com) 2 * Copyright (C) 2001 Jeff Dike (jdike@karaya.com)
3 * Licensed under the GPL 3 * Licensed under the GPL
4 */ 4 */
@@ -25,17 +25,17 @@ static void *tty_chan_init(char *str, int device, struct chan_opts *opts)
25 if(*str != ':'){ 25 if(*str != ':'){
26 printk("tty_init : channel type 'tty' must specify " 26 printk("tty_init : channel type 'tty' must specify "
27 "a device\n"); 27 "a device\n");
28 return(NULL); 28 return NULL;
29 } 29 }
30 str++; 30 str++;
31 31
32 data = um_kmalloc(sizeof(*data)); 32 data = um_kmalloc(sizeof(*data));
33 if(data == NULL) 33 if(data == NULL)
34 return(NULL); 34 return NULL;
35 *data = ((struct tty_chan) { .dev = str, 35 *data = ((struct tty_chan) { .dev = str,
36 .raw = opts->raw }); 36 .raw = opts->raw });
37 37
38 return(data); 38 return data;
39} 39}
40 40
41static int tty_open(int input, int output, int primary, void *d, 41static int tty_open(int input, int output, int primary, void *d,
@@ -45,19 +45,21 @@ static int tty_open(int input, int output, int primary, void *d,
45 int fd, err; 45 int fd, err;
46 46
47 fd = os_open_file(data->dev, of_set_rw(OPENFLAGS(), input, output), 0); 47 fd = os_open_file(data->dev, of_set_rw(OPENFLAGS(), input, output), 0);
48 if(fd < 0) return(fd); 48 if(fd < 0)
49 return fd;
50
49 if(data->raw){ 51 if(data->raw){
50 CATCH_EINTR(err = tcgetattr(fd, &data->tt)); 52 CATCH_EINTR(err = tcgetattr(fd, &data->tt));
51 if(err) 53 if(err)
52 return(err); 54 return err;
53 55
54 err = raw(fd); 56 err = raw(fd);
55 if(err) 57 if(err)
56 return(err); 58 return err;
57 } 59 }
58 60
59 *dev_out = data->dev; 61 *dev_out = data->dev;
60 return(fd); 62 return fd;
61} 63}
62 64
63struct chan_ops tty_ops = { 65struct chan_ops tty_ops = {
@@ -72,14 +74,3 @@ struct chan_ops tty_ops = {
72 .free = generic_free, 74 .free = generic_free,
73 .winch = 0, 75 .winch = 0,
74}; 76};
75
76/*
77 * Overrides for Emacs so that we follow Linus's tabbing style.
78 * Emacs will notice this stuff at the end of the file and automatically
79 * adjust the settings for this buffer only. This must remain at the end
80 * of the file.
81 * ---------------------------------------------------------------------------
82 * Local variables:
83 * c-file-style: "linux"
84 * End:
85 */
diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c
index 602d7286b9e0..34085315aa57 100644
--- a/arch/um/drivers/ubd_kern.c
+++ b/arch/um/drivers/ubd_kern.c
@@ -627,7 +627,6 @@ static int ubd_new_disk(int major, u64 size, int unit,
627 627
628{ 628{
629 struct gendisk *disk; 629 struct gendisk *disk;
630 int err;
631 630
632 disk = alloc_disk(1 << UBD_SHIFT); 631 disk = alloc_disk(1 << UBD_SHIFT);
633 if(disk == NULL) 632 if(disk == NULL)
diff --git a/arch/um/include/irq_user.h b/arch/um/include/irq_user.h
index 69a93c804f0e..15d311b9be9e 100644
--- a/arch/um/include/irq_user.h
+++ b/arch/um/include/irq_user.h
@@ -6,6 +6,8 @@
6#ifndef __IRQ_USER_H__ 6#ifndef __IRQ_USER_H__
7#define __IRQ_USER_H__ 7#define __IRQ_USER_H__
8 8
9#include "uml-config.h"
10
9struct irq_fd { 11struct irq_fd {
10 struct irq_fd *next; 12 struct irq_fd *next;
11 void *id; 13 void *id;
@@ -26,9 +28,10 @@ extern void free_irq_by_fd(int fd);
26extern void reactivate_fd(int fd, int irqnum); 28extern void reactivate_fd(int fd, int irqnum);
27extern void deactivate_fd(int fd, int irqnum); 29extern void deactivate_fd(int fd, int irqnum);
28extern int deactivate_all_fds(void); 30extern int deactivate_all_fds(void);
29extern void forward_interrupts(int pid);
30extern int activate_ipi(int fd, int pid); 31extern int activate_ipi(int fd, int pid);
31extern unsigned long irq_lock(void); 32
32extern void irq_unlock(unsigned long flags); 33#ifdef CONFIG_MODE_TT
34extern void forward_interrupts(int pid);
35#endif
33 36
34#endif 37#endif
diff --git a/arch/um/include/kern_util.h b/arch/um/include/kern_util.h
index 310980b32173..b98bdd8e052a 100644
--- a/arch/um/include/kern_util.h
+++ b/arch/um/include/kern_util.h
@@ -72,10 +72,8 @@ extern void init_flush_vm(void);
72extern void *syscall_sp(void *t); 72extern void *syscall_sp(void *t);
73extern void syscall_trace(union uml_pt_regs *regs, int entryexit); 73extern void syscall_trace(union uml_pt_regs *regs, int entryexit);
74extern int hz(void); 74extern int hz(void);
75extern void uml_idle_timer(void);
76extern unsigned int do_IRQ(int irq, union uml_pt_regs *regs); 75extern unsigned int do_IRQ(int irq, union uml_pt_regs *regs);
77extern int external_pid(void *t); 76extern int external_pid(void *t);
78extern void boot_timer_handler(int sig);
79extern void interrupt_end(void); 77extern void interrupt_end(void);
80extern void initial_thread_cb(void (*proc)(void *), void *arg); 78extern void initial_thread_cb(void (*proc)(void *), void *arg);
81extern int debugger_signal(int status, int pid); 79extern int debugger_signal(int status, int pid);
diff --git a/arch/um/include/os.h b/arch/um/include/os.h
index f88856c28a66..b6c52496e15a 100644
--- a/arch/um/include/os.h
+++ b/arch/um/include/os.h
@@ -199,7 +199,7 @@ extern int os_getpid(void);
199extern int os_getpgrp(void); 199extern int os_getpgrp(void);
200 200
201extern void init_new_thread_stack(void *sig_stack, void (*usr1_handler)(int)); 201extern void init_new_thread_stack(void *sig_stack, void (*usr1_handler)(int));
202extern void init_new_thread_signals(int altstack); 202extern void init_new_thread_signals(void);
203extern int run_kernel_thread(int (*fn)(void *), void *arg, void **jmp_ptr); 203extern int run_kernel_thread(int (*fn)(void *), void *arg, void **jmp_ptr);
204 204
205extern int os_map_memory(void *virt, int fd, unsigned long long off, 205extern int os_map_memory(void *virt, int fd, unsigned long long off,
@@ -318,7 +318,6 @@ extern void reboot_skas(void);
318 318
319/* irq.c */ 319/* irq.c */
320extern int os_waiting_for_events(struct irq_fd *active_fds); 320extern int os_waiting_for_events(struct irq_fd *active_fds);
321extern int os_isatty(int fd);
322extern int os_create_pollfd(int fd, int events, void *tmp_pfd, int size_tmpfds); 321extern int os_create_pollfd(int fd, int events, void *tmp_pfd, int size_tmpfds);
323extern void os_free_irq_by_cb(int (*test)(struct irq_fd *, void *), void *arg, 322extern void os_free_irq_by_cb(int (*test)(struct irq_fd *, void *), void *arg,
324 struct irq_fd *active_fds, struct irq_fd ***last_irq_ptr2); 323 struct irq_fd *active_fds, struct irq_fd ***last_irq_ptr2);
@@ -330,9 +329,8 @@ extern void os_set_ioignore(void);
330extern void init_irq_signals(int on_sigstack); 329extern void init_irq_signals(int on_sigstack);
331 330
332/* sigio.c */ 331/* sigio.c */
333extern void write_sigio_workaround(void);
334extern int add_sigio_fd(int fd, int read);
335extern int ignore_sigio_fd(int fd); 332extern int ignore_sigio_fd(int fd);
333extern void maybe_sigio_broken(int fd, int read);
336 334
337/* skas/trap */ 335/* skas/trap */
338extern void sig_handler_common_skas(int sig, void *sc_ptr); 336extern void sig_handler_common_skas(int sig, void *sc_ptr);
diff --git a/arch/um/include/skas/mode_kern_skas.h b/arch/um/include/skas/mode_kern_skas.h
index 63c58739bde0..9cd9c6ec9a63 100644
--- a/arch/um/include/skas/mode_kern_skas.h
+++ b/arch/um/include/skas/mode_kern_skas.h
@@ -29,8 +29,7 @@ extern void flush_tlb_mm_skas(struct mm_struct *mm);
29extern void force_flush_all_skas(void); 29extern void force_flush_all_skas(void);
30extern long execute_syscall_skas(void *r); 30extern long execute_syscall_skas(void *r);
31extern void before_mem_skas(unsigned long unused); 31extern void before_mem_skas(unsigned long unused);
32extern unsigned long set_task_sizes_skas(int arg, unsigned long *host_size_out, 32extern unsigned long set_task_sizes_skas(unsigned long *task_size_out);
33 unsigned long *task_size_out);
34extern int start_uml_skas(void); 33extern int start_uml_skas(void);
35extern int external_pid_skas(struct task_struct *task); 34extern int external_pid_skas(struct task_struct *task);
36extern int thread_pid_skas(struct task_struct *task); 35extern int thread_pid_skas(struct task_struct *task);
diff --git a/arch/um/include/tt/mode_kern_tt.h b/arch/um/include/tt/mode_kern_tt.h
index efa0012550d0..a4fc63057195 100644
--- a/arch/um/include/tt/mode_kern_tt.h
+++ b/arch/um/include/tt/mode_kern_tt.h
@@ -30,8 +30,7 @@ extern void flush_tlb_mm_tt(struct mm_struct *mm);
30extern void force_flush_all_tt(void); 30extern void force_flush_all_tt(void);
31extern long execute_syscall_tt(void *r); 31extern long execute_syscall_tt(void *r);
32extern void before_mem_tt(unsigned long brk_start); 32extern void before_mem_tt(unsigned long brk_start);
33extern unsigned long set_task_sizes_tt(int arg, unsigned long *host_size_out, 33extern unsigned long set_task_sizes_tt(unsigned long *task_size_out);
34 unsigned long *task_size_out);
35extern int start_uml_tt(void); 34extern int start_uml_tt(void);
36extern int external_pid_tt(struct task_struct *task); 35extern int external_pid_tt(struct task_struct *task);
37extern int thread_pid_tt(struct task_struct *task); 36extern int thread_pid_tt(struct task_struct *task);
diff --git a/arch/um/kernel/Makefile b/arch/um/kernel/Makefile
index fe08971b64cf..a2d93065b2d0 100644
--- a/arch/um/kernel/Makefile
+++ b/arch/um/kernel/Makefile
@@ -6,16 +6,14 @@
6extra-y := vmlinux.lds 6extra-y := vmlinux.lds
7clean-files := 7clean-files :=
8 8
9obj-y = config.o exec_kern.o exitcode.o \ 9obj-y = config.o exec.o exitcode.o init_task.o irq.o ksyms.o mem.o \
10 init_task.o irq.o ksyms.o mem.o physmem.o \ 10 physmem.o process_kern.o ptrace.o reboot.o resource.o sigio.o \
11 process_kern.o ptrace.o reboot.o resource.o sigio_kern.o \ 11 signal.o smp.o syscall.o sysrq.o time.o tlb.o trap.o uaccess.o \
12 signal_kern.o smp.o syscall_kern.o sysrq.o \ 12 um_arch.o umid.o
13 time_kern.o tlb.o trap_kern.o uaccess.o um_arch.o umid.o
14 13
15obj-$(CONFIG_BLK_DEV_INITRD) += initrd.o 14obj-$(CONFIG_BLK_DEV_INITRD) += initrd.o
16obj-$(CONFIG_GPROF) += gprof_syms.o 15obj-$(CONFIG_GPROF) += gprof_syms.o
17obj-$(CONFIG_GCOV) += gmon_syms.o 16obj-$(CONFIG_GCOV) += gmon_syms.o
18obj-$(CONFIG_SYSCALL_DEBUG) += syscall.o
19 17
20obj-$(CONFIG_MODE_TT) += tt/ 18obj-$(CONFIG_MODE_TT) += tt/
21obj-$(CONFIG_MODE_SKAS) += skas/ 19obj-$(CONFIG_MODE_SKAS) += skas/
diff --git a/arch/um/kernel/exec_kern.c b/arch/um/kernel/exec.c
index c0cb627bf594..fc38a6d5906d 100644
--- a/arch/um/kernel/exec_kern.c
+++ b/arch/um/kernel/exec.c
@@ -1,4 +1,4 @@
1/* 1/*
2 * Copyright (C) 2000, 2001 Jeff Dike (jdike@karaya.com) 2 * Copyright (C) 2000, 2001 Jeff Dike (jdike@karaya.com)
3 * Licensed under the GPL 3 * Licensed under the GPL
4 */ 4 */
@@ -31,18 +31,27 @@ void start_thread(struct pt_regs *regs, unsigned long eip, unsigned long esp)
31 CHOOSE_MODE_PROC(start_thread_tt, start_thread_skas, regs, eip, esp); 31 CHOOSE_MODE_PROC(start_thread_tt, start_thread_skas, regs, eip, esp);
32} 32}
33 33
34#ifdef CONFIG_TTY_LOG
35extern void log_exec(char **argv, void *tty);
36#endif
37
34static long execve1(char *file, char __user * __user *argv, 38static long execve1(char *file, char __user * __user *argv,
35 char __user *__user *env) 39 char __user *__user *env)
36{ 40{
37 long error; 41 long error;
38 42
39#ifdef CONFIG_TTY_LOG 43#ifdef CONFIG_TTY_LOG
40 log_exec(argv, current->tty); 44 task_lock(current);
45 log_exec(argv, current->signal->tty);
46 task_unlock(current);
41#endif 47#endif
42 error = do_execve(file, argv, env, &current->thread.regs); 48 error = do_execve(file, argv, env, &current->thread.regs);
43 if (error == 0){ 49 if (error == 0){
44 task_lock(current); 50 task_lock(current);
45 current->ptrace &= ~PT_DTRACE; 51 current->ptrace &= ~PT_DTRACE;
52#ifdef SUBARCH_EXECVE1
53 SUBARCH_EXECVE1(&current->thread.regs.regs);
54#endif
46 task_unlock(current); 55 task_unlock(current);
47 set_cmdline(current_cmd()); 56 set_cmdline(current_cmd());
48 } 57 }
diff --git a/arch/um/kernel/irq.c b/arch/um/kernel/irq.c
index bfd0bdc8cd40..589c69a75043 100644
--- a/arch/um/kernel/irq.c
+++ b/arch/um/kernel/irq.c
@@ -110,18 +110,7 @@ void sigio_handler(int sig, union uml_pt_regs *regs)
110 free_irqs(); 110 free_irqs();
111} 111}
112 112
113static void maybe_sigio_broken(int fd, int type) 113static DEFINE_SPINLOCK(irq_lock);
114{
115 if (os_isatty(fd)) {
116 if ((type == IRQ_WRITE) && !pty_output_sigio) {
117 write_sigio_workaround();
118 add_sigio_fd(fd, 0);
119 } else if ((type == IRQ_READ) && !pty_close_sigio) {
120 write_sigio_workaround();
121 add_sigio_fd(fd, 1);
122 }
123 }
124}
125 114
126int activate_fd(int irq, int fd, int type, void *dev_id) 115int activate_fd(int irq, int fd, int type, void *dev_id)
127{ 116{
@@ -166,7 +155,7 @@ int activate_fd(int irq, int fd, int type, void *dev_id)
166 * this is called only from process context, and can be locked with 155 * this is called only from process context, and can be locked with
167 * a semaphore. 156 * a semaphore.
168 */ 157 */
169 flags = irq_lock(); 158 spin_lock_irqsave(&irq_lock, flags);
170 for (irq_fd = active_fds; irq_fd != NULL; irq_fd = irq_fd->next) { 159 for (irq_fd = active_fds; irq_fd != NULL; irq_fd = irq_fd->next) {
171 if ((irq_fd->fd == fd) && (irq_fd->type == type)) { 160 if ((irq_fd->fd == fd) && (irq_fd->type == type)) {
172 printk("Registering fd %d twice\n", fd); 161 printk("Registering fd %d twice\n", fd);
@@ -199,7 +188,7 @@ int activate_fd(int irq, int fd, int type, void *dev_id)
199 * so we will not be able to put new pollfd struct to pollfds 188 * so we will not be able to put new pollfd struct to pollfds
200 * then we free the buffer tmp_fds and try again. 189 * then we free the buffer tmp_fds and try again.
201 */ 190 */
202 irq_unlock(flags); 191 spin_unlock_irqrestore(&irq_lock, flags);
203 kfree(tmp_pfd); 192 kfree(tmp_pfd);
204 tmp_pfd = NULL; 193 tmp_pfd = NULL;
205 194
@@ -207,24 +196,24 @@ int activate_fd(int irq, int fd, int type, void *dev_id)
207 if (tmp_pfd == NULL) 196 if (tmp_pfd == NULL)
208 goto out_kfree; 197 goto out_kfree;
209 198
210 flags = irq_lock(); 199 spin_lock_irqsave(&irq_lock, flags);
211 } 200 }
212 /*-------------*/ 201 /*-------------*/
213 202
214 *last_irq_ptr = new_fd; 203 *last_irq_ptr = new_fd;
215 last_irq_ptr = &new_fd->next; 204 last_irq_ptr = &new_fd->next;
216 205
217 irq_unlock(flags); 206 spin_unlock_irqrestore(&irq_lock, flags);
218 207
219 /* This calls activate_fd, so it has to be outside the critical 208 /* This calls activate_fd, so it has to be outside the critical
220 * section. 209 * section.
221 */ 210 */
222 maybe_sigio_broken(fd, type); 211 maybe_sigio_broken(fd, (type == IRQ_READ));
223 212
224 return(0); 213 return(0);
225 214
226 out_unlock: 215 out_unlock:
227 irq_unlock(flags); 216 spin_unlock_irqrestore(&irq_lock, flags);
228 out_kfree: 217 out_kfree:
229 kfree(new_fd); 218 kfree(new_fd);
230 out: 219 out:
@@ -235,9 +224,9 @@ static void free_irq_by_cb(int (*test)(struct irq_fd *, void *), void *arg)
235{ 224{
236 unsigned long flags; 225 unsigned long flags;
237 226
238 flags = irq_lock(); 227 spin_lock_irqsave(&irq_lock, flags);
239 os_free_irq_by_cb(test, arg, active_fds, &last_irq_ptr); 228 os_free_irq_by_cb(test, arg, active_fds, &last_irq_ptr);
240 irq_unlock(flags); 229 spin_unlock_irqrestore(&irq_lock, flags);
241} 230}
242 231
243struct irq_and_dev { 232struct irq_and_dev {
@@ -304,19 +293,19 @@ void reactivate_fd(int fd, int irqnum)
304 unsigned long flags; 293 unsigned long flags;
305 int i; 294 int i;
306 295
307 flags = irq_lock(); 296 spin_lock_irqsave(&irq_lock, flags);
308 irq = find_irq_by_fd(fd, irqnum, &i); 297 irq = find_irq_by_fd(fd, irqnum, &i);
309 if (irq == NULL) { 298 if (irq == NULL) {
310 irq_unlock(flags); 299 spin_unlock_irqrestore(&irq_lock, flags);
311 return; 300 return;
312 } 301 }
313 os_set_pollfd(i, irq->fd); 302 os_set_pollfd(i, irq->fd);
314 irq_unlock(flags); 303 spin_unlock_irqrestore(&irq_lock, flags);
315 304
316 /* This calls activate_fd, so it has to be outside the critical 305 /* This calls activate_fd, so it has to be outside the critical
317 * section. 306 * section.
318 */ 307 */
319 maybe_sigio_broken(fd, irq->type); 308 maybe_sigio_broken(fd, (irq->type == IRQ_READ));
320} 309}
321 310
322void deactivate_fd(int fd, int irqnum) 311void deactivate_fd(int fd, int irqnum)
@@ -325,13 +314,13 @@ void deactivate_fd(int fd, int irqnum)
325 unsigned long flags; 314 unsigned long flags;
326 int i; 315 int i;
327 316
328 flags = irq_lock(); 317 spin_lock_irqsave(&irq_lock, flags);
329 irq = find_irq_by_fd(fd, irqnum, &i); 318 irq = find_irq_by_fd(fd, irqnum, &i);
330 if (irq == NULL) 319 if (irq == NULL)
331 goto out; 320 goto out;
332 os_set_pollfd(i, -1); 321 os_set_pollfd(i, -1);
333 out: 322 out:
334 irq_unlock(flags); 323 spin_unlock_irqrestore(&irq_lock, flags);
335} 324}
336 325
337int deactivate_all_fds(void) 326int deactivate_all_fds(void)
@@ -350,13 +339,14 @@ int deactivate_all_fds(void)
350 return 0; 339 return 0;
351} 340}
352 341
342#ifdef CONFIG_MODE_TT
353void forward_interrupts(int pid) 343void forward_interrupts(int pid)
354{ 344{
355 struct irq_fd *irq; 345 struct irq_fd *irq;
356 unsigned long flags; 346 unsigned long flags;
357 int err; 347 int err;
358 348
359 flags = irq_lock(); 349 spin_lock_irqsave(&irq_lock, flags);
360 for (irq = active_fds; irq != NULL; irq = irq->next) { 350 for (irq = active_fds; irq != NULL; irq = irq->next) {
361 err = os_set_owner(irq->fd, pid); 351 err = os_set_owner(irq->fd, pid);
362 if (err < 0) { 352 if (err < 0) {
@@ -369,8 +359,9 @@ void forward_interrupts(int pid)
369 359
370 irq->pid = pid; 360 irq->pid = pid;
371 } 361 }
372 irq_unlock(flags); 362 spin_unlock_irqrestore(&irq_lock, flags);
373} 363}
364#endif
374 365
375/* 366/*
376 * do_IRQ handles all normal device IRQ's (the special 367 * do_IRQ handles all normal device IRQ's (the special
@@ -403,21 +394,6 @@ int um_request_irq(unsigned int irq, int fd, int type,
403EXPORT_SYMBOL(um_request_irq); 394EXPORT_SYMBOL(um_request_irq);
404EXPORT_SYMBOL(reactivate_fd); 395EXPORT_SYMBOL(reactivate_fd);
405 396
406static DEFINE_SPINLOCK(irq_spinlock);
407
408unsigned long irq_lock(void)
409{
410 unsigned long flags;
411
412 spin_lock_irqsave(&irq_spinlock, flags);
413 return flags;
414}
415
416void irq_unlock(unsigned long flags)
417{
418 spin_unlock_irqrestore(&irq_spinlock, flags);
419}
420
421/* hw_interrupt_type must define (startup || enable) && 397/* hw_interrupt_type must define (startup || enable) &&
422 * (shutdown || disable) && end */ 398 * (shutdown || disable) && end */
423static void dummy(unsigned int irq) 399static void dummy(unsigned int irq)
diff --git a/arch/um/kernel/ksyms.c b/arch/um/kernel/ksyms.c
index 432cf0b97a13..c97045d6d89f 100644
--- a/arch/um/kernel/ksyms.c
+++ b/arch/um/kernel/ksyms.c
@@ -88,12 +88,6 @@ EXPORT_SYMBOL(dump_thread);
88EXPORT_SYMBOL(do_gettimeofday); 88EXPORT_SYMBOL(do_gettimeofday);
89EXPORT_SYMBOL(do_settimeofday); 89EXPORT_SYMBOL(do_settimeofday);
90 90
91/* This is here because UML expands lseek to sys_lseek, not to a system
92 * call instruction.
93 */
94EXPORT_SYMBOL(sys_lseek);
95EXPORT_SYMBOL(sys_wait4);
96
97#ifdef CONFIG_SMP 91#ifdef CONFIG_SMP
98 92
99/* required for SMP */ 93/* required for SMP */
diff --git a/arch/um/kernel/mem.c b/arch/um/kernel/mem.c
index 44e41a35f000..61280167c560 100644
--- a/arch/um/kernel/mem.c
+++ b/arch/um/kernel/mem.c
@@ -24,8 +24,6 @@
24#include "init.h" 24#include "init.h"
25#include "kern_constants.h" 25#include "kern_constants.h"
26 26
27extern char __binary_start;
28
29/* Changed during early boot */ 27/* Changed during early boot */
30unsigned long *empty_zero_page = NULL; 28unsigned long *empty_zero_page = NULL;
31unsigned long *empty_bad_page = NULL; 29unsigned long *empty_bad_page = NULL;
@@ -65,8 +63,6 @@ static void setup_highmem(unsigned long highmem_start,
65 63
66void mem_init(void) 64void mem_init(void)
67{ 65{
68 unsigned long start;
69
70 max_low_pfn = (high_physmem - uml_physmem) >> PAGE_SHIFT; 66 max_low_pfn = (high_physmem - uml_physmem) >> PAGE_SHIFT;
71 67
72 /* clear the zero-page */ 68 /* clear the zero-page */
@@ -81,13 +77,6 @@ void mem_init(void)
81 free_bootmem(__pa(brk_end), uml_reserved - brk_end); 77 free_bootmem(__pa(brk_end), uml_reserved - brk_end);
82 uml_reserved = brk_end; 78 uml_reserved = brk_end;
83 79
84 /* Fill in any hole at the start of the binary */
85 start = (unsigned long) &__binary_start & PAGE_MASK;
86 if(uml_physmem != start){
87 map_memory(uml_physmem, __pa(uml_physmem), start - uml_physmem,
88 1, 1, 0);
89 }
90
91 /* this will put all low memory onto the freelists */ 80 /* this will put all low memory onto the freelists */
92 totalram_pages = free_all_bootmem(); 81 totalram_pages = free_all_bootmem();
93 totalhigh_pages = highmem >> PAGE_SHIFT; 82 totalhigh_pages = highmem >> PAGE_SHIFT;
diff --git a/arch/um/kernel/physmem.c b/arch/um/kernel/physmem.c
index 166cb09cae4c..abafa64b8727 100644
--- a/arch/um/kernel/physmem.c
+++ b/arch/um/kernel/physmem.c
@@ -317,7 +317,7 @@ void map_memory(unsigned long virt, unsigned long phys, unsigned long len,
317 } 317 }
318} 318}
319 319
320extern int __syscall_stub_start, __binary_start; 320extern int __syscall_stub_start;
321 321
322void setup_physmem(unsigned long start, unsigned long reserve_end, 322void setup_physmem(unsigned long start, unsigned long reserve_end,
323 unsigned long len, unsigned long long highmem) 323 unsigned long len, unsigned long long highmem)
diff --git a/arch/um/kernel/sigio_kern.c b/arch/um/kernel/sigio.c
index 51b677083948..0ad755ceb212 100644
--- a/arch/um/kernel/sigio_kern.c
+++ b/arch/um/kernel/sigio.c
@@ -31,7 +31,7 @@ int write_sigio_irq(int fd)
31 int err; 31 int err;
32 32
33 err = um_request_irq(SIGIO_WRITE_IRQ, fd, IRQ_READ, sigio_interrupt, 33 err = um_request_irq(SIGIO_WRITE_IRQ, fd, IRQ_READ, sigio_interrupt,
34 IRQF_DISABLED | IRQF_SAMPLE_RANDOM, "write sigio", 34 IRQF_DISABLED|IRQF_SAMPLE_RANDOM, "write sigio",
35 NULL); 35 NULL);
36 if(err){ 36 if(err){
37 printk("write_sigio_irq : um_request_irq failed, err = %d\n", 37 printk("write_sigio_irq : um_request_irq failed, err = %d\n",
@@ -53,17 +53,3 @@ void sigio_unlock(void)
53{ 53{
54 spin_unlock(&sigio_spinlock); 54 spin_unlock(&sigio_spinlock);
55} 55}
56
57extern void sigio_cleanup(void);
58__uml_exitcall(sigio_cleanup);
59
60/*
61 * Overrides for Emacs so that we follow Linus's tabbing style.
62 * Emacs will notice this stuff at the end of the file and automatically
63 * adjust the settings for this buffer only. This must remain at the end
64 * of the file.
65 * ---------------------------------------------------------------------------
66 * Local variables:
67 * c-file-style: "linux"
68 * End:
69 */
diff --git a/arch/um/kernel/signal_kern.c b/arch/um/kernel/signal.c
index da17b7541e08..4aa9808ba264 100644
--- a/arch/um/kernel/signal_kern.c
+++ b/arch/um/kernel/signal.c
@@ -1,4 +1,4 @@
1/* 1/*
2 * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com) 2 * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
3 * Licensed under the GPL 3 * Licensed under the GPL
4 */ 4 */
@@ -36,7 +36,7 @@ EXPORT_SYMBOL(unblock_signals);
36 36
37/* 37/*
38 * OK, we're invoking a handler 38 * OK, we're invoking a handler
39 */ 39 */
40static int handle_signal(struct pt_regs *regs, unsigned long signr, 40static int handle_signal(struct pt_regs *regs, unsigned long signr,
41 struct k_sigaction *ka, siginfo_t *info, 41 struct k_sigaction *ka, siginfo_t *info,
42 sigset_t *oldset) 42 sigset_t *oldset)
@@ -88,7 +88,7 @@ static int handle_signal(struct pt_regs *regs, unsigned long signr,
88 force_sigsegv(signr, current); 88 force_sigsegv(signr, current);
89 } else { 89 } else {
90 spin_lock_irq(&current->sighand->siglock); 90 spin_lock_irq(&current->sighand->siglock);
91 sigorsets(&current->blocked, &current->blocked, 91 sigorsets(&current->blocked, &current->blocked,
92 &ka->sa.sa_mask); 92 &ka->sa.sa_mask);
93 if(!(ka->sa.sa_flags & SA_NODEFER)) 93 if(!(ka->sa.sa_flags & SA_NODEFER))
94 sigaddset(&current->blocked, signr); 94 sigaddset(&current->blocked, signr);
@@ -136,7 +136,7 @@ static int kern_do_signal(struct pt_regs *regs)
136 PT_REGS_RESTART_SYSCALL(regs); 136 PT_REGS_RESTART_SYSCALL(regs);
137 break; 137 break;
138 case -ERESTART_RESTARTBLOCK: 138 case -ERESTART_RESTARTBLOCK:
139 PT_REGS_SYSCALL_RET(regs) = __NR_restart_syscall; 139 PT_REGS_ORIG_SYSCALL(regs) = __NR_restart_syscall;
140 PT_REGS_RESTART_SYSCALL(regs); 140 PT_REGS_RESTART_SYSCALL(regs);
141 break; 141 break;
142 } 142 }
@@ -146,7 +146,7 @@ static int kern_do_signal(struct pt_regs *regs)
146 * you set a breakpoint on a system call instruction and singlestep 146 * you set a breakpoint on a system call instruction and singlestep
147 * from it, the tracing thread used to PTRACE_SINGLESTEP the process 147 * from it, the tracing thread used to PTRACE_SINGLESTEP the process
148 * rather than PTRACE_SYSCALL it, allowing the system call to execute 148 * rather than PTRACE_SYSCALL it, allowing the system call to execute
149 * on the host. The tracing thread will check this flag and 149 * on the host. The tracing thread will check this flag and
150 * PTRACE_SYSCALL if necessary. 150 * PTRACE_SYSCALL if necessary.
151 */ 151 */
152 if(current->ptrace & PT_DTRACE) 152 if(current->ptrace & PT_DTRACE)
diff --git a/arch/um/kernel/skas/mem.c b/arch/um/kernel/skas/mem.c
index 88ab96c609ce..27bbf54b1e52 100644
--- a/arch/um/kernel/skas/mem.c
+++ b/arch/um/kernel/skas/mem.c
@@ -9,31 +9,19 @@
9#include "mem_user.h" 9#include "mem_user.h"
10#include "skas.h" 10#include "skas.h"
11 11
12unsigned long set_task_sizes_skas(int arg, unsigned long *host_size_out, 12unsigned long set_task_sizes_skas(unsigned long *task_size_out)
13 unsigned long *task_size_out)
14{ 13{
15 /* Round up to the nearest 4M */ 14 /* Round up to the nearest 4M */
16 unsigned long top = ROUND_4M((unsigned long) &arg); 15 unsigned long host_task_size = ROUND_4M((unsigned long)
16 &host_task_size);
17 17
18#ifdef CONFIG_HOST_TASK_SIZE 18#ifdef CONFIG_HOST_TASK_SIZE
19 *host_size_out = CONFIG_HOST_TASK_SIZE; 19 *host_size_out = ROUND_4M(CONFIG_HOST_TASK_SIZE);
20 *task_size_out = CONFIG_HOST_TASK_SIZE; 20 *task_size_out = CONFIG_HOST_TASK_SIZE;
21#else 21#else
22 *host_size_out = top;
23 if (!skas_needs_stub) 22 if (!skas_needs_stub)
24 *task_size_out = top; 23 *task_size_out = host_task_size;
25 else *task_size_out = CONFIG_STUB_START & PGDIR_MASK; 24 else *task_size_out = CONFIG_STUB_START & PGDIR_MASK;
26#endif 25#endif
27 return(((unsigned long) set_task_sizes_skas) & ~0xffffff); 26 return host_task_size;
28} 27}
29
30/*
31 * Overrides for Emacs so that we follow Linus's tabbing style.
32 * Emacs will notice this stuff at the end of the file and automatically
33 * adjust the settings for this buffer only. This must remain at the end
34 * of the file.
35 * ---------------------------------------------------------------------------
36 * Local variables:
37 * c-file-style: "linux"
38 * End:
39 */
diff --git a/arch/um/kernel/skas/process_kern.c b/arch/um/kernel/skas/process_kern.c
index 2135eaf98a93..55caeec8b257 100644
--- a/arch/um/kernel/skas/process_kern.c
+++ b/arch/um/kernel/skas/process_kern.c
@@ -177,7 +177,7 @@ int start_uml_skas(void)
177 if(proc_mm) 177 if(proc_mm)
178 userspace_pid[0] = start_userspace(0); 178 userspace_pid[0] = start_userspace(0);
179 179
180 init_new_thread_signals(1); 180 init_new_thread_signals();
181 181
182 init_task.thread.request.u.thread.proc = start_kernel_proc; 182 init_task.thread.request.u.thread.proc = start_kernel_proc;
183 init_task.thread.request.u.thread.arg = NULL; 183 init_task.thread.request.u.thread.arg = NULL;
diff --git a/arch/um/kernel/skas/syscall.c b/arch/um/kernel/skas/syscall.c
index 51fb94076fcf..0ae4eea21be4 100644
--- a/arch/um/kernel/skas/syscall.c
+++ b/arch/um/kernel/skas/syscall.c
@@ -18,11 +18,7 @@ void handle_syscall(union uml_pt_regs *r)
18 struct pt_regs *regs = container_of(r, struct pt_regs, regs); 18 struct pt_regs *regs = container_of(r, struct pt_regs, regs);
19 long result; 19 long result;
20 int syscall; 20 int syscall;
21#ifdef UML_CONFIG_SYSCALL_DEBUG
22 int index;
23 21
24 index = record_syscall_start(UPT_SYSCALL_NR(r));
25#endif
26 syscall_trace(r, 0); 22 syscall_trace(r, 0);
27 23
28 current->thread.nsyscalls++; 24 current->thread.nsyscalls++;
@@ -44,7 +40,4 @@ void handle_syscall(union uml_pt_regs *r)
44 REGS_SET_SYSCALL_RETURN(r->skas.regs, result); 40 REGS_SET_SYSCALL_RETURN(r->skas.regs, result);
45 41
46 syscall_trace(r, 1); 42 syscall_trace(r, 1);
47#ifdef UML_CONFIG_SYSCALL_DEBUG
48 record_syscall_end(index, result);
49#endif
50} 43}
diff --git a/arch/um/kernel/syscall.c b/arch/um/kernel/syscall.c
index 1731d90e6850..abf14aaf905f 100644
--- a/arch/um/kernel/syscall.c
+++ b/arch/um/kernel/syscall.c
@@ -1,36 +1,166 @@
1/* 1/*
2 * Copyright (C) 2002 Jeff Dike (jdike@karaya.com) 2 * Copyright (C) 2000 - 2003 Jeff Dike (jdike@addtoit.com)
3 * Licensed under the GPL 3 * Licensed under the GPL
4 */ 4 */
5 5
6#include "linux/sched.h"
7#include "linux/file.h"
8#include "linux/smp_lock.h"
9#include "linux/mm.h"
10#include "linux/utsname.h"
11#include "linux/msg.h"
12#include "linux/shm.h"
13#include "linux/sys.h"
14#include "linux/syscalls.h"
15#include "linux/unistd.h"
16#include "linux/slab.h"
17#include "linux/utime.h"
18#include "asm/mman.h"
19#include "asm/uaccess.h"
6#include "kern_util.h" 20#include "kern_util.h"
7#include "syscall.h" 21#include "user_util.h"
8#include "os.h" 22#include "sysdep/syscalls.h"
23#include "mode_kern.h"
24#include "choose-mode.h"
9 25
10struct { 26/* Unlocked, I don't care if this is a bit off */
11 int syscall; 27int nsyscalls = 0;
12 int pid;
13 long result;
14 unsigned long long start;
15 unsigned long long end;
16} syscall_record[1024];
17 28
18int record_syscall_start(int syscall) 29long sys_fork(void)
19{ 30{
20 int max, index; 31 long ret;
21 32
22 max = sizeof(syscall_record)/sizeof(syscall_record[0]); 33 current->thread.forking = 1;
23 index = next_syscall_index(max); 34 ret = do_fork(SIGCHLD, UPT_SP(&current->thread.regs.regs),
35 &current->thread.regs, 0, NULL, NULL);
36 current->thread.forking = 0;
37 return(ret);
38}
39
40long sys_vfork(void)
41{
42 long ret;
43
44 current->thread.forking = 1;
45 ret = do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD,
46 UPT_SP(&current->thread.regs.regs),
47 &current->thread.regs, 0, NULL, NULL);
48 current->thread.forking = 0;
49 return(ret);
50}
51
52/* common code for old and new mmaps */
53long sys_mmap2(unsigned long addr, unsigned long len,
54 unsigned long prot, unsigned long flags,
55 unsigned long fd, unsigned long pgoff)
56{
57 long error = -EBADF;
58 struct file * file = NULL;
59
60 flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
61 if (!(flags & MAP_ANONYMOUS)) {
62 file = fget(fd);
63 if (!file)
64 goto out;
65 }
66
67 down_write(&current->mm->mmap_sem);
68 error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
69 up_write(&current->mm->mmap_sem);
70
71 if (file)
72 fput(file);
73 out:
74 return error;
75}
76
77long old_mmap(unsigned long addr, unsigned long len,
78 unsigned long prot, unsigned long flags,
79 unsigned long fd, unsigned long offset)
80{
81 long err = -EINVAL;
82 if (offset & ~PAGE_MASK)
83 goto out;
84
85 err = sys_mmap2(addr, len, prot, flags, fd, offset >> PAGE_SHIFT);
86 out:
87 return err;
88}
89/*
90 * sys_pipe() is the normal C calling standard for creating
91 * a pipe. It's not the way unix traditionally does this, though.
92 */
93long sys_pipe(unsigned long __user * fildes)
94{
95 int fd[2];
96 long error;
97
98 error = do_pipe(fd);
99 if (!error) {
100 if (copy_to_user(fildes, fd, sizeof(fd)))
101 error = -EFAULT;
102 }
103 return error;
104}
24 105
25 syscall_record[index].syscall = syscall; 106
26 syscall_record[index].pid = current_pid(); 107long sys_uname(struct old_utsname __user * name)
27 syscall_record[index].result = 0xdeadbeef; 108{
28 syscall_record[index].start = os_nsecs(); 109 long err;
29 return(index); 110 if (!name)
111 return -EFAULT;
112 down_read(&uts_sem);
113 err = copy_to_user(name, utsname(), sizeof (*name));
114 up_read(&uts_sem);
115 return err?-EFAULT:0;
30} 116}
31 117
32void record_syscall_end(int index, long result) 118long sys_olduname(struct oldold_utsname __user * name)
33{ 119{
34 syscall_record[index].result = result; 120 long error;
35 syscall_record[index].end = os_nsecs(); 121
122 if (!name)
123 return -EFAULT;
124 if (!access_ok(VERIFY_WRITE,name,sizeof(struct oldold_utsname)))
125 return -EFAULT;
126
127 down_read(&uts_sem);
128
129 error = __copy_to_user(&name->sysname, &utsname()->sysname,
130 __OLD_UTS_LEN);
131 error |= __put_user(0, name->sysname + __OLD_UTS_LEN);
132 error |= __copy_to_user(&name->nodename, &utsname()->nodename,
133 __OLD_UTS_LEN);
134 error |= __put_user(0, name->nodename + __OLD_UTS_LEN);
135 error |= __copy_to_user(&name->release, &utsname()->release,
136 __OLD_UTS_LEN);
137 error |= __put_user(0, name->release + __OLD_UTS_LEN);
138 error |= __copy_to_user(&name->version, &utsname()->version,
139 __OLD_UTS_LEN);
140 error |= __put_user(0, name->version + __OLD_UTS_LEN);
141 error |= __copy_to_user(&name->machine, &utsname()->machine,
142 __OLD_UTS_LEN);
143 error |= __put_user(0, name->machine + __OLD_UTS_LEN);
144
145 up_read(&uts_sem);
146
147 error = error ? -EFAULT : 0;
148
149 return error;
150}
151
152DEFINE_SPINLOCK(syscall_lock);
153
154static int syscall_index = 0;
155
156int next_syscall_index(int limit)
157{
158 int ret;
159
160 spin_lock(&syscall_lock);
161 ret = syscall_index;
162 if(++syscall_index == limit)
163 syscall_index = 0;
164 spin_unlock(&syscall_lock);
165 return(ret);
36} 166}
diff --git a/arch/um/kernel/syscall_kern.c b/arch/um/kernel/syscall_kern.c
deleted file mode 100644
index 37d3978337d8..000000000000
--- a/arch/um/kernel/syscall_kern.c
+++ /dev/null
@@ -1,166 +0,0 @@
1/*
2 * Copyright (C) 2000 - 2003 Jeff Dike (jdike@addtoit.com)
3 * Licensed under the GPL
4 */
5
6#include "linux/sched.h"
7#include "linux/file.h"
8#include "linux/smp_lock.h"
9#include "linux/mm.h"
10#include "linux/utsname.h"
11#include "linux/msg.h"
12#include "linux/shm.h"
13#include "linux/sys.h"
14#include "linux/syscalls.h"
15#include "linux/unistd.h"
16#include "linux/slab.h"
17#include "linux/utime.h"
18#include "asm/mman.h"
19#include "asm/uaccess.h"
20#include "kern_util.h"
21#include "user_util.h"
22#include "sysdep/syscalls.h"
23#include "mode_kern.h"
24#include "choose-mode.h"
25
26/* Unlocked, I don't care if this is a bit off */
27int nsyscalls = 0;
28
29long sys_fork(void)
30{
31 long ret;
32
33 current->thread.forking = 1;
34 ret = do_fork(SIGCHLD, UPT_SP(&current->thread.regs.regs),
35 &current->thread.regs, 0, NULL, NULL);
36 current->thread.forking = 0;
37 return(ret);
38}
39
40long sys_vfork(void)
41{
42 long ret;
43
44 current->thread.forking = 1;
45 ret = do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD,
46 UPT_SP(&current->thread.regs.regs),
47 &current->thread.regs, 0, NULL, NULL);
48 current->thread.forking = 0;
49 return(ret);
50}
51
52/* common code for old and new mmaps */
53long sys_mmap2(unsigned long addr, unsigned long len,
54 unsigned long prot, unsigned long flags,
55 unsigned long fd, unsigned long pgoff)
56{
57 long error = -EBADF;
58 struct file * file = NULL;
59
60 flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
61 if (!(flags & MAP_ANONYMOUS)) {
62 file = fget(fd);
63 if (!file)
64 goto out;
65 }
66
67 down_write(&current->mm->mmap_sem);
68 error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
69 up_write(&current->mm->mmap_sem);
70
71 if (file)
72 fput(file);
73 out:
74 return error;
75}
76
77long old_mmap(unsigned long addr, unsigned long len,
78 unsigned long prot, unsigned long flags,
79 unsigned long fd, unsigned long offset)
80{
81 long err = -EINVAL;
82 if (offset & ~PAGE_MASK)
83 goto out;
84
85 err = sys_mmap2(addr, len, prot, flags, fd, offset >> PAGE_SHIFT);
86 out:
87 return err;
88}
89/*
90 * sys_pipe() is the normal C calling standard for creating
91 * a pipe. It's not the way unix traditionally does this, though.
92 */
93long sys_pipe(unsigned long __user * fildes)
94{
95 int fd[2];
96 long error;
97
98 error = do_pipe(fd);
99 if (!error) {
100 if (copy_to_user(fildes, fd, sizeof(fd)))
101 error = -EFAULT;
102 }
103 return error;
104}
105
106
107long sys_uname(struct old_utsname __user * name)
108{
109 long err;
110 if (!name)
111 return -EFAULT;
112 down_read(&uts_sem);
113 err=copy_to_user(name, &system_utsname, sizeof (*name));
114 up_read(&uts_sem);
115 return err?-EFAULT:0;
116}
117
118long sys_olduname(struct oldold_utsname __user * name)
119{
120 long error;
121
122 if (!name)
123 return -EFAULT;
124 if (!access_ok(VERIFY_WRITE,name,sizeof(struct oldold_utsname)))
125 return -EFAULT;
126
127 down_read(&uts_sem);
128
129 error = __copy_to_user(&name->sysname,&system_utsname.sysname,
130 __OLD_UTS_LEN);
131 error |= __put_user(0,name->sysname+__OLD_UTS_LEN);
132 error |= __copy_to_user(&name->nodename,&system_utsname.nodename,
133 __OLD_UTS_LEN);
134 error |= __put_user(0,name->nodename+__OLD_UTS_LEN);
135 error |= __copy_to_user(&name->release,&system_utsname.release,
136 __OLD_UTS_LEN);
137 error |= __put_user(0,name->release+__OLD_UTS_LEN);
138 error |= __copy_to_user(&name->version,&system_utsname.version,
139 __OLD_UTS_LEN);
140 error |= __put_user(0,name->version+__OLD_UTS_LEN);
141 error |= __copy_to_user(&name->machine,&system_utsname.machine,
142 __OLD_UTS_LEN);
143 error |= __put_user(0,name->machine+__OLD_UTS_LEN);
144
145 up_read(&uts_sem);
146
147 error = error ? -EFAULT : 0;
148
149 return error;
150}
151
152DEFINE_SPINLOCK(syscall_lock);
153
154static int syscall_index = 0;
155
156int next_syscall_index(int limit)
157{
158 int ret;
159
160 spin_lock(&syscall_lock);
161 ret = syscall_index;
162 if(++syscall_index == limit)
163 syscall_index = 0;
164 spin_unlock(&syscall_lock);
165 return(ret);
166}
diff --git a/arch/um/kernel/time_kern.c b/arch/um/kernel/time.c
index d7e044b5e5ee..552ca1cb9847 100644
--- a/arch/um/kernel/time_kern.c
+++ b/arch/um/kernel/time.c
@@ -38,7 +38,6 @@ unsigned long long sched_clock(void)
38/* Changed at early boot */ 38/* Changed at early boot */
39int timer_irq_inited = 0; 39int timer_irq_inited = 0;
40 40
41static int first_tick;
42static unsigned long long prev_nsecs; 41static unsigned long long prev_nsecs;
43#ifdef CONFIG_UML_REAL_TIME_CLOCK 42#ifdef CONFIG_UML_REAL_TIME_CLOCK
44static long long delta; /* Deviation per interval */ 43static long long delta; /* Deviation per interval */
@@ -48,15 +47,8 @@ void timer_irq(union uml_pt_regs *regs)
48{ 47{
49 unsigned long long ticks = 0; 48 unsigned long long ticks = 0;
50 49
51 if(!timer_irq_inited){
52 /* This is to ensure that ticks don't pile up when
53 * the timer handler is suspended */
54 first_tick = 0;
55 return;
56 }
57
58 if(first_tick){
59#ifdef CONFIG_UML_REAL_TIME_CLOCK 50#ifdef CONFIG_UML_REAL_TIME_CLOCK
51 if(prev_nsecs){
60 /* We've had 1 tick */ 52 /* We've had 1 tick */
61 unsigned long long nsecs = os_nsecs(); 53 unsigned long long nsecs = os_nsecs();
62 54
@@ -69,44 +61,17 @@ void timer_irq(union uml_pt_regs *regs)
69 61
70 ticks += (delta * HZ) / BILLION; 62 ticks += (delta * HZ) / BILLION;
71 delta -= (ticks * BILLION) / HZ; 63 delta -= (ticks * BILLION) / HZ;
64 }
65 else prev_nsecs = os_nsecs();
72#else 66#else
73 ticks = 1; 67 ticks = 1;
74#endif 68#endif
75 }
76 else {
77 prev_nsecs = os_nsecs();
78 first_tick = 1;
79 }
80
81 while(ticks > 0){ 69 while(ticks > 0){
82 do_IRQ(TIMER_IRQ, regs); 70 do_IRQ(TIMER_IRQ, regs);
83 ticks--; 71 ticks--;
84 } 72 }
85} 73}
86 74
87
88void time_init_kern(void)
89{
90 long long nsecs;
91
92 nsecs = os_nsecs();
93 set_normalized_timespec(&wall_to_monotonic, -nsecs / BILLION,
94 -nsecs % BILLION);
95}
96
97void do_boot_timer_handler(struct sigcontext * sc)
98{
99 unsigned long flags;
100 struct pt_regs regs;
101
102 CHOOSE_MODE((void) (UPT_SC(&regs.regs) = sc),
103 (void) (regs.regs.skas.is_user = 0));
104
105 write_seqlock_irqsave(&xtime_lock, flags);
106 do_timer(&regs);
107 write_sequnlock_irqrestore(&xtime_lock, flags);
108}
109
110static DEFINE_SPINLOCK(timer_spinlock); 75static DEFINE_SPINLOCK(timer_spinlock);
111 76
112static unsigned long long local_offset = 0; 77static unsigned long long local_offset = 0;
@@ -142,6 +107,32 @@ irqreturn_t um_timer(int irq, void *dev, struct pt_regs *regs)
142 return IRQ_HANDLED; 107 return IRQ_HANDLED;
143} 108}
144 109
110static void register_timer(void)
111{
112 int err;
113
114 err = request_irq(TIMER_IRQ, um_timer, IRQF_DISABLED, "timer", NULL);
115 if(err != 0)
116 printk(KERN_ERR "timer_init : request_irq failed - "
117 "errno = %d\n", -err);
118
119 timer_irq_inited = 1;
120
121 user_time_init();
122}
123
124extern void (*late_time_init)(void);
125
126void time_init(void)
127{
128 long long nsecs;
129
130 nsecs = os_nsecs();
131 set_normalized_timespec(&wall_to_monotonic, -nsecs / BILLION,
132 -nsecs % BILLION);
133 late_time_init = register_timer;
134}
135
145void do_gettimeofday(struct timeval *tv) 136void do_gettimeofday(struct timeval *tv)
146{ 137{
147 unsigned long long nsecs = get_time(); 138 unsigned long long nsecs = get_time();
@@ -189,18 +180,3 @@ void timer_handler(int sig, union uml_pt_regs *regs)
189 if(current_thread->cpu == 0) 180 if(current_thread->cpu == 0)
190 timer_irq(regs); 181 timer_irq(regs);
191} 182}
192
193int __init timer_init(void)
194{
195 int err;
196
197 user_time_init();
198 err = request_irq(TIMER_IRQ, um_timer, IRQF_DISABLED, "timer", NULL);
199 if(err != 0)
200 printk(KERN_ERR "timer_init : request_irq failed - "
201 "errno = %d\n", -err);
202 timer_irq_inited = 1;
203 return(0);
204}
205
206arch_initcall(timer_init);
diff --git a/arch/um/kernel/trap_kern.c b/arch/um/kernel/trap.c
index 02f6d4d8dc3a..ac70fa5a2e2a 100644
--- a/arch/um/kernel/trap_kern.c
+++ b/arch/um/kernel/trap.c
@@ -35,7 +35,7 @@
35#include "os.h" 35#include "os.h"
36 36
37/* Note this is constrained to return 0, -EFAULT, -EACCESS, -ENOMEM by segv(). */ 37/* Note this is constrained to return 0, -EFAULT, -EACCESS, -ENOMEM by segv(). */
38int handle_page_fault(unsigned long address, unsigned long ip, 38int handle_page_fault(unsigned long address, unsigned long ip,
39 int is_write, int is_user, int *code_out) 39 int is_write, int is_user, int *code_out)
40{ 40{
41 struct mm_struct *mm = current->mm; 41 struct mm_struct *mm = current->mm;
@@ -55,20 +55,20 @@ int handle_page_fault(unsigned long address, unsigned long ip,
55 55
56 down_read(&mm->mmap_sem); 56 down_read(&mm->mmap_sem);
57 vma = find_vma(mm, address); 57 vma = find_vma(mm, address);
58 if(!vma) 58 if(!vma)
59 goto out; 59 goto out;
60 else if(vma->vm_start <= address) 60 else if(vma->vm_start <= address)
61 goto good_area; 61 goto good_area;
62 else if(!(vma->vm_flags & VM_GROWSDOWN)) 62 else if(!(vma->vm_flags & VM_GROWSDOWN))
63 goto out; 63 goto out;
64 else if(is_user && !ARCH_IS_STACKGROW(address)) 64 else if(is_user && !ARCH_IS_STACKGROW(address))
65 goto out; 65 goto out;
66 else if(expand_stack(vma, address)) 66 else if(expand_stack(vma, address))
67 goto out; 67 goto out;
68 68
69good_area: 69good_area:
70 *code_out = SEGV_ACCERR; 70 *code_out = SEGV_ACCERR;
71 if(is_write && !(vma->vm_flags & VM_WRITE)) 71 if(is_write && !(vma->vm_flags & VM_WRITE))
72 goto out; 72 goto out;
73 73
74 /* Don't require VM_READ|VM_EXEC for write faults! */ 74 /* Don't require VM_READ|VM_EXEC for write faults! */
@@ -184,14 +184,14 @@ unsigned long segv(struct faultinfo fi, unsigned long ip, int is_user, void *sc)
184 else if(catcher != NULL){ 184 else if(catcher != NULL){
185 current->thread.fault_addr = (void *) address; 185 current->thread.fault_addr = (void *) address;
186 do_longjmp(catcher, 1); 186 do_longjmp(catcher, 1);
187 } 187 }
188 else if(current->thread.fault_addr != NULL) 188 else if(current->thread.fault_addr != NULL)
189 panic("fault_addr set but no fault catcher"); 189 panic("fault_addr set but no fault catcher");
190 else if(!is_user && arch_fixup(ip, sc)) 190 else if(!is_user && arch_fixup(ip, sc))
191 return(0); 191 return(0);
192 192
193 if(!is_user) 193 if(!is_user)
194 panic("Kernel mode fault at addr 0x%lx, ip 0x%lx", 194 panic("Kernel mode fault at addr 0x%lx, ip 0x%lx",
195 address, ip); 195 address, ip);
196 196
197 if (err == -EACCES) { 197 if (err == -EACCES) {
diff --git a/arch/um/kernel/tt/exec_kern.c b/arch/um/kernel/tt/exec_kern.c
index 5c1e4cc1c049..ad66df17d9d7 100644
--- a/arch/um/kernel/tt/exec_kern.c
+++ b/arch/um/kernel/tt/exec_kern.c
@@ -21,7 +21,7 @@
21static int exec_tramp(void *sig_stack) 21static int exec_tramp(void *sig_stack)
22{ 22{
23 init_new_thread_stack(sig_stack, NULL); 23 init_new_thread_stack(sig_stack, NULL);
24 init_new_thread_signals(1); 24 init_new_thread_signals();
25 os_stop_process(os_getpid()); 25 os_stop_process(os_getpid());
26 return(0); 26 return(0);
27} 27}
diff --git a/arch/um/kernel/tt/mem.c b/arch/um/kernel/tt/mem.c
index bcb8796c3cb1..84a23b14f770 100644
--- a/arch/um/kernel/tt/mem.c
+++ b/arch/um/kernel/tt/mem.c
@@ -24,22 +24,13 @@ void before_mem_tt(unsigned long brk_start)
24#define SIZE ((CONFIG_NEST_LEVEL + CONFIG_KERNEL_HALF_GIGS) * 0x20000000) 24#define SIZE ((CONFIG_NEST_LEVEL + CONFIG_KERNEL_HALF_GIGS) * 0x20000000)
25#define START (CONFIG_TOP_ADDR - SIZE) 25#define START (CONFIG_TOP_ADDR - SIZE)
26 26
27unsigned long set_task_sizes_tt(int arg, unsigned long *host_size_out, 27unsigned long set_task_sizes_tt(unsigned long *task_size_out)
28 unsigned long *task_size_out)
29{ 28{
29 unsigned long host_task_size;
30
30 /* Round up to the nearest 4M */ 31 /* Round up to the nearest 4M */
31 *host_size_out = ROUND_4M((unsigned long) &arg); 32 host_task_size = ROUND_4M((unsigned long) &host_task_size);
32 *task_size_out = START; 33 *task_size_out = START;
33 return(START);
34}
35 34
36/* 35 return host_task_size;
37 * Overrides for Emacs so that we follow Linus's tabbing style. 36}
38 * Emacs will notice this stuff at the end of the file and automatically
39 * adjust the settings for this buffer only. This must remain at the end
40 * of the file.
41 * ---------------------------------------------------------------------------
42 * Local variables:
43 * c-file-style: "linux"
44 * End:
45 */
diff --git a/arch/um/kernel/tt/process_kern.c b/arch/um/kernel/tt/process_kern.c
index 8368c2dbe635..1e86f0bfef72 100644
--- a/arch/um/kernel/tt/process_kern.c
+++ b/arch/um/kernel/tt/process_kern.c
@@ -142,7 +142,7 @@ static void new_thread_handler(int sig)
142 schedule_tail(current->thread.prev_sched); 142 schedule_tail(current->thread.prev_sched);
143 current->thread.prev_sched = NULL; 143 current->thread.prev_sched = NULL;
144 144
145 init_new_thread_signals(1); 145 init_new_thread_signals();
146 enable_timer(); 146 enable_timer();
147 free_page(current->thread.temp_stack); 147 free_page(current->thread.temp_stack);
148 set_cmdline("(kernel thread)"); 148 set_cmdline("(kernel thread)");
diff --git a/arch/um/kernel/tt/syscall_kern.c b/arch/um/kernel/tt/syscall_kern.c
index 3fda9a03c59a..293caa6d0c2d 100644
--- a/arch/um/kernel/tt/syscall_kern.c
+++ b/arch/um/kernel/tt/syscall_kern.c
@@ -21,18 +21,11 @@ void syscall_handler_tt(int sig, struct pt_regs *regs)
21 void *sc; 21 void *sc;
22 long result; 22 long result;
23 int syscall; 23 int syscall;
24#ifdef CONFIG_SYSCALL_DEBUG 24
25 int index;
26#endif
27 sc = UPT_SC(&regs->regs); 25 sc = UPT_SC(&regs->regs);
28 SC_START_SYSCALL(sc); 26 SC_START_SYSCALL(sc);
29 27
30 syscall = UPT_SYSCALL_NR(&regs->regs); 28 syscall = UPT_SYSCALL_NR(&regs->regs);
31
32#ifdef CONFIG_SYSCALL_DEBUG
33 index = record_syscall_start(syscall);
34#endif
35
36 syscall_trace(&regs->regs, 0); 29 syscall_trace(&regs->regs, 0);
37 30
38 current->thread.nsyscalls++; 31 current->thread.nsyscalls++;
@@ -50,7 +43,4 @@ void syscall_handler_tt(int sig, struct pt_regs *regs)
50 SC_SET_SYSCALL_RETURN(sc, result); 43 SC_SET_SYSCALL_RETURN(sc, result);
51 44
52 syscall_trace(&regs->regs, 1); 45 syscall_trace(&regs->regs, 1);
53#ifdef CONFIG_SYSCALL_DEBUG
54 record_syscall_end(index, result);
55#endif
56} 46}
diff --git a/arch/um/kernel/tt/tracer.c b/arch/um/kernel/tt/tracer.c
index 71daae24e48a..9882342206ec 100644
--- a/arch/um/kernel/tt/tracer.c
+++ b/arch/um/kernel/tt/tracer.c
@@ -188,10 +188,7 @@ int tracer(int (*init_proc)(void *), void *sp)
188 int status, pid = 0, sig = 0, cont_type, tracing = 0, op = 0; 188 int status, pid = 0, sig = 0, cont_type, tracing = 0, op = 0;
189 int proc_id = 0, n, err, old_tracing = 0, strace = 0; 189 int proc_id = 0, n, err, old_tracing = 0, strace = 0;
190 int local_using_sysemu = 0; 190 int local_using_sysemu = 0;
191#ifdef UML_CONFIG_SYSCALL_DEBUG 191
192 unsigned long eip = 0;
193 int last_index;
194#endif
195 signal(SIGPIPE, SIG_IGN); 192 signal(SIGPIPE, SIG_IGN);
196 setup_tracer_winch(); 193 setup_tracer_winch();
197 tracing_pid = os_getpid(); 194 tracing_pid = os_getpid();
@@ -282,23 +279,6 @@ int tracer(int (*init_proc)(void *), void *sp)
282 else if(WIFSTOPPED(status)){ 279 else if(WIFSTOPPED(status)){
283 proc_id = pid_to_processor_id(pid); 280 proc_id = pid_to_processor_id(pid);
284 sig = WSTOPSIG(status); 281 sig = WSTOPSIG(status);
285#ifdef UML_CONFIG_SYSCALL_DEBUG
286 if(signal_index[proc_id] == 1024){
287 signal_index[proc_id] = 0;
288 last_index = 1023;
289 }
290 else last_index = signal_index[proc_id] - 1;
291 if(((sig == SIGPROF) || (sig == SIGVTALRM) ||
292 (sig == SIGALRM)) &&
293 (signal_record[proc_id][last_index].signal == sig)&&
294 (signal_record[proc_id][last_index].pid == pid))
295 signal_index[proc_id] = last_index;
296 signal_record[proc_id][signal_index[proc_id]].pid = pid;
297 gettimeofday(&signal_record[proc_id][signal_index[proc_id]].time, NULL);
298 eip = ptrace(PTRACE_PEEKUSR, pid, PT_IP_OFFSET, 0);
299 signal_record[proc_id][signal_index[proc_id]].addr = eip;
300 signal_record[proc_id][signal_index[proc_id]++].signal = sig;
301#endif
302 if(proc_id == -1){ 282 if(proc_id == -1){
303 sleeping_process_signal(pid, sig); 283 sleeping_process_signal(pid, sig);
304 continue; 284 continue;
diff --git a/arch/um/kernel/um_arch.c b/arch/um/kernel/um_arch.c
index 37cfe7701f06..7896cf98232d 100644
--- a/arch/um/kernel/um_arch.c
+++ b/arch/um/kernel/um_arch.c
@@ -330,6 +330,8 @@ EXPORT_SYMBOL(end_iomem);
330 330
331#define MIN_VMALLOC (32 * 1024 * 1024) 331#define MIN_VMALLOC (32 * 1024 * 1024)
332 332
333extern char __binary_start;
334
333int linux_main(int argc, char **argv) 335int linux_main(int argc, char **argv)
334{ 336{
335 unsigned long avail, diff; 337 unsigned long avail, diff;
@@ -374,8 +376,9 @@ int linux_main(int argc, char **argv)
374 376
375 printf("UML running in %s mode\n", mode); 377 printf("UML running in %s mode\n", mode);
376 378
377 uml_start = CHOOSE_MODE_PROC(set_task_sizes_tt, set_task_sizes_skas, 0, 379 uml_start = (unsigned long) &__binary_start;
378 &host_task_size, &task_size); 380 host_task_size = CHOOSE_MODE_PROC(set_task_sizes_tt,
381 set_task_sizes_skas, &task_size);
379 382
380 /* 383 /*
381 * Setting up handlers to 'sig_info' struct 384 * Setting up handlers to 'sig_info' struct
@@ -395,7 +398,7 @@ int linux_main(int argc, char **argv)
395 physmem_size += UML_ROUND_UP(brk_start) - UML_ROUND_UP(&_end); 398 physmem_size += UML_ROUND_UP(brk_start) - UML_ROUND_UP(&_end);
396 } 399 }
397 400
398 uml_physmem = uml_start; 401 uml_physmem = uml_start & PAGE_MASK;
399 402
400 /* Reserve up to 4M after the current brk */ 403 /* Reserve up to 4M after the current brk */
401 uml_reserved = ROUND_4M(brk_start) + (1 << 22); 404 uml_reserved = ROUND_4M(brk_start) + (1 << 22);
diff --git a/arch/um/kernel/uml.lds.S b/arch/um/kernel/uml.lds.S
index af11915ce0a8..8eca47a6ff08 100644
--- a/arch/um/kernel/uml.lds.S
+++ b/arch/um/kernel/uml.lds.S
@@ -7,13 +7,16 @@ jiffies = jiffies_64;
7 7
8SECTIONS 8SECTIONS
9{ 9{
10 /*This must contain the right address - not quite the default ELF one.*/ 10 /* This must contain the right address - not quite the default ELF one.*/
11 PROVIDE (__executable_start = START); 11 PROVIDE (__executable_start = START);
12 . = START + SIZEOF_HEADERS; 12 /* Static binaries stick stuff here, like the sigreturn trampoline,
13 * invisibly to objdump. So, just make __binary_start equal to the very
14 * beginning of the executable, and if there are unmapped pages after this,
15 * they are forever unusable.
16 */
17 __binary_start = START;
13 18
14 /* Used in arch/um/kernel/mem.c. Any memory between START and __binary_start 19 . = START + SIZEOF_HEADERS;
15 * is remapped.*/
16 __binary_start = .;
17 20
18#ifdef MODE_TT 21#ifdef MODE_TT
19 .remap_data : { UNMAP_PATH (.data .bss) } 22 .remap_data : { UNMAP_PATH (.data .bss) }
diff --git a/arch/um/os-Linux/file.c b/arch/um/os-Linux/file.c
index 09251338d99e..189fa677085a 100644
--- a/arch/um/os-Linux/file.c
+++ b/arch/um/os-Linux/file.c
@@ -1,4 +1,4 @@
1/* 1/*
2 * Copyright (C) 2002 Jeff Dike (jdike@karaya.com) 2 * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
3 * Licensed under the GPL 3 * Licensed under the GPL
4 */ 4 */
@@ -18,6 +18,7 @@
18#include "os.h" 18#include "os.h"
19#include "user.h" 19#include "user.h"
20#include "kern_util.h" 20#include "kern_util.h"
21#include "user_util.h"
21 22
22static void copy_stat(struct uml_stat *dst, struct stat64 *src) 23static void copy_stat(struct uml_stat *dst, struct stat64 *src)
23{ 24{
@@ -42,16 +43,13 @@ int os_stat_fd(const int fd, struct uml_stat *ubuf)
42 struct stat64 sbuf; 43 struct stat64 sbuf;
43 int err; 44 int err;
44 45
45 do { 46 CATCH_EINTR(err = fstat64(fd, &sbuf));
46 err = fstat64(fd, &sbuf);
47 } while((err < 0) && (errno == EINTR)) ;
48
49 if(err < 0) 47 if(err < 0)
50 return(-errno); 48 return -errno;
51 49
52 if(ubuf != NULL) 50 if(ubuf != NULL)
53 copy_stat(ubuf, &sbuf); 51 copy_stat(ubuf, &sbuf);
54 return(err); 52 return err;
55} 53}
56 54
57int os_stat_file(const char *file_name, struct uml_stat *ubuf) 55int os_stat_file(const char *file_name, struct uml_stat *ubuf)
@@ -64,11 +62,11 @@ int os_stat_file(const char *file_name, struct uml_stat *ubuf)
64 } while((err < 0) && (errno == EINTR)) ; 62 } while((err < 0) && (errno == EINTR)) ;
65 63
66 if(err < 0) 64 if(err < 0)
67 return(-errno); 65 return -errno;
68 66
69 if(ubuf != NULL) 67 if(ubuf != NULL)
70 copy_stat(ubuf, &sbuf); 68 copy_stat(ubuf, &sbuf);
71 return(err); 69 return err;
72} 70}
73 71
74int os_access(const char* file, int mode) 72int os_access(const char* file, int mode)
@@ -80,9 +78,9 @@ int os_access(const char* file, int mode)
80 78
81 err = access(file, amode); 79 err = access(file, amode);
82 if(err < 0) 80 if(err < 0)
83 return(-errno); 81 return -errno;
84 82
85 return(0); 83 return 0;
86} 84}
87 85
88void os_print_error(int error, const char* str) 86void os_print_error(int error, const char* str)
@@ -99,9 +97,9 @@ int os_ioctl_generic(int fd, unsigned int cmd, unsigned long arg)
99 97
100 err = ioctl(fd, cmd, arg); 98 err = ioctl(fd, cmd, arg);
101 if(err < 0) 99 if(err < 0)
102 return(-errno); 100 return -errno;
103 101
104 return(err); 102 return err;
105} 103}
106 104
107int os_window_size(int fd, int *rows, int *cols) 105int os_window_size(int fd, int *rows, int *cols)
@@ -109,12 +107,12 @@ int os_window_size(int fd, int *rows, int *cols)
109 struct winsize size; 107 struct winsize size;
110 108
111 if(ioctl(fd, TIOCGWINSZ, &size) < 0) 109 if(ioctl(fd, TIOCGWINSZ, &size) < 0)
112 return(-errno); 110 return -errno;
113 111
114 *rows = size.ws_row; 112 *rows = size.ws_row;
115 *cols = size.ws_col; 113 *cols = size.ws_col;
116 114
117 return(0); 115 return 0;
118} 116}
119 117
120int os_new_tty_pgrp(int fd, int pid) 118int os_new_tty_pgrp(int fd, int pid)
@@ -125,16 +123,16 @@ int os_new_tty_pgrp(int fd, int pid)
125 if(tcsetpgrp(fd, pid) < 0) 123 if(tcsetpgrp(fd, pid) < 0)
126 return -errno; 124 return -errno;
127 125
128 return(0); 126 return 0;
129} 127}
130 128
131/* FIXME: ensure namebuf in os_get_if_name is big enough */ 129/* FIXME: ensure namebuf in os_get_if_name is big enough */
132int os_get_ifname(int fd, char* namebuf) 130int os_get_ifname(int fd, char* namebuf)
133{ 131{
134 if(ioctl(fd, SIOCGIFNAME, namebuf) < 0) 132 if(ioctl(fd, SIOCGIFNAME, namebuf) < 0)
135 return(-errno); 133 return -errno;
136 134
137 return(0); 135 return 0;
138} 136}
139 137
140int os_set_slip(int fd) 138int os_set_slip(int fd)
@@ -149,7 +147,7 @@ int os_set_slip(int fd)
149 if(ioctl(fd, SIOCSIFENCAP, &sencap) < 0) 147 if(ioctl(fd, SIOCSIFENCAP, &sencap) < 0)
150 return -errno; 148 return -errno;
151 149
152 return(0); 150 return 0;
153} 151}
154 152
155int os_set_owner(int fd, int pid) 153int os_set_owner(int fd, int pid)
@@ -158,10 +156,10 @@ int os_set_owner(int fd, int pid)
158 int save_errno = errno; 156 int save_errno = errno;
159 157
160 if(fcntl(fd, F_GETOWN, 0) != pid) 158 if(fcntl(fd, F_GETOWN, 0) != pid)
161 return(-save_errno); 159 return -save_errno;
162 } 160 }
163 161
164 return(0); 162 return 0;
165} 163}
166 164
167/* FIXME? moved wholesale from sigio_user.c to get fcntls out of that file */ 165/* FIXME? moved wholesale from sigio_user.c to get fcntls out of that file */
@@ -192,9 +190,9 @@ int os_mode_fd(int fd, int mode)
192 } while((err < 0) && (errno==EINTR)) ; 190 } while((err < 0) && (errno==EINTR)) ;
193 191
194 if(err < 0) 192 if(err < 0)
195 return(-errno); 193 return -errno;
196 194
197 return(0); 195 return 0;
198} 196}
199 197
200int os_file_type(char *file) 198int os_file_type(char *file)
@@ -204,15 +202,21 @@ int os_file_type(char *file)
204 202
205 err = os_stat_file(file, &buf); 203 err = os_stat_file(file, &buf);
206 if(err < 0) 204 if(err < 0)
207 return(err); 205 return err;
208 206
209 if(S_ISDIR(buf.ust_mode)) return(OS_TYPE_DIR); 207 if(S_ISDIR(buf.ust_mode))
210 else if(S_ISLNK(buf.ust_mode)) return(OS_TYPE_SYMLINK); 208 return OS_TYPE_DIR;
211 else if(S_ISCHR(buf.ust_mode)) return(OS_TYPE_CHARDEV); 209 else if(S_ISLNK(buf.ust_mode))
212 else if(S_ISBLK(buf.ust_mode)) return(OS_TYPE_BLOCKDEV); 210 return OS_TYPE_SYMLINK;
213 else if(S_ISFIFO(buf.ust_mode)) return(OS_TYPE_FIFO); 211 else if(S_ISCHR(buf.ust_mode))
214 else if(S_ISSOCK(buf.ust_mode)) return(OS_TYPE_SOCK); 212 return OS_TYPE_CHARDEV;
215 else return(OS_TYPE_FILE); 213 else if(S_ISBLK(buf.ust_mode))
214 return OS_TYPE_BLOCKDEV;
215 else if(S_ISFIFO(buf.ust_mode))
216 return OS_TYPE_FIFO;
217 else if(S_ISSOCK(buf.ust_mode))
218 return OS_TYPE_SOCK;
219 else return OS_TYPE_FILE;
216} 220}
217 221
218int os_file_mode(char *file, struct openflags *mode_out) 222int os_file_mode(char *file, struct openflags *mode_out)
@@ -302,8 +306,8 @@ int os_seek_file(int fd, __u64 offset)
302 306
303 actual = lseek64(fd, offset, SEEK_SET); 307 actual = lseek64(fd, offset, SEEK_SET);
304 if(actual != offset) 308 if(actual != offset)
305 return(-errno); 309 return -errno;
306 return(0); 310 return 0;
307} 311}
308 312
309static int fault_buffer(void *start, int len, 313static int fault_buffer(void *start, int len,
@@ -314,13 +318,13 @@ static int fault_buffer(void *start, int len,
314 318
315 for(i = 0; i < len; i += page){ 319 for(i = 0; i < len; i += page){
316 if((*copy_proc)(start + i, &c, sizeof(c))) 320 if((*copy_proc)(start + i, &c, sizeof(c)))
317 return(-EFAULT); 321 return -EFAULT;
318 } 322 }
319 if((len % page) != 0){ 323 if((len % page) != 0){
320 if((*copy_proc)(start + len - 1, &c, sizeof(c))) 324 if((*copy_proc)(start + len - 1, &c, sizeof(c)))
321 return(-EFAULT); 325 return -EFAULT;
322 } 326 }
323 return(0); 327 return 0;
324} 328}
325 329
326static int file_io(int fd, void *buf, int len, 330static int file_io(int fd, void *buf, int len,
@@ -334,26 +338,26 @@ static int file_io(int fd, void *buf, int len,
334 if((n < 0) && (errno == EFAULT)){ 338 if((n < 0) && (errno == EFAULT)){
335 err = fault_buffer(buf, len, copy_user_proc); 339 err = fault_buffer(buf, len, copy_user_proc);
336 if(err) 340 if(err)
337 return(err); 341 return err;
338 n = (*io_proc)(fd, buf, len); 342 n = (*io_proc)(fd, buf, len);
339 } 343 }
340 } while((n < 0) && (errno == EINTR)); 344 } while((n < 0) && (errno == EINTR));
341 345
342 if(n < 0) 346 if(n < 0)
343 return(-errno); 347 return -errno;
344 return(n); 348 return n;
345} 349}
346 350
347int os_read_file(int fd, void *buf, int len) 351int os_read_file(int fd, void *buf, int len)
348{ 352{
349 return(file_io(fd, buf, len, (int (*)(int, void *, int)) read, 353 return file_io(fd, buf, len, (int (*)(int, void *, int)) read,
350 copy_from_user_proc)); 354 copy_from_user_proc);
351} 355}
352 356
353int os_write_file(int fd, const void *buf, int len) 357int os_write_file(int fd, const void *buf, int len)
354{ 358{
355 return(file_io(fd, (void *) buf, len, 359 return file_io(fd, (void *) buf, len,
356 (int (*)(int, void *, int)) write, copy_to_user_proc)); 360 (int (*)(int, void *, int)) write, copy_to_user_proc);
357} 361}
358 362
359int os_file_size(char *file, unsigned long long *size_out) 363int os_file_size(char *file, unsigned long long *size_out)
@@ -398,11 +402,11 @@ int os_file_modtime(char *file, unsigned long *modtime)
398 err = os_stat_file(file, &buf); 402 err = os_stat_file(file, &buf);
399 if(err < 0){ 403 if(err < 0){
400 printk("Couldn't stat \"%s\" : err = %d\n", file, -err); 404 printk("Couldn't stat \"%s\" : err = %d\n", file, -err);
401 return(err); 405 return err;
402 } 406 }
403 407
404 *modtime = buf.ust_mtime; 408 *modtime = buf.ust_mtime;
405 return(0); 409 return 0;
406} 410}
407 411
408int os_get_exec_close(int fd, int* close_on_exec) 412int os_get_exec_close(int fd, int* close_on_exec)
@@ -455,7 +459,7 @@ int os_pipe(int *fds, int stream, int close_on_exec)
455 if(err < 0) 459 if(err < 0)
456 goto error; 460 goto error;
457 461
458 return(0); 462 return 0;
459 463
460 error: 464 error:
461 printk("os_pipe : Setting FD_CLOEXEC failed, err = %d\n", -err); 465 printk("os_pipe : Setting FD_CLOEXEC failed, err = %d\n", -err);
@@ -486,12 +490,12 @@ int os_set_fd_async(int fd, int owner)
486 (fcntl(fd, F_SETOWN, owner) < 0)){ 490 (fcntl(fd, F_SETOWN, owner) < 0)){
487 err = -errno; 491 err = -errno;
488 printk("os_set_fd_async : Failed to fcntl F_SETOWN " 492 printk("os_set_fd_async : Failed to fcntl F_SETOWN "
489 "(or F_SETSIG) fd %d to pid %d, errno = %d\n", fd, 493 "(or F_SETSIG) fd %d to pid %d, errno = %d\n", fd,
490 owner, errno); 494 owner, errno);
491 return err; 495 return err;
492 } 496 }
493 497
494 return(0); 498 return 0;
495} 499}
496 500
497int os_clear_fd_async(int fd) 501int os_clear_fd_async(int fd)
@@ -500,8 +504,8 @@ int os_clear_fd_async(int fd)
500 504
501 flags &= ~(O_ASYNC | O_NONBLOCK); 505 flags &= ~(O_ASYNC | O_NONBLOCK);
502 if(fcntl(fd, F_SETFL, flags) < 0) 506 if(fcntl(fd, F_SETFL, flags) < 0)
503 return(-errno); 507 return -errno;
504 return(0); 508 return 0;
505} 509}
506 510
507int os_set_fd_block(int fd, int blocking) 511int os_set_fd_block(int fd, int blocking)
@@ -516,7 +520,7 @@ int os_set_fd_block(int fd, int blocking)
516 if(fcntl(fd, F_SETFL, flags) < 0) 520 if(fcntl(fd, F_SETFL, flags) < 0)
517 return -errno; 521 return -errno;
518 522
519 return(0); 523 return 0;
520} 524}
521 525
522int os_accept_connection(int fd) 526int os_accept_connection(int fd)
@@ -524,9 +528,9 @@ int os_accept_connection(int fd)
524 int new; 528 int new;
525 529
526 new = accept(fd, NULL, 0); 530 new = accept(fd, NULL, 0);
527 if(new < 0) 531 if(new < 0)
528 return(-errno); 532 return -errno;
529 return(new); 533 return new;
530} 534}
531 535
532#ifndef SHUT_RD 536#ifndef SHUT_RD
@@ -550,12 +554,12 @@ int os_shutdown_socket(int fd, int r, int w)
550 else if(w) what = SHUT_WR; 554 else if(w) what = SHUT_WR;
551 else { 555 else {
552 printk("os_shutdown_socket : neither r or w was set\n"); 556 printk("os_shutdown_socket : neither r or w was set\n");
553 return(-EINVAL); 557 return -EINVAL;
554 } 558 }
555 err = shutdown(fd, what); 559 err = shutdown(fd, what);
556 if(err < 0) 560 if(err < 0)
557 return(-errno); 561 return -errno;
558 return(0); 562 return 0;
559} 563}
560 564
561int os_rcv_fd(int fd, int *helper_pid_out) 565int os_rcv_fd(int fd, int *helper_pid_out)
@@ -578,7 +582,7 @@ int os_rcv_fd(int fd, int *helper_pid_out)
578 582
579 n = recvmsg(fd, &msg, 0); 583 n = recvmsg(fd, &msg, 0);
580 if(n < 0) 584 if(n < 0)
581 return(-errno); 585 return -errno;
582 586
583 else if(n != sizeof(iov.iov_len)) 587 else if(n != sizeof(iov.iov_len))
584 *helper_pid_out = -1; 588 *helper_pid_out = -1;
@@ -586,16 +590,16 @@ int os_rcv_fd(int fd, int *helper_pid_out)
586 cmsg = CMSG_FIRSTHDR(&msg); 590 cmsg = CMSG_FIRSTHDR(&msg);
587 if(cmsg == NULL){ 591 if(cmsg == NULL){
588 printk("rcv_fd didn't receive anything, error = %d\n", errno); 592 printk("rcv_fd didn't receive anything, error = %d\n", errno);
589 return(-1); 593 return -1;
590 } 594 }
591 if((cmsg->cmsg_level != SOL_SOCKET) || 595 if((cmsg->cmsg_level != SOL_SOCKET) ||
592 (cmsg->cmsg_type != SCM_RIGHTS)){ 596 (cmsg->cmsg_type != SCM_RIGHTS)){
593 printk("rcv_fd didn't receive a descriptor\n"); 597 printk("rcv_fd didn't receive a descriptor\n");
594 return(-1); 598 return -1;
595 } 599 }
596 600
597 new = ((int *) CMSG_DATA(cmsg))[0]; 601 new = ((int *) CMSG_DATA(cmsg))[0];
598 return(new); 602 return new;
599} 603}
600 604
601int os_create_unix_socket(char *file, int len, int close_on_exec) 605int os_create_unix_socket(char *file, int len, int close_on_exec)
@@ -623,7 +627,7 @@ int os_create_unix_socket(char *file, int len, int close_on_exec)
623 if(err < 0) 627 if(err < 0)
624 return -errno; 628 return -errno;
625 629
626 return(sock); 630 return sock;
627} 631}
628 632
629void os_flush_stdout(void) 633void os_flush_stdout(void)
@@ -654,16 +658,5 @@ int os_lock_file(int fd, int excl)
654 printk("F_SETLK failed, file already locked by pid %d\n", lock.l_pid); 658 printk("F_SETLK failed, file already locked by pid %d\n", lock.l_pid);
655 err = save; 659 err = save;
656 out: 660 out:
657 return(err); 661 return err;
658} 662}
659
660/*
661 * Overrides for Emacs so that we follow Linus's tabbing style.
662 * Emacs will notice this stuff at the end of the file and automatically
663 * adjust the settings for this buffer only. This must remain at the end
664 * of the file.
665 * ---------------------------------------------------------------------------
666 * Local variables:
667 * c-file-style: "linux"
668 * End:
669 */
diff --git a/arch/um/os-Linux/irq.c b/arch/um/os-Linux/irq.c
index 3788d4568d33..7555bf9c33d9 100644
--- a/arch/um/os-Linux/irq.c
+++ b/arch/um/os-Linux/irq.c
@@ -52,11 +52,6 @@ int os_waiting_for_events(struct irq_fd *active_fds)
52 return n; 52 return n;
53} 53}
54 54
55int os_isatty(int fd)
56{
57 return isatty(fd);
58}
59
60int os_create_pollfd(int fd, int events, void *tmp_pfd, int size_tmpfds) 55int os_create_pollfd(int fd, int events, void *tmp_pfd, int size_tmpfds)
61{ 56{
62 if (pollfds_num == pollfds_size) { 57 if (pollfds_num == pollfds_size) {
@@ -142,17 +137,14 @@ void os_set_ioignore(void)
142 137
143void init_irq_signals(int on_sigstack) 138void init_irq_signals(int on_sigstack)
144{ 139{
145 __sighandler_t h;
146 int flags; 140 int flags;
147 141
148 flags = on_sigstack ? SA_ONSTACK : 0; 142 flags = on_sigstack ? SA_ONSTACK : 0;
149 if (timer_irq_inited)
150 h = (__sighandler_t)alarm_handler;
151 else
152 h = boot_timer_handler;
153 143
154 set_handler(SIGVTALRM, h, flags | SA_RESTART, 144 set_handler(SIGVTALRM, (__sighandler_t) alarm_handler,
155 SIGUSR1, SIGIO, SIGWINCH, SIGALRM, -1); 145 flags | SA_RESTART, SIGUSR1, SIGIO, SIGWINCH, SIGALRM, -1);
146 set_handler(SIGALRM, (__sighandler_t) alarm_handler,
147 flags | SA_RESTART, SIGUSR1, SIGIO, SIGWINCH, SIGALRM, -1);
156 set_handler(SIGIO, (__sighandler_t) sig_handler, flags | SA_RESTART, 148 set_handler(SIGIO, (__sighandler_t) sig_handler, flags | SA_RESTART,
157 SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1); 149 SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1);
158 signal(SIGWINCH, SIG_IGN); 150 signal(SIGWINCH, SIG_IGN);
diff --git a/arch/um/os-Linux/process.c b/arch/um/os-Linux/process.c
index 233be2f4f8cb..b1cda818f5b5 100644
--- a/arch/um/os-Linux/process.c
+++ b/arch/um/os-Linux/process.c
@@ -250,25 +250,24 @@ void init_new_thread_stack(void *sig_stack, void (*usr1_handler)(int))
250 if(usr1_handler) set_handler(SIGUSR1, usr1_handler, flags, -1); 250 if(usr1_handler) set_handler(SIGUSR1, usr1_handler, flags, -1);
251} 251}
252 252
253void init_new_thread_signals(int altstack) 253void init_new_thread_signals(void)
254{ 254{
255 int flags = altstack ? SA_ONSTACK : 0; 255 set_handler(SIGSEGV, (__sighandler_t) sig_handler, SA_ONSTACK,
256
257 set_handler(SIGSEGV, (__sighandler_t) sig_handler, flags,
258 SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1); 256 SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1);
259 set_handler(SIGTRAP, (__sighandler_t) sig_handler, flags, 257 set_handler(SIGTRAP, (__sighandler_t) sig_handler, SA_ONSTACK,
260 SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1); 258 SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1);
261 set_handler(SIGFPE, (__sighandler_t) sig_handler, flags, 259 set_handler(SIGFPE, (__sighandler_t) sig_handler, SA_ONSTACK,
262 SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1); 260 SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1);
263 set_handler(SIGILL, (__sighandler_t) sig_handler, flags, 261 set_handler(SIGILL, (__sighandler_t) sig_handler, SA_ONSTACK,
264 SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1); 262 SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1);
265 set_handler(SIGBUS, (__sighandler_t) sig_handler, flags, 263 set_handler(SIGBUS, (__sighandler_t) sig_handler, SA_ONSTACK,
266 SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1); 264 SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1);
267 set_handler(SIGUSR2, (__sighandler_t) sig_handler, 265 set_handler(SIGUSR2, (__sighandler_t) sig_handler,
268 flags, SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1); 266 SA_ONSTACK, SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM,
267 -1);
269 signal(SIGHUP, SIG_IGN); 268 signal(SIGHUP, SIG_IGN);
270 269
271 init_irq_signals(altstack); 270 init_irq_signals(1);
272} 271}
273 272
274int run_kernel_thread(int (*fn)(void *), void *arg, void **jmp_ptr) 273int run_kernel_thread(int (*fn)(void *), void *arg, void **jmp_ptr)
diff --git a/arch/um/os-Linux/sigio.c b/arch/um/os-Linux/sigio.c
index 00e9388e947a..0ecac563c7b3 100644
--- a/arch/um/os-Linux/sigio.c
+++ b/arch/um/os-Linux/sigio.c
@@ -43,13 +43,13 @@ struct pollfds {
43/* Protected by sigio_lock(). Used by the sigio thread, but the UML thread 43/* Protected by sigio_lock(). Used by the sigio thread, but the UML thread
44 * synchronizes with it. 44 * synchronizes with it.
45 */ 45 */
46struct pollfds current_poll = { 46static struct pollfds current_poll = {
47 .poll = NULL, 47 .poll = NULL,
48 .size = 0, 48 .size = 0,
49 .used = 0 49 .used = 0
50}; 50};
51 51
52struct pollfds next_poll = { 52static struct pollfds next_poll = {
53 .poll = NULL, 53 .poll = NULL,
54 .size = 0, 54 .size = 0,
55 .used = 0 55 .used = 0
@@ -156,7 +156,7 @@ static void update_thread(void)
156 set_signals(flags); 156 set_signals(flags);
157} 157}
158 158
159int add_sigio_fd(int fd, int read) 159static int add_sigio_fd(int fd, int read)
160{ 160{
161 int err = 0, i, n, events; 161 int err = 0, i, n, events;
162 162
@@ -191,6 +191,13 @@ int ignore_sigio_fd(int fd)
191 struct pollfd *p; 191 struct pollfd *p;
192 int err = 0, i, n = 0; 192 int err = 0, i, n = 0;
193 193
194 /* This is called from exitcalls elsewhere in UML - if
195 * sigio_cleanup has already run, then update_thread will hang
196 * or fail because the thread is no longer running.
197 */
198 if(write_sigio_pid == -1)
199 return -EIO;
200
194 sigio_lock(); 201 sigio_lock();
195 for(i = 0; i < current_poll.used; i++){ 202 for(i = 0; i < current_poll.used; i++){
196 if(current_poll.poll[i].fd == fd) break; 203 if(current_poll.poll[i].fd == fd) break;
@@ -215,7 +222,7 @@ int ignore_sigio_fd(int fd)
215 update_thread(); 222 update_thread();
216 out: 223 out:
217 sigio_unlock(); 224 sigio_unlock();
218 return(err); 225 return err;
219} 226}
220 227
221static struct pollfd *setup_initial_poll(int fd) 228static struct pollfd *setup_initial_poll(int fd)
@@ -233,7 +240,7 @@ static struct pollfd *setup_initial_poll(int fd)
233 return p; 240 return p;
234} 241}
235 242
236void write_sigio_workaround(void) 243static void write_sigio_workaround(void)
237{ 244{
238 unsigned long stack; 245 unsigned long stack;
239 struct pollfd *p; 246 struct pollfd *p;
@@ -314,10 +321,24 @@ out_close1:
314 close(l_write_sigio_fds[1]); 321 close(l_write_sigio_fds[1]);
315} 322}
316 323
317void sigio_cleanup(void) 324void maybe_sigio_broken(int fd, int read)
325{
326 if(!isatty(fd))
327 return;
328
329 if((read || pty_output_sigio) && (!read || pty_close_sigio))
330 return;
331
332 write_sigio_workaround();
333 add_sigio_fd(fd, read);
334}
335
336static void sigio_cleanup(void)
318{ 337{
319 if(write_sigio_pid != -1){ 338 if(write_sigio_pid != -1){
320 os_kill_process(write_sigio_pid, 1); 339 os_kill_process(write_sigio_pid, 1);
321 write_sigio_pid = -1; 340 write_sigio_pid = -1;
322 } 341 }
323} 342}
343
344__uml_exitcall(sigio_cleanup);
diff --git a/arch/um/os-Linux/signal.c b/arch/um/os-Linux/signal.c
index f11b3124a0c8..60e4faedf254 100644
--- a/arch/um/os-Linux/signal.c
+++ b/arch/um/os-Linux/signal.c
@@ -106,29 +106,6 @@ void alarm_handler(ARCH_SIGHDLR_PARAM)
106 set_signals(enabled); 106 set_signals(enabled);
107} 107}
108 108
109extern void do_boot_timer_handler(struct sigcontext * sc);
110
111void boot_timer_handler(ARCH_SIGHDLR_PARAM)
112{
113 struct sigcontext *sc;
114 int enabled;
115
116 ARCH_GET_SIGCONTEXT(sc, sig);
117
118 enabled = signals_enabled;
119 if(!enabled){
120 if(sig == SIGVTALRM)
121 pending |= SIGVTALRM_MASK;
122 else pending |= SIGALRM_MASK;
123 return;
124 }
125
126 block_signals();
127
128 do_boot_timer_handler(sc);
129 set_signals(enabled);
130}
131
132void set_sigstack(void *sig_stack, int size) 109void set_sigstack(void *sig_stack, int size)
133{ 110{
134 stack_t stack = ((stack_t) { .ss_flags = 0, 111 stack_t stack = ((stack_t) { .ss_flags = 0,
diff --git a/arch/um/os-Linux/skas/process.c b/arch/um/os-Linux/skas/process.c
index bd89c6b99d5d..bf35572d9cfa 100644
--- a/arch/um/os-Linux/skas/process.c
+++ b/arch/um/os-Linux/skas/process.c
@@ -159,7 +159,7 @@ static int userspace_tramp(void *stack)
159 159
160 ptrace(PTRACE_TRACEME, 0, 0, 0); 160 ptrace(PTRACE_TRACEME, 0, 0, 0);
161 161
162 init_new_thread_signals(1); 162 init_new_thread_signals();
163 enable_timer(); 163 enable_timer();
164 164
165 if(!proc_mm){ 165 if(!proc_mm){
diff --git a/arch/um/os-Linux/time.c b/arch/um/os-Linux/time.c
index 280c4fb9b585..4ae73c0e5485 100644
--- a/arch/um/os-Linux/time.c
+++ b/arch/um/os-Linux/time.c
@@ -17,11 +17,6 @@
17#include "kern_constants.h" 17#include "kern_constants.h"
18#include "os.h" 18#include "os.h"
19 19
20/* XXX This really needs to be declared and initialized in a kernel file since
21 * it's in <linux/time.h>
22 */
23extern struct timespec wall_to_monotonic;
24
25static void set_interval(int timer_type) 20static void set_interval(int timer_type)
26{ 21{
27 int usec = 1000000/hz(); 22 int usec = 1000000/hz();
@@ -71,6 +66,7 @@ void switch_timers(int to_real)
71 errno); 66 errno);
72} 67}
73 68
69#ifdef UML_CONFIG_MODE_TT
74void uml_idle_timer(void) 70void uml_idle_timer(void)
75{ 71{
76 if(signal(SIGVTALRM, SIG_IGN) == SIG_ERR) 72 if(signal(SIGVTALRM, SIG_IGN) == SIG_ERR)
@@ -80,14 +76,7 @@ void uml_idle_timer(void)
80 SA_RESTART, SIGUSR1, SIGIO, SIGWINCH, SIGVTALRM, -1); 76 SA_RESTART, SIGUSR1, SIGIO, SIGWINCH, SIGVTALRM, -1);
81 set_interval(ITIMER_REAL); 77 set_interval(ITIMER_REAL);
82} 78}
83 79#endif
84void time_init(void)
85{
86 if(signal(SIGVTALRM, boot_timer_handler) == SIG_ERR)
87 panic("Couldn't set SIGVTALRM handler");
88 set_interval(ITIMER_VIRTUAL);
89 time_init_kern();
90}
91 80
92unsigned long long os_nsecs(void) 81unsigned long long os_nsecs(void)
93{ 82{
@@ -106,15 +95,7 @@ void idle_sleep(int secs)
106 nanosleep(&ts, NULL); 95 nanosleep(&ts, NULL);
107} 96}
108 97
109/* XXX This partly duplicates init_irq_signals */
110
111void user_time_init(void) 98void user_time_init(void)
112{ 99{
113 set_handler(SIGVTALRM, (__sighandler_t) alarm_handler,
114 SA_ONSTACK | SA_RESTART, SIGUSR1, SIGIO, SIGWINCH,
115 SIGALRM, SIGUSR2, -1);
116 set_handler(SIGALRM, (__sighandler_t) alarm_handler,
117 SA_ONSTACK | SA_RESTART, SIGUSR1, SIGIO, SIGWINCH,
118 SIGVTALRM, SIGUSR2, -1);
119 set_interval(ITIMER_VIRTUAL); 100 set_interval(ITIMER_VIRTUAL);
120} 101}
diff --git a/arch/x86_64/defconfig b/arch/x86_64/defconfig
index e69d403949c8..83d389b8ebd8 100644
--- a/arch/x86_64/defconfig
+++ b/arch/x86_64/defconfig
@@ -1,11 +1,13 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.17-git6 3# Linux kernel version: 2.6.17-git22
4# Sat Jun 24 00:52:28 2006 4# Tue Jul 4 14:24:40 2006
5# 5#
6CONFIG_X86_64=y 6CONFIG_X86_64=y
7CONFIG_64BIT=y 7CONFIG_64BIT=y
8CONFIG_X86=y 8CONFIG_X86=y
9CONFIG_LOCKDEP_SUPPORT=y
10CONFIG_STACKTRACE_SUPPORT=y
9CONFIG_SEMAPHORE_SLEEPERS=y 11CONFIG_SEMAPHORE_SLEEPERS=y
10CONFIG_MMU=y 12CONFIG_MMU=y
11CONFIG_RWSEM_GENERIC_SPINLOCK=y 13CONFIG_RWSEM_GENERIC_SPINLOCK=y
@@ -17,6 +19,7 @@ CONFIG_GENERIC_ISA_DMA=y
17CONFIG_GENERIC_IOMAP=y 19CONFIG_GENERIC_IOMAP=y
18CONFIG_ARCH_MAY_HAVE_PC_FDC=y 20CONFIG_ARCH_MAY_HAVE_PC_FDC=y
19CONFIG_DMI=y 21CONFIG_DMI=y
22CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
20 23
21# 24#
22# Code maturity level options 25# Code maturity level options
@@ -52,10 +55,12 @@ CONFIG_PRINTK=y
52CONFIG_BUG=y 55CONFIG_BUG=y
53CONFIG_ELF_CORE=y 56CONFIG_ELF_CORE=y
54CONFIG_BASE_FULL=y 57CONFIG_BASE_FULL=y
58CONFIG_RT_MUTEXES=y
55CONFIG_FUTEX=y 59CONFIG_FUTEX=y
56CONFIG_EPOLL=y 60CONFIG_EPOLL=y
57CONFIG_SHMEM=y 61CONFIG_SHMEM=y
58CONFIG_SLAB=y 62CONFIG_SLAB=y
63CONFIG_VM_EVENT_COUNTERS=y
59# CONFIG_TINY_SHMEM is not set 64# CONFIG_TINY_SHMEM is not set
60CONFIG_BASE_SMALL=0 65CONFIG_BASE_SMALL=0
61# CONFIG_SLOB is not set 66# CONFIG_SLOB is not set
@@ -136,10 +141,12 @@ CONFIG_NEED_MULTIPLE_NODES=y
136# CONFIG_SPARSEMEM_STATIC is not set 141# CONFIG_SPARSEMEM_STATIC is not set
137CONFIG_SPLIT_PTLOCK_CPUS=4 142CONFIG_SPLIT_PTLOCK_CPUS=4
138CONFIG_MIGRATION=y 143CONFIG_MIGRATION=y
144CONFIG_RESOURCES_64BIT=y
139CONFIG_HAVE_ARCH_EARLY_PFN_TO_NID=y 145CONFIG_HAVE_ARCH_EARLY_PFN_TO_NID=y
140CONFIG_OUT_OF_LINE_PFN_TO_PAGE=y 146CONFIG_OUT_OF_LINE_PFN_TO_PAGE=y
141CONFIG_NR_CPUS=32 147CONFIG_NR_CPUS=32
142CONFIG_HOTPLUG_CPU=y 148CONFIG_HOTPLUG_CPU=y
149CONFIG_ARCH_ENABLE_MEMORY_HOTPLUG=y
143CONFIG_HPET_TIMER=y 150CONFIG_HPET_TIMER=y
144CONFIG_HPET_EMULATE_RTC=y 151CONFIG_HPET_EMULATE_RTC=y
145CONFIG_IOMMU=y 152CONFIG_IOMMU=y
@@ -186,6 +193,7 @@ CONFIG_ACPI_BUTTON=y
186# CONFIG_ACPI_VIDEO is not set 193# CONFIG_ACPI_VIDEO is not set
187# CONFIG_ACPI_HOTKEY is not set 194# CONFIG_ACPI_HOTKEY is not set
188CONFIG_ACPI_FAN=y 195CONFIG_ACPI_FAN=y
196# CONFIG_ACPI_DOCK is not set
189CONFIG_ACPI_PROCESSOR=y 197CONFIG_ACPI_PROCESSOR=y
190CONFIG_ACPI_HOTPLUG_CPU=y 198CONFIG_ACPI_HOTPLUG_CPU=y
191CONFIG_ACPI_THERMAL=y 199CONFIG_ACPI_THERMAL=y
@@ -200,7 +208,7 @@ CONFIG_ACPI_POWER=y
200CONFIG_ACPI_SYSTEM=y 208CONFIG_ACPI_SYSTEM=y
201CONFIG_X86_PM_TIMER=y 209CONFIG_X86_PM_TIMER=y
202CONFIG_ACPI_CONTAINER=y 210CONFIG_ACPI_CONTAINER=y
203CONFIG_ACPI_HOTPLUG_MEMORY=y 211# CONFIG_ACPI_SBS is not set
204 212
205# 213#
206# CPU Frequency scaling 214# CPU Frequency scaling
@@ -801,6 +809,7 @@ CONFIG_SERIO_LIBPS2=y
801CONFIG_VT=y 809CONFIG_VT=y
802CONFIG_VT_CONSOLE=y 810CONFIG_VT_CONSOLE=y
803CONFIG_HW_CONSOLE=y 811CONFIG_HW_CONSOLE=y
812# CONFIG_VT_HW_CONSOLE_BINDING is not set
804# CONFIG_SERIAL_NONSTANDARD is not set 813# CONFIG_SERIAL_NONSTANDARD is not set
805 814
806# 815#
@@ -870,6 +879,9 @@ CONFIG_SOFT_WATCHDOG=y
870# 879#
871# CONFIG_USBPCWATCHDOG is not set 880# CONFIG_USBPCWATCHDOG is not set
872CONFIG_HW_RANDOM=y 881CONFIG_HW_RANDOM=y
882CONFIG_HW_RANDOM_INTEL=y
883CONFIG_HW_RANDOM_AMD=y
884# CONFIG_HW_RANDOM_GEODE is not set
873# CONFIG_NVRAM is not set 885# CONFIG_NVRAM is not set
874CONFIG_RTC=y 886CONFIG_RTC=y
875# CONFIG_DTLK is not set 887# CONFIG_DTLK is not set
@@ -886,6 +898,7 @@ CONFIG_AGP_INTEL=y
886# CONFIG_AGP_VIA is not set 898# CONFIG_AGP_VIA is not set
887# CONFIG_DRM is not set 899# CONFIG_DRM is not set
888# CONFIG_MWAVE is not set 900# CONFIG_MWAVE is not set
901# CONFIG_PC8736x_GPIO is not set
889CONFIG_RAW_DRIVER=y 902CONFIG_RAW_DRIVER=y
890CONFIG_MAX_RAW_DEVS=256 903CONFIG_MAX_RAW_DEVS=256
891CONFIG_HPET=y 904CONFIG_HPET=y
@@ -1030,8 +1043,8 @@ CONFIG_VIDEO_V4L2=y
1030# 1043#
1031# Graphics support 1044# Graphics support
1032# 1045#
1046# CONFIG_FIRMWARE_EDID is not set
1033# CONFIG_FB is not set 1047# CONFIG_FB is not set
1034CONFIG_VIDEO_SELECT=y
1035 1048
1036# 1049#
1037# Console display driver support 1050# Console display driver support
@@ -1039,6 +1052,7 @@ CONFIG_VIDEO_SELECT=y
1039CONFIG_VGA_CONSOLE=y 1052CONFIG_VGA_CONSOLE=y
1040CONFIG_VGACON_SOFT_SCROLLBACK=y 1053CONFIG_VGACON_SOFT_SCROLLBACK=y
1041CONFIG_VGACON_SOFT_SCROLLBACK_SIZE=256 1054CONFIG_VGACON_SOFT_SCROLLBACK_SIZE=256
1055CONFIG_VIDEO_SELECT=y
1042CONFIG_DUMMY_CONSOLE=y 1056CONFIG_DUMMY_CONSOLE=y
1043 1057
1044# 1058#
@@ -1359,6 +1373,7 @@ CONFIG_SUNRPC=y
1359# CONFIG_RPCSEC_GSS_SPKM3 is not set 1373# CONFIG_RPCSEC_GSS_SPKM3 is not set
1360# CONFIG_SMB_FS is not set 1374# CONFIG_SMB_FS is not set
1361# CONFIG_CIFS is not set 1375# CONFIG_CIFS is not set
1376# CONFIG_CIFS_DEBUG2 is not set
1362# CONFIG_NCP_FS is not set 1377# CONFIG_NCP_FS is not set
1363# CONFIG_CODA_FS is not set 1378# CONFIG_CODA_FS is not set
1364# CONFIG_AFS_FS is not set 1379# CONFIG_AFS_FS is not set
@@ -1424,16 +1439,24 @@ CONFIG_KPROBES=y
1424# 1439#
1425# Kernel hacking 1440# Kernel hacking
1426# 1441#
1442CONFIG_TRACE_IRQFLAGS_SUPPORT=y
1427# CONFIG_PRINTK_TIME is not set 1443# CONFIG_PRINTK_TIME is not set
1428CONFIG_MAGIC_SYSRQ=y 1444CONFIG_MAGIC_SYSRQ=y
1445CONFIG_UNUSED_SYMBOLS=y
1429CONFIG_DEBUG_KERNEL=y 1446CONFIG_DEBUG_KERNEL=y
1430CONFIG_LOG_BUF_SHIFT=18 1447CONFIG_LOG_BUF_SHIFT=18
1431CONFIG_DETECT_SOFTLOCKUP=y 1448CONFIG_DETECT_SOFTLOCKUP=y
1432# CONFIG_SCHEDSTATS is not set 1449# CONFIG_SCHEDSTATS is not set
1433# CONFIG_DEBUG_SLAB is not set 1450# CONFIG_DEBUG_SLAB is not set
1434# CONFIG_DEBUG_MUTEXES is not set 1451# CONFIG_DEBUG_RT_MUTEXES is not set
1452# CONFIG_RT_MUTEX_TESTER is not set
1435# CONFIG_DEBUG_SPINLOCK is not set 1453# CONFIG_DEBUG_SPINLOCK is not set
1454# CONFIG_DEBUG_MUTEXES is not set
1455# CONFIG_DEBUG_RWSEMS is not set
1456# CONFIG_DEBUG_LOCK_ALLOC is not set
1457# CONFIG_PROVE_LOCKING is not set
1436# CONFIG_DEBUG_SPINLOCK_SLEEP is not set 1458# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
1459# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
1437# CONFIG_DEBUG_KOBJECT is not set 1460# CONFIG_DEBUG_KOBJECT is not set
1438# CONFIG_DEBUG_INFO is not set 1461# CONFIG_DEBUG_INFO is not set
1439CONFIG_DEBUG_FS=y 1462CONFIG_DEBUG_FS=y
@@ -1445,6 +1468,8 @@ CONFIG_STACK_UNWIND=y
1445# CONFIG_RCU_TORTURE_TEST is not set 1468# CONFIG_RCU_TORTURE_TEST is not set
1446# CONFIG_DEBUG_RODATA is not set 1469# CONFIG_DEBUG_RODATA is not set
1447# CONFIG_IOMMU_DEBUG is not set 1470# CONFIG_IOMMU_DEBUG is not set
1471CONFIG_DEBUG_STACKOVERFLOW=y
1472# CONFIG_DEBUG_STACK_USAGE is not set
1448 1473
1449# 1474#
1450# Security options 1475# Security options
@@ -1468,3 +1493,4 @@ CONFIG_STACK_UNWIND=y
1468# CONFIG_CRC16 is not set 1493# CONFIG_CRC16 is not set
1469CONFIG_CRC32=y 1494CONFIG_CRC32=y
1470# CONFIG_LIBCRC32C is not set 1495# CONFIG_LIBCRC32C is not set
1496CONFIG_PLIST=y
diff --git a/arch/x86_64/ia32/ia32_binfmt.c b/arch/x86_64/ia32/ia32_binfmt.c
index 926c4743d13b..a9dc0f3b5b51 100644
--- a/arch/x86_64/ia32/ia32_binfmt.c
+++ b/arch/x86_64/ia32/ia32_binfmt.c
@@ -182,7 +182,7 @@ struct elf_prpsinfo
182#define user user32 182#define user user32
183 183
184#define __ASM_X86_64_ELF_H 1 184#define __ASM_X86_64_ELF_H 1
185#define elf_read_implies_exec(ex, have_pt_gnu_stack) (!(have_pt_gnu_stack)) 185#define elf_read_implies_exec(ex, executable_stack) (executable_stack != EXSTACK_DISABLE_X)
186//#include <asm/ia32.h> 186//#include <asm/ia32.h>
187#include <linux/elf.h> 187#include <linux/elf.h>
188 188
diff --git a/arch/x86_64/ia32/ptrace32.c b/arch/x86_64/ia32/ptrace32.c
index a590b7a0d92d..659c0722f6b8 100644
--- a/arch/x86_64/ia32/ptrace32.c
+++ b/arch/x86_64/ia32/ptrace32.c
@@ -202,17 +202,24 @@ static long ptrace32_siginfo(unsigned request, u32 pid, u32 addr, u32 data)
202{ 202{
203 int ret; 203 int ret;
204 compat_siginfo_t *si32 = (compat_siginfo_t *)compat_ptr(data); 204 compat_siginfo_t *si32 = (compat_siginfo_t *)compat_ptr(data);
205 siginfo_t ssi;
205 siginfo_t *si = compat_alloc_user_space(sizeof(siginfo_t)); 206 siginfo_t *si = compat_alloc_user_space(sizeof(siginfo_t));
206 if (request == PTRACE_SETSIGINFO) { 207 if (request == PTRACE_SETSIGINFO) {
207 ret = copy_siginfo_from_user32(si, si32); 208 memset(&ssi, 0, sizeof(siginfo_t));
209 ret = copy_siginfo_from_user32(&ssi, si32);
208 if (ret) 210 if (ret)
209 return ret; 211 return ret;
212 if (copy_to_user(si, &ssi, sizeof(siginfo_t)))
213 return -EFAULT;
210 } 214 }
211 ret = sys_ptrace(request, pid, addr, (unsigned long)si); 215 ret = sys_ptrace(request, pid, addr, (unsigned long)si);
212 if (ret) 216 if (ret)
213 return ret; 217 return ret;
214 if (request == PTRACE_GETSIGINFO) 218 if (request == PTRACE_GETSIGINFO) {
215 ret = copy_siginfo_to_user32(si32, si); 219 if (copy_from_user(&ssi, si, sizeof(siginfo_t)))
220 return -EFAULT;
221 ret = copy_siginfo_to_user32(si32, &ssi);
222 }
216 return ret; 223 return ret;
217} 224}
218 225
diff --git a/arch/x86_64/kernel/e820.c b/arch/x86_64/kernel/e820.c
index b8eee4c7888b..e56c2adf57a4 100644
--- a/arch/x86_64/kernel/e820.c
+++ b/arch/x86_64/kernel/e820.c
@@ -17,6 +17,7 @@
17#include <linux/kexec.h> 17#include <linux/kexec.h>
18#include <linux/module.h> 18#include <linux/module.h>
19 19
20#include <asm/pgtable.h>
20#include <asm/page.h> 21#include <asm/page.h>
21#include <asm/e820.h> 22#include <asm/e820.h>
22#include <asm/proto.h> 23#include <asm/proto.h>
diff --git a/arch/x86_64/kernel/early_printk.c b/arch/x86_64/kernel/early_printk.c
index b93ef5b51980..140051e07fa6 100644
--- a/arch/x86_64/kernel/early_printk.c
+++ b/arch/x86_64/kernel/early_printk.c
@@ -2,7 +2,7 @@
2#include <linux/kernel.h> 2#include <linux/kernel.h>
3#include <linux/init.h> 3#include <linux/init.h>
4#include <linux/string.h> 4#include <linux/string.h>
5#include <linux/tty.h> 5#include <linux/screen_info.h>
6#include <asm/io.h> 6#include <asm/io.h>
7#include <asm/processor.h> 7#include <asm/processor.h>
8#include <asm/fcntl.h> 8#include <asm/fcntl.h>
diff --git a/arch/x86_64/kernel/mce_amd.c b/arch/x86_64/kernel/mce_amd.c
index 335200aa2737..db2acbf7ad28 100644
--- a/arch/x86_64/kernel/mce_amd.c
+++ b/arch/x86_64/kernel/mce_amd.c
@@ -597,7 +597,7 @@ static __cpuinit void threshold_remove_bank(unsigned int cpu, int bank)
597 /* sibling symlink */ 597 /* sibling symlink */
598 if (shared_bank[bank] && b->blocks->cpu != cpu) { 598 if (shared_bank[bank] && b->blocks->cpu != cpu) {
599 sysfs_remove_link(&per_cpu(device_mce, cpu).kobj, name); 599 sysfs_remove_link(&per_cpu(device_mce, cpu).kobj, name);
600 per_cpu(threshold_banks, i)[bank] = NULL; 600 per_cpu(threshold_banks, cpu)[bank] = NULL;
601 return; 601 return;
602 } 602 }
603 603
diff --git a/arch/x86_64/kernel/pci-calgary.c b/arch/x86_64/kernel/pci-calgary.c
index d91cb843f54d..e71ed53b08fb 100644
--- a/arch/x86_64/kernel/pci-calgary.c
+++ b/arch/x86_64/kernel/pci-calgary.c
@@ -1,9 +1,11 @@
1/* 1/*
2 * Derived from arch/powerpc/kernel/iommu.c 2 * Derived from arch/powerpc/kernel/iommu.c
3 * 3 *
4 * Copyright (C) 2006 Jon Mason <jdmason@us.ibm.com>, IBM Corporation 4 * Copyright (C) IBM Corporation, 2006
5 * Copyright (C) 2006 Muli Ben-Yehuda <muli@il.ibm.com>, IBM Corporation
6 * 5 *
6 * Author: Jon Mason <jdmason@us.ibm.com>
7 * Author: Muli Ben-Yehuda <muli@il.ibm.com>
8
7 * This program is free software; you can redistribute it and/or modify 9 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by 10 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or 11 * the Free Software Foundation; either version 2 of the License, or
diff --git a/arch/x86_64/kernel/setup.c b/arch/x86_64/kernel/setup.c
index 0925518b58d0..8a099ff1f8bc 100644
--- a/arch/x86_64/kernel/setup.c
+++ b/arch/x86_64/kernel/setup.c
@@ -21,7 +21,7 @@
21#include <linux/slab.h> 21#include <linux/slab.h>
22#include <linux/user.h> 22#include <linux/user.h>
23#include <linux/a.out.h> 23#include <linux/a.out.h>
24#include <linux/tty.h> 24#include <linux/screen_info.h>
25#include <linux/ioport.h> 25#include <linux/ioport.h>
26#include <linux/delay.h> 26#include <linux/delay.h>
27#include <linux/init.h> 27#include <linux/init.h>
diff --git a/arch/x86_64/kernel/smpboot.c b/arch/x86_64/kernel/smpboot.c
index b7c705969791..975380207b46 100644
--- a/arch/x86_64/kernel/smpboot.c
+++ b/arch/x86_64/kernel/smpboot.c
@@ -771,12 +771,10 @@ static int __cpuinit do_boot_cpu(int cpu, int apicid)
771 unsigned long start_rip; 771 unsigned long start_rip;
772 struct create_idle c_idle = { 772 struct create_idle c_idle = {
773 .cpu = cpu, 773 .cpu = cpu,
774 .done = COMPLETION_INITIALIZER(c_idle.done), 774 .done = COMPLETION_INITIALIZER_ONSTACK(c_idle.done),
775 }; 775 };
776 DECLARE_WORK(work, do_fork_idle, &c_idle); 776 DECLARE_WORK(work, do_fork_idle, &c_idle);
777 777
778 lockdep_set_class(&c_idle.done.wait.lock, &waitqueue_lock_key);
779
780 /* allocate memory for gdts of secondary cpus. Hotplug is considered */ 778 /* allocate memory for gdts of secondary cpus. Hotplug is considered */
781 if (!cpu_gdt_descr[cpu].address && 779 if (!cpu_gdt_descr[cpu].address &&
782 !(cpu_gdt_descr[cpu].address = get_zeroed_page(GFP_KERNEL))) { 780 !(cpu_gdt_descr[cpu].address = get_zeroed_page(GFP_KERNEL))) {
diff --git a/arch/x86_64/kernel/tce.c b/arch/x86_64/kernel/tce.c
index 8d4c67f61b8e..d3a9e79e954c 100644
--- a/arch/x86_64/kernel/tce.c
+++ b/arch/x86_64/kernel/tce.c
@@ -1,8 +1,10 @@
1/* 1/*
2 * Derived from arch/powerpc/platforms/pseries/iommu.c 2 * Derived from arch/powerpc/platforms/pseries/iommu.c
3 * 3 *
4 * Copyright (C) 2006 Jon Mason <jdmason@us.ibm.com>, IBM Corporation 4 * Copyright (C) IBM Corporation, 2006
5 * Copyright (C) 2006 Muli Ben-Yehuda <muli@il.ibm.com>, IBM Corporation 5 *
6 * Author: Jon Mason <jdmason@us.ibm.com>
7 * Author: Muli Ben-Yehuda <muli@il.ibm.com>
6 * 8 *
7 * This program is free software; you can redistribute it and/or modify 9 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by 10 * it under the terms of the GNU General Public License as published by
diff --git a/arch/x86_64/kernel/traps.c b/arch/x86_64/kernel/traps.c
index 79d05c482072..eb39a2775236 100644
--- a/arch/x86_64/kernel/traps.c
+++ b/arch/x86_64/kernel/traps.c
@@ -76,13 +76,13 @@ int register_die_notifier(struct notifier_block *nb)
76 vmalloc_sync_all(); 76 vmalloc_sync_all();
77 return atomic_notifier_chain_register(&die_chain, nb); 77 return atomic_notifier_chain_register(&die_chain, nb);
78} 78}
79EXPORT_SYMBOL(register_die_notifier); 79EXPORT_SYMBOL(register_die_notifier); /* used modular by kdb */
80 80
81int unregister_die_notifier(struct notifier_block *nb) 81int unregister_die_notifier(struct notifier_block *nb)
82{ 82{
83 return atomic_notifier_chain_unregister(&die_chain, nb); 83 return atomic_notifier_chain_unregister(&die_chain, nb);
84} 84}
85EXPORT_SYMBOL(unregister_die_notifier); 85EXPORT_SYMBOL(unregister_die_notifier); /* used modular by kdb */
86 86
87static inline void conditional_sti(struct pt_regs *regs) 87static inline void conditional_sti(struct pt_regs *regs)
88{ 88{
diff --git a/arch/xtensa/kernel/setup.c b/arch/xtensa/kernel/setup.c
index edb29410d953..82684d05910a 100644
--- a/arch/xtensa/kernel/setup.c
+++ b/arch/xtensa/kernel/setup.c
@@ -17,7 +17,7 @@
17#include <linux/errno.h> 17#include <linux/errno.h>
18#include <linux/init.h> 18#include <linux/init.h>
19#include <linux/proc_fs.h> 19#include <linux/proc_fs.h>
20#include <linux/tty.h> 20#include <linux/screen_info.h>
21#include <linux/bootmem.h> 21#include <linux/bootmem.h>
22#include <linux/kernel.h> 22#include <linux/kernel.h>
23 23
diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
index 480a31796886..5753d06b7860 100644
--- a/drivers/acpi/thermal.c
+++ b/drivers/acpi/thermal.c
@@ -1359,13 +1359,28 @@ static int acpi_thermal_remove(struct acpi_device *device, int type)
1359static int acpi_thermal_resume(struct acpi_device *device, int state) 1359static int acpi_thermal_resume(struct acpi_device *device, int state)
1360{ 1360{
1361 struct acpi_thermal *tz = NULL; 1361 struct acpi_thermal *tz = NULL;
1362 int i;
1362 1363
1363 if (!device || !acpi_driver_data(device)) 1364 if (!device || !acpi_driver_data(device))
1364 return -EINVAL; 1365 return -EINVAL;
1365 1366
1366 tz = (struct acpi_thermal *)acpi_driver_data(device); 1367 tz = (struct acpi_thermal *)acpi_driver_data(device);
1367 1368
1368 acpi_thermal_check(tz); 1369 acpi_thermal_get_temperature(tz);
1370
1371 for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) {
1372 if (tz->trips.active[i].flags.valid) {
1373 tz->temperature = tz->trips.active[i].temperature;
1374 tz->trips.active[i].flags.enabled = 0;
1375
1376 acpi_thermal_active(tz);
1377
1378 tz->state.active |= tz->trips.active[i].flags.enabled;
1379 tz->state.active_index = i;
1380 }
1381 }
1382
1383 acpi_thermal_check(tz);
1369 1384
1370 return AE_OK; 1385 return AE_OK;
1371} 1386}
diff --git a/drivers/base/Kconfig b/drivers/base/Kconfig
index 80502dc6ed66..0b4e22436935 100644
--- a/drivers/base/Kconfig
+++ b/drivers/base/Kconfig
@@ -20,7 +20,7 @@ config PREVENT_FIRMWARE_BUILD
20 20
21config FW_LOADER 21config FW_LOADER
22 tristate "Userspace firmware loading support" 22 tristate "Userspace firmware loading support"
23 select HOTPLUG 23 depends on HOTPLUG
24 ---help--- 24 ---help---
25 This option is provided for the case where no in-kernel-tree modules 25 This option is provided for the case where no in-kernel-tree modules
26 require userspace firmware loading support, but a module built outside 26 require userspace firmware loading support, but a module built outside
diff --git a/drivers/block/aoe/aoechr.c b/drivers/block/aoe/aoechr.c
index 5327f553b4f5..1bc1cf9603f1 100644
--- a/drivers/block/aoe/aoechr.c
+++ b/drivers/block/aoe/aoechr.c
@@ -162,7 +162,7 @@ aoechr_open(struct inode *inode, struct file *filp)
162{ 162{
163 int n, i; 163 int n, i;
164 164
165 n = MINOR(inode->i_rdev); 165 n = iminor(inode);
166 filp->private_data = (void *) (unsigned long) n; 166 filp->private_data = (void *) (unsigned long) n;
167 167
168 for (i = 0; i < ARRAY_SIZE(chardevs); ++i) 168 for (i = 0; i < ARRAY_SIZE(chardevs); ++i)
diff --git a/drivers/bluetooth/bcm203x.c b/drivers/bluetooth/bcm203x.c
index 6f67141f4de0..13ba729cdd57 100644
--- a/drivers/bluetooth/bcm203x.c
+++ b/drivers/bluetooth/bcm203x.c
@@ -234,6 +234,7 @@ static int bcm203x_probe(struct usb_interface *intf, const struct usb_device_id
234 data->fw_data = kmalloc(firmware->size, GFP_KERNEL); 234 data->fw_data = kmalloc(firmware->size, GFP_KERNEL);
235 if (!data->fw_data) { 235 if (!data->fw_data) {
236 BT_ERR("Can't allocate memory for firmware image"); 236 BT_ERR("Can't allocate memory for firmware image");
237 release_firmware(firmware);
237 usb_free_urb(data->urb); 238 usb_free_urb(data->urb);
238 kfree(data->buffer); 239 kfree(data->buffer);
239 kfree(data); 240 kfree(data);
diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
index ca27ee89240b..d239cf8b20bd 100644
--- a/drivers/cdrom/cdrom.c
+++ b/drivers/cdrom/cdrom.c
@@ -1837,7 +1837,7 @@ static int dvd_read_bca(struct cdrom_device_info *cdi, dvd_struct *s)
1837 init_cdrom_command(&cgc, buf, sizeof(buf), CGC_DATA_READ); 1837 init_cdrom_command(&cgc, buf, sizeof(buf), CGC_DATA_READ);
1838 cgc.cmd[0] = GPCMD_READ_DVD_STRUCTURE; 1838 cgc.cmd[0] = GPCMD_READ_DVD_STRUCTURE;
1839 cgc.cmd[7] = s->type; 1839 cgc.cmd[7] = s->type;
1840 cgc.cmd[9] = cgc.buflen = 0xff; 1840 cgc.cmd[9] = cgc.buflen & 0xff;
1841 1841
1842 if ((ret = cdo->generic_packet(cdi, &cgc))) 1842 if ((ret = cdo->generic_packet(cdi, &cgc)))
1843 return ret; 1843 return ret;
diff --git a/drivers/char/hvsi.c b/drivers/char/hvsi.c
index 56612a2dca6b..41db8060e8f7 100644
--- a/drivers/char/hvsi.c
+++ b/drivers/char/hvsi.c
@@ -1299,7 +1299,7 @@ static int __init hvsi_console_init(void)
1299 hp->inbuf_end = hp->inbuf; 1299 hp->inbuf_end = hp->inbuf;
1300 hp->state = HVSI_CLOSED; 1300 hp->state = HVSI_CLOSED;
1301 hp->vtermno = *vtermno; 1301 hp->vtermno = *vtermno;
1302 hp->virq = irq_create_mapping(NULL, irq[0], 0); 1302 hp->virq = irq_create_mapping(NULL, irq[0]);
1303 if (hp->virq == NO_IRQ) { 1303 if (hp->virq == NO_IRQ) {
1304 printk(KERN_ERR "%s: couldn't create irq mapping for 0x%x\n", 1304 printk(KERN_ERR "%s: couldn't create irq mapping for 0x%x\n",
1305 __FUNCTION__, irq[0]); 1305 __FUNCTION__, irq[0]);
diff --git a/drivers/char/ip2/ip2main.c b/drivers/char/ip2/ip2main.c
index 518ece7ac656..7907ae88c2f4 100644
--- a/drivers/char/ip2/ip2main.c
+++ b/drivers/char/ip2/ip2main.c
@@ -3186,3 +3186,10 @@ ip2trace (unsigned short pn, unsigned char cat, unsigned char label, unsigned lo
3186 3186
3187 3187
3188MODULE_LICENSE("GPL"); 3188MODULE_LICENSE("GPL");
3189
3190static struct pci_device_id ip2main_pci_tbl[] __devinitdata = {
3191 { PCI_DEVICE(PCI_VENDOR_ID_COMPUTONE, PCI_DEVICE_ID_COMPUTONE_IP2EX) },
3192 { }
3193};
3194
3195MODULE_DEVICE_TABLE(pci, ip2main_pci_tbl);
diff --git a/drivers/char/mem.c b/drivers/char/mem.c
index e97c32ceb796..917b20402664 100644
--- a/drivers/char/mem.c
+++ b/drivers/char/mem.c
@@ -95,7 +95,7 @@ static inline int valid_phys_addr_range(unsigned long addr, size_t count)
95 return 1; 95 return 1;
96} 96}
97 97
98static inline int valid_mmap_phys_addr_range(unsigned long addr, size_t size) 98static inline int valid_mmap_phys_addr_range(unsigned long pfn, size_t size)
99{ 99{
100 return 1; 100 return 1;
101} 101}
@@ -242,7 +242,7 @@ static int mmap_mem(struct file * file, struct vm_area_struct * vma)
242{ 242{
243 size_t size = vma->vm_end - vma->vm_start; 243 size_t size = vma->vm_end - vma->vm_start;
244 244
245 if (!valid_mmap_phys_addr_range(vma->vm_pgoff << PAGE_SHIFT, size)) 245 if (!valid_mmap_phys_addr_range(vma->vm_pgoff, size))
246 return -EINVAL; 246 return -EINVAL;
247 247
248 vma->vm_page_prot = phys_mem_access_prot(file, vma->vm_pgoff, 248 vma->vm_page_prot = phys_mem_access_prot(file, vma->vm_pgoff,
diff --git a/drivers/char/pc8736x_gpio.c b/drivers/char/pc8736x_gpio.c
index 4005ee0aa11e..11bd78c80628 100644
--- a/drivers/char/pc8736x_gpio.c
+++ b/drivers/char/pc8736x_gpio.c
@@ -3,18 +3,18 @@
3 National Semiconductor PC8736x GPIO driver. Allows a user space 3 National Semiconductor PC8736x GPIO driver. Allows a user space
4 process to play with the GPIO pins. 4 process to play with the GPIO pins.
5 5
6 Copyright (c) 2005 Jim Cromie <jim.cromie@gmail.com> 6 Copyright (c) 2005,2006 Jim Cromie <jim.cromie@gmail.com>
7 7
8 adapted from linux/drivers/char/scx200_gpio.c 8 adapted from linux/drivers/char/scx200_gpio.c
9 Copyright (c) 2001,2002 Christer Weinigel <wingel@nano-system.com>, 9 Copyright (c) 2001,2002 Christer Weinigel <wingel@nano-system.com>,
10*/ 10*/
11 11
12#include <linux/config.h>
13#include <linux/fs.h> 12#include <linux/fs.h>
14#include <linux/module.h> 13#include <linux/module.h>
15#include <linux/errno.h> 14#include <linux/errno.h>
16#include <linux/kernel.h> 15#include <linux/kernel.h>
17#include <linux/init.h> 16#include <linux/init.h>
17#include <linux/cdev.h>
18#include <linux/io.h> 18#include <linux/io.h>
19#include <linux/ioport.h> 19#include <linux/ioport.h>
20#include <linux/mutex.h> 20#include <linux/mutex.h>
@@ -25,7 +25,7 @@
25#define DEVNAME "pc8736x_gpio" 25#define DEVNAME "pc8736x_gpio"
26 26
27MODULE_AUTHOR("Jim Cromie <jim.cromie@gmail.com>"); 27MODULE_AUTHOR("Jim Cromie <jim.cromie@gmail.com>");
28MODULE_DESCRIPTION("NatSemi PC-8736x GPIO Pin Driver"); 28MODULE_DESCRIPTION("NatSemi/Winbond PC-8736x GPIO Pin Driver");
29MODULE_LICENSE("GPL"); 29MODULE_LICENSE("GPL");
30 30
31static int major; /* default to dynamic major */ 31static int major; /* default to dynamic major */
@@ -38,14 +38,14 @@ static u8 pc8736x_gpio_shadow[4];
38 38
39#define SIO_BASE1 0x2E /* 1st command-reg to check */ 39#define SIO_BASE1 0x2E /* 1st command-reg to check */
40#define SIO_BASE2 0x4E /* alt command-reg to check */ 40#define SIO_BASE2 0x4E /* alt command-reg to check */
41#define SIO_BASE_OFFSET 0x20
42 41
43#define SIO_SID 0x20 /* SuperI/O ID Register */ 42#define SIO_SID 0x20 /* SuperI/O ID Register */
44#define SIO_SID_VALUE 0xe9 /* Expected value in SuperI/O ID Register */ 43#define SIO_SID_VALUE 0xe9 /* Expected value in SuperI/O ID Register */
45 44
46#define SIO_CF1 0x21 /* chip config, bit0 is chip enable */ 45#define SIO_CF1 0x21 /* chip config, bit0 is chip enable */
47 46
48#define PC8736X_GPIO_SIZE 16 47#define PC8736X_GPIO_RANGE 16 /* ioaddr range */
48#define PC8736X_GPIO_CT 32 /* minors matching 4 8 bit ports */
49 49
50#define SIO_UNIT_SEL 0x7 /* unit select reg */ 50#define SIO_UNIT_SEL 0x7 /* unit select reg */
51#define SIO_UNIT_ACT 0x30 /* unit enable */ 51#define SIO_UNIT_ACT 0x30 /* unit enable */
@@ -231,7 +231,7 @@ static int pc8736x_gpio_open(struct inode *inode, struct file *file)
231 231
232 dev_dbg(&pdev->dev, "open %d\n", m); 232 dev_dbg(&pdev->dev, "open %d\n", m);
233 233
234 if (m > 63) 234 if (m >= PC8736X_GPIO_CT)
235 return -EINVAL; 235 return -EINVAL;
236 return nonseekable_open(inode, file); 236 return nonseekable_open(inode, file);
237} 237}
@@ -255,9 +255,12 @@ static void __init pc8736x_init_shadow(void)
255 255
256} 256}
257 257
258static struct cdev pc8736x_gpio_cdev;
259
258static int __init pc8736x_gpio_init(void) 260static int __init pc8736x_gpio_init(void)
259{ 261{
260 int rc = 0; 262 int rc;
263 dev_t devid;
261 264
262 pdev = platform_device_alloc(DEVNAME, 0); 265 pdev = platform_device_alloc(DEVNAME, 0);
263 if (!pdev) 266 if (!pdev)
@@ -297,7 +300,7 @@ static int __init pc8736x_gpio_init(void)
297 pc8736x_gpio_base = (superio_inb(SIO_BASE_HADDR) << 8 300 pc8736x_gpio_base = (superio_inb(SIO_BASE_HADDR) << 8
298 | superio_inb(SIO_BASE_LADDR)); 301 | superio_inb(SIO_BASE_LADDR));
299 302
300 if (!request_region(pc8736x_gpio_base, 16, DEVNAME)) { 303 if (!request_region(pc8736x_gpio_base, PC8736X_GPIO_RANGE, DEVNAME)) {
301 rc = -ENODEV; 304 rc = -ENODEV;
302 dev_err(&pdev->dev, "GPIO ioport %x busy\n", 305 dev_err(&pdev->dev, "GPIO ioport %x busy\n",
303 pc8736x_gpio_base); 306 pc8736x_gpio_base);
@@ -305,10 +308,17 @@ static int __init pc8736x_gpio_init(void)
305 } 308 }
306 dev_info(&pdev->dev, "GPIO ioport %x reserved\n", pc8736x_gpio_base); 309 dev_info(&pdev->dev, "GPIO ioport %x reserved\n", pc8736x_gpio_base);
307 310
308 rc = register_chrdev(major, DEVNAME, &pc8736x_gpio_fops); 311 if (major) {
312 devid = MKDEV(major, 0);
313 rc = register_chrdev_region(devid, PC8736X_GPIO_CT, DEVNAME);
314 } else {
315 rc = alloc_chrdev_region(&devid, 0, PC8736X_GPIO_CT, DEVNAME);
316 major = MAJOR(devid);
317 }
318
309 if (rc < 0) { 319 if (rc < 0) {
310 dev_err(&pdev->dev, "register-chrdev failed: %d\n", rc); 320 dev_err(&pdev->dev, "register-chrdev failed: %d\n", rc);
311 goto undo_platform_dev_add; 321 goto undo_request_region;
312 } 322 }
313 if (!major) { 323 if (!major) {
314 major = rc; 324 major = rc;
@@ -316,8 +326,15 @@ static int __init pc8736x_gpio_init(void)
316 } 326 }
317 327
318 pc8736x_init_shadow(); 328 pc8736x_init_shadow();
329
330 /* ignore minor errs, and succeed */
331 cdev_init(&pc8736x_gpio_cdev, &pc8736x_gpio_fops);
332 cdev_add(&pc8736x_gpio_cdev, devid, PC8736X_GPIO_CT);
333
319 return 0; 334 return 0;
320 335
336undo_request_region:
337 release_region(pc8736x_gpio_base, PC8736X_GPIO_RANGE);
321undo_platform_dev_add: 338undo_platform_dev_add:
322 platform_device_del(pdev); 339 platform_device_del(pdev);
323undo_platform_dev_alloc: 340undo_platform_dev_alloc:
@@ -328,11 +345,14 @@ undo_platform_dev_alloc:
328 345
329static void __exit pc8736x_gpio_cleanup(void) 346static void __exit pc8736x_gpio_cleanup(void)
330{ 347{
331 dev_dbg(&pdev->dev, " cleanup\n"); 348 dev_dbg(&pdev->dev, "cleanup\n");
332 349
333 release_region(pc8736x_gpio_base, 16); 350 cdev_del(&pc8736x_gpio_cdev);
351 unregister_chrdev_region(MKDEV(major,0), PC8736X_GPIO_CT);
352 release_region(pc8736x_gpio_base, PC8736X_GPIO_RANGE);
334 353
335 unregister_chrdev(major, DEVNAME); 354 platform_device_del(pdev);
355 platform_device_put(pdev);
336} 356}
337 357
338EXPORT_SYMBOL(pc8736x_access); 358EXPORT_SYMBOL(pc8736x_access);
diff --git a/drivers/char/rtc.c b/drivers/char/rtc.c
index cc7bd1a3095b..6ccc364c08df 100644
--- a/drivers/char/rtc.c
+++ b/drivers/char/rtc.c
@@ -46,13 +46,12 @@
46 * 1.11a Daniele Bellucci: Audit create_proc_read_entry in rtc_init 46 * 1.11a Daniele Bellucci: Audit create_proc_read_entry in rtc_init
47 * 1.12 Venkatesh Pallipadi: Hooks for emulating rtc on HPET base-timer 47 * 1.12 Venkatesh Pallipadi: Hooks for emulating rtc on HPET base-timer
48 * CONFIG_HPET_EMULATE_RTC 48 * CONFIG_HPET_EMULATE_RTC
49 * 1.12a Maciej W. Rozycki: Handle memory-mapped chips properly.
49 * 1.12ac Alan Cox: Allow read access to the day of week register 50 * 1.12ac Alan Cox: Allow read access to the day of week register
50 */ 51 */
51 52
52#define RTC_VERSION "1.12ac" 53#define RTC_VERSION "1.12ac"
53 54
54#define RTC_IO_EXTENT 0x8
55
56/* 55/*
57 * Note that *all* calls to CMOS_READ and CMOS_WRITE are done with 56 * Note that *all* calls to CMOS_READ and CMOS_WRITE are done with
58 * interrupts disabled. Due to the index-port/data-port (0x70/0x71) 57 * interrupts disabled. Due to the index-port/data-port (0x70/0x71)
@@ -337,7 +336,15 @@ static ssize_t rtc_read(struct file *file, char __user *buf,
337 if (rtc_has_irq == 0) 336 if (rtc_has_irq == 0)
338 return -EIO; 337 return -EIO;
339 338
340 if (count < sizeof(unsigned)) 339 /*
340 * Historically this function used to assume that sizeof(unsigned long)
341 * is the same in userspace and kernelspace. This lead to problems
342 * for configurations with multiple ABIs such a the MIPS o32 and 64
343 * ABIs supported on the same kernel. So now we support read of both
344 * 4 and 8 bytes and assume that's the sizeof(unsigned long) in the
345 * userspace ABI.
346 */
347 if (count != sizeof(unsigned int) && count != sizeof(unsigned long))
341 return -EINVAL; 348 return -EINVAL;
342 349
343 add_wait_queue(&rtc_wait, &wait); 350 add_wait_queue(&rtc_wait, &wait);
@@ -368,10 +375,12 @@ static ssize_t rtc_read(struct file *file, char __user *buf,
368 schedule(); 375 schedule();
369 } while (1); 376 } while (1);
370 377
371 if (count < sizeof(unsigned long)) 378 if (count == sizeof(unsigned int))
372 retval = put_user(data, (unsigned int __user *)buf) ?: sizeof(int); 379 retval = put_user(data, (unsigned int __user *)buf) ?: sizeof(int);
373 else 380 else
374 retval = put_user(data, (unsigned long __user *)buf) ?: sizeof(long); 381 retval = put_user(data, (unsigned long __user *)buf) ?: sizeof(long);
382 if (!retval)
383 retval = count;
375 out: 384 out:
376 current->state = TASK_RUNNING; 385 current->state = TASK_RUNNING;
377 remove_wait_queue(&rtc_wait, &wait); 386 remove_wait_queue(&rtc_wait, &wait);
@@ -923,6 +932,9 @@ static int __init rtc_init(void)
923 struct sparc_isa_device *isa_dev; 932 struct sparc_isa_device *isa_dev;
924#endif 933#endif
925#endif 934#endif
935#ifndef __sparc__
936 void *r;
937#endif
926 938
927#ifdef __sparc__ 939#ifdef __sparc__
928 for_each_ebus(ebus) { 940 for_each_ebus(ebus) {
@@ -964,8 +976,13 @@ found:
964 } 976 }
965no_irq: 977no_irq:
966#else 978#else
967 if (!request_region(RTC_PORT(0), RTC_IO_EXTENT, "rtc")) { 979 if (RTC_IOMAPPED)
968 printk(KERN_ERR "rtc: I/O port %d is not free.\n", RTC_PORT (0)); 980 r = request_region(RTC_PORT(0), RTC_IO_EXTENT, "rtc");
981 else
982 r = request_mem_region(RTC_PORT(0), RTC_IO_EXTENT, "rtc");
983 if (!r) {
984 printk(KERN_ERR "rtc: I/O resource %lx is not free.\n",
985 (long)(RTC_PORT(0)));
969 return -EIO; 986 return -EIO;
970 } 987 }
971 988
@@ -979,7 +996,10 @@ no_irq:
979 if(request_irq(RTC_IRQ, rtc_int_handler_ptr, IRQF_DISABLED, "rtc", NULL)) { 996 if(request_irq(RTC_IRQ, rtc_int_handler_ptr, IRQF_DISABLED, "rtc", NULL)) {
980 /* Yeah right, seeing as irq 8 doesn't even hit the bus. */ 997 /* Yeah right, seeing as irq 8 doesn't even hit the bus. */
981 printk(KERN_ERR "rtc: IRQ %d is not free.\n", RTC_IRQ); 998 printk(KERN_ERR "rtc: IRQ %d is not free.\n", RTC_IRQ);
982 release_region(RTC_PORT(0), RTC_IO_EXTENT); 999 if (RTC_IOMAPPED)
1000 release_region(RTC_PORT(0), RTC_IO_EXTENT);
1001 else
1002 release_mem_region(RTC_PORT(0), RTC_IO_EXTENT);
983 return -EIO; 1003 return -EIO;
984 } 1004 }
985 hpet_rtc_timer_init(); 1005 hpet_rtc_timer_init();
@@ -1079,7 +1099,10 @@ static void __exit rtc_exit (void)
1079 if (rtc_has_irq) 1099 if (rtc_has_irq)
1080 free_irq (rtc_irq, &rtc_port); 1100 free_irq (rtc_irq, &rtc_port);
1081#else 1101#else
1082 release_region (RTC_PORT (0), RTC_IO_EXTENT); 1102 if (RTC_IOMAPPED)
1103 release_region(RTC_PORT(0), RTC_IO_EXTENT);
1104 else
1105 release_mem_region(RTC_PORT(0), RTC_IO_EXTENT);
1083#ifdef RTC_IRQ 1106#ifdef RTC_IRQ
1084 if (rtc_has_irq) 1107 if (rtc_has_irq)
1085 free_irq (RTC_IRQ, NULL); 1108 free_irq (RTC_IRQ, NULL);
diff --git a/drivers/char/snsc_event.c b/drivers/char/snsc_event.c
index 8b2210b633df..d12d4f629cec 100644
--- a/drivers/char/snsc_event.c
+++ b/drivers/char/snsc_event.c
@@ -220,20 +220,7 @@ scdrv_dispatch_event(char *event, int len)
220 " Sending SIGPWR to init...\n"); 220 " Sending SIGPWR to init...\n");
221 221
222 /* give a SIGPWR signal to init proc */ 222 /* give a SIGPWR signal to init proc */
223 223 kill_proc(1, SIGPWR, 0);
224 /* first find init's task */
225 read_lock(&tasklist_lock);
226 for_each_process(p) {
227 if (p->pid == 1)
228 break;
229 }
230 if (p) {
231 force_sig(SIGPWR, p);
232 } else {
233 printk(KERN_ERR "Failed to signal init!\n");
234 snsc_shutting_down = 0; /* so can try again (?) */
235 }
236 read_unlock(&tasklist_lock);
237 } else { 224 } else {
238 /* print to system log */ 225 /* print to system log */
239 printk("%s|$(0x%x)%s\n", severity, esp_code, desc); 226 printk("%s|$(0x%x)%s\n", severity, esp_code, desc);
diff --git a/drivers/char/specialix.c b/drivers/char/specialix.c
index cb2859249d49..a1d303f9a33d 100644
--- a/drivers/char/specialix.c
+++ b/drivers/char/specialix.c
@@ -2584,6 +2584,12 @@ static void __exit specialix_exit_module(void)
2584 func_exit(); 2584 func_exit();
2585} 2585}
2586 2586
2587static struct pci_device_id specialx_pci_tbl[] __devinitdata = {
2588 { PCI_DEVICE(PCI_VENDOR_ID_SPECIALIX, PCI_DEVICE_ID_SPECIALIX_IO8) },
2589 { }
2590};
2591MODULE_DEVICE_TABLE(pci, specialx_pci_tbl);
2592
2587module_init(specialix_init_module); 2593module_init(specialix_init_module);
2588module_exit(specialix_exit_module); 2594module_exit(specialix_exit_module);
2589 2595
diff --git a/drivers/edac/edac_mc.c b/drivers/edac/edac_mc.c
index 3a7cfe88b169..4bde30bb3be7 100644
--- a/drivers/edac/edac_mc.c
+++ b/drivers/edac/edac_mc.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * edac_mc kernel module 2 * edac_mc kernel module
3 * (C) 2005 Linux Networx (http://lnxi.com) 3 * (C) 2005, 2006 Linux Networx (http://lnxi.com)
4 * This file may be distributed under the terms of the 4 * This file may be distributed under the terms of the
5 * GNU General Public License. 5 * GNU General Public License.
6 * 6 *
@@ -33,13 +33,8 @@
33#include <asm/edac.h> 33#include <asm/edac.h>
34#include "edac_mc.h" 34#include "edac_mc.h"
35 35
36#define EDAC_MC_VERSION "Ver: 2.0.0 " __DATE__ 36#define EDAC_MC_VERSION "Ver: 2.0.1 " __DATE__
37 37
38/* For now, disable the EDAC sysfs code. The sysfs interface that EDAC
39 * presents to user space needs more thought, and is likely to change
40 * substantially.
41 */
42#define DISABLE_EDAC_SYSFS
43 38
44#ifdef CONFIG_EDAC_DEBUG 39#ifdef CONFIG_EDAC_DEBUG
45/* Values of 0 to 4 will generate output */ 40/* Values of 0 to 4 will generate output */
@@ -64,31 +59,12 @@ static int check_pci_parity = 0; /* default YES check PCI parity */
64static int panic_on_pci_parity; /* default no panic on PCI Parity */ 59static int panic_on_pci_parity; /* default no panic on PCI Parity */
65static atomic_t pci_parity_count = ATOMIC_INIT(0); 60static atomic_t pci_parity_count = ATOMIC_INIT(0);
66 61
67/* Structure of the whitelist and blacklist arrays */
68struct edac_pci_device_list {
69 unsigned int vendor; /* Vendor ID */
70 unsigned int device; /* Deviice ID */
71};
72
73#define MAX_LISTED_PCI_DEVICES 32
74
75/* List of PCI devices (vendor-id:device-id) that should be skipped */
76static struct edac_pci_device_list pci_blacklist[MAX_LISTED_PCI_DEVICES];
77static int pci_blacklist_count;
78
79/* List of PCI devices (vendor-id:device-id) that should be scanned */
80static struct edac_pci_device_list pci_whitelist[MAX_LISTED_PCI_DEVICES];
81static int pci_whitelist_count ;
82
83#ifndef DISABLE_EDAC_SYSFS
84static struct kobject edac_pci_kobj; /* /sys/devices/system/edac/pci */ 62static struct kobject edac_pci_kobj; /* /sys/devices/system/edac/pci */
85static struct completion edac_pci_kobj_complete; 63static struct completion edac_pci_kobj_complete;
86#endif /* DISABLE_EDAC_SYSFS */
87#endif /* CONFIG_PCI */ 64#endif /* CONFIG_PCI */
88 65
89/* START sysfs data and methods */ 66/* START sysfs data and methods */
90 67
91#ifndef DISABLE_EDAC_SYSFS
92 68
93static const char *mem_types[] = { 69static const char *mem_types[] = {
94 [MEM_EMPTY] = "Empty", 70 [MEM_EMPTY] = "Empty",
@@ -147,18 +123,10 @@ static struct completion edac_memctrl_kobj_complete;
147 * /sys/devices/system/edac/mc; 123 * /sys/devices/system/edac/mc;
148 * data structures and methods 124 * data structures and methods
149 */ 125 */
150#if 0
151static ssize_t memctrl_string_show(void *ptr, char *buffer)
152{
153 char *value = (char*) ptr;
154 return sprintf(buffer, "%s\n", value);
155}
156#endif
157
158static ssize_t memctrl_int_show(void *ptr, char *buffer) 126static ssize_t memctrl_int_show(void *ptr, char *buffer)
159{ 127{
160 int *value = (int*) ptr; 128 int *value = (int*) ptr;
161 return sprintf(buffer, "%d\n", *value); 129 return sprintf(buffer, "%u\n", *value);
162} 130}
163 131
164static ssize_t memctrl_int_store(void *ptr, const char *buffer, size_t count) 132static ssize_t memctrl_int_store(void *ptr, const char *buffer, size_t count)
@@ -224,11 +192,6 @@ struct memctrl_dev_attribute attr_##_name = { \
224 .store = _store, \ 192 .store = _store, \
225}; 193};
226 194
227/* cwrow<id> attribute f*/
228#if 0
229MEMCTRL_STRING_ATTR(mc_version,EDAC_MC_VERSION,S_IRUGO,memctrl_string_show,NULL);
230#endif
231
232/* csrow<id> control files */ 195/* csrow<id> control files */
233MEMCTRL_ATTR(panic_on_ue,S_IRUGO|S_IWUSR,memctrl_int_show,memctrl_int_store); 196MEMCTRL_ATTR(panic_on_ue,S_IRUGO|S_IWUSR,memctrl_int_show,memctrl_int_store);
234MEMCTRL_ATTR(log_ue,S_IRUGO|S_IWUSR,memctrl_int_show,memctrl_int_store); 197MEMCTRL_ATTR(log_ue,S_IRUGO|S_IWUSR,memctrl_int_show,memctrl_int_store);
@@ -257,8 +220,6 @@ static struct kobj_type ktype_memctrl = {
257 .default_attrs = (struct attribute **) memctrl_attr, 220 .default_attrs = (struct attribute **) memctrl_attr,
258}; 221};
259 222
260#endif /* DISABLE_EDAC_SYSFS */
261
262/* Initialize the main sysfs entries for edac: 223/* Initialize the main sysfs entries for edac:
263 * /sys/devices/system/edac 224 * /sys/devices/system/edac
264 * 225 *
@@ -268,11 +229,6 @@ static struct kobj_type ktype_memctrl = {
268 * !0 FAILURE 229 * !0 FAILURE
269 */ 230 */
270static int edac_sysfs_memctrl_setup(void) 231static int edac_sysfs_memctrl_setup(void)
271#ifdef DISABLE_EDAC_SYSFS
272{
273 return 0;
274}
275#else
276{ 232{
277 int err=0; 233 int err=0;
278 234
@@ -304,7 +260,6 @@ static int edac_sysfs_memctrl_setup(void)
304 260
305 return err; 261 return err;
306} 262}
307#endif /* DISABLE_EDAC_SYSFS */
308 263
309/* 264/*
310 * MC teardown: 265 * MC teardown:
@@ -312,7 +267,6 @@ static int edac_sysfs_memctrl_setup(void)
312 */ 267 */
313static void edac_sysfs_memctrl_teardown(void) 268static void edac_sysfs_memctrl_teardown(void)
314{ 269{
315#ifndef DISABLE_EDAC_SYSFS
316 debugf0("MC: " __FILE__ ": %s()\n", __func__); 270 debugf0("MC: " __FILE__ ": %s()\n", __func__);
317 271
318 /* Unregister the MC's kobject and wait for reference count to reach 272 /* Unregister the MC's kobject and wait for reference count to reach
@@ -324,144 +278,9 @@ static void edac_sysfs_memctrl_teardown(void)
324 278
325 /* Unregister the 'edac' object */ 279 /* Unregister the 'edac' object */
326 sysdev_class_unregister(&edac_class); 280 sysdev_class_unregister(&edac_class);
327#endif /* DISABLE_EDAC_SYSFS */
328} 281}
329 282
330#ifdef CONFIG_PCI 283#ifdef CONFIG_PCI
331
332#ifndef DISABLE_EDAC_SYSFS
333
334/*
335 * /sys/devices/system/edac/pci;
336 * data structures and methods
337 */
338
339struct list_control {
340 struct edac_pci_device_list *list;
341 int *count;
342};
343
344#if 0
345/* Output the list as: vendor_id:device:id<,vendor_id:device_id> */
346static ssize_t edac_pci_list_string_show(void *ptr, char *buffer)
347{
348 struct list_control *listctl;
349 struct edac_pci_device_list *list;
350 char *p = buffer;
351 int len=0;
352 int i;
353
354 listctl = ptr;
355 list = listctl->list;
356
357 for (i = 0; i < *(listctl->count); i++, list++ ) {
358 if (len > 0)
359 len += snprintf(p + len, (PAGE_SIZE-len), ",");
360
361 len += snprintf(p + len,
362 (PAGE_SIZE-len),
363 "%x:%x",
364 list->vendor,list->device);
365 }
366
367 len += snprintf(p + len,(PAGE_SIZE-len), "\n");
368 return (ssize_t) len;
369}
370
371/**
372 *
373 * Scan string from **s to **e looking for one 'vendor:device' tuple
374 * where each field is a hex value
375 *
376 * return 0 if an entry is NOT found
377 * return 1 if an entry is found
378 * fill in *vendor_id and *device_id with values found
379 *
380 * In both cases, make sure *s has been moved forward toward *e
381 */
382static int parse_one_device(const char **s,const char **e,
383 unsigned int *vendor_id, unsigned int *device_id)
384{
385 const char *runner, *p;
386
387 /* if null byte, we are done */
388 if (!**s) {
389 (*s)++; /* keep *s moving */
390 return 0;
391 }
392
393 /* skip over newlines & whitespace */
394 if ((**s == '\n') || isspace(**s)) {
395 (*s)++;
396 return 0;
397 }
398
399 if (!isxdigit(**s)) {
400 (*s)++;
401 return 0;
402 }
403
404 /* parse vendor_id */
405 runner = *s;
406
407 while (runner < *e) {
408 /* scan for vendor:device delimiter */
409 if (*runner == ':') {
410 *vendor_id = simple_strtol((char*) *s, (char**) &p, 16);
411 runner = p + 1;
412 break;
413 }
414
415 runner++;
416 }
417
418 if (!isxdigit(*runner)) {
419 *s = ++runner;
420 return 0;
421 }
422
423 /* parse device_id */
424 if (runner < *e) {
425 *device_id = simple_strtol((char*)runner, (char**)&p, 16);
426 runner = p;
427 }
428
429 *s = runner;
430 return 1;
431}
432
433static ssize_t edac_pci_list_string_store(void *ptr, const char *buffer,
434 size_t count)
435{
436 struct list_control *listctl;
437 struct edac_pci_device_list *list;
438 unsigned int vendor_id, device_id;
439 const char *s, *e;
440 int *index;
441
442 s = (char*)buffer;
443 e = s + count;
444 listctl = ptr;
445 list = listctl->list;
446 index = listctl->count;
447 *index = 0;
448
449 while (*index < MAX_LISTED_PCI_DEVICES) {
450 if (parse_one_device(&s,&e,&vendor_id,&device_id)) {
451 list[ *index ].vendor = vendor_id;
452 list[ *index ].device = device_id;
453 (*index)++;
454 }
455
456 /* check for all data consume */
457 if (s >= e)
458 break;
459 }
460
461 return count;
462}
463
464#endif
465static ssize_t edac_pci_int_show(void *ptr, char *buffer) 284static ssize_t edac_pci_int_show(void *ptr, char *buffer)
466{ 285{
467 int *value = ptr; 286 int *value = ptr;
@@ -529,31 +348,6 @@ struct edac_pci_dev_attribute edac_pci_attr_##_name = { \
529 .store = _store, \ 348 .store = _store, \
530}; 349};
531 350
532#if 0
533static struct list_control pci_whitelist_control = {
534 .list = pci_whitelist,
535 .count = &pci_whitelist_count
536};
537
538static struct list_control pci_blacklist_control = {
539 .list = pci_blacklist,
540 .count = &pci_blacklist_count
541};
542
543/* whitelist attribute */
544EDAC_PCI_STRING_ATTR(pci_parity_whitelist,
545 &pci_whitelist_control,
546 S_IRUGO|S_IWUSR,
547 edac_pci_list_string_show,
548 edac_pci_list_string_store);
549
550EDAC_PCI_STRING_ATTR(pci_parity_blacklist,
551 &pci_blacklist_control,
552 S_IRUGO|S_IWUSR,
553 edac_pci_list_string_show,
554 edac_pci_list_string_store);
555#endif
556
557/* PCI Parity control files */ 351/* PCI Parity control files */
558EDAC_PCI_ATTR(check_pci_parity, S_IRUGO|S_IWUSR, edac_pci_int_show, 352EDAC_PCI_ATTR(check_pci_parity, S_IRUGO|S_IWUSR, edac_pci_int_show,
559 edac_pci_int_store); 353 edac_pci_int_store);
@@ -582,18 +376,11 @@ static struct kobj_type ktype_edac_pci = {
582 .default_attrs = (struct attribute **) edac_pci_attr, 376 .default_attrs = (struct attribute **) edac_pci_attr,
583}; 377};
584 378
585#endif /* DISABLE_EDAC_SYSFS */
586
587/** 379/**
588 * edac_sysfs_pci_setup() 380 * edac_sysfs_pci_setup()
589 * 381 *
590 */ 382 */
591static int edac_sysfs_pci_setup(void) 383static int edac_sysfs_pci_setup(void)
592#ifdef DISABLE_EDAC_SYSFS
593{
594 return 0;
595}
596#else
597{ 384{
598 int err; 385 int err;
599 386
@@ -617,16 +404,13 @@ static int edac_sysfs_pci_setup(void)
617 404
618 return err; 405 return err;
619} 406}
620#endif /* DISABLE_EDAC_SYSFS */
621 407
622static void edac_sysfs_pci_teardown(void) 408static void edac_sysfs_pci_teardown(void)
623{ 409{
624#ifndef DISABLE_EDAC_SYSFS
625 debugf0("%s()\n", __func__); 410 debugf0("%s()\n", __func__);
626 init_completion(&edac_pci_kobj_complete); 411 init_completion(&edac_pci_kobj_complete);
627 kobject_unregister(&edac_pci_kobj); 412 kobject_unregister(&edac_pci_kobj);
628 wait_for_completion(&edac_pci_kobj_complete); 413 wait_for_completion(&edac_pci_kobj_complete);
629#endif
630} 414}
631 415
632 416
@@ -756,36 +540,6 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
756} 540}
757 541
758/* 542/*
759 * check_dev_on_list: Scan for a PCI device on a white/black list
760 * @list: an EDAC &edac_pci_device_list white/black list pointer
761 * @free_index: index of next free entry on the list
762 * @pci_dev: PCI Device pointer
763 *
764 * see if list contains the device.
765 *
766 * Returns: 0 not found
767 * 1 found on list
768 */
769static int check_dev_on_list(struct edac_pci_device_list *list,
770 int free_index, struct pci_dev *dev)
771{
772 int i;
773 int rc = 0; /* Assume not found */
774 unsigned short vendor=dev->vendor;
775 unsigned short device=dev->device;
776
777 /* Scan the list, looking for a vendor/device match */
778 for (i = 0; i < free_index; i++, list++ ) {
779 if ((list->vendor == vendor ) && (list->device == device )) {
780 rc = 1;
781 break;
782 }
783 }
784
785 return rc;
786}
787
788/*
789 * pci_dev parity list iterator 543 * pci_dev parity list iterator
790 * Scan the PCI device list for one iteration, looking for SERRORs 544 * Scan the PCI device list for one iteration, looking for SERRORs
791 * Master Parity ERRORS or Parity ERRORs on primary or secondary devices 545 * Master Parity ERRORS or Parity ERRORs on primary or secondary devices
@@ -799,22 +553,7 @@ static inline void edac_pci_dev_parity_iterator(pci_parity_check_fn_t fn)
799 * bumped until we are done with it 553 * bumped until we are done with it
800 */ 554 */
801 while((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) { 555 while((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
802 /* if whitelist exists then it has priority, so only scan 556 fn(dev);
803 * those devices on the whitelist
804 */
805 if (pci_whitelist_count > 0 ) {
806 if (check_dev_on_list(pci_whitelist,
807 pci_whitelist_count, dev))
808 fn(dev);
809 } else {
810 /*
811 * if no whitelist, then check if this devices is
812 * blacklisted
813 */
814 if (!check_dev_on_list(pci_blacklist,
815 pci_blacklist_count, dev))
816 fn(dev);
817 }
818 } 557 }
819} 558}
820 559
@@ -855,154 +594,101 @@ static inline void clear_pci_parity_errors(void)
855 594
856#else /* CONFIG_PCI */ 595#else /* CONFIG_PCI */
857 596
858static inline void do_pci_parity_check(void) 597/* pre-process these away */
859{ 598#define do_pci_parity_check()
860 /* no-op */ 599#define clear_pci_parity_errors()
861} 600#define edac_sysfs_pci_teardown()
862 601#define edac_sysfs_pci_setup() (0)
863static inline void clear_pci_parity_errors(void)
864{
865 /* no-op */
866}
867
868static void edac_sysfs_pci_teardown(void)
869{
870}
871 602
872static int edac_sysfs_pci_setup(void)
873{
874 return 0;
875}
876#endif /* CONFIG_PCI */ 603#endif /* CONFIG_PCI */
877 604
878#ifndef DISABLE_EDAC_SYSFS 605/* EDAC sysfs CSROW data structures and methods
879 606 */
880/* EDAC sysfs CSROW data structures and methods */
881
882/* Set of more detailed csrow<id> attribute show/store functions */
883static ssize_t csrow_ch0_dimm_label_show(struct csrow_info *csrow, char *data)
884{
885 ssize_t size = 0;
886
887 if (csrow->nr_channels > 0) {
888 size = snprintf(data, EDAC_MC_LABEL_LEN,"%s\n",
889 csrow->channels[0].label);
890 }
891
892 return size;
893}
894 607
895static ssize_t csrow_ch1_dimm_label_show(struct csrow_info *csrow, char *data) 608/* Set of more default csrow<id> attribute show/store functions */
609static ssize_t csrow_ue_count_show(struct csrow_info *csrow, char *data, int private)
896{ 610{
897 ssize_t size = 0; 611 return sprintf(data,"%u\n", csrow->ue_count);
898
899 if (csrow->nr_channels > 0) {
900 size = snprintf(data, EDAC_MC_LABEL_LEN, "%s\n",
901 csrow->channels[1].label);
902 }
903
904 return size;
905} 612}
906 613
907static ssize_t csrow_ch0_dimm_label_store(struct csrow_info *csrow, 614static ssize_t csrow_ce_count_show(struct csrow_info *csrow, char *data, int private)
908 const char *data, size_t size)
909{ 615{
910 ssize_t max_size = 0; 616 return sprintf(data,"%u\n", csrow->ce_count);
911
912 if (csrow->nr_channels > 0) {
913 max_size = min((ssize_t)size,(ssize_t)EDAC_MC_LABEL_LEN-1);
914 strncpy(csrow->channels[0].label, data, max_size);
915 csrow->channels[0].label[max_size] = '\0';
916 }
917
918 return size;
919} 617}
920 618
921static ssize_t csrow_ch1_dimm_label_store(struct csrow_info *csrow, 619static ssize_t csrow_size_show(struct csrow_info *csrow, char *data, int private)
922 const char *data, size_t size)
923{ 620{
924 ssize_t max_size = 0; 621 return sprintf(data,"%u\n", PAGES_TO_MiB(csrow->nr_pages));
925
926 if (csrow->nr_channels > 1) {
927 max_size = min((ssize_t)size,(ssize_t)EDAC_MC_LABEL_LEN-1);
928 strncpy(csrow->channels[1].label, data, max_size);
929 csrow->channels[1].label[max_size] = '\0';
930 }
931
932 return max_size;
933} 622}
934 623
935static ssize_t csrow_ue_count_show(struct csrow_info *csrow, char *data) 624static ssize_t csrow_mem_type_show(struct csrow_info *csrow, char *data, int private)
936{ 625{
937 return sprintf(data,"%u\n", csrow->ue_count); 626 return sprintf(data,"%s\n", mem_types[csrow->mtype]);
938} 627}
939 628
940static ssize_t csrow_ce_count_show(struct csrow_info *csrow, char *data) 629static ssize_t csrow_dev_type_show(struct csrow_info *csrow, char *data, int private)
941{ 630{
942 return sprintf(data,"%u\n", csrow->ce_count); 631 return sprintf(data,"%s\n", dev_types[csrow->dtype]);
943} 632}
944 633
945static ssize_t csrow_ch0_ce_count_show(struct csrow_info *csrow, char *data) 634static ssize_t csrow_edac_mode_show(struct csrow_info *csrow, char *data, int private)
946{ 635{
947 ssize_t size = 0; 636 return sprintf(data,"%s\n", edac_caps[csrow->edac_mode]);
948
949 if (csrow->nr_channels > 0) {
950 size = sprintf(data,"%u\n", csrow->channels[0].ce_count);
951 }
952
953 return size;
954} 637}
955 638
956static ssize_t csrow_ch1_ce_count_show(struct csrow_info *csrow, char *data) 639/* show/store functions for DIMM Label attributes */
640static ssize_t channel_dimm_label_show(struct csrow_info *csrow,
641 char *data, int channel)
957{ 642{
958 ssize_t size = 0; 643 return snprintf(data, EDAC_MC_LABEL_LEN,"%s",
959 644 csrow->channels[channel].label);
960 if (csrow->nr_channels > 1) {
961 size = sprintf(data,"%u\n", csrow->channels[1].ce_count);
962 }
963
964 return size;
965} 645}
966 646
967static ssize_t csrow_size_show(struct csrow_info *csrow, char *data) 647static ssize_t channel_dimm_label_store(struct csrow_info *csrow,
648 const char *data,
649 size_t count,
650 int channel)
968{ 651{
969 return sprintf(data,"%u\n", PAGES_TO_MiB(csrow->nr_pages)); 652 ssize_t max_size = 0;
970}
971 653
972static ssize_t csrow_mem_type_show(struct csrow_info *csrow, char *data) 654 max_size = min((ssize_t)count,(ssize_t)EDAC_MC_LABEL_LEN-1);
973{ 655 strncpy(csrow->channels[channel].label, data, max_size);
974 return sprintf(data,"%s\n", mem_types[csrow->mtype]); 656 csrow->channels[channel].label[max_size] = '\0';
975}
976 657
977static ssize_t csrow_dev_type_show(struct csrow_info *csrow, char *data) 658 return max_size;
978{
979 return sprintf(data,"%s\n", dev_types[csrow->dtype]);
980} 659}
981 660
982static ssize_t csrow_edac_mode_show(struct csrow_info *csrow, char *data) 661/* show function for dynamic chX_ce_count attribute */
662static ssize_t channel_ce_count_show(struct csrow_info *csrow,
663 char *data,
664 int channel)
983{ 665{
984 return sprintf(data,"%s\n", edac_caps[csrow->edac_mode]); 666 return sprintf(data, "%u\n", csrow->channels[channel].ce_count);
985} 667}
986 668
669/* csrow specific attribute structure */
987struct csrowdev_attribute { 670struct csrowdev_attribute {
988 struct attribute attr; 671 struct attribute attr;
989 ssize_t (*show)(struct csrow_info *,char *); 672 ssize_t (*show)(struct csrow_info *,char *,int);
990 ssize_t (*store)(struct csrow_info *, const char *,size_t); 673 ssize_t (*store)(struct csrow_info *, const char *,size_t,int);
674 int private;
991}; 675};
992 676
993#define to_csrow(k) container_of(k, struct csrow_info, kobj) 677#define to_csrow(k) container_of(k, struct csrow_info, kobj)
994#define to_csrowdev_attr(a) container_of(a, struct csrowdev_attribute, attr) 678#define to_csrowdev_attr(a) container_of(a, struct csrowdev_attribute, attr)
995 679
996/* Set of show/store higher level functions for csrow objects */ 680/* Set of show/store higher level functions for default csrow attributes */
997static ssize_t csrowdev_show(struct kobject *kobj, struct attribute *attr, 681static ssize_t csrowdev_show(struct kobject *kobj,
998 char *buffer) 682 struct attribute *attr,
683 char *buffer)
999{ 684{
1000 struct csrow_info *csrow = to_csrow(kobj); 685 struct csrow_info *csrow = to_csrow(kobj);
1001 struct csrowdev_attribute *csrowdev_attr = to_csrowdev_attr(attr); 686 struct csrowdev_attribute *csrowdev_attr = to_csrowdev_attr(attr);
1002 687
1003 if (csrowdev_attr->show) 688 if (csrowdev_attr->show)
1004 return csrowdev_attr->show(csrow, buffer); 689 return csrowdev_attr->show(csrow,
1005 690 buffer,
691 csrowdev_attr->private);
1006 return -EIO; 692 return -EIO;
1007} 693}
1008 694
@@ -1013,8 +699,10 @@ static ssize_t csrowdev_store(struct kobject *kobj, struct attribute *attr,
1013 struct csrowdev_attribute * csrowdev_attr = to_csrowdev_attr(attr); 699 struct csrowdev_attribute * csrowdev_attr = to_csrowdev_attr(attr);
1014 700
1015 if (csrowdev_attr->store) 701 if (csrowdev_attr->store)
1016 return csrowdev_attr->store(csrow, buffer, count); 702 return csrowdev_attr->store(csrow,
1017 703 buffer,
704 count,
705 csrowdev_attr->private);
1018 return -EIO; 706 return -EIO;
1019} 707}
1020 708
@@ -1023,69 +711,157 @@ static struct sysfs_ops csrowfs_ops = {
1023 .store = csrowdev_store 711 .store = csrowdev_store
1024}; 712};
1025 713
1026#define CSROWDEV_ATTR(_name,_mode,_show,_store) \ 714#define CSROWDEV_ATTR(_name,_mode,_show,_store,_private) \
1027struct csrowdev_attribute attr_##_name = { \ 715struct csrowdev_attribute attr_##_name = { \
1028 .attr = {.name = __stringify(_name), .mode = _mode }, \ 716 .attr = {.name = __stringify(_name), .mode = _mode }, \
1029 .show = _show, \ 717 .show = _show, \
1030 .store = _store, \ 718 .store = _store, \
719 .private = _private, \
1031}; 720};
1032 721
1033/* cwrow<id>/attribute files */ 722/* default cwrow<id>/attribute files */
1034CSROWDEV_ATTR(size_mb,S_IRUGO,csrow_size_show,NULL); 723CSROWDEV_ATTR(size_mb,S_IRUGO,csrow_size_show,NULL,0);
1035CSROWDEV_ATTR(dev_type,S_IRUGO,csrow_dev_type_show,NULL); 724CSROWDEV_ATTR(dev_type,S_IRUGO,csrow_dev_type_show,NULL,0);
1036CSROWDEV_ATTR(mem_type,S_IRUGO,csrow_mem_type_show,NULL); 725CSROWDEV_ATTR(mem_type,S_IRUGO,csrow_mem_type_show,NULL,0);
1037CSROWDEV_ATTR(edac_mode,S_IRUGO,csrow_edac_mode_show,NULL); 726CSROWDEV_ATTR(edac_mode,S_IRUGO,csrow_edac_mode_show,NULL,0);
1038CSROWDEV_ATTR(ue_count,S_IRUGO,csrow_ue_count_show,NULL); 727CSROWDEV_ATTR(ue_count,S_IRUGO,csrow_ue_count_show,NULL,0);
1039CSROWDEV_ATTR(ce_count,S_IRUGO,csrow_ce_count_show,NULL); 728CSROWDEV_ATTR(ce_count,S_IRUGO,csrow_ce_count_show,NULL,0);
1040CSROWDEV_ATTR(ch0_ce_count,S_IRUGO,csrow_ch0_ce_count_show,NULL);
1041CSROWDEV_ATTR(ch1_ce_count,S_IRUGO,csrow_ch1_ce_count_show,NULL);
1042
1043/* control/attribute files */
1044CSROWDEV_ATTR(ch0_dimm_label,S_IRUGO|S_IWUSR,
1045 csrow_ch0_dimm_label_show,
1046 csrow_ch0_dimm_label_store);
1047CSROWDEV_ATTR(ch1_dimm_label,S_IRUGO|S_IWUSR,
1048 csrow_ch1_dimm_label_show,
1049 csrow_ch1_dimm_label_store);
1050 729
1051/* Attributes of the CSROW<id> object */ 730/* default attributes of the CSROW<id> object */
1052static struct csrowdev_attribute *csrow_attr[] = { 731static struct csrowdev_attribute *default_csrow_attr[] = {
1053 &attr_dev_type, 732 &attr_dev_type,
1054 &attr_mem_type, 733 &attr_mem_type,
1055 &attr_edac_mode, 734 &attr_edac_mode,
1056 &attr_size_mb, 735 &attr_size_mb,
1057 &attr_ue_count, 736 &attr_ue_count,
1058 &attr_ce_count, 737 &attr_ce_count,
1059 &attr_ch0_ce_count,
1060 &attr_ch1_ce_count,
1061 &attr_ch0_dimm_label,
1062 &attr_ch1_dimm_label,
1063 NULL, 738 NULL,
1064}; 739};
1065 740
1066/* No memory to release */ 741
742/* possible dynamic channel DIMM Label attribute files */
743CSROWDEV_ATTR(ch0_dimm_label,S_IRUGO|S_IWUSR,
744 channel_dimm_label_show,
745 channel_dimm_label_store,
746 0 );
747CSROWDEV_ATTR(ch1_dimm_label,S_IRUGO|S_IWUSR,
748 channel_dimm_label_show,
749 channel_dimm_label_store,
750 1 );
751CSROWDEV_ATTR(ch2_dimm_label,S_IRUGO|S_IWUSR,
752 channel_dimm_label_show,
753 channel_dimm_label_store,
754 2 );
755CSROWDEV_ATTR(ch3_dimm_label,S_IRUGO|S_IWUSR,
756 channel_dimm_label_show,
757 channel_dimm_label_store,
758 3 );
759CSROWDEV_ATTR(ch4_dimm_label,S_IRUGO|S_IWUSR,
760 channel_dimm_label_show,
761 channel_dimm_label_store,
762 4 );
763CSROWDEV_ATTR(ch5_dimm_label,S_IRUGO|S_IWUSR,
764 channel_dimm_label_show,
765 channel_dimm_label_store,
766 5 );
767
768/* Total possible dynamic DIMM Label attribute file table */
769static struct csrowdev_attribute *dynamic_csrow_dimm_attr[] = {
770 &attr_ch0_dimm_label,
771 &attr_ch1_dimm_label,
772 &attr_ch2_dimm_label,
773 &attr_ch3_dimm_label,
774 &attr_ch4_dimm_label,
775 &attr_ch5_dimm_label
776};
777
778/* possible dynamic channel ce_count attribute files */
779CSROWDEV_ATTR(ch0_ce_count,S_IRUGO|S_IWUSR,
780 channel_ce_count_show,
781 NULL,
782 0 );
783CSROWDEV_ATTR(ch1_ce_count,S_IRUGO|S_IWUSR,
784 channel_ce_count_show,
785 NULL,
786 1 );
787CSROWDEV_ATTR(ch2_ce_count,S_IRUGO|S_IWUSR,
788 channel_ce_count_show,
789 NULL,
790 2 );
791CSROWDEV_ATTR(ch3_ce_count,S_IRUGO|S_IWUSR,
792 channel_ce_count_show,
793 NULL,
794 3 );
795CSROWDEV_ATTR(ch4_ce_count,S_IRUGO|S_IWUSR,
796 channel_ce_count_show,
797 NULL,
798 4 );
799CSROWDEV_ATTR(ch5_ce_count,S_IRUGO|S_IWUSR,
800 channel_ce_count_show,
801 NULL,
802 5 );
803
804/* Total possible dynamic ce_count attribute file table */
805static struct csrowdev_attribute *dynamic_csrow_ce_count_attr[] = {
806 &attr_ch0_ce_count,
807 &attr_ch1_ce_count,
808 &attr_ch2_ce_count,
809 &attr_ch3_ce_count,
810 &attr_ch4_ce_count,
811 &attr_ch5_ce_count
812};
813
814
815#define EDAC_NR_CHANNELS 6
816
817/* Create dynamic CHANNEL files, indexed by 'chan', under specifed CSROW */
818static int edac_create_channel_files(struct kobject *kobj, int chan)
819{
820 int err=-ENODEV;
821
822 if (chan >= EDAC_NR_CHANNELS)
823 return err;
824
825 /* create the DIMM label attribute file */
826 err = sysfs_create_file(kobj,
827 (struct attribute *) dynamic_csrow_dimm_attr[chan]);
828
829 if (!err) {
830 /* create the CE Count attribute file */
831 err = sysfs_create_file(kobj,
832 (struct attribute *) dynamic_csrow_ce_count_attr[chan]);
833 } else {
834 debugf1("%s() dimm labels and ce_count files created", __func__);
835 }
836
837 return err;
838}
839
840/* No memory to release for this kobj */
1067static void edac_csrow_instance_release(struct kobject *kobj) 841static void edac_csrow_instance_release(struct kobject *kobj)
1068{ 842{
1069 struct csrow_info *cs; 843 struct csrow_info *cs;
1070 844
1071 debugf1("%s()\n", __func__);
1072 cs = container_of(kobj, struct csrow_info, kobj); 845 cs = container_of(kobj, struct csrow_info, kobj);
1073 complete(&cs->kobj_complete); 846 complete(&cs->kobj_complete);
1074} 847}
1075 848
849/* the kobj_type instance for a CSROW */
1076static struct kobj_type ktype_csrow = { 850static struct kobj_type ktype_csrow = {
1077 .release = edac_csrow_instance_release, 851 .release = edac_csrow_instance_release,
1078 .sysfs_ops = &csrowfs_ops, 852 .sysfs_ops = &csrowfs_ops,
1079 .default_attrs = (struct attribute **) csrow_attr, 853 .default_attrs = (struct attribute **) default_csrow_attr,
1080}; 854};
1081 855
1082/* Create a CSROW object under specifed edac_mc_device */ 856/* Create a CSROW object under specifed edac_mc_device */
1083static int edac_create_csrow_object(struct kobject *edac_mci_kobj, 857static int edac_create_csrow_object(
1084 struct csrow_info *csrow, int index) 858 struct kobject *edac_mci_kobj,
859 struct csrow_info *csrow,
860 int index)
1085{ 861{
1086 int err = 0; 862 int err = 0;
863 int chan;
1087 864
1088 debugf0("%s()\n", __func__);
1089 memset(&csrow->kobj, 0, sizeof(csrow->kobj)); 865 memset(&csrow->kobj, 0, sizeof(csrow->kobj));
1090 866
1091 /* generate ..../edac/mc/mc<id>/csrow<index> */ 867 /* generate ..../edac/mc/mc<id>/csrow<index> */
@@ -1095,21 +871,27 @@ static int edac_create_csrow_object(struct kobject *edac_mci_kobj,
1095 871
1096 /* name this instance of csrow<id> */ 872 /* name this instance of csrow<id> */
1097 err = kobject_set_name(&csrow->kobj,"csrow%d",index); 873 err = kobject_set_name(&csrow->kobj,"csrow%d",index);
874 if (err)
875 goto error_exit;
1098 876
877 /* Instanstiate the csrow object */
878 err = kobject_register(&csrow->kobj);
1099 if (!err) { 879 if (!err) {
1100 /* Instanstiate the csrow object */ 880 /* Create the dyanmic attribute files on this csrow,
1101 err = kobject_register(&csrow->kobj); 881 * namely, the DIMM labels and the channel ce_count
1102 882 */
1103 if (err) 883 for (chan = 0; chan < csrow->nr_channels; chan++) {
1104 debugf0("Failed to register CSROW%d\n",index); 884 err = edac_create_channel_files(&csrow->kobj,chan);
1105 else 885 if (err)
1106 debugf0("Registered CSROW%d\n",index); 886 break;
887 }
1107 } 888 }
1108 889
890error_exit:
1109 return err; 891 return err;
1110} 892}
1111 893
1112/* sysfs data structures and methods for the MCI kobjects */ 894/* default sysfs methods and data structures for the main MCI kobject */
1113 895
1114static ssize_t mci_reset_counters_store(struct mem_ctl_info *mci, 896static ssize_t mci_reset_counters_store(struct mem_ctl_info *mci,
1115 const char *data, size_t count) 897 const char *data, size_t count)
@@ -1135,6 +917,7 @@ static ssize_t mci_reset_counters_store(struct mem_ctl_info *mci,
1135 return count; 917 return count;
1136} 918}
1137 919
920/* default attribute files for the MCI object */
1138static ssize_t mci_ue_count_show(struct mem_ctl_info *mci, char *data) 921static ssize_t mci_ue_count_show(struct mem_ctl_info *mci, char *data)
1139{ 922{
1140 return sprintf(data,"%d\n", mci->ue_count); 923 return sprintf(data,"%d\n", mci->ue_count);
@@ -1160,71 +943,11 @@ static ssize_t mci_seconds_show(struct mem_ctl_info *mci, char *data)
1160 return sprintf(data,"%ld\n", (jiffies - mci->start_time) / HZ); 943 return sprintf(data,"%ld\n", (jiffies - mci->start_time) / HZ);
1161} 944}
1162 945
1163static ssize_t mci_mod_name_show(struct mem_ctl_info *mci, char *data)
1164{
1165 return sprintf(data,"%s %s\n", mci->mod_name, mci->mod_ver);
1166}
1167
1168static ssize_t mci_ctl_name_show(struct mem_ctl_info *mci, char *data) 946static ssize_t mci_ctl_name_show(struct mem_ctl_info *mci, char *data)
1169{ 947{
1170 return sprintf(data,"%s\n", mci->ctl_name); 948 return sprintf(data,"%s\n", mci->ctl_name);
1171} 949}
1172 950
1173static int mci_output_edac_cap(char *buf, unsigned long edac_cap)
1174{
1175 char *p = buf;
1176 int bit_idx;
1177
1178 for (bit_idx = 0; bit_idx < 8 * sizeof(edac_cap); bit_idx++) {
1179 if ((edac_cap >> bit_idx) & 0x1)
1180 p += sprintf(p, "%s ", edac_caps[bit_idx]);
1181 }
1182
1183 return p - buf;
1184}
1185
1186static ssize_t mci_edac_capability_show(struct mem_ctl_info *mci, char *data)
1187{
1188 char *p = data;
1189
1190 p += mci_output_edac_cap(p,mci->edac_ctl_cap);
1191 p += sprintf(p, "\n");
1192 return p - data;
1193}
1194
1195static ssize_t mci_edac_current_capability_show(struct mem_ctl_info *mci,
1196 char *data)
1197{
1198 char *p = data;
1199
1200 p += mci_output_edac_cap(p,mci->edac_cap);
1201 p += sprintf(p, "\n");
1202 return p - data;
1203}
1204
1205static int mci_output_mtype_cap(char *buf, unsigned long mtype_cap)
1206{
1207 char *p = buf;
1208 int bit_idx;
1209
1210 for (bit_idx = 0; bit_idx < 8 * sizeof(mtype_cap); bit_idx++) {
1211 if ((mtype_cap >> bit_idx) & 0x1)
1212 p += sprintf(p, "%s ", mem_types[bit_idx]);
1213 }
1214
1215 return p - buf;
1216}
1217
1218static ssize_t mci_supported_mem_type_show(struct mem_ctl_info *mci,
1219 char *data)
1220{
1221 char *p = data;
1222
1223 p += mci_output_mtype_cap(p,mci->mtype_cap);
1224 p += sprintf(p, "\n");
1225 return p - data;
1226}
1227
1228static ssize_t mci_size_mb_show(struct mem_ctl_info *mci, char *data) 951static ssize_t mci_size_mb_show(struct mem_ctl_info *mci, char *data)
1229{ 952{
1230 int total_pages, csrow_idx; 953 int total_pages, csrow_idx;
@@ -1251,6 +974,7 @@ struct mcidev_attribute {
1251#define to_mci(k) container_of(k, struct mem_ctl_info, edac_mci_kobj) 974#define to_mci(k) container_of(k, struct mem_ctl_info, edac_mci_kobj)
1252#define to_mcidev_attr(a) container_of(a, struct mcidev_attribute, attr) 975#define to_mcidev_attr(a) container_of(a, struct mcidev_attribute, attr)
1253 976
977/* MCI show/store functions for top most object */
1254static ssize_t mcidev_show(struct kobject *kobj, struct attribute *attr, 978static ssize_t mcidev_show(struct kobject *kobj, struct attribute *attr,
1255 char *buffer) 979 char *buffer)
1256{ 980{
@@ -1287,31 +1011,21 @@ struct mcidev_attribute mci_attr_##_name = { \
1287 .store = _store, \ 1011 .store = _store, \
1288}; 1012};
1289 1013
1290/* Control file */ 1014/* default Control file */
1291MCIDEV_ATTR(reset_counters,S_IWUSR,NULL,mci_reset_counters_store); 1015MCIDEV_ATTR(reset_counters,S_IWUSR,NULL,mci_reset_counters_store);
1292 1016
1293/* Attribute files */ 1017/* default Attribute files */
1294MCIDEV_ATTR(mc_name,S_IRUGO,mci_ctl_name_show,NULL); 1018MCIDEV_ATTR(mc_name,S_IRUGO,mci_ctl_name_show,NULL);
1295MCIDEV_ATTR(module_name,S_IRUGO,mci_mod_name_show,NULL);
1296MCIDEV_ATTR(edac_capability,S_IRUGO,mci_edac_capability_show,NULL);
1297MCIDEV_ATTR(size_mb,S_IRUGO,mci_size_mb_show,NULL); 1019MCIDEV_ATTR(size_mb,S_IRUGO,mci_size_mb_show,NULL);
1298MCIDEV_ATTR(seconds_since_reset,S_IRUGO,mci_seconds_show,NULL); 1020MCIDEV_ATTR(seconds_since_reset,S_IRUGO,mci_seconds_show,NULL);
1299MCIDEV_ATTR(ue_noinfo_count,S_IRUGO,mci_ue_noinfo_show,NULL); 1021MCIDEV_ATTR(ue_noinfo_count,S_IRUGO,mci_ue_noinfo_show,NULL);
1300MCIDEV_ATTR(ce_noinfo_count,S_IRUGO,mci_ce_noinfo_show,NULL); 1022MCIDEV_ATTR(ce_noinfo_count,S_IRUGO,mci_ce_noinfo_show,NULL);
1301MCIDEV_ATTR(ue_count,S_IRUGO,mci_ue_count_show,NULL); 1023MCIDEV_ATTR(ue_count,S_IRUGO,mci_ue_count_show,NULL);
1302MCIDEV_ATTR(ce_count,S_IRUGO,mci_ce_count_show,NULL); 1024MCIDEV_ATTR(ce_count,S_IRUGO,mci_ce_count_show,NULL);
1303MCIDEV_ATTR(edac_current_capability,S_IRUGO,
1304 mci_edac_current_capability_show,NULL);
1305MCIDEV_ATTR(supported_mem_type,S_IRUGO,
1306 mci_supported_mem_type_show,NULL);
1307 1025
1308static struct mcidev_attribute *mci_attr[] = { 1026static struct mcidev_attribute *mci_attr[] = {
1309 &mci_attr_reset_counters, 1027 &mci_attr_reset_counters,
1310 &mci_attr_module_name,
1311 &mci_attr_mc_name, 1028 &mci_attr_mc_name,
1312 &mci_attr_edac_capability,
1313 &mci_attr_edac_current_capability,
1314 &mci_attr_supported_mem_type,
1315 &mci_attr_size_mb, 1029 &mci_attr_size_mb,
1316 &mci_attr_seconds_since_reset, 1030 &mci_attr_seconds_since_reset,
1317 &mci_attr_ue_noinfo_count, 1031 &mci_attr_ue_noinfo_count,
@@ -1339,7 +1053,6 @@ static struct kobj_type ktype_mci = {
1339 .default_attrs = (struct attribute **) mci_attr, 1053 .default_attrs = (struct attribute **) mci_attr,
1340}; 1054};
1341 1055
1342#endif /* DISABLE_EDAC_SYSFS */
1343 1056
1344#define EDAC_DEVICE_SYMLINK "device" 1057#define EDAC_DEVICE_SYMLINK "device"
1345 1058
@@ -1352,11 +1065,6 @@ static struct kobj_type ktype_mci = {
1352 * !0 Failure 1065 * !0 Failure
1353 */ 1066 */
1354static int edac_create_sysfs_mci_device(struct mem_ctl_info *mci) 1067static int edac_create_sysfs_mci_device(struct mem_ctl_info *mci)
1355#ifdef DISABLE_EDAC_SYSFS
1356{
1357 return 0;
1358}
1359#else
1360{ 1068{
1361 int i; 1069 int i;
1362 int err; 1070 int err;
@@ -1368,7 +1076,6 @@ static int edac_create_sysfs_mci_device(struct mem_ctl_info *mci)
1368 1076
1369 /* set the name of the mc<id> object */ 1077 /* set the name of the mc<id> object */
1370 err = kobject_set_name(edac_mci_kobj,"mc%d",mci->mc_idx); 1078 err = kobject_set_name(edac_mci_kobj,"mc%d",mci->mc_idx);
1371
1372 if (err) 1079 if (err)
1373 return err; 1080 return err;
1374 1081
@@ -1378,14 +1085,12 @@ static int edac_create_sysfs_mci_device(struct mem_ctl_info *mci)
1378 1085
1379 /* register the mc<id> kobject */ 1086 /* register the mc<id> kobject */
1380 err = kobject_register(edac_mci_kobj); 1087 err = kobject_register(edac_mci_kobj);
1381
1382 if (err) 1088 if (err)
1383 return err; 1089 return err;
1384 1090
1385 /* create a symlink for the device */ 1091 /* create a symlink for the device */
1386 err = sysfs_create_link(edac_mci_kobj, &mci->dev->kobj, 1092 err = sysfs_create_link(edac_mci_kobj, &mci->dev->kobj,
1387 EDAC_DEVICE_SYMLINK); 1093 EDAC_DEVICE_SYMLINK);
1388
1389 if (err) 1094 if (err)
1390 goto fail0; 1095 goto fail0;
1391 1096
@@ -1398,7 +1103,6 @@ static int edac_create_sysfs_mci_device(struct mem_ctl_info *mci)
1398 /* Only expose populated CSROWs */ 1103 /* Only expose populated CSROWs */
1399 if (csrow->nr_pages > 0) { 1104 if (csrow->nr_pages > 0) {
1400 err = edac_create_csrow_object(edac_mci_kobj,csrow,i); 1105 err = edac_create_csrow_object(edac_mci_kobj,csrow,i);
1401
1402 if (err) 1106 if (err)
1403 goto fail1; 1107 goto fail1;
1404 } 1108 }
@@ -1422,14 +1126,12 @@ fail0:
1422 wait_for_completion(&mci->kobj_complete); 1126 wait_for_completion(&mci->kobj_complete);
1423 return err; 1127 return err;
1424} 1128}
1425#endif /* DISABLE_EDAC_SYSFS */
1426 1129
1427/* 1130/*
1428 * remove a Memory Controller instance 1131 * remove a Memory Controller instance
1429 */ 1132 */
1430static void edac_remove_sysfs_mci_device(struct mem_ctl_info *mci) 1133static void edac_remove_sysfs_mci_device(struct mem_ctl_info *mci)
1431{ 1134{
1432#ifndef DISABLE_EDAC_SYSFS
1433 int i; 1135 int i;
1434 1136
1435 debugf0("%s()\n", __func__); 1137 debugf0("%s()\n", __func__);
@@ -1447,7 +1149,6 @@ static void edac_remove_sysfs_mci_device(struct mem_ctl_info *mci)
1447 init_completion(&mci->kobj_complete); 1149 init_completion(&mci->kobj_complete);
1448 kobject_unregister(&mci->edac_mci_kobj); 1150 kobject_unregister(&mci->edac_mci_kobj);
1449 wait_for_completion(&mci->kobj_complete); 1151 wait_for_completion(&mci->kobj_complete);
1450#endif /* DISABLE_EDAC_SYSFS */
1451} 1152}
1452 1153
1453/* END OF sysfs data and methods */ 1154/* END OF sysfs data and methods */
diff --git a/drivers/isdn/hisax/asuscom.c b/drivers/isdn/hisax/asuscom.c
index a98c5e38bbbc..93ff941c48f1 100644
--- a/drivers/isdn/hisax/asuscom.c
+++ b/drivers/isdn/hisax/asuscom.c
@@ -297,7 +297,7 @@ Asus_card_msg(struct IsdnCardState *cs, int mt, void *arg)
297} 297}
298 298
299#ifdef __ISAPNP__ 299#ifdef __ISAPNP__
300static struct isapnp_device_id asus_ids[] __initdata = { 300static struct isapnp_device_id asus_ids[] __devinitdata = {
301 { ISAPNP_VENDOR('A', 'S', 'U'), ISAPNP_FUNCTION(0x1688), 301 { ISAPNP_VENDOR('A', 'S', 'U'), ISAPNP_FUNCTION(0x1688),
302 ISAPNP_VENDOR('A', 'S', 'U'), ISAPNP_FUNCTION(0x1688), 302 ISAPNP_VENDOR('A', 'S', 'U'), ISAPNP_FUNCTION(0x1688),
303 (unsigned long) "Asus1688 PnP" }, 303 (unsigned long) "Asus1688 PnP" },
@@ -313,11 +313,11 @@ static struct isapnp_device_id asus_ids[] __initdata = {
313 { 0, } 313 { 0, }
314}; 314};
315 315
316static struct isapnp_device_id *ipid __initdata = &asus_ids[0]; 316static struct isapnp_device_id *ipid __devinitdata = &asus_ids[0];
317static struct pnp_card *pnp_c __devinitdata = NULL; 317static struct pnp_card *pnp_c __devinitdata = NULL;
318#endif 318#endif
319 319
320int __init 320int __devinit
321setup_asuscom(struct IsdnCard *card) 321setup_asuscom(struct IsdnCard *card)
322{ 322{
323 int bytecnt; 323 int bytecnt;
diff --git a/drivers/isdn/hisax/avm_a1.c b/drivers/isdn/hisax/avm_a1.c
index 9a8b02557ff9..729e906bdc61 100644
--- a/drivers/isdn/hisax/avm_a1.c
+++ b/drivers/isdn/hisax/avm_a1.c
@@ -178,7 +178,7 @@ AVM_card_msg(struct IsdnCardState *cs, int mt, void *arg)
178 return(0); 178 return(0);
179} 179}
180 180
181int __init 181int __devinit
182setup_avm_a1(struct IsdnCard *card) 182setup_avm_a1(struct IsdnCard *card)
183{ 183{
184 u_char val; 184 u_char val;
diff --git a/drivers/isdn/hisax/avm_pci.c b/drivers/isdn/hisax/avm_pci.c
index 04f5917bf5a1..369afd3a3a4b 100644
--- a/drivers/isdn/hisax/avm_pci.c
+++ b/drivers/isdn/hisax/avm_pci.c
@@ -639,7 +639,7 @@ clear_pending_hdlc_ints(struct IsdnCardState *cs)
639} 639}
640#endif /* 0 */ 640#endif /* 0 */
641 641
642static void __init 642static void
643inithdlc(struct IsdnCardState *cs) 643inithdlc(struct IsdnCardState *cs)
644{ 644{
645 cs->bcs[0].BC_SetStack = setstack_hdlc; 645 cs->bcs[0].BC_SetStack = setstack_hdlc;
@@ -727,13 +727,13 @@ AVM_card_msg(struct IsdnCardState *cs, int mt, void *arg)
727} 727}
728 728
729#ifdef CONFIG_PCI 729#ifdef CONFIG_PCI
730static struct pci_dev *dev_avm __initdata = NULL; 730static struct pci_dev *dev_avm __devinitdata = NULL;
731#endif 731#endif
732#ifdef __ISAPNP__ 732#ifdef __ISAPNP__
733static struct pnp_card *pnp_avm_c __initdata = NULL; 733static struct pnp_card *pnp_avm_c __devinitdata = NULL;
734#endif 734#endif
735 735
736int __init 736int __devinit
737setup_avm_pcipnp(struct IsdnCard *card) 737setup_avm_pcipnp(struct IsdnCard *card)
738{ 738{
739 u_int val, ver; 739 u_int val, ver;
diff --git a/drivers/isdn/hisax/bkm_a4t.c b/drivers/isdn/hisax/bkm_a4t.c
index 3cf1f2421789..87a630128a6c 100644
--- a/drivers/isdn/hisax/bkm_a4t.c
+++ b/drivers/isdn/hisax/bkm_a4t.c
@@ -255,9 +255,9 @@ BKM_card_msg(struct IsdnCardState *cs, int mt, void *arg)
255 return (0); 255 return (0);
256} 256}
257 257
258static struct pci_dev *dev_a4t __initdata = NULL; 258static struct pci_dev *dev_a4t __devinitdata = NULL;
259 259
260int __init 260int __devinit
261setup_bkm_a4t(struct IsdnCard *card) 261setup_bkm_a4t(struct IsdnCard *card)
262{ 262{
263 struct IsdnCardState *cs = card->cs; 263 struct IsdnCardState *cs = card->cs;
diff --git a/drivers/isdn/hisax/bkm_a8.c b/drivers/isdn/hisax/bkm_a8.c
index 15681f3e73b8..dae090a9a489 100644
--- a/drivers/isdn/hisax/bkm_a8.c
+++ b/drivers/isdn/hisax/bkm_a8.c
@@ -260,7 +260,7 @@ BKM_card_msg(struct IsdnCardState *cs, int mt, void *arg)
260 return (0); 260 return (0);
261} 261}
262 262
263static int __init 263static int __devinit
264sct_alloc_io(u_int adr, u_int len) 264sct_alloc_io(u_int adr, u_int len)
265{ 265{
266 if (!request_region(adr, len, "scitel")) { 266 if (!request_region(adr, len, "scitel")) {
@@ -272,16 +272,16 @@ sct_alloc_io(u_int adr, u_int len)
272 return(0); 272 return(0);
273} 273}
274 274
275static struct pci_dev *dev_a8 __initdata = NULL; 275static struct pci_dev *dev_a8 __devinitdata = NULL;
276static u16 sub_vendor_id __initdata = 0; 276static u16 sub_vendor_id __devinitdata = 0;
277static u16 sub_sys_id __initdata = 0; 277static u16 sub_sys_id __devinitdata = 0;
278static u_char pci_bus __initdata = 0; 278static u_char pci_bus __devinitdata = 0;
279static u_char pci_device_fn __initdata = 0; 279static u_char pci_device_fn __devinitdata = 0;
280static u_char pci_irq __initdata = 0; 280static u_char pci_irq __devinitdata = 0;
281 281
282#endif /* CONFIG_PCI */ 282#endif /* CONFIG_PCI */
283 283
284int __init 284int __devinit
285setup_sct_quadro(struct IsdnCard *card) 285setup_sct_quadro(struct IsdnCard *card)
286{ 286{
287#ifdef CONFIG_PCI 287#ifdef CONFIG_PCI
diff --git a/drivers/isdn/hisax/config.c b/drivers/isdn/hisax/config.c
index 5333be5d2c47..e10350360f2f 100644
--- a/drivers/isdn/hisax/config.c
+++ b/drivers/isdn/hisax/config.c
@@ -1875,7 +1875,7 @@ static void EChannel_proc_rcv(struct hisax_d_if *d_if)
1875#ifdef CONFIG_PCI 1875#ifdef CONFIG_PCI
1876#include <linux/pci.h> 1876#include <linux/pci.h>
1877 1877
1878static struct pci_device_id hisax_pci_tbl[] __initdata = { 1878static struct pci_device_id hisax_pci_tbl[] __devinitdata = {
1879#ifdef CONFIG_HISAX_FRITZPCI 1879#ifdef CONFIG_HISAX_FRITZPCI
1880 {PCI_VENDOR_ID_AVM, PCI_DEVICE_ID_AVM_A1, PCI_ANY_ID, PCI_ANY_ID}, 1880 {PCI_VENDOR_ID_AVM, PCI_DEVICE_ID_AVM_A1, PCI_ANY_ID, PCI_ANY_ID},
1881#endif 1881#endif
diff --git a/drivers/isdn/hisax/diva.c b/drivers/isdn/hisax/diva.c
index 323a02ef3844..e294fa3918f3 100644
--- a/drivers/isdn/hisax/diva.c
+++ b/drivers/isdn/hisax/diva.c
@@ -887,13 +887,13 @@ Diva_card_msg(struct IsdnCardState *cs, int mt, void *arg)
887 return(0); 887 return(0);
888} 888}
889 889
890static struct pci_dev *dev_diva __initdata = NULL; 890static struct pci_dev *dev_diva __devinitdata = NULL;
891static struct pci_dev *dev_diva_u __initdata = NULL; 891static struct pci_dev *dev_diva_u __devinitdata = NULL;
892static struct pci_dev *dev_diva201 __initdata = NULL; 892static struct pci_dev *dev_diva201 __devinitdata = NULL;
893static struct pci_dev *dev_diva202 __initdata = NULL; 893static struct pci_dev *dev_diva202 __devinitdata = NULL;
894 894
895#ifdef __ISAPNP__ 895#ifdef __ISAPNP__
896static struct isapnp_device_id diva_ids[] __initdata = { 896static struct isapnp_device_id diva_ids[] __devinitdata = {
897 { ISAPNP_VENDOR('G', 'D', 'I'), ISAPNP_FUNCTION(0x51), 897 { ISAPNP_VENDOR('G', 'D', 'I'), ISAPNP_FUNCTION(0x51),
898 ISAPNP_VENDOR('G', 'D', 'I'), ISAPNP_FUNCTION(0x51), 898 ISAPNP_VENDOR('G', 'D', 'I'), ISAPNP_FUNCTION(0x51),
899 (unsigned long) "Diva picola" }, 899 (unsigned long) "Diva picola" },
@@ -915,12 +915,12 @@ static struct isapnp_device_id diva_ids[] __initdata = {
915 { 0, } 915 { 0, }
916}; 916};
917 917
918static struct isapnp_device_id *ipid __initdata = &diva_ids[0]; 918static struct isapnp_device_id *ipid __devinitdata = &diva_ids[0];
919static struct pnp_card *pnp_c __devinitdata = NULL; 919static struct pnp_card *pnp_c __devinitdata = NULL;
920#endif 920#endif
921 921
922 922
923int __init 923int __devinit
924setup_diva(struct IsdnCard *card) 924setup_diva(struct IsdnCard *card)
925{ 925{
926 int bytecnt = 8; 926 int bytecnt = 8;
diff --git a/drivers/isdn/hisax/enternow_pci.c b/drivers/isdn/hisax/enternow_pci.c
index 8fcbe2e7d765..76c7d29d1b2f 100644
--- a/drivers/isdn/hisax/enternow_pci.c
+++ b/drivers/isdn/hisax/enternow_pci.c
@@ -301,10 +301,10 @@ enpci_interrupt(int intno, void *dev_id, struct pt_regs *regs)
301} 301}
302 302
303 303
304static struct pci_dev *dev_netjet __initdata = NULL; 304static struct pci_dev *dev_netjet __devinitdata = NULL;
305 305
306/* called by config.c */ 306/* called by config.c */
307int __init 307int __devinit
308setup_enternow_pci(struct IsdnCard *card) 308setup_enternow_pci(struct IsdnCard *card)
309{ 309{
310 int bytecnt; 310 int bytecnt;
diff --git a/drivers/isdn/hisax/gazel.c b/drivers/isdn/hisax/gazel.c
index 3e7d92303582..fe2937267777 100644
--- a/drivers/isdn/hisax/gazel.c
+++ b/drivers/isdn/hisax/gazel.c
@@ -484,7 +484,7 @@ reserve_regions(struct IsdnCard *card, struct IsdnCardState *cs)
484 return 1; 484 return 1;
485} 485}
486 486
487static int __init 487static int __devinit
488setup_gazelisa(struct IsdnCard *card, struct IsdnCardState *cs) 488setup_gazelisa(struct IsdnCard *card, struct IsdnCardState *cs)
489{ 489{
490 printk(KERN_INFO "Gazel: ISA PnP card automatic recognition\n"); 490 printk(KERN_INFO "Gazel: ISA PnP card automatic recognition\n");
@@ -532,9 +532,9 @@ setup_gazelisa(struct IsdnCard *card, struct IsdnCardState *cs)
532 return (0); 532 return (0);
533} 533}
534 534
535static struct pci_dev *dev_tel __initdata = NULL; 535static struct pci_dev *dev_tel __devinitdata = NULL;
536 536
537static int __init 537static int __devinit
538setup_gazelpci(struct IsdnCardState *cs) 538setup_gazelpci(struct IsdnCardState *cs)
539{ 539{
540 u_int pci_ioaddr0 = 0, pci_ioaddr1 = 0; 540 u_int pci_ioaddr0 = 0, pci_ioaddr1 = 0;
@@ -621,7 +621,7 @@ setup_gazelpci(struct IsdnCardState *cs)
621 return (0); 621 return (0);
622} 622}
623 623
624int __init 624int __devinit
625setup_gazel(struct IsdnCard *card) 625setup_gazel(struct IsdnCard *card)
626{ 626{
627 struct IsdnCardState *cs = card->cs; 627 struct IsdnCardState *cs = card->cs;
diff --git a/drivers/isdn/hisax/hfc4s8s_l1.c b/drivers/isdn/hisax/hfc4s8s_l1.c
index 0f967b3df79d..3a5ca8a68fc4 100644
--- a/drivers/isdn/hisax/hfc4s8s_l1.c
+++ b/drivers/isdn/hisax/hfc4s8s_l1.c
@@ -1703,7 +1703,7 @@ hfc4s8s_module_init(void)
1703/* driver module exit : */ 1703/* driver module exit : */
1704/* release the HFC-4s/8s hardware */ 1704/* release the HFC-4s/8s hardware */
1705/*************************************/ 1705/*************************************/
1706static void 1706static void __exit
1707hfc4s8s_module_exit(void) 1707hfc4s8s_module_exit(void)
1708{ 1708{
1709 pci_unregister_driver(&hfc4s8s_driver); 1709 pci_unregister_driver(&hfc4s8s_driver);
diff --git a/drivers/isdn/hisax/hfc_2bds0.c b/drivers/isdn/hisax/hfc_2bds0.c
index 637a261c9312..6360e8214720 100644
--- a/drivers/isdn/hisax/hfc_2bds0.c
+++ b/drivers/isdn/hisax/hfc_2bds0.c
@@ -1015,7 +1015,7 @@ hfc_dbusy_timer(struct IsdnCardState *cs)
1015{ 1015{
1016} 1016}
1017 1017
1018static unsigned int __init 1018static unsigned int
1019*init_send_hfcd(int cnt) 1019*init_send_hfcd(int cnt)
1020{ 1020{
1021 int i, *send; 1021 int i, *send;
@@ -1030,7 +1030,7 @@ static unsigned int __init
1030 return(send); 1030 return(send);
1031} 1031}
1032 1032
1033void __init 1033void
1034init2bds0(struct IsdnCardState *cs) 1034init2bds0(struct IsdnCardState *cs)
1035{ 1035{
1036 cs->setstack_d = setstack_hfcd; 1036 cs->setstack_d = setstack_hfcd;
diff --git a/drivers/isdn/hisax/hfc_2bs0.c b/drivers/isdn/hisax/hfc_2bs0.c
index c964539cc43e..d0520ad30677 100644
--- a/drivers/isdn/hisax/hfc_2bs0.c
+++ b/drivers/isdn/hisax/hfc_2bs0.c
@@ -551,7 +551,7 @@ setstack_hfc(struct PStack *st, struct BCState *bcs)
551 return (0); 551 return (0);
552} 552}
553 553
554static void __init 554static void
555init_send(struct BCState *bcs) 555init_send(struct BCState *bcs)
556{ 556{
557 int i; 557 int i;
@@ -565,7 +565,7 @@ init_send(struct BCState *bcs)
565 bcs->hw.hfc.send[i] = 0x1fff; 565 bcs->hw.hfc.send[i] = 0x1fff;
566} 566}
567 567
568void __init 568void
569inithfc(struct IsdnCardState *cs) 569inithfc(struct IsdnCardState *cs)
570{ 570{
571 init_send(&cs->bcs[0]); 571 init_send(&cs->bcs[0]);
diff --git a/drivers/isdn/hisax/hfc_pci.c b/drivers/isdn/hisax/hfc_pci.c
index 7241e73879ba..1df60ca9481f 100644
--- a/drivers/isdn/hisax/hfc_pci.c
+++ b/drivers/isdn/hisax/hfc_pci.c
@@ -1581,7 +1581,7 @@ hfcpci_bh(struct IsdnCardState *cs)
1581/********************************/ 1581/********************************/
1582/* called for card init message */ 1582/* called for card init message */
1583/********************************/ 1583/********************************/
1584static void __init 1584static void
1585inithfcpci(struct IsdnCardState *cs) 1585inithfcpci(struct IsdnCardState *cs)
1586{ 1586{
1587 cs->bcs[0].BC_SetStack = setstack_2b; 1587 cs->bcs[0].BC_SetStack = setstack_2b;
@@ -1638,11 +1638,11 @@ hfcpci_card_msg(struct IsdnCardState *cs, int mt, void *arg)
1638 1638
1639 1639
1640/* this variable is used as card index when more than one cards are present */ 1640/* this variable is used as card index when more than one cards are present */
1641static struct pci_dev *dev_hfcpci __initdata = NULL; 1641static struct pci_dev *dev_hfcpci __devinitdata = NULL;
1642 1642
1643#endif /* CONFIG_PCI */ 1643#endif /* CONFIG_PCI */
1644 1644
1645int __init 1645int __devinit
1646setup_hfcpci(struct IsdnCard *card) 1646setup_hfcpci(struct IsdnCard *card)
1647{ 1647{
1648 u_long flags; 1648 u_long flags;
diff --git a/drivers/isdn/hisax/hfcscard.c b/drivers/isdn/hisax/hfcscard.c
index 86ab1c13f6b1..4e7f472877e9 100644
--- a/drivers/isdn/hisax/hfcscard.c
+++ b/drivers/isdn/hisax/hfcscard.c
@@ -139,7 +139,7 @@ hfcs_card_msg(struct IsdnCardState *cs, int mt, void *arg)
139} 139}
140 140
141#ifdef __ISAPNP__ 141#ifdef __ISAPNP__
142static struct isapnp_device_id hfc_ids[] __initdata = { 142static struct isapnp_device_id hfc_ids[] __devinitdata = {
143 { ISAPNP_VENDOR('A', 'N', 'X'), ISAPNP_FUNCTION(0x1114), 143 { ISAPNP_VENDOR('A', 'N', 'X'), ISAPNP_FUNCTION(0x1114),
144 ISAPNP_VENDOR('A', 'N', 'X'), ISAPNP_FUNCTION(0x1114), 144 ISAPNP_VENDOR('A', 'N', 'X'), ISAPNP_FUNCTION(0x1114),
145 (unsigned long) "Acer P10" }, 145 (unsigned long) "Acer P10" },
@@ -164,11 +164,11 @@ static struct isapnp_device_id hfc_ids[] __initdata = {
164 { 0, } 164 { 0, }
165}; 165};
166 166
167static struct isapnp_device_id *ipid __initdata = &hfc_ids[0]; 167static struct isapnp_device_id *ipid __devinitdata = &hfc_ids[0];
168static struct pnp_card *pnp_c __devinitdata = NULL; 168static struct pnp_card *pnp_c __devinitdata = NULL;
169#endif 169#endif
170 170
171int __init 171int __devinit
172setup_hfcs(struct IsdnCard *card) 172setup_hfcs(struct IsdnCard *card)
173{ 173{
174 struct IsdnCardState *cs = card->cs; 174 struct IsdnCardState *cs = card->cs;
diff --git a/drivers/isdn/hisax/icc.c b/drivers/isdn/hisax/icc.c
index c615752b96aa..2cf7b665609e 100644
--- a/drivers/isdn/hisax/icc.c
+++ b/drivers/isdn/hisax/icc.c
@@ -24,10 +24,10 @@
24#define DBUSY_TIMER_VALUE 80 24#define DBUSY_TIMER_VALUE 80
25#define ARCOFI_USE 0 25#define ARCOFI_USE 0
26 26
27static char *ICCVer[] __initdata = 27static char *ICCVer[] =
28{"2070 A1/A3", "2070 B1", "2070 B2/B3", "2070 V2.4"}; 28{"2070 A1/A3", "2070 B1", "2070 B2/B3", "2070 V2.4"};
29 29
30void __init 30void
31ICCVersion(struct IsdnCardState *cs, char *s) 31ICCVersion(struct IsdnCardState *cs, char *s)
32{ 32{
33 int val; 33 int val;
@@ -613,7 +613,7 @@ dbusy_timer_handler(struct IsdnCardState *cs)
613 } 613 }
614} 614}
615 615
616void __init 616void
617initicc(struct IsdnCardState *cs) 617initicc(struct IsdnCardState *cs)
618{ 618{
619 cs->setstack_d = setstack_icc; 619 cs->setstack_d = setstack_icc;
@@ -646,7 +646,7 @@ initicc(struct IsdnCardState *cs)
646 ph_command(cs, ICC_CMD_DI); 646 ph_command(cs, ICC_CMD_DI);
647} 647}
648 648
649void __init 649void
650clear_pending_icc_ints(struct IsdnCardState *cs) 650clear_pending_icc_ints(struct IsdnCardState *cs)
651{ 651{
652 int val, eval; 652 int val, eval;
diff --git a/drivers/isdn/hisax/icc.h b/drivers/isdn/hisax/icc.h
index b3bb3d5de532..e7f593967e43 100644
--- a/drivers/isdn/hisax/icc.h
+++ b/drivers/isdn/hisax/icc.h
@@ -65,7 +65,7 @@
65#define ICC_IND_AIL 0xE 65#define ICC_IND_AIL 0xE
66#define ICC_IND_DC 0xF 66#define ICC_IND_DC 0xF
67 67
68extern void __init ICCVersion(struct IsdnCardState *cs, char *s); 68extern void ICCVersion(struct IsdnCardState *cs, char *s);
69extern void initicc(struct IsdnCardState *cs); 69extern void initicc(struct IsdnCardState *cs);
70extern void icc_interrupt(struct IsdnCardState *cs, u_char val); 70extern void icc_interrupt(struct IsdnCardState *cs, u_char val);
71extern void clear_pending_icc_ints(struct IsdnCardState *cs); 71extern void clear_pending_icc_ints(struct IsdnCardState *cs);
diff --git a/drivers/isdn/hisax/ipacx.c b/drivers/isdn/hisax/ipacx.c
index df5fc92a89b2..00afd5538909 100644
--- a/drivers/isdn/hisax/ipacx.c
+++ b/drivers/isdn/hisax/ipacx.c
@@ -38,8 +38,8 @@ static void dbusy_timer_handler(struct IsdnCardState *cs);
38static void dch_empty_fifo(struct IsdnCardState *cs, int count); 38static void dch_empty_fifo(struct IsdnCardState *cs, int count);
39static void dch_fill_fifo(struct IsdnCardState *cs); 39static void dch_fill_fifo(struct IsdnCardState *cs);
40static inline void dch_int(struct IsdnCardState *cs); 40static inline void dch_int(struct IsdnCardState *cs);
41static void __devinit dch_setstack(struct PStack *st, struct IsdnCardState *cs); 41static void dch_setstack(struct PStack *st, struct IsdnCardState *cs);
42static void __devinit dch_init(struct IsdnCardState *cs); 42static void dch_init(struct IsdnCardState *cs);
43static void bch_l2l1(struct PStack *st, int pr, void *arg); 43static void bch_l2l1(struct PStack *st, int pr, void *arg);
44static void bch_empty_fifo(struct BCState *bcs, int count); 44static void bch_empty_fifo(struct BCState *bcs, int count);
45static void bch_fill_fifo(struct BCState *bcs); 45static void bch_fill_fifo(struct BCState *bcs);
@@ -48,8 +48,8 @@ static void bch_mode(struct BCState *bcs, int mode, int bc);
48static void bch_close_state(struct BCState *bcs); 48static void bch_close_state(struct BCState *bcs);
49static int bch_open_state(struct IsdnCardState *cs, struct BCState *bcs); 49static int bch_open_state(struct IsdnCardState *cs, struct BCState *bcs);
50static int bch_setstack(struct PStack *st, struct BCState *bcs); 50static int bch_setstack(struct PStack *st, struct BCState *bcs);
51static void __devinit bch_init(struct IsdnCardState *cs, int hscx); 51static void bch_init(struct IsdnCardState *cs, int hscx);
52static void __init clear_pending_ints(struct IsdnCardState *cs); 52static void clear_pending_ints(struct IsdnCardState *cs);
53 53
54//---------------------------------------------------------- 54//----------------------------------------------------------
55// Issue Layer 1 command to chip 55// Issue Layer 1 command to chip
@@ -408,7 +408,7 @@ dch_int(struct IsdnCardState *cs)
408 408
409//---------------------------------------------------------- 409//----------------------------------------------------------
410//---------------------------------------------------------- 410//----------------------------------------------------------
411static void __devinit 411static void
412dch_setstack(struct PStack *st, struct IsdnCardState *cs) 412dch_setstack(struct PStack *st, struct IsdnCardState *cs)
413{ 413{
414 st->l1.l1hw = dch_l2l1; 414 st->l1.l1hw = dch_l2l1;
@@ -416,7 +416,7 @@ dch_setstack(struct PStack *st, struct IsdnCardState *cs)
416 416
417//---------------------------------------------------------- 417//----------------------------------------------------------
418//---------------------------------------------------------- 418//----------------------------------------------------------
419static void __devinit 419static void
420dch_init(struct IsdnCardState *cs) 420dch_init(struct IsdnCardState *cs)
421{ 421{
422 printk(KERN_INFO "HiSax: IPACX ISDN driver v0.1.0\n"); 422 printk(KERN_INFO "HiSax: IPACX ISDN driver v0.1.0\n");
@@ -823,7 +823,7 @@ bch_setstack(struct PStack *st, struct BCState *bcs)
823 823
824//---------------------------------------------------------- 824//----------------------------------------------------------
825//---------------------------------------------------------- 825//----------------------------------------------------------
826static void __devinit 826static void
827bch_init(struct IsdnCardState *cs, int hscx) 827bch_init(struct IsdnCardState *cs, int hscx)
828{ 828{
829 cs->bcs[hscx].BC_SetStack = bch_setstack; 829 cs->bcs[hscx].BC_SetStack = bch_setstack;
@@ -861,7 +861,7 @@ interrupt_ipacx(struct IsdnCardState *cs)
861//---------------------------------------------------------- 861//----------------------------------------------------------
862// Clears chip interrupt status 862// Clears chip interrupt status
863//---------------------------------------------------------- 863//----------------------------------------------------------
864static void __init 864static void
865clear_pending_ints(struct IsdnCardState *cs) 865clear_pending_ints(struct IsdnCardState *cs)
866{ 866{
867 int ista; 867 int ista;
@@ -883,7 +883,7 @@ clear_pending_ints(struct IsdnCardState *cs)
883// Does chip configuration work 883// Does chip configuration work
884// Work to do depends on bit mask in part 884// Work to do depends on bit mask in part
885//---------------------------------------------------------- 885//----------------------------------------------------------
886void __init 886void
887init_ipacx(struct IsdnCardState *cs, int part) 887init_ipacx(struct IsdnCardState *cs, int part)
888{ 888{
889 if (part &1) { // initialise chip 889 if (part &1) { // initialise chip
diff --git a/drivers/isdn/hisax/isurf.c b/drivers/isdn/hisax/isurf.c
index 33747afc984d..715a1a8cd694 100644
--- a/drivers/isdn/hisax/isurf.c
+++ b/drivers/isdn/hisax/isurf.c
@@ -196,10 +196,10 @@ isurf_auxcmd(struct IsdnCardState *cs, isdn_ctrl *ic) {
196} 196}
197 197
198#ifdef __ISAPNP__ 198#ifdef __ISAPNP__
199static struct pnp_card *pnp_c __initdata = NULL; 199static struct pnp_card *pnp_c __devinitdata = NULL;
200#endif 200#endif
201 201
202int __init 202int __devinit
203setup_isurf(struct IsdnCard *card) 203setup_isurf(struct IsdnCard *card)
204{ 204{
205 int ver; 205 int ver;
diff --git a/drivers/isdn/hisax/ix1_micro.c b/drivers/isdn/hisax/ix1_micro.c
index 908a7e144421..39717506c678 100644
--- a/drivers/isdn/hisax/ix1_micro.c
+++ b/drivers/isdn/hisax/ix1_micro.c
@@ -210,7 +210,7 @@ ix1_card_msg(struct IsdnCardState *cs, int mt, void *arg)
210} 210}
211 211
212#ifdef __ISAPNP__ 212#ifdef __ISAPNP__
213static struct isapnp_device_id itk_ids[] __initdata = { 213static struct isapnp_device_id itk_ids[] __devinitdata = {
214 { ISAPNP_VENDOR('I', 'T', 'K'), ISAPNP_FUNCTION(0x25), 214 { ISAPNP_VENDOR('I', 'T', 'K'), ISAPNP_FUNCTION(0x25),
215 ISAPNP_VENDOR('I', 'T', 'K'), ISAPNP_FUNCTION(0x25), 215 ISAPNP_VENDOR('I', 'T', 'K'), ISAPNP_FUNCTION(0x25),
216 (unsigned long) "ITK micro 2" }, 216 (unsigned long) "ITK micro 2" },
@@ -220,12 +220,12 @@ static struct isapnp_device_id itk_ids[] __initdata = {
220 { 0, } 220 { 0, }
221}; 221};
222 222
223static struct isapnp_device_id *ipid __initdata = &itk_ids[0]; 223static struct isapnp_device_id *ipid __devinitdata = &itk_ids[0];
224static struct pnp_card *pnp_c __devinitdata = NULL; 224static struct pnp_card *pnp_c __devinitdata = NULL;
225#endif 225#endif
226 226
227 227
228int __init 228int __devinit
229setup_ix1micro(struct IsdnCard *card) 229setup_ix1micro(struct IsdnCard *card)
230{ 230{
231 struct IsdnCardState *cs = card->cs; 231 struct IsdnCardState *cs = card->cs;
diff --git a/drivers/isdn/hisax/jade.c b/drivers/isdn/hisax/jade.c
index 2659fecc2674..43d61d1bc5b6 100644
--- a/drivers/isdn/hisax/jade.c
+++ b/drivers/isdn/hisax/jade.c
@@ -19,7 +19,7 @@
19#include <linux/interrupt.h> 19#include <linux/interrupt.h>
20 20
21 21
22int __init 22int
23JadeVersion(struct IsdnCardState *cs, char *s) 23JadeVersion(struct IsdnCardState *cs, char *s)
24{ 24{
25 int ver,i; 25 int ver,i;
@@ -253,7 +253,7 @@ setstack_jade(struct PStack *st, struct BCState *bcs)
253 return (0); 253 return (0);
254} 254}
255 255
256void __init 256void
257clear_pending_jade_ints(struct IsdnCardState *cs) 257clear_pending_jade_ints(struct IsdnCardState *cs)
258{ 258{
259 int val; 259 int val;
@@ -279,7 +279,7 @@ clear_pending_jade_ints(struct IsdnCardState *cs)
279 cs->BC_Write_Reg(cs, 1, jade_HDLC_IMR, 0xF8); 279 cs->BC_Write_Reg(cs, 1, jade_HDLC_IMR, 0xF8);
280} 280}
281 281
282void __init 282void
283initjade(struct IsdnCardState *cs) 283initjade(struct IsdnCardState *cs)
284{ 284{
285 cs->bcs[0].BC_SetStack = setstack_jade; 285 cs->bcs[0].BC_SetStack = setstack_jade;
diff --git a/drivers/isdn/hisax/mic.c b/drivers/isdn/hisax/mic.c
index fe11f226b285..8c82519593a8 100644
--- a/drivers/isdn/hisax/mic.c
+++ b/drivers/isdn/hisax/mic.c
@@ -189,7 +189,7 @@ mic_card_msg(struct IsdnCardState *cs, int mt, void *arg)
189 return(0); 189 return(0);
190} 190}
191 191
192int __init 192int __devinit
193setup_mic(struct IsdnCard *card) 193setup_mic(struct IsdnCard *card)
194{ 194{
195 int bytecnt; 195 int bytecnt;
diff --git a/drivers/isdn/hisax/netjet.c b/drivers/isdn/hisax/netjet.c
index 47a47ef0968b..38f648f9b0ed 100644
--- a/drivers/isdn/hisax/netjet.c
+++ b/drivers/isdn/hisax/netjet.c
@@ -909,7 +909,7 @@ setstack_tiger(struct PStack *st, struct BCState *bcs)
909} 909}
910 910
911 911
912void __init 912void
913inittiger(struct IsdnCardState *cs) 913inittiger(struct IsdnCardState *cs)
914{ 914{
915 if (!(cs->bcs[0].hw.tiger.send = kmalloc(NETJET_DMA_TXSIZE * sizeof(unsigned int), 915 if (!(cs->bcs[0].hw.tiger.send = kmalloc(NETJET_DMA_TXSIZE * sizeof(unsigned int),
diff --git a/drivers/isdn/hisax/niccy.c b/drivers/isdn/hisax/niccy.c
index 79a97b1c3812..489022bdef7b 100644
--- a/drivers/isdn/hisax/niccy.c
+++ b/drivers/isdn/hisax/niccy.c
@@ -232,12 +232,12 @@ niccy_card_msg(struct IsdnCardState *cs, int mt, void *arg)
232 return(0); 232 return(0);
233} 233}
234 234
235static struct pci_dev *niccy_dev __initdata = NULL; 235static struct pci_dev *niccy_dev __devinitdata = NULL;
236#ifdef __ISAPNP__ 236#ifdef __ISAPNP__
237static struct pnp_card *pnp_c __devinitdata = NULL; 237static struct pnp_card *pnp_c __devinitdata = NULL;
238#endif 238#endif
239 239
240int __init 240int __devinit
241setup_niccy(struct IsdnCard *card) 241setup_niccy(struct IsdnCard *card)
242{ 242{
243 struct IsdnCardState *cs = card->cs; 243 struct IsdnCardState *cs = card->cs;
diff --git a/drivers/isdn/hisax/nj_s.c b/drivers/isdn/hisax/nj_s.c
index e5b900a6fa0b..80025fd890f4 100644
--- a/drivers/isdn/hisax/nj_s.c
+++ b/drivers/isdn/hisax/nj_s.c
@@ -148,9 +148,9 @@ NETjet_S_card_msg(struct IsdnCardState *cs, int mt, void *arg)
148 return(0); 148 return(0);
149} 149}
150 150
151static struct pci_dev *dev_netjet __initdata = NULL; 151static struct pci_dev *dev_netjet __devinitdata = NULL;
152 152
153int __init 153int __devinit
154setup_netjet_s(struct IsdnCard *card) 154setup_netjet_s(struct IsdnCard *card)
155{ 155{
156 int bytecnt,cfg; 156 int bytecnt,cfg;
diff --git a/drivers/isdn/hisax/nj_u.c b/drivers/isdn/hisax/nj_u.c
index 7002b09936d4..37497162d539 100644
--- a/drivers/isdn/hisax/nj_u.c
+++ b/drivers/isdn/hisax/nj_u.c
@@ -128,9 +128,9 @@ NETjet_U_card_msg(struct IsdnCardState *cs, int mt, void *arg)
128 return(0); 128 return(0);
129} 129}
130 130
131static struct pci_dev *dev_netjet __initdata = NULL; 131static struct pci_dev *dev_netjet __devinitdata = NULL;
132 132
133int __init 133int __devinit
134setup_netjet_u(struct IsdnCard *card) 134setup_netjet_u(struct IsdnCard *card)
135{ 135{
136 int bytecnt; 136 int bytecnt;
diff --git a/drivers/isdn/hisax/s0box.c b/drivers/isdn/hisax/s0box.c
index 7b63085ea6e5..e76042d323ea 100644
--- a/drivers/isdn/hisax/s0box.c
+++ b/drivers/isdn/hisax/s0box.c
@@ -211,7 +211,7 @@ S0Box_card_msg(struct IsdnCardState *cs, int mt, void *arg)
211 return(0); 211 return(0);
212} 212}
213 213
214int __init 214int __devinit
215setup_s0box(struct IsdnCard *card) 215setup_s0box(struct IsdnCard *card)
216{ 216{
217 struct IsdnCardState *cs = card->cs; 217 struct IsdnCardState *cs = card->cs;
diff --git a/drivers/isdn/hisax/saphir.c b/drivers/isdn/hisax/saphir.c
index 821776e1561a..d943d365890b 100644
--- a/drivers/isdn/hisax/saphir.c
+++ b/drivers/isdn/hisax/saphir.c
@@ -241,7 +241,7 @@ saphir_card_msg(struct IsdnCardState *cs, int mt, void *arg)
241} 241}
242 242
243 243
244int __init 244int __devinit
245setup_saphir(struct IsdnCard *card) 245setup_saphir(struct IsdnCard *card)
246{ 246{
247 struct IsdnCardState *cs = card->cs; 247 struct IsdnCardState *cs = card->cs;
diff --git a/drivers/isdn/hisax/sportster.c b/drivers/isdn/hisax/sportster.c
index cdf35dc564c4..a49b694eb730 100644
--- a/drivers/isdn/hisax/sportster.c
+++ b/drivers/isdn/hisax/sportster.c
@@ -184,7 +184,7 @@ Sportster_card_msg(struct IsdnCardState *cs, int mt, void *arg)
184 return(0); 184 return(0);
185} 185}
186 186
187static int __init 187static int __devinit
188get_io_range(struct IsdnCardState *cs) 188get_io_range(struct IsdnCardState *cs)
189{ 189{
190 int i, j, adr; 190 int i, j, adr;
@@ -209,7 +209,7 @@ get_io_range(struct IsdnCardState *cs)
209 } 209 }
210} 210}
211 211
212int __init 212int __devinit
213setup_sportster(struct IsdnCard *card) 213setup_sportster(struct IsdnCard *card)
214{ 214{
215 struct IsdnCardState *cs = card->cs; 215 struct IsdnCardState *cs = card->cs;
diff --git a/drivers/isdn/hisax/teleint.c b/drivers/isdn/hisax/teleint.c
index a2b1816af37a..e94dc6f5bd62 100644
--- a/drivers/isdn/hisax/teleint.c
+++ b/drivers/isdn/hisax/teleint.c
@@ -261,7 +261,7 @@ TeleInt_card_msg(struct IsdnCardState *cs, int mt, void *arg)
261 return(0); 261 return(0);
262} 262}
263 263
264int __init 264int __devinit
265setup_TeleInt(struct IsdnCard *card) 265setup_TeleInt(struct IsdnCard *card)
266{ 266{
267 struct IsdnCardState *cs = card->cs; 267 struct IsdnCardState *cs = card->cs;
diff --git a/drivers/isdn/hisax/teles0.c b/drivers/isdn/hisax/teles0.c
index 2b7df8f98233..f94af0930a17 100644
--- a/drivers/isdn/hisax/teles0.c
+++ b/drivers/isdn/hisax/teles0.c
@@ -265,7 +265,7 @@ Teles_card_msg(struct IsdnCardState *cs, int mt, void *arg)
265 return(0); 265 return(0);
266} 266}
267 267
268int __init 268int __devinit
269setup_teles0(struct IsdnCard *card) 269setup_teles0(struct IsdnCard *card)
270{ 270{
271 u_char val; 271 u_char val;
diff --git a/drivers/isdn/hisax/telespci.c b/drivers/isdn/hisax/telespci.c
index 9382cdf04d8d..dca446865f24 100644
--- a/drivers/isdn/hisax/telespci.c
+++ b/drivers/isdn/hisax/telespci.c
@@ -284,9 +284,9 @@ TelesPCI_card_msg(struct IsdnCardState *cs, int mt, void *arg)
284 return(0); 284 return(0);
285} 285}
286 286
287static struct pci_dev *dev_tel __initdata = NULL; 287static struct pci_dev *dev_tel __devinitdata = NULL;
288 288
289int __init 289int __devinit
290setup_telespci(struct IsdnCard *card) 290setup_telespci(struct IsdnCard *card)
291{ 291{
292 struct IsdnCardState *cs = card->cs; 292 struct IsdnCardState *cs = card->cs;
diff --git a/drivers/isdn/hisax/w6692.c b/drivers/isdn/hisax/w6692.c
index 6c68419c05ff..0595293b8659 100644
--- a/drivers/isdn/hisax/w6692.c
+++ b/drivers/isdn/hisax/w6692.c
@@ -44,11 +44,11 @@ static const char *w6692_revision = "$Revision: 1.18.2.4 $";
44 44
45#define DBUSY_TIMER_VALUE 80 45#define DBUSY_TIMER_VALUE 80
46 46
47static char *W6692Ver[] __initdata = 47static char *W6692Ver[] =
48{"W6692 V00", "W6692 V01", "W6692 V10", 48{"W6692 V00", "W6692 V01", "W6692 V10",
49 "W6692 V11"}; 49 "W6692 V11"};
50 50
51static void __init 51static void
52W6692Version(struct IsdnCardState *cs, char *s) 52W6692Version(struct IsdnCardState *cs, char *s)
53{ 53{
54 int val; 54 int val;
@@ -897,7 +897,7 @@ static void resetW6692(struct IsdnCardState *cs)
897 } 897 }
898} 898}
899 899
900static void __init initW6692(struct IsdnCardState *cs, int part) 900static void initW6692(struct IsdnCardState *cs, int part)
901{ 901{
902 if (part & 1) { 902 if (part & 1) {
903 cs->setstack_d = setstack_W6692; 903 cs->setstack_d = setstack_W6692;
@@ -992,9 +992,9 @@ w6692_card_msg(struct IsdnCardState *cs, int mt, void *arg)
992 992
993static int id_idx ; 993static int id_idx ;
994 994
995static struct pci_dev *dev_w6692 __initdata = NULL; 995static struct pci_dev *dev_w6692 __devinitdata = NULL;
996 996
997int __init 997int __devinit
998setup_w6692(struct IsdnCard *card) 998setup_w6692(struct IsdnCard *card)
999{ 999{
1000 struct IsdnCardState *cs = card->cs; 1000 struct IsdnCardState *cs = card->cs;
diff --git a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c
index 9f6c6375ff75..c3d79eef9e32 100644
--- a/drivers/isdn/i4l/isdn_common.c
+++ b/drivers/isdn/i4l/isdn_common.c
@@ -1059,7 +1059,7 @@ isdn_info_update(void)
1059static ssize_t 1059static ssize_t
1060isdn_read(struct file *file, char __user *buf, size_t count, loff_t * off) 1060isdn_read(struct file *file, char __user *buf, size_t count, loff_t * off)
1061{ 1061{
1062 uint minor = MINOR(file->f_dentry->d_inode->i_rdev); 1062 uint minor = iminor(file->f_dentry->d_inode);
1063 int len = 0; 1063 int len = 0;
1064 int drvidx; 1064 int drvidx;
1065 int chidx; 1065 int chidx;
@@ -1163,7 +1163,7 @@ isdn_read(struct file *file, char __user *buf, size_t count, loff_t * off)
1163static ssize_t 1163static ssize_t
1164isdn_write(struct file *file, const char __user *buf, size_t count, loff_t * off) 1164isdn_write(struct file *file, const char __user *buf, size_t count, loff_t * off)
1165{ 1165{
1166 uint minor = MINOR(file->f_dentry->d_inode->i_rdev); 1166 uint minor = iminor(file->f_dentry->d_inode);
1167 int drvidx; 1167 int drvidx;
1168 int chidx; 1168 int chidx;
1169 int retval; 1169 int retval;
@@ -1225,7 +1225,7 @@ static unsigned int
1225isdn_poll(struct file *file, poll_table * wait) 1225isdn_poll(struct file *file, poll_table * wait)
1226{ 1226{
1227 unsigned int mask = 0; 1227 unsigned int mask = 0;
1228 unsigned int minor = MINOR(file->f_dentry->d_inode->i_rdev); 1228 unsigned int minor = iminor(file->f_dentry->d_inode);
1229 int drvidx = isdn_minor2drv(minor - ISDN_MINOR_CTRL); 1229 int drvidx = isdn_minor2drv(minor - ISDN_MINOR_CTRL);
1230 1230
1231 lock_kernel(); 1231 lock_kernel();
@@ -1266,7 +1266,7 @@ isdn_poll(struct file *file, poll_table * wait)
1266static int 1266static int
1267isdn_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg) 1267isdn_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg)
1268{ 1268{
1269 uint minor = MINOR(inode->i_rdev); 1269 uint minor = iminor(inode);
1270 isdn_ctrl c; 1270 isdn_ctrl c;
1271 int drvidx; 1271 int drvidx;
1272 int chidx; 1272 int chidx;
@@ -1717,7 +1717,7 @@ isdn_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg)
1717static int 1717static int
1718isdn_open(struct inode *ino, struct file *filep) 1718isdn_open(struct inode *ino, struct file *filep)
1719{ 1719{
1720 uint minor = MINOR(ino->i_rdev); 1720 uint minor = iminor(ino);
1721 int drvidx; 1721 int drvidx;
1722 int chidx; 1722 int chidx;
1723 int retval = -ENODEV; 1723 int retval = -ENODEV;
@@ -1779,7 +1779,7 @@ isdn_open(struct inode *ino, struct file *filep)
1779static int 1779static int
1780isdn_close(struct inode *ino, struct file *filep) 1780isdn_close(struct inode *ino, struct file *filep)
1781{ 1781{
1782 uint minor = MINOR(ino->i_rdev); 1782 uint minor = iminor(ino);
1783 1783
1784 lock_kernel(); 1784 lock_kernel();
1785 if (minor == ISDN_MINOR_STATUS) { 1785 if (minor == ISDN_MINOR_STATUS) {
diff --git a/drivers/isdn/i4l/isdn_ppp.c b/drivers/isdn/i4l/isdn_ppp.c
index 29e7667ec962..119412d6bd15 100644
--- a/drivers/isdn/i4l/isdn_ppp.c
+++ b/drivers/isdn/i4l/isdn_ppp.c
@@ -667,7 +667,7 @@ isdn_ppp_poll(struct file *file, poll_table * wait)
667 667
668 if (is->debug & 0x2) 668 if (is->debug & 0x2)
669 printk(KERN_DEBUG "isdn_ppp_poll: minor: %d\n", 669 printk(KERN_DEBUG "isdn_ppp_poll: minor: %d\n",
670 MINOR(file->f_dentry->d_inode->i_rdev)); 670 iminor(file->f_dentry->d_inode));
671 671
672 /* just registers wait_queue hook. This doesn't really wait. */ 672 /* just registers wait_queue hook. This doesn't really wait. */
673 poll_wait(file, &is->wq, wait); 673 poll_wait(file, &is->wq, wait);
diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
index 96509989e921..9c39b98d5a5b 100644
--- a/drivers/leds/Kconfig
+++ b/drivers/leds/Kconfig
@@ -69,6 +69,13 @@ config LEDS_AMS_DELTA
69 help 69 help
70 This option enables support for the LEDs on Amstrad Delta (E3). 70 This option enables support for the LEDs on Amstrad Delta (E3).
71 71
72config LEDS_NET48XX
73 tristate "LED Support for Soekris net48xx series Error LED"
74 depends on LEDS_CLASS && SCx200_GPIO
75 help
76 This option enables support for the Soekris net4801 and net4826 error
77 LED.
78
72comment "LED Triggers" 79comment "LED Triggers"
73 80
74config LEDS_TRIGGERS 81config LEDS_TRIGGERS
diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile
index 88d3b6eaa6a2..6aa2aed7539d 100644
--- a/drivers/leds/Makefile
+++ b/drivers/leds/Makefile
@@ -12,6 +12,7 @@ obj-$(CONFIG_LEDS_IXP4XX) += leds-ixp4xx-gpio.o
12obj-$(CONFIG_LEDS_TOSA) += leds-tosa.o 12obj-$(CONFIG_LEDS_TOSA) += leds-tosa.o
13obj-$(CONFIG_LEDS_S3C24XX) += leds-s3c24xx.o 13obj-$(CONFIG_LEDS_S3C24XX) += leds-s3c24xx.o
14obj-$(CONFIG_LEDS_AMS_DELTA) += leds-ams-delta.o 14obj-$(CONFIG_LEDS_AMS_DELTA) += leds-ams-delta.o
15obj-$(CONFIG_LEDS_NET48XX) += leds-net48xx.o
15 16
16# LED Triggers 17# LED Triggers
17obj-$(CONFIG_LEDS_TRIGGER_TIMER) += ledtrig-timer.o 18obj-$(CONFIG_LEDS_TRIGGER_TIMER) += ledtrig-timer.o
diff --git a/drivers/leds/leds-net48xx.c b/drivers/leds/leds-net48xx.c
new file mode 100644
index 000000000000..35ee52f9b79e
--- /dev/null
+++ b/drivers/leds/leds-net48xx.c
@@ -0,0 +1,115 @@
1/*
2 * LEDs driver for Soekris net48xx
3 *
4 * Copyright (C) 2006 Chris Boot <bootc@bootc.net>
5 *
6 * Based on leds-ams-delta.c
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12
13#include <linux/kernel.h>
14#include <linux/init.h>
15#include <linux/platform_device.h>
16#include <linux/leds.h>
17#include <linux/err.h>
18#include <asm/io.h>
19#include <linux/scx200_gpio.h>
20
21#define NET48XX_ERROR_LED_GPIO 20
22
23static struct platform_device *pdev;
24
25static void net48xx_error_led_set(struct led_classdev *led_cdev,
26 enum led_brightness value)
27{
28 if (value)
29 scx200_gpio_set_high(NET48XX_ERROR_LED_GPIO);
30 else
31 scx200_gpio_set_low(NET48XX_ERROR_LED_GPIO);
32}
33
34static struct led_classdev net48xx_error_led = {
35 .name = "net48xx:error",
36 .brightness_set = net48xx_error_led_set,
37};
38
39#ifdef CONFIG_PM
40static int net48xx_led_suspend(struct platform_device *dev,
41 pm_message_t state)
42{
43 led_classdev_suspend(&net48xx_error_led);
44 return 0;
45}
46
47static int net48xx_led_resume(struct platform_device *dev)
48{
49 led_classdev_resume(&net48xx_error_led);
50 return 0;
51}
52#else
53#define net48xx_led_suspend NULL
54#define net48xx_led_resume NULL
55#endif
56
57static int net48xx_led_probe(struct platform_device *pdev)
58{
59 return led_classdev_register(&pdev->dev, &net48xx_error_led);
60}
61
62static int net48xx_led_remove(struct platform_device *pdev)
63{
64 led_classdev_unregister(&net48xx_error_led);
65 return 0;
66}
67
68static struct platform_driver net48xx_led_driver = {
69 .driver.owner = THIS_MODULE,
70 .probe = net48xx_led_probe,
71 .remove = net48xx_led_remove,
72 .suspend = net48xx_led_suspend,
73 .resume = net48xx_led_resume,
74 .driver = {
75 .name = "net48xx-led",
76 },
77};
78
79static int __init net48xx_led_init(void)
80{
81 int ret;
82
83 if (!scx200_gpio_present()) {
84 ret = -ENODEV;
85 goto out;
86 }
87
88 ret = platform_driver_register(&net48xx_led_driver);
89 if (ret < 0)
90 goto out;
91
92 pdev = platform_device_register_simple("net48xx-led", -1, NULL, 0);
93 if (IS_ERR(pdev)) {
94 ret = PTR_ERR(pdev);
95 platform_driver_unregister(&net48xx_led_driver);
96 goto out;
97 }
98
99out:
100 return ret;
101}
102
103static void __exit net48xx_led_exit(void)
104{
105 platform_device_unregister(pdev);
106 platform_driver_unregister(&net48xx_led_driver);
107}
108
109module_init(net48xx_led_init);
110module_exit(net48xx_led_exit);
111
112MODULE_AUTHOR("Chris Boot <bootc@bootc.net>");
113MODULE_DESCRIPTION("Soekris net48xx LED driver");
114MODULE_LICENSE("GPL");
115
diff --git a/drivers/macintosh/Kconfig b/drivers/macintosh/Kconfig
index 54f3f6b94efc..f5fe7fb4b3ad 100644
--- a/drivers/macintosh/Kconfig
+++ b/drivers/macintosh/Kconfig
@@ -113,7 +113,10 @@ config PMAC_MEDIABAY
113 113
114config PMAC_BACKLIGHT 114config PMAC_BACKLIGHT
115 bool "Backlight control for LCD screens" 115 bool "Backlight control for LCD screens"
116 depends on ADB_PMU && (BROKEN || !PPC64) 116 depends on ADB_PMU && FB = y && (BROKEN || !PPC64)
117 select FB_BACKLIGHT
118 select BACKLIGHT_CLASS_DEVICE
119 select BACKLIGHT_LCD_SUPPORT
117 help 120 help
118 Say Y here to enable Macintosh specific extensions of the generic 121 Say Y here to enable Macintosh specific extensions of the generic
119 backlight code. With this enabled, the brightness keys on older 122 backlight code. With this enabled, the brightness keys on older
diff --git a/drivers/macintosh/macio_asic.c b/drivers/macintosh/macio_asic.c
index 80c0c665b5f6..82657bc86d19 100644
--- a/drivers/macintosh/macio_asic.c
+++ b/drivers/macintosh/macio_asic.c
@@ -330,7 +330,7 @@ static void macio_create_fixup_irq(struct macio_dev *dev, int index,
330{ 330{
331 unsigned int irq; 331 unsigned int irq;
332 332
333 irq = irq_create_mapping(NULL, line, 0); 333 irq = irq_create_mapping(NULL, line);
334 if (irq != NO_IRQ) { 334 if (irq != NO_IRQ) {
335 dev->interrupt[index].start = irq; 335 dev->interrupt[index].start = irq;
336 dev->interrupt[index].flags = IORESOURCE_IRQ; 336 dev->interrupt[index].flags = IORESOURCE_IRQ;
diff --git a/drivers/macintosh/smu.c b/drivers/macintosh/smu.c
index f139a74696fe..00ef46898147 100644
--- a/drivers/macintosh/smu.c
+++ b/drivers/macintosh/smu.c
@@ -75,9 +75,11 @@ struct smu_device {
75 struct of_device *of_dev; 75 struct of_device *of_dev;
76 int doorbell; /* doorbell gpio */ 76 int doorbell; /* doorbell gpio */
77 u32 __iomem *db_buf; /* doorbell buffer */ 77 u32 __iomem *db_buf; /* doorbell buffer */
78 int db_irq; 78 struct device_node *db_node;
79 unsigned int db_irq;
79 int msg; 80 int msg;
80 int msg_irq; 81 struct device_node *msg_node;
82 unsigned int msg_irq;
81 struct smu_cmd_buf *cmd_buf; /* command buffer virtual */ 83 struct smu_cmd_buf *cmd_buf; /* command buffer virtual */
82 u32 cmd_buf_abs; /* command buffer absolute */ 84 u32 cmd_buf_abs; /* command buffer absolute */
83 struct list_head cmd_list; 85 struct list_head cmd_list;
@@ -93,6 +95,7 @@ struct smu_device {
93 */ 95 */
94static struct smu_device *smu; 96static struct smu_device *smu;
95static DEFINE_MUTEX(smu_part_access); 97static DEFINE_MUTEX(smu_part_access);
98static int smu_irq_inited;
96 99
97static void smu_i2c_retry(unsigned long data); 100static void smu_i2c_retry(unsigned long data);
98 101
@@ -257,6 +260,10 @@ int smu_queue_cmd(struct smu_cmd *cmd)
257 smu_start_cmd(); 260 smu_start_cmd();
258 spin_unlock_irqrestore(&smu->lock, flags); 261 spin_unlock_irqrestore(&smu->lock, flags);
259 262
263 /* Workaround for early calls when irq isn't available */
264 if (!smu_irq_inited || smu->db_irq == NO_IRQ)
265 smu_spinwait_cmd(cmd);
266
260 return 0; 267 return 0;
261} 268}
262EXPORT_SYMBOL(smu_queue_cmd); 269EXPORT_SYMBOL(smu_queue_cmd);
@@ -478,14 +485,15 @@ int __init smu_init (void)
478 smu->cmd_buf_abs = (u32)smu_cmdbuf_abs; 485 smu->cmd_buf_abs = (u32)smu_cmdbuf_abs;
479 smu->cmd_buf = (struct smu_cmd_buf *)abs_to_virt(smu_cmdbuf_abs); 486 smu->cmd_buf = (struct smu_cmd_buf *)abs_to_virt(smu_cmdbuf_abs);
480 487
481 np = of_find_node_by_name(NULL, "smu-doorbell"); 488 smu->db_node = of_find_node_by_name(NULL, "smu-doorbell");
482 if (np == NULL) { 489 if (smu->db_node == NULL) {
483 printk(KERN_ERR "SMU: Can't find doorbell GPIO !\n"); 490 printk(KERN_ERR "SMU: Can't find doorbell GPIO !\n");
484 goto fail; 491 goto fail;
485 } 492 }
486 data = (u32 *)get_property(np, "reg", NULL); 493 data = (u32 *)get_property(smu->db_node, "reg", NULL);
487 if (data == NULL) { 494 if (data == NULL) {
488 of_node_put(np); 495 of_node_put(smu->db_node);
496 smu->db_node = NULL;
489 printk(KERN_ERR "SMU: Can't find doorbell GPIO address !\n"); 497 printk(KERN_ERR "SMU: Can't find doorbell GPIO address !\n");
490 goto fail; 498 goto fail;
491 } 499 }
@@ -497,25 +505,21 @@ int __init smu_init (void)
497 smu->doorbell = *data; 505 smu->doorbell = *data;
498 if (smu->doorbell < 0x50) 506 if (smu->doorbell < 0x50)
499 smu->doorbell += 0x50; 507 smu->doorbell += 0x50;
500 smu->db_irq = irq_of_parse_and_map(np, 0);
501
502 of_node_put(np);
503 508
504 /* Now look for the smu-interrupt GPIO */ 509 /* Now look for the smu-interrupt GPIO */
505 do { 510 do {
506 np = of_find_node_by_name(NULL, "smu-interrupt"); 511 smu->msg_node = of_find_node_by_name(NULL, "smu-interrupt");
507 if (np == NULL) 512 if (smu->msg_node == NULL)
508 break; 513 break;
509 data = (u32 *)get_property(np, "reg", NULL); 514 data = (u32 *)get_property(smu->msg_node, "reg", NULL);
510 if (data == NULL) { 515 if (data == NULL) {
511 of_node_put(np); 516 of_node_put(smu->msg_node);
517 smu->msg_node = NULL;
512 break; 518 break;
513 } 519 }
514 smu->msg = *data; 520 smu->msg = *data;
515 if (smu->msg < 0x50) 521 if (smu->msg < 0x50)
516 smu->msg += 0x50; 522 smu->msg += 0x50;
517 smu->msg_irq = irq_of_parse_and_map(np, 0);
518 of_node_put(np);
519 } while(0); 523 } while(0);
520 524
521 /* Doorbell buffer is currently hard-coded, I didn't find a proper 525 /* Doorbell buffer is currently hard-coded, I didn't find a proper
@@ -547,6 +551,19 @@ static int smu_late_init(void)
547 smu->i2c_timer.function = smu_i2c_retry; 551 smu->i2c_timer.function = smu_i2c_retry;
548 smu->i2c_timer.data = (unsigned long)smu; 552 smu->i2c_timer.data = (unsigned long)smu;
549 553
554 if (smu->db_node) {
555 smu->db_irq = irq_of_parse_and_map(smu->db_node, 0);
556 if (smu->db_irq == NO_IRQ)
557 printk(KERN_ERR "smu: failed to map irq for node %s\n",
558 smu->db_node->full_name);
559 }
560 if (smu->msg_node) {
561 smu->msg_irq = irq_of_parse_and_map(smu->msg_node, 0);
562 if (smu->msg_irq == NO_IRQ)
563 printk(KERN_ERR "smu: failed to map irq for node %s\n",
564 smu->msg_node->full_name);
565 }
566
550 /* 567 /*
551 * Try to request the interrupts 568 * Try to request the interrupts
552 */ 569 */
@@ -571,6 +588,7 @@ static int smu_late_init(void)
571 } 588 }
572 } 589 }
573 590
591 smu_irq_inited = 1;
574 return 0; 592 return 0;
575} 593}
576/* This has to be before arch_initcall as the low i2c stuff relies on the 594/* This has to be before arch_initcall as the low i2c stuff relies on the
@@ -742,6 +760,11 @@ static void smu_i2c_low_completion(struct smu_cmd *scmd, void *misc)
742 if (fail && --cmd->retries > 0) { 760 if (fail && --cmd->retries > 0) {
743 DPRINTK("SMU: i2c failure, starting timer...\n"); 761 DPRINTK("SMU: i2c failure, starting timer...\n");
744 BUG_ON(cmd != smu->cmd_i2c_cur); 762 BUG_ON(cmd != smu->cmd_i2c_cur);
763 if (!smu_irq_inited) {
764 mdelay(5);
765 smu_i2c_retry(0);
766 return;
767 }
745 mod_timer(&smu->i2c_timer, jiffies + msecs_to_jiffies(5)); 768 mod_timer(&smu->i2c_timer, jiffies + msecs_to_jiffies(5));
746 return; 769 return;
747 } 770 }
diff --git a/drivers/md/md.c b/drivers/md/md.c
index e4e161372a3e..b6d16022a53e 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -110,7 +110,7 @@ static ctl_table raid_table[] = {
110 .procname = "speed_limit_min", 110 .procname = "speed_limit_min",
111 .data = &sysctl_speed_limit_min, 111 .data = &sysctl_speed_limit_min,
112 .maxlen = sizeof(int), 112 .maxlen = sizeof(int),
113 .mode = 0644, 113 .mode = S_IRUGO|S_IWUSR,
114 .proc_handler = &proc_dointvec, 114 .proc_handler = &proc_dointvec,
115 }, 115 },
116 { 116 {
@@ -118,7 +118,7 @@ static ctl_table raid_table[] = {
118 .procname = "speed_limit_max", 118 .procname = "speed_limit_max",
119 .data = &sysctl_speed_limit_max, 119 .data = &sysctl_speed_limit_max,
120 .maxlen = sizeof(int), 120 .maxlen = sizeof(int),
121 .mode = 0644, 121 .mode = S_IRUGO|S_IWUSR,
122 .proc_handler = &proc_dointvec, 122 .proc_handler = &proc_dointvec,
123 }, 123 },
124 { .ctl_name = 0 } 124 { .ctl_name = 0 }
@@ -129,7 +129,7 @@ static ctl_table raid_dir_table[] = {
129 .ctl_name = DEV_RAID, 129 .ctl_name = DEV_RAID,
130 .procname = "raid", 130 .procname = "raid",
131 .maxlen = 0, 131 .maxlen = 0,
132 .mode = 0555, 132 .mode = S_IRUGO|S_IXUGO,
133 .child = raid_table, 133 .child = raid_table,
134 }, 134 },
135 { .ctl_name = 0 } 135 { .ctl_name = 0 }
@@ -1062,6 +1062,11 @@ static int super_1_load(mdk_rdev_t *rdev, mdk_rdev_t *refdev, int minor_version)
1062 if (rdev->sb_size & bmask) 1062 if (rdev->sb_size & bmask)
1063 rdev-> sb_size = (rdev->sb_size | bmask)+1; 1063 rdev-> sb_size = (rdev->sb_size | bmask)+1;
1064 1064
1065 if (sb->level == cpu_to_le32(LEVEL_MULTIPATH))
1066 rdev->desc_nr = -1;
1067 else
1068 rdev->desc_nr = le32_to_cpu(sb->dev_number);
1069
1065 if (refdev == 0) 1070 if (refdev == 0)
1066 ret = 1; 1071 ret = 1;
1067 else { 1072 else {
@@ -1171,7 +1176,6 @@ static int super_1_validate(mddev_t *mddev, mdk_rdev_t *rdev)
1171 } 1176 }
1172 if (mddev->level != LEVEL_MULTIPATH) { 1177 if (mddev->level != LEVEL_MULTIPATH) {
1173 int role; 1178 int role;
1174 rdev->desc_nr = le32_to_cpu(sb->dev_number);
1175 role = le16_to_cpu(sb->dev_roles[rdev->desc_nr]); 1179 role = le16_to_cpu(sb->dev_roles[rdev->desc_nr]);
1176 switch(role) { 1180 switch(role) {
1177 case 0xffff: /* spare */ 1181 case 0xffff: /* spare */
@@ -1779,8 +1783,8 @@ state_store(mdk_rdev_t *rdev, const char *buf, size_t len)
1779 } 1783 }
1780 return err ? err : len; 1784 return err ? err : len;
1781} 1785}
1782static struct rdev_sysfs_entry 1786static struct rdev_sysfs_entry rdev_state =
1783rdev_state = __ATTR(state, 0644, state_show, state_store); 1787__ATTR(state, S_IRUGO|S_IWUSR, state_show, state_store);
1784 1788
1785static ssize_t 1789static ssize_t
1786super_show(mdk_rdev_t *rdev, char *page) 1790super_show(mdk_rdev_t *rdev, char *page)
@@ -1811,7 +1815,7 @@ errors_store(mdk_rdev_t *rdev, const char *buf, size_t len)
1811 return -EINVAL; 1815 return -EINVAL;
1812} 1816}
1813static struct rdev_sysfs_entry rdev_errors = 1817static struct rdev_sysfs_entry rdev_errors =
1814__ATTR(errors, 0644, errors_show, errors_store); 1818__ATTR(errors, S_IRUGO|S_IWUSR, errors_show, errors_store);
1815 1819
1816static ssize_t 1820static ssize_t
1817slot_show(mdk_rdev_t *rdev, char *page) 1821slot_show(mdk_rdev_t *rdev, char *page)
@@ -1845,7 +1849,7 @@ slot_store(mdk_rdev_t *rdev, const char *buf, size_t len)
1845 1849
1846 1850
1847static struct rdev_sysfs_entry rdev_slot = 1851static struct rdev_sysfs_entry rdev_slot =
1848__ATTR(slot, 0644, slot_show, slot_store); 1852__ATTR(slot, S_IRUGO|S_IWUSR, slot_show, slot_store);
1849 1853
1850static ssize_t 1854static ssize_t
1851offset_show(mdk_rdev_t *rdev, char *page) 1855offset_show(mdk_rdev_t *rdev, char *page)
@@ -1867,7 +1871,7 @@ offset_store(mdk_rdev_t *rdev, const char *buf, size_t len)
1867} 1871}
1868 1872
1869static struct rdev_sysfs_entry rdev_offset = 1873static struct rdev_sysfs_entry rdev_offset =
1870__ATTR(offset, 0644, offset_show, offset_store); 1874__ATTR(offset, S_IRUGO|S_IWUSR, offset_show, offset_store);
1871 1875
1872static ssize_t 1876static ssize_t
1873rdev_size_show(mdk_rdev_t *rdev, char *page) 1877rdev_size_show(mdk_rdev_t *rdev, char *page)
@@ -1891,7 +1895,7 @@ rdev_size_store(mdk_rdev_t *rdev, const char *buf, size_t len)
1891} 1895}
1892 1896
1893static struct rdev_sysfs_entry rdev_size = 1897static struct rdev_sysfs_entry rdev_size =
1894__ATTR(size, 0644, rdev_size_show, rdev_size_store); 1898__ATTR(size, S_IRUGO|S_IWUSR, rdev_size_show, rdev_size_store);
1895 1899
1896static struct attribute *rdev_default_attrs[] = { 1900static struct attribute *rdev_default_attrs[] = {
1897 &rdev_state.attr, 1901 &rdev_state.attr,
@@ -1922,6 +1926,8 @@ rdev_attr_store(struct kobject *kobj, struct attribute *attr,
1922 1926
1923 if (!entry->store) 1927 if (!entry->store)
1924 return -EIO; 1928 return -EIO;
1929 if (!capable(CAP_SYS_ADMIN))
1930 return -EACCES;
1925 return entry->store(rdev, page, length); 1931 return entry->store(rdev, page, length);
1926} 1932}
1927 1933
@@ -2128,7 +2134,7 @@ safe_delay_store(mddev_t *mddev, const char *cbuf, size_t len)
2128 return len; 2134 return len;
2129} 2135}
2130static struct md_sysfs_entry md_safe_delay = 2136static struct md_sysfs_entry md_safe_delay =
2131__ATTR(safe_mode_delay, 0644,safe_delay_show, safe_delay_store); 2137__ATTR(safe_mode_delay, S_IRUGO|S_IWUSR,safe_delay_show, safe_delay_store);
2132 2138
2133static ssize_t 2139static ssize_t
2134level_show(mddev_t *mddev, char *page) 2140level_show(mddev_t *mddev, char *page)
@@ -2163,7 +2169,7 @@ level_store(mddev_t *mddev, const char *buf, size_t len)
2163} 2169}
2164 2170
2165static struct md_sysfs_entry md_level = 2171static struct md_sysfs_entry md_level =
2166__ATTR(level, 0644, level_show, level_store); 2172__ATTR(level, S_IRUGO|S_IWUSR, level_show, level_store);
2167 2173
2168 2174
2169static ssize_t 2175static ssize_t
@@ -2188,7 +2194,7 @@ layout_store(mddev_t *mddev, const char *buf, size_t len)
2188 return len; 2194 return len;
2189} 2195}
2190static struct md_sysfs_entry md_layout = 2196static struct md_sysfs_entry md_layout =
2191__ATTR(layout, 0655, layout_show, layout_store); 2197__ATTR(layout, S_IRUGO|S_IWUSR, layout_show, layout_store);
2192 2198
2193 2199
2194static ssize_t 2200static ssize_t
@@ -2219,7 +2225,7 @@ raid_disks_store(mddev_t *mddev, const char *buf, size_t len)
2219 return rv ? rv : len; 2225 return rv ? rv : len;
2220} 2226}
2221static struct md_sysfs_entry md_raid_disks = 2227static struct md_sysfs_entry md_raid_disks =
2222__ATTR(raid_disks, 0644, raid_disks_show, raid_disks_store); 2228__ATTR(raid_disks, S_IRUGO|S_IWUSR, raid_disks_show, raid_disks_store);
2223 2229
2224static ssize_t 2230static ssize_t
2225chunk_size_show(mddev_t *mddev, char *page) 2231chunk_size_show(mddev_t *mddev, char *page)
@@ -2243,7 +2249,7 @@ chunk_size_store(mddev_t *mddev, const char *buf, size_t len)
2243 return len; 2249 return len;
2244} 2250}
2245static struct md_sysfs_entry md_chunk_size = 2251static struct md_sysfs_entry md_chunk_size =
2246__ATTR(chunk_size, 0644, chunk_size_show, chunk_size_store); 2252__ATTR(chunk_size, S_IRUGO|S_IWUSR, chunk_size_show, chunk_size_store);
2247 2253
2248static ssize_t 2254static ssize_t
2249resync_start_show(mddev_t *mddev, char *page) 2255resync_start_show(mddev_t *mddev, char *page)
@@ -2267,7 +2273,7 @@ resync_start_store(mddev_t *mddev, const char *buf, size_t len)
2267 return len; 2273 return len;
2268} 2274}
2269static struct md_sysfs_entry md_resync_start = 2275static struct md_sysfs_entry md_resync_start =
2270__ATTR(resync_start, 0644, resync_start_show, resync_start_store); 2276__ATTR(resync_start, S_IRUGO|S_IWUSR, resync_start_show, resync_start_store);
2271 2277
2272/* 2278/*
2273 * The array state can be: 2279 * The array state can be:
@@ -2437,7 +2443,8 @@ array_state_store(mddev_t *mddev, const char *buf, size_t len)
2437 else 2443 else
2438 return len; 2444 return len;
2439} 2445}
2440static struct md_sysfs_entry md_array_state = __ATTR(array_state, 0644, array_state_show, array_state_store); 2446static struct md_sysfs_entry md_array_state =
2447__ATTR(array_state, S_IRUGO|S_IWUSR, array_state_show, array_state_store);
2441 2448
2442static ssize_t 2449static ssize_t
2443null_show(mddev_t *mddev, char *page) 2450null_show(mddev_t *mddev, char *page)
@@ -2497,7 +2504,7 @@ new_dev_store(mddev_t *mddev, const char *buf, size_t len)
2497} 2504}
2498 2505
2499static struct md_sysfs_entry md_new_device = 2506static struct md_sysfs_entry md_new_device =
2500__ATTR(new_dev, 0200, null_show, new_dev_store); 2507__ATTR(new_dev, S_IWUSR, null_show, new_dev_store);
2501 2508
2502static ssize_t 2509static ssize_t
2503size_show(mddev_t *mddev, char *page) 2510size_show(mddev_t *mddev, char *page)
@@ -2535,7 +2542,7 @@ size_store(mddev_t *mddev, const char *buf, size_t len)
2535} 2542}
2536 2543
2537static struct md_sysfs_entry md_size = 2544static struct md_sysfs_entry md_size =
2538__ATTR(component_size, 0644, size_show, size_store); 2545__ATTR(component_size, S_IRUGO|S_IWUSR, size_show, size_store);
2539 2546
2540 2547
2541/* Metdata version. 2548/* Metdata version.
@@ -2583,7 +2590,7 @@ metadata_store(mddev_t *mddev, const char *buf, size_t len)
2583} 2590}
2584 2591
2585static struct md_sysfs_entry md_metadata = 2592static struct md_sysfs_entry md_metadata =
2586__ATTR(metadata_version, 0644, metadata_show, metadata_store); 2593__ATTR(metadata_version, S_IRUGO|S_IWUSR, metadata_show, metadata_store);
2587 2594
2588static ssize_t 2595static ssize_t
2589action_show(mddev_t *mddev, char *page) 2596action_show(mddev_t *mddev, char *page)
@@ -2651,12 +2658,11 @@ mismatch_cnt_show(mddev_t *mddev, char *page)
2651 (unsigned long long) mddev->resync_mismatches); 2658 (unsigned long long) mddev->resync_mismatches);
2652} 2659}
2653 2660
2654static struct md_sysfs_entry 2661static struct md_sysfs_entry md_scan_mode =
2655md_scan_mode = __ATTR(sync_action, S_IRUGO|S_IWUSR, action_show, action_store); 2662__ATTR(sync_action, S_IRUGO|S_IWUSR, action_show, action_store);
2656 2663
2657 2664
2658static struct md_sysfs_entry 2665static struct md_sysfs_entry md_mismatches = __ATTR_RO(mismatch_cnt);
2659md_mismatches = __ATTR_RO(mismatch_cnt);
2660 2666
2661static ssize_t 2667static ssize_t
2662sync_min_show(mddev_t *mddev, char *page) 2668sync_min_show(mddev_t *mddev, char *page)
@@ -2715,15 +2721,14 @@ static ssize_t
2715sync_speed_show(mddev_t *mddev, char *page) 2721sync_speed_show(mddev_t *mddev, char *page)
2716{ 2722{
2717 unsigned long resync, dt, db; 2723 unsigned long resync, dt, db;
2718 resync = (mddev->curr_resync - atomic_read(&mddev->recovery_active)); 2724 resync = (mddev->curr_mark_cnt - atomic_read(&mddev->recovery_active));
2719 dt = ((jiffies - mddev->resync_mark) / HZ); 2725 dt = ((jiffies - mddev->resync_mark) / HZ);
2720 if (!dt) dt++; 2726 if (!dt) dt++;
2721 db = resync - (mddev->resync_mark_cnt); 2727 db = resync - (mddev->resync_mark_cnt);
2722 return sprintf(page, "%ld\n", db/dt/2); /* K/sec */ 2728 return sprintf(page, "%ld\n", db/dt/2); /* K/sec */
2723} 2729}
2724 2730
2725static struct md_sysfs_entry 2731static struct md_sysfs_entry md_sync_speed = __ATTR_RO(sync_speed);
2726md_sync_speed = __ATTR_RO(sync_speed);
2727 2732
2728static ssize_t 2733static ssize_t
2729sync_completed_show(mddev_t *mddev, char *page) 2734sync_completed_show(mddev_t *mddev, char *page)
@@ -2739,8 +2744,7 @@ sync_completed_show(mddev_t *mddev, char *page)
2739 return sprintf(page, "%lu / %lu\n", resync, max_blocks); 2744 return sprintf(page, "%lu / %lu\n", resync, max_blocks);
2740} 2745}
2741 2746
2742static struct md_sysfs_entry 2747static struct md_sysfs_entry md_sync_completed = __ATTR_RO(sync_completed);
2743md_sync_completed = __ATTR_RO(sync_completed);
2744 2748
2745static ssize_t 2749static ssize_t
2746suspend_lo_show(mddev_t *mddev, char *page) 2750suspend_lo_show(mddev_t *mddev, char *page)
@@ -2857,6 +2861,8 @@ md_attr_store(struct kobject *kobj, struct attribute *attr,
2857 2861
2858 if (!entry->store) 2862 if (!entry->store)
2859 return -EIO; 2863 return -EIO;
2864 if (!capable(CAP_SYS_ADMIN))
2865 return -EACCES;
2860 rv = mddev_lock(mddev); 2866 rv = mddev_lock(mddev);
2861 if (!rv) { 2867 if (!rv) {
2862 rv = entry->store(mddev, page, length); 2868 rv = entry->store(mddev, page, length);
@@ -3091,7 +3097,6 @@ static int do_md_run(mddev_t * mddev)
3091 } 3097 }
3092 3098
3093 set_bit(MD_RECOVERY_NEEDED, &mddev->recovery); 3099 set_bit(MD_RECOVERY_NEEDED, &mddev->recovery);
3094 md_wakeup_thread(mddev->thread);
3095 3100
3096 if (mddev->sb_dirty) 3101 if (mddev->sb_dirty)
3097 md_update_sb(mddev); 3102 md_update_sb(mddev);
@@ -3112,7 +3117,7 @@ static int do_md_run(mddev_t * mddev)
3112 * start recovery here. If we leave it to md_check_recovery, 3117 * start recovery here. If we leave it to md_check_recovery,
3113 * it will remove the drives and not do the right thing 3118 * it will remove the drives and not do the right thing
3114 */ 3119 */
3115 if (mddev->degraded) { 3120 if (mddev->degraded && !mddev->sync_thread) {
3116 struct list_head *rtmp; 3121 struct list_head *rtmp;
3117 int spares = 0; 3122 int spares = 0;
3118 ITERATE_RDEV(mddev,rdev,rtmp) 3123 ITERATE_RDEV(mddev,rdev,rtmp)
@@ -3133,10 +3138,11 @@ static int do_md_run(mddev_t * mddev)
3133 mdname(mddev)); 3138 mdname(mddev));
3134 /* leave the spares where they are, it shouldn't hurt */ 3139 /* leave the spares where they are, it shouldn't hurt */
3135 mddev->recovery = 0; 3140 mddev->recovery = 0;
3136 } else 3141 }
3137 md_wakeup_thread(mddev->sync_thread);
3138 } 3142 }
3139 } 3143 }
3144 md_wakeup_thread(mddev->thread);
3145 md_wakeup_thread(mddev->sync_thread); /* possibly kick off a reshape */
3140 3146
3141 mddev->changed = 1; 3147 mddev->changed = 1;
3142 md_new_event(mddev); 3148 md_new_event(mddev);
@@ -4586,6 +4592,8 @@ void md_error(mddev_t *mddev, mdk_rdev_t *rdev)
4586 __builtin_return_address(0),__builtin_return_address(1), 4592 __builtin_return_address(0),__builtin_return_address(1),
4587 __builtin_return_address(2),__builtin_return_address(3)); 4593 __builtin_return_address(2),__builtin_return_address(3));
4588*/ 4594*/
4595 if (!mddev->pers)
4596 return;
4589 if (!mddev->pers->error_handler) 4597 if (!mddev->pers->error_handler)
4590 return; 4598 return;
4591 mddev->pers->error_handler(mddev,rdev); 4599 mddev->pers->error_handler(mddev,rdev);
@@ -4683,12 +4691,13 @@ static void status_resync(struct seq_file *seq, mddev_t * mddev)
4683 */ 4691 */
4684 dt = ((jiffies - mddev->resync_mark) / HZ); 4692 dt = ((jiffies - mddev->resync_mark) / HZ);
4685 if (!dt) dt++; 4693 if (!dt) dt++;
4686 db = resync - (mddev->resync_mark_cnt/2); 4694 db = (mddev->curr_mark_cnt - atomic_read(&mddev->recovery_active))
4687 rt = (dt * ((unsigned long)(max_blocks-resync) / (db/100+1)))/100; 4695 - mddev->resync_mark_cnt;
4696 rt = (dt * ((unsigned long)(max_blocks-resync) / (db/2/100+1)))/100;
4688 4697
4689 seq_printf(seq, " finish=%lu.%lumin", rt / 60, (rt % 60)/6); 4698 seq_printf(seq, " finish=%lu.%lumin", rt / 60, (rt % 60)/6);
4690 4699
4691 seq_printf(seq, " speed=%ldK/sec", db/dt); 4700 seq_printf(seq, " speed=%ldK/sec", db/2/dt);
4692} 4701}
4693 4702
4694static void *md_seq_start(struct seq_file *seq, loff_t *pos) 4703static void *md_seq_start(struct seq_file *seq, loff_t *pos)
@@ -5199,6 +5208,7 @@ void md_do_sync(mddev_t *mddev)
5199 5208
5200 j += sectors; 5209 j += sectors;
5201 if (j>1) mddev->curr_resync = j; 5210 if (j>1) mddev->curr_resync = j;
5211 mddev->curr_mark_cnt = io_sectors;
5202 if (last_check == 0) 5212 if (last_check == 0)
5203 /* this is the earliers that rebuilt will be 5213 /* this is the earliers that rebuilt will be
5204 * visible in /proc/mdstat 5214 * visible in /proc/mdstat
@@ -5645,8 +5655,8 @@ static int set_ro(const char *val, struct kernel_param *kp)
5645 return -EINVAL; 5655 return -EINVAL;
5646} 5656}
5647 5657
5648module_param_call(start_ro, set_ro, get_ro, NULL, 0600); 5658module_param_call(start_ro, set_ro, get_ro, NULL, S_IRUSR|S_IWUSR);
5649module_param(start_dirty_degraded, int, 0644); 5659module_param(start_dirty_degraded, int, S_IRUGO|S_IWUSR);
5650 5660
5651 5661
5652EXPORT_SYMBOL(register_md_personality); 5662EXPORT_SYMBOL(register_md_personality);
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index cead918578a7..1efe22a2d041 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -1145,7 +1145,7 @@ static int end_sync_write(struct bio *bio, unsigned int bytes_done, int error)
1145 long sectors_to_go = r1_bio->sectors; 1145 long sectors_to_go = r1_bio->sectors;
1146 /* make sure these bits doesn't get cleared. */ 1146 /* make sure these bits doesn't get cleared. */
1147 do { 1147 do {
1148 bitmap_end_sync(mddev->bitmap, r1_bio->sector, 1148 bitmap_end_sync(mddev->bitmap, s,
1149 &sync_blocks, 1); 1149 &sync_blocks, 1);
1150 s += sync_blocks; 1150 s += sync_blocks;
1151 sectors_to_go -= sync_blocks; 1151 sectors_to_go -= sync_blocks;
@@ -1509,6 +1509,9 @@ static void raid1d(mddev_t *mddev)
1509 s<<9, conf->tmppage, READ) == 0) 1509 s<<9, conf->tmppage, READ) == 0)
1510 /* Well, this device is dead */ 1510 /* Well, this device is dead */
1511 md_error(mddev, rdev); 1511 md_error(mddev, rdev);
1512 else
1513 printk(KERN_INFO "raid1:%s: read error corrected (%d sectors at %llu on %s)\n",
1514 mdname(mddev), s, (unsigned long long)(sect + rdev->data_offset), bdevname(rdev->bdev, b));
1512 } 1515 }
1513 } 1516 }
1514 } else { 1517 } else {
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index 7f636283a1ba..016ddb831c9b 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -1492,6 +1492,10 @@ static void raid10d(mddev_t *mddev)
1492 s<<9, conf->tmppage, READ) == 0) 1492 s<<9, conf->tmppage, READ) == 0)
1493 /* Well, this device is dead */ 1493 /* Well, this device is dead */
1494 md_error(mddev, rdev); 1494 md_error(mddev, rdev);
1495 else
1496 printk(KERN_INFO "raid10:%s: read error corrected (%d sectors at %llu on %s)\n",
1497 mdname(mddev), s, (unsigned long long)(sect+rdev->data_offset), bdevname(rdev->bdev, b));
1498
1495 rdev_dec_pending(rdev, mddev); 1499 rdev_dec_pending(rdev, mddev);
1496 rcu_read_lock(); 1500 rcu_read_lock();
1497 } 1501 }
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 7433871f4b3a..450066007160 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -18,6 +18,30 @@
18 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */ 19 */
20 20
21/*
22 * BITMAP UNPLUGGING:
23 *
24 * The sequencing for updating the bitmap reliably is a little
25 * subtle (and I got it wrong the first time) so it deserves some
26 * explanation.
27 *
28 * We group bitmap updates into batches. Each batch has a number.
29 * We may write out several batches at once, but that isn't very important.
30 * conf->bm_write is the number of the last batch successfully written.
31 * conf->bm_flush is the number of the last batch that was closed to
32 * new additions.
33 * When we discover that we will need to write to any block in a stripe
34 * (in add_stripe_bio) we update the in-memory bitmap and record in sh->bm_seq
35 * the number of the batch it will be in. This is bm_flush+1.
36 * When we are ready to do a write, if that batch hasn't been written yet,
37 * we plug the array and queue the stripe for later.
38 * When an unplug happens, we increment bm_flush, thus closing the current
39 * batch.
40 * When we notice that bm_flush > bm_write, we write out all pending updates
41 * to the bitmap, and advance bm_write to where bm_flush was.
42 * This may occasionally write a bit out twice, but is sure never to
43 * miss any bits.
44 */
21 45
22#include <linux/module.h> 46#include <linux/module.h>
23#include <linux/slab.h> 47#include <linux/slab.h>
@@ -88,12 +112,14 @@ static void __release_stripe(raid5_conf_t *conf, struct stripe_head *sh)
88 BUG_ON(!list_empty(&sh->lru)); 112 BUG_ON(!list_empty(&sh->lru));
89 BUG_ON(atomic_read(&conf->active_stripes)==0); 113 BUG_ON(atomic_read(&conf->active_stripes)==0);
90 if (test_bit(STRIPE_HANDLE, &sh->state)) { 114 if (test_bit(STRIPE_HANDLE, &sh->state)) {
91 if (test_bit(STRIPE_DELAYED, &sh->state)) 115 if (test_bit(STRIPE_DELAYED, &sh->state)) {
92 list_add_tail(&sh->lru, &conf->delayed_list); 116 list_add_tail(&sh->lru, &conf->delayed_list);
93 else if (test_bit(STRIPE_BIT_DELAY, &sh->state) && 117 blk_plug_device(conf->mddev->queue);
94 conf->seq_write == sh->bm_seq) 118 } else if (test_bit(STRIPE_BIT_DELAY, &sh->state) &&
119 sh->bm_seq - conf->seq_write > 0) {
95 list_add_tail(&sh->lru, &conf->bitmap_list); 120 list_add_tail(&sh->lru, &conf->bitmap_list);
96 else { 121 blk_plug_device(conf->mddev->queue);
122 } else {
97 clear_bit(STRIPE_BIT_DELAY, &sh->state); 123 clear_bit(STRIPE_BIT_DELAY, &sh->state);
98 list_add_tail(&sh->lru, &conf->handle_list); 124 list_add_tail(&sh->lru, &conf->handle_list);
99 } 125 }
@@ -270,7 +296,7 @@ static struct stripe_head *get_active_stripe(raid5_conf_t *conf, sector_t sector
270 < (conf->max_nr_stripes *3/4) 296 < (conf->max_nr_stripes *3/4)
271 || !conf->inactive_blocked), 297 || !conf->inactive_blocked),
272 conf->device_lock, 298 conf->device_lock,
273 unplug_slaves(conf->mddev) 299 raid5_unplug_device(conf->mddev->queue)
274 ); 300 );
275 conf->inactive_blocked = 0; 301 conf->inactive_blocked = 0;
276 } else 302 } else
@@ -281,7 +307,8 @@ static struct stripe_head *get_active_stripe(raid5_conf_t *conf, sector_t sector
281 } else { 307 } else {
282 if (!test_bit(STRIPE_HANDLE, &sh->state)) 308 if (!test_bit(STRIPE_HANDLE, &sh->state))
283 atomic_inc(&conf->active_stripes); 309 atomic_inc(&conf->active_stripes);
284 if (list_empty(&sh->lru)) 310 if (list_empty(&sh->lru) &&
311 !test_bit(STRIPE_EXPANDING, &sh->state))
285 BUG(); 312 BUG();
286 list_del_init(&sh->lru); 313 list_del_init(&sh->lru);
287 } 314 }
@@ -496,6 +523,8 @@ static int raid5_end_read_request(struct bio * bi, unsigned int bytes_done,
496 raid5_conf_t *conf = sh->raid_conf; 523 raid5_conf_t *conf = sh->raid_conf;
497 int disks = sh->disks, i; 524 int disks = sh->disks, i;
498 int uptodate = test_bit(BIO_UPTODATE, &bi->bi_flags); 525 int uptodate = test_bit(BIO_UPTODATE, &bi->bi_flags);
526 char b[BDEVNAME_SIZE];
527 mdk_rdev_t *rdev;
499 528
500 if (bi->bi_size) 529 if (bi->bi_size)
501 return 1; 530 return 1;
@@ -543,25 +572,39 @@ static int raid5_end_read_request(struct bio * bi, unsigned int bytes_done,
543 set_bit(R5_UPTODATE, &sh->dev[i].flags); 572 set_bit(R5_UPTODATE, &sh->dev[i].flags);
544#endif 573#endif
545 if (test_bit(R5_ReadError, &sh->dev[i].flags)) { 574 if (test_bit(R5_ReadError, &sh->dev[i].flags)) {
546 printk(KERN_INFO "raid5: read error corrected!!\n"); 575 rdev = conf->disks[i].rdev;
576 printk(KERN_INFO "raid5:%s: read error corrected (%lu sectors at %llu on %s)\n",
577 mdname(conf->mddev), STRIPE_SECTORS,
578 (unsigned long long)sh->sector + rdev->data_offset,
579 bdevname(rdev->bdev, b));
547 clear_bit(R5_ReadError, &sh->dev[i].flags); 580 clear_bit(R5_ReadError, &sh->dev[i].flags);
548 clear_bit(R5_ReWrite, &sh->dev[i].flags); 581 clear_bit(R5_ReWrite, &sh->dev[i].flags);
549 } 582 }
550 if (atomic_read(&conf->disks[i].rdev->read_errors)) 583 if (atomic_read(&conf->disks[i].rdev->read_errors))
551 atomic_set(&conf->disks[i].rdev->read_errors, 0); 584 atomic_set(&conf->disks[i].rdev->read_errors, 0);
552 } else { 585 } else {
586 const char *bdn = bdevname(conf->disks[i].rdev->bdev, b);
553 int retry = 0; 587 int retry = 0;
588 rdev = conf->disks[i].rdev;
589
554 clear_bit(R5_UPTODATE, &sh->dev[i].flags); 590 clear_bit(R5_UPTODATE, &sh->dev[i].flags);
555 atomic_inc(&conf->disks[i].rdev->read_errors); 591 atomic_inc(&rdev->read_errors);
556 if (conf->mddev->degraded) 592 if (conf->mddev->degraded)
557 printk(KERN_WARNING "raid5: read error not correctable.\n"); 593 printk(KERN_WARNING "raid5:%s: read error not correctable (sector %llu on %s).\n",
594 mdname(conf->mddev),
595 (unsigned long long)sh->sector + rdev->data_offset,
596 bdn);
558 else if (test_bit(R5_ReWrite, &sh->dev[i].flags)) 597 else if (test_bit(R5_ReWrite, &sh->dev[i].flags))
559 /* Oh, no!!! */ 598 /* Oh, no!!! */
560 printk(KERN_WARNING "raid5: read error NOT corrected!!\n"); 599 printk(KERN_WARNING "raid5:%s: read error NOT corrected!! (sector %llu on %s).\n",
561 else if (atomic_read(&conf->disks[i].rdev->read_errors) 600 mdname(conf->mddev),
601 (unsigned long long)sh->sector + rdev->data_offset,
602 bdn);
603 else if (atomic_read(&rdev->read_errors)
562 > conf->max_nr_stripes) 604 > conf->max_nr_stripes)
563 printk(KERN_WARNING 605 printk(KERN_WARNING
564 "raid5: Too many read errors, failing device.\n"); 606 "raid5:%s: Too many read errors, failing device %s.\n",
607 mdname(conf->mddev), bdn);
565 else 608 else
566 retry = 1; 609 retry = 1;
567 if (retry) 610 if (retry)
@@ -569,7 +612,7 @@ static int raid5_end_read_request(struct bio * bi, unsigned int bytes_done,
569 else { 612 else {
570 clear_bit(R5_ReadError, &sh->dev[i].flags); 613 clear_bit(R5_ReadError, &sh->dev[i].flags);
571 clear_bit(R5_ReWrite, &sh->dev[i].flags); 614 clear_bit(R5_ReWrite, &sh->dev[i].flags);
572 md_error(conf->mddev, conf->disks[i].rdev); 615 md_error(conf->mddev, rdev);
573 } 616 }
574 } 617 }
575 rdev_dec_pending(conf->disks[i].rdev, conf->mddev); 618 rdev_dec_pending(conf->disks[i].rdev, conf->mddev);
@@ -1270,9 +1313,9 @@ static int add_stripe_bio(struct stripe_head *sh, struct bio *bi, int dd_idx, in
1270 (unsigned long long)sh->sector, dd_idx); 1313 (unsigned long long)sh->sector, dd_idx);
1271 1314
1272 if (conf->mddev->bitmap && firstwrite) { 1315 if (conf->mddev->bitmap && firstwrite) {
1273 sh->bm_seq = conf->seq_write;
1274 bitmap_startwrite(conf->mddev->bitmap, sh->sector, 1316 bitmap_startwrite(conf->mddev->bitmap, sh->sector,
1275 STRIPE_SECTORS, 0); 1317 STRIPE_SECTORS, 0);
1318 sh->bm_seq = conf->seq_flush+1;
1276 set_bit(STRIPE_BIT_DELAY, &sh->state); 1319 set_bit(STRIPE_BIT_DELAY, &sh->state);
1277 } 1320 }
1278 1321
@@ -2554,13 +2597,6 @@ static int raid5_issue_flush(request_queue_t *q, struct gendisk *disk,
2554 return ret; 2597 return ret;
2555} 2598}
2556 2599
2557static inline void raid5_plug_device(raid5_conf_t *conf)
2558{
2559 spin_lock_irq(&conf->device_lock);
2560 blk_plug_device(conf->mddev->queue);
2561 spin_unlock_irq(&conf->device_lock);
2562}
2563
2564static int make_request(request_queue_t *q, struct bio * bi) 2600static int make_request(request_queue_t *q, struct bio * bi)
2565{ 2601{
2566 mddev_t *mddev = q->queuedata; 2602 mddev_t *mddev = q->queuedata;
@@ -2670,7 +2706,6 @@ static int make_request(request_queue_t *q, struct bio * bi)
2670 goto retry; 2706 goto retry;
2671 } 2707 }
2672 finish_wait(&conf->wait_for_overlap, &w); 2708 finish_wait(&conf->wait_for_overlap, &w);
2673 raid5_plug_device(conf);
2674 handle_stripe(sh, NULL); 2709 handle_stripe(sh, NULL);
2675 release_stripe(sh); 2710 release_stripe(sh);
2676 } else { 2711 } else {
@@ -2923,7 +2958,7 @@ static void raid5d (mddev_t *mddev)
2923 while (1) { 2958 while (1) {
2924 struct list_head *first; 2959 struct list_head *first;
2925 2960
2926 if (conf->seq_flush - conf->seq_write > 0) { 2961 if (conf->seq_flush != conf->seq_write) {
2927 int seq = conf->seq_flush; 2962 int seq = conf->seq_flush;
2928 spin_unlock_irq(&conf->device_lock); 2963 spin_unlock_irq(&conf->device_lock);
2929 bitmap_unplug(mddev->bitmap); 2964 bitmap_unplug(mddev->bitmap);
@@ -3246,9 +3281,6 @@ static int run(mddev_t *mddev)
3246 set_bit(MD_RECOVERY_RUNNING, &mddev->recovery); 3281 set_bit(MD_RECOVERY_RUNNING, &mddev->recovery);
3247 mddev->sync_thread = md_register_thread(md_do_sync, mddev, 3282 mddev->sync_thread = md_register_thread(md_do_sync, mddev,
3248 "%s_reshape"); 3283 "%s_reshape");
3249 /* FIXME if md_register_thread fails?? */
3250 md_wakeup_thread(mddev->sync_thread);
3251
3252 } 3284 }
3253 3285
3254 /* read-ahead size must cover two whole stripes, which is 3286 /* read-ahead size must cover two whole stripes, which is
diff --git a/drivers/media/dvb/frontends/nxt200x.c b/drivers/media/dvb/frontends/nxt200x.c
index 55671cb5255e..87c286ee6a00 100644
--- a/drivers/media/dvb/frontends/nxt200x.c
+++ b/drivers/media/dvb/frontends/nxt200x.c
@@ -896,9 +896,9 @@ static int nxt2002_init(struct dvb_frontend* fe)
896 } 896 }
897 897
898 ret = nxt2002_load_firmware(fe, fw); 898 ret = nxt2002_load_firmware(fe, fw);
899 release_firmware(fw);
899 if (ret) { 900 if (ret) {
900 printk("nxt2002: Writing firmware to device failed\n"); 901 printk("nxt2002: Writing firmware to device failed\n");
901 release_firmware(fw);
902 return ret; 902 return ret;
903 } 903 }
904 printk("nxt2002: Firmware upload complete\n"); 904 printk("nxt2002: Firmware upload complete\n");
@@ -960,9 +960,9 @@ static int nxt2004_init(struct dvb_frontend* fe)
960 } 960 }
961 961
962 ret = nxt2004_load_firmware(fe, fw); 962 ret = nxt2004_load_firmware(fe, fw);
963 release_firmware(fw);
963 if (ret) { 964 if (ret) {
964 printk("nxt2004: Writing firmware to device failed\n"); 965 printk("nxt2004: Writing firmware to device failed\n");
965 release_firmware(fw);
966 return ret; 966 return ret;
967 } 967 }
968 printk("nxt2004: Firmware upload complete\n"); 968 printk("nxt2004: Firmware upload complete\n");
diff --git a/drivers/media/dvb/frontends/or51211.c b/drivers/media/dvb/frontends/or51211.c
index 26bed616fabe..2bf124b53689 100644
--- a/drivers/media/dvb/frontends/or51211.c
+++ b/drivers/media/dvb/frontends/or51211.c
@@ -437,10 +437,10 @@ static int or51211_init(struct dvb_frontend* fe)
437 } 437 }
438 438
439 ret = or51211_load_firmware(fe, fw); 439 ret = or51211_load_firmware(fe, fw);
440 release_firmware(fw);
440 if (ret) { 441 if (ret) {
441 printk(KERN_WARNING "or51211: Writing firmware to " 442 printk(KERN_WARNING "or51211: Writing firmware to "
442 "device failed!\n"); 443 "device failed!\n");
443 release_firmware(fw);
444 return ret; 444 return ret;
445 } 445 }
446 printk(KERN_INFO "or51211: Firmware upload complete.\n"); 446 printk(KERN_INFO "or51211: Firmware upload complete.\n");
diff --git a/drivers/media/dvb/frontends/sp8870.c b/drivers/media/dvb/frontends/sp8870.c
index 44ec5b9a4695..d98fd5c2e13e 100644
--- a/drivers/media/dvb/frontends/sp8870.c
+++ b/drivers/media/dvb/frontends/sp8870.c
@@ -318,7 +318,6 @@ static int sp8870_init (struct dvb_frontend* fe)
318 printk("sp8870: waiting for firmware upload (%s)...\n", SP8870_DEFAULT_FIRMWARE); 318 printk("sp8870: waiting for firmware upload (%s)...\n", SP8870_DEFAULT_FIRMWARE);
319 if (state->config->request_firmware(fe, &fw, SP8870_DEFAULT_FIRMWARE)) { 319 if (state->config->request_firmware(fe, &fw, SP8870_DEFAULT_FIRMWARE)) {
320 printk("sp8870: no firmware upload (timeout or file not found?)\n"); 320 printk("sp8870: no firmware upload (timeout or file not found?)\n");
321 release_firmware(fw);
322 return -EIO; 321 return -EIO;
323 } 322 }
324 323
@@ -327,6 +326,7 @@ static int sp8870_init (struct dvb_frontend* fe)
327 release_firmware(fw); 326 release_firmware(fw);
328 return -EIO; 327 return -EIO;
329 } 328 }
329 release_firmware(fw);
330 printk("sp8870: firmware upload complete\n"); 330 printk("sp8870: firmware upload complete\n");
331 331
332 /* enable TS output and interface pins */ 332 /* enable TS output and interface pins */
diff --git a/drivers/media/dvb/frontends/sp887x.c b/drivers/media/dvb/frontends/sp887x.c
index b0a2b02f6608..5c2f8f4e0ae5 100644
--- a/drivers/media/dvb/frontends/sp887x.c
+++ b/drivers/media/dvb/frontends/sp887x.c
@@ -520,9 +520,9 @@ static int sp887x_init(struct dvb_frontend* fe)
520 } 520 }
521 521
522 ret = sp887x_initial_setup(fe, fw); 522 ret = sp887x_initial_setup(fe, fw);
523 release_firmware(fw);
523 if (ret) { 524 if (ret) {
524 printk("sp887x: writing firmware to device failed\n"); 525 printk("sp887x: writing firmware to device failed\n");
525 release_firmware(fw);
526 return ret; 526 return ret;
527 } 527 }
528 printk("sp887x: firmware upload complete\n"); 528 printk("sp887x: firmware upload complete\n");
diff --git a/drivers/media/video/cx88/cx88-blackbird.c b/drivers/media/video/cx88/cx88-blackbird.c
index 349632b48e93..b60177f173c3 100644
--- a/drivers/media/video/cx88/cx88-blackbird.c
+++ b/drivers/media/video/cx88/cx88-blackbird.c
@@ -453,11 +453,13 @@ static int blackbird_load_firmware(struct cx8802_dev *dev)
453 if (firmware->size != BLACKBIRD_FIRM_IMAGE_SIZE) { 453 if (firmware->size != BLACKBIRD_FIRM_IMAGE_SIZE) {
454 dprintk(0, "ERROR: Firmware size mismatch (have %zd, expected %d)\n", 454 dprintk(0, "ERROR: Firmware size mismatch (have %zd, expected %d)\n",
455 firmware->size, BLACKBIRD_FIRM_IMAGE_SIZE); 455 firmware->size, BLACKBIRD_FIRM_IMAGE_SIZE);
456 release_firmware(firmware);
456 return -1; 457 return -1;
457 } 458 }
458 459
459 if (0 != memcmp(firmware->data, magic, 8)) { 460 if (0 != memcmp(firmware->data, magic, 8)) {
460 dprintk(0, "ERROR: Firmware magic mismatch, wrong file?\n"); 461 dprintk(0, "ERROR: Firmware magic mismatch, wrong file?\n");
462 release_firmware(firmware);
461 return -1; 463 return -1;
462 } 464 }
463 465
@@ -478,6 +480,7 @@ static int blackbird_load_firmware(struct cx8802_dev *dev)
478 } 480 }
479 if (checksum) { 481 if (checksum) {
480 dprintk(0, "ERROR: Firmware load failed (checksum mismatch).\n"); 482 dprintk(0, "ERROR: Firmware load failed (checksum mismatch).\n");
483 release_firmware(firmware);
481 return -1; 484 return -1;
482 } 485 }
483 release_firmware(firmware); 486 release_firmware(firmware);
diff --git a/drivers/message/i2o/core.h b/drivers/message/i2o/core.h
index 184974cc734d..dc388a3ff5e0 100644
--- a/drivers/message/i2o/core.h
+++ b/drivers/message/i2o/core.h
@@ -38,6 +38,9 @@ extern struct device_attribute i2o_device_attrs[];
38extern void i2o_device_remove(struct i2o_device *); 38extern void i2o_device_remove(struct i2o_device *);
39extern int i2o_device_parse_lct(struct i2o_controller *); 39extern int i2o_device_parse_lct(struct i2o_controller *);
40 40
41int i2o_parm_issue(struct i2o_device *i2o_dev, int cmd, void *oplist,
42 int oplen, void *reslist, int reslen);
43
41/* IOP */ 44/* IOP */
42extern struct i2o_controller *i2o_iop_alloc(void); 45extern struct i2o_controller *i2o_iop_alloc(void);
43 46
diff --git a/drivers/message/i2o/i2o_config.c b/drivers/message/i2o/i2o_config.c
index 89daf67b764d..7d23e082bf26 100644
--- a/drivers/message/i2o/i2o_config.c
+++ b/drivers/message/i2o/i2o_config.c
@@ -36,9 +36,9 @@
36 36
37#include <asm/uaccess.h> 37#include <asm/uaccess.h>
38 38
39#define SG_TABLESIZE 30 39#include "core.h"
40 40
41extern int i2o_parm_issue(struct i2o_device *, int, void *, int, void *, int); 41#define SG_TABLESIZE 30
42 42
43static int i2o_cfg_ioctl(struct inode *, struct file *, unsigned int, 43static int i2o_cfg_ioctl(struct inode *, struct file *, unsigned int,
44 unsigned long); 44 unsigned long);
diff --git a/drivers/net/hamradio/bpqether.c b/drivers/net/hamradio/bpqether.c
index 0641f54fc638..889f338132fa 100644
--- a/drivers/net/hamradio/bpqether.c
+++ b/drivers/net/hamradio/bpqether.c
@@ -122,6 +122,12 @@ struct bpqdev {
122 122
123static LIST_HEAD(bpq_devices); 123static LIST_HEAD(bpq_devices);
124 124
125/*
126 * bpqether network devices are paired with ethernet devices below them, so
127 * form a special "super class" of normal ethernet devices; split their locks
128 * off into a separate class since they always nest.
129 */
130static struct lock_class_key bpq_netdev_xmit_lock_key;
125 131
126/* ------------------------------------------------------------------------ */ 132/* ------------------------------------------------------------------------ */
127 133
@@ -528,6 +534,7 @@ static int bpq_new_device(struct net_device *edev)
528 err = register_netdevice(ndev); 534 err = register_netdevice(ndev);
529 if (err) 535 if (err)
530 goto error; 536 goto error;
537 lockdep_set_class(&ndev->_xmit_lock, &bpq_netdev_xmit_lock_key);
531 538
532 /* List protected by RTNL */ 539 /* List protected by RTNL */
533 list_add_rcu(&bpq->bpq_list, &bpq_devices); 540 list_add_rcu(&bpq->bpq_list, &bpq_devices);
diff --git a/drivers/net/wireless/spectrum_cs.c b/drivers/net/wireless/spectrum_cs.c
index 15465278c789..7f78b7801fb3 100644
--- a/drivers/net/wireless/spectrum_cs.c
+++ b/drivers/net/wireless/spectrum_cs.c
@@ -34,8 +34,6 @@
34 34
35#include "orinoco.h" 35#include "orinoco.h"
36 36
37static unsigned char *primsym;
38static unsigned char *secsym;
39static const char primary_fw_name[] = "symbol_sp24t_prim_fw"; 37static const char primary_fw_name[] = "symbol_sp24t_prim_fw";
40static const char secondary_fw_name[] = "symbol_sp24t_sec_fw"; 38static const char secondary_fw_name[] = "symbol_sp24t_sec_fw";
41 39
@@ -440,7 +438,7 @@ spectrum_load_blocks(hermes_t *hw, const struct dblock *first_block)
440 */ 438 */
441static int 439static int
442spectrum_dl_image(hermes_t *hw, struct pcmcia_device *link, 440spectrum_dl_image(hermes_t *hw, struct pcmcia_device *link,
443 const unsigned char *image) 441 const unsigned char *image, int secondary)
444{ 442{
445 int ret; 443 int ret;
446 const unsigned char *ptr; 444 const unsigned char *ptr;
@@ -455,7 +453,7 @@ spectrum_dl_image(hermes_t *hw, struct pcmcia_device *link,
455 first_block = (const struct dblock *) ptr; 453 first_block = (const struct dblock *) ptr;
456 454
457 /* Read the PDA */ 455 /* Read the PDA */
458 if (image != primsym) { 456 if (secondary) {
459 ret = spectrum_read_pda(hw, pda, sizeof(pda)); 457 ret = spectrum_read_pda(hw, pda, sizeof(pda));
460 if (ret) 458 if (ret)
461 return ret; 459 return ret;
@@ -472,7 +470,7 @@ spectrum_dl_image(hermes_t *hw, struct pcmcia_device *link,
472 return ret; 470 return ret;
473 471
474 /* Write the PDA to the adapter */ 472 /* Write the PDA to the adapter */
475 if (image != primsym) { 473 if (secondary) {
476 ret = spectrum_apply_pda(hw, first_block, pda); 474 ret = spectrum_apply_pda(hw, first_block, pda);
477 if (ret) 475 if (ret)
478 return ret; 476 return ret;
@@ -487,7 +485,7 @@ spectrum_dl_image(hermes_t *hw, struct pcmcia_device *link,
487 ret = hermes_init(hw); 485 ret = hermes_init(hw);
488 486
489 /* hermes_reset() should return 0 with the secondary firmware */ 487 /* hermes_reset() should return 0 with the secondary firmware */
490 if (image != primsym && ret != 0) 488 if (secondary && ret != 0)
491 return -ENODEV; 489 return -ENODEV;
492 490
493 /* And this should work with any firmware */ 491 /* And this should work with any firmware */
@@ -509,33 +507,30 @@ spectrum_dl_firmware(hermes_t *hw, struct pcmcia_device *link)
509 const struct firmware *fw_entry; 507 const struct firmware *fw_entry;
510 508
511 if (request_firmware(&fw_entry, primary_fw_name, 509 if (request_firmware(&fw_entry, primary_fw_name,
512 &handle_to_dev(link)) == 0) { 510 &handle_to_dev(link)) != 0) {
513 primsym = fw_entry->data;
514 } else {
515 printk(KERN_ERR PFX "Cannot find firmware: %s\n", 511 printk(KERN_ERR PFX "Cannot find firmware: %s\n",
516 primary_fw_name); 512 primary_fw_name);
517 return -ENOENT; 513 return -ENOENT;
518 } 514 }
519 515
520 if (request_firmware(&fw_entry, secondary_fw_name,
521 &handle_to_dev(link)) == 0) {
522 secsym = fw_entry->data;
523 } else {
524 printk(KERN_ERR PFX "Cannot find firmware: %s\n",
525 secondary_fw_name);
526 return -ENOENT;
527 }
528
529 /* Load primary firmware */ 516 /* Load primary firmware */
530 ret = spectrum_dl_image(hw, link, primsym); 517 ret = spectrum_dl_image(hw, link, fw_entry->data, 0);
518 release_firmware(fw_entry);
531 if (ret) { 519 if (ret) {
532 printk(KERN_ERR PFX "Primary firmware download failed\n"); 520 printk(KERN_ERR PFX "Primary firmware download failed\n");
533 return ret; 521 return ret;
534 } 522 }
535 523
536 /* Load secondary firmware */ 524 if (request_firmware(&fw_entry, secondary_fw_name,
537 ret = spectrum_dl_image(hw, link, secsym); 525 &handle_to_dev(link)) != 0) {
526 printk(KERN_ERR PFX "Cannot find firmware: %s\n",
527 secondary_fw_name);
528 return -ENOENT;
529 }
538 530
531 /* Load secondary firmware */
532 ret = spectrum_dl_image(hw, link, fw_entry->data, 1);
533 release_firmware(fw_entry);
539 if (ret) { 534 if (ret) {
540 printk(KERN_ERR PFX "Secondary firmware download failed\n"); 535 printk(KERN_ERR PFX "Secondary firmware download failed\n");
541 } 536 }
diff --git a/drivers/pci/hotplug/Kconfig b/drivers/pci/hotplug/Kconfig
index d305d212ad6c..3fae77ffb2fa 100644
--- a/drivers/pci/hotplug/Kconfig
+++ b/drivers/pci/hotplug/Kconfig
@@ -6,8 +6,7 @@ menu "PCI Hotplug Support"
6 6
7config HOTPLUG_PCI 7config HOTPLUG_PCI
8 tristate "Support for PCI Hotplug (EXPERIMENTAL)" 8 tristate "Support for PCI Hotplug (EXPERIMENTAL)"
9 depends on PCI && EXPERIMENTAL 9 depends on PCI && EXPERIMENTAL && HOTPLUG
10 select HOTPLUG
11 ---help--- 10 ---help---
12 Say Y here if you have a motherboard with a PCI Hotplug controller. 11 Say Y here if you have a motherboard with a PCI Hotplug controller.
13 This allows you to add and remove PCI cards while the machine is 12 This allows you to add and remove PCI cards while the machine is
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index f89dbc3738b7..c5a58d1c6c1c 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -815,6 +815,7 @@ pci_scan_device(struct pci_bus *bus, int devfn)
815 dev->vendor = l & 0xffff; 815 dev->vendor = l & 0xffff;
816 dev->device = (l >> 16) & 0xffff; 816 dev->device = (l >> 16) & 0xffff;
817 dev->cfg_size = pci_cfg_space_size(dev); 817 dev->cfg_size = pci_cfg_space_size(dev);
818 dev->error_state = pci_channel_io_normal;
818 819
819 /* Assume 32-bit PCI; let 64-bit PCI cards (which are far rarer) 820 /* Assume 32-bit PCI; let 64-bit PCI cards (which are far rarer)
820 set this higher, assuming the system even supports it. */ 821 set this higher, assuming the system even supports it. */
diff --git a/drivers/pcmcia/Kconfig b/drivers/pcmcia/Kconfig
index 61cb4b29f55c..35f88649d3b7 100644
--- a/drivers/pcmcia/Kconfig
+++ b/drivers/pcmcia/Kconfig
@@ -6,7 +6,7 @@ menu "PCCARD (PCMCIA/CardBus) support"
6 6
7config PCCARD 7config PCCARD
8 tristate "PCCard (PCMCIA/CardBus) support" 8 tristate "PCCard (PCMCIA/CardBus) support"
9 select HOTPLUG 9 depends on HOTPLUG
10 ---help--- 10 ---help---
11 Say Y here if you want to attach PCMCIA- or PC-cards to your Linux 11 Say Y here if you want to attach PCMCIA- or PC-cards to your Linux
12 computer. These are credit-card size devices such as network cards, 12 computer. These are credit-card size devices such as network cards,
diff --git a/drivers/s390/net/claw.c b/drivers/s390/net/claw.c
index 23d53bf9daf1..95f4e105cb96 100644
--- a/drivers/s390/net/claw.c
+++ b/drivers/s390/net/claw.c
@@ -529,7 +529,7 @@ claw_open(struct net_device *dev)
529 printk(KERN_INFO "%s:%s Enter \n",dev->name,__FUNCTION__); 529 printk(KERN_INFO "%s:%s Enter \n",dev->name,__FUNCTION__);
530#endif 530#endif
531 CLAW_DBF_TEXT(4,trace,"open"); 531 CLAW_DBF_TEXT(4,trace,"open");
532 if (!dev | (dev->name[0] == 0x00)) { 532 if (!dev || (dev->name[0] == 0x00)) {
533 CLAW_DBF_TEXT(2,trace,"BadDev"); 533 CLAW_DBF_TEXT(2,trace,"BadDev");
534 printk(KERN_WARNING "claw: Bad device at open failing \n"); 534 printk(KERN_WARNING "claw: Bad device at open failing \n");
535 return -ENODEV; 535 return -ENODEV;
diff --git a/drivers/s390/net/netiucv.c b/drivers/s390/net/netiucv.c
index b452cc1afd55..5d6e6cbfa360 100644
--- a/drivers/s390/net/netiucv.c
+++ b/drivers/s390/net/netiucv.c
@@ -2029,7 +2029,7 @@ remove_write (struct device_driver *drv, const char *buf, size_t count)
2029 count = IFNAMSIZ-1; 2029 count = IFNAMSIZ-1;
2030 2030
2031 for (i=0, p=(char *)buf; i<count && *p; i++, p++) { 2031 for (i=0, p=(char *)buf; i<count && *p; i++, p++) {
2032 if ((*p == '\n') | (*p == ' ')) { 2032 if ((*p == '\n') || (*p == ' ')) {
2033 /* trailing lf, grr */ 2033 /* trailing lf, grr */
2034 break; 2034 break;
2035 } else { 2035 } else {
diff --git a/drivers/s390/net/qeth_main.c b/drivers/s390/net/qeth_main.c
index 329e12c1fae4..4caced21ac8c 100644
--- a/drivers/s390/net/qeth_main.c
+++ b/drivers/s390/net/qeth_main.c
@@ -4420,8 +4420,10 @@ qeth_send_packet(struct qeth_card *card, struct sk_buff *skb)
4420 enum qeth_large_send_types large_send = QETH_LARGE_SEND_NO; 4420 enum qeth_large_send_types large_send = QETH_LARGE_SEND_NO;
4421 struct qeth_eddp_context *ctx = NULL; 4421 struct qeth_eddp_context *ctx = NULL;
4422 int tx_bytes = skb->len; 4422 int tx_bytes = skb->len;
4423#ifdef CONFIG_QETH_PERF_STATS
4423 unsigned short nr_frags = skb_shinfo(skb)->nr_frags; 4424 unsigned short nr_frags = skb_shinfo(skb)->nr_frags;
4424 unsigned short tso_size = skb_shinfo(skb)->gso_size; 4425 unsigned short tso_size = skb_shinfo(skb)->gso_size;
4426#endif
4425 int rc; 4427 int rc;
4426 4428
4427 QETH_DBF_TEXT(trace, 6, "sendpkt"); 4429 QETH_DBF_TEXT(trace, 6, "sendpkt");
diff --git a/drivers/scsi/aic7xxx/aic79xx_osm.h b/drivers/scsi/aic7xxx/aic79xx_osm.h
index 9e871de23835..601340d84410 100644
--- a/drivers/scsi/aic7xxx/aic79xx_osm.h
+++ b/drivers/scsi/aic7xxx/aic79xx_osm.h
@@ -93,7 +93,6 @@
93#endif 93#endif
94 94
95/********************************** Misc Macros *******************************/ 95/********************************** Misc Macros *******************************/
96#define roundup(x, y) ((((x)+((y)-1))/(y))*(y))
97#define powerof2(x) ((((x)-1)&(x))==0) 96#define powerof2(x) ((((x)-1)&(x))==0)
98 97
99/************************* Forward Declarations *******************************/ 98/************************* Forward Declarations *******************************/
diff --git a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c
index eb7188b3565c..d6acc92a4ae3 100644
--- a/drivers/usb/storage/transport.c
+++ b/drivers/usb/storage/transport.c
@@ -180,7 +180,7 @@ static int usb_stor_msg_common(struct us_data *us, int timeout)
180 if (timeleft <= 0) { 180 if (timeleft <= 0) {
181 US_DEBUGP("%s -- cancelling URB\n", 181 US_DEBUGP("%s -- cancelling URB\n",
182 timeleft == 0 ? "Timeout" : "Signal"); 182 timeleft == 0 ? "Timeout" : "Signal");
183 usb_unlink_urb(us->current_urb); 183 usb_kill_urb(us->current_urb);
184 } 184 }
185 185
186 /* return the URB status */ 186 /* return the URB status */
diff --git a/drivers/video/68328fb.c b/drivers/video/68328fb.c
index 78488bb41aeb..0dda73da8628 100644
--- a/drivers/video/68328fb.c
+++ b/drivers/video/68328fb.c
@@ -32,7 +32,6 @@
32#include <linux/errno.h> 32#include <linux/errno.h>
33#include <linux/string.h> 33#include <linux/string.h>
34#include <linux/mm.h> 34#include <linux/mm.h>
35#include <linux/tty.h>
36#include <linux/slab.h> 35#include <linux/slab.h>
37#include <linux/vmalloc.h> 36#include <linux/vmalloc.h>
38#include <linux/delay.h> 37#include <linux/delay.h>
diff --git a/drivers/video/S3triofb.c b/drivers/video/S3triofb.c
index e714e8449c1d..afd146f5f683 100644
--- a/drivers/video/S3triofb.c
+++ b/drivers/video/S3triofb.c
@@ -28,7 +28,6 @@
28#include <linux/errno.h> 28#include <linux/errno.h>
29#include <linux/string.h> 29#include <linux/string.h>
30#include <linux/mm.h> 30#include <linux/mm.h>
31#include <linux/tty.h>
32#include <linux/slab.h> 31#include <linux/slab.h>
33#include <linux/vmalloc.h> 32#include <linux/vmalloc.h>
34#include <linux/delay.h> 33#include <linux/delay.h>
diff --git a/drivers/video/amifb.c b/drivers/video/amifb.c
index f9bc9f777e75..f1ba54f4fc39 100644
--- a/drivers/video/amifb.c
+++ b/drivers/video/amifb.c
@@ -45,7 +45,6 @@
45#include <linux/errno.h> 45#include <linux/errno.h>
46#include <linux/string.h> 46#include <linux/string.h>
47#include <linux/mm.h> 47#include <linux/mm.h>
48#include <linux/tty.h>
49#include <linux/slab.h> 48#include <linux/slab.h>
50#include <linux/delay.h> 49#include <linux/delay.h>
51#include <linux/interrupt.h> 50#include <linux/interrupt.h>
diff --git a/drivers/video/arcfb.c b/drivers/video/arcfb.c
index fd95c2dbd4f7..70dd8115a4d8 100644
--- a/drivers/video/arcfb.c
+++ b/drivers/video/arcfb.c
@@ -39,7 +39,6 @@
39#include <linux/errno.h> 39#include <linux/errno.h>
40#include <linux/string.h> 40#include <linux/string.h>
41#include <linux/mm.h> 41#include <linux/mm.h>
42#include <linux/tty.h>
43#include <linux/slab.h> 42#include <linux/slab.h>
44#include <linux/vmalloc.h> 43#include <linux/vmalloc.h>
45#include <linux/delay.h> 44#include <linux/delay.h>
diff --git a/drivers/video/asiliantfb.c b/drivers/video/asiliantfb.c
index eaeaf4d1a094..1fd22f460b0f 100644
--- a/drivers/video/asiliantfb.c
+++ b/drivers/video/asiliantfb.c
@@ -34,7 +34,6 @@
34#include <linux/errno.h> 34#include <linux/errno.h>
35#include <linux/string.h> 35#include <linux/string.h>
36#include <linux/mm.h> 36#include <linux/mm.h>
37#include <linux/tty.h>
38#include <linux/slab.h> 37#include <linux/slab.h>
39#include <linux/vmalloc.h> 38#include <linux/vmalloc.h>
40#include <linux/delay.h> 39#include <linux/delay.h>
diff --git a/drivers/video/atafb.c b/drivers/video/atafb.c
index e69ab65f7843..5831893bf7a0 100644
--- a/drivers/video/atafb.c
+++ b/drivers/video/atafb.c
@@ -53,7 +53,6 @@
53#include <linux/errno.h> 53#include <linux/errno.h>
54#include <linux/string.h> 54#include <linux/string.h>
55#include <linux/mm.h> 55#include <linux/mm.h>
56#include <linux/tty.h>
57#include <linux/slab.h> 56#include <linux/slab.h>
58#include <linux/delay.h> 57#include <linux/delay.h>
59#include <linux/init.h> 58#include <linux/init.h>
diff --git a/drivers/video/aty/aty128fb.c b/drivers/video/aty/aty128fb.c
index 72c589109471..c64a717e2d4b 100644
--- a/drivers/video/aty/aty128fb.c
+++ b/drivers/video/aty/aty128fb.c
@@ -52,7 +52,6 @@
52#include <linux/errno.h> 52#include <linux/errno.h>
53#include <linux/string.h> 53#include <linux/string.h>
54#include <linux/mm.h> 54#include <linux/mm.h>
55#include <linux/tty.h>
56#include <linux/slab.h> 55#include <linux/slab.h>
57#include <linux/vmalloc.h> 56#include <linux/vmalloc.h>
58#include <linux/delay.h> 57#include <linux/delay.h>
@@ -456,6 +455,7 @@ static void do_wait_for_fifo(u16 entries, struct aty128fb_par *par);
456static void wait_for_fifo(u16 entries, struct aty128fb_par *par); 455static void wait_for_fifo(u16 entries, struct aty128fb_par *par);
457static void wait_for_idle(struct aty128fb_par *par); 456static void wait_for_idle(struct aty128fb_par *par);
458static u32 depth_to_dst(u32 depth); 457static u32 depth_to_dst(u32 depth);
458static void aty128_bl_set_power(struct fb_info *info, int power);
459 459
460#define BIOS_IN8(v) (readb(bios + (v))) 460#define BIOS_IN8(v) (readb(bios + (v)))
461#define BIOS_IN16(v) (readb(bios + (v)) | \ 461#define BIOS_IN16(v) (readb(bios + (v)) | \
@@ -1258,25 +1258,11 @@ static void aty128_set_lcd_enable(struct aty128fb_par *par, int on)
1258 reg &= ~LVDS_DISPLAY_DIS; 1258 reg &= ~LVDS_DISPLAY_DIS;
1259 aty_st_le32(LVDS_GEN_CNTL, reg); 1259 aty_st_le32(LVDS_GEN_CNTL, reg);
1260#ifdef CONFIG_FB_ATY128_BACKLIGHT 1260#ifdef CONFIG_FB_ATY128_BACKLIGHT
1261 mutex_lock(&info->bl_mutex); 1261 aty128_bl_set_power(info, FB_BLANK_UNBLANK);
1262 if (info->bl_dev) {
1263 down(&info->bl_dev->sem);
1264 info->bl_dev->props->update_status(info->bl_dev);
1265 up(&info->bl_dev->sem);
1266 }
1267 mutex_unlock(&info->bl_mutex);
1268#endif 1262#endif
1269 } else { 1263 } else {
1270#ifdef CONFIG_FB_ATY128_BACKLIGHT 1264#ifdef CONFIG_FB_ATY128_BACKLIGHT
1271 mutex_lock(&info->bl_mutex); 1265 aty128_bl_set_power(info, FB_BLANK_POWERDOWN);
1272 if (info->bl_dev) {
1273 down(&info->bl_dev->sem);
1274 info->bl_dev->props->brightness = 0;
1275 info->bl_dev->props->power = FB_BLANK_POWERDOWN;
1276 info->bl_dev->props->update_status(info->bl_dev);
1277 up(&info->bl_dev->sem);
1278 }
1279 mutex_unlock(&info->bl_mutex);
1280#endif 1266#endif
1281 reg = aty_ld_le32(LVDS_GEN_CNTL); 1267 reg = aty_ld_le32(LVDS_GEN_CNTL);
1282 reg |= LVDS_DISPLAY_DIS; 1268 reg |= LVDS_DISPLAY_DIS;
@@ -1703,6 +1689,7 @@ static int __devinit aty128fb_setup(char *options)
1703 1689
1704static struct backlight_properties aty128_bl_data; 1690static struct backlight_properties aty128_bl_data;
1705 1691
1692/* Call with fb_info->bl_mutex held */
1706static int aty128_bl_get_level_brightness(struct aty128fb_par *par, 1693static int aty128_bl_get_level_brightness(struct aty128fb_par *par,
1707 int level) 1694 int level)
1708{ 1695{
@@ -1710,10 +1697,8 @@ static int aty128_bl_get_level_brightness(struct aty128fb_par *par,
1710 int atylevel; 1697 int atylevel;
1711 1698
1712 /* Get and convert the value */ 1699 /* Get and convert the value */
1713 mutex_lock(&info->bl_mutex);
1714 atylevel = MAX_LEVEL - 1700 atylevel = MAX_LEVEL -
1715 (info->bl_curve[level] * FB_BACKLIGHT_MAX / MAX_LEVEL); 1701 (info->bl_curve[level] * FB_BACKLIGHT_MAX / MAX_LEVEL);
1716 mutex_unlock(&info->bl_mutex);
1717 1702
1718 if (atylevel < 0) 1703 if (atylevel < 0)
1719 atylevel = 0; 1704 atylevel = 0;
@@ -1731,7 +1716,8 @@ static int aty128_bl_get_level_brightness(struct aty128fb_par *par,
1731/* That one prevents proper CRT output with LCD off */ 1716/* That one prevents proper CRT output with LCD off */
1732#undef BACKLIGHT_DAC_OFF 1717#undef BACKLIGHT_DAC_OFF
1733 1718
1734static int aty128_bl_update_status(struct backlight_device *bd) 1719/* Call with fb_info->bl_mutex held */
1720static int __aty128_bl_update_status(struct backlight_device *bd)
1735{ 1721{
1736 struct aty128fb_par *par = class_get_devdata(&bd->class_dev); 1722 struct aty128fb_par *par = class_get_devdata(&bd->class_dev);
1737 unsigned int reg = aty_ld_le32(LVDS_GEN_CNTL); 1723 unsigned int reg = aty_ld_le32(LVDS_GEN_CNTL);
@@ -1784,6 +1770,19 @@ static int aty128_bl_update_status(struct backlight_device *bd)
1784 return 0; 1770 return 0;
1785} 1771}
1786 1772
1773static int aty128_bl_update_status(struct backlight_device *bd)
1774{
1775 struct aty128fb_par *par = class_get_devdata(&bd->class_dev);
1776 struct fb_info *info = pci_get_drvdata(par->pdev);
1777 int ret;
1778
1779 mutex_lock(&info->bl_mutex);
1780 ret = __aty128_bl_update_status(bd);
1781 mutex_unlock(&info->bl_mutex);
1782
1783 return ret;
1784}
1785
1787static int aty128_bl_get_brightness(struct backlight_device *bd) 1786static int aty128_bl_get_brightness(struct backlight_device *bd)
1788{ 1787{
1789 return bd->props->brightness; 1788 return bd->props->brightness;
@@ -1796,6 +1795,16 @@ static struct backlight_properties aty128_bl_data = {
1796 .max_brightness = (FB_BACKLIGHT_LEVELS - 1), 1795 .max_brightness = (FB_BACKLIGHT_LEVELS - 1),
1797}; 1796};
1798 1797
1798static void aty128_bl_set_power(struct fb_info *info, int power)
1799{
1800 mutex_lock(&info->bl_mutex);
1801 up(&info->bl_dev->sem);
1802 info->bl_dev->props->power = power;
1803 __aty128_bl_update_status(info->bl_dev);
1804 down(&info->bl_dev->sem);
1805 mutex_unlock(&info->bl_mutex);
1806}
1807
1799static void aty128_bl_init(struct aty128fb_par *par) 1808static void aty128_bl_init(struct aty128fb_par *par)
1800{ 1809{
1801 struct fb_info *info = pci_get_drvdata(par->pdev); 1810 struct fb_info *info = pci_get_drvdata(par->pdev);
@@ -2198,12 +2207,8 @@ static int aty128fb_blank(int blank, struct fb_info *fb)
2198 return 0; 2207 return 0;
2199 2208
2200#ifdef CONFIG_FB_ATY128_BACKLIGHT 2209#ifdef CONFIG_FB_ATY128_BACKLIGHT
2201 if (machine_is(powermac) && blank) { 2210 if (machine_is(powermac) && blank)
2202 down(&fb->bl_dev->sem); 2211 aty128_bl_set_power(fb, FB_BLANK_POWERDOWN);
2203 fb->bl_dev->props->power = FB_BLANK_POWERDOWN;
2204 fb->bl_dev->props->update_status(fb->bl_dev);
2205 up(&fb->bl_dev->sem);
2206 }
2207#endif 2212#endif
2208 2213
2209 if (blank & FB_BLANK_VSYNC_SUSPEND) 2214 if (blank & FB_BLANK_VSYNC_SUSPEND)
@@ -2219,14 +2224,12 @@ static int aty128fb_blank(int blank, struct fb_info *fb)
2219 aty128_set_crt_enable(par, par->crt_on && !blank); 2224 aty128_set_crt_enable(par, par->crt_on && !blank);
2220 aty128_set_lcd_enable(par, par->lcd_on && !blank); 2225 aty128_set_lcd_enable(par, par->lcd_on && !blank);
2221 } 2226 }
2227
2222#ifdef CONFIG_FB_ATY128_BACKLIGHT 2228#ifdef CONFIG_FB_ATY128_BACKLIGHT
2223 if (machine_is(powermac) && !blank) { 2229 if (machine_is(powermac) && !blank)
2224 down(&fb->bl_dev->sem); 2230 aty128_bl_set_power(fb, FB_BLANK_UNBLANK);
2225 fb->bl_dev->props->power = FB_BLANK_UNBLANK;
2226 fb->bl_dev->props->update_status(fb->bl_dev);
2227 up(&fb->bl_dev->sem);
2228 }
2229#endif 2231#endif
2232
2230 return 0; 2233 return 0;
2231} 2234}
2232 2235
diff --git a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c
index 0c9706746d79..1507d19f481f 100644
--- a/drivers/video/aty/atyfb_base.c
+++ b/drivers/video/aty/atyfb_base.c
@@ -2129,15 +2129,14 @@ static int atyfb_pci_resume(struct pci_dev *pdev)
2129 2129
2130static struct backlight_properties aty_bl_data; 2130static struct backlight_properties aty_bl_data;
2131 2131
2132/* Call with fb_info->bl_mutex held */
2132static int aty_bl_get_level_brightness(struct atyfb_par *par, int level) 2133static int aty_bl_get_level_brightness(struct atyfb_par *par, int level)
2133{ 2134{
2134 struct fb_info *info = pci_get_drvdata(par->pdev); 2135 struct fb_info *info = pci_get_drvdata(par->pdev);
2135 int atylevel; 2136 int atylevel;
2136 2137
2137 /* Get and convert the value */ 2138 /* Get and convert the value */
2138 mutex_lock(&info->bl_mutex);
2139 atylevel = info->bl_curve[level] * FB_BACKLIGHT_MAX / MAX_LEVEL; 2139 atylevel = info->bl_curve[level] * FB_BACKLIGHT_MAX / MAX_LEVEL;
2140 mutex_unlock(&info->bl_mutex);
2141 2140
2142 if (atylevel < 0) 2141 if (atylevel < 0)
2143 atylevel = 0; 2142 atylevel = 0;
@@ -2147,7 +2146,8 @@ static int aty_bl_get_level_brightness(struct atyfb_par *par, int level)
2147 return atylevel; 2146 return atylevel;
2148} 2147}
2149 2148
2150static int aty_bl_update_status(struct backlight_device *bd) 2149/* Call with fb_info->bl_mutex held */
2150static int __aty_bl_update_status(struct backlight_device *bd)
2151{ 2151{
2152 struct atyfb_par *par = class_get_devdata(&bd->class_dev); 2152 struct atyfb_par *par = class_get_devdata(&bd->class_dev);
2153 unsigned int reg = aty_ld_lcd(LCD_MISC_CNTL, par); 2153 unsigned int reg = aty_ld_lcd(LCD_MISC_CNTL, par);
@@ -2172,6 +2172,19 @@ static int aty_bl_update_status(struct backlight_device *bd)
2172 return 0; 2172 return 0;
2173} 2173}
2174 2174
2175static int aty_bl_update_status(struct backlight_device *bd)
2176{
2177 struct atyfb_par *par = class_get_devdata(&bd->class_dev);
2178 struct fb_info *info = pci_get_drvdata(par->pdev);
2179 int ret;
2180
2181 mutex_lock(&info->bl_mutex);
2182 ret = __aty_bl_update_status(bd);
2183 mutex_unlock(&info->bl_mutex);
2184
2185 return ret;
2186}
2187
2175static int aty_bl_get_brightness(struct backlight_device *bd) 2188static int aty_bl_get_brightness(struct backlight_device *bd)
2176{ 2189{
2177 return bd->props->brightness; 2190 return bd->props->brightness;
@@ -2184,6 +2197,16 @@ static struct backlight_properties aty_bl_data = {
2184 .max_brightness = (FB_BACKLIGHT_LEVELS - 1), 2197 .max_brightness = (FB_BACKLIGHT_LEVELS - 1),
2185}; 2198};
2186 2199
2200static void aty_bl_set_power(struct fb_info *info, int power)
2201{
2202 mutex_lock(&info->bl_mutex);
2203 up(&info->bl_dev->sem);
2204 info->bl_dev->props->power = power;
2205 __aty_bl_update_status(info->bl_dev);
2206 down(&info->bl_dev->sem);
2207 mutex_unlock(&info->bl_mutex);
2208}
2209
2187static void aty_bl_init(struct atyfb_par *par) 2210static void aty_bl_init(struct atyfb_par *par)
2188{ 2211{
2189 struct fb_info *info = pci_get_drvdata(par->pdev); 2212 struct fb_info *info = pci_get_drvdata(par->pdev);
@@ -2790,16 +2813,8 @@ static int atyfb_blank(int blank, struct fb_info *info)
2790 return 0; 2813 return 0;
2791 2814
2792#ifdef CONFIG_PMAC_BACKLIGHT 2815#ifdef CONFIG_PMAC_BACKLIGHT
2793 if (machine_is(powermac) && blank > FB_BLANK_NORMAL) { 2816 if (machine_is(powermac) && blank > FB_BLANK_NORMAL)
2794 mutex_lock(&info->bl_mutex); 2817 aty_bl_set_power(info, FB_BLANK_POWERDOWN);
2795 if (info->bl_dev) {
2796 down(&info->bl_dev->sem);
2797 info->bl_dev->props->power = FB_BLANK_POWERDOWN;
2798 info->bl_dev->props->update_status(info->bl_dev);
2799 up(&info->bl_dev->sem);
2800 }
2801 mutex_unlock(&info->bl_mutex);
2802 }
2803#elif defined(CONFIG_FB_ATY_GENERIC_LCD) 2818#elif defined(CONFIG_FB_ATY_GENERIC_LCD)
2804 if (par->lcd_table && blank > FB_BLANK_NORMAL && 2819 if (par->lcd_table && blank > FB_BLANK_NORMAL &&
2805 (aty_ld_lcd(LCD_GEN_CNTL, par) & LCD_ON)) { 2820 (aty_ld_lcd(LCD_GEN_CNTL, par) & LCD_ON)) {
@@ -2830,16 +2845,8 @@ static int atyfb_blank(int blank, struct fb_info *info)
2830 aty_st_le32(CRTC_GEN_CNTL, gen_cntl, par); 2845 aty_st_le32(CRTC_GEN_CNTL, gen_cntl, par);
2831 2846
2832#ifdef CONFIG_PMAC_BACKLIGHT 2847#ifdef CONFIG_PMAC_BACKLIGHT
2833 if (machine_is(powermac) && blank <= FB_BLANK_NORMAL) { 2848 if (machine_is(powermac) && blank <= FB_BLANK_NORMAL)
2834 mutex_lock(&info->bl_mutex); 2849 aty_bl_set_power(info, FB_BLANK_UNBLANK);
2835 if (info->bl_dev) {
2836 down(&info->bl_dev->sem);
2837 info->bl_dev->props->power = FB_BLANK_UNBLANK;
2838 info->bl_dev->props->update_status(info->bl_dev);
2839 up(&info->bl_dev->sem);
2840 }
2841 mutex_unlock(&info->bl_mutex);
2842 }
2843#elif defined(CONFIG_FB_ATY_GENERIC_LCD) 2850#elif defined(CONFIG_FB_ATY_GENERIC_LCD)
2844 if (par->lcd_table && blank <= FB_BLANK_NORMAL && 2851 if (par->lcd_table && blank <= FB_BLANK_NORMAL &&
2845 (aty_ld_lcd(LCD_GEN_CNTL, par) & LCD_ON)) { 2852 (aty_ld_lcd(LCD_GEN_CNTL, par) & LCD_ON)) {
diff --git a/drivers/video/aty/radeon_base.c b/drivers/video/aty/radeon_base.c
index 51b78f8de949..8d85fc58142e 100644
--- a/drivers/video/aty/radeon_base.c
+++ b/drivers/video/aty/radeon_base.c
@@ -58,7 +58,6 @@
58#include <linux/errno.h> 58#include <linux/errno.h>
59#include <linux/string.h> 59#include <linux/string.h>
60#include <linux/mm.h> 60#include <linux/mm.h>
61#include <linux/tty.h>
62#include <linux/slab.h> 61#include <linux/slab.h>
63#include <linux/delay.h> 62#include <linux/delay.h>
64#include <linux/time.h> 63#include <linux/time.h>
diff --git a/drivers/video/chipsfb.c b/drivers/video/chipsfb.c
index 0e465c80ef24..73cb426bf2d7 100644
--- a/drivers/video/chipsfb.c
+++ b/drivers/video/chipsfb.c
@@ -19,7 +19,6 @@
19#include <linux/errno.h> 19#include <linux/errno.h>
20#include <linux/string.h> 20#include <linux/string.h>
21#include <linux/mm.h> 21#include <linux/mm.h>
22#include <linux/tty.h>
23#include <linux/slab.h> 22#include <linux/slab.h>
24#include <linux/vmalloc.h> 23#include <linux/vmalloc.h>
25#include <linux/delay.h> 24#include <linux/delay.h>
@@ -150,12 +149,11 @@ static int chipsfb_blank(int blank, struct fb_info *info)
150 mutex_lock(&pmac_backlight_mutex); 149 mutex_lock(&pmac_backlight_mutex);
151 150
152 if (pmac_backlight) { 151 if (pmac_backlight) {
153 down(&pmac_backlight->sem);
154
155 /* used to disable backlight only for blank > 1, but it seems 152 /* used to disable backlight only for blank > 1, but it seems
156 * useful at blank = 1 too (saves battery, extends backlight 153 * useful at blank = 1 too (saves battery, extends backlight
157 * life) 154 * life)
158 */ 155 */
156 down(&pmac_backlight->sem);
159 if (blank) 157 if (blank)
160 pmac_backlight->props->power = FB_BLANK_POWERDOWN; 158 pmac_backlight->props->power = FB_BLANK_POWERDOWN;
161 else 159 else
diff --git a/drivers/video/cirrusfb.c b/drivers/video/cirrusfb.c
index 7355da09c721..daf43f535a0b 100644
--- a/drivers/video/cirrusfb.c
+++ b/drivers/video/cirrusfb.c
@@ -41,7 +41,6 @@
41#include <linux/errno.h> 41#include <linux/errno.h>
42#include <linux/string.h> 42#include <linux/string.h>
43#include <linux/mm.h> 43#include <linux/mm.h>
44#include <linux/tty.h>
45#include <linux/slab.h> 44#include <linux/slab.h>
46#include <linux/delay.h> 45#include <linux/delay.h>
47#include <linux/fb.h> 46#include <linux/fb.h>
diff --git a/drivers/video/console/dummycon.c b/drivers/video/console/dummycon.c
index 878707a04398..d9315d99445f 100644
--- a/drivers/video/console/dummycon.c
+++ b/drivers/video/console/dummycon.c
@@ -7,9 +7,9 @@
7 7
8#include <linux/types.h> 8#include <linux/types.h>
9#include <linux/kdev_t.h> 9#include <linux/kdev_t.h>
10#include <linux/tty.h>
11#include <linux/console.h> 10#include <linux/console.h>
12#include <linux/vt_kern.h> 11#include <linux/vt_kern.h>
12#include <linux/screen_info.h>
13#include <linux/init.h> 13#include <linux/init.h>
14#include <linux/module.h> 14#include <linux/module.h>
15 15
diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c
index 94e9f7069bef..390439b3d899 100644
--- a/drivers/video/console/fbcon.c
+++ b/drivers/video/console/fbcon.c
@@ -64,7 +64,6 @@
64#include <linux/fs.h> 64#include <linux/fs.h>
65#include <linux/kernel.h> 65#include <linux/kernel.h>
66#include <linux/delay.h> /* MSch: for IRQ probe */ 66#include <linux/delay.h> /* MSch: for IRQ probe */
67#include <linux/tty.h>
68#include <linux/console.h> 67#include <linux/console.h>
69#include <linux/string.h> 68#include <linux/string.h>
70#include <linux/kd.h> 69#include <linux/kd.h>
diff --git a/drivers/video/console/mdacon.c b/drivers/video/console/mdacon.c
index c89f90edf8ac..52ed12b12acc 100644
--- a/drivers/video/console/mdacon.c
+++ b/drivers/video/console/mdacon.c
@@ -31,7 +31,6 @@
31#include <linux/fs.h> 31#include <linux/fs.h>
32#include <linux/kernel.h> 32#include <linux/kernel.h>
33#include <linux/module.h> 33#include <linux/module.h>
34#include <linux/tty.h>
35#include <linux/console.h> 34#include <linux/console.h>
36#include <linux/string.h> 35#include <linux/string.h>
37#include <linux/kd.h> 36#include <linux/kd.h>
diff --git a/drivers/video/console/newport_con.c b/drivers/video/console/newport_con.c
index 03041311711b..7fa1afeae8dc 100644
--- a/drivers/video/console/newport_con.c
+++ b/drivers/video/console/newport_con.c
@@ -12,7 +12,6 @@
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/kernel.h> 13#include <linux/kernel.h>
14#include <linux/errno.h> 14#include <linux/errno.h>
15#include <linux/tty.h>
16#include <linux/kd.h> 15#include <linux/kd.h>
17#include <linux/selection.h> 16#include <linux/selection.h>
18#include <linux/console.h> 17#include <linux/console.h>
diff --git a/drivers/video/console/promcon.c b/drivers/video/console/promcon.c
index 5cd5e114d1e6..b78eac63459f 100644
--- a/drivers/video/console/promcon.c
+++ b/drivers/video/console/promcon.c
@@ -10,7 +10,6 @@
10#include <linux/errno.h> 10#include <linux/errno.h>
11#include <linux/string.h> 11#include <linux/string.h>
12#include <linux/mm.h> 12#include <linux/mm.h>
13#include <linux/tty.h>
14#include <linux/slab.h> 13#include <linux/slab.h>
15#include <linux/delay.h> 14#include <linux/delay.h>
16#include <linux/console.h> 15#include <linux/console.h>
diff --git a/drivers/video/console/softcursor.c b/drivers/video/console/softcursor.c
index 3957fc7523e2..557c563e4aed 100644
--- a/drivers/video/console/softcursor.c
+++ b/drivers/video/console/softcursor.c
@@ -10,7 +10,6 @@
10 10
11#include <linux/module.h> 11#include <linux/module.h>
12#include <linux/string.h> 12#include <linux/string.h>
13#include <linux/tty.h>
14#include <linux/fb.h> 13#include <linux/fb.h>
15#include <linux/slab.h> 14#include <linux/slab.h>
16 15
diff --git a/drivers/video/console/sticon.c b/drivers/video/console/sticon.c
index 45c4f227e56e..45586aaabd1e 100644
--- a/drivers/video/console/sticon.c
+++ b/drivers/video/console/sticon.c
@@ -37,7 +37,6 @@
37 37
38#include <linux/init.h> 38#include <linux/init.h>
39#include <linux/kernel.h> 39#include <linux/kernel.h>
40#include <linux/tty.h>
41#include <linux/console.h> 40#include <linux/console.h>
42#include <linux/errno.h> 41#include <linux/errno.h>
43#include <linux/vt_kern.h> 42#include <linux/vt_kern.h>
diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c
index 05735ff4e9c5..0a2c10a1abf8 100644
--- a/drivers/video/console/vgacon.c
+++ b/drivers/video/console/vgacon.c
@@ -38,7 +38,6 @@
38#include <linux/sched.h> 38#include <linux/sched.h>
39#include <linux/fs.h> 39#include <linux/fs.h>
40#include <linux/kernel.h> 40#include <linux/kernel.h>
41#include <linux/tty.h>
42#include <linux/console.h> 41#include <linux/console.h>
43#include <linux/string.h> 42#include <linux/string.h>
44#include <linux/kd.h> 43#include <linux/kd.h>
@@ -48,6 +47,7 @@
48#include <linux/spinlock.h> 47#include <linux/spinlock.h>
49#include <linux/ioport.h> 48#include <linux/ioport.h>
50#include <linux/init.h> 49#include <linux/init.h>
50#include <linux/screen_info.h>
51#include <linux/smp_lock.h> 51#include <linux/smp_lock.h>
52#include <video/vga.h> 52#include <video/vga.h>
53#include <asm/io.h> 53#include <asm/io.h>
diff --git a/drivers/video/controlfb.c b/drivers/video/controlfb.c
index acdd6a103dbb..8cc6c0e2d27a 100644
--- a/drivers/video/controlfb.c
+++ b/drivers/video/controlfb.c
@@ -36,7 +36,6 @@
36#include <linux/errno.h> 36#include <linux/errno.h>
37#include <linux/string.h> 37#include <linux/string.h>
38#include <linux/mm.h> 38#include <linux/mm.h>
39#include <linux/tty.h>
40#include <linux/slab.h> 39#include <linux/slab.h>
41#include <linux/vmalloc.h> 40#include <linux/vmalloc.h>
42#include <linux/delay.h> 41#include <linux/delay.h>
diff --git a/drivers/video/cyber2000fb.c b/drivers/video/cyber2000fb.c
index 2e2924957d8f..aae6d9c26e88 100644
--- a/drivers/video/cyber2000fb.c
+++ b/drivers/video/cyber2000fb.c
@@ -41,7 +41,6 @@
41#include <linux/errno.h> 41#include <linux/errno.h>
42#include <linux/string.h> 42#include <linux/string.h>
43#include <linux/mm.h> 43#include <linux/mm.h>
44#include <linux/tty.h>
45#include <linux/slab.h> 44#include <linux/slab.h>
46#include <linux/delay.h> 45#include <linux/delay.h>
47#include <linux/fb.h> 46#include <linux/fb.h>
diff --git a/drivers/video/cyberfb.c b/drivers/video/cyberfb.c
index a3e189f90a7d..c40e72dafb0e 100644
--- a/drivers/video/cyberfb.c
+++ b/drivers/video/cyberfb.c
@@ -81,7 +81,6 @@
81#include <linux/errno.h> 81#include <linux/errno.h>
82#include <linux/string.h> 82#include <linux/string.h>
83#include <linux/mm.h> 83#include <linux/mm.h>
84#include <linux/tty.h>
85#include <linux/slab.h> 84#include <linux/slab.h>
86#include <linux/delay.h> 85#include <linux/delay.h>
87#include <linux/zorro.h> 86#include <linux/zorro.h>
diff --git a/drivers/video/dnfb.c b/drivers/video/dnfb.c
index 5abd3cb00671..b083ea7e9c69 100644
--- a/drivers/video/dnfb.c
+++ b/drivers/video/dnfb.c
@@ -2,7 +2,6 @@
2#include <linux/errno.h> 2#include <linux/errno.h>
3#include <linux/string.h> 3#include <linux/string.h>
4#include <linux/mm.h> 4#include <linux/mm.h>
5#include <linux/tty.h>
6#include <linux/slab.h> 5#include <linux/slab.h>
7#include <linux/delay.h> 6#include <linux/delay.h>
8#include <linux/interrupt.h> 7#include <linux/interrupt.h>
diff --git a/drivers/video/epson1355fb.c b/drivers/video/epson1355fb.c
index f0a621ecc288..737257d278f0 100644
--- a/drivers/video/epson1355fb.c
+++ b/drivers/video/epson1355fb.c
@@ -48,7 +48,6 @@
48#include <linux/errno.h> 48#include <linux/errno.h>
49#include <linux/string.h> 49#include <linux/string.h>
50#include <linux/mm.h> 50#include <linux/mm.h>
51#include <linux/tty.h>
52#include <linux/slab.h> 51#include <linux/slab.h>
53#include <linux/delay.h> 52#include <linux/delay.h>
54#include <linux/fb.h> 53#include <linux/fb.h>
diff --git a/drivers/video/fbcmap.c b/drivers/video/fbcmap.c
index 1f98392a43b3..e8b135f3d80d 100644
--- a/drivers/video/fbcmap.c
+++ b/drivers/video/fbcmap.c
@@ -13,7 +13,6 @@
13 13
14#include <linux/string.h> 14#include <linux/string.h>
15#include <linux/module.h> 15#include <linux/module.h>
16#include <linux/tty.h>
17#include <linux/fb.h> 16#include <linux/fb.h>
18#include <linux/slab.h> 17#include <linux/slab.h>
19 18
diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
index 33034f81114d..4fc9df426c1a 100644
--- a/drivers/video/fbmem.c
+++ b/drivers/video/fbmem.c
@@ -23,7 +23,7 @@
23#include <linux/slab.h> 23#include <linux/slab.h>
24#include <linux/mm.h> 24#include <linux/mm.h>
25#include <linux/mman.h> 25#include <linux/mman.h>
26#include <linux/tty.h> 26#include <linux/vt.h>
27#include <linux/init.h> 27#include <linux/init.h>
28#include <linux/linux_logo.h> 28#include <linux/linux_logo.h>
29#include <linux/proc_fs.h> 29#include <linux/proc_fs.h>
diff --git a/drivers/video/fbmon.c b/drivers/video/fbmon.c
index 3ccfff715a51..de93139ccbb5 100644
--- a/drivers/video/fbmon.c
+++ b/drivers/video/fbmon.c
@@ -26,7 +26,6 @@
26 * for more details. 26 * for more details.
27 * 27 *
28 */ 28 */
29#include <linux/tty.h>
30#include <linux/fb.h> 29#include <linux/fb.h>
31#include <linux/module.h> 30#include <linux/module.h>
32#include <linux/pci.h> 31#include <linux/pci.h>
diff --git a/drivers/video/g364fb.c b/drivers/video/g364fb.c
index 605d1a132020..1b981b635675 100644
--- a/drivers/video/g364fb.c
+++ b/drivers/video/g364fb.c
@@ -21,7 +21,6 @@
21#include <linux/errno.h> 21#include <linux/errno.h>
22#include <linux/string.h> 22#include <linux/string.h>
23#include <linux/mm.h> 23#include <linux/mm.h>
24#include <linux/tty.h>
25#include <linux/slab.h> 24#include <linux/slab.h>
26#include <linux/vmalloc.h> 25#include <linux/vmalloc.h>
27#include <linux/delay.h> 26#include <linux/delay.h>
diff --git a/drivers/video/geode/gx1fb_core.c b/drivers/video/geode/gx1fb_core.c
index 4d3a8871d3d1..bcf9cea54d8b 100644
--- a/drivers/video/geode/gx1fb_core.c
+++ b/drivers/video/geode/gx1fb_core.c
@@ -15,7 +15,6 @@
15#include <linux/errno.h> 15#include <linux/errno.h>
16#include <linux/string.h> 16#include <linux/string.h>
17#include <linux/mm.h> 17#include <linux/mm.h>
18#include <linux/tty.h>
19#include <linux/slab.h> 18#include <linux/slab.h>
20#include <linux/delay.h> 19#include <linux/delay.h>
21#include <linux/fb.h> 20#include <linux/fb.h>
diff --git a/drivers/video/geode/gxfb_core.c b/drivers/video/geode/gxfb_core.c
index 5ef12a3dfa50..0d3643fc6293 100644
--- a/drivers/video/geode/gxfb_core.c
+++ b/drivers/video/geode/gxfb_core.c
@@ -25,7 +25,6 @@
25#include <linux/errno.h> 25#include <linux/errno.h>
26#include <linux/string.h> 26#include <linux/string.h>
27#include <linux/mm.h> 27#include <linux/mm.h>
28#include <linux/tty.h>
29#include <linux/slab.h> 28#include <linux/slab.h>
30#include <linux/delay.h> 29#include <linux/delay.h>
31#include <linux/fb.h> 30#include <linux/fb.h>
diff --git a/drivers/video/hgafb.c b/drivers/video/hgafb.c
index 4e39035cf335..fb9e67228543 100644
--- a/drivers/video/hgafb.c
+++ b/drivers/video/hgafb.c
@@ -36,7 +36,6 @@
36#include <linux/spinlock.h> 36#include <linux/spinlock.h>
37#include <linux/string.h> 37#include <linux/string.h>
38#include <linux/mm.h> 38#include <linux/mm.h>
39#include <linux/tty.h>
40#include <linux/slab.h> 39#include <linux/slab.h>
41#include <linux/delay.h> 40#include <linux/delay.h>
42#include <linux/fb.h> 41#include <linux/fb.h>
diff --git a/drivers/video/hitfb.c b/drivers/video/hitfb.c
index 01864767450d..4cc6b454265e 100644
--- a/drivers/video/hitfb.c
+++ b/drivers/video/hitfb.c
@@ -17,7 +17,6 @@
17#include <linux/errno.h> 17#include <linux/errno.h>
18#include <linux/string.h> 18#include <linux/string.h>
19#include <linux/mm.h> 19#include <linux/mm.h>
20#include <linux/tty.h>
21#include <linux/slab.h> 20#include <linux/slab.h>
22#include <linux/delay.h> 21#include <linux/delay.h>
23#include <linux/init.h> 22#include <linux/init.h>
diff --git a/drivers/video/hpfb.c b/drivers/video/hpfb.c
index abd920a663a0..91cf3b577d15 100644
--- a/drivers/video/hpfb.c
+++ b/drivers/video/hpfb.c
@@ -11,7 +11,6 @@
11#include <linux/errno.h> 11#include <linux/errno.h>
12#include <linux/string.h> 12#include <linux/string.h>
13#include <linux/mm.h> 13#include <linux/mm.h>
14#include <linux/tty.h>
15#include <linux/slab.h> 14#include <linux/slab.h>
16#include <linux/delay.h> 15#include <linux/delay.h>
17#include <linux/init.h> 16#include <linux/init.h>
diff --git a/drivers/video/i810/i810_main.c b/drivers/video/i810/i810_main.c
index fbe8a2c4b04c..a6ca02f2156a 100644
--- a/drivers/video/i810/i810_main.c
+++ b/drivers/video/i810/i810_main.c
@@ -33,7 +33,6 @@
33#include <linux/errno.h> 33#include <linux/errno.h>
34#include <linux/string.h> 34#include <linux/string.h>
35#include <linux/mm.h> 35#include <linux/mm.h>
36#include <linux/tty.h>
37#include <linux/slab.h> 36#include <linux/slab.h>
38#include <linux/fb.h> 37#include <linux/fb.h>
39#include <linux/init.h> 38#include <linux/init.h>
diff --git a/drivers/video/igafb.c b/drivers/video/igafb.c
index 8a0c2d3d3805..67f384f86758 100644
--- a/drivers/video/igafb.c
+++ b/drivers/video/igafb.c
@@ -33,7 +33,6 @@
33#include <linux/errno.h> 33#include <linux/errno.h>
34#include <linux/string.h> 34#include <linux/string.h>
35#include <linux/mm.h> 35#include <linux/mm.h>
36#include <linux/tty.h>
37#include <linux/slab.h> 36#include <linux/slab.h>
38#include <linux/vmalloc.h> 37#include <linux/vmalloc.h>
39#include <linux/delay.h> 38#include <linux/delay.h>
diff --git a/drivers/video/imacfb.c b/drivers/video/imacfb.c
index cdbae173d69a..ff233b84dec4 100644
--- a/drivers/video/imacfb.c
+++ b/drivers/video/imacfb.c
@@ -15,9 +15,9 @@
15#include <linux/mm.h> 15#include <linux/mm.h>
16#include <linux/module.h> 16#include <linux/module.h>
17#include <linux/platform_device.h> 17#include <linux/platform_device.h>
18#include <linux/screen_info.h>
18#include <linux/slab.h> 19#include <linux/slab.h>
19#include <linux/string.h> 20#include <linux/string.h>
20#include <linux/tty.h>
21 21
22#include <asm/io.h> 22#include <asm/io.h>
23 23
diff --git a/drivers/video/imsttfb.c b/drivers/video/imsttfb.c
index 5f393d985b11..5715b8ad0ddc 100644
--- a/drivers/video/imsttfb.c
+++ b/drivers/video/imsttfb.c
@@ -21,7 +21,6 @@
21#include <linux/errno.h> 21#include <linux/errno.h>
22#include <linux/string.h> 22#include <linux/string.h>
23#include <linux/mm.h> 23#include <linux/mm.h>
24#include <linux/tty.h>
25#include <linux/slab.h> 24#include <linux/slab.h>
26#include <linux/vmalloc.h> 25#include <linux/vmalloc.h>
27#include <linux/delay.h> 26#include <linux/delay.h>
diff --git a/drivers/video/intelfb/intelfbdrv.c b/drivers/video/intelfb/intelfbdrv.c
index 3f39d84015f1..06af89d44a0d 100644
--- a/drivers/video/intelfb/intelfbdrv.c
+++ b/drivers/video/intelfb/intelfbdrv.c
@@ -113,7 +113,6 @@
113#include <linux/errno.h> 113#include <linux/errno.h>
114#include <linux/string.h> 114#include <linux/string.h>
115#include <linux/mm.h> 115#include <linux/mm.h>
116#include <linux/tty.h>
117#include <linux/slab.h> 116#include <linux/slab.h>
118#include <linux/delay.h> 117#include <linux/delay.h>
119#include <linux/fb.h> 118#include <linux/fb.h>
@@ -122,6 +121,7 @@
122#include <linux/pci.h> 121#include <linux/pci.h>
123#include <linux/vmalloc.h> 122#include <linux/vmalloc.h>
124#include <linux/pagemap.h> 123#include <linux/pagemap.h>
124#include <linux/screen_info.h>
125 125
126#include <asm/io.h> 126#include <asm/io.h>
127 127
diff --git a/drivers/video/intelfb/intelfbhw.c b/drivers/video/intelfb/intelfbhw.c
index 3b78a57924f0..2a9322f9cfdc 100644
--- a/drivers/video/intelfb/intelfbhw.c
+++ b/drivers/video/intelfb/intelfbhw.c
@@ -24,7 +24,6 @@
24#include <linux/errno.h> 24#include <linux/errno.h>
25#include <linux/string.h> 25#include <linux/string.h>
26#include <linux/mm.h> 26#include <linux/mm.h>
27#include <linux/tty.h>
28#include <linux/slab.h> 27#include <linux/slab.h>
29#include <linux/delay.h> 28#include <linux/delay.h>
30#include <linux/fb.h> 29#include <linux/fb.h>
diff --git a/drivers/video/kyro/fbdev.c b/drivers/video/kyro/fbdev.c
index 2fdbe9b2b04b..f0d614a80f1f 100644
--- a/drivers/video/kyro/fbdev.c
+++ b/drivers/video/kyro/fbdev.c
@@ -16,7 +16,6 @@
16#include <linux/mm.h> 16#include <linux/mm.h>
17#include <linux/errno.h> 17#include <linux/errno.h>
18#include <linux/string.h> 18#include <linux/string.h>
19#include <linux/tty.h>
20#include <linux/delay.h> 19#include <linux/delay.h>
21#include <linux/fb.h> 20#include <linux/fb.h>
22#include <linux/ioctl.h> 21#include <linux/ioctl.h>
diff --git a/drivers/video/macfb.c b/drivers/video/macfb.c
index e6cbd9de944a..80a043807161 100644
--- a/drivers/video/macfb.c
+++ b/drivers/video/macfb.c
@@ -24,7 +24,6 @@
24#include <linux/errno.h> 24#include <linux/errno.h>
25#include <linux/string.h> 25#include <linux/string.h>
26#include <linux/mm.h> 26#include <linux/mm.h>
27#include <linux/tty.h>
28#include <linux/slab.h> 27#include <linux/slab.h>
29#include <linux/delay.h> 28#include <linux/delay.h>
30#include <linux/nubus.h> 29#include <linux/nubus.h>
diff --git a/drivers/video/matrox/matroxfb_base.h b/drivers/video/matrox/matroxfb_base.h
index b95779b57c06..9c25c2f7966b 100644
--- a/drivers/video/matrox/matroxfb_base.h
+++ b/drivers/video/matrox/matroxfb_base.h
@@ -30,7 +30,6 @@
30#include <linux/errno.h> 30#include <linux/errno.h>
31#include <linux/string.h> 31#include <linux/string.h>
32#include <linux/mm.h> 32#include <linux/mm.h>
33#include <linux/tty.h>
34#include <linux/slab.h> 33#include <linux/slab.h>
35#include <linux/delay.h> 34#include <linux/delay.h>
36#include <linux/fb.h> 35#include <linux/fb.h>
diff --git a/drivers/video/maxinefb.c b/drivers/video/maxinefb.c
index f85421bf7cb5..38c8d38de4fd 100644
--- a/drivers/video/maxinefb.c
+++ b/drivers/video/maxinefb.c
@@ -29,7 +29,6 @@
29#include <linux/errno.h> 29#include <linux/errno.h>
30#include <linux/string.h> 30#include <linux/string.h>
31#include <linux/mm.h> 31#include <linux/mm.h>
32#include <linux/tty.h>
33#include <linux/slab.h> 32#include <linux/slab.h>
34#include <linux/delay.h> 33#include <linux/delay.h>
35#include <linux/init.h> 34#include <linux/init.h>
diff --git a/drivers/video/modedb.c b/drivers/video/modedb.c
index ff5454601e22..d1267904c280 100644
--- a/drivers/video/modedb.c
+++ b/drivers/video/modedb.c
@@ -12,7 +12,6 @@
12 */ 12 */
13 13
14#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/tty.h>
16#include <linux/fb.h> 15#include <linux/fb.h>
17#include <linux/sched.h> 16#include <linux/sched.h>
18 17
diff --git a/drivers/video/neofb.c b/drivers/video/neofb.c
index 773855a311e8..59a6f5fa5ae6 100644
--- a/drivers/video/neofb.c
+++ b/drivers/video/neofb.c
@@ -59,7 +59,6 @@
59#include <linux/errno.h> 59#include <linux/errno.h>
60#include <linux/string.h> 60#include <linux/string.h>
61#include <linux/mm.h> 61#include <linux/mm.h>
62#include <linux/tty.h>
63#include <linux/slab.h> 62#include <linux/slab.h>
64#include <linux/delay.h> 63#include <linux/delay.h>
65#include <linux/fb.h> 64#include <linux/fb.h>
diff --git a/drivers/video/nvidia/nv_backlight.c b/drivers/video/nvidia/nv_backlight.c
index 1c1c10c699c5..b45f577094ac 100644
--- a/drivers/video/nvidia/nv_backlight.c
+++ b/drivers/video/nvidia/nv_backlight.c
@@ -26,9 +26,11 @@
26 */ 26 */
27#define MIN_LEVEL 0x158 27#define MIN_LEVEL 0x158
28#define MAX_LEVEL 0x534 28#define MAX_LEVEL 0x534
29#define LEVEL_STEP ((MAX_LEVEL - MIN_LEVEL) / FB_BACKLIGHT_MAX)
29 30
30static struct backlight_properties nvidia_bl_data; 31static struct backlight_properties nvidia_bl_data;
31 32
33/* Call with fb_info->bl_mutex held */
32static int nvidia_bl_get_level_brightness(struct nvidia_par *par, 34static int nvidia_bl_get_level_brightness(struct nvidia_par *par,
33 int level) 35 int level)
34{ 36{
@@ -36,9 +38,7 @@ static int nvidia_bl_get_level_brightness(struct nvidia_par *par,
36 int nlevel; 38 int nlevel;
37 39
38 /* Get and convert the value */ 40 /* Get and convert the value */
39 mutex_lock(&info->bl_mutex); 41 nlevel = MIN_LEVEL + info->bl_curve[level] * LEVEL_STEP;
40 nlevel = info->bl_curve[level] * FB_BACKLIGHT_MAX / MAX_LEVEL;
41 mutex_unlock(&info->bl_mutex);
42 42
43 if (nlevel < 0) 43 if (nlevel < 0)
44 nlevel = 0; 44 nlevel = 0;
@@ -50,7 +50,8 @@ static int nvidia_bl_get_level_brightness(struct nvidia_par *par,
50 return nlevel; 50 return nlevel;
51} 51}
52 52
53static int nvidia_bl_update_status(struct backlight_device *bd) 53/* Call with fb_info->bl_mutex held */
54static int __nvidia_bl_update_status(struct backlight_device *bd)
54{ 55{
55 struct nvidia_par *par = class_get_devdata(&bd->class_dev); 56 struct nvidia_par *par = class_get_devdata(&bd->class_dev);
56 u32 tmp_pcrt, tmp_pmc, fpcontrol; 57 u32 tmp_pcrt, tmp_pmc, fpcontrol;
@@ -84,6 +85,19 @@ static int nvidia_bl_update_status(struct backlight_device *bd)
84 return 0; 85 return 0;
85} 86}
86 87
88static int nvidia_bl_update_status(struct backlight_device *bd)
89{
90 struct nvidia_par *par = class_get_devdata(&bd->class_dev);
91 struct fb_info *info = pci_get_drvdata(par->pci_dev);
92 int ret;
93
94 mutex_lock(&info->bl_mutex);
95 ret = __nvidia_bl_update_status(bd);
96 mutex_unlock(&info->bl_mutex);
97
98 return ret;
99}
100
87static int nvidia_bl_get_brightness(struct backlight_device *bd) 101static int nvidia_bl_get_brightness(struct backlight_device *bd)
88{ 102{
89 return bd->props->brightness; 103 return bd->props->brightness;
@@ -96,6 +110,16 @@ static struct backlight_properties nvidia_bl_data = {
96 .max_brightness = (FB_BACKLIGHT_LEVELS - 1), 110 .max_brightness = (FB_BACKLIGHT_LEVELS - 1),
97}; 111};
98 112
113void nvidia_bl_set_power(struct fb_info *info, int power)
114{
115 mutex_lock(&info->bl_mutex);
116 up(&info->bl_dev->sem);
117 info->bl_dev->props->power = power;
118 __nvidia_bl_update_status(info->bl_dev);
119 down(&info->bl_dev->sem);
120 mutex_unlock(&info->bl_mutex);
121}
122
99void nvidia_bl_init(struct nvidia_par *par) 123void nvidia_bl_init(struct nvidia_par *par)
100{ 124{
101 struct fb_info *info = pci_get_drvdata(par->pci_dev); 125 struct fb_info *info = pci_get_drvdata(par->pci_dev);
diff --git a/drivers/video/nvidia/nv_proto.h b/drivers/video/nvidia/nv_proto.h
index 6fba656cd56b..861271017655 100644
--- a/drivers/video/nvidia/nv_proto.h
+++ b/drivers/video/nvidia/nv_proto.h
@@ -68,9 +68,11 @@ extern u8 byte_rev[256];
68#ifdef CONFIG_FB_NVIDIA_BACKLIGHT 68#ifdef CONFIG_FB_NVIDIA_BACKLIGHT
69extern void nvidia_bl_init(struct nvidia_par *par); 69extern void nvidia_bl_init(struct nvidia_par *par);
70extern void nvidia_bl_exit(struct nvidia_par *par); 70extern void nvidia_bl_exit(struct nvidia_par *par);
71extern void nvidia_bl_set_power(struct fb_info *info, int power);
71#else 72#else
72static inline void nvidia_bl_init(struct nvidia_par *par) {} 73static inline void nvidia_bl_init(struct nvidia_par *par) {}
73static inline void nvidia_bl_exit(struct nvidia_par *par) {} 74static inline void nvidia_bl_exit(struct nvidia_par *par) {}
75static inline void nvidia_bl_set_power(struct fb_info *info, int power) {}
74#endif 76#endif
75 77
76#endif /* __NV_PROTO_H__ */ 78#endif /* __NV_PROTO_H__ */
diff --git a/drivers/video/nvidia/nvidia.c b/drivers/video/nvidia/nvidia.c
index b02d6033cc0c..9f2066f0745a 100644
--- a/drivers/video/nvidia/nvidia.c
+++ b/drivers/video/nvidia/nvidia.c
@@ -14,7 +14,6 @@
14#include <linux/errno.h> 14#include <linux/errno.h>
15#include <linux/string.h> 15#include <linux/string.h>
16#include <linux/mm.h> 16#include <linux/mm.h>
17#include <linux/tty.h>
18#include <linux/slab.h> 17#include <linux/slab.h>
19#include <linux/delay.h> 18#include <linux/delay.h>
20#include <linux/fb.h> 19#include <linux/fb.h>
@@ -933,16 +932,7 @@ static int nvidiafb_blank(int blank, struct fb_info *info)
933 NVWriteSeq(par, 0x01, tmp); 932 NVWriteSeq(par, 0x01, tmp);
934 NVWriteCrtc(par, 0x1a, vesa); 933 NVWriteCrtc(par, 0x1a, vesa);
935 934
936#ifdef CONFIG_FB_NVIDIA_BACKLIGHT 935 nvidia_bl_set_power(info, blank);
937 mutex_lock(&info->bl_mutex);
938 if (info->bl_dev) {
939 down(&info->bl_dev->sem);
940 info->bl_dev->props->power = blank;
941 info->bl_dev->props->update_status(info->bl_dev);
942 up(&info->bl_dev->sem);
943 }
944 mutex_unlock(&info->bl_mutex);
945#endif
946 936
947 NVTRACE_LEAVE(); 937 NVTRACE_LEAVE();
948 938
diff --git a/drivers/video/offb.c b/drivers/video/offb.c
index 71ce1fa45cf4..ce5f3031b99b 100644
--- a/drivers/video/offb.c
+++ b/drivers/video/offb.c
@@ -17,7 +17,6 @@
17#include <linux/errno.h> 17#include <linux/errno.h>
18#include <linux/string.h> 18#include <linux/string.h>
19#include <linux/mm.h> 19#include <linux/mm.h>
20#include <linux/tty.h>
21#include <linux/slab.h> 20#include <linux/slab.h>
22#include <linux/vmalloc.h> 21#include <linux/vmalloc.h>
23#include <linux/delay.h> 22#include <linux/delay.h>
diff --git a/drivers/video/platinumfb.c b/drivers/video/platinumfb.c
index 450e802e0aa8..983be3ec2345 100644
--- a/drivers/video/platinumfb.c
+++ b/drivers/video/platinumfb.c
@@ -22,7 +22,6 @@
22#include <linux/errno.h> 22#include <linux/errno.h>
23#include <linux/string.h> 23#include <linux/string.h>
24#include <linux/mm.h> 24#include <linux/mm.h>
25#include <linux/tty.h>
26#include <linux/slab.h> 25#include <linux/slab.h>
27#include <linux/vmalloc.h> 26#include <linux/vmalloc.h>
28#include <linux/delay.h> 27#include <linux/delay.h>
diff --git a/drivers/video/pm2fb.c b/drivers/video/pm2fb.c
index 49a203e1591c..a560a2223825 100644
--- a/drivers/video/pm2fb.c
+++ b/drivers/video/pm2fb.c
@@ -33,7 +33,6 @@
33#include <linux/errno.h> 33#include <linux/errno.h>
34#include <linux/string.h> 34#include <linux/string.h>
35#include <linux/mm.h> 35#include <linux/mm.h>
36#include <linux/tty.h>
37#include <linux/slab.h> 36#include <linux/slab.h>
38#include <linux/delay.h> 37#include <linux/delay.h>
39#include <linux/fb.h> 38#include <linux/fb.h>
diff --git a/drivers/video/pm3fb.c b/drivers/video/pm3fb.c
index 0e0f977b05ee..1d81ef47efd3 100644
--- a/drivers/video/pm3fb.c
+++ b/drivers/video/pm3fb.c
@@ -57,7 +57,6 @@
57#include <linux/errno.h> 57#include <linux/errno.h>
58#include <linux/string.h> 58#include <linux/string.h>
59#include <linux/mm.h> 59#include <linux/mm.h>
60#include <linux/tty.h>
61#include <linux/slab.h> 60#include <linux/slab.h>
62#include <linux/vmalloc.h> 61#include <linux/vmalloc.h>
63#include <linux/delay.h> 62#include <linux/delay.h>
diff --git a/drivers/video/pmag-aa-fb.c b/drivers/video/pmag-aa-fb.c
index d92f352211ef..68ca3cc40770 100644
--- a/drivers/video/pmag-aa-fb.c
+++ b/drivers/video/pmag-aa-fb.c
@@ -29,7 +29,6 @@
29#include <linux/string.h> 29#include <linux/string.h>
30#include <linux/timer.h> 30#include <linux/timer.h>
31#include <linux/mm.h> 31#include <linux/mm.h>
32#include <linux/tty.h>
33#include <linux/slab.h> 32#include <linux/slab.h>
34#include <linux/delay.h> 33#include <linux/delay.h>
35#include <linux/init.h> 34#include <linux/init.h>
diff --git a/drivers/video/pvr2fb.c b/drivers/video/pvr2fb.c
index 4a1e0e856920..940ba2be55e9 100644
--- a/drivers/video/pvr2fb.c
+++ b/drivers/video/pvr2fb.c
@@ -53,7 +53,6 @@
53#include <linux/errno.h> 53#include <linux/errno.h>
54#include <linux/string.h> 54#include <linux/string.h>
55#include <linux/mm.h> 55#include <linux/mm.h>
56#include <linux/tty.h>
57#include <linux/slab.h> 56#include <linux/slab.h>
58#include <linux/delay.h> 57#include <linux/delay.h>
59#include <linux/interrupt.h> 58#include <linux/interrupt.h>
diff --git a/drivers/video/q40fb.c b/drivers/video/q40fb.c
index fc91dbf896d2..48536c3e58a4 100644
--- a/drivers/video/q40fb.c
+++ b/drivers/video/q40fb.c
@@ -14,7 +14,6 @@
14#include <linux/errno.h> 14#include <linux/errno.h>
15#include <linux/string.h> 15#include <linux/string.h>
16#include <linux/mm.h> 16#include <linux/mm.h>
17#include <linux/tty.h>
18#include <linux/slab.h> 17#include <linux/slab.h>
19#include <linux/delay.h> 18#include <linux/delay.h>
20#include <linux/interrupt.h> 19#include <linux/interrupt.h>
diff --git a/drivers/video/retz3fb.c b/drivers/video/retz3fb.c
index 5e2c64f622cb..cf41ff177644 100644
--- a/drivers/video/retz3fb.c
+++ b/drivers/video/retz3fb.c
@@ -25,7 +25,6 @@
25#include <linux/errno.h> 25#include <linux/errno.h>
26#include <linux/string.h> 26#include <linux/string.h>
27#include <linux/mm.h> 27#include <linux/mm.h>
28#include <linux/tty.h>
29#include <linux/slab.h> 28#include <linux/slab.h>
30#include <linux/delay.h> 29#include <linux/delay.h>
31#include <linux/fb.h> 30#include <linux/fb.h>
diff --git a/drivers/video/riva/fbdev.c b/drivers/video/riva/fbdev.c
index 2788655e6e7d..33dddbae5420 100644
--- a/drivers/video/riva/fbdev.c
+++ b/drivers/video/riva/fbdev.c
@@ -34,7 +34,6 @@
34#include <linux/errno.h> 34#include <linux/errno.h>
35#include <linux/string.h> 35#include <linux/string.h>
36#include <linux/mm.h> 36#include <linux/mm.h>
37#include <linux/tty.h>
38#include <linux/slab.h> 37#include <linux/slab.h>
39#include <linux/delay.h> 38#include <linux/delay.h>
40#include <linux/fb.h> 39#include <linux/fb.h>
@@ -278,9 +277,11 @@ static const struct riva_regs reg_template = {
278 */ 277 */
279#define MIN_LEVEL 0x158 278#define MIN_LEVEL 0x158
280#define MAX_LEVEL 0x534 279#define MAX_LEVEL 0x534
280#define LEVEL_STEP ((MAX_LEVEL - MIN_LEVEL) / FB_BACKLIGHT_MAX)
281 281
282static struct backlight_properties riva_bl_data; 282static struct backlight_properties riva_bl_data;
283 283
284/* Call with fb_info->bl_mutex held */
284static int riva_bl_get_level_brightness(struct riva_par *par, 285static int riva_bl_get_level_brightness(struct riva_par *par,
285 int level) 286 int level)
286{ 287{
@@ -288,9 +289,7 @@ static int riva_bl_get_level_brightness(struct riva_par *par,
288 int nlevel; 289 int nlevel;
289 290
290 /* Get and convert the value */ 291 /* Get and convert the value */
291 mutex_lock(&info->bl_mutex); 292 nlevel = MIN_LEVEL + info->bl_curve[level] * LEVEL_STEP;
292 nlevel = info->bl_curve[level] * FB_BACKLIGHT_MAX / MAX_LEVEL;
293 mutex_unlock(&info->bl_mutex);
294 293
295 if (nlevel < 0) 294 if (nlevel < 0)
296 nlevel = 0; 295 nlevel = 0;
@@ -302,7 +301,8 @@ static int riva_bl_get_level_brightness(struct riva_par *par,
302 return nlevel; 301 return nlevel;
303} 302}
304 303
305static int riva_bl_update_status(struct backlight_device *bd) 304/* Call with fb_info->bl_mutex held */
305static int __riva_bl_update_status(struct backlight_device *bd)
306{ 306{
307 struct riva_par *par = class_get_devdata(&bd->class_dev); 307 struct riva_par *par = class_get_devdata(&bd->class_dev);
308 U032 tmp_pcrt, tmp_pmc; 308 U032 tmp_pcrt, tmp_pmc;
@@ -327,6 +327,19 @@ static int riva_bl_update_status(struct backlight_device *bd)
327 return 0; 327 return 0;
328} 328}
329 329
330static int riva_bl_update_status(struct backlight_device *bd)
331{
332 struct riva_par *par = class_get_devdata(&bd->class_dev);
333 struct fb_info *info = pci_get_drvdata(par->pdev);
334 int ret;
335
336 mutex_lock(&info->bl_mutex);
337 ret = __riva_bl_update_status(bd);
338 mutex_unlock(&info->bl_mutex);
339
340 return ret;
341}
342
330static int riva_bl_get_brightness(struct backlight_device *bd) 343static int riva_bl_get_brightness(struct backlight_device *bd)
331{ 344{
332 return bd->props->brightness; 345 return bd->props->brightness;
@@ -339,6 +352,16 @@ static struct backlight_properties riva_bl_data = {
339 .max_brightness = (FB_BACKLIGHT_LEVELS - 1), 352 .max_brightness = (FB_BACKLIGHT_LEVELS - 1),
340}; 353};
341 354
355static void riva_bl_set_power(struct fb_info *info, int power)
356{
357 mutex_lock(&info->bl_mutex);
358 up(&info->bl_dev->sem);
359 info->bl_dev->props->power = power;
360 __riva_bl_update_status(info->bl_dev);
361 down(&info->bl_dev->sem);
362 mutex_unlock(&info->bl_mutex);
363}
364
342static void riva_bl_init(struct riva_par *par) 365static void riva_bl_init(struct riva_par *par)
343{ 366{
344 struct fb_info *info = pci_get_drvdata(par->pdev); 367 struct fb_info *info = pci_get_drvdata(par->pdev);
@@ -419,6 +442,7 @@ static void riva_bl_exit(struct riva_par *par)
419#else 442#else
420static inline void riva_bl_init(struct riva_par *par) {} 443static inline void riva_bl_init(struct riva_par *par) {}
421static inline void riva_bl_exit(struct riva_par *par) {} 444static inline void riva_bl_exit(struct riva_par *par) {}
445static inline void riva_bl_set_power(struct fb_info *info, int power) {}
422#endif /* CONFIG_FB_RIVA_BACKLIGHT */ 446#endif /* CONFIG_FB_RIVA_BACKLIGHT */
423 447
424/* ------------------------------------------------------------------------- * 448/* ------------------------------------------------------------------------- *
@@ -1337,16 +1361,7 @@ static int rivafb_blank(int blank, struct fb_info *info)
1337 SEQout(par, 0x01, tmp); 1361 SEQout(par, 0x01, tmp);
1338 CRTCout(par, 0x1a, vesa); 1362 CRTCout(par, 0x1a, vesa);
1339 1363
1340#ifdef CONFIG_FB_RIVA_BACKLIGHT 1364 riva_bl_set_power(info, blank);
1341 mutex_lock(&info->bl_mutex);
1342 if (info->bl_dev) {
1343 down(&info->bl_dev->sem);
1344 info->bl_dev->props->power = blank;
1345 info->bl_dev->props->update_status(info->bl_dev);
1346 up(&info->bl_dev->sem);
1347 }
1348 mutex_unlock(&info->bl_mutex);
1349#endif
1350 1365
1351 NVTRACE_LEAVE(); 1366 NVTRACE_LEAVE();
1352 1367
diff --git a/drivers/video/s3c2410fb.c b/drivers/video/s3c2410fb.c
index f461eb10cc79..ad3bdd6f1ac1 100644
--- a/drivers/video/s3c2410fb.c
+++ b/drivers/video/s3c2410fb.c
@@ -76,7 +76,6 @@
76#include <linux/errno.h> 76#include <linux/errno.h>
77#include <linux/string.h> 77#include <linux/string.h>
78#include <linux/mm.h> 78#include <linux/mm.h>
79#include <linux/tty.h>
80#include <linux/slab.h> 79#include <linux/slab.h>
81#include <linux/delay.h> 80#include <linux/delay.h>
82#include <linux/fb.h> 81#include <linux/fb.h>
diff --git a/drivers/video/savage/savagefb_driver.c b/drivers/video/savage/savagefb_driver.c
index 4729af477fbf..461e094e7b45 100644
--- a/drivers/video/savage/savagefb_driver.c
+++ b/drivers/video/savage/savagefb_driver.c
@@ -46,7 +46,6 @@
46#include <linux/errno.h> 46#include <linux/errno.h>
47#include <linux/string.h> 47#include <linux/string.h>
48#include <linux/mm.h> 48#include <linux/mm.h>
49#include <linux/tty.h>
50#include <linux/slab.h> 49#include <linux/slab.h>
51#include <linux/delay.h> 50#include <linux/delay.h>
52#include <linux/fb.h> 51#include <linux/fb.h>
diff --git a/drivers/video/sis/sis_main.c b/drivers/video/sis/sis_main.c
index b848ca7db7f9..895ebda7d9e3 100644
--- a/drivers/video/sis/sis_main.c
+++ b/drivers/video/sis/sis_main.c
@@ -44,7 +44,13 @@
44#include <linux/errno.h> 44#include <linux/errno.h>
45#include <linux/string.h> 45#include <linux/string.h>
46#include <linux/mm.h> 46#include <linux/mm.h>
47
48#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,17)
47#include <linux/tty.h> 49#include <linux/tty.h>
50#else
51#include <linux/screen_info.h>
52#endif
53
48#include <linux/slab.h> 54#include <linux/slab.h>
49#include <linux/fb.h> 55#include <linux/fb.h>
50#include <linux/selection.h> 56#include <linux/selection.h>
diff --git a/drivers/video/skeletonfb.c b/drivers/video/skeletonfb.c
index 67f429e93189..bb96cb65fdaa 100644
--- a/drivers/video/skeletonfb.c
+++ b/drivers/video/skeletonfb.c
@@ -47,7 +47,6 @@
47#include <linux/errno.h> 47#include <linux/errno.h>
48#include <linux/string.h> 48#include <linux/string.h>
49#include <linux/mm.h> 49#include <linux/mm.h>
50#include <linux/tty.h>
51#include <linux/slab.h> 50#include <linux/slab.h>
52#include <linux/delay.h> 51#include <linux/delay.h>
53#include <linux/fb.h> 52#include <linux/fb.h>
diff --git a/drivers/video/sun3fb.c b/drivers/video/sun3fb.c
index e046e20f02b9..f80356dfa8e8 100644
--- a/drivers/video/sun3fb.c
+++ b/drivers/video/sun3fb.c
@@ -30,7 +30,6 @@
30#include <linux/errno.h> 30#include <linux/errno.h>
31#include <linux/string.h> 31#include <linux/string.h>
32#include <linux/mm.h> 32#include <linux/mm.h>
33#include <linux/tty.h>
34#include <linux/slab.h> 33#include <linux/slab.h>
35#include <linux/vmalloc.h> 34#include <linux/vmalloc.h>
36#include <linux/delay.h> 35#include <linux/delay.h>
diff --git a/drivers/video/tdfxfb.c b/drivers/video/tdfxfb.c
index 239b1496874b..689ce0270b81 100644
--- a/drivers/video/tdfxfb.c
+++ b/drivers/video/tdfxfb.c
@@ -63,7 +63,6 @@
63#include <linux/errno.h> 63#include <linux/errno.h>
64#include <linux/string.h> 64#include <linux/string.h>
65#include <linux/mm.h> 65#include <linux/mm.h>
66#include <linux/tty.h>
67#include <linux/slab.h> 66#include <linux/slab.h>
68#include <linux/delay.h> 67#include <linux/delay.h>
69#include <linux/interrupt.h> 68#include <linux/interrupt.h>
diff --git a/drivers/video/tgafb.c b/drivers/video/tgafb.c
index 6c2c78ab9827..94fde625a6c0 100644
--- a/drivers/video/tgafb.c
+++ b/drivers/video/tgafb.c
@@ -17,7 +17,6 @@
17#include <linux/errno.h> 17#include <linux/errno.h>
18#include <linux/string.h> 18#include <linux/string.h>
19#include <linux/mm.h> 19#include <linux/mm.h>
20#include <linux/tty.h>
21#include <linux/slab.h> 20#include <linux/slab.h>
22#include <linux/delay.h> 21#include <linux/delay.h>
23#include <linux/init.h> 22#include <linux/init.h>
diff --git a/drivers/video/tx3912fb.c b/drivers/video/tx3912fb.c
index d904da44e1aa..07389ba01eff 100644
--- a/drivers/video/tx3912fb.c
+++ b/drivers/video/tx3912fb.c
@@ -14,7 +14,6 @@
14#include <linux/kernel.h> 14#include <linux/kernel.h>
15#include <linux/errno.h> 15#include <linux/errno.h>
16#include <linux/string.h> 16#include <linux/string.h>
17#include <linux/tty.h>
18#include <linux/delay.h> 17#include <linux/delay.h>
19#include <linux/interrupt.h> 18#include <linux/interrupt.h>
20#include <linux/init.h> 19#include <linux/init.h>
diff --git a/drivers/video/valkyriefb.c b/drivers/video/valkyriefb.c
index 1d76c035050e..47f27924a7d7 100644
--- a/drivers/video/valkyriefb.c
+++ b/drivers/video/valkyriefb.c
@@ -44,7 +44,6 @@
44#include <linux/errno.h> 44#include <linux/errno.h>
45#include <linux/string.h> 45#include <linux/string.h>
46#include <linux/mm.h> 46#include <linux/mm.h>
47#include <linux/tty.h>
48#include <linux/slab.h> 47#include <linux/slab.h>
49#include <linux/vmalloc.h> 48#include <linux/vmalloc.h>
50#include <linux/delay.h> 49#include <linux/delay.h>
diff --git a/drivers/video/vesafb.c b/drivers/video/vesafb.c
index 5718924b677f..2196448396ec 100644
--- a/drivers/video/vesafb.c
+++ b/drivers/video/vesafb.c
@@ -13,13 +13,13 @@
13#include <linux/errno.h> 13#include <linux/errno.h>
14#include <linux/string.h> 14#include <linux/string.h>
15#include <linux/mm.h> 15#include <linux/mm.h>
16#include <linux/tty.h>
17#include <linux/slab.h> 16#include <linux/slab.h>
18#include <linux/delay.h> 17#include <linux/delay.h>
19#include <linux/fb.h> 18#include <linux/fb.h>
20#include <linux/ioport.h> 19#include <linux/ioport.h>
21#include <linux/init.h> 20#include <linux/init.h>
22#include <linux/platform_device.h> 21#include <linux/platform_device.h>
22#include <linux/screen_info.h>
23 23
24#include <video/vga.h> 24#include <video/vga.h>
25#include <asm/io.h> 25#include <asm/io.h>
diff --git a/drivers/video/vfb.c b/drivers/video/vfb.c
index d073ffb6e1f9..a9b99b01bd8e 100644
--- a/drivers/video/vfb.c
+++ b/drivers/video/vfb.c
@@ -15,7 +15,6 @@
15#include <linux/errno.h> 15#include <linux/errno.h>
16#include <linux/string.h> 16#include <linux/string.h>
17#include <linux/mm.h> 17#include <linux/mm.h>
18#include <linux/tty.h>
19#include <linux/slab.h> 18#include <linux/slab.h>
20#include <linux/vmalloc.h> 19#include <linux/vmalloc.h>
21#include <linux/delay.h> 20#include <linux/delay.h>
diff --git a/drivers/video/vga16fb.c b/drivers/video/vga16fb.c
index 3c404c9bd36c..43d5a6d9c4a6 100644
--- a/drivers/video/vga16fb.c
+++ b/drivers/video/vga16fb.c
@@ -15,13 +15,13 @@
15#include <linux/errno.h> 15#include <linux/errno.h>
16#include <linux/string.h> 16#include <linux/string.h>
17#include <linux/mm.h> 17#include <linux/mm.h>
18#include <linux/tty.h>
19#include <linux/slab.h> 18#include <linux/slab.h>
20#include <linux/delay.h> 19#include <linux/delay.h>
21#include <linux/fb.h> 20#include <linux/fb.h>
22#include <linux/ioport.h> 21#include <linux/ioport.h>
23#include <linux/init.h> 22#include <linux/init.h>
24#include <linux/platform_device.h> 23#include <linux/platform_device.h>
24#include <linux/screen_info.h>
25 25
26#include <asm/io.h> 26#include <asm/io.h>
27#include <video/vga.h> 27#include <video/vga.h>
diff --git a/drivers/video/virgefb.c b/drivers/video/virgefb.c
index 5ea2345dab99..64378959dd7b 100644
--- a/drivers/video/virgefb.c
+++ b/drivers/video/virgefb.c
@@ -39,7 +39,6 @@
39#include <linux/errno.h> 39#include <linux/errno.h>
40#include <linux/string.h> 40#include <linux/string.h>
41#include <linux/mm.h> 41#include <linux/mm.h>
42#include <linux/tty.h>
43#include <linux/slab.h> 42#include <linux/slab.h>
44#include <linux/delay.h> 43#include <linux/delay.h>
45#include <linux/zorro.h> 44#include <linux/zorro.h>
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index f42e64210ee5..672a3b90bc55 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -1185,8 +1185,6 @@ static int maydump(struct vm_area_struct *vma)
1185 return 1; 1185 return 1;
1186} 1186}
1187 1187
1188#define roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y))
1189
1190/* An ELF note in memory */ 1188/* An ELF note in memory */
1191struct memelfnote 1189struct memelfnote
1192{ 1190{
diff --git a/fs/binfmt_elf_fdpic.c b/fs/binfmt_elf_fdpic.c
index eba4e23b9ca0..2f3365829229 100644
--- a/fs/binfmt_elf_fdpic.c
+++ b/fs/binfmt_elf_fdpic.c
@@ -1,6 +1,6 @@
1/* binfmt_elf_fdpic.c: FDPIC ELF binary format 1/* binfmt_elf_fdpic.c: FDPIC ELF binary format
2 * 2 *
3 * Copyright (C) 2003, 2004 Red Hat, Inc. All Rights Reserved. 3 * Copyright (C) 2003, 2004, 2006 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com) 4 * Written by David Howells (dhowells@redhat.com)
5 * Derived from binfmt_elf.c 5 * Derived from binfmt_elf.c
6 * 6 *
@@ -24,7 +24,9 @@
24#include <linux/file.h> 24#include <linux/file.h>
25#include <linux/fcntl.h> 25#include <linux/fcntl.h>
26#include <linux/slab.h> 26#include <linux/slab.h>
27#include <linux/pagemap.h>
27#include <linux/highmem.h> 28#include <linux/highmem.h>
29#include <linux/highuid.h>
28#include <linux/personality.h> 30#include <linux/personality.h>
29#include <linux/ptrace.h> 31#include <linux/ptrace.h>
30#include <linux/init.h> 32#include <linux/init.h>
@@ -48,45 +50,59 @@ typedef char *elf_caddr_t;
48#define kdebug(fmt, ...) do {} while(0) 50#define kdebug(fmt, ...) do {} while(0)
49#endif 51#endif
50 52
53#if 0
54#define kdcore(fmt, ...) printk("FDPIC "fmt"\n" ,##__VA_ARGS__ )
55#else
56#define kdcore(fmt, ...) do {} while(0)
57#endif
58
51MODULE_LICENSE("GPL"); 59MODULE_LICENSE("GPL");
52 60
53static int load_elf_fdpic_binary(struct linux_binprm *bprm, struct pt_regs *regs); 61static int load_elf_fdpic_binary(struct linux_binprm *, struct pt_regs *);
54//static int load_elf_fdpic_library(struct file *); 62static int elf_fdpic_fetch_phdrs(struct elf_fdpic_params *, struct file *);
55static int elf_fdpic_fetch_phdrs(struct elf_fdpic_params *params, struct file *file); 63static int elf_fdpic_map_file(struct elf_fdpic_params *, struct file *,
56static int elf_fdpic_map_file(struct elf_fdpic_params *params, 64 struct mm_struct *, const char *);
57 struct file *file,
58 struct mm_struct *mm,
59 const char *what);
60 65
61static int create_elf_fdpic_tables(struct linux_binprm *bprm, 66static int create_elf_fdpic_tables(struct linux_binprm *, struct mm_struct *,
62 struct mm_struct *mm, 67 struct elf_fdpic_params *,
63 struct elf_fdpic_params *exec_params, 68 struct elf_fdpic_params *);
64 struct elf_fdpic_params *interp_params);
65 69
66#ifndef CONFIG_MMU 70#ifndef CONFIG_MMU
67static int elf_fdpic_transfer_args_to_stack(struct linux_binprm *bprm, unsigned long *_sp); 71static int elf_fdpic_transfer_args_to_stack(struct linux_binprm *,
68static int elf_fdpic_map_file_constdisp_on_uclinux(struct elf_fdpic_params *params, 72 unsigned long *);
69 struct file *file, 73static int elf_fdpic_map_file_constdisp_on_uclinux(struct elf_fdpic_params *,
70 struct mm_struct *mm); 74 struct file *,
75 struct mm_struct *);
71#endif 76#endif
72 77
73static int elf_fdpic_map_file_by_direct_mmap(struct elf_fdpic_params *params, 78static int elf_fdpic_map_file_by_direct_mmap(struct elf_fdpic_params *,
74 struct file *file, 79 struct file *, struct mm_struct *);
75 struct mm_struct *mm); 80
81#if defined(USE_ELF_CORE_DUMP) && defined(CONFIG_ELF_CORE)
82static int elf_fdpic_core_dump(long, struct pt_regs *, struct file *);
83#endif
76 84
77static struct linux_binfmt elf_fdpic_format = { 85static struct linux_binfmt elf_fdpic_format = {
78 .module = THIS_MODULE, 86 .module = THIS_MODULE,
79 .load_binary = load_elf_fdpic_binary, 87 .load_binary = load_elf_fdpic_binary,
80// .load_shlib = load_elf_fdpic_library, 88#if defined(USE_ELF_CORE_DUMP) && defined(CONFIG_ELF_CORE)
81// .core_dump = elf_fdpic_core_dump, 89 .core_dump = elf_fdpic_core_dump,
90#endif
82 .min_coredump = ELF_EXEC_PAGESIZE, 91 .min_coredump = ELF_EXEC_PAGESIZE,
83}; 92};
84 93
85static int __init init_elf_fdpic_binfmt(void) { return register_binfmt(&elf_fdpic_format); } 94static int __init init_elf_fdpic_binfmt(void)
86static void __exit exit_elf_fdpic_binfmt(void) { unregister_binfmt(&elf_fdpic_format); } 95{
96 return register_binfmt(&elf_fdpic_format);
97}
98
99static void __exit exit_elf_fdpic_binfmt(void)
100{
101 unregister_binfmt(&elf_fdpic_format);
102}
87 103
88module_init(init_elf_fdpic_binfmt) 104core_initcall(init_elf_fdpic_binfmt);
89module_exit(exit_elf_fdpic_binfmt) 105module_exit(exit_elf_fdpic_binfmt);
90 106
91static int is_elf_fdpic(struct elfhdr *hdr, struct file *file) 107static int is_elf_fdpic(struct elfhdr *hdr, struct file *file)
92{ 108{
@@ -105,7 +121,8 @@ static int is_elf_fdpic(struct elfhdr *hdr, struct file *file)
105/* 121/*
106 * read the program headers table into memory 122 * read the program headers table into memory
107 */ 123 */
108static int elf_fdpic_fetch_phdrs(struct elf_fdpic_params *params, struct file *file) 124static int elf_fdpic_fetch_phdrs(struct elf_fdpic_params *params,
125 struct file *file)
109{ 126{
110 struct elf32_phdr *phdr; 127 struct elf32_phdr *phdr;
111 unsigned long size; 128 unsigned long size;
@@ -121,7 +138,8 @@ static int elf_fdpic_fetch_phdrs(struct elf_fdpic_params *params, struct file *f
121 if (!params->phdrs) 138 if (!params->phdrs)
122 return -ENOMEM; 139 return -ENOMEM;
123 140
124 retval = kernel_read(file, params->hdr.e_phoff, (char *) params->phdrs, size); 141 retval = kernel_read(file, params->hdr.e_phoff,
142 (char *) params->phdrs, size);
125 if (retval < 0) 143 if (retval < 0)
126 return retval; 144 return retval;
127 145
@@ -141,17 +159,24 @@ static int elf_fdpic_fetch_phdrs(struct elf_fdpic_params *params, struct file *f
141 } 159 }
142 160
143 return 0; 161 return 0;
144} /* end elf_fdpic_fetch_phdrs() */ 162}
145 163
146/*****************************************************************************/ 164/*****************************************************************************/
147/* 165/*
148 * load an fdpic binary into various bits of memory 166 * load an fdpic binary into various bits of memory
149 */ 167 */
150static int load_elf_fdpic_binary(struct linux_binprm *bprm, struct pt_regs *regs) 168static int load_elf_fdpic_binary(struct linux_binprm *bprm,
169 struct pt_regs *regs)
151{ 170{
152 struct elf_fdpic_params exec_params, interp_params; 171 struct elf_fdpic_params exec_params, interp_params;
153 struct elf_phdr *phdr; 172 struct elf_phdr *phdr;
154 unsigned long stack_size; 173 unsigned long stack_size, entryaddr;
174#ifndef CONFIG_MMU
175 unsigned long fullsize;
176#endif
177#ifdef ELF_FDPIC_PLAT_INIT
178 unsigned long dynaddr;
179#endif
155 struct file *interpreter = NULL; /* to shut gcc up */ 180 struct file *interpreter = NULL; /* to shut gcc up */
156 char *interpreter_name = NULL; 181 char *interpreter_name = NULL;
157 int executable_stack; 182 int executable_stack;
@@ -212,7 +237,8 @@ static int load_elf_fdpic_binary(struct linux_binprm *bprm, struct pt_regs *regs
212 goto error; 237 goto error;
213 } 238 }
214 239
215 retval = kernel_read(interpreter, 0, bprm->buf, BINPRM_BUF_SIZE); 240 retval = kernel_read(interpreter, 0, bprm->buf,
241 BINPRM_BUF_SIZE);
216 if (retval < 0) 242 if (retval < 0)
217 goto error; 243 goto error;
218 244
@@ -295,7 +321,8 @@ static int load_elf_fdpic_binary(struct linux_binprm *bprm, struct pt_regs *regs
295 &current->mm->start_stack, 321 &current->mm->start_stack,
296 &current->mm->start_brk); 322 &current->mm->start_brk);
297 323
298 retval = setup_arg_pages(bprm, current->mm->start_stack, executable_stack); 324 retval = setup_arg_pages(bprm, current->mm->start_stack,
325 executable_stack);
299 if (retval < 0) { 326 if (retval < 0) {
300 send_sig(SIGKILL, current, 0); 327 send_sig(SIGKILL, current, 0);
301 goto error_kill; 328 goto error_kill;
@@ -303,7 +330,8 @@ static int load_elf_fdpic_binary(struct linux_binprm *bprm, struct pt_regs *regs
303#endif 330#endif
304 331
305 /* load the executable and interpreter into memory */ 332 /* load the executable and interpreter into memory */
306 retval = elf_fdpic_map_file(&exec_params, bprm->file, current->mm, "executable"); 333 retval = elf_fdpic_map_file(&exec_params, bprm->file, current->mm,
334 "executable");
307 if (retval < 0) 335 if (retval < 0)
308 goto error_kill; 336 goto error_kill;
309 337
@@ -324,7 +352,8 @@ static int load_elf_fdpic_binary(struct linux_binprm *bprm, struct pt_regs *regs
324 if (!current->mm->start_brk) 352 if (!current->mm->start_brk)
325 current->mm->start_brk = current->mm->end_data; 353 current->mm->start_brk = current->mm->end_data;
326 354
327 current->mm->brk = current->mm->start_brk = PAGE_ALIGN(current->mm->start_brk); 355 current->mm->brk = current->mm->start_brk =
356 PAGE_ALIGN(current->mm->start_brk);
328 357
329#else 358#else
330 /* create a stack and brk area big enough for everyone 359 /* create a stack and brk area big enough for everyone
@@ -336,47 +365,45 @@ static int load_elf_fdpic_binary(struct linux_binprm *bprm, struct pt_regs *regs
336 stack_size = PAGE_SIZE * 2; 365 stack_size = PAGE_SIZE * 2;
337 366
338 down_write(&current->mm->mmap_sem); 367 down_write(&current->mm->mmap_sem);
339 current->mm->start_brk = do_mmap(NULL, 368 current->mm->start_brk = do_mmap(NULL, 0, stack_size,
340 0,
341 stack_size,
342 PROT_READ | PROT_WRITE | PROT_EXEC, 369 PROT_READ | PROT_WRITE | PROT_EXEC,
343 MAP_PRIVATE | MAP_ANON | MAP_GROWSDOWN, 370 MAP_PRIVATE | MAP_ANON | MAP_GROWSDOWN,
344 0); 371 0);
345 372
346 if (IS_ERR((void *) current->mm->start_brk)) { 373 if (IS_ERR_VALUE(current->mm->start_brk)) {
347 up_write(&current->mm->mmap_sem); 374 up_write(&current->mm->mmap_sem);
348 retval = current->mm->start_brk; 375 retval = current->mm->start_brk;
349 current->mm->start_brk = 0; 376 current->mm->start_brk = 0;
350 goto error_kill; 377 goto error_kill;
351 } 378 }
352 379
353 if (do_mremap(current->mm->start_brk, 380 /* expand the stack mapping to use up the entire allocation granule */
354 stack_size, 381 fullsize = ksize((char *) current->mm->start_brk);
355 ksize((char *) current->mm->start_brk), 382 if (!IS_ERR_VALUE(do_mremap(current->mm->start_brk, stack_size,
356 0, 0 383 fullsize, 0, 0)))
357 ) == current->mm->start_brk 384 stack_size = fullsize;
358 )
359 stack_size = ksize((char *) current->mm->start_brk);
360 up_write(&current->mm->mmap_sem); 385 up_write(&current->mm->mmap_sem);
361 386
362 current->mm->brk = current->mm->start_brk; 387 current->mm->brk = current->mm->start_brk;
363 current->mm->context.end_brk = current->mm->start_brk; 388 current->mm->context.end_brk = current->mm->start_brk;
364 current->mm->context.end_brk += (stack_size > PAGE_SIZE) ? (stack_size - PAGE_SIZE) : 0; 389 current->mm->context.end_brk +=
390 (stack_size > PAGE_SIZE) ? (stack_size - PAGE_SIZE) : 0;
365 current->mm->start_stack = current->mm->start_brk + stack_size; 391 current->mm->start_stack = current->mm->start_brk + stack_size;
366#endif 392#endif
367 393
368 compute_creds(bprm); 394 compute_creds(bprm);
369 current->flags &= ~PF_FORKNOEXEC; 395 current->flags &= ~PF_FORKNOEXEC;
370 if (create_elf_fdpic_tables(bprm, current->mm, &exec_params, &interp_params) < 0) 396 if (create_elf_fdpic_tables(bprm, current->mm,
397 &exec_params, &interp_params) < 0)
371 goto error_kill; 398 goto error_kill;
372 399
373 kdebug("- start_code %lx", (long) current->mm->start_code); 400 kdebug("- start_code %lx", current->mm->start_code);
374 kdebug("- end_code %lx", (long) current->mm->end_code); 401 kdebug("- end_code %lx", current->mm->end_code);
375 kdebug("- start_data %lx", (long) current->mm->start_data); 402 kdebug("- start_data %lx", current->mm->start_data);
376 kdebug("- end_data %lx", (long) current->mm->end_data); 403 kdebug("- end_data %lx", current->mm->end_data);
377 kdebug("- start_brk %lx", (long) current->mm->start_brk); 404 kdebug("- start_brk %lx", current->mm->start_brk);
378 kdebug("- brk %lx", (long) current->mm->brk); 405 kdebug("- brk %lx", current->mm->brk);
379 kdebug("- start_stack %lx", (long) current->mm->start_stack); 406 kdebug("- start_stack %lx", current->mm->start_stack);
380 407
381#ifdef ELF_FDPIC_PLAT_INIT 408#ifdef ELF_FDPIC_PLAT_INIT
382 /* 409 /*
@@ -385,21 +412,18 @@ static int load_elf_fdpic_binary(struct linux_binprm *bprm, struct pt_regs *regs
385 * example. This macro performs whatever initialization to 412 * example. This macro performs whatever initialization to
386 * the regs structure is required. 413 * the regs structure is required.
387 */ 414 */
388 ELF_FDPIC_PLAT_INIT(regs, 415 dynaddr = interp_params.dynamic_addr ?: exec_params.dynamic_addr;
389 exec_params.map_addr, 416 ELF_FDPIC_PLAT_INIT(regs, exec_params.map_addr, interp_params.map_addr,
390 interp_params.map_addr, 417 dynaddr);
391 interp_params.dynamic_addr ?: exec_params.dynamic_addr
392 );
393#endif 418#endif
394 419
395 /* everything is now ready... get the userspace context ready to roll */ 420 /* everything is now ready... get the userspace context ready to roll */
396 start_thread(regs, 421 entryaddr = interp_params.entry_addr ?: exec_params.entry_addr;
397 interp_params.entry_addr ?: exec_params.entry_addr, 422 start_thread(regs, entryaddr, current->mm->start_stack);
398 current->mm->start_stack);
399 423
400 if (unlikely(current->ptrace & PT_PTRACED)) { 424 if (unlikely(current->ptrace & PT_PTRACED)) {
401 if (current->ptrace & PT_TRACE_EXEC) 425 if (current->ptrace & PT_TRACE_EXEC)
402 ptrace_notify ((PTRACE_EVENT_EXEC << 8) | SIGTRAP); 426 ptrace_notify((PTRACE_EVENT_EXEC << 8) | SIGTRAP);
403 else 427 else
404 send_sig(SIGTRAP, current, 0); 428 send_sig(SIGTRAP, current, 0);
405 } 429 }
@@ -419,11 +443,11 @@ error:
419 return retval; 443 return retval;
420 444
421 /* unrecoverable error - kill the process */ 445 /* unrecoverable error - kill the process */
422 error_kill: 446error_kill:
423 send_sig(SIGSEGV, current, 0); 447 send_sig(SIGSEGV, current, 0);
424 goto error; 448 goto error;
425 449
426} /* end load_elf_fdpic_binary() */ 450}
427 451
428/*****************************************************************************/ 452/*****************************************************************************/
429/* 453/*
@@ -459,6 +483,7 @@ static int create_elf_fdpic_tables(struct linux_binprm *bprm,
459 */ 483 */
460 hwcap = ELF_HWCAP; 484 hwcap = ELF_HWCAP;
461 k_platform = ELF_PLATFORM; 485 k_platform = ELF_PLATFORM;
486 u_platform = NULL;
462 487
463 if (k_platform) { 488 if (k_platform) {
464 platform_len = strlen(k_platform) + 1; 489 platform_len = strlen(k_platform) + 1;
@@ -470,11 +495,11 @@ static int create_elf_fdpic_tables(struct linux_binprm *bprm,
470 495
471#if defined(__i386__) && defined(CONFIG_SMP) 496#if defined(__i386__) && defined(CONFIG_SMP)
472 /* in some cases (e.g. Hyper-Threading), we want to avoid L1 evictions 497 /* in some cases (e.g. Hyper-Threading), we want to avoid L1 evictions
473 * by the processes running on the same package. One thing we can do 498 * by the processes running on the same package. One thing we can do is
474 * is to shuffle the initial stack for them. 499 * to shuffle the initial stack for them.
475 * 500 *
476 * the conditionals here are unneeded, but kept in to make the 501 * the conditionals here are unneeded, but kept in to make the code
477 * code behaviour the same as pre change unless we have hyperthreaded 502 * behaviour the same as pre change unless we have hyperthreaded
478 * processors. This keeps Mr Marcelo Person happier but should be 503 * processors. This keeps Mr Marcelo Person happier but should be
479 * removed for 2.5 504 * removed for 2.5
480 */ 505 */
@@ -497,11 +522,13 @@ static int create_elf_fdpic_tables(struct linux_binprm *bprm,
497 522
498 if (interp_params->loadmap) { 523 if (interp_params->loadmap) {
499 len = sizeof(struct elf32_fdpic_loadmap); 524 len = sizeof(struct elf32_fdpic_loadmap);
500 len += sizeof(struct elf32_fdpic_loadseg) * interp_params->loadmap->nsegs; 525 len += sizeof(struct elf32_fdpic_loadseg) *
526 interp_params->loadmap->nsegs;
501 sp = (sp - len) & ~7UL; 527 sp = (sp - len) & ~7UL;
502 interp_params->map_addr = sp; 528 interp_params->map_addr = sp;
503 529
504 if (copy_to_user((void __user *) sp, interp_params->loadmap, len) != 0) 530 if (copy_to_user((void __user *) sp, interp_params->loadmap,
531 len) != 0)
505 return -EFAULT; 532 return -EFAULT;
506 533
507 current->mm->context.interp_fdpic_loadmap = (unsigned long) sp; 534 current->mm->context.interp_fdpic_loadmap = (unsigned long) sp;
@@ -525,34 +552,37 @@ static int create_elf_fdpic_tables(struct linux_binprm *bprm,
525 sp -= sp & 15UL; 552 sp -= sp & 15UL;
526 553
527 /* put the ELF interpreter info on the stack */ 554 /* put the ELF interpreter info on the stack */
528#define NEW_AUX_ENT(nr, id, val) \ 555#define NEW_AUX_ENT(nr, id, val) \
529 do { \ 556 do { \
530 struct { unsigned long _id, _val; } __user *ent = (void __user *) csp; \ 557 struct { unsigned long _id, _val; } __user *ent; \
531 __put_user((id), &ent[nr]._id); \ 558 \
532 __put_user((val), &ent[nr]._val); \ 559 ent = (void __user *) csp; \
560 __put_user((id), &ent[nr]._id); \
561 __put_user((val), &ent[nr]._val); \
533 } while (0) 562 } while (0)
534 563
535 csp -= 2 * sizeof(unsigned long); 564 csp -= 2 * sizeof(unsigned long);
536 NEW_AUX_ENT(0, AT_NULL, 0); 565 NEW_AUX_ENT(0, AT_NULL, 0);
537 if (k_platform) { 566 if (k_platform) {
538 csp -= 2 * sizeof(unsigned long); 567 csp -= 2 * sizeof(unsigned long);
539 NEW_AUX_ENT(0, AT_PLATFORM, (elf_addr_t)(unsigned long) u_platform); 568 NEW_AUX_ENT(0, AT_PLATFORM,
569 (elf_addr_t) (unsigned long) u_platform);
540 } 570 }
541 571
542 csp -= DLINFO_ITEMS * 2 * sizeof(unsigned long); 572 csp -= DLINFO_ITEMS * 2 * sizeof(unsigned long);
543 NEW_AUX_ENT( 0, AT_HWCAP, hwcap); 573 NEW_AUX_ENT( 0, AT_HWCAP, hwcap);
544 NEW_AUX_ENT( 1, AT_PAGESZ, PAGE_SIZE); 574 NEW_AUX_ENT( 1, AT_PAGESZ, PAGE_SIZE);
545 NEW_AUX_ENT( 2, AT_CLKTCK, CLOCKS_PER_SEC); 575 NEW_AUX_ENT( 2, AT_CLKTCK, CLOCKS_PER_SEC);
546 NEW_AUX_ENT( 3, AT_PHDR, exec_params->ph_addr); 576 NEW_AUX_ENT( 3, AT_PHDR, exec_params->ph_addr);
547 NEW_AUX_ENT( 4, AT_PHENT, sizeof(struct elf_phdr)); 577 NEW_AUX_ENT( 4, AT_PHENT, sizeof(struct elf_phdr));
548 NEW_AUX_ENT( 5, AT_PHNUM, exec_params->hdr.e_phnum); 578 NEW_AUX_ENT( 5, AT_PHNUM, exec_params->hdr.e_phnum);
549 NEW_AUX_ENT( 6, AT_BASE, interp_params->elfhdr_addr); 579 NEW_AUX_ENT( 6, AT_BASE, interp_params->elfhdr_addr);
550 NEW_AUX_ENT( 7, AT_FLAGS, 0); 580 NEW_AUX_ENT( 7, AT_FLAGS, 0);
551 NEW_AUX_ENT( 8, AT_ENTRY, exec_params->entry_addr); 581 NEW_AUX_ENT( 8, AT_ENTRY, exec_params->entry_addr);
552 NEW_AUX_ENT( 9, AT_UID, (elf_addr_t) current->uid); 582 NEW_AUX_ENT( 9, AT_UID, (elf_addr_t) current->uid);
553 NEW_AUX_ENT(10, AT_EUID, (elf_addr_t) current->euid); 583 NEW_AUX_ENT(10, AT_EUID, (elf_addr_t) current->euid);
554 NEW_AUX_ENT(11, AT_GID, (elf_addr_t) current->gid); 584 NEW_AUX_ENT(11, AT_GID, (elf_addr_t) current->gid);
555 NEW_AUX_ENT(12, AT_EGID, (elf_addr_t) current->egid); 585 NEW_AUX_ENT(12, AT_EGID, (elf_addr_t) current->egid);
556 586
557#ifdef ARCH_DLINFO 587#ifdef ARCH_DLINFO
558 /* ARCH_DLINFO must come last so platform specific code can enforce 588 /* ARCH_DLINFO must come last so platform specific code can enforce
@@ -578,7 +608,8 @@ static int create_elf_fdpic_tables(struct linux_binprm *bprm,
578#ifdef CONFIG_MMU 608#ifdef CONFIG_MMU
579 current->mm->arg_start = bprm->p; 609 current->mm->arg_start = bprm->p;
580#else 610#else
581 current->mm->arg_start = current->mm->start_stack - (MAX_ARG_PAGES * PAGE_SIZE - bprm->p); 611 current->mm->arg_start = current->mm->start_stack -
612 (MAX_ARG_PAGES * PAGE_SIZE - bprm->p);
582#endif 613#endif
583 614
584 p = (char __user *) current->mm->arg_start; 615 p = (char __user *) current->mm->arg_start;
@@ -606,7 +637,7 @@ static int create_elf_fdpic_tables(struct linux_binprm *bprm,
606 637
607 mm->start_stack = (unsigned long) sp; 638 mm->start_stack = (unsigned long) sp;
608 return 0; 639 return 0;
609} /* end create_elf_fdpic_tables() */ 640}
610 641
611/*****************************************************************************/ 642/*****************************************************************************/
612/* 643/*
@@ -614,7 +645,8 @@ static int create_elf_fdpic_tables(struct linux_binprm *bprm,
614 * the stack 645 * the stack
615 */ 646 */
616#ifndef CONFIG_MMU 647#ifndef CONFIG_MMU
617static int elf_fdpic_transfer_args_to_stack(struct linux_binprm *bprm, unsigned long *_sp) 648static int elf_fdpic_transfer_args_to_stack(struct linux_binprm *bprm,
649 unsigned long *_sp)
618{ 650{
619 unsigned long index, stop, sp; 651 unsigned long index, stop, sp;
620 char *src; 652 char *src;
@@ -635,9 +667,9 @@ static int elf_fdpic_transfer_args_to_stack(struct linux_binprm *bprm, unsigned
635 667
636 *_sp = (*_sp - (MAX_ARG_PAGES * PAGE_SIZE - bprm->p)) & ~15; 668 *_sp = (*_sp - (MAX_ARG_PAGES * PAGE_SIZE - bprm->p)) & ~15;
637 669
638 out: 670out:
639 return ret; 671 return ret;
640} /* end elf_fdpic_transfer_args_to_stack() */ 672}
641#endif 673#endif
642 674
643/*****************************************************************************/ 675/*****************************************************************************/
@@ -712,17 +744,18 @@ static int elf_fdpic_map_file(struct elf_fdpic_params *params,
712 seg = loadmap->segs; 744 seg = loadmap->segs;
713 for (loop = loadmap->nsegs; loop > 0; loop--, seg++) { 745 for (loop = loadmap->nsegs; loop > 0; loop--, seg++) {
714 if (params->hdr.e_entry >= seg->p_vaddr && 746 if (params->hdr.e_entry >= seg->p_vaddr &&
715 params->hdr.e_entry < seg->p_vaddr + seg->p_memsz 747 params->hdr.e_entry < seg->p_vaddr + seg->p_memsz) {
716 ) {
717 params->entry_addr = 748 params->entry_addr =
718 (params->hdr.e_entry - seg->p_vaddr) + seg->addr; 749 (params->hdr.e_entry - seg->p_vaddr) +
750 seg->addr;
719 break; 751 break;
720 } 752 }
721 } 753 }
722 } 754 }
723 755
724 /* determine where the program header table has wound up if mapped */ 756 /* determine where the program header table has wound up if mapped */
725 stop = params->hdr.e_phoff + params->hdr.e_phnum * sizeof (struct elf_phdr); 757 stop = params->hdr.e_phoff;
758 stop += params->hdr.e_phnum * sizeof (struct elf_phdr);
726 phdr = params->phdrs; 759 phdr = params->phdrs;
727 760
728 for (loop = 0; loop < params->hdr.e_phnum; loop++, phdr++) { 761 for (loop = 0; loop < params->hdr.e_phnum; loop++, phdr++) {
@@ -736,9 +769,11 @@ static int elf_fdpic_map_file(struct elf_fdpic_params *params,
736 seg = loadmap->segs; 769 seg = loadmap->segs;
737 for (loop = loadmap->nsegs; loop > 0; loop--, seg++) { 770 for (loop = loadmap->nsegs; loop > 0; loop--, seg++) {
738 if (phdr->p_vaddr >= seg->p_vaddr && 771 if (phdr->p_vaddr >= seg->p_vaddr &&
739 phdr->p_vaddr + phdr->p_filesz <= seg->p_vaddr + seg->p_memsz 772 phdr->p_vaddr + phdr->p_filesz <=
740 ) { 773 seg->p_vaddr + seg->p_memsz) {
741 params->ph_addr = (phdr->p_vaddr - seg->p_vaddr) + seg->addr + 774 params->ph_addr =
775 (phdr->p_vaddr - seg->p_vaddr) +
776 seg->addr +
742 params->hdr.e_phoff - phdr->p_offset; 777 params->hdr.e_phoff - phdr->p_offset;
743 break; 778 break;
744 } 779 }
@@ -755,18 +790,22 @@ static int elf_fdpic_map_file(struct elf_fdpic_params *params,
755 seg = loadmap->segs; 790 seg = loadmap->segs;
756 for (loop = loadmap->nsegs; loop > 0; loop--, seg++) { 791 for (loop = loadmap->nsegs; loop > 0; loop--, seg++) {
757 if (phdr->p_vaddr >= seg->p_vaddr && 792 if (phdr->p_vaddr >= seg->p_vaddr &&
758 phdr->p_vaddr + phdr->p_memsz <= seg->p_vaddr + seg->p_memsz 793 phdr->p_vaddr + phdr->p_memsz <=
759 ) { 794 seg->p_vaddr + seg->p_memsz) {
760 params->dynamic_addr = (phdr->p_vaddr - seg->p_vaddr) + seg->addr; 795 params->dynamic_addr =
761 796 (phdr->p_vaddr - seg->p_vaddr) +
762 /* check the dynamic section contains at least one item, and that 797 seg->addr;
763 * the last item is a NULL entry */ 798
799 /* check the dynamic section contains at least
800 * one item, and that the last item is a NULL
801 * entry */
764 if (phdr->p_memsz == 0 || 802 if (phdr->p_memsz == 0 ||
765 phdr->p_memsz % sizeof(Elf32_Dyn) != 0) 803 phdr->p_memsz % sizeof(Elf32_Dyn) != 0)
766 goto dynamic_error; 804 goto dynamic_error;
767 805
768 tmp = phdr->p_memsz / sizeof(Elf32_Dyn); 806 tmp = phdr->p_memsz / sizeof(Elf32_Dyn);
769 if (((Elf32_Dyn *) params->dynamic_addr)[tmp - 1].d_tag != 0) 807 if (((Elf32_Dyn *)
808 params->dynamic_addr)[tmp - 1].d_tag != 0)
770 goto dynamic_error; 809 goto dynamic_error;
771 break; 810 break;
772 } 811 }
@@ -775,8 +814,8 @@ static int elf_fdpic_map_file(struct elf_fdpic_params *params,
775 } 814 }
776 815
777 /* now elide adjacent segments in the load map on MMU linux 816 /* now elide adjacent segments in the load map on MMU linux
778 * - on uClinux the holes between may actually be filled with system stuff or stuff from 817 * - on uClinux the holes between may actually be filled with system
779 * other processes 818 * stuff or stuff from other processes
780 */ 819 */
781#ifdef CONFIG_MMU 820#ifdef CONFIG_MMU
782 nloads = loadmap->nsegs; 821 nloads = loadmap->nsegs;
@@ -787,7 +826,9 @@ static int elf_fdpic_map_file(struct elf_fdpic_params *params,
787 if (seg->p_vaddr - mseg->p_vaddr == seg->addr - mseg->addr) { 826 if (seg->p_vaddr - mseg->p_vaddr == seg->addr - mseg->addr) {
788 load_addr = PAGE_ALIGN(mseg->addr + mseg->p_memsz); 827 load_addr = PAGE_ALIGN(mseg->addr + mseg->p_memsz);
789 if (load_addr == (seg->addr & PAGE_MASK)) { 828 if (load_addr == (seg->addr & PAGE_MASK)) {
790 mseg->p_memsz += load_addr - (mseg->addr + mseg->p_memsz); 829 mseg->p_memsz +=
830 load_addr -
831 (mseg->addr + mseg->p_memsz);
791 mseg->p_memsz += seg->addr & ~PAGE_MASK; 832 mseg->p_memsz += seg->addr & ~PAGE_MASK;
792 mseg->p_memsz += seg->p_memsz; 833 mseg->p_memsz += seg->p_memsz;
793 loadmap->nsegs--; 834 loadmap->nsegs--;
@@ -815,20 +856,21 @@ static int elf_fdpic_map_file(struct elf_fdpic_params *params,
815 856
816 return 0; 857 return 0;
817 858
818 dynamic_error: 859dynamic_error:
819 printk("ELF FDPIC %s with invalid DYNAMIC section (inode=%lu)\n", 860 printk("ELF FDPIC %s with invalid DYNAMIC section (inode=%lu)\n",
820 what, file->f_dentry->d_inode->i_ino); 861 what, file->f_dentry->d_inode->i_ino);
821 return -ELIBBAD; 862 return -ELIBBAD;
822} /* end elf_fdpic_map_file() */ 863}
823 864
824/*****************************************************************************/ 865/*****************************************************************************/
825/* 866/*
826 * map a file with constant displacement under uClinux 867 * map a file with constant displacement under uClinux
827 */ 868 */
828#ifndef CONFIG_MMU 869#ifndef CONFIG_MMU
829static int elf_fdpic_map_file_constdisp_on_uclinux(struct elf_fdpic_params *params, 870static int elf_fdpic_map_file_constdisp_on_uclinux(
830 struct file *file, 871 struct elf_fdpic_params *params,
831 struct mm_struct *mm) 872 struct file *file,
873 struct mm_struct *mm)
832{ 874{
833 struct elf32_fdpic_loadseg *seg; 875 struct elf32_fdpic_loadseg *seg;
834 struct elf32_phdr *phdr; 876 struct elf32_phdr *phdr;
@@ -839,7 +881,8 @@ static int elf_fdpic_map_file_constdisp_on_uclinux(struct elf_fdpic_params *para
839 load_addr = params->load_addr; 881 load_addr = params->load_addr;
840 seg = params->loadmap->segs; 882 seg = params->loadmap->segs;
841 883
842 /* determine the bounds of the contiguous overall allocation we must make */ 884 /* determine the bounds of the contiguous overall allocation we must
885 * make */
843 phdr = params->phdrs; 886 phdr = params->phdrs;
844 for (loop = 0; loop < params->hdr.e_phnum; loop++, phdr++) { 887 for (loop = 0; loop < params->hdr.e_phnum; loop++, phdr++) {
845 if (params->phdrs[loop].p_type != PT_LOAD) 888 if (params->phdrs[loop].p_type != PT_LOAD)
@@ -860,7 +903,7 @@ static int elf_fdpic_map_file_constdisp_on_uclinux(struct elf_fdpic_params *para
860 maddr = do_mmap(NULL, load_addr, top - base, 903 maddr = do_mmap(NULL, load_addr, top - base,
861 PROT_READ | PROT_WRITE | PROT_EXEC, mflags, 0); 904 PROT_READ | PROT_WRITE | PROT_EXEC, mflags, 0);
862 up_write(&mm->mmap_sem); 905 up_write(&mm->mmap_sem);
863 if (IS_ERR((void *) maddr)) 906 if (IS_ERR_VALUE(maddr))
864 return (int) maddr; 907 return (int) maddr;
865 908
866 if (load_addr != 0) 909 if (load_addr != 0)
@@ -878,7 +921,8 @@ static int elf_fdpic_map_file_constdisp_on_uclinux(struct elf_fdpic_params *para
878 seg->p_vaddr = phdr->p_vaddr; 921 seg->p_vaddr = phdr->p_vaddr;
879 seg->p_memsz = phdr->p_memsz; 922 seg->p_memsz = phdr->p_memsz;
880 923
881 ret = file->f_op->read(file, (void *) seg->addr, phdr->p_filesz, &fpos); 924 ret = file->f_op->read(file, (void *) seg->addr,
925 phdr->p_filesz, &fpos);
882 if (ret < 0) 926 if (ret < 0)
883 return ret; 927 return ret;
884 928
@@ -895,8 +939,7 @@ static int elf_fdpic_map_file_constdisp_on_uclinux(struct elf_fdpic_params *para
895 if (phdr->p_flags & PF_X) { 939 if (phdr->p_flags & PF_X) {
896 mm->start_code = seg->addr; 940 mm->start_code = seg->addr;
897 mm->end_code = seg->addr + phdr->p_memsz; 941 mm->end_code = seg->addr + phdr->p_memsz;
898 } 942 } else if (!mm->start_data) {
899 else if (!mm->start_data) {
900 mm->start_data = seg->addr; 943 mm->start_data = seg->addr;
901#ifndef CONFIG_MMU 944#ifndef CONFIG_MMU
902 mm->end_data = seg->addr + phdr->p_memsz; 945 mm->end_data = seg->addr + phdr->p_memsz;
@@ -913,7 +956,7 @@ static int elf_fdpic_map_file_constdisp_on_uclinux(struct elf_fdpic_params *para
913 } 956 }
914 957
915 return 0; 958 return 0;
916} /* end elf_fdpic_map_file_constdisp_on_uclinux() */ 959}
917#endif 960#endif
918 961
919/*****************************************************************************/ 962/*****************************************************************************/
@@ -974,14 +1017,14 @@ static int elf_fdpic_map_file_by_direct_mmap(struct elf_fdpic_params *params,
974 1017
975 case ELF_FDPIC_FLAG_CONSTDISP: 1018 case ELF_FDPIC_FLAG_CONSTDISP:
976 /* constant displacement 1019 /* constant displacement
977 * - can be mapped anywhere, but must be mapped as a unit 1020 * - can be mapped anywhere, but must be mapped as a
1021 * unit
978 */ 1022 */
979 if (!dvset) { 1023 if (!dvset) {
980 maddr = load_addr; 1024 maddr = load_addr;
981 delta_vaddr = phdr->p_vaddr; 1025 delta_vaddr = phdr->p_vaddr;
982 dvset = 1; 1026 dvset = 1;
983 } 1027 } else {
984 else {
985 maddr = load_addr + phdr->p_vaddr - delta_vaddr; 1028 maddr = load_addr + phdr->p_vaddr - delta_vaddr;
986 flags |= MAP_FIXED; 1029 flags |= MAP_FIXED;
987 } 1030 }
@@ -1005,13 +1048,14 @@ static int elf_fdpic_map_file_by_direct_mmap(struct elf_fdpic_params *params,
1005 up_write(&mm->mmap_sem); 1048 up_write(&mm->mmap_sem);
1006 1049
1007 kdebug("mmap[%d] <file> sz=%lx pr=%x fl=%x of=%lx --> %08lx", 1050 kdebug("mmap[%d] <file> sz=%lx pr=%x fl=%x of=%lx --> %08lx",
1008 loop, phdr->p_memsz + disp, prot, flags, phdr->p_offset - disp, 1051 loop, phdr->p_memsz + disp, prot, flags,
1009 maddr); 1052 phdr->p_offset - disp, maddr);
1010 1053
1011 if (IS_ERR((void *) maddr)) 1054 if (IS_ERR_VALUE(maddr))
1012 return (int) maddr; 1055 return (int) maddr;
1013 1056
1014 if ((params->flags & ELF_FDPIC_FLAG_ARRANGEMENT) == ELF_FDPIC_FLAG_CONTIGUOUS) 1057 if ((params->flags & ELF_FDPIC_FLAG_ARRANGEMENT) ==
1058 ELF_FDPIC_FLAG_CONTIGUOUS)
1015 load_addr += PAGE_ALIGN(phdr->p_memsz + disp); 1059 load_addr += PAGE_ALIGN(phdr->p_memsz + disp);
1016 1060
1017 seg->addr = maddr + disp; 1061 seg->addr = maddr + disp;
@@ -1022,7 +1066,8 @@ static int elf_fdpic_map_file_by_direct_mmap(struct elf_fdpic_params *params,
1022 if (phdr->p_offset == 0) 1066 if (phdr->p_offset == 0)
1023 params->elfhdr_addr = seg->addr; 1067 params->elfhdr_addr = seg->addr;
1024 1068
1025 /* clear the bit between beginning of mapping and beginning of PT_LOAD */ 1069 /* clear the bit between beginning of mapping and beginning of
1070 * PT_LOAD */
1026 if (prot & PROT_WRITE && disp > 0) { 1071 if (prot & PROT_WRITE && disp > 0) {
1027 kdebug("clear[%d] ad=%lx sz=%lx", loop, maddr, disp); 1072 kdebug("clear[%d] ad=%lx sz=%lx", loop, maddr, disp);
1028 clear_user((void __user *) maddr, disp); 1073 clear_user((void __user *) maddr, disp);
@@ -1038,19 +1083,20 @@ static int elf_fdpic_map_file_by_direct_mmap(struct elf_fdpic_params *params,
1038 excess1 = PAGE_SIZE - ((maddr + phdr->p_filesz) & ~PAGE_MASK); 1083 excess1 = PAGE_SIZE - ((maddr + phdr->p_filesz) & ~PAGE_MASK);
1039 1084
1040#ifdef CONFIG_MMU 1085#ifdef CONFIG_MMU
1041
1042 if (excess > excess1) { 1086 if (excess > excess1) {
1043 unsigned long xaddr = maddr + phdr->p_filesz + excess1; 1087 unsigned long xaddr = maddr + phdr->p_filesz + excess1;
1044 unsigned long xmaddr; 1088 unsigned long xmaddr;
1045 1089
1046 flags |= MAP_FIXED | MAP_ANONYMOUS; 1090 flags |= MAP_FIXED | MAP_ANONYMOUS;
1047 down_write(&mm->mmap_sem); 1091 down_write(&mm->mmap_sem);
1048 xmaddr = do_mmap(NULL, xaddr, excess - excess1, prot, flags, 0); 1092 xmaddr = do_mmap(NULL, xaddr, excess - excess1,
1093 prot, flags, 0);
1049 up_write(&mm->mmap_sem); 1094 up_write(&mm->mmap_sem);
1050 1095
1051 kdebug("mmap[%d] <anon>" 1096 kdebug("mmap[%d] <anon>"
1052 " ad=%lx sz=%lx pr=%x fl=%x of=0 --> %08lx", 1097 " ad=%lx sz=%lx pr=%x fl=%x of=0 --> %08lx",
1053 loop, xaddr, excess - excess1, prot, flags, xmaddr); 1098 loop, xaddr, excess - excess1, prot, flags,
1099 xmaddr);
1054 1100
1055 if (xmaddr != xaddr) 1101 if (xmaddr != xaddr)
1056 return -ENOMEM; 1102 return -ENOMEM;
@@ -1059,7 +1105,8 @@ static int elf_fdpic_map_file_by_direct_mmap(struct elf_fdpic_params *params,
1059 if (prot & PROT_WRITE && excess1 > 0) { 1105 if (prot & PROT_WRITE && excess1 > 0) {
1060 kdebug("clear[%d] ad=%lx sz=%lx", 1106 kdebug("clear[%d] ad=%lx sz=%lx",
1061 loop, maddr + phdr->p_filesz, excess1); 1107 loop, maddr + phdr->p_filesz, excess1);
1062 clear_user((void __user *) maddr + phdr->p_filesz, excess1); 1108 clear_user((void __user *) maddr + phdr->p_filesz,
1109 excess1);
1063 } 1110 }
1064 1111
1065#else 1112#else
@@ -1074,8 +1121,7 @@ static int elf_fdpic_map_file_by_direct_mmap(struct elf_fdpic_params *params,
1074 if (phdr->p_flags & PF_X) { 1121 if (phdr->p_flags & PF_X) {
1075 mm->start_code = maddr; 1122 mm->start_code = maddr;
1076 mm->end_code = maddr + phdr->p_memsz; 1123 mm->end_code = maddr + phdr->p_memsz;
1077 } 1124 } else if (!mm->start_data) {
1078 else if (!mm->start_data) {
1079 mm->start_data = maddr; 1125 mm->start_data = maddr;
1080 mm->end_data = maddr + phdr->p_memsz; 1126 mm->end_data = maddr + phdr->p_memsz;
1081 } 1127 }
@@ -1085,4 +1131,662 @@ static int elf_fdpic_map_file_by_direct_mmap(struct elf_fdpic_params *params,
1085 } 1131 }
1086 1132
1087 return 0; 1133 return 0;
1088} /* end elf_fdpic_map_file_by_direct_mmap() */ 1134}
1135
1136/*****************************************************************************/
1137/*
1138 * ELF-FDPIC core dumper
1139 *
1140 * Modelled on fs/exec.c:aout_core_dump()
1141 * Jeremy Fitzhardinge <jeremy@sw.oz.au>
1142 *
1143 * Modelled on fs/binfmt_elf.c core dumper
1144 */
1145#if defined(USE_ELF_CORE_DUMP) && defined(CONFIG_ELF_CORE)
1146
1147/*
1148 * These are the only things you should do on a core-file: use only these
1149 * functions to write out all the necessary info.
1150 */
1151static int dump_write(struct file *file, const void *addr, int nr)
1152{
1153 return file->f_op->write(file, addr, nr, &file->f_pos) == nr;
1154}
1155
1156static int dump_seek(struct file *file, loff_t off)
1157{
1158 if (file->f_op->llseek) {
1159 if (file->f_op->llseek(file, off, SEEK_SET) != off)
1160 return 0;
1161 } else {
1162 file->f_pos = off;
1163 }
1164 return 1;
1165}
1166
1167/*
1168 * Decide whether a segment is worth dumping; default is yes to be
1169 * sure (missing info is worse than too much; etc).
1170 * Personally I'd include everything, and use the coredump limit...
1171 *
1172 * I think we should skip something. But I am not sure how. H.J.
1173 */
1174static int maydump(struct vm_area_struct *vma)
1175{
1176 /* Do not dump I/O mapped devices or special mappings */
1177 if (vma->vm_flags & (VM_IO | VM_RESERVED)) {
1178 kdcore("%08lx: %08lx: no (IO)", vma->vm_start, vma->vm_flags);
1179 return 0;
1180 }
1181
1182 /* If we may not read the contents, don't allow us to dump
1183 * them either. "dump_write()" can't handle it anyway.
1184 */
1185 if (!(vma->vm_flags & VM_READ)) {
1186 kdcore("%08lx: %08lx: no (!read)", vma->vm_start, vma->vm_flags);
1187 return 0;
1188 }
1189
1190 /* Dump shared memory only if mapped from an anonymous file. */
1191 if (vma->vm_flags & VM_SHARED) {
1192 if (vma->vm_file->f_dentry->d_inode->i_nlink == 0) {
1193 kdcore("%08lx: %08lx: no (share)", vma->vm_start, vma->vm_flags);
1194 return 1;
1195 }
1196
1197 kdcore("%08lx: %08lx: no (share)", vma->vm_start, vma->vm_flags);
1198 return 0;
1199 }
1200
1201#ifdef CONFIG_MMU
1202 /* If it hasn't been written to, don't write it out */
1203 if (!vma->anon_vma) {
1204 kdcore("%08lx: %08lx: no (!anon)", vma->vm_start, vma->vm_flags);
1205 return 0;
1206 }
1207#endif
1208
1209 kdcore("%08lx: %08lx: yes", vma->vm_start, vma->vm_flags);
1210 return 1;
1211}
1212
1213/* An ELF note in memory */
1214struct memelfnote
1215{
1216 const char *name;
1217 int type;
1218 unsigned int datasz;
1219 void *data;
1220};
1221
1222static int notesize(struct memelfnote *en)
1223{
1224 int sz;
1225
1226 sz = sizeof(struct elf_note);
1227 sz += roundup(strlen(en->name) + 1, 4);
1228 sz += roundup(en->datasz, 4);
1229
1230 return sz;
1231}
1232
1233/* #define DEBUG */
1234
1235#define DUMP_WRITE(addr, nr) \
1236 do { if (!dump_write(file, (addr), (nr))) return 0; } while(0)
1237#define DUMP_SEEK(off) \
1238 do { if (!dump_seek(file, (off))) return 0; } while(0)
1239
1240static int writenote(struct memelfnote *men, struct file *file)
1241{
1242 struct elf_note en;
1243
1244 en.n_namesz = strlen(men->name) + 1;
1245 en.n_descsz = men->datasz;
1246 en.n_type = men->type;
1247
1248 DUMP_WRITE(&en, sizeof(en));
1249 DUMP_WRITE(men->name, en.n_namesz);
1250 /* XXX - cast from long long to long to avoid need for libgcc.a */
1251 DUMP_SEEK(roundup((unsigned long)file->f_pos, 4)); /* XXX */
1252 DUMP_WRITE(men->data, men->datasz);
1253 DUMP_SEEK(roundup((unsigned long)file->f_pos, 4)); /* XXX */
1254
1255 return 1;
1256}
1257#undef DUMP_WRITE
1258#undef DUMP_SEEK
1259
1260#define DUMP_WRITE(addr, nr) \
1261 if ((size += (nr)) > limit || !dump_write(file, (addr), (nr))) \
1262 goto end_coredump;
1263#define DUMP_SEEK(off) \
1264 if (!dump_seek(file, (off))) \
1265 goto end_coredump;
1266
1267static inline void fill_elf_fdpic_header(struct elfhdr *elf, int segs)
1268{
1269 memcpy(elf->e_ident, ELFMAG, SELFMAG);
1270 elf->e_ident[EI_CLASS] = ELF_CLASS;
1271 elf->e_ident[EI_DATA] = ELF_DATA;
1272 elf->e_ident[EI_VERSION] = EV_CURRENT;
1273 elf->e_ident[EI_OSABI] = ELF_OSABI;
1274 memset(elf->e_ident+EI_PAD, 0, EI_NIDENT-EI_PAD);
1275
1276 elf->e_type = ET_CORE;
1277 elf->e_machine = ELF_ARCH;
1278 elf->e_version = EV_CURRENT;
1279 elf->e_entry = 0;
1280 elf->e_phoff = sizeof(struct elfhdr);
1281 elf->e_shoff = 0;
1282 elf->e_flags = ELF_FDPIC_CORE_EFLAGS;
1283 elf->e_ehsize = sizeof(struct elfhdr);
1284 elf->e_phentsize = sizeof(struct elf_phdr);
1285 elf->e_phnum = segs;
1286 elf->e_shentsize = 0;
1287 elf->e_shnum = 0;
1288 elf->e_shstrndx = 0;
1289 return;
1290}
1291
1292static inline void fill_elf_note_phdr(struct elf_phdr *phdr, int sz, loff_t offset)
1293{
1294 phdr->p_type = PT_NOTE;
1295 phdr->p_offset = offset;
1296 phdr->p_vaddr = 0;
1297 phdr->p_paddr = 0;
1298 phdr->p_filesz = sz;
1299 phdr->p_memsz = 0;
1300 phdr->p_flags = 0;
1301 phdr->p_align = 0;
1302 return;
1303}
1304
1305static inline void fill_note(struct memelfnote *note, const char *name, int type,
1306 unsigned int sz, void *data)
1307{
1308 note->name = name;
1309 note->type = type;
1310 note->datasz = sz;
1311 note->data = data;
1312 return;
1313}
1314
1315/*
1316 * fill up all the fields in prstatus from the given task struct, except
1317 * registers which need to be filled up seperately.
1318 */
1319static void fill_prstatus(struct elf_prstatus *prstatus,
1320 struct task_struct *p, long signr)
1321{
1322 prstatus->pr_info.si_signo = prstatus->pr_cursig = signr;
1323 prstatus->pr_sigpend = p->pending.signal.sig[0];
1324 prstatus->pr_sighold = p->blocked.sig[0];
1325 prstatus->pr_pid = p->pid;
1326 prstatus->pr_ppid = p->parent->pid;
1327 prstatus->pr_pgrp = process_group(p);
1328 prstatus->pr_sid = p->signal->session;
1329 if (thread_group_leader(p)) {
1330 /*
1331 * This is the record for the group leader. Add in the
1332 * cumulative times of previous dead threads. This total
1333 * won't include the time of each live thread whose state
1334 * is included in the core dump. The final total reported
1335 * to our parent process when it calls wait4 will include
1336 * those sums as well as the little bit more time it takes
1337 * this and each other thread to finish dying after the
1338 * core dump synchronization phase.
1339 */
1340 cputime_to_timeval(cputime_add(p->utime, p->signal->utime),
1341 &prstatus->pr_utime);
1342 cputime_to_timeval(cputime_add(p->stime, p->signal->stime),
1343 &prstatus->pr_stime);
1344 } else {
1345 cputime_to_timeval(p->utime, &prstatus->pr_utime);
1346 cputime_to_timeval(p->stime, &prstatus->pr_stime);
1347 }
1348 cputime_to_timeval(p->signal->cutime, &prstatus->pr_cutime);
1349 cputime_to_timeval(p->signal->cstime, &prstatus->pr_cstime);
1350
1351 prstatus->pr_exec_fdpic_loadmap = p->mm->context.exec_fdpic_loadmap;
1352 prstatus->pr_interp_fdpic_loadmap = p->mm->context.interp_fdpic_loadmap;
1353}
1354
1355static int fill_psinfo(struct elf_prpsinfo *psinfo, struct task_struct *p,
1356 struct mm_struct *mm)
1357{
1358 unsigned int i, len;
1359
1360 /* first copy the parameters from user space */
1361 memset(psinfo, 0, sizeof(struct elf_prpsinfo));
1362
1363 len = mm->arg_end - mm->arg_start;
1364 if (len >= ELF_PRARGSZ)
1365 len = ELF_PRARGSZ - 1;
1366 if (copy_from_user(&psinfo->pr_psargs,
1367 (const char __user *) mm->arg_start, len))
1368 return -EFAULT;
1369 for (i = 0; i < len; i++)
1370 if (psinfo->pr_psargs[i] == 0)
1371 psinfo->pr_psargs[i] = ' ';
1372 psinfo->pr_psargs[len] = 0;
1373
1374 psinfo->pr_pid = p->pid;
1375 psinfo->pr_ppid = p->parent->pid;
1376 psinfo->pr_pgrp = process_group(p);
1377 psinfo->pr_sid = p->signal->session;
1378
1379 i = p->state ? ffz(~p->state) + 1 : 0;
1380 psinfo->pr_state = i;
1381 psinfo->pr_sname = (i > 5) ? '.' : "RSDTZW"[i];
1382 psinfo->pr_zomb = psinfo->pr_sname == 'Z';
1383 psinfo->pr_nice = task_nice(p);
1384 psinfo->pr_flag = p->flags;
1385 SET_UID(psinfo->pr_uid, p->uid);
1386 SET_GID(psinfo->pr_gid, p->gid);
1387 strncpy(psinfo->pr_fname, p->comm, sizeof(psinfo->pr_fname));
1388
1389 return 0;
1390}
1391
1392/* Here is the structure in which status of each thread is captured. */
1393struct elf_thread_status
1394{
1395 struct list_head list;
1396 struct elf_prstatus prstatus; /* NT_PRSTATUS */
1397 elf_fpregset_t fpu; /* NT_PRFPREG */
1398 struct task_struct *thread;
1399#ifdef ELF_CORE_COPY_XFPREGS
1400 elf_fpxregset_t xfpu; /* NT_PRXFPREG */
1401#endif
1402 struct memelfnote notes[3];
1403 int num_notes;
1404};
1405
1406/*
1407 * In order to add the specific thread information for the elf file format,
1408 * we need to keep a linked list of every thread's pr_status and then create
1409 * a single section for them in the final core file.
1410 */
1411static int elf_dump_thread_status(long signr, struct elf_thread_status *t)
1412{
1413 struct task_struct *p = t->thread;
1414 int sz = 0;
1415
1416 t->num_notes = 0;
1417
1418 fill_prstatus(&t->prstatus, p, signr);
1419 elf_core_copy_task_regs(p, &t->prstatus.pr_reg);
1420
1421 fill_note(&t->notes[0], "CORE", NT_PRSTATUS, sizeof(t->prstatus),
1422 &t->prstatus);
1423 t->num_notes++;
1424 sz += notesize(&t->notes[0]);
1425
1426 t->prstatus.pr_fpvalid = elf_core_copy_task_fpregs(p, NULL, &t->fpu);
1427 if (t->prstatus.pr_fpvalid) {
1428 fill_note(&t->notes[1], "CORE", NT_PRFPREG, sizeof(t->fpu),
1429 &t->fpu);
1430 t->num_notes++;
1431 sz += notesize(&t->notes[1]);
1432 }
1433
1434#ifdef ELF_CORE_COPY_XFPREGS
1435 if (elf_core_copy_task_xfpregs(p, &t->xfpu)) {
1436 fill_note(&t->notes[2], "LINUX", NT_PRXFPREG, sizeof(t->xfpu),
1437 &t->xfpu);
1438 t->num_notes++;
1439 sz += notesize(&t->notes[2]);
1440 }
1441#endif
1442 return sz;
1443}
1444
1445/*
1446 * dump the segments for an MMU process
1447 */
1448#ifdef CONFIG_MMU
1449static int elf_fdpic_dump_segments(struct file *file, struct mm_struct *mm,
1450 size_t *size, unsigned long *limit)
1451{
1452 struct vm_area_struct *vma;
1453
1454 for (vma = current->mm->mmap; vma; vma = vma->vm_next) {
1455 unsigned long addr;
1456
1457 if (!maydump(vma))
1458 continue;
1459
1460 for (addr = vma->vm_start;
1461 addr < vma->vm_end;
1462 addr += PAGE_SIZE
1463 ) {
1464 struct vm_area_struct *vma;
1465 struct page *page;
1466
1467 if (get_user_pages(current, current->mm, addr, 1, 0, 1,
1468 &page, &vma) <= 0) {
1469 DUMP_SEEK(file->f_pos + PAGE_SIZE);
1470 }
1471 else if (page == ZERO_PAGE(addr)) {
1472 DUMP_SEEK(file->f_pos + PAGE_SIZE);
1473 page_cache_release(page);
1474 }
1475 else {
1476 void *kaddr;
1477
1478 flush_cache_page(vma, addr, page_to_pfn(page));
1479 kaddr = kmap(page);
1480 if ((*size += PAGE_SIZE) > *limit ||
1481 !dump_write(file, kaddr, PAGE_SIZE)
1482 ) {
1483 kunmap(page);
1484 page_cache_release(page);
1485 return -EIO;
1486 }
1487 kunmap(page);
1488 page_cache_release(page);
1489 }
1490 }
1491 }
1492
1493 return 0;
1494
1495end_coredump:
1496 return -EFBIG;
1497}
1498#endif
1499
1500/*
1501 * dump the segments for a NOMMU process
1502 */
1503#ifndef CONFIG_MMU
1504static int elf_fdpic_dump_segments(struct file *file, struct mm_struct *mm,
1505 size_t *size, unsigned long *limit)
1506{
1507 struct vm_list_struct *vml;
1508
1509 for (vml = current->mm->context.vmlist; vml; vml = vml->next) {
1510 struct vm_area_struct *vma = vml->vma;
1511
1512 if (!maydump(vma))
1513 continue;
1514
1515 if ((*size += PAGE_SIZE) > *limit)
1516 return -EFBIG;
1517
1518 if (!dump_write(file, (void *) vma->vm_start,
1519 vma->vm_end - vma->vm_start))
1520 return -EIO;
1521 }
1522
1523 return 0;
1524}
1525#endif
1526
1527/*
1528 * Actual dumper
1529 *
1530 * This is a two-pass process; first we find the offsets of the bits,
1531 * and then they are actually written out. If we run out of core limit
1532 * we just truncate.
1533 */
1534static int elf_fdpic_core_dump(long signr, struct pt_regs *regs,
1535 struct file *file)
1536{
1537#define NUM_NOTES 6
1538 int has_dumped = 0;
1539 mm_segment_t fs;
1540 int segs;
1541 size_t size = 0;
1542 int i;
1543 struct vm_area_struct *vma;
1544 struct elfhdr *elf = NULL;
1545 loff_t offset = 0, dataoff;
1546 unsigned long limit = current->signal->rlim[RLIMIT_CORE].rlim_cur;
1547 int numnote;
1548 struct memelfnote *notes = NULL;
1549 struct elf_prstatus *prstatus = NULL; /* NT_PRSTATUS */
1550 struct elf_prpsinfo *psinfo = NULL; /* NT_PRPSINFO */
1551 struct task_struct *g, *p;
1552 LIST_HEAD(thread_list);
1553 struct list_head *t;
1554 elf_fpregset_t *fpu = NULL;
1555#ifdef ELF_CORE_COPY_XFPREGS
1556 elf_fpxregset_t *xfpu = NULL;
1557#endif
1558 int thread_status_size = 0;
1559#ifndef CONFIG_MMU
1560 struct vm_list_struct *vml;
1561#endif
1562 elf_addr_t *auxv;
1563
1564 /*
1565 * We no longer stop all VM operations.
1566 *
1567 * This is because those proceses that could possibly change map_count
1568 * or the mmap / vma pages are now blocked in do_exit on current
1569 * finishing this core dump.
1570 *
1571 * Only ptrace can touch these memory addresses, but it doesn't change
1572 * the map_count or the pages allocated. So no possibility of crashing
1573 * exists while dumping the mm->vm_next areas to the core file.
1574 */
1575
1576 /* alloc memory for large data structures: too large to be on stack */
1577 elf = kmalloc(sizeof(*elf), GFP_KERNEL);
1578 if (!elf)
1579 goto cleanup;
1580 prstatus = kzalloc(sizeof(*prstatus), GFP_KERNEL);
1581 if (!prstatus)
1582 goto cleanup;
1583 psinfo = kmalloc(sizeof(*psinfo), GFP_KERNEL);
1584 if (!psinfo)
1585 goto cleanup;
1586 notes = kmalloc(NUM_NOTES * sizeof(struct memelfnote), GFP_KERNEL);
1587 if (!notes)
1588 goto cleanup;
1589 fpu = kmalloc(sizeof(*fpu), GFP_KERNEL);
1590 if (!fpu)
1591 goto cleanup;
1592#ifdef ELF_CORE_COPY_XFPREGS
1593 xfpu = kmalloc(sizeof(*xfpu), GFP_KERNEL);
1594 if (!xfpu)
1595 goto cleanup;
1596#endif
1597
1598 if (signr) {
1599 struct elf_thread_status *tmp;
1600 read_lock(&tasklist_lock);
1601 do_each_thread(g,p)
1602 if (current->mm == p->mm && current != p) {
1603 tmp = kzalloc(sizeof(*tmp), GFP_ATOMIC);
1604 if (!tmp) {
1605 read_unlock(&tasklist_lock);
1606 goto cleanup;
1607 }
1608 INIT_LIST_HEAD(&tmp->list);
1609 tmp->thread = p;
1610 list_add(&tmp->list, &thread_list);
1611 }
1612 while_each_thread(g,p);
1613 read_unlock(&tasklist_lock);
1614 list_for_each(t, &thread_list) {
1615 struct elf_thread_status *tmp;
1616 int sz;
1617
1618 tmp = list_entry(t, struct elf_thread_status, list);
1619 sz = elf_dump_thread_status(signr, tmp);
1620 thread_status_size += sz;
1621 }
1622 }
1623
1624 /* now collect the dump for the current */
1625 fill_prstatus(prstatus, current, signr);
1626 elf_core_copy_regs(&prstatus->pr_reg, regs);
1627
1628#ifdef CONFIG_MMU
1629 segs = current->mm->map_count;
1630#else
1631 segs = 0;
1632 for (vml = current->mm->context.vmlist; vml; vml = vml->next)
1633 segs++;
1634#endif
1635#ifdef ELF_CORE_EXTRA_PHDRS
1636 segs += ELF_CORE_EXTRA_PHDRS;
1637#endif
1638
1639 /* Set up header */
1640 fill_elf_fdpic_header(elf, segs + 1); /* including notes section */
1641
1642 has_dumped = 1;
1643 current->flags |= PF_DUMPCORE;
1644
1645 /*
1646 * Set up the notes in similar form to SVR4 core dumps made
1647 * with info from their /proc.
1648 */
1649
1650 fill_note(notes + 0, "CORE", NT_PRSTATUS, sizeof(*prstatus), prstatus);
1651 fill_psinfo(psinfo, current->group_leader, current->mm);
1652 fill_note(notes + 1, "CORE", NT_PRPSINFO, sizeof(*psinfo), psinfo);
1653
1654 numnote = 2;
1655
1656 auxv = (elf_addr_t *) current->mm->saved_auxv;
1657
1658 i = 0;
1659 do
1660 i += 2;
1661 while (auxv[i - 2] != AT_NULL);
1662 fill_note(&notes[numnote++], "CORE", NT_AUXV,
1663 i * sizeof(elf_addr_t), auxv);
1664
1665 /* Try to dump the FPU. */
1666 if ((prstatus->pr_fpvalid =
1667 elf_core_copy_task_fpregs(current, regs, fpu)))
1668 fill_note(notes + numnote++,
1669 "CORE", NT_PRFPREG, sizeof(*fpu), fpu);
1670#ifdef ELF_CORE_COPY_XFPREGS
1671 if (elf_core_copy_task_xfpregs(current, xfpu))
1672 fill_note(notes + numnote++,
1673 "LINUX", NT_PRXFPREG, sizeof(*xfpu), xfpu);
1674#endif
1675
1676 fs = get_fs();
1677 set_fs(KERNEL_DS);
1678
1679 DUMP_WRITE(elf, sizeof(*elf));
1680 offset += sizeof(*elf); /* Elf header */
1681 offset += (segs+1) * sizeof(struct elf_phdr); /* Program headers */
1682
1683 /* Write notes phdr entry */
1684 {
1685 struct elf_phdr phdr;
1686 int sz = 0;
1687
1688 for (i = 0; i < numnote; i++)
1689 sz += notesize(notes + i);
1690
1691 sz += thread_status_size;
1692
1693 fill_elf_note_phdr(&phdr, sz, offset);
1694 offset += sz;
1695 DUMP_WRITE(&phdr, sizeof(phdr));
1696 }
1697
1698 /* Page-align dumped data */
1699 dataoff = offset = roundup(offset, ELF_EXEC_PAGESIZE);
1700
1701 /* write program headers for segments dump */
1702 for (
1703#ifdef CONFIG_MMU
1704 vma = current->mm->mmap; vma; vma = vma->vm_next
1705#else
1706 vml = current->mm->context.vmlist; vml; vml = vml->next
1707#endif
1708 ) {
1709 struct elf_phdr phdr;
1710 size_t sz;
1711
1712#ifndef CONFIG_MMU
1713 vma = vml->vma;
1714#endif
1715
1716 sz = vma->vm_end - vma->vm_start;
1717
1718 phdr.p_type = PT_LOAD;
1719 phdr.p_offset = offset;
1720 phdr.p_vaddr = vma->vm_start;
1721 phdr.p_paddr = 0;
1722 phdr.p_filesz = maydump(vma) ? sz : 0;
1723 phdr.p_memsz = sz;
1724 offset += phdr.p_filesz;
1725 phdr.p_flags = vma->vm_flags & VM_READ ? PF_R : 0;
1726 if (vma->vm_flags & VM_WRITE)
1727 phdr.p_flags |= PF_W;
1728 if (vma->vm_flags & VM_EXEC)
1729 phdr.p_flags |= PF_X;
1730 phdr.p_align = ELF_EXEC_PAGESIZE;
1731
1732 DUMP_WRITE(&phdr, sizeof(phdr));
1733 }
1734
1735#ifdef ELF_CORE_WRITE_EXTRA_PHDRS
1736 ELF_CORE_WRITE_EXTRA_PHDRS;
1737#endif
1738
1739 /* write out the notes section */
1740 for (i = 0; i < numnote; i++)
1741 if (!writenote(notes + i, file))
1742 goto end_coredump;
1743
1744 /* write out the thread status notes section */
1745 list_for_each(t, &thread_list) {
1746 struct elf_thread_status *tmp =
1747 list_entry(t, struct elf_thread_status, list);
1748
1749 for (i = 0; i < tmp->num_notes; i++)
1750 if (!writenote(&tmp->notes[i], file))
1751 goto end_coredump;
1752 }
1753
1754 DUMP_SEEK(dataoff);
1755
1756 if (elf_fdpic_dump_segments(file, current->mm, &size, &limit) < 0)
1757 goto end_coredump;
1758
1759#ifdef ELF_CORE_WRITE_EXTRA_DATA
1760 ELF_CORE_WRITE_EXTRA_DATA;
1761#endif
1762
1763 if (file->f_pos != offset) {
1764 /* Sanity check */
1765 printk(KERN_WARNING
1766 "elf_core_dump: file->f_pos (%lld) != offset (%lld)\n",
1767 file->f_pos, offset);
1768 }
1769
1770end_coredump:
1771 set_fs(fs);
1772
1773cleanup:
1774 while (!list_empty(&thread_list)) {
1775 struct list_head *tmp = thread_list.next;
1776 list_del(tmp);
1777 kfree(list_entry(tmp, struct elf_thread_status, list));
1778 }
1779
1780 kfree(elf);
1781 kfree(prstatus);
1782 kfree(psinfo);
1783 kfree(notes);
1784 kfree(fpu);
1785#ifdef ELF_CORE_COPY_XFPREGS
1786 kfree(xfpu);
1787#endif
1788 return has_dumped;
1789#undef NUM_NOTES
1790}
1791
1792#endif /* USE_ELF_CORE_DUMP */
diff --git a/fs/ext3/acl.h b/fs/ext3/acl.h
index 92d50b53a933..0d1e6279cbfd 100644
--- a/fs/ext3/acl.h
+++ b/fs/ext3/acl.h
@@ -62,9 +62,6 @@ extern int ext3_permission (struct inode *, int, struct nameidata *);
62extern int ext3_acl_chmod (struct inode *); 62extern int ext3_acl_chmod (struct inode *);
63extern int ext3_init_acl (handle_t *, struct inode *, struct inode *); 63extern int ext3_init_acl (handle_t *, struct inode *, struct inode *);
64 64
65extern int init_ext3_acl(void);
66extern void exit_ext3_acl(void);
67
68#else /* CONFIG_EXT3_FS_POSIX_ACL */ 65#else /* CONFIG_EXT3_FS_POSIX_ACL */
69#include <linux/sched.h> 66#include <linux/sched.h>
70#define ext3_permission NULL 67#define ext3_permission NULL
diff --git a/fs/file.c b/fs/file.c
index 55f4e7022563..3f356086061d 100644
--- a/fs/file.c
+++ b/fs/file.c
@@ -240,13 +240,9 @@ static struct fdtable *alloc_fdtable(int nr)
240 if (!fdt) 240 if (!fdt)
241 goto out; 241 goto out;
242 242
243 nfds = 8 * L1_CACHE_BYTES; 243 nfds = max_t(int, 8 * L1_CACHE_BYTES, roundup_pow_of_two(nfds));
244 /* Expand to the max in easy steps */ 244 if (nfds > NR_OPEN)
245 while (nfds <= nr) { 245 nfds = NR_OPEN;
246 nfds = nfds * 2;
247 if (nfds > NR_OPEN)
248 nfds = NR_OPEN;
249 }
250 246
251 new_openset = alloc_fdset(nfds); 247 new_openset = alloc_fdset(nfds);
252 new_execset = alloc_fdset(nfds); 248 new_execset = alloc_fdset(nfds);
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index 6449cb697967..c3920c96dadf 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -83,8 +83,6 @@ static int hugetlbfs_file_mmap(struct file *file, struct vm_area_struct *vma)
83 83
84 ret = -ENOMEM; 84 ret = -ENOMEM;
85 len = vma_len + ((loff_t)vma->vm_pgoff << PAGE_SHIFT); 85 len = vma_len + ((loff_t)vma->vm_pgoff << PAGE_SHIFT);
86 if (!(vma->vm_flags & VM_WRITE) && len > inode->i_size)
87 goto out;
88 86
89 if (vma->vm_flags & VM_MAYSHARE && 87 if (vma->vm_flags & VM_MAYSHARE &&
90 hugetlb_reserve_pages(inode, vma->vm_pgoff >> (HPAGE_SHIFT-PAGE_SHIFT), 88 hugetlb_reserve_pages(inode, vma->vm_pgoff >> (HPAGE_SHIFT-PAGE_SHIFT),
@@ -93,7 +91,7 @@ static int hugetlbfs_file_mmap(struct file *file, struct vm_area_struct *vma)
93 91
94 ret = 0; 92 ret = 0;
95 hugetlb_prefault_arch_hook(vma->vm_mm); 93 hugetlb_prefault_arch_hook(vma->vm_mm);
96 if (inode->i_size < len) 94 if (vma->vm_flags & VM_WRITE && inode->i_size < len)
97 inode->i_size = len; 95 inode->i_size = len;
98out: 96out:
99 mutex_unlock(&inode->i_mutex); 97 mutex_unlock(&inode->i_mutex);
diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
index b0e095ea0c03..ee4eff27aedc 100644
--- a/fs/nfsd/nfs4proc.c
+++ b/fs/nfsd/nfs4proc.c
@@ -721,6 +721,12 @@ nfsd4_proc_null(struct svc_rqst *rqstp, void *argp, void *resp)
721 return nfs_ok; 721 return nfs_ok;
722} 722}
723 723
724static inline void nfsd4_increment_op_stats(u32 opnum)
725{
726 if (opnum >= FIRST_NFS4_OP && opnum <= LAST_NFS4_OP)
727 nfsdstats.nfs4_opcount[opnum]++;
728}
729
724 730
725/* 731/*
726 * COMPOUND call. 732 * COMPOUND call.
@@ -930,6 +936,8 @@ encode_op:
930 /* XXX Ugh, we need to get rid of this kind of special case: */ 936 /* XXX Ugh, we need to get rid of this kind of special case: */
931 if (op->opnum == OP_READ && op->u.read.rd_filp) 937 if (op->opnum == OP_READ && op->u.read.rd_filp)
932 fput(op->u.read.rd_filp); 938 fput(op->u.read.rd_filp);
939
940 nfsd4_increment_op_stats(op->opnum);
933 } 941 }
934 942
935out: 943out:
diff --git a/fs/nfsd/stats.c b/fs/nfsd/stats.c
index 57265d563804..71944cddf680 100644
--- a/fs/nfsd/stats.c
+++ b/fs/nfsd/stats.c
@@ -72,6 +72,16 @@ static int nfsd_proc_show(struct seq_file *seq, void *v)
72 /* show my rpc info */ 72 /* show my rpc info */
73 svc_seq_show(seq, &nfsd_svcstats); 73 svc_seq_show(seq, &nfsd_svcstats);
74 74
75#ifdef CONFIG_NFSD_V4
76 /* Show count for individual nfsv4 operations */
77 /* Writing operation numbers 0 1 2 also for maintaining uniformity */
78 seq_printf(seq,"proc4ops %u", LAST_NFS4_OP + 1);
79 for (i = 0; i <= LAST_NFS4_OP; i++)
80 seq_printf(seq, " %u", nfsdstats.nfs4_opcount[i]);
81
82 seq_putc(seq, '\n');
83#endif
84
75 return 0; 85 return 0;
76} 86}
77 87
diff --git a/fs/partitions/check.c b/fs/partitions/check.c
index 839634026eb5..51c6a748df49 100644
--- a/fs/partitions/check.c
+++ b/fs/partitions/check.c
@@ -339,6 +339,7 @@ void add_partition(struct gendisk *disk, int part, sector_t start, sector_t len)
339 p->start_sect = start; 339 p->start_sect = start;
340 p->nr_sects = len; 340 p->nr_sects = len;
341 p->partno = part; 341 p->partno = part;
342 p->policy = disk->policy;
342 343
343 if (isdigit(disk->kobj.name[strlen(disk->kobj.name)-1])) 344 if (isdigit(disk->kobj.name[strlen(disk->kobj.name)-1]))
344 snprintf(p->kobj.name,KOBJ_NAME_LEN,"%sp%d",disk->kobj.name,part); 345 snprintf(p->kobj.name,KOBJ_NAME_LEN,"%sp%d",disk->kobj.name,part);
diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c
index 036d14d83627..8d6d85d7400f 100644
--- a/fs/proc/kcore.c
+++ b/fs/proc/kcore.c
@@ -42,8 +42,6 @@ const struct file_operations proc_kcore_operations = {
42#define kc_offset_to_vaddr(o) ((o) + PAGE_OFFSET) 42#define kc_offset_to_vaddr(o) ((o) + PAGE_OFFSET)
43#endif 43#endif
44 44
45#define roundup(x, y) ((((x)+((y)-1))/(y))*(y))
46
47/* An ELF note in memory */ 45/* An ELF note in memory */
48struct memelfnote 46struct memelfnote
49{ 47{
diff --git a/fs/ramfs/file-nommu.c b/fs/ramfs/file-nommu.c
index 99fffc9e1bfd..677139b48e00 100644
--- a/fs/ramfs/file-nommu.c
+++ b/fs/ramfs/file-nommu.c
@@ -283,9 +283,9 @@ unsigned long ramfs_nommu_get_unmapped_area(struct file *file,
283 283
284/*****************************************************************************/ 284/*****************************************************************************/
285/* 285/*
286 * set up a mapping 286 * set up a mapping for shared memory segments
287 */ 287 */
288int ramfs_nommu_mmap(struct file *file, struct vm_area_struct *vma) 288int ramfs_nommu_mmap(struct file *file, struct vm_area_struct *vma)
289{ 289{
290 return 0; 290 return vma->vm_flags & VM_SHARED ? 0 : -ENOSYS;
291} 291}
diff --git a/fs/read_write.c b/fs/read_write.c
index 5bc0e9234f9d..d4cb3183c99c 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -436,7 +436,7 @@ unsigned long iov_shorten(struct iovec *iov, unsigned long nr_segs, size_t to)
436 return seg; 436 return seg;
437} 437}
438 438
439EXPORT_SYMBOL(iov_shorten); 439EXPORT_UNUSED_SYMBOL(iov_shorten); /* June 2006 */
440 440
441/* A write operation does a read from user space and vice versa */ 441/* A write operation does a read from user space and vice versa */
442#define vrfy_dir(type) ((type) == READ ? VERIFY_WRITE : VERIFY_READ) 442#define vrfy_dir(type) ((type) == READ ? VERIFY_WRITE : VERIFY_READ)
diff --git a/fs/reiserfs/file.c b/fs/reiserfs/file.c
index 752cea12e30f..f318b58510fd 100644
--- a/fs/reiserfs/file.c
+++ b/fs/reiserfs/file.c
@@ -860,8 +860,12 @@ static int reiserfs_submit_file_region_for_write(struct reiserfs_transaction_han
860 // this sets the proper flags for O_SYNC to trigger a commit 860 // this sets the proper flags for O_SYNC to trigger a commit
861 mark_inode_dirty(inode); 861 mark_inode_dirty(inode);
862 reiserfs_write_unlock(inode->i_sb); 862 reiserfs_write_unlock(inode->i_sb);
863 } else 863 } else {
864 reiserfs_write_lock(inode->i_sb);
865 reiserfs_update_inode_transaction(inode);
864 mark_inode_dirty(inode); 866 mark_inode_dirty(inode);
867 reiserfs_write_unlock(inode->i_sb);
868 }
865 869
866 sd_update = 1; 870 sd_update = 1;
867 } 871 }
diff --git a/fs/xfs/linux-2.6/xfs_linux.h b/fs/xfs/linux-2.6/xfs_linux.h
index 8c021dc57d1f..a13f75c1a936 100644
--- a/fs/xfs/linux-2.6/xfs_linux.h
+++ b/fs/xfs/linux-2.6/xfs_linux.h
@@ -215,7 +215,6 @@ BUFFER_FNS(PrivateStart, unwritten);
215#define MIN(a,b) (min(a,b)) 215#define MIN(a,b) (min(a,b))
216#define MAX(a,b) (max(a,b)) 216#define MAX(a,b) (max(a,b))
217#define howmany(x, y) (((x)+((y)-1))/(y)) 217#define howmany(x, y) (((x)+((y)-1))/(y))
218#define roundup(x, y) ((((x)+((y)-1))/(y))*(y))
219 218
220/* 219/*
221 * Various platform dependent calls that don't fit anywhere else 220 * Various platform dependent calls that don't fit anywhere else
diff --git a/include/asm-frv/elf.h b/include/asm-frv/elf.h
index 38656da00e40..7df58a3e6e4a 100644
--- a/include/asm-frv/elf.h
+++ b/include/asm-frv/elf.h
@@ -64,7 +64,7 @@ typedef unsigned long elf_greg_t;
64#define ELF_NGREG (sizeof(struct pt_regs) / sizeof(elf_greg_t)) 64#define ELF_NGREG (sizeof(struct pt_regs) / sizeof(elf_greg_t))
65typedef elf_greg_t elf_gregset_t[ELF_NGREG]; 65typedef elf_greg_t elf_gregset_t[ELF_NGREG];
66 66
67typedef struct fpmedia_struct elf_fpregset_t; 67typedef struct user_fpmedia_regs elf_fpregset_t;
68 68
69/* 69/*
70 * This is used to ensure we don't load something for the wrong architecture. 70 * This is used to ensure we don't load something for the wrong architecture.
@@ -116,6 +116,7 @@ do { \
116} while(0) 116} while(0)
117 117
118#define USE_ELF_CORE_DUMP 118#define USE_ELF_CORE_DUMP
119#define ELF_FDPIC_CORE_EFLAGS EF_FRV_FDPIC
119#define ELF_EXEC_PAGESIZE 16384 120#define ELF_EXEC_PAGESIZE 16384
120 121
121/* This is the location that an ET_DYN program is loaded if exec'ed. Typical 122/* This is the location that an ET_DYN program is loaded if exec'ed. Typical
@@ -125,9 +126,6 @@ do { \
125 126
126#define ELF_ET_DYN_BASE 0x08000000UL 127#define ELF_ET_DYN_BASE 0x08000000UL
127 128
128#define ELF_CORE_COPY_REGS(pr_reg, regs) \
129 memcpy(&pr_reg[0], &regs->sp, 31 * sizeof(uint32_t));
130
131/* This yields a mask that user programs can use to figure out what 129/* This yields a mask that user programs can use to figure out what
132 instruction set this cpu supports. */ 130 instruction set this cpu supports. */
133 131
diff --git a/include/asm-frv/gdb-stub.h b/include/asm-frv/gdb-stub.h
index c58479a4be99..24f9738670bd 100644
--- a/include/asm-frv/gdb-stub.h
+++ b/include/asm-frv/gdb-stub.h
@@ -89,6 +89,7 @@ extern void gdbstub_do_rx(void);
89 89
90extern asmlinkage void __debug_stub_init_break(void); 90extern asmlinkage void __debug_stub_init_break(void);
91extern asmlinkage void __break_hijack_kernel_event(void); 91extern asmlinkage void __break_hijack_kernel_event(void);
92extern asmlinkage void __break_hijack_kernel_event_breaks_here(void);
92extern asmlinkage void start_kernel(void); 93extern asmlinkage void start_kernel(void);
93 94
94extern asmlinkage void gdbstub_rx_handler(void); 95extern asmlinkage void gdbstub_rx_handler(void);
@@ -114,5 +115,26 @@ extern void console_set_baud(unsigned baud);
114#define gdbstub_proto(FMT,...) ({ 0; }) 115#define gdbstub_proto(FMT,...) ({ 0; })
115#endif 116#endif
116 117
118/*
119 * we dedicate GR31 to keeping a pointer to the gdbstub exception frame
120 * - gr31 is destroyed on entry to the gdbstub if !MMU
121 * - gr31 is saved in scr3 on entry to the gdbstub if in !MMU
122 */
123register struct frv_frame0 *__debug_frame0 asm("gr31");
124
125#define __debug_frame (&__debug_frame0->regs)
126#define __debug_user_context (&__debug_frame0->uc)
127#define __debug_regs (&__debug_frame0->debug)
128#define __debug_reg(X) ((unsigned long *) ((unsigned long) &__debug_frame0 + (X)))
129
130struct frv_debug_status {
131 unsigned long bpsr;
132 unsigned long dcr;
133 unsigned long brr;
134 unsigned long nmar;
135};
136
137extern struct frv_debug_status __debug_status;
138
117#endif /* _LANGUAGE_ASSEMBLY */ 139#endif /* _LANGUAGE_ASSEMBLY */
118#endif /* __ASM_GDB_STUB_H */ 140#endif /* __ASM_GDB_STUB_H */
diff --git a/include/asm-frv/ptrace.h b/include/asm-frv/ptrace.h
index b2cce0718e57..7ff525162a72 100644
--- a/include/asm-frv/ptrace.h
+++ b/include/asm-frv/ptrace.h
@@ -62,18 +62,10 @@
62#ifndef __ASSEMBLY__ 62#ifndef __ASSEMBLY__
63 63
64/* 64/*
65 * dedicate GR28; to keeping the a pointer to the current exception frame 65 * we dedicate GR28 to keeping a pointer to the current exception frame
66 * - gr28 is destroyed on entry to the kernel from userspace
66 */ 67 */
67register struct pt_regs *__frame asm("gr28"); 68register struct pt_regs *__frame asm("gr28");
68register struct pt_regs *__debug_frame asm("gr31");
69
70#ifndef container_of
71#define container_of(ptr, type, member) ({ \
72 const typeof( ((type *)0)->member ) *__mptr = (ptr); \
73 (type *)( (char *)__mptr - offsetof(type,member) );})
74#endif
75
76#define __debug_regs container_of(__debug_frame, struct pt_debug_regs, normal_regs)
77 69
78#define user_mode(regs) (!((regs)->psr & PSR_S)) 70#define user_mode(regs) (!((regs)->psr & PSR_S))
79#define instruction_pointer(regs) ((regs)->pc) 71#define instruction_pointer(regs) ((regs)->pc)
diff --git a/include/asm-frv/registers.h b/include/asm-frv/registers.h
index fccfd95cff68..9666119fcf6e 100644
--- a/include/asm-frv/registers.h
+++ b/include/asm-frv/registers.h
@@ -23,7 +23,13 @@
23 * 23 *
24 * +0x2000 +---------------------- 24 * +0x2000 +----------------------
25 * | union { 25 * | union {
26 * | struct user_context 26 * | struct frv_frame0 {
27 * | struct user_context {
28 * | struct user_int_regs
29 * | struct user_fpmedia_regs
30 * | }
31 * | struct frv_debug_regs
32 * | }
27 * | struct pt_regs [user exception] 33 * | struct pt_regs [user exception]
28 * | } 34 * | }
29 * +---------------------- <-- __kernel_frame0_ptr (maybe GR28) 35 * +---------------------- <-- __kernel_frame0_ptr (maybe GR28)
@@ -51,11 +57,11 @@
51#define _ASM_REGISTERS_H 57#define _ASM_REGISTERS_H
52 58
53#ifndef __ASSEMBLY__ 59#ifndef __ASSEMBLY__
54#define __OFFSET(X) (X) 60#define __OFFSET(X,N) ((X)+(N)*4)
55#define __OFFSETC(X,N) xxxxxxxxxxxxxxxxxxxxxxxx 61#define __OFFSETC(X,N) xxxxxxxxxxxxxxxxxxxxxxxx
56#else 62#else
57#define __OFFSET(X) ((X)*4) 63#define __OFFSET(X,N) ((X)+(N)*4)
58#define __OFFSETC(X,N) ((X)*4+(N)) 64#define __OFFSETC(X,N) ((X)+(N))
59#endif 65#endif
60 66
61/*****************************************************************************/ 67/*****************************************************************************/
@@ -117,30 +123,13 @@ struct pt_regs {
117 123
118#endif 124#endif
119 125
120#define REG_PSR __OFFSET( 0) /* Processor Status Register */
121#define REG_ISR __OFFSET( 1) /* Integer Status Register */
122#define REG_CCR __OFFSET( 2) /* Condition Code Register */
123#define REG_CCCR __OFFSET( 3) /* Condition Code for Conditional Insns Register */
124#define REG_LR __OFFSET( 4) /* Link Register */
125#define REG_LCR __OFFSET( 5) /* Loop Count Register */
126#define REG_PC __OFFSET( 6) /* Program Counter */
127
128#define REG__STATUS __OFFSET( 7) /* exception status */
129#define REG__STATUS_STEP 0x00000001 /* - reenable single stepping on return */ 126#define REG__STATUS_STEP 0x00000001 /* - reenable single stepping on return */
130#define REG__STATUS_STEPPED 0x00000002 /* - single step caused exception */ 127#define REG__STATUS_STEPPED 0x00000002 /* - single step caused exception */
131#define REG__STATUS_BROKE 0x00000004 /* - BREAK insn caused exception */ 128#define REG__STATUS_BROKE 0x00000004 /* - BREAK insn caused exception */
132#define REG__STATUS_SYSC_ENTRY 0x40000000 /* - T on syscall entry (ptrace.c only) */ 129#define REG__STATUS_SYSC_ENTRY 0x40000000 /* - T on syscall entry (ptrace.c only) */
133#define REG__STATUS_SYSC_EXIT 0x80000000 /* - T on syscall exit (ptrace.c only) */ 130#define REG__STATUS_SYSC_EXIT 0x80000000 /* - T on syscall exit (ptrace.c only) */
134 131
135#define REG_SYSCALLNO __OFFSET( 8) /* syscall number or -1 */ 132#define REG_GR(R) __OFFSET(REG_GR0, (R))
136#define REG_ORIG_GR8 __OFFSET( 9) /* saved GR8 for signal handling */
137#define REG_GNER0 __OFFSET(10)
138#define REG_GNER1 __OFFSET(11)
139#define REG_IACC0 __OFFSET(12)
140
141#define REG_TBR __OFFSET(14) /* Trap Vector Register */
142#define REG_GR(R) __OFFSET((14+(R)))
143#define REG__END REG_GR(32)
144 133
145#define REG_SP REG_GR(1) 134#define REG_SP REG_GR(1)
146#define REG_FP REG_GR(2) 135#define REG_FP REG_GR(2)
@@ -149,27 +138,21 @@ struct pt_regs {
149 138
150/*****************************************************************************/ 139/*****************************************************************************/
151/* 140/*
152 * extension tacked in front of the exception frame in debug mode 141 * debugging registers
153 */ 142 */
154#ifndef __ASSEMBLY__ 143#ifndef __ASSEMBLY__
155 144
156struct pt_debug_regs 145struct frv_debug_regs
157{ 146{
158 unsigned long bpsr;
159 unsigned long dcr; 147 unsigned long dcr;
160 unsigned long brr; 148 unsigned long ibar[4] __attribute__((aligned(8)));
161 unsigned long nmar; 149 unsigned long dbar[4] __attribute__((aligned(8)));
162 struct pt_regs normal_regs; 150 unsigned long dbdr[4][4] __attribute__((aligned(8)));
151 unsigned long dbmr[4][4] __attribute__((aligned(8)));
163} __attribute__((aligned(8))); 152} __attribute__((aligned(8)));
164 153
165#endif 154#endif
166 155
167#define REG_NMAR __OFFSET(-1)
168#define REG_BRR __OFFSET(-2)
169#define REG_DCR __OFFSET(-3)
170#define REG_BPSR __OFFSET(-4)
171#define REG__DEBUG_XTRA __OFFSET(4)
172
173/*****************************************************************************/ 156/*****************************************************************************/
174/* 157/*
175 * userspace registers 158 * userspace registers
@@ -223,33 +206,27 @@ struct user_context
223 void *extension; 206 void *extension;
224} __attribute__((aligned(8))); 207} __attribute__((aligned(8)));
225 208
209struct frv_frame0 {
210 union {
211 struct pt_regs regs;
212 struct user_context uc;
213 };
214
215 struct frv_debug_regs debug;
216
217} __attribute__((aligned(32)));
218
226#endif 219#endif
227 220
228#define NR_USER_INT_REGS (14 + 64) 221#define __INT_GR(R) __OFFSET(__INT_GR0, (R))
229#define NR_USER_FPMEDIA_REGS (64 + 2 + 2 + 8 + 8/4 + 1) 222
230#define NR_USER_CONTEXT (NR_USER_INT_REGS + NR_USER_FPMEDIA_REGS + 1) 223#define __FPMEDIA_FR(R) __OFFSET(__FPMEDIA_FR0, (R))
231 224#define __FPMEDIA_FNER(R) __OFFSET(__FPMEDIA_FNER0, (R))
232#define USER_CONTEXT_SIZE (((NR_USER_CONTEXT + 1) & ~1) * 4) 225#define __FPMEDIA_MSR(R) __OFFSET(__FPMEDIA_MSR0, (R))
233 226#define __FPMEDIA_ACC(R) __OFFSET(__FPMEDIA_ACC0, (R))
234#define __THREAD_FRAME __OFFSET(0) 227#define __FPMEDIA_ACCG(R) __OFFSETC(__FPMEDIA_ACCG0, (R))
235#define __THREAD_CURR __OFFSET(1) 228#define __FPMEDIA_FSR(R) __OFFSET(__FPMEDIA_FSR0, (R))
236#define __THREAD_SP __OFFSET(2) 229
237#define __THREAD_FP __OFFSET(3) 230#define __THREAD_GR(R) __OFFSET(__THREAD_GR16, (R) - 16)
238#define __THREAD_LR __OFFSET(4)
239#define __THREAD_PC __OFFSET(5)
240#define __THREAD_GR(R) __OFFSET(6 + (R) - 16)
241#define __THREAD_FRAME0 __OFFSET(19)
242#define __THREAD_USER __OFFSET(19)
243
244#define __USER_INT __OFFSET(0)
245#define __INT_GR(R) __OFFSET(14 + (R))
246
247#define __USER_FPMEDIA __OFFSET(NR_USER_INT_REGS)
248#define __FPMEDIA_FR(R) __OFFSET(NR_USER_INT_REGS + (R))
249#define __FPMEDIA_FNER(R) __OFFSET(NR_USER_INT_REGS + 64 + (R))
250#define __FPMEDIA_MSR(R) __OFFSET(NR_USER_INT_REGS + 66 + (R))
251#define __FPMEDIA_ACC(R) __OFFSET(NR_USER_INT_REGS + 68 + (R))
252#define __FPMEDIA_ACCG(R) __OFFSETC(NR_USER_INT_REGS + 76, (R))
253#define __FPMEDIA_FSR(R) __OFFSET(NR_USER_INT_REGS + 78 + (R))
254 231
255#endif /* _ASM_REGISTERS_H */ 232#endif /* _ASM_REGISTERS_H */
diff --git a/include/asm-frv/thread_info.h b/include/asm-frv/thread_info.h
index ea426abf01d3..d66c48e6ef14 100644
--- a/include/asm-frv/thread_info.h
+++ b/include/asm-frv/thread_info.h
@@ -19,6 +19,8 @@
19#include <asm/processor.h> 19#include <asm/processor.h>
20#endif 20#endif
21 21
22#define THREAD_SIZE 8192
23
22/* 24/*
23 * low level task data that entry.S needs immediate access to 25 * low level task data that entry.S needs immediate access to
24 * - this struct should fit entirely inside of one cache line 26 * - this struct should fit entirely inside of one cache line
@@ -46,15 +48,7 @@ struct thread_info {
46 48
47#else /* !__ASSEMBLY__ */ 49#else /* !__ASSEMBLY__ */
48 50
49/* offsets into the thread_info struct for assembly code access */ 51#include <asm/asm-offsets.h>
50#define TI_TASK 0x00000000
51#define TI_EXEC_DOMAIN 0x00000004
52#define TI_FLAGS 0x00000008
53#define TI_STATUS 0x0000000C
54#define TI_CPU 0x00000010
55#define TI_PRE_COUNT 0x00000014
56#define TI_ADDR_LIMIT 0x00000018
57#define TI_RESTART_BLOCK 0x0000001C
58 52
59#endif 53#endif
60 54
@@ -83,12 +77,6 @@ struct thread_info {
83#define init_thread_info (init_thread_union.thread_info) 77#define init_thread_info (init_thread_union.thread_info)
84#define init_stack (init_thread_union.stack) 78#define init_stack (init_thread_union.stack)
85 79
86#ifdef CONFIG_SMALL_TASKS
87#define THREAD_SIZE 4096
88#else
89#define THREAD_SIZE 8192
90#endif
91
92/* how to get the thread information struct from C */ 80/* how to get the thread information struct from C */
93register struct thread_info *__current_thread_info asm("gr15"); 81register struct thread_info *__current_thread_info asm("gr15");
94 82
@@ -111,11 +99,7 @@ register struct thread_info *__current_thread_info asm("gr15");
111 99
112#define free_thread_info(info) kfree(info) 100#define free_thread_info(info) kfree(info)
113 101
114#else /* !__ASSEMBLY__ */ 102#endif /* __ASSEMBLY__ */
115
116#define THREAD_SIZE 8192
117
118#endif
119 103
120/* 104/*
121 * thread information flags 105 * thread information flags
diff --git a/include/asm-h8300/page.h b/include/asm-h8300/page.h
index f9f9d3eea8ed..d673077d2fd6 100644
--- a/include/asm-h8300/page.h
+++ b/include/asm-h8300/page.h
@@ -66,7 +66,6 @@ extern unsigned long memory_end;
66 66
67#define MAP_NR(addr) (((unsigned long)(addr)-PAGE_OFFSET) >> PAGE_SHIFT) 67#define MAP_NR(addr) (((unsigned long)(addr)-PAGE_OFFSET) >> PAGE_SHIFT)
68#define virt_to_page(addr) (mem_map + (((unsigned long)(addr)-PAGE_OFFSET) >> PAGE_SHIFT)) 68#define virt_to_page(addr) (mem_map + (((unsigned long)(addr)-PAGE_OFFSET) >> PAGE_SHIFT))
69#define virt_to_page(addr) (mem_map + (((unsigned long)(addr)-PAGE_OFFSET) >> PAGE_SHIFT))
70#define page_to_virt(page) ((((page) - mem_map) << PAGE_SHIFT) + PAGE_OFFSET) 69#define page_to_virt(page) ((((page) - mem_map) << PAGE_SHIFT) + PAGE_OFFSET)
71#define pfn_valid(page) (page < max_mapnr) 70#define pfn_valid(page) (page < max_mapnr)
72 71
diff --git a/include/asm-ia64/io.h b/include/asm-ia64/io.h
index 781ee2c7e8c3..43bfff6c6b87 100644
--- a/include/asm-ia64/io.h
+++ b/include/asm-ia64/io.h
@@ -90,7 +90,7 @@ phys_to_virt (unsigned long address)
90#define ARCH_HAS_VALID_PHYS_ADDR_RANGE 90#define ARCH_HAS_VALID_PHYS_ADDR_RANGE
91extern u64 kern_mem_attribute (unsigned long phys_addr, unsigned long size); 91extern u64 kern_mem_attribute (unsigned long phys_addr, unsigned long size);
92extern int valid_phys_addr_range (unsigned long addr, size_t count); /* efi.c */ 92extern int valid_phys_addr_range (unsigned long addr, size_t count); /* efi.c */
93extern int valid_mmap_phys_addr_range (unsigned long addr, size_t count); 93extern int valid_mmap_phys_addr_range (unsigned long pfn, size_t count);
94 94
95/* 95/*
96 * The following two macros are deprecated and scheduled for removal. 96 * The following two macros are deprecated and scheduled for removal.
diff --git a/include/asm-mips/mach-dec/mc146818rtc.h b/include/asm-mips/mach-dec/mc146818rtc.h
index 6d37a5675803..6724e99e43e1 100644
--- a/include/asm-mips/mach-dec/mc146818rtc.h
+++ b/include/asm-mips/mach-dec/mc146818rtc.h
@@ -19,6 +19,8 @@
19 19
20extern volatile u8 *dec_rtc_base; 20extern volatile u8 *dec_rtc_base;
21 21
22#define ARCH_RTC_LOCATION
23
22#define RTC_PORT(x) CPHYSADDR((long)dec_rtc_base) 24#define RTC_PORT(x) CPHYSADDR((long)dec_rtc_base)
23#define RTC_IO_EXTENT dec_kn_slot_size 25#define RTC_IO_EXTENT dec_kn_slot_size
24#define RTC_IOMAPPED 0 26#define RTC_IOMAPPED 0
diff --git a/include/asm-powerpc/backlight.h b/include/asm-powerpc/backlight.h
index a5e9e656e332..58d4b6f8d827 100644
--- a/include/asm-powerpc/backlight.h
+++ b/include/asm-powerpc/backlight.h
@@ -16,13 +16,19 @@
16extern struct backlight_device *pmac_backlight; 16extern struct backlight_device *pmac_backlight;
17extern struct mutex pmac_backlight_mutex; 17extern struct mutex pmac_backlight_mutex;
18 18
19extern void pmac_backlight_calc_curve(struct fb_info*);
20extern int pmac_backlight_curve_lookup(struct fb_info *info, int value); 19extern int pmac_backlight_curve_lookup(struct fb_info *info, int value);
21 20
22extern int pmac_has_backlight_type(const char *type); 21extern int pmac_has_backlight_type(const char *type);
23 22
24extern void pmac_backlight_key_up(void); 23extern void pmac_backlight_key(int direction);
25extern void pmac_backlight_key_down(void); 24static inline void pmac_backlight_key_up(void)
25{
26 pmac_backlight_key(0);
27}
28static inline void pmac_backlight_key_down(void)
29{
30 pmac_backlight_key(1);
31}
26 32
27extern int pmac_backlight_set_legacy_brightness(int brightness); 33extern int pmac_backlight_set_legacy_brightness(int brightness);
28extern int pmac_backlight_get_legacy_brightness(void); 34extern int pmac_backlight_get_legacy_brightness(void);
diff --git a/include/asm-powerpc/irq.h b/include/asm-powerpc/irq.h
index e05754752028..d903a62959da 100644
--- a/include/asm-powerpc/irq.h
+++ b/include/asm-powerpc/irq.h
@@ -83,25 +83,24 @@ struct irq_host_ops {
83 int (*match)(struct irq_host *h, struct device_node *node); 83 int (*match)(struct irq_host *h, struct device_node *node);
84 84
85 /* Create or update a mapping between a virtual irq number and a hw 85 /* Create or update a mapping between a virtual irq number and a hw
86 * irq number. This can be called several times for the same mapping 86 * irq number. This is called only once for a given mapping.
87 * but with different flags, though unmap shall always be called
88 * before the virq->hw mapping is changed.
89 */ 87 */
90 int (*map)(struct irq_host *h, unsigned int virq, 88 int (*map)(struct irq_host *h, unsigned int virq, irq_hw_number_t hw);
91 irq_hw_number_t hw, unsigned int flags);
92 89
93 /* Dispose of such a mapping */ 90 /* Dispose of such a mapping */
94 void (*unmap)(struct irq_host *h, unsigned int virq); 91 void (*unmap)(struct irq_host *h, unsigned int virq);
95 92
96 /* Translate device-tree interrupt specifier from raw format coming 93 /* Translate device-tree interrupt specifier from raw format coming
97 * from the firmware to a irq_hw_number_t (interrupt line number) and 94 * from the firmware to a irq_hw_number_t (interrupt line number) and
98 * trigger flags that can be passed to irq_create_mapping(). 95 * type (sense) that can be passed to set_irq_type(). In the absence
99 * If no translation is provided, raw format is assumed to be one cell 96 * of this callback, irq_create_of_mapping() and irq_of_parse_and_map()
100 * for interrupt line and default sense. 97 * will return the hw number in the first cell and IRQ_TYPE_NONE for
98 * the type (which amount to keeping whatever default value the
99 * interrupt controller has for that line)
101 */ 100 */
102 int (*xlate)(struct irq_host *h, struct device_node *ctrler, 101 int (*xlate)(struct irq_host *h, struct device_node *ctrler,
103 u32 *intspec, unsigned int intsize, 102 u32 *intspec, unsigned int intsize,
104 irq_hw_number_t *out_hwirq, unsigned int *out_flags); 103 irq_hw_number_t *out_hwirq, unsigned int *out_type);
105}; 104};
106 105
107struct irq_host { 106struct irq_host {
@@ -193,25 +192,14 @@ extern void irq_set_virq_count(unsigned int count);
193 * irq_create_mapping - Map a hardware interrupt into linux virq space 192 * irq_create_mapping - Map a hardware interrupt into linux virq space
194 * @host: host owning this hardware interrupt or NULL for default host 193 * @host: host owning this hardware interrupt or NULL for default host
195 * @hwirq: hardware irq number in that host space 194 * @hwirq: hardware irq number in that host space
196 * @flags: flags passed to the controller. contains the trigger type among
197 * others. Use IRQ_TYPE_* defined in include/linux/irq.h
198 * 195 *
199 * Only one mapping per hardware interrupt is permitted. Returns a linux 196 * Only one mapping per hardware interrupt is permitted. Returns a linux
200 * virq number. The flags can be used to provide sense information to the 197 * virq number.
201 * controller (typically extracted from the device-tree). If no information 198 * If the sense/trigger is to be specified, set_irq_type() should be called
202 * is passed, the controller defaults will apply (for example, xics can only 199 * on the number returned from that call.
203 * do edge so flags are irrelevant for some pseries specific irqs).
204 *
205 * The device-tree generally contains the trigger info in an encoding that is
206 * specific to a given type of controller. In that case, you can directly use
207 * host->ops->trigger_xlate() to translate that.
208 *
209 * It is recommended that new PICs that don't have existing OF bindings chose
210 * to use a representation of triggers identical to linux.
211 */ 200 */
212extern unsigned int irq_create_mapping(struct irq_host *host, 201extern unsigned int irq_create_mapping(struct irq_host *host,
213 irq_hw_number_t hwirq, 202 irq_hw_number_t hwirq);
214 unsigned int flags);
215 203
216 204
217/*** 205/***
@@ -295,7 +283,7 @@ extern void irq_free_virt(unsigned int virq, unsigned int count);
295 * 283 *
296 * This function is identical to irq_create_mapping except that it takes 284 * This function is identical to irq_create_mapping except that it takes
297 * as input informations straight from the device-tree (typically the results 285 * as input informations straight from the device-tree (typically the results
298 * of the of_irq_map_*() functions 286 * of the of_irq_map_*() functions.
299 */ 287 */
300extern unsigned int irq_create_of_mapping(struct device_node *controller, 288extern unsigned int irq_create_of_mapping(struct device_node *controller,
301 u32 *intspec, unsigned int intsize); 289 u32 *intspec, unsigned int intsize);
diff --git a/include/asm-x86_64/calgary.h b/include/asm-x86_64/calgary.h
index 6e1654f30986..fbfb50136edb 100644
--- a/include/asm-x86_64/calgary.h
+++ b/include/asm-x86_64/calgary.h
@@ -1,8 +1,10 @@
1/* 1/*
2 * Derived from include/asm-powerpc/iommu.h 2 * Derived from include/asm-powerpc/iommu.h
3 * 3 *
4 * Copyright (C) 2006 Jon Mason <jdmason@us.ibm.com>, IBM Corporation 4 * Copyright (C) IBM Corporation, 2006
5 * Copyright (C) 2006 Muli Ben-Yehuda <muli@il.ibm.com>, IBM Corporation 5 *
6 * Author: Jon Mason <jdmason@us.ibm.com>
7 * Author: Muli Ben-Yehuda <muli@il.ibm.com>
6 * 8 *
7 * This program is free software; you can redistribute it and/or modify 9 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by 10 * it under the terms of the GNU General Public License as published by
diff --git a/include/asm-x86_64/tce.h b/include/asm-x86_64/tce.h
index ee51d31528d6..53e9a68b3336 100644
--- a/include/asm-x86_64/tce.h
+++ b/include/asm-x86_64/tce.h
@@ -1,9 +1,11 @@
1/* 1/*
2 * Copyright (C) 2006 Muli Ben-Yehuda <muli@il.ibm.com>, IBM Corporation
3 * Copyright (C) 2006 Jon Mason <jdmason@us.ibm.com>, IBM Corporation
4 *
5 * This file is derived from asm-powerpc/tce.h. 2 * This file is derived from asm-powerpc/tce.h.
6 * 3 *
4 * Copyright (C) IBM Corporation, 2006
5 *
6 * Author: Muli Ben-Yehuda <muli@il.ibm.com>
7 * Author: Jon Mason <jdmason@us.ibm.com>
8 *
7 * This program is free software; you can redistribute it and/or modify 9 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by 10 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or 11 * the Free Software Foundation; either version 2 of the License, or
diff --git a/include/linux/bootmem.h b/include/linux/bootmem.h
index 22866fa2d960..1021f508d82c 100644
--- a/include/linux/bootmem.h
+++ b/include/linux/bootmem.h
@@ -91,7 +91,7 @@ static inline void *alloc_remap(int nid, unsigned long size)
91} 91}
92#endif 92#endif
93 93
94extern unsigned long nr_kernel_pages; 94extern unsigned long __meminitdata nr_kernel_pages;
95extern unsigned long nr_all_pages; 95extern unsigned long nr_all_pages;
96 96
97extern void *__init alloc_large_system_hash(const char *tablename, 97extern void *__init alloc_large_system_hash(const char *tablename,
diff --git a/include/linux/completion.h b/include/linux/completion.h
index 251c41e3ddd5..268c5a4a2bd4 100644
--- a/include/linux/completion.h
+++ b/include/linux/completion.h
@@ -18,6 +18,9 @@ struct completion {
18#define COMPLETION_INITIALIZER(work) \ 18#define COMPLETION_INITIALIZER(work) \
19 { 0, __WAIT_QUEUE_HEAD_INITIALIZER((work).wait) } 19 { 0, __WAIT_QUEUE_HEAD_INITIALIZER((work).wait) }
20 20
21#define COMPLETION_INITIALIZER_ONSTACK(work) \
22 ({ init_completion(&work); work; })
23
21#define DECLARE_COMPLETION(work) \ 24#define DECLARE_COMPLETION(work) \
22 struct completion work = COMPLETION_INITIALIZER(work) 25 struct completion work = COMPLETION_INITIALIZER(work)
23 26
@@ -28,7 +31,7 @@ struct completion {
28 */ 31 */
29#ifdef CONFIG_LOCKDEP 32#ifdef CONFIG_LOCKDEP
30# define DECLARE_COMPLETION_ONSTACK(work) \ 33# define DECLARE_COMPLETION_ONSTACK(work) \
31 struct completion work = ({ init_completion(&work); work; }) 34 struct completion work = COMPLETION_INITIALIZER_ONSTACK(work)
32#else 35#else
33# define DECLARE_COMPLETION_ONSTACK(work) DECLARE_COMPLETION(work) 36# define DECLARE_COMPLETION_ONSTACK(work) DECLARE_COMPLETION(work)
34#endif 37#endif
diff --git a/include/linux/console_struct.h b/include/linux/console_struct.h
index f8e5587a0f92..25423f79bf9f 100644
--- a/include/linux/console_struct.h
+++ b/include/linux/console_struct.h
@@ -9,6 +9,7 @@
9 * to achieve effects such as fast scrolling by changing the origin. 9 * to achieve effects such as fast scrolling by changing the origin.
10 */ 10 */
11 11
12#include <linux/wait.h>
12#include <linux/vt.h> 13#include <linux/vt.h>
13 14
14struct vt_struct; 15struct vt_struct;
diff --git a/include/linux/elfcore.h b/include/linux/elfcore.h
index 0cf0bea010fe..9631dddae348 100644
--- a/include/linux/elfcore.h
+++ b/include/linux/elfcore.h
@@ -60,6 +60,16 @@ struct elf_prstatus
60 long pr_instr; /* Current instruction */ 60 long pr_instr; /* Current instruction */
61#endif 61#endif
62 elf_gregset_t pr_reg; /* GP registers */ 62 elf_gregset_t pr_reg; /* GP registers */
63#ifdef CONFIG_BINFMT_ELF_FDPIC
64 /* When using FDPIC, the loadmap addresses need to be communicated
65 * to GDB in order for GDB to do the necessary relocations. The
66 * fields (below) used to communicate this information are placed
67 * immediately after ``pr_reg'', so that the loadmap addresses may
68 * be viewed as part of the register set if so desired.
69 */
70 unsigned long pr_exec_fdpic_loadmap;
71 unsigned long pr_interp_fdpic_loadmap;
72#endif
63 int pr_fpvalid; /* True if math co-processor being used. */ 73 int pr_fpvalid; /* True if math co-processor being used. */
64}; 74};
65 75
diff --git a/include/linux/fb.h b/include/linux/fb.h
index ffefeeeeca93..405f44e44e5d 100644
--- a/include/linux/fb.h
+++ b/include/linux/fb.h
@@ -377,7 +377,6 @@ struct fb_cursor {
377 377
378#include <linux/fs.h> 378#include <linux/fs.h>
379#include <linux/init.h> 379#include <linux/init.h>
380#include <linux/tty.h>
381#include <linux/device.h> 380#include <linux/device.h>
382#include <linux/workqueue.h> 381#include <linux/workqueue.h>
383#include <linux/notifier.h> 382#include <linux/notifier.h>
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 43aef9b230fd..25610205c90d 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -27,6 +27,10 @@
27#define BLOCK_SIZE_BITS 10 27#define BLOCK_SIZE_BITS 10
28#define BLOCK_SIZE (1<<BLOCK_SIZE_BITS) 28#define BLOCK_SIZE (1<<BLOCK_SIZE_BITS)
29 29
30#define SEEK_SET 0 /* seek relative to beginning of file */
31#define SEEK_CUR 1 /* seek relative to current file position */
32#define SEEK_END 2 /* seek relative to end of file */
33
30/* And dynamically-tunable limits and defaults: */ 34/* And dynamically-tunable limits and defaults: */
31struct files_stat_struct { 35struct files_stat_struct {
32 int nr_files; /* read only */ 36 int nr_files; /* read only */
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 5c1ec1f84eab..181c69cad4e3 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -33,6 +33,7 @@ extern const char linux_banner[];
33#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) 33#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
34#define ALIGN(x,a) (((x)+(a)-1)&~((a)-1)) 34#define ALIGN(x,a) (((x)+(a)-1)&~((a)-1))
35#define FIELD_SIZEOF(t, f) (sizeof(((t*)0)->f)) 35#define FIELD_SIZEOF(t, f) (sizeof(((t*)0)->f))
36#define roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y))
36 37
37#define KERN_EMERG "<0>" /* system is unusable */ 38#define KERN_EMERG "<0>" /* system is unusable */
38#define KERN_ALERT "<1>" /* action must be taken immediately */ 39#define KERN_ALERT "<1>" /* action must be taken immediately */
diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h
index 316e0fb8d7b1..c040a8c969aa 100644
--- a/include/linux/lockdep.h
+++ b/include/linux/lockdep.h
@@ -120,7 +120,7 @@ struct lock_class {
120 */ 120 */
121struct lockdep_map { 121struct lockdep_map {
122 struct lock_class_key *key; 122 struct lock_class_key *key;
123 struct lock_class *class[MAX_LOCKDEP_SUBCLASSES]; 123 struct lock_class *class_cache;
124 const char *name; 124 const char *name;
125}; 125};
126 126
diff --git a/include/linux/mc146818rtc.h b/include/linux/mc146818rtc.h
index bbc93ae217e1..432b2fa24929 100644
--- a/include/linux/mc146818rtc.h
+++ b/include/linux/mc146818rtc.h
@@ -89,4 +89,11 @@ extern spinlock_t rtc_lock; /* serialize CMOS RAM access */
89# define RTC_VRT 0x80 /* valid RAM and time */ 89# define RTC_VRT 0x80 /* valid RAM and time */
90/**********************************************************************/ 90/**********************************************************************/
91 91
92#ifndef ARCH_RTC_LOCATION /* Override by <asm/mc146818rtc.h>? */
93
94#define RTC_IO_EXTENT 0x8
95#define RTC_IOMAPPED 1 /* Default to I/O mapping. */
96
97#endif /* ARCH_RTC_LOCATION */
98
92#endif /* _MC146818RTC_H */ 99#endif /* _MC146818RTC_H */
diff --git a/include/linux/nfs4.h b/include/linux/nfs4.h
index 5f681d534295..db05182ca0e8 100644
--- a/include/linux/nfs4.h
+++ b/include/linux/nfs4.h
@@ -157,6 +157,12 @@ enum nfs_opnum4 {
157 OP_ILLEGAL = 10044, 157 OP_ILLEGAL = 10044,
158}; 158};
159 159
160/*Defining first and last NFS4 operations implemented.
161Needs to be updated if more operations are defined in future.*/
162
163#define FIRST_NFS4_OP OP_ACCESS
164#define LAST_NFS4_OP OP_RELEASE_LOCKOWNER
165
160enum nfsstat4 { 166enum nfsstat4 {
161 NFS4_OK = 0, 167 NFS4_OK = 0,
162 NFS4ERR_PERM = 1, 168 NFS4ERR_PERM = 1,
diff --git a/include/linux/nfsd/stats.h b/include/linux/nfsd/stats.h
index b6f1e0cda4f2..28a82fdd922f 100644
--- a/include/linux/nfsd/stats.h
+++ b/include/linux/nfsd/stats.h
@@ -9,6 +9,8 @@
9#ifndef LINUX_NFSD_STATS_H 9#ifndef LINUX_NFSD_STATS_H
10#define LINUX_NFSD_STATS_H 10#define LINUX_NFSD_STATS_H
11 11
12#include <linux/nfs4.h>
13
12struct nfsd_stats { 14struct nfsd_stats {
13 unsigned int rchits; /* repcache hits */ 15 unsigned int rchits; /* repcache hits */
14 unsigned int rcmisses; /* repcache hits */ 16 unsigned int rcmisses; /* repcache hits */
@@ -27,6 +29,10 @@ struct nfsd_stats {
27 unsigned int ra_size; /* size of ra cache */ 29 unsigned int ra_size; /* size of ra cache */
28 unsigned int ra_depth[11]; /* number of times ra entry was found that deep 30 unsigned int ra_depth[11]; /* number of times ra entry was found that deep
29 * in the cache (10percentiles). [10] = not found */ 31 * in the cache (10percentiles). [10] = not found */
32#ifdef CONFIG_NFSD_V4
33 unsigned int nfs4_opcount[LAST_NFS4_OP + 1]; /* count of individual nfsv4 operations */
34#endif
35
30}; 36};
31 37
32/* thread usage wraps very million seconds (approx one fortnight) */ 38/* thread usage wraps very million seconds (approx one fortnight) */
diff --git a/include/linux/raid/md_k.h b/include/linux/raid/md_k.h
index c1e0ac55bab5..d28890295852 100644
--- a/include/linux/raid/md_k.h
+++ b/include/linux/raid/md_k.h
@@ -148,9 +148,10 @@ struct mddev_s
148 148
149 struct mdk_thread_s *thread; /* management thread */ 149 struct mdk_thread_s *thread; /* management thread */
150 struct mdk_thread_s *sync_thread; /* doing resync or reconstruct */ 150 struct mdk_thread_s *sync_thread; /* doing resync or reconstruct */
151 sector_t curr_resync; /* blocks scheduled */ 151 sector_t curr_resync; /* last block scheduled */
152 unsigned long resync_mark; /* a recent timestamp */ 152 unsigned long resync_mark; /* a recent timestamp */
153 sector_t resync_mark_cnt;/* blocks written at resync_mark */ 153 sector_t resync_mark_cnt;/* blocks written at resync_mark */
154 sector_t curr_mark_cnt; /* blocks scheduled now */
154 155
155 sector_t resync_max_sectors; /* may be set by personality */ 156 sector_t resync_max_sectors; /* may be set by personality */
156 157
diff --git a/include/linux/rwsem.h b/include/linux/rwsem.h
index 658afb37c3f5..7b524b4109a0 100644
--- a/include/linux/rwsem.h
+++ b/include/linux/rwsem.h
@@ -61,12 +61,25 @@ extern void downgrade_write(struct rw_semaphore *sem);
61 61
62#ifdef CONFIG_DEBUG_LOCK_ALLOC 62#ifdef CONFIG_DEBUG_LOCK_ALLOC
63/* 63/*
64 * nested locking: 64 * nested locking. NOTE: rwsems are not allowed to recurse
65 * (which occurs if the same task tries to acquire the same
66 * lock instance multiple times), but multiple locks of the
67 * same lock class might be taken, if the order of the locks
68 * is always the same. This ordering rule can be expressed
69 * to lockdep via the _nested() APIs, but enumerating the
70 * subclasses that are used. (If the nesting relationship is
71 * static then another method for expressing nested locking is
72 * the explicit definition of lock class keys and the use of
73 * lockdep_set_class() at lock initialization time.
74 * See Documentation/lockdep-design.txt for more details.)
65 */ 75 */
66extern void down_read_nested(struct rw_semaphore *sem, int subclass); 76extern void down_read_nested(struct rw_semaphore *sem, int subclass);
67extern void down_write_nested(struct rw_semaphore *sem, int subclass); 77extern void down_write_nested(struct rw_semaphore *sem, int subclass);
68/* 78/*
69 * Take/release a lock when not the owner will release it: 79 * Take/release a lock when not the owner will release it.
80 *
81 * [ This API should be avoided as much as possible - the
82 * proper abstraction for this case is completions. ]
70 */ 83 */
71extern void down_read_non_owner(struct rw_semaphore *sem); 84extern void down_read_non_owner(struct rw_semaphore *sem);
72extern void up_read_non_owner(struct rw_semaphore *sem); 85extern void up_read_non_owner(struct rw_semaphore *sem);
diff --git a/include/linux/tty.h b/include/linux/tty.h
index b3b807e4b050..e421d5e34818 100644
--- a/include/linux/tty.h
+++ b/include/linux/tty.h
@@ -5,16 +5,6 @@
5 * 'tty.h' defines some structures used by tty_io.c and some defines. 5 * 'tty.h' defines some structures used by tty_io.c and some defines.
6 */ 6 */
7 7
8/*
9 * These constants are also useful for user-level apps (e.g., VC
10 * resizing).
11 */
12#define MIN_NR_CONSOLES 1 /* must be at least 1 */
13#define MAX_NR_CONSOLES 63 /* serial lines start at 64 */
14#define MAX_NR_USER_CONSOLES 63 /* must be root to allocate above this */
15 /* Note: the ioctl VT_GETSTATE does not work for
16 consoles 16 and higher (since it returns a short) */
17
18#ifdef __KERNEL__ 8#ifdef __KERNEL__
19#include <linux/fs.h> 9#include <linux/fs.h>
20#include <linux/major.h> 10#include <linux/major.h>
@@ -22,7 +12,6 @@
22#include <linux/workqueue.h> 12#include <linux/workqueue.h>
23#include <linux/tty_driver.h> 13#include <linux/tty_driver.h>
24#include <linux/tty_ldisc.h> 14#include <linux/tty_ldisc.h>
25#include <linux/screen_info.h>
26#include <linux/mutex.h> 15#include <linux/mutex.h>
27 16
28#include <asm/system.h> 17#include <asm/system.h>
@@ -270,7 +259,6 @@ struct tty_struct {
270extern void tty_write_flush(struct tty_struct *); 259extern void tty_write_flush(struct tty_struct *);
271 260
272extern struct termios tty_std_termios; 261extern struct termios tty_std_termios;
273extern int fg_console, last_console, want_console;
274 262
275extern int kmsg_redirect; 263extern int kmsg_redirect;
276 264
diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h
index 3e0daf54133e..1ab806c47514 100644
--- a/include/linux/vmstat.h
+++ b/include/linux/vmstat.h
@@ -57,7 +57,7 @@ static inline void __count_vm_events(enum vm_event_item item, long delta)
57 57
58static inline void count_vm_events(enum vm_event_item item, long delta) 58static inline void count_vm_events(enum vm_event_item item, long delta)
59{ 59{
60 get_cpu_var(vm_event_states.event[item])++; 60 get_cpu_var(vm_event_states.event[item]) += delta;
61 put_cpu(); 61 put_cpu();
62} 62}
63 63
@@ -186,11 +186,16 @@ static inline void __mod_zone_page_state(struct zone *zone,
186 zone_page_state_add(delta, zone, item); 186 zone_page_state_add(delta, zone, item);
187} 187}
188 188
189static inline void __inc_zone_state(struct zone *zone, enum zone_stat_item item)
190{
191 atomic_long_inc(&zone->vm_stat[item]);
192 atomic_long_inc(&vm_stat[item]);
193}
194
189static inline void __inc_zone_page_state(struct page *page, 195static inline void __inc_zone_page_state(struct page *page,
190 enum zone_stat_item item) 196 enum zone_stat_item item)
191{ 197{
192 atomic_long_inc(&page_zone(page)->vm_stat[item]); 198 __inc_zone_state(page_zone(page), item);
193 atomic_long_inc(&vm_stat[item]);
194} 199}
195 200
196static inline void __dec_zone_page_state(struct page *page, 201static inline void __dec_zone_page_state(struct page *page,
diff --git a/include/linux/vt.h b/include/linux/vt.h
index 9f95b0bea5b3..8ab334a48222 100644
--- a/include/linux/vt.h
+++ b/include/linux/vt.h
@@ -1,6 +1,16 @@
1#ifndef _LINUX_VT_H 1#ifndef _LINUX_VT_H
2#define _LINUX_VT_H 2#define _LINUX_VT_H
3 3
4/*
5 * These constants are also useful for user-level apps (e.g., VC
6 * resizing).
7 */
8#define MIN_NR_CONSOLES 1 /* must be at least 1 */
9#define MAX_NR_CONSOLES 63 /* serial lines start at 64 */
10#define MAX_NR_USER_CONSOLES 63 /* must be root to allocate above this */
11 /* Note: the ioctl VT_GETSTATE does not work for
12 consoles 16 and higher (since it returns a short) */
13
4/* 0x56 is 'V', to avoid collision with termios and kd */ 14/* 0x56 is 'V', to avoid collision with termios and kd */
5 15
6#define VT_OPENQRY 0x5600 /* find available vt */ 16#define VT_OPENQRY 0x5600 /* find available vt */
diff --git a/include/linux/vt_kern.h b/include/linux/vt_kern.h
index 940d0261a545..918a29763aea 100644
--- a/include/linux/vt_kern.h
+++ b/include/linux/vt_kern.h
@@ -26,6 +26,7 @@
26 26
27extern void kd_mksound(unsigned int hz, unsigned int ticks); 27extern void kd_mksound(unsigned int hz, unsigned int ticks);
28extern int kbd_rate(struct kbd_repeat *rep); 28extern int kbd_rate(struct kbd_repeat *rep);
29extern int fg_console, last_console, want_console;
29 30
30/* console.c */ 31/* console.c */
31 32
diff --git a/include/linux/wait.h b/include/linux/wait.h
index 794be7af58ae..b3b9048421d8 100644
--- a/include/linux/wait.h
+++ b/include/linux/wait.h
@@ -77,17 +77,7 @@ struct task_struct;
77#define __WAIT_BIT_KEY_INITIALIZER(word, bit) \ 77#define __WAIT_BIT_KEY_INITIALIZER(word, bit) \
78 { .flags = word, .bit_nr = bit, } 78 { .flags = word, .bit_nr = bit, }
79 79
80/* 80extern void init_waitqueue_head(wait_queue_head_t *q);
81 * lockdep: we want one lock-class for all waitqueue locks.
82 */
83extern struct lock_class_key waitqueue_lock_key;
84
85static inline void init_waitqueue_head(wait_queue_head_t *q)
86{
87 spin_lock_init(&q->lock);
88 lockdep_set_class(&q->lock, &waitqueue_lock_key);
89 INIT_LIST_HEAD(&q->task_list);
90}
91 81
92static inline void init_waitqueue_entry(wait_queue_t *q, struct task_struct *p) 82static inline void init_waitqueue_entry(wait_queue_t *q, struct task_struct *p)
93{ 83{
diff --git a/kernel/fork.c b/kernel/fork.c
index 56e4e07e45f7..926e5a68ea9e 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -61,9 +61,7 @@ int max_threads; /* tunable limit on nr_threads */
61 61
62DEFINE_PER_CPU(unsigned long, process_counts) = 0; 62DEFINE_PER_CPU(unsigned long, process_counts) = 0;
63 63
64 __cacheline_aligned DEFINE_RWLOCK(tasklist_lock); /* outer */ 64__cacheline_aligned DEFINE_RWLOCK(tasklist_lock); /* outer */
65
66EXPORT_SYMBOL(tasklist_lock);
67 65
68int nr_processes(void) 66int nr_processes(void)
69{ 67{
diff --git a/kernel/futex.c b/kernel/futex.c
index 1dc98e4dd287..cf0c8e21d1ab 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -476,6 +476,12 @@ lookup_pi_state(u32 uval, struct futex_hash_bucket *hb, struct futex_q *me)
476 * the refcount and return its pi_state: 476 * the refcount and return its pi_state:
477 */ 477 */
478 pi_state = this->pi_state; 478 pi_state = this->pi_state;
479 /*
480 * Userspace might have messed up non PI and PI futexes
481 */
482 if (unlikely(!pi_state))
483 return -EINVAL;
484
479 atomic_inc(&pi_state->refcount); 485 atomic_inc(&pi_state->refcount);
480 me->pi_state = pi_state; 486 me->pi_state = pi_state;
481 487
diff --git a/kernel/lockdep.c b/kernel/lockdep.c
index f32ca78c198d..9bad17884513 100644
--- a/kernel/lockdep.c
+++ b/kernel/lockdep.c
@@ -169,22 +169,17 @@ EXPORT_SYMBOL(lockdep_internal);
169 */ 169 */
170static int class_filter(struct lock_class *class) 170static int class_filter(struct lock_class *class)
171{ 171{
172#if 0
173 /* Example */
172 if (class->name_version == 1 && 174 if (class->name_version == 1 &&
173 !strcmp(class->name, "&rl->lock")) 175 !strcmp(class->name, "lockname"))
174 return 1; 176 return 1;
175 if (class->name_version == 1 && 177 if (class->name_version == 1 &&
176 !strcmp(class->name, "&ni->mrec_lock")) 178 !strcmp(class->name, "&struct->lockfield"))
177 return 1; 179 return 1;
178 if (class->name_version == 1 && 180#endif
179 !strcmp(class->name, "mft_ni_runlist_lock")) 181 /* Allow everything else. 0 would be filter everything else */
180 return 1; 182 return 1;
181 if (class->name_version == 1 &&
182 !strcmp(class->name, "mft_ni_mrec_lock"))
183 return 1;
184 if (class->name_version == 1 &&
185 !strcmp(class->name, "&vol->lcnbmp_lock"))
186 return 1;
187 return 0;
188} 183}
189#endif 184#endif
190 185
@@ -408,23 +403,12 @@ static void lockdep_print_held_locks(struct task_struct *curr)
408 print_lock(curr->held_locks + i); 403 print_lock(curr->held_locks + i);
409 } 404 }
410} 405}
411/*
412 * Helper to print a nice hierarchy of lock dependencies:
413 */
414static void print_spaces(int nr)
415{
416 int i;
417
418 for (i = 0; i < nr; i++)
419 printk(" ");
420}
421 406
422static void print_lock_class_header(struct lock_class *class, int depth) 407static void print_lock_class_header(struct lock_class *class, int depth)
423{ 408{
424 int bit; 409 int bit;
425 410
426 print_spaces(depth); 411 printk("%*s->", depth, "");
427 printk("->");
428 print_lock_name(class); 412 print_lock_name(class);
429 printk(" ops: %lu", class->ops); 413 printk(" ops: %lu", class->ops);
430 printk(" {\n"); 414 printk(" {\n");
@@ -433,17 +417,14 @@ static void print_lock_class_header(struct lock_class *class, int depth)
433 if (class->usage_mask & (1 << bit)) { 417 if (class->usage_mask & (1 << bit)) {
434 int len = depth; 418 int len = depth;
435 419
436 print_spaces(depth); 420 len += printk("%*s %s", depth, "", usage_str[bit]);
437 len += printk(" %s", usage_str[bit]);
438 len += printk(" at:\n"); 421 len += printk(" at:\n");
439 print_stack_trace(class->usage_traces + bit, len); 422 print_stack_trace(class->usage_traces + bit, len);
440 } 423 }
441 } 424 }
442 print_spaces(depth); 425 printk("%*s }\n", depth, "");
443 printk(" }\n");
444 426
445 print_spaces(depth); 427 printk("%*s ... key at: ",depth,"");
446 printk(" ... key at: ");
447 print_ip_sym((unsigned long)class->key); 428 print_ip_sym((unsigned long)class->key);
448} 429}
449 430
@@ -463,8 +444,7 @@ static void print_lock_dependencies(struct lock_class *class, int depth)
463 DEBUG_LOCKS_WARN_ON(!entry->class); 444 DEBUG_LOCKS_WARN_ON(!entry->class);
464 print_lock_dependencies(entry->class, depth + 1); 445 print_lock_dependencies(entry->class, depth + 1);
465 446
466 print_spaces(depth); 447 printk("%*s ... acquired at:\n",depth,"");
467 printk(" ... acquired at:\n");
468 print_stack_trace(&entry->trace, 2); 448 print_stack_trace(&entry->trace, 2);
469 printk("\n"); 449 printk("\n");
470 } 450 }
@@ -1124,7 +1104,7 @@ extern void __error_too_big_MAX_LOCKDEP_SUBCLASSES(void);
1124 * itself, so actual lookup of the hash should be once per lock object. 1104 * itself, so actual lookup of the hash should be once per lock object.
1125 */ 1105 */
1126static inline struct lock_class * 1106static inline struct lock_class *
1127register_lock_class(struct lockdep_map *lock, unsigned int subclass) 1107look_up_lock_class(struct lockdep_map *lock, unsigned int subclass)
1128{ 1108{
1129 struct lockdep_subclass_key *key; 1109 struct lockdep_subclass_key *key;
1130 struct list_head *hash_head; 1110 struct list_head *hash_head;
@@ -1168,7 +1148,26 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass)
1168 */ 1148 */
1169 list_for_each_entry(class, hash_head, hash_entry) 1149 list_for_each_entry(class, hash_head, hash_entry)
1170 if (class->key == key) 1150 if (class->key == key)
1171 goto out_set; 1151 return class;
1152
1153 return NULL;
1154}
1155
1156/*
1157 * Register a lock's class in the hash-table, if the class is not present
1158 * yet. Otherwise we look it up. We cache the result in the lock object
1159 * itself, so actual lookup of the hash should be once per lock object.
1160 */
1161static inline struct lock_class *
1162register_lock_class(struct lockdep_map *lock, unsigned int subclass)
1163{
1164 struct lockdep_subclass_key *key;
1165 struct list_head *hash_head;
1166 struct lock_class *class;
1167
1168 class = look_up_lock_class(lock, subclass);
1169 if (likely(class))
1170 return class;
1172 1171
1173 /* 1172 /*
1174 * Debug-check: all keys must be persistent! 1173 * Debug-check: all keys must be persistent!
@@ -1183,6 +1182,9 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass)
1183 return NULL; 1182 return NULL;
1184 } 1183 }
1185 1184
1185 key = lock->key->subkeys + subclass;
1186 hash_head = classhashentry(key);
1187
1186 __raw_spin_lock(&hash_lock); 1188 __raw_spin_lock(&hash_lock);
1187 /* 1189 /*
1188 * We have to do the hash-walk again, to avoid races 1190 * We have to do the hash-walk again, to avoid races
@@ -1229,8 +1231,8 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass)
1229out_unlock_set: 1231out_unlock_set:
1230 __raw_spin_unlock(&hash_lock); 1232 __raw_spin_unlock(&hash_lock);
1231 1233
1232out_set: 1234 if (!subclass)
1233 lock->class[subclass] = class; 1235 lock->class_cache = class;
1234 1236
1235 DEBUG_LOCKS_WARN_ON(class->subclass != subclass); 1237 DEBUG_LOCKS_WARN_ON(class->subclass != subclass);
1236 1238
@@ -1934,7 +1936,7 @@ void lockdep_init_map(struct lockdep_map *lock, const char *name,
1934 } 1936 }
1935 lock->name = name; 1937 lock->name = name;
1936 lock->key = key; 1938 lock->key = key;
1937 memset(lock->class, 0, sizeof(lock->class[0])*MAX_LOCKDEP_SUBCLASSES); 1939 lock->class_cache = NULL;
1938} 1940}
1939 1941
1940EXPORT_SYMBOL_GPL(lockdep_init_map); 1942EXPORT_SYMBOL_GPL(lockdep_init_map);
@@ -1948,8 +1950,8 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass,
1948 unsigned long ip) 1950 unsigned long ip)
1949{ 1951{
1950 struct task_struct *curr = current; 1952 struct task_struct *curr = current;
1953 struct lock_class *class = NULL;
1951 struct held_lock *hlock; 1954 struct held_lock *hlock;
1952 struct lock_class *class;
1953 unsigned int depth, id; 1955 unsigned int depth, id;
1954 int chain_head = 0; 1956 int chain_head = 0;
1955 u64 chain_key; 1957 u64 chain_key;
@@ -1967,8 +1969,11 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass,
1967 return 0; 1969 return 0;
1968 } 1970 }
1969 1971
1970 class = lock->class[subclass]; 1972 if (!subclass)
1971 /* not cached yet? */ 1973 class = lock->class_cache;
1974 /*
1975 * Not cached yet or subclass?
1976 */
1972 if (unlikely(!class)) { 1977 if (unlikely(!class)) {
1973 class = register_lock_class(lock, subclass); 1978 class = register_lock_class(lock, subclass);
1974 if (!class) 1979 if (!class)
@@ -2469,48 +2474,44 @@ void lockdep_free_key_range(void *start, unsigned long size)
2469 2474
2470void lockdep_reset_lock(struct lockdep_map *lock) 2475void lockdep_reset_lock(struct lockdep_map *lock)
2471{ 2476{
2472 struct lock_class *class, *next, *entry; 2477 struct lock_class *class, *next;
2473 struct list_head *head; 2478 struct list_head *head;
2474 unsigned long flags; 2479 unsigned long flags;
2475 int i, j; 2480 int i, j;
2476 2481
2477 raw_local_irq_save(flags); 2482 raw_local_irq_save(flags);
2478 __raw_spin_lock(&hash_lock);
2479 2483
2480 /* 2484 /*
2481 * Remove all classes this lock has: 2485 * Remove all classes this lock might have:
2486 */
2487 for (j = 0; j < MAX_LOCKDEP_SUBCLASSES; j++) {
2488 /*
2489 * If the class exists we look it up and zap it:
2490 */
2491 class = look_up_lock_class(lock, j);
2492 if (class)
2493 zap_class(class);
2494 }
2495 /*
2496 * Debug check: in the end all mapped classes should
2497 * be gone.
2482 */ 2498 */
2499 __raw_spin_lock(&hash_lock);
2483 for (i = 0; i < CLASSHASH_SIZE; i++) { 2500 for (i = 0; i < CLASSHASH_SIZE; i++) {
2484 head = classhash_table + i; 2501 head = classhash_table + i;
2485 if (list_empty(head)) 2502 if (list_empty(head))
2486 continue; 2503 continue;
2487 list_for_each_entry_safe(class, next, head, hash_entry) { 2504 list_for_each_entry_safe(class, next, head, hash_entry) {
2488 for (j = 0; j < MAX_LOCKDEP_SUBCLASSES; j++) { 2505 if (unlikely(class == lock->class_cache)) {
2489 entry = lock->class[j]; 2506 __raw_spin_unlock(&hash_lock);
2490 if (class == entry) { 2507 DEBUG_LOCKS_WARN_ON(1);
2491 zap_class(class); 2508 goto out_restore;
2492 lock->class[j] = NULL;
2493 break;
2494 }
2495 } 2509 }
2496 } 2510 }
2497 } 2511 }
2498
2499 /*
2500 * Debug check: in the end all mapped classes should
2501 * be gone.
2502 */
2503 for (j = 0; j < MAX_LOCKDEP_SUBCLASSES; j++) {
2504 entry = lock->class[j];
2505 if (!entry)
2506 continue;
2507 __raw_spin_unlock(&hash_lock);
2508 DEBUG_LOCKS_WARN_ON(1);
2509 raw_local_irq_restore(flags);
2510 return;
2511 }
2512
2513 __raw_spin_unlock(&hash_lock); 2512 __raw_spin_unlock(&hash_lock);
2513
2514out_restore:
2514 raw_local_irq_restore(flags); 2515 raw_local_irq_restore(flags);
2515} 2516}
2516 2517
@@ -2571,7 +2572,7 @@ static inline int in_range(const void *start, const void *addr, const void *end)
2571 2572
2572static void 2573static void
2573print_freed_lock_bug(struct task_struct *curr, const void *mem_from, 2574print_freed_lock_bug(struct task_struct *curr, const void *mem_from,
2574 const void *mem_to) 2575 const void *mem_to, struct held_lock *hlock)
2575{ 2576{
2576 if (!debug_locks_off()) 2577 if (!debug_locks_off())
2577 return; 2578 return;
@@ -2583,6 +2584,7 @@ print_freed_lock_bug(struct task_struct *curr, const void *mem_from,
2583 printk( "-------------------------\n"); 2584 printk( "-------------------------\n");
2584 printk("%s/%d is freeing memory %p-%p, with a lock still held there!\n", 2585 printk("%s/%d is freeing memory %p-%p, with a lock still held there!\n",
2585 curr->comm, curr->pid, mem_from, mem_to-1); 2586 curr->comm, curr->pid, mem_from, mem_to-1);
2587 print_lock(hlock);
2586 lockdep_print_held_locks(curr); 2588 lockdep_print_held_locks(curr);
2587 2589
2588 printk("\nstack backtrace:\n"); 2590 printk("\nstack backtrace:\n");
@@ -2616,7 +2618,7 @@ void debug_check_no_locks_freed(const void *mem_from, unsigned long mem_len)
2616 !in_range(mem_from, lock_to, mem_to)) 2618 !in_range(mem_from, lock_to, mem_to))
2617 continue; 2619 continue;
2618 2620
2619 print_freed_lock_bug(curr, mem_from, mem_to); 2621 print_freed_lock_bug(curr, mem_from, mem_to, hlock);
2620 break; 2622 break;
2621 } 2623 }
2622 local_irq_restore(flags); 2624 local_irq_restore(flags);
diff --git a/kernel/panic.c b/kernel/panic.c
index ab13f0f668b5..d8a0bca21233 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -172,6 +172,7 @@ const char *print_tainted(void)
172 172
173void add_taint(unsigned flag) 173void add_taint(unsigned flag)
174{ 174{
175 debug_locks_off(); /* can't trust the integrity of the kernel anymore */
175 tainted |= flag; 176 tainted |= flag;
176} 177}
177EXPORT_SYMBOL(add_taint); 178EXPORT_SYMBOL(add_taint);
@@ -256,6 +257,7 @@ int oops_may_print(void)
256 */ 257 */
257void oops_enter(void) 258void oops_enter(void)
258{ 259{
260 debug_locks_off(); /* can't trust the integrity of the kernel anymore */
259 do_oops_enter_exit(); 261 do_oops_enter_exit();
260} 262}
261 263
diff --git a/kernel/power/snapshot.c b/kernel/power/snapshot.c
index 24c96f354231..75d4886e648e 100644
--- a/kernel/power/snapshot.c
+++ b/kernel/power/snapshot.c
@@ -227,11 +227,17 @@ static void copy_data_pages(struct pbe *pblist)
227 for (zone_pfn = 0; zone_pfn < zone->spanned_pages; ++zone_pfn) { 227 for (zone_pfn = 0; zone_pfn < zone->spanned_pages; ++zone_pfn) {
228 if (saveable(zone, &zone_pfn)) { 228 if (saveable(zone, &zone_pfn)) {
229 struct page *page; 229 struct page *page;
230 long *src, *dst;
231 int n;
232
230 page = pfn_to_page(zone_pfn + zone->zone_start_pfn); 233 page = pfn_to_page(zone_pfn + zone->zone_start_pfn);
231 BUG_ON(!pbe); 234 BUG_ON(!pbe);
232 pbe->orig_address = (unsigned long)page_address(page); 235 pbe->orig_address = (unsigned long)page_address(page);
233 /* copy_page is not usable for copying task structs. */ 236 /* copy_page and memcpy are not usable for copying task structs. */
234 memcpy((void *)pbe->address, (void *)pbe->orig_address, PAGE_SIZE); 237 dst = (long *)pbe->address;
238 src = (long *)pbe->orig_address;
239 for (n = PAGE_SIZE / sizeof(long); n; n--)
240 *dst++ = *src++;
235 pbe = pbe->next; 241 pbe = pbe->next;
236 } 242 }
237 } 243 }
diff --git a/kernel/power/swap.c b/kernel/power/swap.c
index 044b8e0c1025..f1dd146bd64d 100644
--- a/kernel/power/swap.c
+++ b/kernel/power/swap.c
@@ -263,7 +263,6 @@ int swsusp_write(void)
263 struct swap_map_handle handle; 263 struct swap_map_handle handle;
264 struct snapshot_handle snapshot; 264 struct snapshot_handle snapshot;
265 struct swsusp_info *header; 265 struct swsusp_info *header;
266 unsigned long start;
267 int error; 266 int error;
268 267
269 if ((error = swsusp_swap_check())) { 268 if ((error = swsusp_swap_check())) {
@@ -281,16 +280,17 @@ int swsusp_write(void)
281 } 280 }
282 error = get_swap_writer(&handle); 281 error = get_swap_writer(&handle);
283 if (!error) { 282 if (!error) {
284 start = handle.cur_swap; 283 unsigned long start = handle.cur_swap;
285 error = swap_write_page(&handle, header); 284 error = swap_write_page(&handle, header);
286 } 285 if (!error)
287 if (!error) 286 error = save_image(&handle, &snapshot,
288 error = save_image(&handle, &snapshot, header->pages - 1); 287 header->pages - 1);
289 if (!error) { 288 if (!error) {
290 flush_swap_writer(&handle); 289 flush_swap_writer(&handle);
291 printk("S"); 290 printk("S");
292 error = mark_swapfiles(swp_entry(root_swap, start)); 291 error = mark_swapfiles(swp_entry(root_swap, start));
293 printk("|\n"); 292 printk("|\n");
293 }
294 } 294 }
295 if (error) 295 if (error)
296 free_all_swap_pages(root_swap, handle.bitmap); 296 free_all_swap_pages(root_swap, handle.bitmap);
@@ -311,8 +311,10 @@ static atomic_t io_done = ATOMIC_INIT(0);
311 311
312static int end_io(struct bio *bio, unsigned int num, int err) 312static int end_io(struct bio *bio, unsigned int num, int err)
313{ 313{
314 if (!test_bit(BIO_UPTODATE, &bio->bi_flags)) 314 if (!test_bit(BIO_UPTODATE, &bio->bi_flags)) {
315 panic("I/O error reading memory image"); 315 printk(KERN_ERR "I/O error reading swsusp image.\n");
316 return -EIO;
317 }
316 atomic_set(&io_done, 0); 318 atomic_set(&io_done, 0);
317 return 0; 319 return 0;
318} 320}
diff --git a/kernel/printk.c b/kernel/printk.c
index bdba5d80496c..65ca0688f86f 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -52,7 +52,7 @@ int console_printk[4] = {
52 DEFAULT_CONSOLE_LOGLEVEL, /* default_console_loglevel */ 52 DEFAULT_CONSOLE_LOGLEVEL, /* default_console_loglevel */
53}; 53};
54 54
55EXPORT_SYMBOL(console_printk); 55EXPORT_UNUSED_SYMBOL(console_printk); /* June 2006 */
56 56
57/* 57/*
58 * Low lever drivers may need that to know if they can schedule in 58 * Low lever drivers may need that to know if they can schedule in
@@ -773,7 +773,7 @@ int is_console_locked(void)
773{ 773{
774 return console_locked; 774 return console_locked;
775} 775}
776EXPORT_SYMBOL(is_console_locked); 776EXPORT_UNUSED_SYMBOL(is_console_locked); /* June 2006 */
777 777
778/** 778/**
779 * release_console_sem - unlock the console system 779 * release_console_sem - unlock the console system
diff --git a/kernel/sched.c b/kernel/sched.c
index 4ee400f9d56b..d714611f1691 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -3384,7 +3384,7 @@ EXPORT_SYMBOL(schedule);
3384 3384
3385#ifdef CONFIG_PREEMPT 3385#ifdef CONFIG_PREEMPT
3386/* 3386/*
3387 * this is is the entry point to schedule() from in-kernel preemption 3387 * this is the entry point to schedule() from in-kernel preemption
3388 * off of preempt_enable. Kernel preemptions off return from interrupt 3388 * off of preempt_enable. Kernel preemptions off return from interrupt
3389 * occur there and call schedule directly. 3389 * occur there and call schedule directly.
3390 */ 3390 */
@@ -3427,7 +3427,7 @@ need_resched:
3427EXPORT_SYMBOL(preempt_schedule); 3427EXPORT_SYMBOL(preempt_schedule);
3428 3428
3429/* 3429/*
3430 * this is is the entry point to schedule() from kernel preemption 3430 * this is the entry point to schedule() from kernel preemption
3431 * off of irq context. 3431 * off of irq context.
3432 * Note, that this is called and return with irqs disabled. This will 3432 * Note, that this is called and return with irqs disabled. This will
3433 * protect us against recursive calling from irq. 3433 * protect us against recursive calling from irq.
@@ -3439,7 +3439,7 @@ asmlinkage void __sched preempt_schedule_irq(void)
3439 struct task_struct *task = current; 3439 struct task_struct *task = current;
3440 int saved_lock_depth; 3440 int saved_lock_depth;
3441#endif 3441#endif
3442 /* Catch callers which need to be fixed*/ 3442 /* Catch callers which need to be fixed */
3443 BUG_ON(ti->preempt_count || !irqs_disabled()); 3443 BUG_ON(ti->preempt_count || !irqs_disabled());
3444 3444
3445need_resched: 3445need_resched:
@@ -4650,7 +4650,7 @@ static inline struct task_struct *younger_sibling(struct task_struct *p)
4650 return list_entry(p->sibling.next,struct task_struct,sibling); 4650 return list_entry(p->sibling.next,struct task_struct,sibling);
4651} 4651}
4652 4652
4653static const char *stat_nam[] = { "R", "S", "D", "T", "t", "Z", "X" }; 4653static const char stat_nam[] = "RSDTtZX";
4654 4654
4655static void show_task(struct task_struct *p) 4655static void show_task(struct task_struct *p)
4656{ 4656{
@@ -4658,12 +4658,9 @@ static void show_task(struct task_struct *p)
4658 unsigned long free = 0; 4658 unsigned long free = 0;
4659 unsigned state; 4659 unsigned state;
4660 4660
4661 printk("%-13.13s ", p->comm);
4662 state = p->state ? __ffs(p->state) + 1 : 0; 4661 state = p->state ? __ffs(p->state) + 1 : 0;
4663 if (state < ARRAY_SIZE(stat_nam)) 4662 printk("%-13.13s %c", p->comm,
4664 printk(stat_nam[state]); 4663 state < sizeof(stat_nam) - 1 ? stat_nam[state] : '?');
4665 else
4666 printk("?");
4667#if (BITS_PER_LONG == 32) 4664#if (BITS_PER_LONG == 32)
4668 if (state == TASK_RUNNING) 4665 if (state == TASK_RUNNING)
4669 printk(" running "); 4666 printk(" running ");
@@ -4877,7 +4874,7 @@ static int __migrate_task(struct task_struct *p, int src_cpu, int dest_cpu)
4877 p->timestamp = p->timestamp - rq_src->timestamp_last_tick 4874 p->timestamp = p->timestamp - rq_src->timestamp_last_tick
4878 + rq_dest->timestamp_last_tick; 4875 + rq_dest->timestamp_last_tick;
4879 deactivate_task(p, rq_src); 4876 deactivate_task(p, rq_src);
4880 activate_task(p, rq_dest, 0); 4877 __activate_task(p, rq_dest);
4881 if (TASK_PREEMPTS_CURR(p, rq_dest)) 4878 if (TASK_PREEMPTS_CURR(p, rq_dest))
4882 resched_task(rq_dest->curr); 4879 resched_task(rq_dest->curr);
4883 } 4880 }
@@ -5776,7 +5773,7 @@ static unsigned long long measure_migration_cost(int cpu1, int cpu2)
5776 cache = vmalloc(max_size); 5773 cache = vmalloc(max_size);
5777 if (!cache) { 5774 if (!cache) {
5778 printk("could not vmalloc %d bytes for cache!\n", 2*max_size); 5775 printk("could not vmalloc %d bytes for cache!\n", 2*max_size);
5779 return 1000000; // return 1 msec on very small boxen 5776 return 1000000; /* return 1 msec on very small boxen */
5780 } 5777 }
5781 5778
5782 while (size <= max_size) { 5779 while (size <= max_size) {
diff --git a/kernel/softirq.c b/kernel/softirq.c
index 215541e26c1a..fd12f2556f0d 100644
--- a/kernel/softirq.c
+++ b/kernel/softirq.c
@@ -311,7 +311,7 @@ void open_softirq(int nr, void (*action)(struct softirq_action*), void *data)
311 softirq_vec[nr].action = action; 311 softirq_vec[nr].action = action;
312} 312}
313 313
314EXPORT_SYMBOL(open_softirq); 314EXPORT_UNUSED_SYMBOL(open_softirq); /* June 2006 */
315 315
316/* Tasklets */ 316/* Tasklets */
317struct tasklet_head 317struct tasklet_head
diff --git a/kernel/timer.c b/kernel/timer.c
index 396a3c024c2c..2a87430a58d4 100644
--- a/kernel/timer.c
+++ b/kernel/timer.c
@@ -891,6 +891,7 @@ int do_settimeofday(struct timespec *tv)
891 set_normalized_timespec(&xtime, sec, nsec); 891 set_normalized_timespec(&xtime, sec, nsec);
892 set_normalized_timespec(&wall_to_monotonic, wtm_sec, wtm_nsec); 892 set_normalized_timespec(&wall_to_monotonic, wtm_sec, wtm_nsec);
893 893
894 clock->error = 0;
894 ntp_clear(); 895 ntp_clear();
895 896
896 write_sequnlock_irqrestore(&xtime_lock, flags); 897 write_sequnlock_irqrestore(&xtime_lock, flags);
@@ -1008,52 +1009,52 @@ static int __init timekeeping_init_device(void)
1008device_initcall(timekeeping_init_device); 1009device_initcall(timekeeping_init_device);
1009 1010
1010/* 1011/*
1011 * If the error is already larger, we look ahead another tick, 1012 * If the error is already larger, we look ahead even further
1012 * to compensate for late or lost adjustments. 1013 * to compensate for late or lost adjustments.
1013 */ 1014 */
1014static __always_inline int clocksource_bigadjust(int sign, s64 error, s64 *interval, s64 *offset) 1015static __always_inline int clocksource_bigadjust(s64 error, s64 *interval, s64 *offset)
1015{ 1016{
1016 int adj; 1017 s64 tick_error, i;
1018 u32 look_ahead, adj;
1019 s32 error2, mult;
1017 1020
1018 /* 1021 /*
1019 * As soon as the machine is synchronized to the external time 1022 * Use the current error value to determine how much to look ahead.
1020 * source this should be the common case. 1023 * The larger the error the slower we adjust for it to avoid problems
1024 * with losing too many ticks, otherwise we would overadjust and
1025 * produce an even larger error. The smaller the adjustment the
1026 * faster we try to adjust for it, as lost ticks can do less harm
1027 * here. This is tuned so that an error of about 1 msec is adusted
1028 * within about 1 sec (or 2^20 nsec in 2^SHIFT_HZ ticks).
1021 */ 1029 */
1022 error >>= 2; 1030 error2 = clock->error >> (TICK_LENGTH_SHIFT + 22 - 2 * SHIFT_HZ);
1023 if (likely(sign > 0 ? error <= *interval : error >= *interval)) 1031 error2 = abs(error2);
1024 return sign; 1032 for (look_ahead = 0; error2 > 0; look_ahead++)
1033 error2 >>= 2;
1025 1034
1026 /* 1035 /*
1027 * An extra look ahead dampens the effect of the current error, 1036 * Now calculate the error in (1 << look_ahead) ticks, but first
1028 * which can grow quite large with continously late updates, as 1037 * remove the single look ahead already included in the error.
1029 * it would dominate the adjustment value and can lead to
1030 * oscillation.
1031 */ 1038 */
1032 error += current_tick_length() >> (TICK_LENGTH_SHIFT - clock->shift + 1); 1039 tick_error = current_tick_length() >> (TICK_LENGTH_SHIFT - clock->shift + 1);
1033 error -= clock->xtime_interval >> 1; 1040 tick_error -= clock->xtime_interval >> 1;
1034 1041 error = ((error - tick_error) >> look_ahead) + tick_error;
1035 adj = 0; 1042
1036 while (1) { 1043 /* Finally calculate the adjustment shift value. */
1037 error >>= 1; 1044 i = *interval;
1038 if (sign > 0 ? error <= *interval : error >= *interval) 1045 mult = 1;
1039 break; 1046 if (error < 0) {
1040 adj++; 1047 error = -error;
1048 *interval = -*interval;
1049 *offset = -*offset;
1050 mult = -1;
1041 } 1051 }
1042 1052 for (adj = 0; error > i; adj++)
1043 /* 1053 error >>= 1;
1044 * Add the current adjustments to the error and take the offset
1045 * into account, the latter can cause the error to be hardly
1046 * reduced at the next tick. Check the error again if there's
1047 * room for another adjustment, thus further reducing the error
1048 * which otherwise had to be corrected at the next update.
1049 */
1050 error = (error << 1) - *interval + *offset;
1051 if (sign > 0 ? error > *interval : error < *interval)
1052 adj++;
1053 1054
1054 *interval <<= adj; 1055 *interval <<= adj;
1055 *offset <<= adj; 1056 *offset <<= adj;
1056 return sign << adj; 1057 return mult << adj;
1057} 1058}
1058 1059
1059/* 1060/*
@@ -1068,11 +1069,19 @@ static void clocksource_adjust(struct clocksource *clock, s64 offset)
1068 1069
1069 error = clock->error >> (TICK_LENGTH_SHIFT - clock->shift - 1); 1070 error = clock->error >> (TICK_LENGTH_SHIFT - clock->shift - 1);
1070 if (error > interval) { 1071 if (error > interval) {
1071 adj = clocksource_bigadjust(1, error, &interval, &offset); 1072 error >>= 2;
1073 if (likely(error <= interval))
1074 adj = 1;
1075 else
1076 adj = clocksource_bigadjust(error, &interval, &offset);
1072 } else if (error < -interval) { 1077 } else if (error < -interval) {
1073 interval = -interval; 1078 error >>= 2;
1074 offset = -offset; 1079 if (likely(error >= -interval)) {
1075 adj = clocksource_bigadjust(-1, error, &interval, &offset); 1080 adj = -1;
1081 interval = -interval;
1082 offset = -offset;
1083 } else
1084 adj = clocksource_bigadjust(error, &interval, &offset);
1076 } else 1085 } else
1077 return; 1086 return;
1078 1087
@@ -1129,7 +1138,7 @@ static void update_wall_time(void)
1129 clocksource_adjust(clock, offset); 1138 clocksource_adjust(clock, offset);
1130 1139
1131 /* store full nanoseconds into xtime */ 1140 /* store full nanoseconds into xtime */
1132 xtime.tv_nsec = clock->xtime_nsec >> clock->shift; 1141 xtime.tv_nsec = (s64)clock->xtime_nsec >> clock->shift;
1133 clock->xtime_nsec -= (s64)xtime.tv_nsec << clock->shift; 1142 clock->xtime_nsec -= (s64)xtime.tv_nsec << clock->shift;
1134 1143
1135 /* check to see if there is a new clocksource to use */ 1144 /* check to see if there is a new clocksource to use */
diff --git a/kernel/wait.c b/kernel/wait.c
index a1d57aeb7f75..59a82f63275d 100644
--- a/kernel/wait.c
+++ b/kernel/wait.c
@@ -10,9 +10,13 @@
10#include <linux/wait.h> 10#include <linux/wait.h>
11#include <linux/hash.h> 11#include <linux/hash.h>
12 12
13struct lock_class_key waitqueue_lock_key; 13void init_waitqueue_head(wait_queue_head_t *q)
14{
15 spin_lock_init(&q->lock);
16 INIT_LIST_HEAD(&q->task_list);
17}
14 18
15EXPORT_SYMBOL(waitqueue_lock_key); 19EXPORT_SYMBOL(init_waitqueue_head);
16 20
17void fastcall add_wait_queue(wait_queue_head_t *q, wait_queue_t *wait) 21void fastcall add_wait_queue(wait_queue_head_t *q, wait_queue_t *wait)
18{ 22{
diff --git a/mm/bootmem.c b/mm/bootmem.c
index d213feded10d..50353e0dac12 100644
--- a/mm/bootmem.c
+++ b/mm/bootmem.c
@@ -29,9 +29,7 @@ unsigned long max_low_pfn;
29unsigned long min_low_pfn; 29unsigned long min_low_pfn;
30unsigned long max_pfn; 30unsigned long max_pfn;
31 31
32EXPORT_SYMBOL(max_pfn); /* This is exported so 32EXPORT_UNUSED_SYMBOL(max_pfn); /* June 2006 */
33 * dma_get_required_mask(), which uses
34 * it, can be an inline function */
35 33
36static LIST_HEAD(bdata_list); 34static LIST_HEAD(bdata_list);
37#ifdef CONFIG_CRASH_DUMP 35#ifdef CONFIG_CRASH_DUMP
diff --git a/mm/fadvise.c b/mm/fadvise.c
index 0a03357a1f8e..60a5d55e51d9 100644
--- a/mm/fadvise.c
+++ b/mm/fadvise.c
@@ -23,18 +23,6 @@
23/* 23/*
24 * POSIX_FADV_WILLNEED could set PG_Referenced, and POSIX_FADV_NOREUSE could 24 * POSIX_FADV_WILLNEED could set PG_Referenced, and POSIX_FADV_NOREUSE could
25 * deactivate the pages and clear PG_Referenced. 25 * deactivate the pages and clear PG_Referenced.
26 *
27 * LINUX_FADV_ASYNC_WRITE: start async writeout of any dirty pages between file
28 * offsets `offset' and `offset+len' inclusive. Any pages which are currently
29 * under writeout are skipped, whether or not they are dirty.
30 *
31 * LINUX_FADV_WRITE_WAIT: wait upon writeout of any dirty pages between file
32 * offsets `offset' and `offset+len'.
33 *
34 * By combining these two operations the application may do several things:
35 *
36 * LINUX_FADV_ASYNC_WRITE: push some or all of the dirty pages at the disk.
37 *
38 */ 26 */
39asmlinkage long sys_fadvise64_64(int fd, loff_t offset, loff_t len, int advice) 27asmlinkage long sys_fadvise64_64(int fd, loff_t offset, loff_t len, int advice)
40{ 28{
diff --git a/mm/memory.c b/mm/memory.c
index c1e14c9e67e4..dc0d82cf2a1c 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -1853,7 +1853,7 @@ int vmtruncate_range(struct inode *inode, loff_t offset, loff_t end)
1853 1853
1854 return 0; 1854 return 0;
1855} 1855}
1856EXPORT_SYMBOL(vmtruncate_range); 1856EXPORT_UNUSED_SYMBOL(vmtruncate_range); /* June 2006 */
1857 1857
1858/* 1858/*
1859 * Primitive swap readahead code. We simply read an aligned block of 1859 * Primitive swap readahead code. We simply read an aligned block of
diff --git a/mm/mmzone.c b/mm/mmzone.c
index 0959ee1a4795..febea1c98168 100644
--- a/mm/mmzone.c
+++ b/mm/mmzone.c
@@ -14,7 +14,7 @@ struct pglist_data *first_online_pgdat(void)
14 return NODE_DATA(first_online_node); 14 return NODE_DATA(first_online_node);
15} 15}
16 16
17EXPORT_SYMBOL(first_online_pgdat); 17EXPORT_UNUSED_SYMBOL(first_online_pgdat); /* June 2006 */
18 18
19struct pglist_data *next_online_pgdat(struct pglist_data *pgdat) 19struct pglist_data *next_online_pgdat(struct pglist_data *pgdat)
20{ 20{
@@ -24,7 +24,7 @@ struct pglist_data *next_online_pgdat(struct pglist_data *pgdat)
24 return NULL; 24 return NULL;
25 return NODE_DATA(nid); 25 return NODE_DATA(nid);
26} 26}
27EXPORT_SYMBOL(next_online_pgdat); 27EXPORT_UNUSED_SYMBOL(next_online_pgdat); /* June 2006 */
28 28
29 29
30/* 30/*
@@ -45,5 +45,5 @@ struct zone *next_zone(struct zone *zone)
45 } 45 }
46 return zone; 46 return zone;
47} 47}
48EXPORT_SYMBOL(next_zone); 48EXPORT_UNUSED_SYMBOL(next_zone); /* June 2006 */
49 49
diff --git a/mm/vmstat.c b/mm/vmstat.c
index 73b83d67bab6..dfdf24133901 100644
--- a/mm/vmstat.c
+++ b/mm/vmstat.c
@@ -81,6 +81,7 @@ void all_vm_events(unsigned long *ret)
81{ 81{
82 sum_vm_events(ret, &cpu_online_map); 82 sum_vm_events(ret, &cpu_online_map);
83} 83}
84EXPORT_SYMBOL_GPL(all_vm_events);
84 85
85#ifdef CONFIG_HOTPLUG 86#ifdef CONFIG_HOTPLUG
86/* 87/*
diff --git a/net/ax25/ax25_in.c b/net/ax25/ax25_in.c
index 4cf87540fb3a..e9d94291581e 100644
--- a/net/ax25/ax25_in.c
+++ b/net/ax25/ax25_in.c
@@ -102,8 +102,8 @@ static int ax25_rx_fragment(ax25_cb *ax25, struct sk_buff *skb)
102int ax25_rx_iframe(ax25_cb *ax25, struct sk_buff *skb) 102int ax25_rx_iframe(ax25_cb *ax25, struct sk_buff *skb)
103{ 103{
104 int (*func)(struct sk_buff *, ax25_cb *); 104 int (*func)(struct sk_buff *, ax25_cb *);
105 volatile int queued = 0;
106 unsigned char pid; 105 unsigned char pid;
106 int queued = 0;
107 107
108 if (skb == NULL) return 0; 108 if (skb == NULL) return 0;
109 109
diff --git a/net/dccp/proto.c b/net/dccp/proto.c
index f4f0627ea41c..6f14bb5a28d4 100644
--- a/net/dccp/proto.c
+++ b/net/dccp/proto.c
@@ -484,7 +484,7 @@ static int do_dccp_setsockopt(struct sock *sk, int level, int optname,
484 err = -EINVAL; 484 err = -EINVAL;
485 else 485 else
486 err = dccp_setsockopt_change(sk, DCCPO_CHANGE_L, 486 err = dccp_setsockopt_change(sk, DCCPO_CHANGE_L,
487 (struct dccp_so_feat *) 487 (struct dccp_so_feat __user *)
488 optval); 488 optval);
489 break; 489 break;
490 490
@@ -493,7 +493,7 @@ static int do_dccp_setsockopt(struct sock *sk, int level, int optname,
493 err = -EINVAL; 493 err = -EINVAL;
494 else 494 else
495 err = dccp_setsockopt_change(sk, DCCPO_CHANGE_R, 495 err = dccp_setsockopt_change(sk, DCCPO_CHANGE_R,
496 (struct dccp_so_feat *) 496 (struct dccp_so_feat __user *)
497 optval); 497 optval);
498 break; 498 break;
499 499
diff --git a/net/ipv4/Kconfig b/net/ipv4/Kconfig
index da33393be45f..8514106761b0 100644
--- a/net/ipv4/Kconfig
+++ b/net/ipv4/Kconfig
@@ -572,16 +572,6 @@ config TCP_CONG_VENO
572 loss packets. 572 loss packets.
573 See http://www.ntu.edu.sg/home5/ZHOU0022/papers/CPFu03a.pdf 573 See http://www.ntu.edu.sg/home5/ZHOU0022/papers/CPFu03a.pdf
574 574
575config TCP_CONG_COMPOUND
576 tristate "TCP Compound"
577 depends on EXPERIMENTAL
578 default n
579 ---help---
580 TCP Compound is a sender-side only change to TCP that uses
581 a mixed Reno/Vegas approach to calculate the cwnd.
582 For further details look here:
583 ftp://ftp.research.microsoft.com/pub/tr/TR-2005-86.pdf
584
585endmenu 575endmenu
586 576
587config TCP_CONG_BIC 577config TCP_CONG_BIC
diff --git a/net/ipv4/Makefile b/net/ipv4/Makefile
index 38b8039bdd55..4878fc5be85f 100644
--- a/net/ipv4/Makefile
+++ b/net/ipv4/Makefile
@@ -47,7 +47,6 @@ obj-$(CONFIG_TCP_CONG_VEGAS) += tcp_vegas.o
47obj-$(CONFIG_TCP_CONG_VENO) += tcp_veno.o 47obj-$(CONFIG_TCP_CONG_VENO) += tcp_veno.o
48obj-$(CONFIG_TCP_CONG_SCALABLE) += tcp_scalable.o 48obj-$(CONFIG_TCP_CONG_SCALABLE) += tcp_scalable.o
49obj-$(CONFIG_TCP_CONG_LP) += tcp_lp.o 49obj-$(CONFIG_TCP_CONG_LP) += tcp_lp.o
50obj-$(CONFIG_TCP_CONG_COMPOUND) += tcp_compound.o
51 50
52obj-$(CONFIG_XFRM) += xfrm4_policy.o xfrm4_state.o xfrm4_input.o \ 51obj-$(CONFIG_XFRM) += xfrm4_policy.o xfrm4_state.o xfrm4_input.o \
53 xfrm4_output.o 52 xfrm4_output.o
diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c
index 2160874ce7aa..03ff62ebcfeb 100644
--- a/net/ipv4/inetpeer.c
+++ b/net/ipv4/inetpeer.c
@@ -86,7 +86,7 @@ static struct inet_peer *peer_root = peer_avl_empty;
86static DEFINE_RWLOCK(peer_pool_lock); 86static DEFINE_RWLOCK(peer_pool_lock);
87#define PEER_MAXDEPTH 40 /* sufficient for about 2^27 nodes */ 87#define PEER_MAXDEPTH 40 /* sufficient for about 2^27 nodes */
88 88
89static volatile int peer_total; 89static int peer_total;
90/* Exported for sysctl_net_ipv4. */ 90/* Exported for sysctl_net_ipv4. */
91int inet_peer_threshold = 65536 + 128; /* start to throw entries more 91int inet_peer_threshold = 65536 + 128; /* start to throw entries more
92 * aggressively at this stage */ 92 * aggressively at this stage */
diff --git a/net/ipv4/tcp_compound.c b/net/ipv4/tcp_compound.c
deleted file mode 100644
index bc54f7e9aea9..000000000000
--- a/net/ipv4/tcp_compound.c
+++ /dev/null
@@ -1,448 +0,0 @@
1/*
2 * TCP Vegas congestion control
3 *
4 * This is based on the congestion detection/avoidance scheme described in
5 * Lawrence S. Brakmo and Larry L. Peterson.
6 * "TCP Vegas: End to end congestion avoidance on a global internet."
7 * IEEE Journal on Selected Areas in Communication, 13(8):1465--1480,
8 * October 1995. Available from:
9 * ftp://ftp.cs.arizona.edu/xkernel/Papers/jsac.ps
10 *
11 * See http://www.cs.arizona.edu/xkernel/ for their implementation.
12 * The main aspects that distinguish this implementation from the
13 * Arizona Vegas implementation are:
14 * o We do not change the loss detection or recovery mechanisms of
15 * Linux in any way. Linux already recovers from losses quite well,
16 * using fine-grained timers, NewReno, and FACK.
17 * o To avoid the performance penalty imposed by increasing cwnd
18 * only every-other RTT during slow start, we increase during
19 * every RTT during slow start, just like Reno.
20 * o Largely to allow continuous cwnd growth during slow start,
21 * we use the rate at which ACKs come back as the "actual"
22 * rate, rather than the rate at which data is sent.
23 * o To speed convergence to the right rate, we set the cwnd
24 * to achieve the right ("actual") rate when we exit slow start.
25 * o To filter out the noise caused by delayed ACKs, we use the
26 * minimum RTT sample observed during the last RTT to calculate
27 * the actual rate.
28 * o When the sender re-starts from idle, it waits until it has
29 * received ACKs for an entire flight of new data before making
30 * a cwnd adjustment decision. The original Vegas implementation
31 * assumed senders never went idle.
32 *
33 *
34 * TCP Compound based on TCP Vegas
35 *
36 * further details can be found here:
37 * ftp://ftp.research.microsoft.com/pub/tr/TR-2005-86.pdf
38 */
39
40#include <linux/config.h>
41#include <linux/mm.h>
42#include <linux/module.h>
43#include <linux/skbuff.h>
44#include <linux/inet_diag.h>
45
46#include <net/tcp.h>
47
48/* Default values of the Vegas variables, in fixed-point representation
49 * with V_PARAM_SHIFT bits to the right of the binary point.
50 */
51#define V_PARAM_SHIFT 1
52
53#define TCP_COMPOUND_ALPHA 3U
54#define TCP_COMPOUND_BETA 1U
55#define TCP_COMPOUND_GAMMA 30
56#define TCP_COMPOUND_ZETA 1
57
58/* TCP compound variables */
59struct compound {
60 u32 beg_snd_nxt; /* right edge during last RTT */
61 u32 beg_snd_una; /* left edge during last RTT */
62 u32 beg_snd_cwnd; /* saves the size of the cwnd */
63 u8 doing_vegas_now; /* if true, do vegas for this RTT */
64 u16 cntRTT; /* # of RTTs measured within last RTT */
65 u32 minRTT; /* min of RTTs measured within last RTT (in usec) */
66 u32 baseRTT; /* the min of all Vegas RTT measurements seen (in usec) */
67
68 u32 cwnd;
69 u32 dwnd;
70};
71
72/* There are several situations when we must "re-start" Vegas:
73 *
74 * o when a connection is established
75 * o after an RTO
76 * o after fast recovery
77 * o when we send a packet and there is no outstanding
78 * unacknowledged data (restarting an idle connection)
79 *
80 * In these circumstances we cannot do a Vegas calculation at the
81 * end of the first RTT, because any calculation we do is using
82 * stale info -- both the saved cwnd and congestion feedback are
83 * stale.
84 *
85 * Instead we must wait until the completion of an RTT during
86 * which we actually receive ACKs.
87 */
88static inline void vegas_enable(struct sock *sk)
89{
90 const struct tcp_sock *tp = tcp_sk(sk);
91 struct compound *vegas = inet_csk_ca(sk);
92
93 /* Begin taking Vegas samples next time we send something. */
94 vegas->doing_vegas_now = 1;
95
96 /* Set the beginning of the next send window. */
97 vegas->beg_snd_nxt = tp->snd_nxt;
98
99 vegas->cntRTT = 0;
100 vegas->minRTT = 0x7fffffff;
101}
102
103/* Stop taking Vegas samples for now. */
104static inline void vegas_disable(struct sock *sk)
105{
106 struct compound *vegas = inet_csk_ca(sk);
107
108 vegas->doing_vegas_now = 0;
109}
110
111static void tcp_compound_init(struct sock *sk)
112{
113 struct compound *vegas = inet_csk_ca(sk);
114 const struct tcp_sock *tp = tcp_sk(sk);
115
116 vegas->baseRTT = 0x7fffffff;
117 vegas_enable(sk);
118
119 vegas->dwnd = 0;
120 vegas->cwnd = tp->snd_cwnd;
121}
122
123/* Do RTT sampling needed for Vegas.
124 * Basically we:
125 * o min-filter RTT samples from within an RTT to get the current
126 * propagation delay + queuing delay (we are min-filtering to try to
127 * avoid the effects of delayed ACKs)
128 * o min-filter RTT samples from a much longer window (forever for now)
129 * to find the propagation delay (baseRTT)
130 */
131static void tcp_compound_rtt_calc(struct sock *sk, u32 usrtt)
132{
133 struct compound *vegas = inet_csk_ca(sk);
134 u32 vrtt = usrtt + 1; /* Never allow zero rtt or baseRTT */
135
136 /* Filter to find propagation delay: */
137 if (vrtt < vegas->baseRTT)
138 vegas->baseRTT = vrtt;
139
140 /* Find the min RTT during the last RTT to find
141 * the current prop. delay + queuing delay:
142 */
143
144 vegas->minRTT = min(vegas->minRTT, vrtt);
145 vegas->cntRTT++;
146}
147
148static void tcp_compound_state(struct sock *sk, u8 ca_state)
149{
150
151 if (ca_state == TCP_CA_Open)
152 vegas_enable(sk);
153 else
154 vegas_disable(sk);
155}
156
157
158/* 64bit divisor, dividend and result. dynamic precision */
159static inline u64 div64_64(u64 dividend, u64 divisor)
160{
161 u32 d = divisor;
162
163 if (divisor > 0xffffffffULL) {
164 unsigned int shift = fls(divisor >> 32);
165
166 d = divisor >> shift;
167 dividend >>= shift;
168 }
169
170 /* avoid 64 bit division if possible */
171 if (dividend >> 32)
172 do_div(dividend, d);
173 else
174 dividend = (u32) dividend / d;
175
176 return dividend;
177}
178
179/* calculate the quartic root of "a" using Newton-Raphson */
180static u32 qroot(u64 a)
181{
182 u32 x, x1;
183
184 /* Initial estimate is based on:
185 * qrt(x) = exp(log(x) / 4)
186 */
187 x = 1u << (fls64(a) >> 2);
188
189 /*
190 * Iteration based on:
191 * 3
192 * x = ( 3 * x + a / x ) / 4
193 * k+1 k k
194 */
195 do {
196 u64 x3 = x;
197
198 x1 = x;
199 x3 *= x;
200 x3 *= x;
201
202 x = (3 * x + (u32) div64_64(a, x3)) / 4;
203 } while (abs(x1 - x) > 1);
204
205 return x;
206}
207
208
209/*
210 * If the connection is idle and we are restarting,
211 * then we don't want to do any Vegas calculations
212 * until we get fresh RTT samples. So when we
213 * restart, we reset our Vegas state to a clean
214 * slate. After we get acks for this flight of
215 * packets, _then_ we can make Vegas calculations
216 * again.
217 */
218static void tcp_compound_cwnd_event(struct sock *sk, enum tcp_ca_event event)
219{
220 if (event == CA_EVENT_CWND_RESTART || event == CA_EVENT_TX_START)
221 tcp_compound_init(sk);
222}
223
224static void tcp_compound_cong_avoid(struct sock *sk, u32 ack,
225 u32 seq_rtt, u32 in_flight, int flag)
226{
227 struct tcp_sock *tp = tcp_sk(sk);
228 struct compound *vegas = inet_csk_ca(sk);
229 u8 inc = 0;
230
231 if (vegas->cwnd + vegas->dwnd > tp->snd_cwnd) {
232 if (vegas->cwnd > tp->snd_cwnd || vegas->dwnd > tp->snd_cwnd) {
233 vegas->cwnd = tp->snd_cwnd;
234 vegas->dwnd = 0;
235 } else
236 vegas->cwnd = tp->snd_cwnd - vegas->dwnd;
237
238 }
239
240 if (!tcp_is_cwnd_limited(sk, in_flight))
241 return;
242
243 if (vegas->cwnd <= tp->snd_ssthresh)
244 inc = 1;
245 else if (tp->snd_cwnd_cnt < tp->snd_cwnd)
246 tp->snd_cwnd_cnt++;
247
248 if (tp->snd_cwnd_cnt >= tp->snd_cwnd) {
249 inc = 1;
250 tp->snd_cwnd_cnt = 0;
251 }
252
253 if (inc && tp->snd_cwnd < tp->snd_cwnd_clamp)
254 vegas->cwnd++;
255
256 /* The key players are v_beg_snd_una and v_beg_snd_nxt.
257 *
258 * These are so named because they represent the approximate values
259 * of snd_una and snd_nxt at the beginning of the current RTT. More
260 * precisely, they represent the amount of data sent during the RTT.
261 * At the end of the RTT, when we receive an ACK for v_beg_snd_nxt,
262 * we will calculate that (v_beg_snd_nxt - v_beg_snd_una) outstanding
263 * bytes of data have been ACKed during the course of the RTT, giving
264 * an "actual" rate of:
265 *
266 * (v_beg_snd_nxt - v_beg_snd_una) / (rtt duration)
267 *
268 * Unfortunately, v_beg_snd_una is not exactly equal to snd_una,
269 * because delayed ACKs can cover more than one segment, so they
270 * don't line up nicely with the boundaries of RTTs.
271 *
272 * Another unfortunate fact of life is that delayed ACKs delay the
273 * advance of the left edge of our send window, so that the number
274 * of bytes we send in an RTT is often less than our cwnd will allow.
275 * So we keep track of our cwnd separately, in v_beg_snd_cwnd.
276 */
277
278 if (after(ack, vegas->beg_snd_nxt)) {
279 /* Do the Vegas once-per-RTT cwnd adjustment. */
280 u32 old_wnd, old_snd_cwnd;
281
282 /* Here old_wnd is essentially the window of data that was
283 * sent during the previous RTT, and has all
284 * been acknowledged in the course of the RTT that ended
285 * with the ACK we just received. Likewise, old_snd_cwnd
286 * is the cwnd during the previous RTT.
287 */
288 if (!tp->mss_cache)
289 return;
290
291 old_wnd = (vegas->beg_snd_nxt - vegas->beg_snd_una) /
292 tp->mss_cache;
293 old_snd_cwnd = vegas->beg_snd_cwnd;
294
295 /* Save the extent of the current window so we can use this
296 * at the end of the next RTT.
297 */
298 vegas->beg_snd_una = vegas->beg_snd_nxt;
299 vegas->beg_snd_nxt = tp->snd_nxt;
300 vegas->beg_snd_cwnd = tp->snd_cwnd;
301
302 /* We do the Vegas calculations only if we got enough RTT
303 * samples that we can be reasonably sure that we got
304 * at least one RTT sample that wasn't from a delayed ACK.
305 * If we only had 2 samples total,
306 * then that means we're getting only 1 ACK per RTT, which
307 * means they're almost certainly delayed ACKs.
308 * If we have 3 samples, we should be OK.
309 */
310
311 if (vegas->cntRTT > 2) {
312 u32 rtt, target_cwnd, diff;
313 u32 brtt, dwnd;
314
315 /* We have enough RTT samples, so, using the Vegas
316 * algorithm, we determine if we should increase or
317 * decrease cwnd, and by how much.
318 */
319
320 /* Pluck out the RTT we are using for the Vegas
321 * calculations. This is the min RTT seen during the
322 * last RTT. Taking the min filters out the effects
323 * of delayed ACKs, at the cost of noticing congestion
324 * a bit later.
325 */
326 rtt = vegas->minRTT;
327
328 /* Calculate the cwnd we should have, if we weren't
329 * going too fast.
330 *
331 * This is:
332 * (actual rate in segments) * baseRTT
333 * We keep it as a fixed point number with
334 * V_PARAM_SHIFT bits to the right of the binary point.
335 */
336 if (!rtt)
337 return;
338
339 brtt = vegas->baseRTT;
340 target_cwnd = ((old_wnd * brtt)
341 << V_PARAM_SHIFT) / rtt;
342
343 /* Calculate the difference between the window we had,
344 * and the window we would like to have. This quantity
345 * is the "Diff" from the Arizona Vegas papers.
346 *
347 * Again, this is a fixed point number with
348 * V_PARAM_SHIFT bits to the right of the binary
349 * point.
350 */
351
352 diff = (old_wnd << V_PARAM_SHIFT) - target_cwnd;
353
354 dwnd = vegas->dwnd;
355
356 if (diff < (TCP_COMPOUND_GAMMA << V_PARAM_SHIFT)) {
357 u64 v;
358 u32 x;
359
360 /*
361 * The TCP Compound paper describes the choice
362 * of "k" determines the agressiveness,
363 * ie. slope of the response function.
364 *
365 * For same value as HSTCP would be 0.8
366 * but for computaional reasons, both the
367 * original authors and this implementation
368 * use 0.75.
369 */
370 v = old_wnd;
371 x = qroot(v * v * v) >> TCP_COMPOUND_ALPHA;
372 if (x > 1)
373 dwnd = x - 1;
374 else
375 dwnd = 0;
376
377 dwnd += vegas->dwnd;
378
379 } else if ((dwnd << V_PARAM_SHIFT) <
380 (diff * TCP_COMPOUND_BETA))
381 dwnd = 0;
382 else
383 dwnd =
384 ((dwnd << V_PARAM_SHIFT) -
385 (diff *
386 TCP_COMPOUND_BETA)) >> V_PARAM_SHIFT;
387
388 vegas->dwnd = dwnd;
389
390 }
391
392 /* Wipe the slate clean for the next RTT. */
393 vegas->cntRTT = 0;
394 vegas->minRTT = 0x7fffffff;
395 }
396
397 tp->snd_cwnd = vegas->cwnd + vegas->dwnd;
398}
399
400/* Extract info for Tcp socket info provided via netlink. */
401static void tcp_compound_get_info(struct sock *sk, u32 ext, struct sk_buff *skb)
402{
403 const struct compound *ca = inet_csk_ca(sk);
404 if (ext & (1 << (INET_DIAG_VEGASINFO - 1))) {
405 struct tcpvegas_info *info;
406
407 info = RTA_DATA(__RTA_PUT(skb, INET_DIAG_VEGASINFO,
408 sizeof(*info)));
409
410 info->tcpv_enabled = ca->doing_vegas_now;
411 info->tcpv_rttcnt = ca->cntRTT;
412 info->tcpv_rtt = ca->baseRTT;
413 info->tcpv_minrtt = ca->minRTT;
414 rtattr_failure:;
415 }
416}
417
418static struct tcp_congestion_ops tcp_compound = {
419 .init = tcp_compound_init,
420 .ssthresh = tcp_reno_ssthresh,
421 .cong_avoid = tcp_compound_cong_avoid,
422 .rtt_sample = tcp_compound_rtt_calc,
423 .set_state = tcp_compound_state,
424 .cwnd_event = tcp_compound_cwnd_event,
425 .get_info = tcp_compound_get_info,
426
427 .owner = THIS_MODULE,
428 .name = "compound",
429};
430
431static int __init tcp_compound_register(void)
432{
433 BUG_ON(sizeof(struct compound) > ICSK_CA_PRIV_SIZE);
434 tcp_register_congestion_control(&tcp_compound);
435 return 0;
436}
437
438static void __exit tcp_compound_unregister(void)
439{
440 tcp_unregister_congestion_control(&tcp_compound);
441}
442
443module_init(tcp_compound_register);
444module_exit(tcp_compound_unregister);
445
446MODULE_AUTHOR("Angelo P. Castellani, Stephen Hemminger");
447MODULE_LICENSE("GPL");
448MODULE_DESCRIPTION("TCP Compound");
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index 24caaeec8894..2e8b4dfcbc74 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -246,6 +246,7 @@ static int superblock_alloc_security(struct super_block *sb)
246 sbsec->sb = sb; 246 sbsec->sb = sb;
247 sbsec->sid = SECINITSID_UNLABELED; 247 sbsec->sid = SECINITSID_UNLABELED;
248 sbsec->def_sid = SECINITSID_FILE; 248 sbsec->def_sid = SECINITSID_FILE;
249 sbsec->mntpoint_sid = SECINITSID_UNLABELED;
249 sb->s_security = sbsec; 250 sb->s_security = sbsec;
250 251
251 return 0; 252 return 0;
@@ -319,19 +320,53 @@ enum {
319 Opt_context = 1, 320 Opt_context = 1,
320 Opt_fscontext = 2, 321 Opt_fscontext = 2,
321 Opt_defcontext = 4, 322 Opt_defcontext = 4,
323 Opt_rootcontext = 8,
322}; 324};
323 325
324static match_table_t tokens = { 326static match_table_t tokens = {
325 {Opt_context, "context=%s"}, 327 {Opt_context, "context=%s"},
326 {Opt_fscontext, "fscontext=%s"}, 328 {Opt_fscontext, "fscontext=%s"},
327 {Opt_defcontext, "defcontext=%s"}, 329 {Opt_defcontext, "defcontext=%s"},
330 {Opt_rootcontext, "rootcontext=%s"},
328}; 331};
329 332
330#define SEL_MOUNT_FAIL_MSG "SELinux: duplicate or incompatible mount options\n" 333#define SEL_MOUNT_FAIL_MSG "SELinux: duplicate or incompatible mount options\n"
331 334
335static int may_context_mount_sb_relabel(u32 sid,
336 struct superblock_security_struct *sbsec,
337 struct task_security_struct *tsec)
338{
339 int rc;
340
341 rc = avc_has_perm(tsec->sid, sbsec->sid, SECCLASS_FILESYSTEM,
342 FILESYSTEM__RELABELFROM, NULL);
343 if (rc)
344 return rc;
345
346 rc = avc_has_perm(tsec->sid, sid, SECCLASS_FILESYSTEM,
347 FILESYSTEM__RELABELTO, NULL);
348 return rc;
349}
350
351static int may_context_mount_inode_relabel(u32 sid,
352 struct superblock_security_struct *sbsec,
353 struct task_security_struct *tsec)
354{
355 int rc;
356 rc = avc_has_perm(tsec->sid, sbsec->sid, SECCLASS_FILESYSTEM,
357 FILESYSTEM__RELABELFROM, NULL);
358 if (rc)
359 return rc;
360
361 rc = avc_has_perm(sid, sbsec->sid, SECCLASS_FILESYSTEM,
362 FILESYSTEM__ASSOCIATE, NULL);
363 return rc;
364}
365
332static int try_context_mount(struct super_block *sb, void *data) 366static int try_context_mount(struct super_block *sb, void *data)
333{ 367{
334 char *context = NULL, *defcontext = NULL; 368 char *context = NULL, *defcontext = NULL;
369 char *fscontext = NULL, *rootcontext = NULL;
335 const char *name; 370 const char *name;
336 u32 sid; 371 u32 sid;
337 int alloc = 0, rc = 0, seen = 0; 372 int alloc = 0, rc = 0, seen = 0;
@@ -374,7 +409,7 @@ static int try_context_mount(struct super_block *sb, void *data)
374 409
375 switch (token) { 410 switch (token) {
376 case Opt_context: 411 case Opt_context:
377 if (seen) { 412 if (seen & (Opt_context|Opt_defcontext)) {
378 rc = -EINVAL; 413 rc = -EINVAL;
379 printk(KERN_WARNING SEL_MOUNT_FAIL_MSG); 414 printk(KERN_WARNING SEL_MOUNT_FAIL_MSG);
380 goto out_free; 415 goto out_free;
@@ -390,13 +425,13 @@ static int try_context_mount(struct super_block *sb, void *data)
390 break; 425 break;
391 426
392 case Opt_fscontext: 427 case Opt_fscontext:
393 if (seen & (Opt_context|Opt_fscontext)) { 428 if (seen & Opt_fscontext) {
394 rc = -EINVAL; 429 rc = -EINVAL;
395 printk(KERN_WARNING SEL_MOUNT_FAIL_MSG); 430 printk(KERN_WARNING SEL_MOUNT_FAIL_MSG);
396 goto out_free; 431 goto out_free;
397 } 432 }
398 context = match_strdup(&args[0]); 433 fscontext = match_strdup(&args[0]);
399 if (!context) { 434 if (!fscontext) {
400 rc = -ENOMEM; 435 rc = -ENOMEM;
401 goto out_free; 436 goto out_free;
402 } 437 }
@@ -405,6 +440,22 @@ static int try_context_mount(struct super_block *sb, void *data)
405 seen |= Opt_fscontext; 440 seen |= Opt_fscontext;
406 break; 441 break;
407 442
443 case Opt_rootcontext:
444 if (seen & Opt_rootcontext) {
445 rc = -EINVAL;
446 printk(KERN_WARNING SEL_MOUNT_FAIL_MSG);
447 goto out_free;
448 }
449 rootcontext = match_strdup(&args[0]);
450 if (!rootcontext) {
451 rc = -ENOMEM;
452 goto out_free;
453 }
454 if (!alloc)
455 alloc = 1;
456 seen |= Opt_rootcontext;
457 break;
458
408 case Opt_defcontext: 459 case Opt_defcontext:
409 if (sbsec->behavior != SECURITY_FS_USE_XATTR) { 460 if (sbsec->behavior != SECURITY_FS_USE_XATTR) {
410 rc = -EINVAL; 461 rc = -EINVAL;
@@ -441,6 +492,28 @@ static int try_context_mount(struct super_block *sb, void *data)
441 if (!seen) 492 if (!seen)
442 goto out; 493 goto out;
443 494
495 /* sets the context of the superblock for the fs being mounted. */
496 if (fscontext) {
497 rc = security_context_to_sid(fscontext, strlen(fscontext), &sid);
498 if (rc) {
499 printk(KERN_WARNING "SELinux: security_context_to_sid"
500 "(%s) failed for (dev %s, type %s) errno=%d\n",
501 fscontext, sb->s_id, name, rc);
502 goto out_free;
503 }
504
505 rc = may_context_mount_sb_relabel(sid, sbsec, tsec);
506 if (rc)
507 goto out_free;
508
509 sbsec->sid = sid;
510 }
511
512 /*
513 * Switch to using mount point labeling behavior.
514 * sets the label used on all file below the mountpoint, and will set
515 * the superblock context if not already set.
516 */
444 if (context) { 517 if (context) {
445 rc = security_context_to_sid(context, strlen(context), &sid); 518 rc = security_context_to_sid(context, strlen(context), &sid);
446 if (rc) { 519 if (rc) {
@@ -450,20 +523,34 @@ static int try_context_mount(struct super_block *sb, void *data)
450 goto out_free; 523 goto out_free;
451 } 524 }
452 525
453 rc = avc_has_perm(tsec->sid, sbsec->sid, SECCLASS_FILESYSTEM, 526 rc = may_context_mount_sb_relabel(sid, sbsec, tsec);
454 FILESYSTEM__RELABELFROM, NULL);
455 if (rc) 527 if (rc)
456 goto out_free; 528 goto out_free;
457 529
458 rc = avc_has_perm(tsec->sid, sid, SECCLASS_FILESYSTEM, 530 if (!fscontext)
459 FILESYSTEM__RELABELTO, NULL); 531 sbsec->sid = sid;
460 if (rc) 532 sbsec->mntpoint_sid = sid;
533
534 sbsec->behavior = SECURITY_FS_USE_MNTPOINT;
535 }
536
537 if (rootcontext) {
538 struct inode *inode = sb->s_root->d_inode;
539 struct inode_security_struct *isec = inode->i_security;
540 rc = security_context_to_sid(rootcontext, strlen(rootcontext), &sid);
541 if (rc) {
542 printk(KERN_WARNING "SELinux: security_context_to_sid"
543 "(%s) failed for (dev %s, type %s) errno=%d\n",
544 rootcontext, sb->s_id, name, rc);
461 goto out_free; 545 goto out_free;
546 }
462 547
463 sbsec->sid = sid; 548 rc = may_context_mount_inode_relabel(sid, sbsec, tsec);
549 if (rc)
550 goto out_free;
464 551
465 if (seen & Opt_context) 552 isec->sid = sid;
466 sbsec->behavior = SECURITY_FS_USE_MNTPOINT; 553 isec->initialized = 1;
467 } 554 }
468 555
469 if (defcontext) { 556 if (defcontext) {
@@ -478,13 +565,7 @@ static int try_context_mount(struct super_block *sb, void *data)
478 if (sid == sbsec->def_sid) 565 if (sid == sbsec->def_sid)
479 goto out_free; 566 goto out_free;
480 567
481 rc = avc_has_perm(tsec->sid, sbsec->sid, SECCLASS_FILESYSTEM, 568 rc = may_context_mount_inode_relabel(sid, sbsec, tsec);
482 FILESYSTEM__RELABELFROM, NULL);
483 if (rc)
484 goto out_free;
485
486 rc = avc_has_perm(sid, sbsec->sid, SECCLASS_FILESYSTEM,
487 FILESYSTEM__ASSOCIATE, NULL);
488 if (rc) 569 if (rc)
489 goto out_free; 570 goto out_free;
490 571
@@ -495,6 +576,8 @@ out_free:
495 if (alloc) { 576 if (alloc) {
496 kfree(context); 577 kfree(context);
497 kfree(defcontext); 578 kfree(defcontext);
579 kfree(fscontext);
580 kfree(rootcontext);
498 } 581 }
499out: 582out:
500 return rc; 583 return rc;
@@ -876,8 +959,11 @@ static int inode_doinit_with_dentry(struct inode *inode, struct dentry *opt_dent
876 goto out; 959 goto out;
877 isec->sid = sid; 960 isec->sid = sid;
878 break; 961 break;
962 case SECURITY_FS_USE_MNTPOINT:
963 isec->sid = sbsec->mntpoint_sid;
964 break;
879 default: 965 default:
880 /* Default to the fs SID. */ 966 /* Default to the fs superblock SID. */
881 isec->sid = sbsec->sid; 967 isec->sid = sbsec->sid;
882 968
883 if (sbsec->proc) { 969 if (sbsec->proc) {
@@ -1843,7 +1929,8 @@ static inline int selinux_option(char *option, int len)
1843{ 1929{
1844 return (match_prefix("context=", sizeof("context=")-1, option, len) || 1930 return (match_prefix("context=", sizeof("context=")-1, option, len) ||
1845 match_prefix("fscontext=", sizeof("fscontext=")-1, option, len) || 1931 match_prefix("fscontext=", sizeof("fscontext=")-1, option, len) ||
1846 match_prefix("defcontext=", sizeof("defcontext=")-1, option, len)); 1932 match_prefix("defcontext=", sizeof("defcontext=")-1, option, len) ||
1933 match_prefix("rootcontext=", sizeof("rootcontext=")-1, option, len));
1847} 1934}
1848 1935
1849static inline void take_option(char **to, char *from, int *first, int len) 1936static inline void take_option(char **to, char *from, int *first, int len)
diff --git a/security/selinux/include/objsec.h b/security/selinux/include/objsec.h
index cf54a304169a..940178865fc7 100644
--- a/security/selinux/include/objsec.h
+++ b/security/selinux/include/objsec.h
@@ -57,8 +57,9 @@ struct file_security_struct {
57struct superblock_security_struct { 57struct superblock_security_struct {
58 struct super_block *sb; /* back pointer to sb object */ 58 struct super_block *sb; /* back pointer to sb object */
59 struct list_head list; /* list of superblock_security_struct */ 59 struct list_head list; /* list of superblock_security_struct */
60 u32 sid; /* SID of file system */ 60 u32 sid; /* SID of file system superblock */
61 u32 def_sid; /* default SID for labeling */ 61 u32 def_sid; /* default SID for labeling */
62 u32 mntpoint_sid; /* SECURITY_FS_USE_MNTPOINT context for files */
62 unsigned int behavior; /* labeling behavior */ 63 unsigned int behavior; /* labeling behavior */
63 unsigned char initialized; /* initialization flag */ 64 unsigned char initialized; /* initialization flag */
64 unsigned char proc; /* proc fs */ 65 unsigned char proc; /* proc fs */
diff --git a/sound/aoa/Makefile b/sound/aoa/Makefile
index d8de3e7df48d..a8c037f908f8 100644
--- a/sound/aoa/Makefile
+++ b/sound/aoa/Makefile
@@ -1,4 +1,4 @@
1obj-$(CONFIG_SND_AOA) += core/ 1obj-$(CONFIG_SND_AOA) += core/
2obj-$(CONFIG_SND_AOA) += codecs/
3obj-$(CONFIG_SND_AOA) += fabrics/
4obj-$(CONFIG_SND_AOA_SOUNDBUS) += soundbus/ 2obj-$(CONFIG_SND_AOA_SOUNDBUS) += soundbus/
3obj-$(CONFIG_SND_AOA) += fabrics/
4obj-$(CONFIG_SND_AOA) += codecs/
diff --git a/sound/aoa/codecs/snd-aoa-codec-tas-basstreble.h b/sound/aoa/codecs/snd-aoa-codec-tas-basstreble.h
new file mode 100644
index 000000000000..69b61136fd54
--- /dev/null
+++ b/sound/aoa/codecs/snd-aoa-codec-tas-basstreble.h
@@ -0,0 +1,134 @@
1/*
2 * This file is only included exactly once!
3 *
4 * The tables here are derived from the tas3004 datasheet,
5 * modulo typo corrections and some smoothing...
6 */
7
8#define TAS3004_TREBLE_MIN 0
9#define TAS3004_TREBLE_MAX 72
10#define TAS3004_BASS_MIN 0
11#define TAS3004_BASS_MAX 72
12#define TAS3004_TREBLE_ZERO 36
13#define TAS3004_BASS_ZERO 36
14
15static u8 tas3004_treble_table[] = {
16 150, /* -18 dB */
17 149,
18 148,
19 147,
20 146,
21 145,
22 144,
23 143,
24 142,
25 141,
26 140,
27 139,
28 138,
29 137,
30 136,
31 135,
32 134,
33 133,
34 132,
35 131,
36 130,
37 129,
38 128,
39 127,
40 126,
41 125,
42 124,
43 123,
44 122,
45 121,
46 120,
47 119,
48 118,
49 117,
50 116,
51 115,
52 114, /* 0 dB */
53 113,
54 112,
55 111,
56 109,
57 108,
58 107,
59 105,
60 104,
61 103,
62 101,
63 99,
64 98,
65 96,
66 93,
67 91,
68 89,
69 86,
70 83,
71 81,
72 77,
73 74,
74 71,
75 67,
76 63,
77 59,
78 54,
79 49,
80 44,
81 38,
82 32,
83 26,
84 19,
85 10,
86 4,
87 2,
88 1, /* +18 dB */
89};
90
91static inline u8 tas3004_treble(int idx)
92{
93 return tas3004_treble_table[idx];
94}
95
96/* I only save the difference here to the treble table
97 * so that the binary is smaller...
98 * I have also ignored completely differences of
99 * +/- 1
100 */
101static s8 tas3004_bass_diff_to_treble[] = {
102 2, /* 7 dB, offset 50 */
103 2,
104 2,
105 2,
106 2,
107 1,
108 2,
109 2,
110 2,
111 3,
112 4,
113 4,
114 5,
115 6,
116 7,
117 8,
118 9,
119 10,
120 11,
121 14,
122 13,
123 8,
124 1, /* 18 dB */
125};
126
127static inline u8 tas3004_bass(int idx)
128{
129 u8 result = tas3004_treble_table[idx];
130
131 if (idx >= 50)
132 result += tas3004_bass_diff_to_treble[idx-50];
133 return result;
134}
diff --git a/sound/aoa/codecs/snd-aoa-codec-tas.c b/sound/aoa/codecs/snd-aoa-codec-tas.c
index 2e39ff6ee349..16c0b6b0a805 100644
--- a/sound/aoa/codecs/snd-aoa-codec-tas.c
+++ b/sound/aoa/codecs/snd-aoa-codec-tas.c
@@ -72,22 +72,29 @@ MODULE_DESCRIPTION("tas codec driver for snd-aoa");
72 72
73#include "snd-aoa-codec-tas.h" 73#include "snd-aoa-codec-tas.h"
74#include "snd-aoa-codec-tas-gain-table.h" 74#include "snd-aoa-codec-tas-gain-table.h"
75#include "snd-aoa-codec-tas-basstreble.h"
75#include "../aoa.h" 76#include "../aoa.h"
76#include "../soundbus/soundbus.h" 77#include "../soundbus/soundbus.h"
77 78
78
79#define PFX "snd-aoa-codec-tas: " 79#define PFX "snd-aoa-codec-tas: "
80 80
81
81struct tas { 82struct tas {
82 struct aoa_codec codec; 83 struct aoa_codec codec;
83 struct i2c_client i2c; 84 struct i2c_client i2c;
84 u32 muted_l:1, muted_r:1, 85 u32 mute_l:1, mute_r:1 ,
85 controls_created:1; 86 controls_created:1 ,
87 drc_enabled:1,
88 hw_enabled:1;
86 u8 cached_volume_l, cached_volume_r; 89 u8 cached_volume_l, cached_volume_r;
87 u8 mixer_l[3], mixer_r[3]; 90 u8 mixer_l[3], mixer_r[3];
91 u8 bass, treble;
88 u8 acr; 92 u8 acr;
93 int drc_range;
89}; 94};
90 95
96static int tas_reset_init(struct tas *tas);
97
91static struct tas *codec_to_tas(struct aoa_codec *codec) 98static struct tas *codec_to_tas(struct aoa_codec *codec)
92{ 99{
93 return container_of(codec, struct tas, codec); 100 return container_of(codec, struct tas, codec);
@@ -101,6 +108,44 @@ static inline int tas_write_reg(struct tas *tas, u8 reg, u8 len, u8 *data)
101 return i2c_smbus_write_i2c_block_data(&tas->i2c, reg, len, data); 108 return i2c_smbus_write_i2c_block_data(&tas->i2c, reg, len, data);
102} 109}
103 110
111static void tas3004_set_drc(struct tas *tas)
112{
113 unsigned char val[6];
114
115 if (tas->drc_enabled)
116 val[0] = 0x50; /* 3:1 above threshold */
117 else
118 val[0] = 0x51; /* disabled */
119 val[1] = 0x02; /* 1:1 below threshold */
120 if (tas->drc_range > 0xef)
121 val[2] = 0xef;
122 else if (tas->drc_range < 0)
123 val[2] = 0x00;
124 else
125 val[2] = tas->drc_range;
126 val[3] = 0xb0;
127 val[4] = 0x60;
128 val[5] = 0xa0;
129
130 tas_write_reg(tas, TAS_REG_DRC, 6, val);
131}
132
133static void tas_set_treble(struct tas *tas)
134{
135 u8 tmp;
136
137 tmp = tas3004_treble(tas->treble);
138 tas_write_reg(tas, TAS_REG_TREBLE, 1, &tmp);
139}
140
141static void tas_set_bass(struct tas *tas)
142{
143 u8 tmp;
144
145 tmp = tas3004_bass(tas->bass);
146 tas_write_reg(tas, TAS_REG_BASS, 1, &tmp);
147}
148
104static void tas_set_volume(struct tas *tas) 149static void tas_set_volume(struct tas *tas)
105{ 150{
106 u8 block[6]; 151 u8 block[6];
@@ -113,8 +158,8 @@ static void tas_set_volume(struct tas *tas)
113 if (left > 177) left = 177; 158 if (left > 177) left = 177;
114 if (right > 177) right = 177; 159 if (right > 177) right = 177;
115 160
116 if (tas->muted_l) left = 0; 161 if (tas->mute_l) left = 0;
117 if (tas->muted_r) right = 0; 162 if (tas->mute_r) right = 0;
118 163
119 /* analysing the volume and mixer tables shows 164 /* analysing the volume and mixer tables shows
120 * that they are similar enough when we shift 165 * that they are similar enough when we shift
@@ -202,7 +247,8 @@ static int tas_snd_vol_put(struct snd_kcontrol *kcontrol,
202 247
203 tas->cached_volume_l = ucontrol->value.integer.value[0]; 248 tas->cached_volume_l = ucontrol->value.integer.value[0];
204 tas->cached_volume_r = ucontrol->value.integer.value[1]; 249 tas->cached_volume_r = ucontrol->value.integer.value[1];
205 tas_set_volume(tas); 250 if (tas->hw_enabled)
251 tas_set_volume(tas);
206 return 1; 252 return 1;
207} 253}
208 254
@@ -230,8 +276,8 @@ static int tas_snd_mute_get(struct snd_kcontrol *kcontrol,
230{ 276{
231 struct tas *tas = snd_kcontrol_chip(kcontrol); 277 struct tas *tas = snd_kcontrol_chip(kcontrol);
232 278
233 ucontrol->value.integer.value[0] = !tas->muted_l; 279 ucontrol->value.integer.value[0] = !tas->mute_l;
234 ucontrol->value.integer.value[1] = !tas->muted_r; 280 ucontrol->value.integer.value[1] = !tas->mute_r;
235 return 0; 281 return 0;
236} 282}
237 283
@@ -240,13 +286,14 @@ static int tas_snd_mute_put(struct snd_kcontrol *kcontrol,
240{ 286{
241 struct tas *tas = snd_kcontrol_chip(kcontrol); 287 struct tas *tas = snd_kcontrol_chip(kcontrol);
242 288
243 if (tas->muted_l == !ucontrol->value.integer.value[0] 289 if (tas->mute_l == !ucontrol->value.integer.value[0]
244 && tas->muted_r == !ucontrol->value.integer.value[1]) 290 && tas->mute_r == !ucontrol->value.integer.value[1])
245 return 0; 291 return 0;
246 292
247 tas->muted_l = !ucontrol->value.integer.value[0]; 293 tas->mute_l = !ucontrol->value.integer.value[0];
248 tas->muted_r = !ucontrol->value.integer.value[1]; 294 tas->mute_r = !ucontrol->value.integer.value[1];
249 tas_set_volume(tas); 295 if (tas->hw_enabled)
296 tas_set_volume(tas);
250 return 1; 297 return 1;
251} 298}
252 299
@@ -294,7 +341,8 @@ static int tas_snd_mixer_put(struct snd_kcontrol *kcontrol,
294 tas->mixer_l[idx] = ucontrol->value.integer.value[0]; 341 tas->mixer_l[idx] = ucontrol->value.integer.value[0];
295 tas->mixer_r[idx] = ucontrol->value.integer.value[1]; 342 tas->mixer_r[idx] = ucontrol->value.integer.value[1];
296 343
297 tas_set_mixer(tas); 344 if (tas->hw_enabled)
345 tas_set_mixer(tas);
298 return 1; 346 return 1;
299} 347}
300 348
@@ -309,9 +357,93 @@ static struct snd_kcontrol_new n##_control = { \
309 .private_value = idx, \ 357 .private_value = idx, \
310} 358}
311 359
312MIXER_CONTROL(pcm1, "PCM1", 0); 360MIXER_CONTROL(pcm1, "PCM", 0);
313MIXER_CONTROL(monitor, "Monitor", 2); 361MIXER_CONTROL(monitor, "Monitor", 2);
314 362
363static int tas_snd_drc_range_info(struct snd_kcontrol *kcontrol,
364 struct snd_ctl_elem_info *uinfo)
365{
366 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
367 uinfo->count = 1;
368 uinfo->value.integer.min = 0;
369 uinfo->value.integer.max = TAS3004_DRC_MAX;
370 return 0;
371}
372
373static int tas_snd_drc_range_get(struct snd_kcontrol *kcontrol,
374 struct snd_ctl_elem_value *ucontrol)
375{
376 struct tas *tas = snd_kcontrol_chip(kcontrol);
377
378 ucontrol->value.integer.value[0] = tas->drc_range;
379 return 0;
380}
381
382static int tas_snd_drc_range_put(struct snd_kcontrol *kcontrol,
383 struct snd_ctl_elem_value *ucontrol)
384{
385 struct tas *tas = snd_kcontrol_chip(kcontrol);
386
387 if (tas->drc_range == ucontrol->value.integer.value[0])
388 return 0;
389
390 tas->drc_range = ucontrol->value.integer.value[0];
391 if (tas->hw_enabled)
392 tas3004_set_drc(tas);
393 return 1;
394}
395
396static struct snd_kcontrol_new drc_range_control = {
397 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
398 .name = "DRC Range",
399 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
400 .info = tas_snd_drc_range_info,
401 .get = tas_snd_drc_range_get,
402 .put = tas_snd_drc_range_put,
403};
404
405static int tas_snd_drc_switch_info(struct snd_kcontrol *kcontrol,
406 struct snd_ctl_elem_info *uinfo)
407{
408 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
409 uinfo->count = 1;
410 uinfo->value.integer.min = 0;
411 uinfo->value.integer.max = 1;
412 return 0;
413}
414
415static int tas_snd_drc_switch_get(struct snd_kcontrol *kcontrol,
416 struct snd_ctl_elem_value *ucontrol)
417{
418 struct tas *tas = snd_kcontrol_chip(kcontrol);
419
420 ucontrol->value.integer.value[0] = tas->drc_enabled;
421 return 0;
422}
423
424static int tas_snd_drc_switch_put(struct snd_kcontrol *kcontrol,
425 struct snd_ctl_elem_value *ucontrol)
426{
427 struct tas *tas = snd_kcontrol_chip(kcontrol);
428
429 if (tas->drc_enabled == ucontrol->value.integer.value[0])
430 return 0;
431
432 tas->drc_enabled = ucontrol->value.integer.value[0];
433 if (tas->hw_enabled)
434 tas3004_set_drc(tas);
435 return 1;
436}
437
438static struct snd_kcontrol_new drc_switch_control = {
439 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
440 .name = "DRC Range Switch",
441 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
442 .info = tas_snd_drc_switch_info,
443 .get = tas_snd_drc_switch_get,
444 .put = tas_snd_drc_switch_put,
445};
446
315static int tas_snd_capture_source_info(struct snd_kcontrol *kcontrol, 447static int tas_snd_capture_source_info(struct snd_kcontrol *kcontrol,
316 struct snd_ctl_elem_info *uinfo) 448 struct snd_ctl_elem_info *uinfo)
317{ 449{
@@ -346,7 +478,8 @@ static int tas_snd_capture_source_put(struct snd_kcontrol *kcontrol,
346 tas->acr |= TAS_ACR_INPUT_B; 478 tas->acr |= TAS_ACR_INPUT_B;
347 if (oldacr == tas->acr) 479 if (oldacr == tas->acr)
348 return 0; 480 return 0;
349 tas_write_reg(tas, TAS_REG_ACR, 1, &tas->acr); 481 if (tas->hw_enabled)
482 tas_write_reg(tas, TAS_REG_ACR, 1, &tas->acr);
350 return 1; 483 return 1;
351} 484}
352 485
@@ -370,6 +503,89 @@ static struct snd_kcontrol_new capture_source_control = {
370 .put = tas_snd_capture_source_put, 503 .put = tas_snd_capture_source_put,
371}; 504};
372 505
506static int tas_snd_treble_info(struct snd_kcontrol *kcontrol,
507 struct snd_ctl_elem_info *uinfo)
508{
509 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
510 uinfo->count = 1;
511 uinfo->value.integer.min = TAS3004_TREBLE_MIN;
512 uinfo->value.integer.max = TAS3004_TREBLE_MAX;
513 return 0;
514}
515
516static int tas_snd_treble_get(struct snd_kcontrol *kcontrol,
517 struct snd_ctl_elem_value *ucontrol)
518{
519 struct tas *tas = snd_kcontrol_chip(kcontrol);
520
521 ucontrol->value.integer.value[0] = tas->treble;
522 return 0;
523}
524
525static int tas_snd_treble_put(struct snd_kcontrol *kcontrol,
526 struct snd_ctl_elem_value *ucontrol)
527{
528 struct tas *tas = snd_kcontrol_chip(kcontrol);
529
530 if (tas->treble == ucontrol->value.integer.value[0])
531 return 0;
532
533 tas->treble = ucontrol->value.integer.value[0];
534 if (tas->hw_enabled)
535 tas_set_treble(tas);
536 return 1;
537}
538
539static struct snd_kcontrol_new treble_control = {
540 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
541 .name = "Treble",
542 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
543 .info = tas_snd_treble_info,
544 .get = tas_snd_treble_get,
545 .put = tas_snd_treble_put,
546};
547
548static int tas_snd_bass_info(struct snd_kcontrol *kcontrol,
549 struct snd_ctl_elem_info *uinfo)
550{
551 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
552 uinfo->count = 1;
553 uinfo->value.integer.min = TAS3004_BASS_MIN;
554 uinfo->value.integer.max = TAS3004_BASS_MAX;
555 return 0;
556}
557
558static int tas_snd_bass_get(struct snd_kcontrol *kcontrol,
559 struct snd_ctl_elem_value *ucontrol)
560{
561 struct tas *tas = snd_kcontrol_chip(kcontrol);
562
563 ucontrol->value.integer.value[0] = tas->bass;
564 return 0;
565}
566
567static int tas_snd_bass_put(struct snd_kcontrol *kcontrol,
568 struct snd_ctl_elem_value *ucontrol)
569{
570 struct tas *tas = snd_kcontrol_chip(kcontrol);
571
572 if (tas->bass == ucontrol->value.integer.value[0])
573 return 0;
574
575 tas->bass = ucontrol->value.integer.value[0];
576 if (tas->hw_enabled)
577 tas_set_bass(tas);
578 return 1;
579}
580
581static struct snd_kcontrol_new bass_control = {
582 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
583 .name = "Bass",
584 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
585 .info = tas_snd_bass_info,
586 .get = tas_snd_bass_get,
587 .put = tas_snd_bass_put,
588};
373 589
374static struct transfer_info tas_transfers[] = { 590static struct transfer_info tas_transfers[] = {
375 { 591 {
@@ -399,26 +615,67 @@ static int tas_usable(struct codec_info_item *cii,
399static int tas_reset_init(struct tas *tas) 615static int tas_reset_init(struct tas *tas)
400{ 616{
401 u8 tmp; 617 u8 tmp;
618
619 tas->codec.gpio->methods->all_amps_off(tas->codec.gpio);
620 msleep(5);
402 tas->codec.gpio->methods->set_hw_reset(tas->codec.gpio, 0); 621 tas->codec.gpio->methods->set_hw_reset(tas->codec.gpio, 0);
403 msleep(1); 622 msleep(5);
404 tas->codec.gpio->methods->set_hw_reset(tas->codec.gpio, 1); 623 tas->codec.gpio->methods->set_hw_reset(tas->codec.gpio, 1);
405 msleep(1); 624 msleep(20);
406 tas->codec.gpio->methods->set_hw_reset(tas->codec.gpio, 0); 625 tas->codec.gpio->methods->set_hw_reset(tas->codec.gpio, 0);
407 msleep(1); 626 msleep(10);
408 627 tas->codec.gpio->methods->all_amps_restore(tas->codec.gpio);
409 tas->acr &= ~TAS_ACR_ANALOG_PDOWN;
410 tas->acr |= TAS_ACR_B_MONAUREAL | TAS_ACR_B_MON_SEL_RIGHT;
411 if (tas_write_reg(tas, TAS_REG_ACR, 1, &tas->acr))
412 return -ENODEV;
413 628
414 tmp = TAS_MCS_SCLK64 | TAS_MCS_SPORT_MODE_I2S | TAS_MCS_SPORT_WL_24BIT; 629 tmp = TAS_MCS_SCLK64 | TAS_MCS_SPORT_MODE_I2S | TAS_MCS_SPORT_WL_24BIT;
415 if (tas_write_reg(tas, TAS_REG_MCS, 1, &tmp)) 630 if (tas_write_reg(tas, TAS_REG_MCS, 1, &tmp))
416 return -ENODEV; 631 return -ENODEV;
417 632
633 tas->acr |= TAS_ACR_ANALOG_PDOWN | TAS_ACR_B_MONAUREAL |
634 TAS_ACR_B_MON_SEL_RIGHT;
635 if (tas_write_reg(tas, TAS_REG_ACR, 1, &tas->acr))
636 return -ENODEV;
637
418 tmp = 0; 638 tmp = 0;
419 if (tas_write_reg(tas, TAS_REG_MCS2, 1, &tmp)) 639 if (tas_write_reg(tas, TAS_REG_MCS2, 1, &tmp))
420 return -ENODEV; 640 return -ENODEV;
421 641
642 tas3004_set_drc(tas);
643
644 /* Set treble & bass to 0dB */
645 tas->treble = TAS3004_TREBLE_ZERO;
646 tas->bass = TAS3004_BASS_ZERO;
647 tas_set_treble(tas);
648 tas_set_bass(tas);
649
650 tas->acr &= ~TAS_ACR_ANALOG_PDOWN;
651 if (tas_write_reg(tas, TAS_REG_ACR, 1, &tas->acr))
652 return -ENODEV;
653
654 return 0;
655}
656
657static int tas_switch_clock(struct codec_info_item *cii, enum clock_switch clock)
658{
659 struct tas *tas = cii->codec_data;
660
661 switch(clock) {
662 case CLOCK_SWITCH_PREPARE_SLAVE:
663 /* Clocks are going away, mute mute mute */
664 tas->codec.gpio->methods->all_amps_off(tas->codec.gpio);
665 tas->hw_enabled = 0;
666 break;
667 case CLOCK_SWITCH_SLAVE:
668 /* Clocks are back, re-init the codec */
669 tas_reset_init(tas);
670 tas_set_volume(tas);
671 tas_set_mixer(tas);
672 tas->hw_enabled = 1;
673 tas->codec.gpio->methods->all_amps_restore(tas->codec.gpio);
674 break;
675 default:
676 /* doesn't happen as of now */
677 return -EINVAL;
678 }
422 return 0; 679 return 0;
423} 680}
424 681
@@ -427,6 +684,7 @@ static int tas_reset_init(struct tas *tas)
427 * our i2c device is suspended, and then take note of that! */ 684 * our i2c device is suspended, and then take note of that! */
428static int tas_suspend(struct tas *tas) 685static int tas_suspend(struct tas *tas)
429{ 686{
687 tas->hw_enabled = 0;
430 tas->acr |= TAS_ACR_ANALOG_PDOWN; 688 tas->acr |= TAS_ACR_ANALOG_PDOWN;
431 tas_write_reg(tas, TAS_REG_ACR, 1, &tas->acr); 689 tas_write_reg(tas, TAS_REG_ACR, 1, &tas->acr);
432 return 0; 690 return 0;
@@ -438,6 +696,7 @@ static int tas_resume(struct tas *tas)
438 tas_reset_init(tas); 696 tas_reset_init(tas);
439 tas_set_volume(tas); 697 tas_set_volume(tas);
440 tas_set_mixer(tas); 698 tas_set_mixer(tas);
699 tas->hw_enabled = 1;
441 return 0; 700 return 0;
442} 701}
443 702
@@ -463,6 +722,7 @@ static struct codec_info tas_codec_info = {
463 .bus_factor = 64, 722 .bus_factor = 64,
464 .owner = THIS_MODULE, 723 .owner = THIS_MODULE,
465 .usable = tas_usable, 724 .usable = tas_usable,
725 .switch_clock = tas_switch_clock,
466#ifdef CONFIG_PM 726#ifdef CONFIG_PM
467 .suspend = _tas_suspend, 727 .suspend = _tas_suspend,
468 .resume = _tas_resume, 728 .resume = _tas_resume,
@@ -483,6 +743,7 @@ static int tas_init_codec(struct aoa_codec *codec)
483 printk(KERN_ERR PFX "tas failed to initialise\n"); 743 printk(KERN_ERR PFX "tas failed to initialise\n");
484 return -ENXIO; 744 return -ENXIO;
485 } 745 }
746 tas->hw_enabled = 1;
486 747
487 if (tas->codec.soundbus_dev->attach_codec(tas->codec.soundbus_dev, 748 if (tas->codec.soundbus_dev->attach_codec(tas->codec.soundbus_dev,
488 aoa_get_card(), 749 aoa_get_card(),
@@ -515,6 +776,22 @@ static int tas_init_codec(struct aoa_codec *codec)
515 if (err) 776 if (err)
516 goto error; 777 goto error;
517 778
779 err = aoa_snd_ctl_add(snd_ctl_new1(&drc_range_control, tas));
780 if (err)
781 goto error;
782
783 err = aoa_snd_ctl_add(snd_ctl_new1(&drc_switch_control, tas));
784 if (err)
785 goto error;
786
787 err = aoa_snd_ctl_add(snd_ctl_new1(&treble_control, tas));
788 if (err)
789 goto error;
790
791 err = aoa_snd_ctl_add(snd_ctl_new1(&bass_control, tas));
792 if (err)
793 goto error;
794
518 return 0; 795 return 0;
519 error: 796 error:
520 tas->codec.soundbus_dev->detach_codec(tas->codec.soundbus_dev, tas); 797 tas->codec.soundbus_dev->detach_codec(tas->codec.soundbus_dev, tas);
@@ -548,6 +825,8 @@ static int tas_create(struct i2c_adapter *adapter,
548 tas->i2c.driver = &tas_driver; 825 tas->i2c.driver = &tas_driver;
549 tas->i2c.adapter = adapter; 826 tas->i2c.adapter = adapter;
550 tas->i2c.addr = addr; 827 tas->i2c.addr = addr;
828 /* seems that half is a saner default */
829 tas->drc_range = TAS3004_DRC_MAX / 2;
551 strlcpy(tas->i2c.name, "tas audio codec", I2C_NAME_SIZE-1); 830 strlcpy(tas->i2c.name, "tas audio codec", I2C_NAME_SIZE-1);
552 831
553 if (i2c_attach_client(&tas->i2c)) { 832 if (i2c_attach_client(&tas->i2c)) {
@@ -564,7 +843,9 @@ static int tas_create(struct i2c_adapter *adapter,
564 if (aoa_codec_register(&tas->codec)) { 843 if (aoa_codec_register(&tas->codec)) {
565 goto detach; 844 goto detach;
566 } 845 }
567 printk(KERN_DEBUG "snd-aoa-codec-tas: created and attached tas instance\n"); 846 printk(KERN_DEBUG
847 "snd-aoa-codec-tas: tas found, addr 0x%02x on %s\n",
848 addr, node->full_name);
568 return 0; 849 return 0;
569 detach: 850 detach:
570 i2c_detach_client(&tas->i2c); 851 i2c_detach_client(&tas->i2c);
diff --git a/sound/aoa/codecs/snd-aoa-codec-tas.h b/sound/aoa/codecs/snd-aoa-codec-tas.h
index daf81f45d83a..ae177e3466e6 100644
--- a/sound/aoa/codecs/snd-aoa-codec-tas.h
+++ b/sound/aoa/codecs/snd-aoa-codec-tas.h
@@ -44,4 +44,12 @@
44#define TAS_REG_LEFT_BIQUAD6 0x10 44#define TAS_REG_LEFT_BIQUAD6 0x10
45#define TAS_REG_RIGHT_BIQUAD6 0x19 45#define TAS_REG_RIGHT_BIQUAD6 0x19
46 46
47#define TAS_REG_LEFT_LOUDNESS 0x21
48#define TAS_REG_RIGHT_LOUDNESS 0x22
49#define TAS_REG_LEFT_LOUDNESS_GAIN 0x23
50#define TAS_REG_RIGHT_LOUDNESS_GAIN 0x24
51
52#define TAS3001_DRC_MAX 0x5f
53#define TAS3004_DRC_MAX 0xef
54
47#endif /* __SND_AOA_CODECTASH */ 55#endif /* __SND_AOA_CODECTASH */
diff --git a/sound/aoa/core/snd-aoa-gpio-pmf.c b/sound/aoa/core/snd-aoa-gpio-pmf.c
index 0e9b9bb2a6de..3d57fd1aec4b 100644
--- a/sound/aoa/core/snd-aoa-gpio-pmf.c
+++ b/sound/aoa/core/snd-aoa-gpio-pmf.c
@@ -14,9 +14,13 @@
14static void pmf_gpio_set_##name(struct gpio_runtime *rt, int on)\ 14static void pmf_gpio_set_##name(struct gpio_runtime *rt, int on)\
15{ \ 15{ \
16 struct pmf_args args = { .count = 1, .u[0].v = !on }; \ 16 struct pmf_args args = { .count = 1, .u[0].v = !on }; \
17 \ 17 int rc; \
18 \
18 if (unlikely(!rt)) return; \ 19 if (unlikely(!rt)) return; \
19 pmf_call_function(rt->node, #name "-mute", &args); \ 20 rc = pmf_call_function(rt->node, #name "-mute", &args); \
21 if (rc) \
22 printk(KERN_WARNING "pmf_gpio_set_" #name \
23 " failed, rc: %d\n", rc); \
20 rt->implementation_private &= ~(1<<bit); \ 24 rt->implementation_private &= ~(1<<bit); \
21 rt->implementation_private |= (!!on << bit); \ 25 rt->implementation_private |= (!!on << bit); \
22} \ 26} \
@@ -33,9 +37,13 @@ PMF_GPIO(lineout, 2);
33static void pmf_gpio_set_hw_reset(struct gpio_runtime *rt, int on) 37static void pmf_gpio_set_hw_reset(struct gpio_runtime *rt, int on)
34{ 38{
35 struct pmf_args args = { .count = 1, .u[0].v = !!on }; 39 struct pmf_args args = { .count = 1, .u[0].v = !!on };
40 int rc;
36 41
37 if (unlikely(!rt)) return; 42 if (unlikely(!rt)) return;
38 pmf_call_function(rt->node, "hw-reset", &args); 43 rc = pmf_call_function(rt->node, "hw-reset", &args);
44 if (rc)
45 printk(KERN_WARNING "pmf_gpio_set_hw_reset"
46 " failed, rc: %d\n", rc);
39} 47}
40 48
41static void pmf_gpio_all_amps_off(struct gpio_runtime *rt) 49static void pmf_gpio_all_amps_off(struct gpio_runtime *rt)
diff --git a/sound/aoa/fabrics/snd-aoa-fabric-layout.c b/sound/aoa/fabrics/snd-aoa-fabric-layout.c
index cbc8a3b5cea4..172eb95476c0 100644
--- a/sound/aoa/fabrics/snd-aoa-fabric-layout.c
+++ b/sound/aoa/fabrics/snd-aoa-fabric-layout.c
@@ -77,24 +77,39 @@ struct layout {
77 int pcmid; 77 int pcmid;
78}; 78};
79 79
80MODULE_ALIAS("sound-layout-36");
80MODULE_ALIAS("sound-layout-41"); 81MODULE_ALIAS("sound-layout-41");
81MODULE_ALIAS("sound-layout-45"); 82MODULE_ALIAS("sound-layout-45");
83MODULE_ALIAS("sound-layout-47");
84MODULE_ALIAS("sound-layout-48");
85MODULE_ALIAS("sound-layout-49");
86MODULE_ALIAS("sound-layout-50");
82MODULE_ALIAS("sound-layout-51"); 87MODULE_ALIAS("sound-layout-51");
88MODULE_ALIAS("sound-layout-56");
89MODULE_ALIAS("sound-layout-57");
83MODULE_ALIAS("sound-layout-58"); 90MODULE_ALIAS("sound-layout-58");
84MODULE_ALIAS("sound-layout-60"); 91MODULE_ALIAS("sound-layout-60");
85MODULE_ALIAS("sound-layout-61"); 92MODULE_ALIAS("sound-layout-61");
93MODULE_ALIAS("sound-layout-62");
86MODULE_ALIAS("sound-layout-64"); 94MODULE_ALIAS("sound-layout-64");
87MODULE_ALIAS("sound-layout-65"); 95MODULE_ALIAS("sound-layout-65");
96MODULE_ALIAS("sound-layout-66");
97MODULE_ALIAS("sound-layout-67");
88MODULE_ALIAS("sound-layout-68"); 98MODULE_ALIAS("sound-layout-68");
89MODULE_ALIAS("sound-layout-69"); 99MODULE_ALIAS("sound-layout-69");
90MODULE_ALIAS("sound-layout-70"); 100MODULE_ALIAS("sound-layout-70");
91MODULE_ALIAS("sound-layout-72"); 101MODULE_ALIAS("sound-layout-72");
102MODULE_ALIAS("sound-layout-76");
92MODULE_ALIAS("sound-layout-80"); 103MODULE_ALIAS("sound-layout-80");
93MODULE_ALIAS("sound-layout-82"); 104MODULE_ALIAS("sound-layout-82");
94MODULE_ALIAS("sound-layout-84"); 105MODULE_ALIAS("sound-layout-84");
95MODULE_ALIAS("sound-layout-86"); 106MODULE_ALIAS("sound-layout-86");
107MODULE_ALIAS("sound-layout-90");
96MODULE_ALIAS("sound-layout-92"); 108MODULE_ALIAS("sound-layout-92");
109MODULE_ALIAS("sound-layout-94");
97MODULE_ALIAS("sound-layout-96"); 110MODULE_ALIAS("sound-layout-96");
111MODULE_ALIAS("sound-layout-98");
112MODULE_ALIAS("sound-layout-100");
98 113
99/* onyx with all but microphone connected */ 114/* onyx with all but microphone connected */
100static struct codec_connection onyx_connections_nomic[] = { 115static struct codec_connection onyx_connections_nomic[] = {
@@ -950,11 +965,12 @@ static int aoa_fabric_layout_probe(struct soundbus_dev *sdev)
950 layout_id = (unsigned int *) get_property(sound, "layout-id", NULL); 965 layout_id = (unsigned int *) get_property(sound, "layout-id", NULL);
951 if (!layout_id) 966 if (!layout_id)
952 goto outnodev; 967 goto outnodev;
953 printk(KERN_INFO "snd-aoa-fabric-layout: found bus with layout %d ", *layout_id); 968 printk(KERN_INFO "snd-aoa-fabric-layout: found bus with layout %d\n",
969 *layout_id);
954 970
955 layout = find_layout_by_id(*layout_id); 971 layout = find_layout_by_id(*layout_id);
956 if (!layout) { 972 if (!layout) {
957 printk("(no idea how to handle)\n"); 973 printk(KERN_ERR "snd-aoa-fabric-layout: unknown layout\n");
958 goto outnodev; 974 goto outnodev;
959 } 975 }
960 976
@@ -972,15 +988,17 @@ static int aoa_fabric_layout_probe(struct soundbus_dev *sdev)
972 case 51: /* PowerBook5,4 */ 988 case 51: /* PowerBook5,4 */
973 case 58: /* Mac Mini */ 989 case 58: /* Mac Mini */
974 ldev->gpio.methods = ftr_gpio_methods; 990 ldev->gpio.methods = ftr_gpio_methods;
991 printk(KERN_DEBUG
992 "snd-aoa-fabric-layout: Using direct GPIOs\n");
975 break; 993 break;
976 default: 994 default:
977 ldev->gpio.methods = pmf_gpio_methods; 995 ldev->gpio.methods = pmf_gpio_methods;
996 printk(KERN_DEBUG
997 "snd-aoa-fabric-layout: Using PMF GPIOs\n");
978 } 998 }
979 ldev->selfptr_headphone.ptr = ldev; 999 ldev->selfptr_headphone.ptr = ldev;
980 ldev->selfptr_lineout.ptr = ldev; 1000 ldev->selfptr_lineout.ptr = ldev;
981 sdev->ofdev.dev.driver_data = ldev; 1001 sdev->ofdev.dev.driver_data = ldev;
982
983 printk("(using)\n");
984 list_add(&ldev->list, &layouts_list); 1002 list_add(&ldev->list, &layouts_list);
985 layouts_list_items++; 1003 layouts_list_items++;
986 1004
diff --git a/sound/aoa/soundbus/core.c b/sound/aoa/soundbus/core.c
index abe84a76c835..47b3e3768df0 100644
--- a/sound/aoa/soundbus/core.c
+++ b/sound/aoa/soundbus/core.c
@@ -194,16 +194,6 @@ static struct bus_type soundbus_bus_type = {
194 .dev_attrs = soundbus_dev_attrs, 194 .dev_attrs = soundbus_dev_attrs,
195}; 195};
196 196
197static int __init soundbus_init(void)
198{
199 return bus_register(&soundbus_bus_type);
200}
201
202static void __exit soundbus_exit(void)
203{
204 bus_unregister(&soundbus_bus_type);
205}
206
207int soundbus_add_one(struct soundbus_dev *dev) 197int soundbus_add_one(struct soundbus_dev *dev)
208{ 198{
209 static int devcount; 199 static int devcount;
@@ -246,5 +236,15 @@ void soundbus_unregister_driver(struct soundbus_driver *drv)
246} 236}
247EXPORT_SYMBOL_GPL(soundbus_unregister_driver); 237EXPORT_SYMBOL_GPL(soundbus_unregister_driver);
248 238
249module_init(soundbus_init); 239static int __init soundbus_init(void)
240{
241 return bus_register(&soundbus_bus_type);
242}
243
244static void __exit soundbus_exit(void)
245{
246 bus_unregister(&soundbus_bus_type);
247}
248
249subsys_initcall(soundbus_init);
250module_exit(soundbus_exit); 250module_exit(soundbus_exit);
diff --git a/sound/aoa/soundbus/i2sbus/i2sbus-control.c b/sound/aoa/soundbus/i2sbus/i2sbus-control.c
index f50407952d3c..87beb4ad4d63 100644
--- a/sound/aoa/soundbus/i2sbus/i2sbus-control.c
+++ b/sound/aoa/soundbus/i2sbus/i2sbus-control.c
@@ -6,12 +6,16 @@
6 * GPL v2, can be found in COPYING. 6 * GPL v2, can be found in COPYING.
7 */ 7 */
8 8
9#include <asm/io.h> 9#include <linux/kernel.h>
10#include <linux/delay.h> 10#include <linux/delay.h>
11
12#include <asm/io.h>
11#include <asm/prom.h> 13#include <asm/prom.h>
12#include <asm/macio.h> 14#include <asm/macio.h>
13#include <asm/pmac_feature.h> 15#include <asm/pmac_feature.h>
14#include <asm/pmac_pfunc.h> 16#include <asm/pmac_pfunc.h>
17#include <asm/keylargo.h>
18
15#include "i2sbus.h" 19#include "i2sbus.h"
16 20
17int i2sbus_control_init(struct macio_dev* dev, struct i2sbus_control **c) 21int i2sbus_control_init(struct macio_dev* dev, struct i2sbus_control **c)
@@ -22,26 +26,12 @@ int i2sbus_control_init(struct macio_dev* dev, struct i2sbus_control **c)
22 26
23 INIT_LIST_HEAD(&(*c)->list); 27 INIT_LIST_HEAD(&(*c)->list);
24 28
25 if (of_address_to_resource(dev->ofdev.node, 0, &(*c)->rsrc)) 29 (*c)->macio = dev->bus->chip;
26 goto err;
27 /* we really should be using feature calls instead of mapping
28 * these registers. It's safe for now since no one else is
29 * touching them... */
30 (*c)->controlregs = ioremap((*c)->rsrc.start,
31 sizeof(struct i2s_control_regs));
32 if (!(*c)->controlregs)
33 goto err;
34
35 return 0; 30 return 0;
36 err:
37 kfree(*c);
38 *c = NULL;
39 return -ENODEV;
40} 31}
41 32
42void i2sbus_control_destroy(struct i2sbus_control *c) 33void i2sbus_control_destroy(struct i2sbus_control *c)
43{ 34{
44 iounmap(c->controlregs);
45 kfree(c); 35 kfree(c);
46} 36}
47 37
@@ -93,19 +83,22 @@ int i2sbus_control_enable(struct i2sbus_control *c,
93 struct i2sbus_dev *i2sdev) 83 struct i2sbus_dev *i2sdev)
94{ 84{
95 struct pmf_args args = { .count = 0 }; 85 struct pmf_args args = { .count = 0 };
96 int cc; 86 struct macio_chip *macio = c->macio;
97 87
98 if (i2sdev->enable) 88 if (i2sdev->enable)
99 return pmf_call_one(i2sdev->enable, &args); 89 return pmf_call_one(i2sdev->enable, &args);
100 90
91 if (macio == NULL || macio->base == NULL)
92 return -ENODEV;
93
101 switch (i2sdev->bus_number) { 94 switch (i2sdev->bus_number) {
102 case 0: 95 case 0:
103 cc = in_le32(&c->controlregs->cell_control); 96 /* these need to be locked or done through
104 out_le32(&c->controlregs->cell_control, cc | CTRL_CLOCK_INTF_0_ENABLE); 97 * newly created feature calls! */
98 MACIO_BIS(KEYLARGO_FCR1, KL1_I2S0_ENABLE);
105 break; 99 break;
106 case 1: 100 case 1:
107 cc = in_le32(&c->controlregs->cell_control); 101 MACIO_BIS(KEYLARGO_FCR1, KL1_I2S1_ENABLE);
108 out_le32(&c->controlregs->cell_control, cc | CTRL_CLOCK_INTF_1_ENABLE);
109 break; 102 break;
110 default: 103 default:
111 return -ENODEV; 104 return -ENODEV;
@@ -118,7 +111,7 @@ int i2sbus_control_cell(struct i2sbus_control *c,
118 int enable) 111 int enable)
119{ 112{
120 struct pmf_args args = { .count = 0 }; 113 struct pmf_args args = { .count = 0 };
121 int cc; 114 struct macio_chip *macio = c->macio;
122 115
123 switch (enable) { 116 switch (enable) {
124 case 0: 117 case 0:
@@ -133,18 +126,22 @@ int i2sbus_control_cell(struct i2sbus_control *c,
133 printk(KERN_ERR "i2sbus: INVALID CELL ENABLE VALUE\n"); 126 printk(KERN_ERR "i2sbus: INVALID CELL ENABLE VALUE\n");
134 return -ENODEV; 127 return -ENODEV;
135 } 128 }
129
130 if (macio == NULL || macio->base == NULL)
131 return -ENODEV;
132
136 switch (i2sdev->bus_number) { 133 switch (i2sdev->bus_number) {
137 case 0: 134 case 0:
138 cc = in_le32(&c->controlregs->cell_control); 135 if (enable)
139 cc &= ~CTRL_CLOCK_CELL_0_ENABLE; 136 MACIO_BIS(KEYLARGO_FCR1, KL1_I2S0_CELL_ENABLE);
140 cc |= enable * CTRL_CLOCK_CELL_0_ENABLE; 137 else
141 out_le32(&c->controlregs->cell_control, cc); 138 MACIO_BIC(KEYLARGO_FCR1, KL1_I2S0_CELL_ENABLE);
142 break; 139 break;
143 case 1: 140 case 1:
144 cc = in_le32(&c->controlregs->cell_control); 141 if (enable)
145 cc &= ~CTRL_CLOCK_CELL_1_ENABLE; 142 MACIO_BIS(KEYLARGO_FCR1, KL1_I2S1_CELL_ENABLE);
146 cc |= enable * CTRL_CLOCK_CELL_1_ENABLE; 143 else
147 out_le32(&c->controlregs->cell_control, cc); 144 MACIO_BIC(KEYLARGO_FCR1, KL1_I2S1_CELL_ENABLE);
148 break; 145 break;
149 default: 146 default:
150 return -ENODEV; 147 return -ENODEV;
@@ -157,7 +154,7 @@ int i2sbus_control_clock(struct i2sbus_control *c,
157 int enable) 154 int enable)
158{ 155{
159 struct pmf_args args = { .count = 0 }; 156 struct pmf_args args = { .count = 0 };
160 int cc; 157 struct macio_chip *macio = c->macio;
161 158
162 switch (enable) { 159 switch (enable) {
163 case 0: 160 case 0:
@@ -172,18 +169,22 @@ int i2sbus_control_clock(struct i2sbus_control *c,
172 printk(KERN_ERR "i2sbus: INVALID CLOCK ENABLE VALUE\n"); 169 printk(KERN_ERR "i2sbus: INVALID CLOCK ENABLE VALUE\n");
173 return -ENODEV; 170 return -ENODEV;
174 } 171 }
172
173 if (macio == NULL || macio->base == NULL)
174 return -ENODEV;
175
175 switch (i2sdev->bus_number) { 176 switch (i2sdev->bus_number) {
176 case 0: 177 case 0:
177 cc = in_le32(&c->controlregs->cell_control); 178 if (enable)
178 cc &= ~CTRL_CLOCK_CLOCK_0_ENABLE; 179 MACIO_BIS(KEYLARGO_FCR1, KL1_I2S0_CLK_ENABLE_BIT);
179 cc |= enable * CTRL_CLOCK_CLOCK_0_ENABLE; 180 else
180 out_le32(&c->controlregs->cell_control, cc); 181 MACIO_BIC(KEYLARGO_FCR1, KL1_I2S0_CLK_ENABLE_BIT);
181 break; 182 break;
182 case 1: 183 case 1:
183 cc = in_le32(&c->controlregs->cell_control); 184 if (enable)
184 cc &= ~CTRL_CLOCK_CLOCK_1_ENABLE; 185 MACIO_BIS(KEYLARGO_FCR1, KL1_I2S1_CLK_ENABLE_BIT);
185 cc |= enable * CTRL_CLOCK_CLOCK_1_ENABLE; 186 else
186 out_le32(&c->controlregs->cell_control, cc); 187 MACIO_BIC(KEYLARGO_FCR1, KL1_I2S1_CLK_ENABLE_BIT);
187 break; 188 break;
188 default: 189 default:
189 return -ENODEV; 190 return -ENODEV;
diff --git a/sound/aoa/soundbus/i2sbus/i2sbus-control.h b/sound/aoa/soundbus/i2sbus/i2sbus-control.h
deleted file mode 100644
index bb05550f730b..000000000000
--- a/sound/aoa/soundbus/i2sbus/i2sbus-control.h
+++ /dev/null
@@ -1,37 +0,0 @@
1/*
2 * i2sbus driver -- bus register definitions
3 *
4 * Copyright 2006 Johannes Berg <johannes@sipsolutions.net>
5 *
6 * GPL v2, can be found in COPYING.
7 */
8#ifndef __I2SBUS_CONTROLREGS_H
9#define __I2SBUS_CONTROLREGS_H
10
11/* i2s control registers, at least what we know about them */
12
13#define __PAD(m,n) u8 __pad##m[n]
14#define _PAD(line, n) __PAD(line, n)
15#define PAD(n) _PAD(__LINE__, (n))
16struct i2s_control_regs {
17 PAD(0x38);
18 __le32 fcr0; /* 0x38 (unknown) */
19 __le32 cell_control; /* 0x3c (fcr1) */
20 __le32 fcr2; /* 0x40 (unknown) */
21 __le32 fcr3; /* 0x44 (fcr3) */
22 __le32 clock_control; /* 0x48 (unknown) */
23 PAD(4);
24 /* total size: 0x50 bytes */
25} __attribute__((__packed__));
26
27#define CTRL_CLOCK_CELL_0_ENABLE (1<<10)
28#define CTRL_CLOCK_CLOCK_0_ENABLE (1<<12)
29#define CTRL_CLOCK_SWRESET_0 (1<<11)
30#define CTRL_CLOCK_INTF_0_ENABLE (1<<13)
31
32#define CTRL_CLOCK_CELL_1_ENABLE (1<<17)
33#define CTRL_CLOCK_CLOCK_1_ENABLE (1<<18)
34#define CTRL_CLOCK_SWRESET_1 (1<<19)
35#define CTRL_CLOCK_INTF_1_ENABLE (1<<20)
36
37#endif /* __I2SBUS_CONTROLREGS_H */
diff --git a/sound/aoa/soundbus/i2sbus/i2sbus-core.c b/sound/aoa/soundbus/i2sbus/i2sbus-core.c
index 01c0724335a3..23190aa6bc7b 100644
--- a/sound/aoa/soundbus/i2sbus/i2sbus-core.c
+++ b/sound/aoa/soundbus/i2sbus/i2sbus-core.c
@@ -7,13 +7,16 @@
7 */ 7 */
8 8
9#include <linux/module.h> 9#include <linux/module.h>
10#include <asm/macio.h>
11#include <asm/dbdma.h>
12#include <linux/pci.h> 10#include <linux/pci.h>
13#include <linux/interrupt.h> 11#include <linux/interrupt.h>
12#include <linux/dma-mapping.h>
13
14#include <sound/driver.h> 14#include <sound/driver.h>
15#include <sound/core.h> 15#include <sound/core.h>
16#include <linux/dma-mapping.h> 16
17#include <asm/macio.h>
18#include <asm/dbdma.h>
19
17#include "../soundbus.h" 20#include "../soundbus.h"
18#include "i2sbus.h" 21#include "i2sbus.h"
19 22
@@ -24,6 +27,11 @@ MODULE_DESCRIPTION("Apple Soundbus: I2S support");
24 * string that macio puts into the relevant device */ 27 * string that macio puts into the relevant device */
25MODULE_ALIAS("of:Ni2sTi2sC"); 28MODULE_ALIAS("of:Ni2sTi2sC");
26 29
30static int force;
31module_param(force, int, 0444);
32MODULE_PARM_DESC(force, "Force loading i2sbus even when"
33 " no layout-id property is present");
34
27static struct of_device_id i2sbus_match[] = { 35static struct of_device_id i2sbus_match[] = {
28 { .name = "i2s" }, 36 { .name = "i2s" },
29 { } 37 { }
@@ -73,12 +81,12 @@ static void i2sbus_release_dev(struct device *dev)
73 if (i2sdev->intfregs) iounmap(i2sdev->intfregs); 81 if (i2sdev->intfregs) iounmap(i2sdev->intfregs);
74 if (i2sdev->out.dbdma) iounmap(i2sdev->out.dbdma); 82 if (i2sdev->out.dbdma) iounmap(i2sdev->out.dbdma);
75 if (i2sdev->in.dbdma) iounmap(i2sdev->in.dbdma); 83 if (i2sdev->in.dbdma) iounmap(i2sdev->in.dbdma);
76 for (i=0;i<3;i++) 84 for (i = aoa_resource_i2smmio; i <= aoa_resource_rxdbdma; i++)
77 if (i2sdev->allocated_resource[i]) 85 if (i2sdev->allocated_resource[i])
78 release_and_free_resource(i2sdev->allocated_resource[i]); 86 release_and_free_resource(i2sdev->allocated_resource[i]);
79 free_dbdma_descriptor_ring(i2sdev, &i2sdev->out.dbdma_ring); 87 free_dbdma_descriptor_ring(i2sdev, &i2sdev->out.dbdma_ring);
80 free_dbdma_descriptor_ring(i2sdev, &i2sdev->in.dbdma_ring); 88 free_dbdma_descriptor_ring(i2sdev, &i2sdev->in.dbdma_ring);
81 for (i=0;i<3;i++) 89 for (i = aoa_resource_i2smmio; i <= aoa_resource_rxdbdma; i++)
82 free_irq(i2sdev->interrupts[i], i2sdev); 90 free_irq(i2sdev->interrupts[i], i2sdev);
83 i2sbus_control_remove_dev(i2sdev->control, i2sdev); 91 i2sbus_control_remove_dev(i2sdev->control, i2sdev);
84 mutex_destroy(&i2sdev->lock); 92 mutex_destroy(&i2sdev->lock);
@@ -101,10 +109,49 @@ static irqreturn_t i2sbus_bus_intr(int irq, void *devid, struct pt_regs *regs)
101 return IRQ_HANDLED; 109 return IRQ_HANDLED;
102} 110}
103 111
104static int force; 112
105module_param(force, int, 0444); 113/*
106MODULE_PARM_DESC(force, "Force loading i2sbus even when" 114 * XXX FIXME: We test the layout_id's here to get the proper way of
107 " no layout-id property is present"); 115 * mapping in various registers, thanks to bugs in Apple device-trees.
116 * We could instead key off the machine model and the name of the i2s
117 * node (i2s-a). This we'll do when we move it all to macio_asic.c
118 * and have that export items for each sub-node too.
119 */
120static int i2sbus_get_and_fixup_rsrc(struct device_node *np, int index,
121 int layout, struct resource *res)
122{
123 struct device_node *parent;
124 int pindex, rc = -ENXIO;
125 u32 *reg;
126
127 /* Machines with layout 76 and 36 (K2 based) have a weird device
128 * tree what we need to special case.
129 * Normal machines just fetch the resource from the i2s-X node.
130 * Darwin further divides normal machines into old and new layouts
131 * with a subtely different code path but that doesn't seem necessary
132 * in practice, they just bloated it. In addition, even on our K2
133 * case the i2s-modem node, if we ever want to handle it, uses the
134 * normal layout
135 */
136 if (layout != 76 && layout != 36)
137 return of_address_to_resource(np, index, res);
138
139 parent = of_get_parent(np);
140 pindex = (index == aoa_resource_i2smmio) ? 0 : 1;
141 rc = of_address_to_resource(parent, pindex, res);
142 if (rc)
143 goto bail;
144 reg = (u32 *)get_property(np, "reg", NULL);
145 if (reg == NULL) {
146 rc = -ENXIO;
147 goto bail;
148 }
149 res->start += reg[index * 2];
150 res->end = res->start + reg[index * 2 + 1] - 1;
151 bail:
152 of_node_put(parent);
153 return rc;
154}
108 155
109/* FIXME: look at device node refcounting */ 156/* FIXME: look at device node refcounting */
110static int i2sbus_add_dev(struct macio_dev *macio, 157static int i2sbus_add_dev(struct macio_dev *macio,
@@ -113,7 +160,8 @@ static int i2sbus_add_dev(struct macio_dev *macio,
113{ 160{
114 struct i2sbus_dev *dev; 161 struct i2sbus_dev *dev;
115 struct device_node *child = NULL, *sound = NULL; 162 struct device_node *child = NULL, *sound = NULL;
116 int i; 163 struct resource *r;
164 int i, layout = 0, rlen;
117 static const char *rnames[] = { "i2sbus: %s (control)", 165 static const char *rnames[] = { "i2sbus: %s (control)",
118 "i2sbus: %s (tx)", 166 "i2sbus: %s (tx)",
119 "i2sbus: %s (rx)" }; 167 "i2sbus: %s (rx)" };
@@ -129,9 +177,6 @@ static int i2sbus_add_dev(struct macio_dev *macio,
129 if (strncmp(np->name, "i2s-", 4)) 177 if (strncmp(np->name, "i2s-", 4))
130 return 0; 178 return 0;
131 179
132 if (macio_irq_count(macio) != 3)
133 return 0;
134
135 dev = kzalloc(sizeof(struct i2sbus_dev), GFP_KERNEL); 180 dev = kzalloc(sizeof(struct i2sbus_dev), GFP_KERNEL);
136 if (!dev) 181 if (!dev)
137 return 0; 182 return 0;
@@ -147,8 +192,9 @@ static int i2sbus_add_dev(struct macio_dev *macio,
147 u32 *layout_id; 192 u32 *layout_id;
148 layout_id = (u32*) get_property(sound, "layout-id", NULL); 193 layout_id = (u32*) get_property(sound, "layout-id", NULL);
149 if (layout_id) { 194 if (layout_id) {
195 layout = *layout_id;
150 snprintf(dev->sound.modalias, 32, 196 snprintf(dev->sound.modalias, 32,
151 "sound-layout-%d", *layout_id); 197 "sound-layout-%d", layout);
152 force = 1; 198 force = 1;
153 } 199 }
154 } 200 }
@@ -178,23 +224,32 @@ static int i2sbus_add_dev(struct macio_dev *macio,
178 dev->bus_number = np->name[4] - 'a'; 224 dev->bus_number = np->name[4] - 'a';
179 INIT_LIST_HEAD(&dev->sound.codec_list); 225 INIT_LIST_HEAD(&dev->sound.codec_list);
180 226
181 for (i=0;i<3;i++) { 227 for (i = aoa_resource_i2smmio; i <= aoa_resource_rxdbdma; i++) {
182 dev->interrupts[i] = -1; 228 dev->interrupts[i] = -1;
183 snprintf(dev->rnames[i], sizeof(dev->rnames[i]), rnames[i], np->name); 229 snprintf(dev->rnames[i], sizeof(dev->rnames[i]),
230 rnames[i], np->name);
184 } 231 }
185 for (i=0;i<3;i++) { 232 for (i = aoa_resource_i2smmio; i <= aoa_resource_rxdbdma; i++) {
186 if (request_irq(macio_irq(macio, i), ints[i], 0, 233 int irq = irq_of_parse_and_map(np, i);
187 dev->rnames[i], dev)) 234 if (request_irq(irq, ints[i], 0, dev->rnames[i], dev))
188 goto err; 235 goto err;
189 dev->interrupts[i] = macio_irq(macio, i); 236 dev->interrupts[i] = irq;
190 } 237 }
191 238
192 for (i=0;i<3;i++) { 239
193 if (of_address_to_resource(np, i, &dev->resources[i])) 240 /* Resource handling is problematic as some device-trees contain
241 * useless crap (ugh ugh ugh). We work around that here by calling
242 * specific functions for calculating the appropriate resources.
243 *
244 * This will all be moved to macio_asic.c at one point
245 */
246 for (i = aoa_resource_i2smmio; i <= aoa_resource_rxdbdma; i++) {
247 if (i2sbus_get_and_fixup_rsrc(np,i,layout,&dev->resources[i]))
194 goto err; 248 goto err;
195 /* if only we could use our resource dev->resources[i]... 249 /* If only we could use our resource dev->resources[i]...
196 * but request_resource doesn't know about parents and 250 * but request_resource doesn't know about parents and
197 * contained resources... */ 251 * contained resources...
252 */
198 dev->allocated_resource[i] = 253 dev->allocated_resource[i] =
199 request_mem_region(dev->resources[i].start, 254 request_mem_region(dev->resources[i].start,
200 dev->resources[i].end - 255 dev->resources[i].end -
@@ -205,13 +260,25 @@ static int i2sbus_add_dev(struct macio_dev *macio,
205 goto err; 260 goto err;
206 } 261 }
207 } 262 }
208 /* should do sanity checking here about length of them */ 263
209 dev->intfregs = ioremap(dev->resources[0].start, 264 r = &dev->resources[aoa_resource_i2smmio];
210 dev->resources[0].end-dev->resources[0].start+1); 265 rlen = r->end - r->start + 1;
211 dev->out.dbdma = ioremap(dev->resources[1].start, 266 if (rlen < sizeof(struct i2s_interface_regs))
212 dev->resources[1].end-dev->resources[1].start+1); 267 goto err;
213 dev->in.dbdma = ioremap(dev->resources[2].start, 268 dev->intfregs = ioremap(r->start, rlen);
214 dev->resources[2].end-dev->resources[2].start+1); 269
270 r = &dev->resources[aoa_resource_txdbdma];
271 rlen = r->end - r->start + 1;
272 if (rlen < sizeof(struct dbdma_regs))
273 goto err;
274 dev->out.dbdma = ioremap(r->start, rlen);
275
276 r = &dev->resources[aoa_resource_rxdbdma];
277 rlen = r->end - r->start + 1;
278 if (rlen < sizeof(struct dbdma_regs))
279 goto err;
280 dev->in.dbdma = ioremap(r->start, rlen);
281
215 if (!dev->intfregs || !dev->out.dbdma || !dev->in.dbdma) 282 if (!dev->intfregs || !dev->out.dbdma || !dev->in.dbdma)
216 goto err; 283 goto err;
217 284
diff --git a/sound/aoa/soundbus/i2sbus/i2sbus.h b/sound/aoa/soundbus/i2sbus/i2sbus.h
index cfa5162e3b0f..0c69d209be50 100644
--- a/sound/aoa/soundbus/i2sbus/i2sbus.h
+++ b/sound/aoa/soundbus/i2sbus/i2sbus.h
@@ -7,20 +7,22 @@
7 */ 7 */
8#ifndef __I2SBUS_H 8#ifndef __I2SBUS_H
9#define __I2SBUS_H 9#define __I2SBUS_H
10#include <asm/dbdma.h>
11#include <linux/interrupt.h> 10#include <linux/interrupt.h>
12#include <sound/pcm.h>
13#include <linux/spinlock.h> 11#include <linux/spinlock.h>
14#include <linux/mutex.h> 12#include <linux/mutex.h>
13
14#include <sound/pcm.h>
15
15#include <asm/prom.h> 16#include <asm/prom.h>
17#include <asm/pmac_feature.h>
18#include <asm/dbdma.h>
19
16#include "i2sbus-interface.h" 20#include "i2sbus-interface.h"
17#include "i2sbus-control.h"
18#include "../soundbus.h" 21#include "../soundbus.h"
19 22
20struct i2sbus_control { 23struct i2sbus_control {
21 volatile struct i2s_control_regs __iomem *controlregs;
22 struct resource rsrc;
23 struct list_head list; 24 struct list_head list;
25 struct macio_chip *macio;
24}; 26};
25 27
26#define MAX_DBDMA_COMMANDS 32 28#define MAX_DBDMA_COMMANDS 32
@@ -45,6 +47,12 @@ struct pcm_info {
45 volatile struct dbdma_regs __iomem *dbdma; 47 volatile struct dbdma_regs __iomem *dbdma;
46}; 48};
47 49
50enum {
51 aoa_resource_i2smmio = 0,
52 aoa_resource_txdbdma,
53 aoa_resource_rxdbdma,
54};
55
48struct i2sbus_dev { 56struct i2sbus_dev {
49 struct soundbus_dev sound; 57 struct soundbus_dev sound;
50 struct macio_dev *macio; 58 struct macio_dev *macio;